@sma1lboy/rove 0.9.180 → 0.9.182

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 (44) hide show
  1. package/dist/cli/{chunk-tx9e0s5t.js → chunk-0pmfap6g.js} +1 -1
  2. package/dist/cli/{chunk-z36wx5ac.js → chunk-1jnvvb50.js} +1 -1
  3. package/dist/cli/{chunk-dh325cpa.js → chunk-2kbhctee.js} +1 -1
  4. package/dist/cli/{chunk-3p61am71.js → chunk-3r7w4jvt.js} +2 -2
  5. package/dist/cli/{chunk-tjm59qf8.js → chunk-40msmve1.js} +1 -1
  6. package/dist/cli/{chunk-c8pv6mpt.js → chunk-470vz1ct.js} +1 -1
  7. package/dist/cli/{chunk-557z89gd.js → chunk-4dk74m3q.js} +1 -1
  8. package/dist/cli/{chunk-hzjq1236.js → chunk-4s6j1hv9.js} +1 -1
  9. package/dist/cli/{chunk-dsmxdtb4.js → chunk-6c4dsp6s.js} +2 -2
  10. package/dist/cli/{chunk-yev3v3q6.js → chunk-7xtj3f4z.js} +1 -1
  11. package/dist/cli/{chunk-2qvy513b.js → chunk-847gwrx2.js} +1 -1
  12. package/dist/cli/{chunk-f2r29dnm.js → chunk-8dyejwv4.js} +1 -1
  13. package/dist/cli/{chunk-gbk1453d.js → chunk-90yrqfvx.js} +1 -1
  14. package/dist/cli/{chunk-40pfs6ds.js → chunk-9s2wqk17.js} +1 -1
  15. package/dist/cli/{chunk-p3s241pd.js → chunk-9yka9rbf.js} +1 -1
  16. package/dist/cli/{chunk-bded5zqf.js → chunk-bhsm9s5p.js} +3 -3
  17. package/dist/cli/{chunk-23c1kx9q.js → chunk-bk629r67.js} +1 -1
  18. package/dist/cli/{chunk-fa7s3d1e.js → chunk-bwrb6c2h.js} +1 -1
  19. package/dist/cli/{chunk-bgfj17b3.js → chunk-cc95msmk.js} +1 -1
  20. package/dist/cli/{chunk-mwndt77s.js → chunk-d8hcpwr6.js} +1 -1
  21. package/dist/cli/{chunk-wwqp6zr9.js → chunk-e7br325r.js} +2 -2
  22. package/dist/cli/{chunk-dg187pbx.js → chunk-eahj40hv.js} +1 -1
  23. package/dist/cli/{chunk-m0y9apst.js → chunk-ey9xbdpm.js} +1 -1
  24. package/dist/cli/{chunk-qs0d7cwe.js → chunk-h14es4mw.js} +1 -1
  25. package/dist/cli/{chunk-5j4qcghg.js → chunk-hvykjgqm.js} +1 -1
  26. package/dist/cli/{chunk-0yhgy5ds.js → chunk-mczdta59.js} +1 -1
  27. package/dist/cli/{chunk-9929x040.js → chunk-pnb48jrh.js} +1 -1
  28. package/dist/cli/{chunk-6tvs0r4z.js → chunk-ptfe9a1h.js} +1 -1
  29. package/dist/cli/{chunk-ynrr6pzv.js → chunk-q7n1rvps.js} +2 -2
  30. package/dist/cli/chunk-qqh9aef5.js +3 -0
  31. package/dist/cli/{chunk-716dt0ht.js → chunk-rwn5npkb.js} +4 -4
  32. package/dist/cli/{chunk-j2tnxxq5.js → chunk-sqk21ey5.js} +1 -1
  33. package/dist/cli/{chunk-bk86axf1.js → chunk-v2pcztn4.js} +1 -1
  34. package/dist/cli/{chunk-3ftykwn3.js → chunk-w0vdm8a0.js} +1 -1
  35. package/dist/cli/{chunk-2cd4jnv1.js → chunk-wjfzgxpw.js} +1 -1
  36. package/dist/cli/{chunk-8wj5b3y4.js → chunk-xkydjarc.js} +1 -1
  37. package/dist/cli/index.js +3 -3
  38. package/dist/cli/kobe.js +1 -1
  39. package/dist/cli/rove.js +1 -1
  40. package/dist/pulse-ynhb2ave.wav +0 -0
  41. package/dist/skills/rove/SKILL.md +30 -5
  42. package/package.json +1 -1
  43. package/dist/cli/chunk-dazqahfp.js +0 -3
  44. package/dist/pulse-n3cq1btw.wav +0 -0
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{KEY_HINTS_ENABLED_KEY,PANE_HINT_USED_KEYS,grammarHelpSections,guideCategory,keyHintsEnabled,keyHintsToggleOn,legendCap,paneHintTokens,paneHintVisible,scopeCategory,statusHintTokens,toggleKeyHints}from"./chunk-dh325cpa.js";import{embeddedTerminalEnv}from"./chunk-ef39ym8f.js";import{readOutdatedCache}from"./chunk-5ygc7rce.js";import{listPaneLaunches}from"./chunk-1x7xjh3h.js";import{deriveTitleFromSessionId,startTaskSessionWithPromptAdapter}from"./chunk-m0y9apst.js";import{canonPath,checkResolutionNotify}from"./chunk-mc33ba6j.js";import{readLastActiveTaskId}from"./chunk-2kb4z64z.js";import{formatBytes}from"./chunk-my20q579.js";import{detectEngineStatuses,probeableEngineIds,summarizeEngines}from"./chunk-n4bhegyh.js";import{ISSUE_STATUSES,isValidCron,nextCronAfter,tightenPluginPermissions}from"./chunk-px6axbd9.js";import"./chunk-xsrcwcjc.js";import"./chunk-jpdf97cx.js";import{DEFAULT_EDITOR_KIND,EDITOR_CUSTOM_KEY,EDITOR_KINDS,EDITOR_KIND_KEY,normalizeEditorKind,resolveEditorLaunch}from"./chunk-zj8y4f4x.js";import{approxCellWidth,approxCharCells,charWidth,displayWidth,padEndCells}from"./chunk-dvcb6mk4.js";import{UpdatePage,openWithSystemViewer,resolveRowSelectionChrome,spawnDetached}from"./chunk-z36wx5ac.js";import{$Fragment,$jsx,$jsxs,DEFAULT_PREFIX_CONFIGURATION,DIRECT_GUIDE_PREFIX_ACTION_ID,FIXED_BINDING_IDS,KobeKeymap,PREFIX_GUIDE_DELAY_MS,PREFIX_HUD_TTL_MS,RemoteOrchestrator,armPrefixFromCurrentStack,attentionEdges,attentionKindFor,bindByIds,bootPaneHost,chipAttentionKind,currentBindingReachability,currentPrefixConfiguration,defaultChordsOf,findBinding,formatChord,hostTargetFps,imeAnchorController,invokeArmedPrefixActionFromCurrentStack,isKittyModifierKeyEvent,isNarrowWidth,keymapVersion,modalActive,narrowSurface,pageCloseBindings,pluginKeybindings,prefixAction,prefixHudClock,prefixHudState,redrawScreen,reloadUserKeybindings,require_react_production,shortcutCaption,showDialog,subscribeKeymapVersion,taskJumpDigit,useAccessor,useBindingStackVersion,useBindings,useDialog,useDialogPaddingX,useFocus,useKV,useLatest,useNotifications,useOptionalDialog,useOptionalFocus,useOptionalKV,useOptionalNotifications,usePaste,useRenderer,useT,useTerminalDimensions,useTheme,userKeybindingsReport}from"./chunk-bded5zqf.js";import"./chunk-764bsyb0.js";import"./chunk-23c1kx9q.js";import{getGlobalDefaultVendor,resolvePreferredVendor,setGlobalDefaultVendor,setRepoLastActiveVendor}from"./chunk-bkm7vxr5.js";import{parseNumstatRows,parsePorcelain,pickPushedChanges,sameWorktreeChanges}from"./chunk-xqw5d5rv.js";import{parsePorcelainRows,unquoteGitPath}from"./chunk-h4n8ffqy.js";import{reloadPluginEngines}from"./chunk-kyr0cyq1.js";import{submitFeedback}from"./chunk-c8pv6mpt.js";import"./chunk-xb9b93ts.js";import{DIRTY_WORKTREE_CODE,PROJECT_SIBLING_BASE,TASK_DELETING_CODE,TaskDeletingError,WORKTREE_BASE_CUSTOM_KEY,worktreeBaseKindOf}from"./chunk-vhq2dhx2.js";import{currentPluginPlatform,loadPluginRegistry,parsePluginManifest,pluginConfigDir,pluginLogPath,pluginManifestPath,qualifiedActionId,readPluginManifest,savePluginRegistry,supportsPlatform}from"./chunk-g2e1dmxh.js";import{PROJECT_DIR_TOKEN,WORKTREE_BASE_KEY,hasProjectDirToken,normalizeWorktreeBase}from"./chunk-63wmhbqs.js";import{ulid}from"./chunk-qkehg2c1.js";import{READ_ONLY_GIT_ENV,readOnlyGitProcessEnv}from"./chunk-6xppe9bj.js";import{matchPathGlob}from"./chunk-kg11c1py.js";import{CURRENT_VERSION}from"./chunk-bgfj17b3.js";import{addTab,closeActiveTab,closeTab,collapseSplit,cycleLeaf,cycleTab,engineTabSpawnFor,expandHome,filterSubdirs,findEditorTab,forgetTaskTabsSnapshot,hasEngineLeaf,initialShellTabs,initialSplit,initialTabs,isTabSplit,joinDrill,joinPicked,leaves,listSubdirs,moveTab,openCommandTab,openContentTab,openEditorTab,pathLeaf,recycleTabs,rehydrateTabs,removeLeaf,renameActiveTab,renameLeaf,reopenTabs,selectTab,setTabAutoTitle,setTabEngineCommand,setTabForkFrom,setTabInitialPrompt,setTabLastTitle,setTabLiveVendor,setTabSessionId,setTabSpawned,setTabSplit,setTabTitle,shellIdentityInput,splitActive,splitLeafNames,splitLeafPtyKey,splitPathForDirSuggest,stripTrailingSlash,sweepOrphanTabsSnapshots,tabCwdFor,tabExitAction,tabPtyKey,tabPtyKeyFor,tabTitle,tabTitleStable,terminalTabsKey,visibleNativeStatus}from"./chunk-2qvy513b.js";import{AUTO_STATUS_KEY,DISPATCHER_KEY,hostedTaskKeys,killHostedSessions,listHostedSessions,openHostedSessionHost,pastePromptWhenEngineUp}from"./chunk-mwndt77s.js";import{execHostForWorktreePath,remoteKeyForRepo}from"./chunk-rc0sqhdh.js";import"./chunk-2apszxn2.js";import"./chunk-g2advs8t.js";import{ensurePtyHostReachable}from"./chunk-gsy8xfh6.js";import{ENGINE_PROTOCOLS,engineCanFork,engineLaunchArgv,engineProtocolKey,getEngineProtocol,pickUnclaimedSessionId,protocolEntry,withPinnedSessionId}from"./chunk-yrmj16b9.js";import"./chunk-rcyasw34.js";import{DEFAULT_TERMINAL_COLORS,formatDefaultColorReply,parseTerminalDefaultColors}from"./chunk-7q67dz4c.js";import{readFirstNonEmptyRepoFile}from"./chunk-92d2t5sk.js";import"./chunk-hape5vwj.js";import{defaultEngineCommand,engineCommandKey,engineDisplayName,engineNameKey,humanizeSlug,interactiveEngineCommand,kobeApiInvocation}from"./chunk-wdrgfezn.js";import{FOCUS_ACCENT_SLOTS,LOCALE_KEY}from"./chunk-6tvs0r4z.js";import"./chunk-z7c6nap0.js";import{currentLang,intlLocale,setLocaleLang,t,tKeys}from"./chunk-fa7s3d1e.js";import{LOCALES}from"./chunk-dazqahfp.js";import{createStateCell}from"./chunk-sdyzxayr.js";import{resolveLoginShell}from"./chunk-b99tf0jr.js";import"./chunk-w25b7xxz.js";import"./chunk-jvxh93nz.js";import{tildify}from"./chunk-fczqwtmq.js";import{connectOrStartDaemon}from"./chunk-te8g5azg.js";import"./chunk-y13681dw.js";import{KobeDaemonClient}from"./chunk-b5mbpv97.js";import{attentionInboxItemKey,automationRunNeedsAttention}from"./chunk-re5ke4fz.js";import"./chunk-mnqxgvyb.js";import{foregroundEngineIn,parsePsSnapshot,psSnapshot}from"./chunk-1jbznr12.js";import{engineEntry,engineSessionIdFromTitle,engineTitleTurnHint,getCapabilities,stripEngineStatusPrefix}from"./chunk-71k66b8f.js";import{maybeStartScheduledRun,spawnCapture}from"./chunk-khj0apc7.js";import{availableEngineIds,installedEngineIds}from"./chunk-5zh5fcpe.js";import"./chunk-w7zv47mp.js";import{roveCliInvocation}from"./chunk-pdnq8dbm.js";import"./chunk-7jkf3tvr.js";import"./chunk-7kysxgbq.js";import"./chunk-r9gfh1zz.js";import{DEFAULT_TASK_VENDOR,TASK_STATUSES}from"./chunk-xy8be792.js";import{addSavedRepo,getSavedRepos,isGitRepo,isRemoteRepoKey,resolveMainRepoRoot}from"./chunk-ejqs2ta9.js";import{loadStateFile}from"./chunk-3jh78dmc.js";import"./chunk-ddcxvbme.js";import{errorMessage,userFacingErrorMessage}from"./chunk-2brn8e1y.js";import{ALL_VENDORS,isBuiltinVendor,nextVendorWithin,prevVendorWithin}from"./chunk-bq3fyc0p.js";import"./chunk-81p6mm0p.js";import{isDev,promptAttachmentsDir,roveStateDir}from"./chunk-q5jhy3t8.js";import"./chunk-t915by6w.js";import{OWNER_ONLY_DIR_MODE,OWNER_ONLY_FILE_MODE}from"./chunk-9prawccj.js";import{activeCliName}from"./chunk-00ehck55.js";import"./chunk-fxs82dsx.js";import{ROVE_PRODUCT_NAME}from"./chunk-sb0ns0c7.js";import"./chunk-pxk2c2vj.js";import{logClientError}from"./chunk-0q6h4vt4.js";import"./chunk-pw6yfj10.js";import{pathIdentity,pathSyntax,pathWithin,samePath}from"./chunk-f10n6063.js";import{defaultDaemonSocketPath}from"./chunk-8cjr5ypt.js";import{readRoveEnv}from"./chunk-hq4b3fca.js";import{__commonJS,__require,__toESM}from"./chunk-wqfp8d9w.js";var require_xterm_headless=__commonJS((exports)=>{(()=>{var e2={5639:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.CircularList=void 0;let i3=s3(7150),r7=s3(802);class n3 extends i3.Disposable{constructor(e4){super(),this._maxLength=e4,this.onDeleteEmitter=this._register(new r7.Emitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new r7.Emitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new r7.Emitter),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e4){if(this._maxLength===e4)return;let t5=Array(e4);for(let s4=0;s4<Math.min(e4,this.length);s4++)t5[s4]=this._array[this._getCyclicIndex(s4)];this._array=t5,this._maxLength=e4,this._startIndex=0}get length(){return this._length}set length(e4){if(e4>this._length)for(let t5=this._length;t5<e4;t5++)this._array[t5]=void 0;this._length=e4}get(e4){return this._array[this._getCyclicIndex(e4)]}set(e4,t5){this._array[this._getCyclicIndex(e4)]=t5}push(e4){this._array[this._getCyclicIndex(this._length)]=e4,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e4,t5,...s4){if(t5){for(let s5=e4;s5<this._length-t5;s5++)this._array[this._getCyclicIndex(s5)]=this._array[this._getCyclicIndex(s5+t5)];this._length-=t5,this.onDeleteEmitter.fire({index:e4,amount:t5})}for(let t6=this._length-1;t6>=e4;t6--)this._array[this._getCyclicIndex(t6+s4.length)]=this._array[this._getCyclicIndex(t6)];for(let t6=0;t6<s4.length;t6++)this._array[this._getCyclicIndex(e4+t6)]=s4[t6];if(s4.length&&this.onInsertEmitter.fire({index:e4,amount:s4.length}),this._length+s4.length>this._maxLength){let e5=this._length+s4.length-this._maxLength;this._startIndex+=e5,this._length=this._maxLength,this.onTrimEmitter.fire(e5)}else this._length+=s4.length}trimStart(e4){e4>this._length&&(e4=this._length),this._startIndex+=e4,this._length-=e4,this.onTrimEmitter.fire(e4)}shiftElements(e4,t5,s4){if(!(t5<=0)){if(e4<0||e4>=this._length)throw Error("start argument out of range");if(e4+s4<0)throw Error("Cannot shift elements in list beyond index 0");if(s4>0){for(let i5=t5-1;i5>=0;i5--)this.set(e4+i5+s4,this.get(e4+i5));let i4=e4+t5+s4-this._length;if(i4>0)for(this._length+=i4;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i4=0;i4<t5;i4++)this.set(e4+i4+s4,this.get(e4+i4))}}_getCyclicIndex(e4){return(this._startIndex+e4)%this._maxLength}}t4.CircularList=n3},7453:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.clone=function e4(t5,s3=5){if(typeof t5!="object")return t5;let i3=Array.isArray(t5)?[]:{};for(let r7 in t5)i3[r7]=s3<=1?t5[r7]:t5[r7]&&e4(t5[r7],s3-1);return i3}},5777:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.CoreTerminal=void 0;let i3=s3(6501),r7=s3(6025),n3=s3(7276),o2=s3(9640),a2=s3(56),h2=s3(4071),c2=s3(7792),l2=s3(6415),u2=s3(5746),d2=s3(5882),f2=s3(2486),_4=s3(3562),p3=s3(8811),g3=s3(802),v3=s3(7150),m3=!1;class b3 extends v3.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new g3.Emitter),this._onScroll.event((e4)=>{this._onScrollApi?.fire(e4.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e4){for(let t5 in e4)this.optionsService.options[t5]=e4[t5]}constructor(e4){super(),this._windowsWrappingHeuristics=this._register(new v3.MutableDisposable),this._onBinary=this._register(new g3.Emitter),this.onBinary=this._onBinary.event,this._onData=this._register(new g3.Emitter),this.onData=this._onData.event,this._onLineFeed=this._register(new g3.Emitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new g3.Emitter),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new g3.Emitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new g3.Emitter),this._instantiationService=new r7.InstantiationService,this.optionsService=this._register(new a2.OptionsService(e4)),this._instantiationService.setService(i3.IOptionsService,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(o2.BufferService)),this._instantiationService.setService(i3.IBufferService,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(n3.LogService)),this._instantiationService.setService(i3.ILogService,this._logService),this.coreService=this._register(this._instantiationService.createInstance(h2.CoreService)),this._instantiationService.setService(i3.ICoreService,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(c2.CoreMouseService)),this._instantiationService.setService(i3.ICoreMouseService,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(l2.UnicodeService)),this._instantiationService.setService(i3.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u2.CharsetService),this._instantiationService.setService(i3.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(p3.OscLinkService),this._instantiationService.setService(i3.IOscLinkService,this._oscLinkService),this._inputHandler=this._register(new f2.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(g3.Event.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(g3.Event.forward(this._bufferService.onResize,this._onResize)),this._register(g3.Event.forward(this.coreService.onData,this._onData)),this._register(g3.Event.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new _4.WriteBuffer((e5,t5)=>this._inputHandler.parse(e5,t5))),this._register(g3.Event.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(e4,t5){this._writeBuffer.write(e4,t5)}writeSync(e4,t5){this._logService.logLevel<=i3.LogLevelEnum.WARN&&!m3&&(this._logService.warn("writeSync is unreliable and will be removed soon."),m3=!0),this._writeBuffer.writeSync(e4,t5)}input(e4,t5=!0){this.coreService.triggerDataEvent(e4,t5)}resize(e4,t5){isNaN(e4)||isNaN(t5)||(e4=Math.max(e4,o2.MINIMUM_COLS),t5=Math.max(t5,o2.MINIMUM_ROWS),this._bufferService.resize(e4,t5))}scroll(e4,t5=!1){this._bufferService.scroll(e4,t5)}scrollLines(e4,t5){this._bufferService.scrollLines(e4,t5)}scrollPages(e4){this.scrollLines(e4*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e4){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e4){let t5=e4-this._bufferService.buffer.ydisp;t5!==0&&this.scrollLines(t5)}registerEscHandler(e4,t5){return this._inputHandler.registerEscHandler(e4,t5)}registerDcsHandler(e4,t5){return this._inputHandler.registerDcsHandler(e4,t5)}registerCsiHandler(e4,t5){return this._inputHandler.registerCsiHandler(e4,t5)}registerOscHandler(e4,t5){return this._inputHandler.registerOscHandler(e4,t5)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e4=!1,t5=this.optionsService.rawOptions.windowsPty;t5&&t5.buildNumber!==void 0&&t5.buildNumber!==void 0?e4=t5.backend==="conpty"&&t5.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e4=!0),e4?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e4=[];e4.push(this.onLineFeed(d2.updateWindowsModeWrappedState.bind(null,this._bufferService))),e4.push(this.registerCsiHandler({final:"H"},()=>((0,d2.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,v3.toDisposable)(()=>{for(let t5 of e4)t5.dispose()})}}}t4.CoreTerminal=b3},2486:function(e3,t4,s3){var i3=this&&this.__decorate||function(e4,t5,s4,i4){var r8,n4=arguments.length,o3=n4<3?t5:i4===null?i4=Object.getOwnPropertyDescriptor(t5,s4):i4;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o3=Reflect.decorate(e4,t5,s4,i4);else for(var a3=e4.length-1;a3>=0;a3--)(r8=e4[a3])&&(o3=(n4<3?r8(o3):n4>3?r8(t5,s4,o3):r8(t5,s4))||o3);return n4>3&&o3&&Object.defineProperty(t5,s4,o3),o3},r7=this&&this.__param||function(e4,t5){return function(s4,i4){t5(s4,i4,e4)}};Object.defineProperty(t4,"__esModule",{value:!0}),t4.InputHandler=t4.WindowsOptionsReportType=void 0,t4.isValidColorIndex=k3;let n3=s3(3534),o2=s3(6760),a2=s3(6717),h2=s3(7150),c2=s3(726),l2=s3(6107),u2=s3(8938),d2=s3(3055),f2=s3(5451),_4=s3(6501),p3=s3(6415),g3=s3(1346),v3=s3(9823),m3=s3(8693),b3=s3(802),S3={"(":0,")":1,"*":2,"+":3,"-":1,".":2},y3=131072;function C3(e4,t5){if(e4>24)return t5.setWinLines||!1;switch(e4){case 1:return!!t5.restoreWin;case 2:return!!t5.minimizeWin;case 3:return!!t5.setWinPosition;case 4:return!!t5.setWinSizePixels;case 5:return!!t5.raiseWin;case 6:return!!t5.lowerWin;case 7:return!!t5.refreshWin;case 8:return!!t5.setWinSizeChars;case 9:return!!t5.maximizeWin;case 10:return!!t5.fullscreenWin;case 11:return!!t5.getWinState;case 13:return!!t5.getWinPosition;case 14:return!!t5.getWinSizePixels;case 15:return!!t5.getScreenSizePixels;case 16:return!!t5.getCellSizePixels;case 18:return!!t5.getWinSizeChars;case 19:return!!t5.getScreenSizeChars;case 20:return!!t5.getIconTitle;case 21:return!!t5.getWinTitle;case 22:return!!t5.pushTitle;case 23:return!!t5.popTitle;case 24:return!!t5.setWinLines}return!1}var w4;(function(e4){e4[e4.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",e4[e4.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(w4||(t4.WindowsOptionsReportType=w4={}));let E3=0;class A4 extends h2.Disposable{getAttrData(){return this._curAttrData}constructor(e4,t5,s4,i4,r8,h3,u3,d3,f3=new a2.EscapeSequenceParser){super(),this._bufferService=e4,this._charsetService=t5,this._coreService=s4,this._logService=i4,this._optionsService=r8,this._oscLinkService=h3,this._coreMouseService=u3,this._unicodeService=d3,this._parser=f3,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new c2.StringToUtf32,this._utf8Decoder=new c2.Utf8ToUtf32,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=l2.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l2.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this._register(new b3.Emitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new b3.Emitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new b3.Emitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new b3.Emitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new b3.Emitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new b3.Emitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new b3.Emitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new b3.Emitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new b3.Emitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new b3.Emitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new b3.Emitter),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new b3.Emitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new b3.Emitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new L2(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate((e5)=>this._activeBuffer=e5.activeBuffer)),this._parser.setCsiHandlerFallback((e5,t6)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e5),params:t6.toArray()})}),this._parser.setEscHandlerFallback((e5)=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e5)})}),this._parser.setExecuteHandlerFallback((e5)=>{this._logService.debug("Unknown EXECUTE code: ",{code:e5})}),this._parser.setOscHandlerFallback((e5,t6,s5)=>{this._logService.debug("Unknown OSC code: ",{identifier:e5,action:t6,data:s5})}),this._parser.setDcsHandlerFallback((e5,t6,s5)=>{t6==="HOOK"&&(s5=s5.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e5),action:t6,payload:s5})}),this._parser.setPrintHandler((e5,t6,s5)=>this.print(e5,t6,s5)),this._parser.registerCsiHandler({final:"@"},(e5)=>this.insertChars(e5)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(e5)=>this.scrollLeft(e5)),this._parser.registerCsiHandler({final:"A"},(e5)=>this.cursorUp(e5)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(e5)=>this.scrollRight(e5)),this._parser.registerCsiHandler({final:"B"},(e5)=>this.cursorDown(e5)),this._parser.registerCsiHandler({final:"C"},(e5)=>this.cursorForward(e5)),this._parser.registerCsiHandler({final:"D"},(e5)=>this.cursorBackward(e5)),this._parser.registerCsiHandler({final:"E"},(e5)=>this.cursorNextLine(e5)),this._parser.registerCsiHandler({final:"F"},(e5)=>this.cursorPrecedingLine(e5)),this._parser.registerCsiHandler({final:"G"},(e5)=>this.cursorCharAbsolute(e5)),this._parser.registerCsiHandler({final:"H"},(e5)=>this.cursorPosition(e5)),this._parser.registerCsiHandler({final:"I"},(e5)=>this.cursorForwardTab(e5)),this._parser.registerCsiHandler({final:"J"},(e5)=>this.eraseInDisplay(e5,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},(e5)=>this.eraseInDisplay(e5,!0)),this._parser.registerCsiHandler({final:"K"},(e5)=>this.eraseInLine(e5,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},(e5)=>this.eraseInLine(e5,!0)),this._parser.registerCsiHandler({final:"L"},(e5)=>this.insertLines(e5)),this._parser.registerCsiHandler({final:"M"},(e5)=>this.deleteLines(e5)),this._parser.registerCsiHandler({final:"P"},(e5)=>this.deleteChars(e5)),this._parser.registerCsiHandler({final:"S"},(e5)=>this.scrollUp(e5)),this._parser.registerCsiHandler({final:"T"},(e5)=>this.scrollDown(e5)),this._parser.registerCsiHandler({final:"X"},(e5)=>this.eraseChars(e5)),this._parser.registerCsiHandler({final:"Z"},(e5)=>this.cursorBackwardTab(e5)),this._parser.registerCsiHandler({final:"`"},(e5)=>this.charPosAbsolute(e5)),this._parser.registerCsiHandler({final:"a"},(e5)=>this.hPositionRelative(e5)),this._parser.registerCsiHandler({final:"b"},(e5)=>this.repeatPrecedingCharacter(e5)),this._parser.registerCsiHandler({final:"c"},(e5)=>this.sendDeviceAttributesPrimary(e5)),this._parser.registerCsiHandler({prefix:">",final:"c"},(e5)=>this.sendDeviceAttributesSecondary(e5)),this._parser.registerCsiHandler({final:"d"},(e5)=>this.linePosAbsolute(e5)),this._parser.registerCsiHandler({final:"e"},(e5)=>this.vPositionRelative(e5)),this._parser.registerCsiHandler({final:"f"},(e5)=>this.hVPosition(e5)),this._parser.registerCsiHandler({final:"g"},(e5)=>this.tabClear(e5)),this._parser.registerCsiHandler({final:"h"},(e5)=>this.setMode(e5)),this._parser.registerCsiHandler({prefix:"?",final:"h"},(e5)=>this.setModePrivate(e5)),this._parser.registerCsiHandler({final:"l"},(e5)=>this.resetMode(e5)),this._parser.registerCsiHandler({prefix:"?",final:"l"},(e5)=>this.resetModePrivate(e5)),this._parser.registerCsiHandler({final:"m"},(e5)=>this.charAttributes(e5)),this._parser.registerCsiHandler({final:"n"},(e5)=>this.deviceStatus(e5)),this._parser.registerCsiHandler({prefix:"?",final:"n"},(e5)=>this.deviceStatusPrivate(e5)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(e5)=>this.softReset(e5)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(e5)=>this.setCursorStyle(e5)),this._parser.registerCsiHandler({final:"r"},(e5)=>this.setScrollRegion(e5)),this._parser.registerCsiHandler({final:"s"},(e5)=>this.saveCursor(e5)),this._parser.registerCsiHandler({final:"t"},(e5)=>this.windowOptions(e5)),this._parser.registerCsiHandler({final:"u"},(e5)=>this.restoreCursor(e5)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(e5)=>this.insertColumns(e5)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(e5)=>this.deleteColumns(e5)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(e5)=>this.selectProtected(e5)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(e5)=>this.requestMode(e5,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(e5)=>this.requestMode(e5,!1)),this._parser.setExecuteHandler(n3.C0.BEL,()=>this.bell()),this._parser.setExecuteHandler(n3.C0.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(n3.C0.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(n3.C0.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(n3.C0.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(n3.C0.BS,()=>this.backspace()),this._parser.setExecuteHandler(n3.C0.HT,()=>this.tab()),this._parser.setExecuteHandler(n3.C0.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(n3.C0.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(n3.C1.IND,()=>this.index()),this._parser.setExecuteHandler(n3.C1.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(n3.C1.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new g3.OscHandler((e5)=>(this.setTitle(e5),this.setIconName(e5),!0))),this._parser.registerOscHandler(1,new g3.OscHandler((e5)=>this.setIconName(e5))),this._parser.registerOscHandler(2,new g3.OscHandler((e5)=>this.setTitle(e5))),this._parser.registerOscHandler(4,new g3.OscHandler((e5)=>this.setOrReportIndexedColor(e5))),this._parser.registerOscHandler(8,new g3.OscHandler((e5)=>this.setHyperlink(e5))),this._parser.registerOscHandler(10,new g3.OscHandler((e5)=>this.setOrReportFgColor(e5))),this._parser.registerOscHandler(11,new g3.OscHandler((e5)=>this.setOrReportBgColor(e5))),this._parser.registerOscHandler(12,new g3.OscHandler((e5)=>this.setOrReportCursorColor(e5))),this._parser.registerOscHandler(104,new g3.OscHandler((e5)=>this.restoreIndexedColor(e5))),this._parser.registerOscHandler(110,new g3.OscHandler((e5)=>this.restoreFgColor(e5))),this._parser.registerOscHandler(111,new g3.OscHandler((e5)=>this.restoreBgColor(e5))),this._parser.registerOscHandler(112,new g3.OscHandler((e5)=>this.restoreCursorColor(e5))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let e5 in o2.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:e5},()=>this.selectCharset("("+e5)),this._parser.registerEscHandler({intermediates:")",final:e5},()=>this.selectCharset(")"+e5)),this._parser.registerEscHandler({intermediates:"*",final:e5},()=>this.selectCharset("*"+e5)),this._parser.registerEscHandler({intermediates:"+",final:e5},()=>this.selectCharset("+"+e5)),this._parser.registerEscHandler({intermediates:"-",final:e5},()=>this.selectCharset("-"+e5)),this._parser.registerEscHandler({intermediates:".",final:e5},()=>this.selectCharset("."+e5)),this._parser.registerEscHandler({intermediates:"/",final:e5},()=>this.selectCharset("/"+e5));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler((e5)=>(this._logService.error("Parsing error: ",e5),e5)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new v3.DcsHandler((e5,t6)=>this.requestStatusString(e5,t6)))}_preserveStack(e4,t5,s4,i4){this._parseStack.paused=!0,this._parseStack.cursorStartX=e4,this._parseStack.cursorStartY=t5,this._parseStack.decodedLength=s4,this._parseStack.position=i4}_logSlowResolvingAsync(e4){this._logService.logLevel<=_4.LogLevelEnum.WARN&&Promise.race([e4,new Promise((e5,t5)=>setTimeout(()=>t5("#SLOW_TIMEOUT"),5000))]).catch((e5)=>{if(e5!=="#SLOW_TIMEOUT")throw e5;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e4,t5){let s4,i4=this._activeBuffer.x,r8=this._activeBuffer.y,n4=0,o3=this._parseStack.paused;if(o3){if(s4=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t5))return this._logSlowResolvingAsync(s4),s4;i4=this._parseStack.cursorStartX,r8=this._parseStack.cursorStartY,this._parseStack.paused=!1,e4.length>y3&&(n4=this._parseStack.position+y3)}if(this._logService.logLevel<=_4.LogLevelEnum.DEBUG&&this._logService.debug("parsing data "+(typeof e4=="string"?` "${e4}"`:` "${Array.prototype.map.call(e4,(e5)=>String.fromCharCode(e5)).join("")}"`)),this._logService.logLevel===_4.LogLevelEnum.TRACE&&this._logService.trace("parsing data (codes)",typeof e4=="string"?e4.split("").map((e5)=>e5.charCodeAt(0)):e4),this._parseBuffer.length<e4.length&&this._parseBuffer.length<y3&&(this._parseBuffer=new Uint32Array(Math.min(e4.length,y3))),o3||this._dirtyRowTracker.clearRange(),e4.length>y3)for(let t6=n4;t6<e4.length;t6+=y3){let n5=t6+y3<e4.length?t6+y3:e4.length,o4=typeof e4=="string"?this._stringDecoder.decode(e4.substring(t6,n5),this._parseBuffer):this._utf8Decoder.decode(e4.subarray(t6,n5),this._parseBuffer);if(s4=this._parser.parse(this._parseBuffer,o4))return this._preserveStack(i4,r8,o4,t6),this._logSlowResolvingAsync(s4),s4}else if(!o3){let t6=typeof e4=="string"?this._stringDecoder.decode(e4,this._parseBuffer):this._utf8Decoder.decode(e4,this._parseBuffer);if(s4=this._parser.parse(this._parseBuffer,t6))return this._preserveStack(i4,r8,t6,0),this._logSlowResolvingAsync(s4),s4}this._activeBuffer.x===i4&&this._activeBuffer.y===r8||this._onCursorMove.fire();let a3=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h3=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h3<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h3,this._bufferService.rows-1),end:Math.min(a3,this._bufferService.rows-1)})}print(e4,t5,s4){let i4,r8,n4=this._charsetService.charset,o3=this._optionsService.rawOptions.screenReaderMode,a3=this._bufferService.cols,h3=this._coreService.decPrivateModes.wraparound,d3=this._coreService.modes.insertMode,f3=this._curAttrData,_5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s4-t5>0&&_5.getWidth(this._activeBuffer.x-1)===2&&_5.setCellFromCodepoint(this._activeBuffer.x-1,0,1,f3);let g4=this._parser.precedingJoinState;for(let v4=t5;v4<s4;++v4){if(i4=e4[v4],i4<127&&n4){let e5=n4[String.fromCharCode(i4)];e5&&(i4=e5.charCodeAt(0))}let t6=this._unicodeService.charProperties(i4,g4);r8=p3.UnicodeService.extractWidth(t6);let s5=p3.UnicodeService.extractShouldJoin(t6),m4=s5?p3.UnicodeService.extractWidth(g4):0;if(g4=t6,o3&&this._onA11yChar.fire((0,c2.stringFromCodePoint)(i4)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r8-m4>a3){if(h3){let e5=_5,t7=this._activeBuffer.x-m4;for(this._activeBuffer.x=m4,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m4>0&&_5 instanceof l2.BufferLine&&_5.copyCellsFrom(e5,t7,0,m4,!1);t7<a3;)e5.setCellFromCodepoint(t7++,0,1,f3)}else if(this._activeBuffer.x=a3-1,r8===2)continue}if(s5&&this._activeBuffer.x){let e5=_5.getWidth(this._activeBuffer.x-1)?1:2;_5.addCodepointToCell(this._activeBuffer.x-e5,i4,r8);for(let e6=r8-m4;--e6>=0;)_5.setCellFromCodepoint(this._activeBuffer.x++,0,0,f3)}else if(d3&&(_5.insertCells(this._activeBuffer.x,r8-m4,this._activeBuffer.getNullCell(f3)),_5.getWidth(a3-1)===2&&_5.setCellFromCodepoint(a3-1,u2.NULL_CELL_CODE,u2.NULL_CELL_WIDTH,f3)),_5.setCellFromCodepoint(this._activeBuffer.x++,i4,r8,f3),r8>0)for(;--r8;)_5.setCellFromCodepoint(this._activeBuffer.x++,0,0,f3)}this._parser.precedingJoinState=g4,this._activeBuffer.x<a3&&s4-t5>0&&_5.getWidth(this._activeBuffer.x)===0&&!_5.hasContent(this._activeBuffer.x)&&_5.setCellFromCodepoint(this._activeBuffer.x,0,1,f3),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e4,t5){return e4.final!=="t"||e4.prefix||e4.intermediates?this._parser.registerCsiHandler(e4,t5):this._parser.registerCsiHandler(e4,(e5)=>!C3(e5.params[0],this._optionsService.rawOptions.windowOptions)||t5(e5))}registerDcsHandler(e4,t5){return this._parser.registerDcsHandler(e4,new v3.DcsHandler(t5))}registerEscHandler(e4,t5){return this._parser.registerEscHandler(e4,t5)}registerOscHandler(e4,t5){return this._parser.registerOscHandler(e4,new g3.OscHandler(t5))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e4=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e4.hasWidth(this._activeBuffer.x)&&!e4.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e4=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e4),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e4=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e4,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e4,t5){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e4,this._activeBuffer.y=this._activeBuffer.scrollTop+t5):(this._activeBuffer.x=e4,this._activeBuffer.y=t5),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e4,t5){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e4,this._activeBuffer.y+t5)}cursorUp(e4){let t5=this._activeBuffer.y-this._activeBuffer.scrollTop;return t5>=0?this._moveCursor(0,-Math.min(t5,e4.params[0]||1)):this._moveCursor(0,-(e4.params[0]||1)),!0}cursorDown(e4){let t5=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t5>=0?this._moveCursor(0,Math.min(t5,e4.params[0]||1)):this._moveCursor(0,e4.params[0]||1),!0}cursorForward(e4){return this._moveCursor(e4.params[0]||1,0),!0}cursorBackward(e4){return this._moveCursor(-(e4.params[0]||1),0),!0}cursorNextLine(e4){return this.cursorDown(e4),this._activeBuffer.x=0,!0}cursorPrecedingLine(e4){return this.cursorUp(e4),this._activeBuffer.x=0,!0}cursorCharAbsolute(e4){return this._setCursor((e4.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e4){return this._setCursor(e4.length>=2?(e4.params[1]||1)-1:0,(e4.params[0]||1)-1),!0}charPosAbsolute(e4){return this._setCursor((e4.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e4){return this._moveCursor(e4.params[0]||1,0),!0}linePosAbsolute(e4){return this._setCursor(this._activeBuffer.x,(e4.params[0]||1)-1),!0}vPositionRelative(e4){return this._moveCursor(0,e4.params[0]||1),!0}hVPosition(e4){return this.cursorPosition(e4),!0}tabClear(e4){let t5=e4.params[0];return t5===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t5===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e4){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t5=e4.params[0]||1;for(;t5--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e4){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t5=e4.params[0]||1;for(;t5--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e4){let t5=e4.params[0];return t5===1&&(this._curAttrData.bg|=536870912),t5!==2&&t5!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e4,t5,s4,i4=!1,r8=!1){let n4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e4);n4.replaceCells(t5,s4,this._activeBuffer.getNullCell(this._eraseAttrData()),r8),i4&&(n4.isWrapped=!1)}_resetBufferLine(e4,t5=!1){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e4);s4&&(s4.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t5),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e4),s4.isWrapped=!1)}eraseInDisplay(e4,t5=!1){let s4;switch(this._restrictCursor(this._bufferService.cols),e4.params[0]){case 0:for(s4=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s4),this._eraseInBufferLine(s4++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t5);s4<this._bufferService.rows;s4++)this._resetBufferLine(s4,t5);this._dirtyRowTracker.markDirty(s4);break;case 1:for(s4=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s4),this._eraseInBufferLine(s4,0,this._activeBuffer.x+1,!0,t5),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s4+1).isWrapped=!1);s4--;)this._resetBufferLine(s4,t5);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s4=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s4-1);s4--;)if(this._activeBuffer.lines.get(this._activeBuffer.ybase+s4)?.getTrimmedLength())break;for(;s4>=0;s4--)this._bufferService.scroll(this._eraseAttrData())}else{for(s4=this._bufferService.rows,this._dirtyRowTracker.markDirty(s4-1);s4--;)this._resetBufferLine(s4,t5);this._dirtyRowTracker.markDirty(0)}break;case 3:let e5=this._activeBuffer.lines.length-this._bufferService.rows;e5>0&&(this._activeBuffer.lines.trimStart(e5),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e5,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e5,0),this._onScroll.fire(0))}return!0}eraseInLine(e4,t5=!1){switch(this._restrictCursor(this._bufferService.cols),e4.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t5);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t5);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t5)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e4){this._restrictCursor();let t5=e4.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s4=this._activeBuffer.ybase+this._activeBuffer.y,i4=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r8=this._bufferService.rows-1+this._activeBuffer.ybase-i4+1;for(;t5--;)this._activeBuffer.lines.splice(r8-1,1),this._activeBuffer.lines.splice(s4,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e4){this._restrictCursor();let t5=e4.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s4=this._activeBuffer.ybase+this._activeBuffer.y,i4;for(i4=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i4=this._bufferService.rows-1+this._activeBuffer.ybase-i4;t5--;)this._activeBuffer.lines.splice(s4,1),this._activeBuffer.lines.splice(i4,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e4){this._restrictCursor();let t5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t5&&(t5.insertCells(this._activeBuffer.x,e4.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e4){this._restrictCursor();let t5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t5&&(t5.deleteCells(this._activeBuffer.x,e4.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e4){let t5=e4.params[0]||1;for(;t5--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e4){let t5=e4.params[0]||1;for(;t5--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(l2.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e4){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t5=e4.params[0]||1;for(let e5=this._activeBuffer.scrollTop;e5<=this._activeBuffer.scrollBottom;++e5){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e5);s4.deleteCells(0,t5,this._activeBuffer.getNullCell(this._eraseAttrData())),s4.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e4){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t5=e4.params[0]||1;for(let e5=this._activeBuffer.scrollTop;e5<=this._activeBuffer.scrollBottom;++e5){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e5);s4.insertCells(0,t5,this._activeBuffer.getNullCell(this._eraseAttrData())),s4.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e4){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t5=e4.params[0]||1;for(let e5=this._activeBuffer.scrollTop;e5<=this._activeBuffer.scrollBottom;++e5){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e5);s4.insertCells(this._activeBuffer.x,t5,this._activeBuffer.getNullCell(this._eraseAttrData())),s4.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e4){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t5=e4.params[0]||1;for(let e5=this._activeBuffer.scrollTop;e5<=this._activeBuffer.scrollBottom;++e5){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e5);s4.deleteCells(this._activeBuffer.x,t5,this._activeBuffer.getNullCell(this._eraseAttrData())),s4.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e4){this._restrictCursor();let t5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t5&&(t5.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e4.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e4){let t5=this._parser.precedingJoinState;if(!t5)return!0;let s4=e4.params[0]||1,i4=p3.UnicodeService.extractWidth(t5),r8=this._activeBuffer.x-i4,n4=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r8),o3=new Uint32Array(n4.length*s4),a3=0;for(let e5=0;e5<n4.length;){let t6=n4.codePointAt(e5)||0;o3[a3++]=t6,e5+=t6>65535?2:1}let h3=a3;for(let e5=1;e5<s4;++e5)o3.copyWithin(h3,0,a3),h3+=a3;return this.print(o3,0,h3),!0}sendDeviceAttributesPrimary(e4){return e4.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(n3.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(n3.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e4){return e4.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(n3.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(n3.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e4.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(n3.C0.ESC+"[>83;40003;0c")),!0}_is(e4){return(this._optionsService.rawOptions.termName+"").indexOf(e4)===0}setMode(e4){for(let t5=0;t5<e4.length;t5++)switch(e4.params[t5]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e4){for(let t5=0;t5<e4.length;t5++)switch(e4.params[t5]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,o2.DEFAULT_CHARSET),this._charsetService.setgCharset(1,o2.DEFAULT_CHARSET),this._charsetService.setgCharset(2,o2.DEFAULT_CHARSET),this._charsetService.setgCharset(3,o2.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1000:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e4){for(let t5=0;t5<e4.length;t5++)switch(e4.params[t5]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e4){for(let t5=0;t5<e4.length;t5++)switch(e4.params[t5]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1000:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e4.params[t5]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e4,t5){let s4=this._coreService.decPrivateModes,{activeProtocol:i4,activeEncoding:r8}=this._coreMouseService,o3=this._coreService,{buffers:a3,cols:h3}=this._bufferService,{active:c3,alt:l3}=a3,u3=this._optionsService.rawOptions,d3=(e5)=>e5?1:2,f3=e4.params[0];return _5=f3,p4=t5?f3===2?4:f3===4?d3(o3.modes.insertMode):f3===12?3:f3===20?d3(u3.convertEol):0:f3===1?d3(s4.applicationCursorKeys):f3===3?u3.windowOptions.setWinLines?h3===80?2:h3===132?1:0:0:f3===6?d3(s4.origin):f3===7?d3(s4.wraparound):f3===8?3:f3===9?d3(i4==="X10"):f3===12?d3(u3.cursorBlink):f3===25?d3(!o3.isCursorHidden):f3===45?d3(s4.reverseWraparound):f3===66?d3(s4.applicationKeypad):f3===67?4:f3===1000?d3(i4==="VT200"):f3===1002?d3(i4==="DRAG"):f3===1003?d3(i4==="ANY"):f3===1004?d3(s4.sendFocus):f3===1005?4:f3===1006?d3(r8==="SGR"):f3===1015?4:f3===1016?d3(r8==="SGR_PIXELS"):f3===1048?1:f3===47||f3===1047||f3===1049?d3(c3===l3):f3===2004?d3(s4.bracketedPasteMode):f3===2026?d3(s4.synchronizedOutput):0,o3.triggerDataEvent(`${n3.C0.ESC}[${t5?"":"?"}${_5};${p4}$y`),!0;var _5,p4}_updateAttrColor(e4,t5,s4,i4,r8){return t5===2?(e4|=50331648,e4&=-16777216,e4|=f2.AttributeData.fromColorRGB([s4,i4,r8])):t5===5&&(e4&=-50331904,e4|=33554432|255&s4),e4}_extractColor(e4,t5,s4){let i4=[0,0,-1,0,0,0],r8=0,n4=0;do{if(i4[n4+r8]=e4.params[t5+n4],e4.hasSubParams(t5+n4)){let s5=e4.getSubParams(t5+n4),o3=0;do i4[1]===5&&(r8=1),i4[n4+o3+1+r8]=s5[o3];while(++o3<s5.length&&o3+n4+1+r8<i4.length);break}if(i4[1]===5&&n4+r8>=2||i4[1]===2&&n4+r8>=5)break;i4[1]&&(r8=1)}while(++n4+t5<e4.length&&n4+r8<i4.length);for(let e5=2;e5<i4.length;++e5)i4[e5]===-1&&(i4[e5]=0);switch(i4[0]){case 38:s4.fg=this._updateAttrColor(s4.fg,i4[1],i4[3],i4[4],i4[5]);break;case 48:s4.bg=this._updateAttrColor(s4.bg,i4[1],i4[3],i4[4],i4[5]);break;case 58:s4.extended=s4.extended.clone(),s4.extended.underlineColor=this._updateAttrColor(s4.extended.underlineColor,i4[1],i4[3],i4[4],i4[5])}return n4}_processUnderline(e4,t5){t5.extended=t5.extended.clone(),(!~e4||e4>5)&&(e4=1),t5.extended.underlineStyle=e4,t5.fg|=268435456,e4===0&&(t5.fg&=-268435457),t5.updateExtended()}_processSGR0(e4){e4.fg=l2.DEFAULT_ATTR_DATA.fg,e4.bg=l2.DEFAULT_ATTR_DATA.bg,e4.extended=e4.extended.clone(),e4.extended.underlineStyle=0,e4.extended.underlineColor&=-67108864,e4.updateExtended()}charAttributes(e4){if(e4.length===1&&e4.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t5=e4.length,s4,i4=this._curAttrData;for(let r8=0;r8<t5;r8++)s4=e4.params[r8],s4>=30&&s4<=37?(i4.fg&=-50331904,i4.fg|=16777216|s4-30):s4>=40&&s4<=47?(i4.bg&=-50331904,i4.bg|=16777216|s4-40):s4>=90&&s4<=97?(i4.fg&=-50331904,i4.fg|=16777224|s4-90):s4>=100&&s4<=107?(i4.bg&=-50331904,i4.bg|=16777224|s4-100):s4===0?this._processSGR0(i4):s4===1?i4.fg|=134217728:s4===3?i4.bg|=67108864:s4===4?(i4.fg|=268435456,this._processUnderline(e4.hasSubParams(r8)?e4.getSubParams(r8)[0]:1,i4)):s4===5?i4.fg|=536870912:s4===7?i4.fg|=67108864:s4===8?i4.fg|=1073741824:s4===9?i4.fg|=2147483648:s4===2?i4.bg|=134217728:s4===21?this._processUnderline(2,i4):s4===22?(i4.fg&=-134217729,i4.bg&=-134217729):s4===23?i4.bg&=-67108865:s4===24?(i4.fg&=-268435457,this._processUnderline(0,i4)):s4===25?i4.fg&=-536870913:s4===27?i4.fg&=-67108865:s4===28?i4.fg&=-1073741825:s4===29?i4.fg&=2147483647:s4===39?(i4.fg&=-67108864,i4.fg|=16777215&l2.DEFAULT_ATTR_DATA.fg):s4===49?(i4.bg&=-67108864,i4.bg|=16777215&l2.DEFAULT_ATTR_DATA.bg):s4===38||s4===48||s4===58?r8+=this._extractColor(e4,r8,i4):s4===53?i4.bg|=1073741824:s4===55?i4.bg&=-1073741825:s4===59?(i4.extended=i4.extended.clone(),i4.extended.underlineColor=-1,i4.updateExtended()):s4===100?(i4.fg&=-67108864,i4.fg|=16777215&l2.DEFAULT_ATTR_DATA.fg,i4.bg&=-67108864,i4.bg|=16777215&l2.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",s4);return!0}deviceStatus(e4){switch(e4.params[0]){case 5:this._coreService.triggerDataEvent(`${n3.C0.ESC}[0n`);break;case 6:let e5=this._activeBuffer.y+1,t5=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n3.C0.ESC}[${e5};${t5}R`)}return!0}deviceStatusPrivate(e4){if(e4.params[0]===6){let e5=this._activeBuffer.y+1,t5=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n3.C0.ESC}[?${e5};${t5}R`)}return!0}softReset(e4){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=l2.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e4){let t5=e4.length===0?1:e4.params[0];if(t5===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t5){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar"}let e5=t5%2==1;this._coreService.decPrivateModes.cursorBlink=e5}return!0}setScrollRegion(e4){let t5=e4.params[0]||1,s4;return(e4.length<2||(s4=e4.params[1])>this._bufferService.rows||s4===0)&&(s4=this._bufferService.rows),s4>t5&&(this._activeBuffer.scrollTop=t5-1,this._activeBuffer.scrollBottom=s4-1,this._setCursor(0,0)),!0}windowOptions(e4){if(!C3(e4.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t5=e4.length>1?e4.params[1]:0;switch(e4.params[0]){case 14:t5!==2&&this._onRequestWindowsOptionsReport.fire(w4.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(w4.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${n3.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:t5!==0&&t5!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),t5!==0&&t5!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:t5!==0&&t5!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),t5!==0&&t5!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e4){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e4){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e4){return this._windowTitle=e4,this._onTitleChange.fire(e4),!0}setIconName(e4){return this._iconName=e4,!0}setOrReportIndexedColor(e4){let t5=[],s4=e4.split(";");for(;s4.length>1;){let e5=s4.shift(),i4=s4.shift();if(/^\d+$/.exec(e5)){let s5=parseInt(e5);if(k3(s5))if(i4==="?")t5.push({type:0,index:s5});else{let e6=(0,m3.parseColor)(i4);e6&&t5.push({type:1,index:s5,color:e6})}}}return t5.length&&this._onColor.fire(t5),!0}setHyperlink(e4){let t5=e4.indexOf(";");if(t5===-1)return!0;let s4=e4.slice(0,t5).trim(),i4=e4.slice(t5+1);return i4?this._createHyperlink(s4,i4):!s4.trim()&&this._finishHyperlink()}_createHyperlink(e4,t5){this._getCurrentLinkId()&&this._finishHyperlink();let s4=e4.split(":"),i4,r8=s4.findIndex((e5)=>e5.startsWith("id="));return r8!==-1&&(i4=s4[r8].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i4,uri:t5}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e4,t5){let s4=e4.split(";");for(let e5=0;e5<s4.length&&!(t5>=this._specialColors.length);++e5,++t5)if(s4[e5]==="?")this._onColor.fire([{type:0,index:this._specialColors[t5]}]);else{let i4=(0,m3.parseColor)(s4[e5]);i4&&this._onColor.fire([{type:1,index:this._specialColors[t5],color:i4}])}return!0}setOrReportFgColor(e4){return this._setOrReportSpecialColor(e4,0)}setOrReportBgColor(e4){return this._setOrReportSpecialColor(e4,1)}setOrReportCursorColor(e4){return this._setOrReportSpecialColor(e4,2)}restoreIndexedColor(e4){if(!e4)return this._onColor.fire([{type:2}]),!0;let t5=[],s4=e4.split(";");for(let e5=0;e5<s4.length;++e5)if(/^\d+$/.exec(s4[e5])){let i4=parseInt(s4[e5]);k3(i4)&&t5.push({type:2,index:i4})}return t5.length&&this._onColor.fire(t5),!0}restoreFgColor(e4){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e4){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e4){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,o2.DEFAULT_CHARSET),!0}selectCharset(e4){return e4.length!==2?(this.selectDefaultCharset(),!0):(e4[0]==="/"||this._charsetService.setgCharset(S3[e4[0]],o2.CHARSETS[e4[1]]||o2.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e4=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e4,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=l2.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l2.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e4){return this._charsetService.setgLevel(e4),!0}screenAlignmentPattern(){let e4=new d2.CellData;e4.content=4194373,e4.fg=this._curAttrData.fg,e4.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t5=0;t5<this._bufferService.rows;++t5){let s4=this._activeBuffer.ybase+this._activeBuffer.y+t5,i4=this._activeBuffer.lines.get(s4);i4&&(i4.fill(e4),i4.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e4,t5){let s4=this._bufferService.buffer,i4=this._optionsService.rawOptions;return((e5)=>(this._coreService.triggerDataEvent(`${n3.C0.ESC}${e5}${n3.C0.ESC}\\`),!0))(e4==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e4==='"p'?'P1$r61;1"p':e4==="r"?`P1$r${s4.scrollTop+1};${s4.scrollBottom+1}r`:e4==="m"?"P1$r0m":e4===" q"?`P1$r${{block:2,underline:4,bar:6}[i4.cursorStyle]-(i4.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e4,t5){this._dirtyRowTracker.markRangeDirty(e4,t5)}}t4.InputHandler=A4;let L2=class{constructor(e4){this._bufferService=e4,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e4){e4<this.start?this.start=e4:e4>this.end&&(this.end=e4)}markRangeDirty(e4,t5){e4>t5&&(E3=e4,e4=t5,t5=E3),e4<this.start&&(this.start=e4),t5>this.end&&(this.end=t5)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function k3(e4){return 0<=e4&&e4<256}L2=i3([r7(0,_4.IBufferService)],L2)},701:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.isChromeOS=t4.isLinux=t4.isWindows=t4.isIphone=t4.isIpad=t4.isMac=t4.isSafari=t4.isLegacyEdge=t4.isFirefox=t4.isNode=void 0,t4.getSafariVersion=function(){if(!t4.isSafari)return 0;let e4=s3.match(/Version\/(\d+)/);return e4===null||e4.length<2?0:parseInt(e4[1])},t4.isNode=typeof process<"u"&&"title"in process;let s3=t4.isNode?"node":navigator.userAgent,i3=t4.isNode?"node":navigator.platform;t4.isFirefox=s3.includes("Firefox"),t4.isLegacyEdge=s3.includes("Edge"),t4.isSafari=/^((?!chrome|android).)*safari/i.test(s3),t4.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(i3),t4.isIpad=i3==="iPad",t4.isIphone=i3==="iPhone",t4.isWindows=["Windows","Win16","Win32","WinCE"].includes(i3),t4.isLinux=i3.indexOf("Linux")>=0,t4.isChromeOS=/\bCrOS\b/.test(s3)},6168:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.DebouncedIdleTask=t4.IdleTaskQueue=t4.PriorityTaskQueue=void 0;let i3=s3(701);class r7{constructor(){this._tasks=[],this._i=0}enqueue(e4){this._tasks.push(e4),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e4){this._idleCallback=void 0;let t5=0,s4=0,i4=e4.timeRemaining(),r8=0;for(;this._i<this._tasks.length;){if(t5=performance.now(),this._tasks[this._i]()||this._i++,t5=Math.max(1,performance.now()-t5),s4=Math.max(t5,s4),r8=e4.timeRemaining(),1.5*s4>r8)return i4-t5<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i4-t5))}ms`),void this._start();i4=r8}this.clear()}}class n3 extends r7{_requestCallback(e4){return setTimeout(()=>e4(this._createDeadline(16)))}_cancelCallback(e4){clearTimeout(e4)}_createDeadline(e4){let t5=performance.now()+e4;return{timeRemaining:()=>Math.max(0,t5-performance.now())}}}t4.PriorityTaskQueue=n3,t4.IdleTaskQueue=!i3.isNode&&"requestIdleCallback"in window?class extends r7{_requestCallback(e4){return requestIdleCallback(e4)}_cancelCallback(e4){cancelIdleCallback(e4)}}:n3,t4.DebouncedIdleTask=class{constructor(){this._queue=new t4.IdleTaskQueue}set(e4){this._queue.clear(),this._queue.enqueue(e4)}flush(){this._queue.flush()}}},5882:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.updateWindowsModeWrappedState=function(e4){let t5=e4.buffer.lines.get(e4.buffer.ybase+e4.buffer.y-1),s4=t5?.get(e4.cols-1),r7=e4.buffer.lines.get(e4.buffer.ybase+e4.buffer.y);r7&&s4&&(r7.isWrapped=s4[i3.CHAR_DATA_CODE_INDEX]!==i3.NULL_CELL_CODE&&s4[i3.CHAR_DATA_CODE_INDEX]!==i3.WHITESPACE_CELL_CODE)};let i3=s3(8938)},5451:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.ExtendedAttrs=t4.AttributeData=void 0;class s3{constructor(){this.fg=0,this.bg=0,this.extended=new i3}static toColorRGB(e4){return[e4>>>16&255,e4>>>8&255,255&e4]}static fromColorRGB(e4){return(255&e4[0])<<16|(255&e4[1])<<8|255&e4[2]}clone(){let e4=new s3;return e4.fg=this.fg,e4.bg=this.bg,e4.extended=this.extended.clone(),e4}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}t4.AttributeData=s3;class i3{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e4){this._ext=e4}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e4){this._ext&=-469762049,this._ext|=e4<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e4){this._ext&=-67108864,this._ext|=67108863&e4}get urlId(){return this._urlId}set urlId(e4){this._urlId=e4}get underlineVariantOffset(){let e4=(3758096384&this._ext)>>29;return e4<0?4294967288^e4:e4}set underlineVariantOffset(e4){this._ext&=536870911,this._ext|=e4<<29&3758096384}constructor(e4=0,t5=0){this._ext=0,this._urlId=0,this._ext=e4,this._urlId=t5}clone(){return new i3(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}t4.ExtendedAttrs=i3},1073:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.Buffer=t4.MAX_BUFFER_SIZE=void 0;let i3=s3(5639),r7=s3(6168),n3=s3(5451),o2=s3(6107),a2=s3(732),h2=s3(3055),c2=s3(8938),l2=s3(8158),u2=s3(6760);t4.MAX_BUFFER_SIZE=4294967295,t4.Buffer=class{constructor(e4,t5,s4){this._hasScrollback=e4,this._optionsService=t5,this._bufferService=s4,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=o2.DEFAULT_ATTR_DATA.clone(),this.savedCharset=u2.DEFAULT_CHARSET,this.markers=[],this._nullCell=h2.CellData.fromCharData([0,c2.NULL_CELL_CHAR,c2.NULL_CELL_WIDTH,c2.NULL_CELL_CODE]),this._whitespaceCell=h2.CellData.fromCharData([0,c2.WHITESPACE_CELL_CHAR,c2.WHITESPACE_CELL_WIDTH,c2.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new r7.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new i3.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e4){return e4?(this._nullCell.fg=e4.fg,this._nullCell.bg=e4.bg,this._nullCell.extended=e4.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new n3.ExtendedAttrs),this._nullCell}getWhitespaceCell(e4){return e4?(this._whitespaceCell.fg=e4.fg,this._whitespaceCell.bg=e4.bg,this._whitespaceCell.extended=e4.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new n3.ExtendedAttrs),this._whitespaceCell}getBlankLine(e4,t5){return new o2.BufferLine(this._bufferService.cols,this.getNullCell(e4),t5)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e4=this.ybase+this.y-this.ydisp;return e4>=0&&e4<this._rows}_getCorrectBufferLength(e4){if(!this._hasScrollback)return e4;let s4=e4+this._optionsService.rawOptions.scrollback;return s4>t4.MAX_BUFFER_SIZE?t4.MAX_BUFFER_SIZE:s4}fillViewportRows(e4){if(this.lines.length===0){e4===void 0&&(e4=o2.DEFAULT_ATTR_DATA);let t5=this._rows;for(;t5--;)this.lines.push(this.getBlankLine(e4))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new i3.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e4,t5){let s4=this.getNullCell(o2.DEFAULT_ATTR_DATA),i4=0,r8=this._getCorrectBufferLength(t5);if(r8>this.lines.maxLength&&(this.lines.maxLength=r8),this.lines.length>0){if(this._cols<e4)for(let t6=0;t6<this.lines.length;t6++)i4+=+this.lines.get(t6).resize(e4,s4);let n4=0;if(this._rows<t5)for(let i5=this._rows;i5<t5;i5++)this.lines.length<t5+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new o2.BufferLine(e4,s4)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n4+1?(this.ybase--,n4++,this.ydisp>0&&this.ydisp--):this.lines.push(new o2.BufferLine(e4,s4)));else for(let e5=this._rows;e5>t5;e5--)this.lines.length>t5+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r8<this.lines.maxLength){let e5=this.lines.length-r8;e5>0&&(this.lines.trimStart(e5),this.ybase=Math.max(this.ybase-e5,0),this.ydisp=Math.max(this.ydisp-e5,0),this.savedY=Math.max(this.savedY-e5,0)),this.lines.maxLength=r8}this.x=Math.min(this.x,e4-1),this.y=Math.min(this.y,t5-1),n4&&(this.y+=n4),this.savedX=Math.min(this.savedX,e4-1),this.scrollTop=0}if(this.scrollBottom=t5-1,this._isReflowEnabled&&(this._reflow(e4,t5),this._cols>e4))for(let t6=0;t6<this.lines.length;t6++)i4+=+this.lines.get(t6).resize(e4,s4);this._cols=e4,this._rows=t5,this._memoryCleanupQueue.clear(),i4>0.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e4=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e4=!1);let t5=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t5+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t5>100)return!0;return e4}get _isReflowEnabled(){let e4=this._optionsService.rawOptions.windowsPty;return e4&&e4.buildNumber?this._hasScrollback&&e4.backend==="conpty"&&e4.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e4,t5){this._cols!==e4&&(e4>this._cols?this._reflowLarger(e4,t5):this._reflowSmaller(e4,t5))}_reflowLarger(e4,t5){let s4=this._optionsService.rawOptions.reflowCursorLine,i4=(0,a2.reflowLargerGetLinesToRemove)(this.lines,this._cols,e4,this.ybase+this.y,this.getNullCell(o2.DEFAULT_ATTR_DATA),s4);if(i4.length>0){let s5=(0,a2.reflowLargerCreateNewLayout)(this.lines,i4);(0,a2.reflowLargerApplyNewLayout)(this.lines,s5.layout),this._reflowLargerAdjustViewport(e4,t5,s5.countRemoved)}}_reflowLargerAdjustViewport(e4,t5,s4){let i4=this.getNullCell(o2.DEFAULT_ATTR_DATA),r8=s4;for(;r8-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t5&&this.lines.push(new o2.BufferLine(e4,i4))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s4,0)}_reflowSmaller(e4,t5){let s4=this._optionsService.rawOptions.reflowCursorLine,i4=this.getNullCell(o2.DEFAULT_ATTR_DATA),r8=[],n4=0;for(let h3=this.lines.length-1;h3>=0;h3--){let c3=this.lines.get(h3);if(!c3||!c3.isWrapped&&c3.getTrimmedLength()<=e4)continue;let l3=[c3];for(;c3.isWrapped&&h3>0;)c3=this.lines.get(--h3),l3.unshift(c3);if(!s4){let e5=this.ybase+this.y;if(e5>=h3&&e5<h3+l3.length)continue}let u3=l3[l3.length-1].getTrimmedLength(),d2=(0,a2.reflowSmallerGetNewLineLengths)(l3,this._cols,e4),f2=d2.length-l3.length,_4;_4=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+f2):Math.max(0,this.lines.length-this.lines.maxLength+f2);let p3=[];for(let e5=0;e5<f2;e5++){let e6=this.getBlankLine(o2.DEFAULT_ATTR_DATA,!0);p3.push(e6)}p3.length>0&&(r8.push({start:h3+l3.length+n4,newLines:p3}),n4+=p3.length),l3.push(...p3);let g3=d2.length-1,v3=d2[g3];v3===0&&(g3--,v3=d2[g3]);let m3=l3.length-f2-1,b3=u3;for(;m3>=0;){let e5=Math.min(b3,v3);if(l3[g3]===void 0)break;if(l3[g3].copyCellsFrom(l3[m3],b3-e5,v3-e5,e5,!0),v3-=e5,v3===0&&(g3--,v3=d2[g3]),b3-=e5,b3===0){m3--;let e6=Math.max(m3,0);b3=(0,a2.getWrappedLineTrimmedLength)(l3,e6,this._cols)}}for(let t6=0;t6<l3.length;t6++)d2[t6]<e4&&l3[t6].setCell(d2[t6],i4);let S3=f2-_4;for(;S3-- >0;)this.ybase===0?this.y<t5-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n4)-t5&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+f2,this.ybase+t5-1)}if(r8.length>0){let e5=[],t6=[];for(let e6=0;e6<this.lines.length;e6++)t6.push(this.lines.get(e6));let s5=this.lines.length,i5=s5-1,o3=0,a3=r8[o3];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n4);let h3=0;for(let c4=Math.min(this.lines.maxLength-1,s5+n4-1);c4>=0;c4--)if(a3&&a3.start>i5+h3){for(let e6=a3.newLines.length-1;e6>=0;e6--)this.lines.set(c4--,a3.newLines[e6]);c4++,e5.push({index:i5+1,amount:a3.newLines.length}),h3+=a3.newLines.length,a3=r8[++o3]}else this.lines.set(c4,t6[i5--]);let c3=0;for(let t7=e5.length-1;t7>=0;t7--)e5[t7].index+=c3,this.lines.onInsertEmitter.fire(e5[t7]),c3+=e5[t7].amount;let l3=Math.max(0,s5+n4-this.lines.maxLength);l3>0&&this.lines.onTrimEmitter.fire(l3)}}translateBufferLineToString(e4,t5,s4=0,i4){let r8=this.lines.get(e4);return r8?r8.translateToString(t5,s4,i4):""}getWrappedRangeForLine(e4){let t5=e4,s4=e4;for(;t5>0&&this.lines.get(t5).isWrapped;)t5--;for(;s4+1<this.lines.length&&this.lines.get(s4+1).isWrapped;)s4++;return{first:t5,last:s4}}setupTabStops(e4){for(e4!=null?this.tabs[e4]||(e4=this.prevStop(e4)):(this.tabs={},e4=0);e4<this._cols;e4+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e4]=!0}prevStop(e4){for(e4==null&&(e4=this.x);!this.tabs[--e4]&&e4>0;);return e4>=this._cols?this._cols-1:e4<0?0:e4}nextStop(e4){for(e4==null&&(e4=this.x);!this.tabs[++e4]&&e4<this._cols;);return e4>=this._cols?this._cols-1:e4<0?0:e4}clearMarkers(e4){this._isClearing=!0;for(let t5=0;t5<this.markers.length;t5++)this.markers[t5].line===e4&&(this.markers[t5].dispose(),this.markers.splice(t5--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e4=0;e4<this.markers.length;e4++)this.markers[e4].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e4){let t5=new l2.Marker(e4);return this.markers.push(t5),t5.register(this.lines.onTrim((e5)=>{t5.line-=e5,t5.line<0&&t5.dispose()})),t5.register(this.lines.onInsert((e5)=>{t5.line>=e5.index&&(t5.line+=e5.amount)})),t5.register(this.lines.onDelete((e5)=>{t5.line>=e5.index&&t5.line<e5.index+e5.amount&&t5.dispose(),t5.line>e5.index&&(t5.line-=e5.amount)})),t5.register(t5.onDispose(()=>this._removeMarker(t5))),t5}_removeMarker(e4){this._isClearing||this.markers.splice(this.markers.indexOf(e4),1)}}},6107:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.BufferLine=t4.DEFAULT_ATTR_DATA=void 0;let i3=s3(5451),r7=s3(3055),n3=s3(8938),o2=s3(726);t4.DEFAULT_ATTR_DATA=Object.freeze(new i3.AttributeData);let a2=0;class h2{constructor(e4,t5,s4=!1){this.isWrapped=s4,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e4);let i4=t5||r7.CellData.fromCharData([0,n3.NULL_CELL_CHAR,n3.NULL_CELL_WIDTH,n3.NULL_CELL_CODE]);for(let t6=0;t6<e4;++t6)this.setCell(t6,i4);this.length=e4}get(e4){let t5=this._data[3*e4+0],s4=2097151&t5;return[this._data[3*e4+1],2097152&t5?this._combined[e4]:s4?(0,o2.stringFromCodePoint)(s4):"",t5>>22,2097152&t5?this._combined[e4].charCodeAt(this._combined[e4].length-1):s4]}set(e4,t5){this._data[3*e4+1]=t5[n3.CHAR_DATA_ATTR_INDEX],t5[n3.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e4]=t5[1],this._data[3*e4+0]=2097152|e4|t5[n3.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e4+0]=t5[n3.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t5[n3.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(e4){return this._data[3*e4+0]>>22}hasWidth(e4){return 12582912&this._data[3*e4+0]}getFg(e4){return this._data[3*e4+1]}getBg(e4){return this._data[3*e4+2]}hasContent(e4){return 4194303&this._data[3*e4+0]}getCodePoint(e4){let t5=this._data[3*e4+0];return 2097152&t5?this._combined[e4].charCodeAt(this._combined[e4].length-1):2097151&t5}isCombined(e4){return 2097152&this._data[3*e4+0]}getString(e4){let t5=this._data[3*e4+0];return 2097152&t5?this._combined[e4]:2097151&t5?(0,o2.stringFromCodePoint)(2097151&t5):""}isProtected(e4){return 536870912&this._data[3*e4+2]}loadCell(e4,t5){return a2=3*e4,t5.content=this._data[a2+0],t5.fg=this._data[a2+1],t5.bg=this._data[a2+2],2097152&t5.content&&(t5.combinedData=this._combined[e4]),268435456&t5.bg&&(t5.extended=this._extendedAttrs[e4]),t5}setCell(e4,t5){2097152&t5.content&&(this._combined[e4]=t5.combinedData),268435456&t5.bg&&(this._extendedAttrs[e4]=t5.extended),this._data[3*e4+0]=t5.content,this._data[3*e4+1]=t5.fg,this._data[3*e4+2]=t5.bg}setCellFromCodepoint(e4,t5,s4,i4){268435456&i4.bg&&(this._extendedAttrs[e4]=i4.extended),this._data[3*e4+0]=t5|s4<<22,this._data[3*e4+1]=i4.fg,this._data[3*e4+2]=i4.bg}addCodepointToCell(e4,t5,s4){let i4=this._data[3*e4+0];2097152&i4?this._combined[e4]+=(0,o2.stringFromCodePoint)(t5):2097151&i4?(this._combined[e4]=(0,o2.stringFromCodePoint)(2097151&i4)+(0,o2.stringFromCodePoint)(t5),i4&=-2097152,i4|=2097152):i4=t5|4194304,s4&&(i4&=-12582913,i4|=s4<<22),this._data[3*e4+0]=i4}insertCells(e4,t5,s4){if((e4%=this.length)&&this.getWidth(e4-1)===2&&this.setCellFromCodepoint(e4-1,0,1,s4),t5<this.length-e4){let i4=new r7.CellData;for(let s5=this.length-e4-t5-1;s5>=0;--s5)this.setCell(e4+t5+s5,this.loadCell(e4+s5,i4));for(let i5=0;i5<t5;++i5)this.setCell(e4+i5,s4)}else for(let t6=e4;t6<this.length;++t6)this.setCell(t6,s4);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s4)}deleteCells(e4,t5,s4){if(e4%=this.length,t5<this.length-e4){let i4=new r7.CellData;for(let s5=0;s5<this.length-e4-t5;++s5)this.setCell(e4+s5,this.loadCell(e4+t5+s5,i4));for(let e5=this.length-t5;e5<this.length;++e5)this.setCell(e5,s4)}else for(let t6=e4;t6<this.length;++t6)this.setCell(t6,s4);e4&&this.getWidth(e4-1)===2&&this.setCellFromCodepoint(e4-1,0,1,s4),this.getWidth(e4)!==0||this.hasContent(e4)||this.setCellFromCodepoint(e4,0,1,s4)}replaceCells(e4,t5,s4,i4=!1){if(i4)for(e4&&this.getWidth(e4-1)===2&&!this.isProtected(e4-1)&&this.setCellFromCodepoint(e4-1,0,1,s4),t5<this.length&&this.getWidth(t5-1)===2&&!this.isProtected(t5)&&this.setCellFromCodepoint(t5,0,1,s4);e4<t5&&e4<this.length;)this.isProtected(e4)||this.setCell(e4,s4),e4++;else for(e4&&this.getWidth(e4-1)===2&&this.setCellFromCodepoint(e4-1,0,1,s4),t5<this.length&&this.getWidth(t5-1)===2&&this.setCellFromCodepoint(t5,0,1,s4);e4<t5&&e4<this.length;)this.setCell(e4++,s4)}resize(e4,t5){if(e4===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let s4=3*e4;if(e4>this.length){if(this._data.buffer.byteLength>=4*s4)this._data=new Uint32Array(this._data.buffer,0,s4);else{let e5=new Uint32Array(s4);e5.set(this._data),this._data=e5}for(let s5=this.length;s5<e4;++s5)this.setCell(s5,t5)}else{this._data=this._data.subarray(0,s4);let t6=Object.keys(this._combined);for(let s5=0;s5<t6.length;s5++){let i5=parseInt(t6[s5],10);i5>=e4&&delete this._combined[i5]}let i4=Object.keys(this._extendedAttrs);for(let t7=0;t7<i4.length;t7++){let s5=parseInt(i4[t7],10);s5>=e4&&delete this._extendedAttrs[s5]}}return this.length=e4,4*s4*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e4=new Uint32Array(this._data.length);return e4.set(this._data),this._data=e4,1}return 0}fill(e4,t5=!1){if(t5)for(let t6=0;t6<this.length;++t6)this.isProtected(t6)||this.setCell(t6,e4);else{this._combined={},this._extendedAttrs={};for(let t6=0;t6<this.length;++t6)this.setCell(t6,e4)}}copyFrom(e4){this.length!==e4.length?this._data=new Uint32Array(e4._data):this._data.set(e4._data),this.length=e4.length,this._combined={};for(let t5 in e4._combined)this._combined[t5]=e4._combined[t5];this._extendedAttrs={};for(let t5 in e4._extendedAttrs)this._extendedAttrs[t5]=e4._extendedAttrs[t5];this.isWrapped=e4.isWrapped}clone(){let e4=new h2(0);e4._data=new Uint32Array(this._data),e4.length=this.length;for(let t5 in this._combined)e4._combined[t5]=this._combined[t5];for(let t5 in this._extendedAttrs)e4._extendedAttrs[t5]=this._extendedAttrs[t5];return e4.isWrapped=this.isWrapped,e4}getTrimmedLength(){for(let e4=this.length-1;e4>=0;--e4)if(4194303&this._data[3*e4+0])return e4+(this._data[3*e4+0]>>22);return 0}getNoBgTrimmedLength(){for(let e4=this.length-1;e4>=0;--e4)if(4194303&this._data[3*e4+0]||50331648&this._data[3*e4+2])return e4+(this._data[3*e4+0]>>22);return 0}copyCellsFrom(e4,t5,s4,i4,r8){let n4=e4._data;if(r8)for(let r9=i4-1;r9>=0;r9--){for(let e5=0;e5<3;e5++)this._data[3*(s4+r9)+e5]=n4[3*(t5+r9)+e5];268435456&n4[3*(t5+r9)+2]&&(this._extendedAttrs[s4+r9]=e4._extendedAttrs[t5+r9])}else for(let r9=0;r9<i4;r9++){for(let e5=0;e5<3;e5++)this._data[3*(s4+r9)+e5]=n4[3*(t5+r9)+e5];268435456&n4[3*(t5+r9)+2]&&(this._extendedAttrs[s4+r9]=e4._extendedAttrs[t5+r9])}let o3=Object.keys(e4._combined);for(let i5=0;i5<o3.length;i5++){let r9=parseInt(o3[i5],10);r9>=t5&&(this._combined[r9-t5+s4]=e4._combined[r9])}}translateToString(e4,t5,s4,i4){t5=t5??0,s4=s4??this.length,e4&&(s4=Math.min(s4,this.getTrimmedLength())),i4&&(i4.length=0);let r8="";for(;t5<s4;){let e5=this._data[3*t5+0],s5=2097151&e5,a3=2097152&e5?this._combined[t5]:s5?(0,o2.stringFromCodePoint)(s5):n3.WHITESPACE_CELL_CHAR;if(r8+=a3,i4)for(let e6=0;e6<a3.length;++e6)i4.push(t5);t5+=e5>>22||1}return i4&&i4.push(t5),r8}}t4.BufferLine=h2},732:(e3,t4)=>{function s3(e4,t5,s4){if(t5===e4.length-1)return e4[t5].getTrimmedLength();let i3=!e4[t5].hasContent(s4-1)&&e4[t5].getWidth(s4-1)===1,r7=e4[t5+1].getWidth(0)===2;return i3&&r7?s4-1:s4}Object.defineProperty(t4,"__esModule",{value:!0}),t4.reflowLargerGetLinesToRemove=function(e4,t5,i3,r7,n3,o2){let a2=[];for(let h2=0;h2<e4.length-1;h2++){let c2=h2,l2=e4.get(++c2);if(!l2.isWrapped)continue;let u2=[e4.get(h2)];for(;c2<e4.length&&l2.isWrapped;)u2.push(l2),l2=e4.get(++c2);if(!o2&&r7>=h2&&r7<c2){h2+=u2.length-1;continue}let d2=0,f2=s3(u2,d2,t5),_4=1,p3=0;for(;_4<u2.length;){let e5=s3(u2,_4,t5),r8=e5-p3,o3=i3-f2,a3=Math.min(r8,o3);u2[d2].copyCellsFrom(u2[_4],p3,f2,a3,!1),f2+=a3,f2===i3&&(d2++,f2=0),p3+=a3,p3===e5&&(_4++,p3=0),f2===0&&d2!==0&&u2[d2-1].getWidth(i3-1)===2&&(u2[d2].copyCellsFrom(u2[d2-1],i3-1,f2++,1,!1),u2[d2-1].setCell(i3-1,n3))}u2[d2].replaceCells(f2,i3,n3);let g3=0;for(let e5=u2.length-1;e5>0&&(e5>d2||u2[e5].getTrimmedLength()===0);e5--)g3++;g3>0&&(a2.push(h2+u2.length-g3),a2.push(g3)),h2+=u2.length-1}return a2},t4.reflowLargerCreateNewLayout=function(e4,t5){let s4=[],i3=0,r7=t5[i3],n3=0;for(let o2=0;o2<e4.length;o2++)if(r7===o2){let s5=t5[++i3];e4.onDeleteEmitter.fire({index:o2-n3,amount:s5}),o2+=s5-1,n3+=s5,r7=t5[++i3]}else s4.push(o2);return{layout:s4,countRemoved:n3}},t4.reflowLargerApplyNewLayout=function(e4,t5){let s4=[];for(let i3=0;i3<t5.length;i3++)s4.push(e4.get(t5[i3]));for(let t6=0;t6<s4.length;t6++)e4.set(t6,s4[t6]);e4.length=t5.length},t4.reflowSmallerGetNewLineLengths=function(e4,t5,i3){let r7=[],n3=e4.map((i4,r8)=>s3(e4,r8,t5)).reduce((e5,t6)=>e5+t6),o2=0,a2=0,h2=0;for(;h2<n3;){if(n3-h2<i3){r7.push(n3-h2);break}o2+=i3;let c2=s3(e4,a2,t5);o2>c2&&(o2-=c2,a2++);let l2=e4[a2].getWidth(o2-1)===2;l2&&o2--;let u2=l2?i3-1:i3;r7.push(u2),h2+=u2}return r7},t4.getWrappedLineTrimmedLength=s3},4097:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.BufferSet=void 0;let i3=s3(7150),r7=s3(1073),n3=s3(802);class o2 extends i3.Disposable{constructor(e4,t5){super(),this._optionsService=e4,this._bufferService=t5,this._onBufferActivate=this._register(new n3.Emitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new r7.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new r7.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e4){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e4),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e4,t5){this._normal.resize(e4,t5),this._alt.resize(e4,t5),this.setupTabStops(e4)}setupTabStops(e4){this._normal.setupTabStops(e4),this._alt.setupTabStops(e4)}}t4.BufferSet=o2},3055:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.CellData=void 0;let i3=s3(726),r7=s3(8938),n3=s3(5451);class o2 extends n3.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new n3.ExtendedAttrs,this.combinedData=""}static fromCharData(e4){let t5=new o2;return t5.setFromCharData(e4),t5}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,i3.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e4){this.fg=e4[r7.CHAR_DATA_ATTR_INDEX],this.bg=0;let t5=!1;if(e4[r7.CHAR_DATA_CHAR_INDEX].length>2)t5=!0;else if(e4[r7.CHAR_DATA_CHAR_INDEX].length===2){let s4=e4[r7.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=s4&&s4<=56319){let i4=e4[r7.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=i4&&i4<=57343?this.content=1024*(s4-55296)+i4-56320+65536|e4[r7.CHAR_DATA_WIDTH_INDEX]<<22:t5=!0}else t5=!0}else this.content=e4[r7.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e4[r7.CHAR_DATA_WIDTH_INDEX]<<22;t5&&(this.combinedData=e4[r7.CHAR_DATA_CHAR_INDEX],this.content=2097152|e4[r7.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t4.CellData=o2},8938:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.WHITESPACE_CELL_CODE=t4.WHITESPACE_CELL_WIDTH=t4.WHITESPACE_CELL_CHAR=t4.NULL_CELL_CODE=t4.NULL_CELL_WIDTH=t4.NULL_CELL_CHAR=t4.CHAR_DATA_CODE_INDEX=t4.CHAR_DATA_WIDTH_INDEX=t4.CHAR_DATA_CHAR_INDEX=t4.CHAR_DATA_ATTR_INDEX=t4.DEFAULT_EXT=t4.DEFAULT_ATTR=t4.DEFAULT_COLOR=void 0,t4.DEFAULT_COLOR=0,t4.DEFAULT_ATTR=t4.DEFAULT_COLOR<<9|256,t4.DEFAULT_EXT=0,t4.CHAR_DATA_ATTR_INDEX=0,t4.CHAR_DATA_CHAR_INDEX=1,t4.CHAR_DATA_WIDTH_INDEX=2,t4.CHAR_DATA_CODE_INDEX=3,t4.NULL_CELL_CHAR="",t4.NULL_CELL_WIDTH=1,t4.NULL_CELL_CODE=0,t4.WHITESPACE_CELL_CHAR=" ",t4.WHITESPACE_CELL_WIDTH=1,t4.WHITESPACE_CELL_CODE=32},8158:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.Marker=void 0;let i3=s3(802),r7=s3(7150);class n3{get id(){return this._id}constructor(e4){this.line=e4,this.isDisposed=!1,this._disposables=[],this._id=n3._nextId++,this._onDispose=this.register(new i3.Emitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,r7.dispose)(this._disposables),this._disposables.length=0)}register(e4){return this._disposables.push(e4),e4}}t4.Marker=n3,n3._nextId=1},6760:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.DEFAULT_CHARSET=t4.CHARSETS=void 0,t4.CHARSETS={},t4.DEFAULT_CHARSET=t4.CHARSETS.B,t4.CHARSETS[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"},t4.CHARSETS.A={"#":"\xA3"},t4.CHARSETS.B=void 0,t4.CHARSETS[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"},t4.CHARSETS.C=t4.CHARSETS[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},t4.CHARSETS.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"},t4.CHARSETS.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"},t4.CHARSETS.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"},t4.CHARSETS.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"},t4.CHARSETS.E=t4.CHARSETS[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"},t4.CHARSETS.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"},t4.CHARSETS.H=t4.CHARSETS[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},t4.CHARSETS["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"}},3534:(e3,t4)=>{var s3,i3,r7;Object.defineProperty(t4,"__esModule",{value:!0}),t4.C1_ESCAPED=t4.C1=t4.C0=void 0,function(e4){e4.NUL="\x00",e4.SOH="\x01",e4.STX="\x02",e4.ETX="\x03",e4.EOT="\x04",e4.ENQ="\x05",e4.ACK="\x06",e4.BEL="\x07",e4.BS="\b",e4.HT="\t",e4.LF=`
2
+ import{KEY_HINTS_ENABLED_KEY,PANE_HINT_USED_KEYS,grammarHelpSections,guideCategory,keyHintsEnabled,keyHintsToggleOn,legendCap,paneHintTokens,paneHintVisible,scopeCategory,statusHintTokens,toggleKeyHints}from"./chunk-2kbhctee.js";import{embeddedTerminalEnv}from"./chunk-ef39ym8f.js";import{readOutdatedCache}from"./chunk-5ygc7rce.js";import{listPaneLaunches}from"./chunk-1x7xjh3h.js";import{deriveTitleFromSessionId,startTaskSessionWithPromptAdapter}from"./chunk-ey9xbdpm.js";import{canonPath,checkResolutionNotify}from"./chunk-mc33ba6j.js";import{readLastActiveTaskId}from"./chunk-2kb4z64z.js";import{formatBytes}from"./chunk-my20q579.js";import{detectEngineStatuses,probeableEngineIds,summarizeEngines}from"./chunk-n4bhegyh.js";import{ISSUE_STATUSES,isValidCron,nextCronAfter,tightenPluginPermissions}from"./chunk-px6axbd9.js";import"./chunk-xsrcwcjc.js";import"./chunk-jpdf97cx.js";import{DEFAULT_EDITOR_KIND,EDITOR_CUSTOM_KEY,EDITOR_KINDS,EDITOR_KIND_KEY,normalizeEditorKind,resolveEditorLaunch}from"./chunk-zj8y4f4x.js";import{approxCellWidth,approxCharCells,charWidth,displayWidth,padEndCells}from"./chunk-dvcb6mk4.js";import{UpdatePage,openWithSystemViewer,resolveRowSelectionChrome,spawnDetached}from"./chunk-1jnvvb50.js";import{$Fragment,$jsx,$jsxs,DEFAULT_PREFIX_CONFIGURATION,DEFAULT_SOUND_VOLUME,DIRECT_GUIDE_PREFIX_ACTION_ID,FIXED_BINDING_IDS,KobeKeymap,PREFIX_GUIDE_DELAY_MS,PREFIX_HUD_TTL_MS,RemoteOrchestrator,SOUND_VOLUME_KEY,armPrefixFromCurrentStack,attentionEdges,attentionKindFor,bindByIds,bootPaneHost,chipAttentionKind,currentBindingReachability,currentPrefixConfiguration,defaultChordsOf,findBinding,formatChord,hostTargetFps,imeAnchorController,invokeArmedPrefixActionFromCurrentStack,isKittyModifierKeyEvent,isNarrowWidth,keymapVersion,modalActive,narrowSurface,nextSoundVolume,normalizeSoundVolume,pageCloseBindings,pluginKeybindings,prefixAction,prefixHudClock,prefixHudState,redrawScreen,reloadUserKeybindings,require_react_production,shortcutCaption,showDialog,subscribeKeymapVersion,taskJumpDigit,useAccessor,useBindingStackVersion,useBindings,useDialog,useDialogPaddingX,useFocus,useKV,useLatest,useNotifications,useOptionalDialog,useOptionalFocus,useOptionalKV,useOptionalNotifications,usePaste,useRenderer,useT,useTerminalDimensions,useTheme,userKeybindingsReport}from"./chunk-bhsm9s5p.js";import"./chunk-764bsyb0.js";import"./chunk-bk629r67.js";import{getGlobalDefaultVendor,resolvePreferredVendor,setGlobalDefaultVendor,setRepoLastActiveVendor}from"./chunk-bkm7vxr5.js";import{parseNumstatRows,parsePorcelain,pickPushedChanges,sameWorktreeChanges}from"./chunk-xqw5d5rv.js";import{parsePorcelainRows,unquoteGitPath}from"./chunk-h4n8ffqy.js";import{reloadPluginEngines}from"./chunk-kyr0cyq1.js";import{submitFeedback}from"./chunk-470vz1ct.js";import"./chunk-xb9b93ts.js";import{DIRTY_WORKTREE_CODE,PROJECT_SIBLING_BASE,TASK_DELETING_CODE,TaskDeletingError,WORKTREE_BASE_CUSTOM_KEY,worktreeBaseKindOf}from"./chunk-vhq2dhx2.js";import{currentPluginPlatform,loadPluginRegistry,parsePluginManifest,pluginConfigDir,pluginLogPath,pluginManifestPath,qualifiedActionId,readPluginManifest,savePluginRegistry,supportsPlatform}from"./chunk-g2e1dmxh.js";import{PROJECT_DIR_TOKEN,WORKTREE_BASE_KEY,hasProjectDirToken,normalizeWorktreeBase}from"./chunk-63wmhbqs.js";import{ulid}from"./chunk-qkehg2c1.js";import{READ_ONLY_GIT_ENV,readOnlyGitProcessEnv}from"./chunk-6xppe9bj.js";import{matchPathGlob}from"./chunk-kg11c1py.js";import{CURRENT_VERSION}from"./chunk-cc95msmk.js";import{addTab,closeActiveTab,closeTab,collapseSplit,cycleLeaf,cycleTab,engineTabSpawnFor,expandHome,filterSubdirs,findEditorTab,forgetTaskTabsSnapshot,hasEngineLeaf,initialShellTabs,initialSplit,initialTabs,isTabSplit,joinDrill,joinPicked,leaves,listSubdirs,moveTab,openCommandTab,openContentTab,openEditorTab,pathLeaf,recycleTabs,rehydrateTabs,removeLeaf,renameActiveTab,renameLeaf,reopenTabs,selectTab,setTabAutoTitle,setTabEngineCommand,setTabForkFrom,setTabInitialPrompt,setTabLastTitle,setTabLiveVendor,setTabSessionId,setTabSpawned,setTabSplit,setTabTitle,shellIdentityInput,splitActive,splitLeafNames,splitLeafPtyKey,splitPathForDirSuggest,stripTrailingSlash,sweepOrphanTabsSnapshots,tabCwdFor,tabExitAction,tabPtyKey,tabPtyKeyFor,tabTitle,tabTitleStable,terminalTabsKey,visibleNativeStatus}from"./chunk-847gwrx2.js";import{AUTO_STATUS_KEY,DISPATCHER_KEY,hostedTaskKeys,killHostedSessions,listHostedSessions,openHostedSessionHost,pastePromptWhenEngineUp}from"./chunk-d8hcpwr6.js";import{execHostForWorktreePath,remoteKeyForRepo}from"./chunk-rc0sqhdh.js";import"./chunk-2apszxn2.js";import"./chunk-g2advs8t.js";import{ensurePtyHostReachable}from"./chunk-gsy8xfh6.js";import{ENGINE_PROTOCOLS,engineCanFork,engineLaunchArgv,engineProtocolKey,getEngineProtocol,pickUnclaimedSessionId,protocolEntry,withPinnedSessionId}from"./chunk-yrmj16b9.js";import"./chunk-rcyasw34.js";import{DEFAULT_TERMINAL_COLORS,formatDefaultColorReply,parseTerminalDefaultColors}from"./chunk-7q67dz4c.js";import{readFirstNonEmptyRepoFile}from"./chunk-92d2t5sk.js";import"./chunk-hape5vwj.js";import{defaultEngineCommand,engineCommandKey,engineDisplayName,engineNameKey,humanizeSlug,interactiveEngineCommand,kobeApiInvocation}from"./chunk-wdrgfezn.js";import{FOCUS_ACCENT_SLOTS,LOCALE_KEY}from"./chunk-ptfe9a1h.js";import"./chunk-z7c6nap0.js";import{currentLang,intlLocale,setLocaleLang,t,tKeys}from"./chunk-bwrb6c2h.js";import{LOCALES}from"./chunk-qqh9aef5.js";import{createStateCell}from"./chunk-sdyzxayr.js";import{resolveLoginShell}from"./chunk-b99tf0jr.js";import"./chunk-w25b7xxz.js";import"./chunk-jvxh93nz.js";import{tildify}from"./chunk-fczqwtmq.js";import{connectOrStartDaemon}from"./chunk-te8g5azg.js";import"./chunk-y13681dw.js";import{KobeDaemonClient}from"./chunk-b5mbpv97.js";import{attentionInboxItemKey,automationRunNeedsAttention}from"./chunk-re5ke4fz.js";import"./chunk-mnqxgvyb.js";import{foregroundEngineIn,parsePsSnapshot,psSnapshot}from"./chunk-1jbznr12.js";import{engineEntry,engineSessionIdFromTitle,engineTitleTurnHint,getCapabilities,stripEngineStatusPrefix}from"./chunk-71k66b8f.js";import{maybeStartScheduledRun,spawnCapture}from"./chunk-khj0apc7.js";import{availableEngineIds,installedEngineIds}from"./chunk-5zh5fcpe.js";import"./chunk-w7zv47mp.js";import{roveCliInvocation}from"./chunk-pdnq8dbm.js";import"./chunk-7jkf3tvr.js";import"./chunk-7kysxgbq.js";import"./chunk-r9gfh1zz.js";import{DEFAULT_TASK_VENDOR,TASK_STATUSES}from"./chunk-xy8be792.js";import{addSavedRepo,getSavedRepos,isGitRepo,isRemoteRepoKey,resolveMainRepoRoot}from"./chunk-ejqs2ta9.js";import{loadStateFile}from"./chunk-3jh78dmc.js";import"./chunk-ddcxvbme.js";import{errorMessage,userFacingErrorMessage}from"./chunk-2brn8e1y.js";import{ALL_VENDORS,isBuiltinVendor,nextVendorWithin,prevVendorWithin}from"./chunk-bq3fyc0p.js";import"./chunk-81p6mm0p.js";import{isDev,promptAttachmentsDir,roveStateDir}from"./chunk-q5jhy3t8.js";import"./chunk-t915by6w.js";import{OWNER_ONLY_DIR_MODE,OWNER_ONLY_FILE_MODE}from"./chunk-9prawccj.js";import{activeCliName}from"./chunk-00ehck55.js";import"./chunk-fxs82dsx.js";import{ROVE_PRODUCT_NAME}from"./chunk-sb0ns0c7.js";import"./chunk-pxk2c2vj.js";import{logClientError}from"./chunk-0q6h4vt4.js";import"./chunk-pw6yfj10.js";import{pathIdentity,pathSyntax,pathWithin,samePath}from"./chunk-f10n6063.js";import{defaultDaemonSocketPath}from"./chunk-8cjr5ypt.js";import{readRoveEnv}from"./chunk-hq4b3fca.js";import{__commonJS,__require,__toESM}from"./chunk-wqfp8d9w.js";var require_xterm_headless=__commonJS((exports)=>{(()=>{var e2={5639:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.CircularList=void 0;let i3=s3(7150),r7=s3(802);class n3 extends i3.Disposable{constructor(e4){super(),this._maxLength=e4,this.onDeleteEmitter=this._register(new r7.Emitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new r7.Emitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new r7.Emitter),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e4){if(this._maxLength===e4)return;let t5=Array(e4);for(let s4=0;s4<Math.min(e4,this.length);s4++)t5[s4]=this._array[this._getCyclicIndex(s4)];this._array=t5,this._maxLength=e4,this._startIndex=0}get length(){return this._length}set length(e4){if(e4>this._length)for(let t5=this._length;t5<e4;t5++)this._array[t5]=void 0;this._length=e4}get(e4){return this._array[this._getCyclicIndex(e4)]}set(e4,t5){this._array[this._getCyclicIndex(e4)]=t5}push(e4){this._array[this._getCyclicIndex(this._length)]=e4,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e4,t5,...s4){if(t5){for(let s5=e4;s5<this._length-t5;s5++)this._array[this._getCyclicIndex(s5)]=this._array[this._getCyclicIndex(s5+t5)];this._length-=t5,this.onDeleteEmitter.fire({index:e4,amount:t5})}for(let t6=this._length-1;t6>=e4;t6--)this._array[this._getCyclicIndex(t6+s4.length)]=this._array[this._getCyclicIndex(t6)];for(let t6=0;t6<s4.length;t6++)this._array[this._getCyclicIndex(e4+t6)]=s4[t6];if(s4.length&&this.onInsertEmitter.fire({index:e4,amount:s4.length}),this._length+s4.length>this._maxLength){let e5=this._length+s4.length-this._maxLength;this._startIndex+=e5,this._length=this._maxLength,this.onTrimEmitter.fire(e5)}else this._length+=s4.length}trimStart(e4){e4>this._length&&(e4=this._length),this._startIndex+=e4,this._length-=e4,this.onTrimEmitter.fire(e4)}shiftElements(e4,t5,s4){if(!(t5<=0)){if(e4<0||e4>=this._length)throw Error("start argument out of range");if(e4+s4<0)throw Error("Cannot shift elements in list beyond index 0");if(s4>0){for(let i5=t5-1;i5>=0;i5--)this.set(e4+i5+s4,this.get(e4+i5));let i4=e4+t5+s4-this._length;if(i4>0)for(this._length+=i4;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i4=0;i4<t5;i4++)this.set(e4+i4+s4,this.get(e4+i4))}}_getCyclicIndex(e4){return(this._startIndex+e4)%this._maxLength}}t4.CircularList=n3},7453:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.clone=function e4(t5,s3=5){if(typeof t5!="object")return t5;let i3=Array.isArray(t5)?[]:{};for(let r7 in t5)i3[r7]=s3<=1?t5[r7]:t5[r7]&&e4(t5[r7],s3-1);return i3}},5777:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.CoreTerminal=void 0;let i3=s3(6501),r7=s3(6025),n3=s3(7276),o2=s3(9640),a2=s3(56),h2=s3(4071),c2=s3(7792),l2=s3(6415),u2=s3(5746),d2=s3(5882),f2=s3(2486),_4=s3(3562),p3=s3(8811),g3=s3(802),v3=s3(7150),m3=!1;class b3 extends v3.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new g3.Emitter),this._onScroll.event((e4)=>{this._onScrollApi?.fire(e4.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e4){for(let t5 in e4)this.optionsService.options[t5]=e4[t5]}constructor(e4){super(),this._windowsWrappingHeuristics=this._register(new v3.MutableDisposable),this._onBinary=this._register(new g3.Emitter),this.onBinary=this._onBinary.event,this._onData=this._register(new g3.Emitter),this.onData=this._onData.event,this._onLineFeed=this._register(new g3.Emitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new g3.Emitter),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new g3.Emitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new g3.Emitter),this._instantiationService=new r7.InstantiationService,this.optionsService=this._register(new a2.OptionsService(e4)),this._instantiationService.setService(i3.IOptionsService,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(o2.BufferService)),this._instantiationService.setService(i3.IBufferService,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(n3.LogService)),this._instantiationService.setService(i3.ILogService,this._logService),this.coreService=this._register(this._instantiationService.createInstance(h2.CoreService)),this._instantiationService.setService(i3.ICoreService,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(c2.CoreMouseService)),this._instantiationService.setService(i3.ICoreMouseService,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(l2.UnicodeService)),this._instantiationService.setService(i3.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u2.CharsetService),this._instantiationService.setService(i3.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(p3.OscLinkService),this._instantiationService.setService(i3.IOscLinkService,this._oscLinkService),this._inputHandler=this._register(new f2.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(g3.Event.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(g3.Event.forward(this._bufferService.onResize,this._onResize)),this._register(g3.Event.forward(this.coreService.onData,this._onData)),this._register(g3.Event.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new _4.WriteBuffer((e5,t5)=>this._inputHandler.parse(e5,t5))),this._register(g3.Event.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(e4,t5){this._writeBuffer.write(e4,t5)}writeSync(e4,t5){this._logService.logLevel<=i3.LogLevelEnum.WARN&&!m3&&(this._logService.warn("writeSync is unreliable and will be removed soon."),m3=!0),this._writeBuffer.writeSync(e4,t5)}input(e4,t5=!0){this.coreService.triggerDataEvent(e4,t5)}resize(e4,t5){isNaN(e4)||isNaN(t5)||(e4=Math.max(e4,o2.MINIMUM_COLS),t5=Math.max(t5,o2.MINIMUM_ROWS),this._bufferService.resize(e4,t5))}scroll(e4,t5=!1){this._bufferService.scroll(e4,t5)}scrollLines(e4,t5){this._bufferService.scrollLines(e4,t5)}scrollPages(e4){this.scrollLines(e4*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e4){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e4){let t5=e4-this._bufferService.buffer.ydisp;t5!==0&&this.scrollLines(t5)}registerEscHandler(e4,t5){return this._inputHandler.registerEscHandler(e4,t5)}registerDcsHandler(e4,t5){return this._inputHandler.registerDcsHandler(e4,t5)}registerCsiHandler(e4,t5){return this._inputHandler.registerCsiHandler(e4,t5)}registerOscHandler(e4,t5){return this._inputHandler.registerOscHandler(e4,t5)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e4=!1,t5=this.optionsService.rawOptions.windowsPty;t5&&t5.buildNumber!==void 0&&t5.buildNumber!==void 0?e4=t5.backend==="conpty"&&t5.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e4=!0),e4?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e4=[];e4.push(this.onLineFeed(d2.updateWindowsModeWrappedState.bind(null,this._bufferService))),e4.push(this.registerCsiHandler({final:"H"},()=>((0,d2.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,v3.toDisposable)(()=>{for(let t5 of e4)t5.dispose()})}}}t4.CoreTerminal=b3},2486:function(e3,t4,s3){var i3=this&&this.__decorate||function(e4,t5,s4,i4){var r8,n4=arguments.length,o3=n4<3?t5:i4===null?i4=Object.getOwnPropertyDescriptor(t5,s4):i4;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o3=Reflect.decorate(e4,t5,s4,i4);else for(var a3=e4.length-1;a3>=0;a3--)(r8=e4[a3])&&(o3=(n4<3?r8(o3):n4>3?r8(t5,s4,o3):r8(t5,s4))||o3);return n4>3&&o3&&Object.defineProperty(t5,s4,o3),o3},r7=this&&this.__param||function(e4,t5){return function(s4,i4){t5(s4,i4,e4)}};Object.defineProperty(t4,"__esModule",{value:!0}),t4.InputHandler=t4.WindowsOptionsReportType=void 0,t4.isValidColorIndex=k3;let n3=s3(3534),o2=s3(6760),a2=s3(6717),h2=s3(7150),c2=s3(726),l2=s3(6107),u2=s3(8938),d2=s3(3055),f2=s3(5451),_4=s3(6501),p3=s3(6415),g3=s3(1346),v3=s3(9823),m3=s3(8693),b3=s3(802),S3={"(":0,")":1,"*":2,"+":3,"-":1,".":2},y3=131072;function C3(e4,t5){if(e4>24)return t5.setWinLines||!1;switch(e4){case 1:return!!t5.restoreWin;case 2:return!!t5.minimizeWin;case 3:return!!t5.setWinPosition;case 4:return!!t5.setWinSizePixels;case 5:return!!t5.raiseWin;case 6:return!!t5.lowerWin;case 7:return!!t5.refreshWin;case 8:return!!t5.setWinSizeChars;case 9:return!!t5.maximizeWin;case 10:return!!t5.fullscreenWin;case 11:return!!t5.getWinState;case 13:return!!t5.getWinPosition;case 14:return!!t5.getWinSizePixels;case 15:return!!t5.getScreenSizePixels;case 16:return!!t5.getCellSizePixels;case 18:return!!t5.getWinSizeChars;case 19:return!!t5.getScreenSizeChars;case 20:return!!t5.getIconTitle;case 21:return!!t5.getWinTitle;case 22:return!!t5.pushTitle;case 23:return!!t5.popTitle;case 24:return!!t5.setWinLines}return!1}var w4;(function(e4){e4[e4.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",e4[e4.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(w4||(t4.WindowsOptionsReportType=w4={}));let E3=0;class A4 extends h2.Disposable{getAttrData(){return this._curAttrData}constructor(e4,t5,s4,i4,r8,h3,u3,d3,f3=new a2.EscapeSequenceParser){super(),this._bufferService=e4,this._charsetService=t5,this._coreService=s4,this._logService=i4,this._optionsService=r8,this._oscLinkService=h3,this._coreMouseService=u3,this._unicodeService=d3,this._parser=f3,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new c2.StringToUtf32,this._utf8Decoder=new c2.Utf8ToUtf32,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=l2.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l2.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this._register(new b3.Emitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new b3.Emitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new b3.Emitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new b3.Emitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new b3.Emitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new b3.Emitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new b3.Emitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new b3.Emitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new b3.Emitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new b3.Emitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new b3.Emitter),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new b3.Emitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new b3.Emitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new L2(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate((e5)=>this._activeBuffer=e5.activeBuffer)),this._parser.setCsiHandlerFallback((e5,t6)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e5),params:t6.toArray()})}),this._parser.setEscHandlerFallback((e5)=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e5)})}),this._parser.setExecuteHandlerFallback((e5)=>{this._logService.debug("Unknown EXECUTE code: ",{code:e5})}),this._parser.setOscHandlerFallback((e5,t6,s5)=>{this._logService.debug("Unknown OSC code: ",{identifier:e5,action:t6,data:s5})}),this._parser.setDcsHandlerFallback((e5,t6,s5)=>{t6==="HOOK"&&(s5=s5.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e5),action:t6,payload:s5})}),this._parser.setPrintHandler((e5,t6,s5)=>this.print(e5,t6,s5)),this._parser.registerCsiHandler({final:"@"},(e5)=>this.insertChars(e5)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(e5)=>this.scrollLeft(e5)),this._parser.registerCsiHandler({final:"A"},(e5)=>this.cursorUp(e5)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(e5)=>this.scrollRight(e5)),this._parser.registerCsiHandler({final:"B"},(e5)=>this.cursorDown(e5)),this._parser.registerCsiHandler({final:"C"},(e5)=>this.cursorForward(e5)),this._parser.registerCsiHandler({final:"D"},(e5)=>this.cursorBackward(e5)),this._parser.registerCsiHandler({final:"E"},(e5)=>this.cursorNextLine(e5)),this._parser.registerCsiHandler({final:"F"},(e5)=>this.cursorPrecedingLine(e5)),this._parser.registerCsiHandler({final:"G"},(e5)=>this.cursorCharAbsolute(e5)),this._parser.registerCsiHandler({final:"H"},(e5)=>this.cursorPosition(e5)),this._parser.registerCsiHandler({final:"I"},(e5)=>this.cursorForwardTab(e5)),this._parser.registerCsiHandler({final:"J"},(e5)=>this.eraseInDisplay(e5,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},(e5)=>this.eraseInDisplay(e5,!0)),this._parser.registerCsiHandler({final:"K"},(e5)=>this.eraseInLine(e5,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},(e5)=>this.eraseInLine(e5,!0)),this._parser.registerCsiHandler({final:"L"},(e5)=>this.insertLines(e5)),this._parser.registerCsiHandler({final:"M"},(e5)=>this.deleteLines(e5)),this._parser.registerCsiHandler({final:"P"},(e5)=>this.deleteChars(e5)),this._parser.registerCsiHandler({final:"S"},(e5)=>this.scrollUp(e5)),this._parser.registerCsiHandler({final:"T"},(e5)=>this.scrollDown(e5)),this._parser.registerCsiHandler({final:"X"},(e5)=>this.eraseChars(e5)),this._parser.registerCsiHandler({final:"Z"},(e5)=>this.cursorBackwardTab(e5)),this._parser.registerCsiHandler({final:"`"},(e5)=>this.charPosAbsolute(e5)),this._parser.registerCsiHandler({final:"a"},(e5)=>this.hPositionRelative(e5)),this._parser.registerCsiHandler({final:"b"},(e5)=>this.repeatPrecedingCharacter(e5)),this._parser.registerCsiHandler({final:"c"},(e5)=>this.sendDeviceAttributesPrimary(e5)),this._parser.registerCsiHandler({prefix:">",final:"c"},(e5)=>this.sendDeviceAttributesSecondary(e5)),this._parser.registerCsiHandler({final:"d"},(e5)=>this.linePosAbsolute(e5)),this._parser.registerCsiHandler({final:"e"},(e5)=>this.vPositionRelative(e5)),this._parser.registerCsiHandler({final:"f"},(e5)=>this.hVPosition(e5)),this._parser.registerCsiHandler({final:"g"},(e5)=>this.tabClear(e5)),this._parser.registerCsiHandler({final:"h"},(e5)=>this.setMode(e5)),this._parser.registerCsiHandler({prefix:"?",final:"h"},(e5)=>this.setModePrivate(e5)),this._parser.registerCsiHandler({final:"l"},(e5)=>this.resetMode(e5)),this._parser.registerCsiHandler({prefix:"?",final:"l"},(e5)=>this.resetModePrivate(e5)),this._parser.registerCsiHandler({final:"m"},(e5)=>this.charAttributes(e5)),this._parser.registerCsiHandler({final:"n"},(e5)=>this.deviceStatus(e5)),this._parser.registerCsiHandler({prefix:"?",final:"n"},(e5)=>this.deviceStatusPrivate(e5)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(e5)=>this.softReset(e5)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(e5)=>this.setCursorStyle(e5)),this._parser.registerCsiHandler({final:"r"},(e5)=>this.setScrollRegion(e5)),this._parser.registerCsiHandler({final:"s"},(e5)=>this.saveCursor(e5)),this._parser.registerCsiHandler({final:"t"},(e5)=>this.windowOptions(e5)),this._parser.registerCsiHandler({final:"u"},(e5)=>this.restoreCursor(e5)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(e5)=>this.insertColumns(e5)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(e5)=>this.deleteColumns(e5)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(e5)=>this.selectProtected(e5)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(e5)=>this.requestMode(e5,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(e5)=>this.requestMode(e5,!1)),this._parser.setExecuteHandler(n3.C0.BEL,()=>this.bell()),this._parser.setExecuteHandler(n3.C0.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(n3.C0.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(n3.C0.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(n3.C0.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(n3.C0.BS,()=>this.backspace()),this._parser.setExecuteHandler(n3.C0.HT,()=>this.tab()),this._parser.setExecuteHandler(n3.C0.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(n3.C0.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(n3.C1.IND,()=>this.index()),this._parser.setExecuteHandler(n3.C1.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(n3.C1.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new g3.OscHandler((e5)=>(this.setTitle(e5),this.setIconName(e5),!0))),this._parser.registerOscHandler(1,new g3.OscHandler((e5)=>this.setIconName(e5))),this._parser.registerOscHandler(2,new g3.OscHandler((e5)=>this.setTitle(e5))),this._parser.registerOscHandler(4,new g3.OscHandler((e5)=>this.setOrReportIndexedColor(e5))),this._parser.registerOscHandler(8,new g3.OscHandler((e5)=>this.setHyperlink(e5))),this._parser.registerOscHandler(10,new g3.OscHandler((e5)=>this.setOrReportFgColor(e5))),this._parser.registerOscHandler(11,new g3.OscHandler((e5)=>this.setOrReportBgColor(e5))),this._parser.registerOscHandler(12,new g3.OscHandler((e5)=>this.setOrReportCursorColor(e5))),this._parser.registerOscHandler(104,new g3.OscHandler((e5)=>this.restoreIndexedColor(e5))),this._parser.registerOscHandler(110,new g3.OscHandler((e5)=>this.restoreFgColor(e5))),this._parser.registerOscHandler(111,new g3.OscHandler((e5)=>this.restoreBgColor(e5))),this._parser.registerOscHandler(112,new g3.OscHandler((e5)=>this.restoreCursorColor(e5))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let e5 in o2.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:e5},()=>this.selectCharset("("+e5)),this._parser.registerEscHandler({intermediates:")",final:e5},()=>this.selectCharset(")"+e5)),this._parser.registerEscHandler({intermediates:"*",final:e5},()=>this.selectCharset("*"+e5)),this._parser.registerEscHandler({intermediates:"+",final:e5},()=>this.selectCharset("+"+e5)),this._parser.registerEscHandler({intermediates:"-",final:e5},()=>this.selectCharset("-"+e5)),this._parser.registerEscHandler({intermediates:".",final:e5},()=>this.selectCharset("."+e5)),this._parser.registerEscHandler({intermediates:"/",final:e5},()=>this.selectCharset("/"+e5));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler((e5)=>(this._logService.error("Parsing error: ",e5),e5)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new v3.DcsHandler((e5,t6)=>this.requestStatusString(e5,t6)))}_preserveStack(e4,t5,s4,i4){this._parseStack.paused=!0,this._parseStack.cursorStartX=e4,this._parseStack.cursorStartY=t5,this._parseStack.decodedLength=s4,this._parseStack.position=i4}_logSlowResolvingAsync(e4){this._logService.logLevel<=_4.LogLevelEnum.WARN&&Promise.race([e4,new Promise((e5,t5)=>setTimeout(()=>t5("#SLOW_TIMEOUT"),5000))]).catch((e5)=>{if(e5!=="#SLOW_TIMEOUT")throw e5;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e4,t5){let s4,i4=this._activeBuffer.x,r8=this._activeBuffer.y,n4=0,o3=this._parseStack.paused;if(o3){if(s4=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t5))return this._logSlowResolvingAsync(s4),s4;i4=this._parseStack.cursorStartX,r8=this._parseStack.cursorStartY,this._parseStack.paused=!1,e4.length>y3&&(n4=this._parseStack.position+y3)}if(this._logService.logLevel<=_4.LogLevelEnum.DEBUG&&this._logService.debug("parsing data "+(typeof e4=="string"?` "${e4}"`:` "${Array.prototype.map.call(e4,(e5)=>String.fromCharCode(e5)).join("")}"`)),this._logService.logLevel===_4.LogLevelEnum.TRACE&&this._logService.trace("parsing data (codes)",typeof e4=="string"?e4.split("").map((e5)=>e5.charCodeAt(0)):e4),this._parseBuffer.length<e4.length&&this._parseBuffer.length<y3&&(this._parseBuffer=new Uint32Array(Math.min(e4.length,y3))),o3||this._dirtyRowTracker.clearRange(),e4.length>y3)for(let t6=n4;t6<e4.length;t6+=y3){let n5=t6+y3<e4.length?t6+y3:e4.length,o4=typeof e4=="string"?this._stringDecoder.decode(e4.substring(t6,n5),this._parseBuffer):this._utf8Decoder.decode(e4.subarray(t6,n5),this._parseBuffer);if(s4=this._parser.parse(this._parseBuffer,o4))return this._preserveStack(i4,r8,o4,t6),this._logSlowResolvingAsync(s4),s4}else if(!o3){let t6=typeof e4=="string"?this._stringDecoder.decode(e4,this._parseBuffer):this._utf8Decoder.decode(e4,this._parseBuffer);if(s4=this._parser.parse(this._parseBuffer,t6))return this._preserveStack(i4,r8,t6,0),this._logSlowResolvingAsync(s4),s4}this._activeBuffer.x===i4&&this._activeBuffer.y===r8||this._onCursorMove.fire();let a3=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h3=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h3<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h3,this._bufferService.rows-1),end:Math.min(a3,this._bufferService.rows-1)})}print(e4,t5,s4){let i4,r8,n4=this._charsetService.charset,o3=this._optionsService.rawOptions.screenReaderMode,a3=this._bufferService.cols,h3=this._coreService.decPrivateModes.wraparound,d3=this._coreService.modes.insertMode,f3=this._curAttrData,_5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s4-t5>0&&_5.getWidth(this._activeBuffer.x-1)===2&&_5.setCellFromCodepoint(this._activeBuffer.x-1,0,1,f3);let g4=this._parser.precedingJoinState;for(let v4=t5;v4<s4;++v4){if(i4=e4[v4],i4<127&&n4){let e5=n4[String.fromCharCode(i4)];e5&&(i4=e5.charCodeAt(0))}let t6=this._unicodeService.charProperties(i4,g4);r8=p3.UnicodeService.extractWidth(t6);let s5=p3.UnicodeService.extractShouldJoin(t6),m4=s5?p3.UnicodeService.extractWidth(g4):0;if(g4=t6,o3&&this._onA11yChar.fire((0,c2.stringFromCodePoint)(i4)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r8-m4>a3){if(h3){let e5=_5,t7=this._activeBuffer.x-m4;for(this._activeBuffer.x=m4,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m4>0&&_5 instanceof l2.BufferLine&&_5.copyCellsFrom(e5,t7,0,m4,!1);t7<a3;)e5.setCellFromCodepoint(t7++,0,1,f3)}else if(this._activeBuffer.x=a3-1,r8===2)continue}if(s5&&this._activeBuffer.x){let e5=_5.getWidth(this._activeBuffer.x-1)?1:2;_5.addCodepointToCell(this._activeBuffer.x-e5,i4,r8);for(let e6=r8-m4;--e6>=0;)_5.setCellFromCodepoint(this._activeBuffer.x++,0,0,f3)}else if(d3&&(_5.insertCells(this._activeBuffer.x,r8-m4,this._activeBuffer.getNullCell(f3)),_5.getWidth(a3-1)===2&&_5.setCellFromCodepoint(a3-1,u2.NULL_CELL_CODE,u2.NULL_CELL_WIDTH,f3)),_5.setCellFromCodepoint(this._activeBuffer.x++,i4,r8,f3),r8>0)for(;--r8;)_5.setCellFromCodepoint(this._activeBuffer.x++,0,0,f3)}this._parser.precedingJoinState=g4,this._activeBuffer.x<a3&&s4-t5>0&&_5.getWidth(this._activeBuffer.x)===0&&!_5.hasContent(this._activeBuffer.x)&&_5.setCellFromCodepoint(this._activeBuffer.x,0,1,f3),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e4,t5){return e4.final!=="t"||e4.prefix||e4.intermediates?this._parser.registerCsiHandler(e4,t5):this._parser.registerCsiHandler(e4,(e5)=>!C3(e5.params[0],this._optionsService.rawOptions.windowOptions)||t5(e5))}registerDcsHandler(e4,t5){return this._parser.registerDcsHandler(e4,new v3.DcsHandler(t5))}registerEscHandler(e4,t5){return this._parser.registerEscHandler(e4,t5)}registerOscHandler(e4,t5){return this._parser.registerOscHandler(e4,new g3.OscHandler(t5))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e4=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e4.hasWidth(this._activeBuffer.x)&&!e4.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e4=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e4),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e4=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e4,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e4,t5){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e4,this._activeBuffer.y=this._activeBuffer.scrollTop+t5):(this._activeBuffer.x=e4,this._activeBuffer.y=t5),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e4,t5){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e4,this._activeBuffer.y+t5)}cursorUp(e4){let t5=this._activeBuffer.y-this._activeBuffer.scrollTop;return t5>=0?this._moveCursor(0,-Math.min(t5,e4.params[0]||1)):this._moveCursor(0,-(e4.params[0]||1)),!0}cursorDown(e4){let t5=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t5>=0?this._moveCursor(0,Math.min(t5,e4.params[0]||1)):this._moveCursor(0,e4.params[0]||1),!0}cursorForward(e4){return this._moveCursor(e4.params[0]||1,0),!0}cursorBackward(e4){return this._moveCursor(-(e4.params[0]||1),0),!0}cursorNextLine(e4){return this.cursorDown(e4),this._activeBuffer.x=0,!0}cursorPrecedingLine(e4){return this.cursorUp(e4),this._activeBuffer.x=0,!0}cursorCharAbsolute(e4){return this._setCursor((e4.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e4){return this._setCursor(e4.length>=2?(e4.params[1]||1)-1:0,(e4.params[0]||1)-1),!0}charPosAbsolute(e4){return this._setCursor((e4.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e4){return this._moveCursor(e4.params[0]||1,0),!0}linePosAbsolute(e4){return this._setCursor(this._activeBuffer.x,(e4.params[0]||1)-1),!0}vPositionRelative(e4){return this._moveCursor(0,e4.params[0]||1),!0}hVPosition(e4){return this.cursorPosition(e4),!0}tabClear(e4){let t5=e4.params[0];return t5===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t5===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e4){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t5=e4.params[0]||1;for(;t5--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e4){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t5=e4.params[0]||1;for(;t5--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e4){let t5=e4.params[0];return t5===1&&(this._curAttrData.bg|=536870912),t5!==2&&t5!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e4,t5,s4,i4=!1,r8=!1){let n4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e4);n4.replaceCells(t5,s4,this._activeBuffer.getNullCell(this._eraseAttrData()),r8),i4&&(n4.isWrapped=!1)}_resetBufferLine(e4,t5=!1){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e4);s4&&(s4.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t5),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e4),s4.isWrapped=!1)}eraseInDisplay(e4,t5=!1){let s4;switch(this._restrictCursor(this._bufferService.cols),e4.params[0]){case 0:for(s4=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s4),this._eraseInBufferLine(s4++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t5);s4<this._bufferService.rows;s4++)this._resetBufferLine(s4,t5);this._dirtyRowTracker.markDirty(s4);break;case 1:for(s4=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s4),this._eraseInBufferLine(s4,0,this._activeBuffer.x+1,!0,t5),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s4+1).isWrapped=!1);s4--;)this._resetBufferLine(s4,t5);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s4=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s4-1);s4--;)if(this._activeBuffer.lines.get(this._activeBuffer.ybase+s4)?.getTrimmedLength())break;for(;s4>=0;s4--)this._bufferService.scroll(this._eraseAttrData())}else{for(s4=this._bufferService.rows,this._dirtyRowTracker.markDirty(s4-1);s4--;)this._resetBufferLine(s4,t5);this._dirtyRowTracker.markDirty(0)}break;case 3:let e5=this._activeBuffer.lines.length-this._bufferService.rows;e5>0&&(this._activeBuffer.lines.trimStart(e5),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e5,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e5,0),this._onScroll.fire(0))}return!0}eraseInLine(e4,t5=!1){switch(this._restrictCursor(this._bufferService.cols),e4.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t5);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t5);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t5)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e4){this._restrictCursor();let t5=e4.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s4=this._activeBuffer.ybase+this._activeBuffer.y,i4=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r8=this._bufferService.rows-1+this._activeBuffer.ybase-i4+1;for(;t5--;)this._activeBuffer.lines.splice(r8-1,1),this._activeBuffer.lines.splice(s4,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e4){this._restrictCursor();let t5=e4.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s4=this._activeBuffer.ybase+this._activeBuffer.y,i4;for(i4=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i4=this._bufferService.rows-1+this._activeBuffer.ybase-i4;t5--;)this._activeBuffer.lines.splice(s4,1),this._activeBuffer.lines.splice(i4,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e4){this._restrictCursor();let t5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t5&&(t5.insertCells(this._activeBuffer.x,e4.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e4){this._restrictCursor();let t5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t5&&(t5.deleteCells(this._activeBuffer.x,e4.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e4){let t5=e4.params[0]||1;for(;t5--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e4){let t5=e4.params[0]||1;for(;t5--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(l2.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e4){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t5=e4.params[0]||1;for(let e5=this._activeBuffer.scrollTop;e5<=this._activeBuffer.scrollBottom;++e5){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e5);s4.deleteCells(0,t5,this._activeBuffer.getNullCell(this._eraseAttrData())),s4.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e4){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t5=e4.params[0]||1;for(let e5=this._activeBuffer.scrollTop;e5<=this._activeBuffer.scrollBottom;++e5){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e5);s4.insertCells(0,t5,this._activeBuffer.getNullCell(this._eraseAttrData())),s4.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e4){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t5=e4.params[0]||1;for(let e5=this._activeBuffer.scrollTop;e5<=this._activeBuffer.scrollBottom;++e5){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e5);s4.insertCells(this._activeBuffer.x,t5,this._activeBuffer.getNullCell(this._eraseAttrData())),s4.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e4){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t5=e4.params[0]||1;for(let e5=this._activeBuffer.scrollTop;e5<=this._activeBuffer.scrollBottom;++e5){let s4=this._activeBuffer.lines.get(this._activeBuffer.ybase+e5);s4.deleteCells(this._activeBuffer.x,t5,this._activeBuffer.getNullCell(this._eraseAttrData())),s4.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e4){this._restrictCursor();let t5=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t5&&(t5.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e4.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e4){let t5=this._parser.precedingJoinState;if(!t5)return!0;let s4=e4.params[0]||1,i4=p3.UnicodeService.extractWidth(t5),r8=this._activeBuffer.x-i4,n4=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r8),o3=new Uint32Array(n4.length*s4),a3=0;for(let e5=0;e5<n4.length;){let t6=n4.codePointAt(e5)||0;o3[a3++]=t6,e5+=t6>65535?2:1}let h3=a3;for(let e5=1;e5<s4;++e5)o3.copyWithin(h3,0,a3),h3+=a3;return this.print(o3,0,h3),!0}sendDeviceAttributesPrimary(e4){return e4.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(n3.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(n3.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e4){return e4.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(n3.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(n3.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e4.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(n3.C0.ESC+"[>83;40003;0c")),!0}_is(e4){return(this._optionsService.rawOptions.termName+"").indexOf(e4)===0}setMode(e4){for(let t5=0;t5<e4.length;t5++)switch(e4.params[t5]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e4){for(let t5=0;t5<e4.length;t5++)switch(e4.params[t5]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,o2.DEFAULT_CHARSET),this._charsetService.setgCharset(1,o2.DEFAULT_CHARSET),this._charsetService.setgCharset(2,o2.DEFAULT_CHARSET),this._charsetService.setgCharset(3,o2.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1000:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e4){for(let t5=0;t5<e4.length;t5++)switch(e4.params[t5]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e4){for(let t5=0;t5<e4.length;t5++)switch(e4.params[t5]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1000:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e4.params[t5]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e4,t5){let s4=this._coreService.decPrivateModes,{activeProtocol:i4,activeEncoding:r8}=this._coreMouseService,o3=this._coreService,{buffers:a3,cols:h3}=this._bufferService,{active:c3,alt:l3}=a3,u3=this._optionsService.rawOptions,d3=(e5)=>e5?1:2,f3=e4.params[0];return _5=f3,p4=t5?f3===2?4:f3===4?d3(o3.modes.insertMode):f3===12?3:f3===20?d3(u3.convertEol):0:f3===1?d3(s4.applicationCursorKeys):f3===3?u3.windowOptions.setWinLines?h3===80?2:h3===132?1:0:0:f3===6?d3(s4.origin):f3===7?d3(s4.wraparound):f3===8?3:f3===9?d3(i4==="X10"):f3===12?d3(u3.cursorBlink):f3===25?d3(!o3.isCursorHidden):f3===45?d3(s4.reverseWraparound):f3===66?d3(s4.applicationKeypad):f3===67?4:f3===1000?d3(i4==="VT200"):f3===1002?d3(i4==="DRAG"):f3===1003?d3(i4==="ANY"):f3===1004?d3(s4.sendFocus):f3===1005?4:f3===1006?d3(r8==="SGR"):f3===1015?4:f3===1016?d3(r8==="SGR_PIXELS"):f3===1048?1:f3===47||f3===1047||f3===1049?d3(c3===l3):f3===2004?d3(s4.bracketedPasteMode):f3===2026?d3(s4.synchronizedOutput):0,o3.triggerDataEvent(`${n3.C0.ESC}[${t5?"":"?"}${_5};${p4}$y`),!0;var _5,p4}_updateAttrColor(e4,t5,s4,i4,r8){return t5===2?(e4|=50331648,e4&=-16777216,e4|=f2.AttributeData.fromColorRGB([s4,i4,r8])):t5===5&&(e4&=-50331904,e4|=33554432|255&s4),e4}_extractColor(e4,t5,s4){let i4=[0,0,-1,0,0,0],r8=0,n4=0;do{if(i4[n4+r8]=e4.params[t5+n4],e4.hasSubParams(t5+n4)){let s5=e4.getSubParams(t5+n4),o3=0;do i4[1]===5&&(r8=1),i4[n4+o3+1+r8]=s5[o3];while(++o3<s5.length&&o3+n4+1+r8<i4.length);break}if(i4[1]===5&&n4+r8>=2||i4[1]===2&&n4+r8>=5)break;i4[1]&&(r8=1)}while(++n4+t5<e4.length&&n4+r8<i4.length);for(let e5=2;e5<i4.length;++e5)i4[e5]===-1&&(i4[e5]=0);switch(i4[0]){case 38:s4.fg=this._updateAttrColor(s4.fg,i4[1],i4[3],i4[4],i4[5]);break;case 48:s4.bg=this._updateAttrColor(s4.bg,i4[1],i4[3],i4[4],i4[5]);break;case 58:s4.extended=s4.extended.clone(),s4.extended.underlineColor=this._updateAttrColor(s4.extended.underlineColor,i4[1],i4[3],i4[4],i4[5])}return n4}_processUnderline(e4,t5){t5.extended=t5.extended.clone(),(!~e4||e4>5)&&(e4=1),t5.extended.underlineStyle=e4,t5.fg|=268435456,e4===0&&(t5.fg&=-268435457),t5.updateExtended()}_processSGR0(e4){e4.fg=l2.DEFAULT_ATTR_DATA.fg,e4.bg=l2.DEFAULT_ATTR_DATA.bg,e4.extended=e4.extended.clone(),e4.extended.underlineStyle=0,e4.extended.underlineColor&=-67108864,e4.updateExtended()}charAttributes(e4){if(e4.length===1&&e4.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t5=e4.length,s4,i4=this._curAttrData;for(let r8=0;r8<t5;r8++)s4=e4.params[r8],s4>=30&&s4<=37?(i4.fg&=-50331904,i4.fg|=16777216|s4-30):s4>=40&&s4<=47?(i4.bg&=-50331904,i4.bg|=16777216|s4-40):s4>=90&&s4<=97?(i4.fg&=-50331904,i4.fg|=16777224|s4-90):s4>=100&&s4<=107?(i4.bg&=-50331904,i4.bg|=16777224|s4-100):s4===0?this._processSGR0(i4):s4===1?i4.fg|=134217728:s4===3?i4.bg|=67108864:s4===4?(i4.fg|=268435456,this._processUnderline(e4.hasSubParams(r8)?e4.getSubParams(r8)[0]:1,i4)):s4===5?i4.fg|=536870912:s4===7?i4.fg|=67108864:s4===8?i4.fg|=1073741824:s4===9?i4.fg|=2147483648:s4===2?i4.bg|=134217728:s4===21?this._processUnderline(2,i4):s4===22?(i4.fg&=-134217729,i4.bg&=-134217729):s4===23?i4.bg&=-67108865:s4===24?(i4.fg&=-268435457,this._processUnderline(0,i4)):s4===25?i4.fg&=-536870913:s4===27?i4.fg&=-67108865:s4===28?i4.fg&=-1073741825:s4===29?i4.fg&=2147483647:s4===39?(i4.fg&=-67108864,i4.fg|=16777215&l2.DEFAULT_ATTR_DATA.fg):s4===49?(i4.bg&=-67108864,i4.bg|=16777215&l2.DEFAULT_ATTR_DATA.bg):s4===38||s4===48||s4===58?r8+=this._extractColor(e4,r8,i4):s4===53?i4.bg|=1073741824:s4===55?i4.bg&=-1073741825:s4===59?(i4.extended=i4.extended.clone(),i4.extended.underlineColor=-1,i4.updateExtended()):s4===100?(i4.fg&=-67108864,i4.fg|=16777215&l2.DEFAULT_ATTR_DATA.fg,i4.bg&=-67108864,i4.bg|=16777215&l2.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",s4);return!0}deviceStatus(e4){switch(e4.params[0]){case 5:this._coreService.triggerDataEvent(`${n3.C0.ESC}[0n`);break;case 6:let e5=this._activeBuffer.y+1,t5=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n3.C0.ESC}[${e5};${t5}R`)}return!0}deviceStatusPrivate(e4){if(e4.params[0]===6){let e5=this._activeBuffer.y+1,t5=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n3.C0.ESC}[?${e5};${t5}R`)}return!0}softReset(e4){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=l2.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e4){let t5=e4.length===0?1:e4.params[0];if(t5===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t5){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar"}let e5=t5%2==1;this._coreService.decPrivateModes.cursorBlink=e5}return!0}setScrollRegion(e4){let t5=e4.params[0]||1,s4;return(e4.length<2||(s4=e4.params[1])>this._bufferService.rows||s4===0)&&(s4=this._bufferService.rows),s4>t5&&(this._activeBuffer.scrollTop=t5-1,this._activeBuffer.scrollBottom=s4-1,this._setCursor(0,0)),!0}windowOptions(e4){if(!C3(e4.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t5=e4.length>1?e4.params[1]:0;switch(e4.params[0]){case 14:t5!==2&&this._onRequestWindowsOptionsReport.fire(w4.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(w4.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${n3.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:t5!==0&&t5!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),t5!==0&&t5!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:t5!==0&&t5!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),t5!==0&&t5!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e4){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e4){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e4){return this._windowTitle=e4,this._onTitleChange.fire(e4),!0}setIconName(e4){return this._iconName=e4,!0}setOrReportIndexedColor(e4){let t5=[],s4=e4.split(";");for(;s4.length>1;){let e5=s4.shift(),i4=s4.shift();if(/^\d+$/.exec(e5)){let s5=parseInt(e5);if(k3(s5))if(i4==="?")t5.push({type:0,index:s5});else{let e6=(0,m3.parseColor)(i4);e6&&t5.push({type:1,index:s5,color:e6})}}}return t5.length&&this._onColor.fire(t5),!0}setHyperlink(e4){let t5=e4.indexOf(";");if(t5===-1)return!0;let s4=e4.slice(0,t5).trim(),i4=e4.slice(t5+1);return i4?this._createHyperlink(s4,i4):!s4.trim()&&this._finishHyperlink()}_createHyperlink(e4,t5){this._getCurrentLinkId()&&this._finishHyperlink();let s4=e4.split(":"),i4,r8=s4.findIndex((e5)=>e5.startsWith("id="));return r8!==-1&&(i4=s4[r8].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i4,uri:t5}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e4,t5){let s4=e4.split(";");for(let e5=0;e5<s4.length&&!(t5>=this._specialColors.length);++e5,++t5)if(s4[e5]==="?")this._onColor.fire([{type:0,index:this._specialColors[t5]}]);else{let i4=(0,m3.parseColor)(s4[e5]);i4&&this._onColor.fire([{type:1,index:this._specialColors[t5],color:i4}])}return!0}setOrReportFgColor(e4){return this._setOrReportSpecialColor(e4,0)}setOrReportBgColor(e4){return this._setOrReportSpecialColor(e4,1)}setOrReportCursorColor(e4){return this._setOrReportSpecialColor(e4,2)}restoreIndexedColor(e4){if(!e4)return this._onColor.fire([{type:2}]),!0;let t5=[],s4=e4.split(";");for(let e5=0;e5<s4.length;++e5)if(/^\d+$/.exec(s4[e5])){let i4=parseInt(s4[e5]);k3(i4)&&t5.push({type:2,index:i4})}return t5.length&&this._onColor.fire(t5),!0}restoreFgColor(e4){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e4){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e4){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,o2.DEFAULT_CHARSET),!0}selectCharset(e4){return e4.length!==2?(this.selectDefaultCharset(),!0):(e4[0]==="/"||this._charsetService.setgCharset(S3[e4[0]],o2.CHARSETS[e4[1]]||o2.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e4=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e4,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=l2.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l2.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e4){return this._charsetService.setgLevel(e4),!0}screenAlignmentPattern(){let e4=new d2.CellData;e4.content=4194373,e4.fg=this._curAttrData.fg,e4.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t5=0;t5<this._bufferService.rows;++t5){let s4=this._activeBuffer.ybase+this._activeBuffer.y+t5,i4=this._activeBuffer.lines.get(s4);i4&&(i4.fill(e4),i4.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e4,t5){let s4=this._bufferService.buffer,i4=this._optionsService.rawOptions;return((e5)=>(this._coreService.triggerDataEvent(`${n3.C0.ESC}${e5}${n3.C0.ESC}\\`),!0))(e4==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e4==='"p'?'P1$r61;1"p':e4==="r"?`P1$r${s4.scrollTop+1};${s4.scrollBottom+1}r`:e4==="m"?"P1$r0m":e4===" q"?`P1$r${{block:2,underline:4,bar:6}[i4.cursorStyle]-(i4.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e4,t5){this._dirtyRowTracker.markRangeDirty(e4,t5)}}t4.InputHandler=A4;let L2=class{constructor(e4){this._bufferService=e4,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e4){e4<this.start?this.start=e4:e4>this.end&&(this.end=e4)}markRangeDirty(e4,t5){e4>t5&&(E3=e4,e4=t5,t5=E3),e4<this.start&&(this.start=e4),t5>this.end&&(this.end=t5)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function k3(e4){return 0<=e4&&e4<256}L2=i3([r7(0,_4.IBufferService)],L2)},701:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.isChromeOS=t4.isLinux=t4.isWindows=t4.isIphone=t4.isIpad=t4.isMac=t4.isSafari=t4.isLegacyEdge=t4.isFirefox=t4.isNode=void 0,t4.getSafariVersion=function(){if(!t4.isSafari)return 0;let e4=s3.match(/Version\/(\d+)/);return e4===null||e4.length<2?0:parseInt(e4[1])},t4.isNode=typeof process<"u"&&"title"in process;let s3=t4.isNode?"node":navigator.userAgent,i3=t4.isNode?"node":navigator.platform;t4.isFirefox=s3.includes("Firefox"),t4.isLegacyEdge=s3.includes("Edge"),t4.isSafari=/^((?!chrome|android).)*safari/i.test(s3),t4.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(i3),t4.isIpad=i3==="iPad",t4.isIphone=i3==="iPhone",t4.isWindows=["Windows","Win16","Win32","WinCE"].includes(i3),t4.isLinux=i3.indexOf("Linux")>=0,t4.isChromeOS=/\bCrOS\b/.test(s3)},6168:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.DebouncedIdleTask=t4.IdleTaskQueue=t4.PriorityTaskQueue=void 0;let i3=s3(701);class r7{constructor(){this._tasks=[],this._i=0}enqueue(e4){this._tasks.push(e4),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e4){this._idleCallback=void 0;let t5=0,s4=0,i4=e4.timeRemaining(),r8=0;for(;this._i<this._tasks.length;){if(t5=performance.now(),this._tasks[this._i]()||this._i++,t5=Math.max(1,performance.now()-t5),s4=Math.max(t5,s4),r8=e4.timeRemaining(),1.5*s4>r8)return i4-t5<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i4-t5))}ms`),void this._start();i4=r8}this.clear()}}class n3 extends r7{_requestCallback(e4){return setTimeout(()=>e4(this._createDeadline(16)))}_cancelCallback(e4){clearTimeout(e4)}_createDeadline(e4){let t5=performance.now()+e4;return{timeRemaining:()=>Math.max(0,t5-performance.now())}}}t4.PriorityTaskQueue=n3,t4.IdleTaskQueue=!i3.isNode&&"requestIdleCallback"in window?class extends r7{_requestCallback(e4){return requestIdleCallback(e4)}_cancelCallback(e4){cancelIdleCallback(e4)}}:n3,t4.DebouncedIdleTask=class{constructor(){this._queue=new t4.IdleTaskQueue}set(e4){this._queue.clear(),this._queue.enqueue(e4)}flush(){this._queue.flush()}}},5882:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.updateWindowsModeWrappedState=function(e4){let t5=e4.buffer.lines.get(e4.buffer.ybase+e4.buffer.y-1),s4=t5?.get(e4.cols-1),r7=e4.buffer.lines.get(e4.buffer.ybase+e4.buffer.y);r7&&s4&&(r7.isWrapped=s4[i3.CHAR_DATA_CODE_INDEX]!==i3.NULL_CELL_CODE&&s4[i3.CHAR_DATA_CODE_INDEX]!==i3.WHITESPACE_CELL_CODE)};let i3=s3(8938)},5451:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.ExtendedAttrs=t4.AttributeData=void 0;class s3{constructor(){this.fg=0,this.bg=0,this.extended=new i3}static toColorRGB(e4){return[e4>>>16&255,e4>>>8&255,255&e4]}static fromColorRGB(e4){return(255&e4[0])<<16|(255&e4[1])<<8|255&e4[2]}clone(){let e4=new s3;return e4.fg=this.fg,e4.bg=this.bg,e4.extended=this.extended.clone(),e4}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}t4.AttributeData=s3;class i3{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e4){this._ext=e4}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e4){this._ext&=-469762049,this._ext|=e4<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e4){this._ext&=-67108864,this._ext|=67108863&e4}get urlId(){return this._urlId}set urlId(e4){this._urlId=e4}get underlineVariantOffset(){let e4=(3758096384&this._ext)>>29;return e4<0?4294967288^e4:e4}set underlineVariantOffset(e4){this._ext&=536870911,this._ext|=e4<<29&3758096384}constructor(e4=0,t5=0){this._ext=0,this._urlId=0,this._ext=e4,this._urlId=t5}clone(){return new i3(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}t4.ExtendedAttrs=i3},1073:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.Buffer=t4.MAX_BUFFER_SIZE=void 0;let i3=s3(5639),r7=s3(6168),n3=s3(5451),o2=s3(6107),a2=s3(732),h2=s3(3055),c2=s3(8938),l2=s3(8158),u2=s3(6760);t4.MAX_BUFFER_SIZE=4294967295,t4.Buffer=class{constructor(e4,t5,s4){this._hasScrollback=e4,this._optionsService=t5,this._bufferService=s4,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=o2.DEFAULT_ATTR_DATA.clone(),this.savedCharset=u2.DEFAULT_CHARSET,this.markers=[],this._nullCell=h2.CellData.fromCharData([0,c2.NULL_CELL_CHAR,c2.NULL_CELL_WIDTH,c2.NULL_CELL_CODE]),this._whitespaceCell=h2.CellData.fromCharData([0,c2.WHITESPACE_CELL_CHAR,c2.WHITESPACE_CELL_WIDTH,c2.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new r7.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new i3.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e4){return e4?(this._nullCell.fg=e4.fg,this._nullCell.bg=e4.bg,this._nullCell.extended=e4.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new n3.ExtendedAttrs),this._nullCell}getWhitespaceCell(e4){return e4?(this._whitespaceCell.fg=e4.fg,this._whitespaceCell.bg=e4.bg,this._whitespaceCell.extended=e4.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new n3.ExtendedAttrs),this._whitespaceCell}getBlankLine(e4,t5){return new o2.BufferLine(this._bufferService.cols,this.getNullCell(e4),t5)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e4=this.ybase+this.y-this.ydisp;return e4>=0&&e4<this._rows}_getCorrectBufferLength(e4){if(!this._hasScrollback)return e4;let s4=e4+this._optionsService.rawOptions.scrollback;return s4>t4.MAX_BUFFER_SIZE?t4.MAX_BUFFER_SIZE:s4}fillViewportRows(e4){if(this.lines.length===0){e4===void 0&&(e4=o2.DEFAULT_ATTR_DATA);let t5=this._rows;for(;t5--;)this.lines.push(this.getBlankLine(e4))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new i3.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e4,t5){let s4=this.getNullCell(o2.DEFAULT_ATTR_DATA),i4=0,r8=this._getCorrectBufferLength(t5);if(r8>this.lines.maxLength&&(this.lines.maxLength=r8),this.lines.length>0){if(this._cols<e4)for(let t6=0;t6<this.lines.length;t6++)i4+=+this.lines.get(t6).resize(e4,s4);let n4=0;if(this._rows<t5)for(let i5=this._rows;i5<t5;i5++)this.lines.length<t5+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new o2.BufferLine(e4,s4)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n4+1?(this.ybase--,n4++,this.ydisp>0&&this.ydisp--):this.lines.push(new o2.BufferLine(e4,s4)));else for(let e5=this._rows;e5>t5;e5--)this.lines.length>t5+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r8<this.lines.maxLength){let e5=this.lines.length-r8;e5>0&&(this.lines.trimStart(e5),this.ybase=Math.max(this.ybase-e5,0),this.ydisp=Math.max(this.ydisp-e5,0),this.savedY=Math.max(this.savedY-e5,0)),this.lines.maxLength=r8}this.x=Math.min(this.x,e4-1),this.y=Math.min(this.y,t5-1),n4&&(this.y+=n4),this.savedX=Math.min(this.savedX,e4-1),this.scrollTop=0}if(this.scrollBottom=t5-1,this._isReflowEnabled&&(this._reflow(e4,t5),this._cols>e4))for(let t6=0;t6<this.lines.length;t6++)i4+=+this.lines.get(t6).resize(e4,s4);this._cols=e4,this._rows=t5,this._memoryCleanupQueue.clear(),i4>0.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e4=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e4=!1);let t5=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t5+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t5>100)return!0;return e4}get _isReflowEnabled(){let e4=this._optionsService.rawOptions.windowsPty;return e4&&e4.buildNumber?this._hasScrollback&&e4.backend==="conpty"&&e4.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e4,t5){this._cols!==e4&&(e4>this._cols?this._reflowLarger(e4,t5):this._reflowSmaller(e4,t5))}_reflowLarger(e4,t5){let s4=this._optionsService.rawOptions.reflowCursorLine,i4=(0,a2.reflowLargerGetLinesToRemove)(this.lines,this._cols,e4,this.ybase+this.y,this.getNullCell(o2.DEFAULT_ATTR_DATA),s4);if(i4.length>0){let s5=(0,a2.reflowLargerCreateNewLayout)(this.lines,i4);(0,a2.reflowLargerApplyNewLayout)(this.lines,s5.layout),this._reflowLargerAdjustViewport(e4,t5,s5.countRemoved)}}_reflowLargerAdjustViewport(e4,t5,s4){let i4=this.getNullCell(o2.DEFAULT_ATTR_DATA),r8=s4;for(;r8-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t5&&this.lines.push(new o2.BufferLine(e4,i4))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s4,0)}_reflowSmaller(e4,t5){let s4=this._optionsService.rawOptions.reflowCursorLine,i4=this.getNullCell(o2.DEFAULT_ATTR_DATA),r8=[],n4=0;for(let h3=this.lines.length-1;h3>=0;h3--){let c3=this.lines.get(h3);if(!c3||!c3.isWrapped&&c3.getTrimmedLength()<=e4)continue;let l3=[c3];for(;c3.isWrapped&&h3>0;)c3=this.lines.get(--h3),l3.unshift(c3);if(!s4){let e5=this.ybase+this.y;if(e5>=h3&&e5<h3+l3.length)continue}let u3=l3[l3.length-1].getTrimmedLength(),d2=(0,a2.reflowSmallerGetNewLineLengths)(l3,this._cols,e4),f2=d2.length-l3.length,_4;_4=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+f2):Math.max(0,this.lines.length-this.lines.maxLength+f2);let p3=[];for(let e5=0;e5<f2;e5++){let e6=this.getBlankLine(o2.DEFAULT_ATTR_DATA,!0);p3.push(e6)}p3.length>0&&(r8.push({start:h3+l3.length+n4,newLines:p3}),n4+=p3.length),l3.push(...p3);let g3=d2.length-1,v3=d2[g3];v3===0&&(g3--,v3=d2[g3]);let m3=l3.length-f2-1,b3=u3;for(;m3>=0;){let e5=Math.min(b3,v3);if(l3[g3]===void 0)break;if(l3[g3].copyCellsFrom(l3[m3],b3-e5,v3-e5,e5,!0),v3-=e5,v3===0&&(g3--,v3=d2[g3]),b3-=e5,b3===0){m3--;let e6=Math.max(m3,0);b3=(0,a2.getWrappedLineTrimmedLength)(l3,e6,this._cols)}}for(let t6=0;t6<l3.length;t6++)d2[t6]<e4&&l3[t6].setCell(d2[t6],i4);let S3=f2-_4;for(;S3-- >0;)this.ybase===0?this.y<t5-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n4)-t5&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+f2,this.ybase+t5-1)}if(r8.length>0){let e5=[],t6=[];for(let e6=0;e6<this.lines.length;e6++)t6.push(this.lines.get(e6));let s5=this.lines.length,i5=s5-1,o3=0,a3=r8[o3];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n4);let h3=0;for(let c4=Math.min(this.lines.maxLength-1,s5+n4-1);c4>=0;c4--)if(a3&&a3.start>i5+h3){for(let e6=a3.newLines.length-1;e6>=0;e6--)this.lines.set(c4--,a3.newLines[e6]);c4++,e5.push({index:i5+1,amount:a3.newLines.length}),h3+=a3.newLines.length,a3=r8[++o3]}else this.lines.set(c4,t6[i5--]);let c3=0;for(let t7=e5.length-1;t7>=0;t7--)e5[t7].index+=c3,this.lines.onInsertEmitter.fire(e5[t7]),c3+=e5[t7].amount;let l3=Math.max(0,s5+n4-this.lines.maxLength);l3>0&&this.lines.onTrimEmitter.fire(l3)}}translateBufferLineToString(e4,t5,s4=0,i4){let r8=this.lines.get(e4);return r8?r8.translateToString(t5,s4,i4):""}getWrappedRangeForLine(e4){let t5=e4,s4=e4;for(;t5>0&&this.lines.get(t5).isWrapped;)t5--;for(;s4+1<this.lines.length&&this.lines.get(s4+1).isWrapped;)s4++;return{first:t5,last:s4}}setupTabStops(e4){for(e4!=null?this.tabs[e4]||(e4=this.prevStop(e4)):(this.tabs={},e4=0);e4<this._cols;e4+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e4]=!0}prevStop(e4){for(e4==null&&(e4=this.x);!this.tabs[--e4]&&e4>0;);return e4>=this._cols?this._cols-1:e4<0?0:e4}nextStop(e4){for(e4==null&&(e4=this.x);!this.tabs[++e4]&&e4<this._cols;);return e4>=this._cols?this._cols-1:e4<0?0:e4}clearMarkers(e4){this._isClearing=!0;for(let t5=0;t5<this.markers.length;t5++)this.markers[t5].line===e4&&(this.markers[t5].dispose(),this.markers.splice(t5--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e4=0;e4<this.markers.length;e4++)this.markers[e4].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e4){let t5=new l2.Marker(e4);return this.markers.push(t5),t5.register(this.lines.onTrim((e5)=>{t5.line-=e5,t5.line<0&&t5.dispose()})),t5.register(this.lines.onInsert((e5)=>{t5.line>=e5.index&&(t5.line+=e5.amount)})),t5.register(this.lines.onDelete((e5)=>{t5.line>=e5.index&&t5.line<e5.index+e5.amount&&t5.dispose(),t5.line>e5.index&&(t5.line-=e5.amount)})),t5.register(t5.onDispose(()=>this._removeMarker(t5))),t5}_removeMarker(e4){this._isClearing||this.markers.splice(this.markers.indexOf(e4),1)}}},6107:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.BufferLine=t4.DEFAULT_ATTR_DATA=void 0;let i3=s3(5451),r7=s3(3055),n3=s3(8938),o2=s3(726);t4.DEFAULT_ATTR_DATA=Object.freeze(new i3.AttributeData);let a2=0;class h2{constructor(e4,t5,s4=!1){this.isWrapped=s4,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e4);let i4=t5||r7.CellData.fromCharData([0,n3.NULL_CELL_CHAR,n3.NULL_CELL_WIDTH,n3.NULL_CELL_CODE]);for(let t6=0;t6<e4;++t6)this.setCell(t6,i4);this.length=e4}get(e4){let t5=this._data[3*e4+0],s4=2097151&t5;return[this._data[3*e4+1],2097152&t5?this._combined[e4]:s4?(0,o2.stringFromCodePoint)(s4):"",t5>>22,2097152&t5?this._combined[e4].charCodeAt(this._combined[e4].length-1):s4]}set(e4,t5){this._data[3*e4+1]=t5[n3.CHAR_DATA_ATTR_INDEX],t5[n3.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e4]=t5[1],this._data[3*e4+0]=2097152|e4|t5[n3.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e4+0]=t5[n3.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t5[n3.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(e4){return this._data[3*e4+0]>>22}hasWidth(e4){return 12582912&this._data[3*e4+0]}getFg(e4){return this._data[3*e4+1]}getBg(e4){return this._data[3*e4+2]}hasContent(e4){return 4194303&this._data[3*e4+0]}getCodePoint(e4){let t5=this._data[3*e4+0];return 2097152&t5?this._combined[e4].charCodeAt(this._combined[e4].length-1):2097151&t5}isCombined(e4){return 2097152&this._data[3*e4+0]}getString(e4){let t5=this._data[3*e4+0];return 2097152&t5?this._combined[e4]:2097151&t5?(0,o2.stringFromCodePoint)(2097151&t5):""}isProtected(e4){return 536870912&this._data[3*e4+2]}loadCell(e4,t5){return a2=3*e4,t5.content=this._data[a2+0],t5.fg=this._data[a2+1],t5.bg=this._data[a2+2],2097152&t5.content&&(t5.combinedData=this._combined[e4]),268435456&t5.bg&&(t5.extended=this._extendedAttrs[e4]),t5}setCell(e4,t5){2097152&t5.content&&(this._combined[e4]=t5.combinedData),268435456&t5.bg&&(this._extendedAttrs[e4]=t5.extended),this._data[3*e4+0]=t5.content,this._data[3*e4+1]=t5.fg,this._data[3*e4+2]=t5.bg}setCellFromCodepoint(e4,t5,s4,i4){268435456&i4.bg&&(this._extendedAttrs[e4]=i4.extended),this._data[3*e4+0]=t5|s4<<22,this._data[3*e4+1]=i4.fg,this._data[3*e4+2]=i4.bg}addCodepointToCell(e4,t5,s4){let i4=this._data[3*e4+0];2097152&i4?this._combined[e4]+=(0,o2.stringFromCodePoint)(t5):2097151&i4?(this._combined[e4]=(0,o2.stringFromCodePoint)(2097151&i4)+(0,o2.stringFromCodePoint)(t5),i4&=-2097152,i4|=2097152):i4=t5|4194304,s4&&(i4&=-12582913,i4|=s4<<22),this._data[3*e4+0]=i4}insertCells(e4,t5,s4){if((e4%=this.length)&&this.getWidth(e4-1)===2&&this.setCellFromCodepoint(e4-1,0,1,s4),t5<this.length-e4){let i4=new r7.CellData;for(let s5=this.length-e4-t5-1;s5>=0;--s5)this.setCell(e4+t5+s5,this.loadCell(e4+s5,i4));for(let i5=0;i5<t5;++i5)this.setCell(e4+i5,s4)}else for(let t6=e4;t6<this.length;++t6)this.setCell(t6,s4);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s4)}deleteCells(e4,t5,s4){if(e4%=this.length,t5<this.length-e4){let i4=new r7.CellData;for(let s5=0;s5<this.length-e4-t5;++s5)this.setCell(e4+s5,this.loadCell(e4+t5+s5,i4));for(let e5=this.length-t5;e5<this.length;++e5)this.setCell(e5,s4)}else for(let t6=e4;t6<this.length;++t6)this.setCell(t6,s4);e4&&this.getWidth(e4-1)===2&&this.setCellFromCodepoint(e4-1,0,1,s4),this.getWidth(e4)!==0||this.hasContent(e4)||this.setCellFromCodepoint(e4,0,1,s4)}replaceCells(e4,t5,s4,i4=!1){if(i4)for(e4&&this.getWidth(e4-1)===2&&!this.isProtected(e4-1)&&this.setCellFromCodepoint(e4-1,0,1,s4),t5<this.length&&this.getWidth(t5-1)===2&&!this.isProtected(t5)&&this.setCellFromCodepoint(t5,0,1,s4);e4<t5&&e4<this.length;)this.isProtected(e4)||this.setCell(e4,s4),e4++;else for(e4&&this.getWidth(e4-1)===2&&this.setCellFromCodepoint(e4-1,0,1,s4),t5<this.length&&this.getWidth(t5-1)===2&&this.setCellFromCodepoint(t5,0,1,s4);e4<t5&&e4<this.length;)this.setCell(e4++,s4)}resize(e4,t5){if(e4===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let s4=3*e4;if(e4>this.length){if(this._data.buffer.byteLength>=4*s4)this._data=new Uint32Array(this._data.buffer,0,s4);else{let e5=new Uint32Array(s4);e5.set(this._data),this._data=e5}for(let s5=this.length;s5<e4;++s5)this.setCell(s5,t5)}else{this._data=this._data.subarray(0,s4);let t6=Object.keys(this._combined);for(let s5=0;s5<t6.length;s5++){let i5=parseInt(t6[s5],10);i5>=e4&&delete this._combined[i5]}let i4=Object.keys(this._extendedAttrs);for(let t7=0;t7<i4.length;t7++){let s5=parseInt(i4[t7],10);s5>=e4&&delete this._extendedAttrs[s5]}}return this.length=e4,4*s4*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e4=new Uint32Array(this._data.length);return e4.set(this._data),this._data=e4,1}return 0}fill(e4,t5=!1){if(t5)for(let t6=0;t6<this.length;++t6)this.isProtected(t6)||this.setCell(t6,e4);else{this._combined={},this._extendedAttrs={};for(let t6=0;t6<this.length;++t6)this.setCell(t6,e4)}}copyFrom(e4){this.length!==e4.length?this._data=new Uint32Array(e4._data):this._data.set(e4._data),this.length=e4.length,this._combined={};for(let t5 in e4._combined)this._combined[t5]=e4._combined[t5];this._extendedAttrs={};for(let t5 in e4._extendedAttrs)this._extendedAttrs[t5]=e4._extendedAttrs[t5];this.isWrapped=e4.isWrapped}clone(){let e4=new h2(0);e4._data=new Uint32Array(this._data),e4.length=this.length;for(let t5 in this._combined)e4._combined[t5]=this._combined[t5];for(let t5 in this._extendedAttrs)e4._extendedAttrs[t5]=this._extendedAttrs[t5];return e4.isWrapped=this.isWrapped,e4}getTrimmedLength(){for(let e4=this.length-1;e4>=0;--e4)if(4194303&this._data[3*e4+0])return e4+(this._data[3*e4+0]>>22);return 0}getNoBgTrimmedLength(){for(let e4=this.length-1;e4>=0;--e4)if(4194303&this._data[3*e4+0]||50331648&this._data[3*e4+2])return e4+(this._data[3*e4+0]>>22);return 0}copyCellsFrom(e4,t5,s4,i4,r8){let n4=e4._data;if(r8)for(let r9=i4-1;r9>=0;r9--){for(let e5=0;e5<3;e5++)this._data[3*(s4+r9)+e5]=n4[3*(t5+r9)+e5];268435456&n4[3*(t5+r9)+2]&&(this._extendedAttrs[s4+r9]=e4._extendedAttrs[t5+r9])}else for(let r9=0;r9<i4;r9++){for(let e5=0;e5<3;e5++)this._data[3*(s4+r9)+e5]=n4[3*(t5+r9)+e5];268435456&n4[3*(t5+r9)+2]&&(this._extendedAttrs[s4+r9]=e4._extendedAttrs[t5+r9])}let o3=Object.keys(e4._combined);for(let i5=0;i5<o3.length;i5++){let r9=parseInt(o3[i5],10);r9>=t5&&(this._combined[r9-t5+s4]=e4._combined[r9])}}translateToString(e4,t5,s4,i4){t5=t5??0,s4=s4??this.length,e4&&(s4=Math.min(s4,this.getTrimmedLength())),i4&&(i4.length=0);let r8="";for(;t5<s4;){let e5=this._data[3*t5+0],s5=2097151&e5,a3=2097152&e5?this._combined[t5]:s5?(0,o2.stringFromCodePoint)(s5):n3.WHITESPACE_CELL_CHAR;if(r8+=a3,i4)for(let e6=0;e6<a3.length;++e6)i4.push(t5);t5+=e5>>22||1}return i4&&i4.push(t5),r8}}t4.BufferLine=h2},732:(e3,t4)=>{function s3(e4,t5,s4){if(t5===e4.length-1)return e4[t5].getTrimmedLength();let i3=!e4[t5].hasContent(s4-1)&&e4[t5].getWidth(s4-1)===1,r7=e4[t5+1].getWidth(0)===2;return i3&&r7?s4-1:s4}Object.defineProperty(t4,"__esModule",{value:!0}),t4.reflowLargerGetLinesToRemove=function(e4,t5,i3,r7,n3,o2){let a2=[];for(let h2=0;h2<e4.length-1;h2++){let c2=h2,l2=e4.get(++c2);if(!l2.isWrapped)continue;let u2=[e4.get(h2)];for(;c2<e4.length&&l2.isWrapped;)u2.push(l2),l2=e4.get(++c2);if(!o2&&r7>=h2&&r7<c2){h2+=u2.length-1;continue}let d2=0,f2=s3(u2,d2,t5),_4=1,p3=0;for(;_4<u2.length;){let e5=s3(u2,_4,t5),r8=e5-p3,o3=i3-f2,a3=Math.min(r8,o3);u2[d2].copyCellsFrom(u2[_4],p3,f2,a3,!1),f2+=a3,f2===i3&&(d2++,f2=0),p3+=a3,p3===e5&&(_4++,p3=0),f2===0&&d2!==0&&u2[d2-1].getWidth(i3-1)===2&&(u2[d2].copyCellsFrom(u2[d2-1],i3-1,f2++,1,!1),u2[d2-1].setCell(i3-1,n3))}u2[d2].replaceCells(f2,i3,n3);let g3=0;for(let e5=u2.length-1;e5>0&&(e5>d2||u2[e5].getTrimmedLength()===0);e5--)g3++;g3>0&&(a2.push(h2+u2.length-g3),a2.push(g3)),h2+=u2.length-1}return a2},t4.reflowLargerCreateNewLayout=function(e4,t5){let s4=[],i3=0,r7=t5[i3],n3=0;for(let o2=0;o2<e4.length;o2++)if(r7===o2){let s5=t5[++i3];e4.onDeleteEmitter.fire({index:o2-n3,amount:s5}),o2+=s5-1,n3+=s5,r7=t5[++i3]}else s4.push(o2);return{layout:s4,countRemoved:n3}},t4.reflowLargerApplyNewLayout=function(e4,t5){let s4=[];for(let i3=0;i3<t5.length;i3++)s4.push(e4.get(t5[i3]));for(let t6=0;t6<s4.length;t6++)e4.set(t6,s4[t6]);e4.length=t5.length},t4.reflowSmallerGetNewLineLengths=function(e4,t5,i3){let r7=[],n3=e4.map((i4,r8)=>s3(e4,r8,t5)).reduce((e5,t6)=>e5+t6),o2=0,a2=0,h2=0;for(;h2<n3;){if(n3-h2<i3){r7.push(n3-h2);break}o2+=i3;let c2=s3(e4,a2,t5);o2>c2&&(o2-=c2,a2++);let l2=e4[a2].getWidth(o2-1)===2;l2&&o2--;let u2=l2?i3-1:i3;r7.push(u2),h2+=u2}return r7},t4.getWrappedLineTrimmedLength=s3},4097:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.BufferSet=void 0;let i3=s3(7150),r7=s3(1073),n3=s3(802);class o2 extends i3.Disposable{constructor(e4,t5){super(),this._optionsService=e4,this._bufferService=t5,this._onBufferActivate=this._register(new n3.Emitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new r7.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new r7.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e4){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e4),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e4,t5){this._normal.resize(e4,t5),this._alt.resize(e4,t5),this.setupTabStops(e4)}setupTabStops(e4){this._normal.setupTabStops(e4),this._alt.setupTabStops(e4)}}t4.BufferSet=o2},3055:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.CellData=void 0;let i3=s3(726),r7=s3(8938),n3=s3(5451);class o2 extends n3.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new n3.ExtendedAttrs,this.combinedData=""}static fromCharData(e4){let t5=new o2;return t5.setFromCharData(e4),t5}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,i3.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e4){this.fg=e4[r7.CHAR_DATA_ATTR_INDEX],this.bg=0;let t5=!1;if(e4[r7.CHAR_DATA_CHAR_INDEX].length>2)t5=!0;else if(e4[r7.CHAR_DATA_CHAR_INDEX].length===2){let s4=e4[r7.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=s4&&s4<=56319){let i4=e4[r7.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=i4&&i4<=57343?this.content=1024*(s4-55296)+i4-56320+65536|e4[r7.CHAR_DATA_WIDTH_INDEX]<<22:t5=!0}else t5=!0}else this.content=e4[r7.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e4[r7.CHAR_DATA_WIDTH_INDEX]<<22;t5&&(this.combinedData=e4[r7.CHAR_DATA_CHAR_INDEX],this.content=2097152|e4[r7.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t4.CellData=o2},8938:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.WHITESPACE_CELL_CODE=t4.WHITESPACE_CELL_WIDTH=t4.WHITESPACE_CELL_CHAR=t4.NULL_CELL_CODE=t4.NULL_CELL_WIDTH=t4.NULL_CELL_CHAR=t4.CHAR_DATA_CODE_INDEX=t4.CHAR_DATA_WIDTH_INDEX=t4.CHAR_DATA_CHAR_INDEX=t4.CHAR_DATA_ATTR_INDEX=t4.DEFAULT_EXT=t4.DEFAULT_ATTR=t4.DEFAULT_COLOR=void 0,t4.DEFAULT_COLOR=0,t4.DEFAULT_ATTR=t4.DEFAULT_COLOR<<9|256,t4.DEFAULT_EXT=0,t4.CHAR_DATA_ATTR_INDEX=0,t4.CHAR_DATA_CHAR_INDEX=1,t4.CHAR_DATA_WIDTH_INDEX=2,t4.CHAR_DATA_CODE_INDEX=3,t4.NULL_CELL_CHAR="",t4.NULL_CELL_WIDTH=1,t4.NULL_CELL_CODE=0,t4.WHITESPACE_CELL_CHAR=" ",t4.WHITESPACE_CELL_WIDTH=1,t4.WHITESPACE_CELL_CODE=32},8158:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.Marker=void 0;let i3=s3(802),r7=s3(7150);class n3{get id(){return this._id}constructor(e4){this.line=e4,this.isDisposed=!1,this._disposables=[],this._id=n3._nextId++,this._onDispose=this.register(new i3.Emitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,r7.dispose)(this._disposables),this._disposables.length=0)}register(e4){return this._disposables.push(e4),e4}}t4.Marker=n3,n3._nextId=1},6760:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.DEFAULT_CHARSET=t4.CHARSETS=void 0,t4.CHARSETS={},t4.DEFAULT_CHARSET=t4.CHARSETS.B,t4.CHARSETS[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"},t4.CHARSETS.A={"#":"\xA3"},t4.CHARSETS.B=void 0,t4.CHARSETS[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"},t4.CHARSETS.C=t4.CHARSETS[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},t4.CHARSETS.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"},t4.CHARSETS.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"},t4.CHARSETS.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"},t4.CHARSETS.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"},t4.CHARSETS.E=t4.CHARSETS[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"},t4.CHARSETS.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"},t4.CHARSETS.H=t4.CHARSETS[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},t4.CHARSETS["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"}},3534:(e3,t4)=>{var s3,i3,r7;Object.defineProperty(t4,"__esModule",{value:!0}),t4.C1_ESCAPED=t4.C1=t4.C0=void 0,function(e4){e4.NUL="\x00",e4.SOH="\x01",e4.STX="\x02",e4.ETX="\x03",e4.EOT="\x04",e4.ENQ="\x05",e4.ACK="\x06",e4.BEL="\x07",e4.BS="\b",e4.HT="\t",e4.LF=`
3
3
  `,e4.VT="\v",e4.FF="\f",e4.CR="\r",e4.SO="\x0E",e4.SI="\x0F",e4.DLE="\x10",e4.DC1="\x11",e4.DC2="\x12",e4.DC3="\x13",e4.DC4="\x14",e4.NAK="\x15",e4.SYN="\x16",e4.ETB="\x17",e4.CAN="\x18",e4.EM="\x19",e4.SUB="\x1A",e4.ESC="\x1B",e4.FS="\x1C",e4.GS="\x1D",e4.RS="\x1E",e4.US="\x1F",e4.SP=" ",e4.DEL="\x7F"}(s3||(t4.C0=s3={})),function(e4){e4.PAD="\x80",e4.HOP="\x81",e4.BPH="\x82",e4.NBH="\x83",e4.IND="\x84",e4.NEL="\x85",e4.SSA="\x86",e4.ESA="\x87",e4.HTS="\x88",e4.HTJ="\x89",e4.VTS="\x8A",e4.PLD="\x8B",e4.PLU="\x8C",e4.RI="\x8D",e4.SS2="\x8E",e4.SS3="\x8F",e4.DCS="\x90",e4.PU1="\x91",e4.PU2="\x92",e4.STS="\x93",e4.CCH="\x94",e4.MW="\x95",e4.SPA="\x96",e4.EPA="\x97",e4.SOS="\x98",e4.SGCI="\x99",e4.SCI="\x9A",e4.CSI="\x9B",e4.ST="\x9C",e4.OSC="\x9D",e4.PM="\x9E",e4.APC="\x9F"}(i3||(t4.C1=i3={})),function(e4){e4.ST=`${s3.ESC}\\`}(r7||(t4.C1_ESCAPED=r7={}))},726:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.Utf8ToUtf32=t4.StringToUtf32=void 0,t4.stringFromCodePoint=function(e4){return e4>65535?(e4-=65536,String.fromCharCode(55296+(e4>>10))+String.fromCharCode(e4%1024+56320)):String.fromCharCode(e4)},t4.utf32ToString=function(e4,t5=0,s3=e4.length){let i3="";for(let r7=t5;r7<s3;++r7){let t6=e4[r7];t6>65535?(t6-=65536,i3+=String.fromCharCode(55296+(t6>>10))+String.fromCharCode(t6%1024+56320)):i3+=String.fromCharCode(t6)}return i3},t4.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e4,t5){let s3=e4.length;if(!s3)return 0;let i3=0,r7=0;if(this._interim){let s4=e4.charCodeAt(r7++);56320<=s4&&s4<=57343?t5[i3++]=1024*(this._interim-55296)+s4-56320+65536:(t5[i3++]=this._interim,t5[i3++]=s4),this._interim=0}for(let n3=r7;n3<s3;++n3){let r8=e4.charCodeAt(n3);if(55296<=r8&&r8<=56319){if(++n3>=s3)return this._interim=r8,i3;let o2=e4.charCodeAt(n3);56320<=o2&&o2<=57343?t5[i3++]=1024*(r8-55296)+o2-56320+65536:(t5[i3++]=r8,t5[i3++]=o2)}else r8!==65279&&(t5[i3++]=r8)}return i3}},t4.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e4,t5){let s3=e4.length;if(!s3)return 0;let i3,r7,n3,o2,a2=0,h2=0,c2=0;if(this.interim[0]){let i4=!1,r8=this.interim[0];r8&=(224&r8)==192?31:(240&r8)==224?15:7;let n4,o3=0;for(;(n4=63&this.interim[++o3])&&o3<4;)r8<<=6,r8|=n4;let h3=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,l3=h3-o3;for(;c2<l3;){if(c2>=s3)return 0;if(n4=e4[c2++],(192&n4)!=128){c2--,i4=!0;break}this.interim[o3++]=n4,r8<<=6,r8|=63&n4}i4||(h3===2?r8<128?c2--:t5[a2++]=r8:h3===3?r8<2048||r8>=55296&&r8<=57343||r8===65279||(t5[a2++]=r8):r8<65536||r8>1114111||(t5[a2++]=r8)),this.interim.fill(0)}let l2=s3-4,u2=c2;for(;u2<s3;){for(;!(!(u2<l2)||128&(i3=e4[u2])||128&(r7=e4[u2+1])||128&(n3=e4[u2+2])||128&(o2=e4[u2+3]));)t5[a2++]=i3,t5[a2++]=r7,t5[a2++]=n3,t5[a2++]=o2,u2+=4;if(i3=e4[u2++],i3<128)t5[a2++]=i3;else if((224&i3)==192){if(u2>=s3)return this.interim[0]=i3,a2;if(r7=e4[u2++],(192&r7)!=128){u2--;continue}if(h2=(31&i3)<<6|63&r7,h2<128){u2--;continue}t5[a2++]=h2}else if((240&i3)==224){if(u2>=s3)return this.interim[0]=i3,a2;if(r7=e4[u2++],(192&r7)!=128){u2--;continue}if(u2>=s3)return this.interim[0]=i3,this.interim[1]=r7,a2;if(n3=e4[u2++],(192&n3)!=128){u2--;continue}if(h2=(15&i3)<<12|(63&r7)<<6|63&n3,h2<2048||h2>=55296&&h2<=57343||h2===65279)continue;t5[a2++]=h2}else if((248&i3)==240){if(u2>=s3)return this.interim[0]=i3,a2;if(r7=e4[u2++],(192&r7)!=128){u2--;continue}if(u2>=s3)return this.interim[0]=i3,this.interim[1]=r7,a2;if(n3=e4[u2++],(192&n3)!=128){u2--;continue}if(u2>=s3)return this.interim[0]=i3,this.interim[1]=r7,this.interim[2]=n3,a2;if(o2=e4[u2++],(192&o2)!=128){u2--;continue}if(h2=(7&i3)<<18|(63&r7)<<12|(63&n3)<<6|63&o2,h2<65536||h2>1114111)continue;t5[a2++]=h2}}return a2}}},7428:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.UnicodeV6=void 0;let i3=s3(6415),r7=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],n3=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],o2;t4.UnicodeV6=class{constructor(){if(this.version="6",!o2){o2=new Uint8Array(65536),o2.fill(1),o2[0]=0,o2.fill(0,1,32),o2.fill(0,127,160),o2.fill(2,4352,4448),o2[9001]=2,o2[9002]=2,o2.fill(2,11904,42192),o2[12351]=1,o2.fill(2,44032,55204),o2.fill(2,63744,64256),o2.fill(2,65040,65050),o2.fill(2,65072,65136),o2.fill(2,65280,65377),o2.fill(2,65504,65511);for(let e4=0;e4<r7.length;++e4)o2.fill(0,r7[e4][0],r7[e4][1]+1)}}wcwidth(e4){return e4<32?0:e4<127?1:e4<65536?o2[e4]:function(e5,t5){let s4,i4=0,r8=t5.length-1;if(e5<t5[0][0]||e5>t5[r8][1])return!1;for(;r8>=i4;)if(s4=i4+r8>>1,e5>t5[s4][1])i4=s4+1;else{if(!(e5<t5[s4][0]))return!0;r8=s4-1}return!1}(e4,n3)?0:e4>=131072&&e4<=196605||e4>=196608&&e4<=262141?2:1}charProperties(e4,t5){let s4=this.wcwidth(e4),r8=s4===0&&t5!==0;if(r8){let e5=i3.UnicodeService.extractWidth(t5);e5===0?r8=!1:e5>s4&&(s4=e5)}return i3.UnicodeService.createPropertyValue(0,s4,r8)}}},3562:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.WriteBuffer=void 0;let i3=s3(7150),r7=s3(802);class n3 extends i3.Disposable{constructor(e4){super(),this._action=e4,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new r7.Emitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e4,t5){if(t5!==void 0&&this._syncCalls>t5)return void(this._syncCalls=0);if(this._pendingData+=e4.length,this._writeBuffer.push(e4),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let s4;for(this._isSyncWriting=!0;s4=this._writeBuffer.shift();){this._action(s4);let e5=this._callbacks.shift();e5&&e5()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e4,t5){if(this._pendingData>50000000)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=e4.length,this._writeBuffer.push(e4),this._callbacks.push(t5),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=e4.length,this._writeBuffer.push(e4),this._callbacks.push(t5)}_innerWrite(e4=0,t5=!0){let s4=e4||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e5=this._writeBuffer[this._bufferOffset],i4=this._action(e5,t5);if(i4){let e6=(e7)=>performance.now()-s4>=12?setTimeout(()=>this._innerWrite(0,e7)):this._innerWrite(s4,e7);return void i4.catch((e7)=>(queueMicrotask(()=>{throw e7}),Promise.resolve(!1))).then(e6)}let r8=this._callbacks[this._bufferOffset];if(r8&&r8(),this._bufferOffset++,this._pendingData-=e5.length,performance.now()-s4>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}t4.WriteBuffer=n3},8693:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.parseColor=function(e4){if(!e4)return;let t5=e4.toLowerCase();if(t5.indexOf("rgb:")===0){t5=t5.slice(4);let e5=s3.exec(t5);if(e5){let t6=e5[1]?15:e5[4]?255:e5[7]?4095:65535;return[Math.round(parseInt(e5[1]||e5[4]||e5[7]||e5[10],16)/t6*255),Math.round(parseInt(e5[2]||e5[5]||e5[8]||e5[11],16)/t6*255),Math.round(parseInt(e5[3]||e5[6]||e5[9]||e5[12],16)/t6*255)]}}else if(t5.indexOf("#")===0&&(t5=t5.slice(1),i3.exec(t5)&&[3,6,9,12].includes(t5.length))){let e5=t5.length/3,s4=[0,0,0];for(let i4=0;i4<3;++i4){let r8=parseInt(t5.slice(e5*i4,e5*i4+e5),16);s4[i4]=e5===1?r8<<4:e5===2?r8:e5===3?r8>>4:r8>>8}return s4}},t4.toRgbString=function(e4,t5=16){let[s4,i4,n3]=e4;return`rgb:${r7(s4,t5)}/${r7(i4,t5)}/${r7(n3,t5)}`};let s3=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,i3=/^[\da-f]+$/;function r7(e4,t5){let s4=e4.toString(16),i4=s4.length<2?"0"+s4:s4;switch(t5){case 4:return s4[0];case 8:return i4;case 12:return(i4+i4).slice(0,3);default:return i4+i4}}},1263:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.PAYLOAD_LIMIT=void 0,t4.PAYLOAD_LIMIT=1e7},9823:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.DcsHandler=t4.DcsParser=void 0;let i3=s3(726),r7=s3(7262),n3=s3(1263),o2=[];t4.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=o2,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o2}registerHandler(e4,t5){this._handlers[e4]===void 0&&(this._handlers[e4]=[]);let s4=this._handlers[e4];return s4.push(t5),{dispose:()=>{let e5=s4.indexOf(t5);e5!==-1&&s4.splice(e5,1)}}}clearHandler(e4){this._handlers[e4]&&delete this._handlers[e4]}setHandlerFallback(e4){this._handlerFb=e4}reset(){if(this._active.length)for(let e4=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e4>=0;--e4)this._active[e4].unhook(!1);this._stack.paused=!1,this._active=o2,this._ident=0}hook(e4,t5){if(this.reset(),this._ident=e4,this._active=this._handlers[e4]||o2,this._active.length)for(let e5=this._active.length-1;e5>=0;e5--)this._active[e5].hook(t5);else this._handlerFb(this._ident,"HOOK",t5)}put(e4,t5,s4){if(this._active.length)for(let i4=this._active.length-1;i4>=0;i4--)this._active[i4].put(e4,t5,s4);else this._handlerFb(this._ident,"PUT",(0,i3.utf32ToString)(e4,t5,s4))}unhook(e4,t5=!0){if(this._active.length){let s4=!1,i4=this._active.length-1,r8=!1;if(this._stack.paused&&(i4=this._stack.loopPosition-1,s4=t5,r8=this._stack.fallThrough,this._stack.paused=!1),!r8&&s4===!1){for(;i4>=0&&(s4=this._active[i4].unhook(e4),s4!==!0);i4--)if(s4 instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i4,this._stack.fallThrough=!1,s4;i4--}for(;i4>=0;i4--)if(s4=this._active[i4].unhook(!1),s4 instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i4,this._stack.fallThrough=!0,s4}else this._handlerFb(this._ident,"UNHOOK",e4);this._active=o2,this._ident=0}};let a2=new r7.Params;a2.addParam(0),t4.DcsHandler=class{constructor(e4){this._handler=e4,this._data="",this._params=a2,this._hitLimit=!1}hook(e4){this._params=e4.length>1||e4.params[0]?e4.clone():a2,this._data="",this._hitLimit=!1}put(e4,t5,s4){this._hitLimit||(this._data+=(0,i3.utf32ToString)(e4,t5,s4),this._data.length>n3.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(e4){let t5=!1;if(this._hitLimit)t5=!1;else if(e4&&(t5=this._handler(this._data,this._params),t5 instanceof Promise))return t5.then((e5)=>(this._params=a2,this._data="",this._hitLimit=!1,e5));return this._params=a2,this._data="",this._hitLimit=!1,t5}}},6717:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.EscapeSequenceParser=t4.VT500_TRANSITION_TABLE=t4.TransitionTable=void 0;let i3=s3(7150),r7=s3(7262),n3=s3(1346),o2=s3(9823);class a2{constructor(e4){this.table=new Uint8Array(e4)}setDefault(e4,t5){this.table.fill(e4<<4|t5)}add(e4,t5,s4,i4){this.table[t5<<8|e4]=s4<<4|i4}addMany(e4,t5,s4,i4){for(let r8=0;r8<e4.length;r8++)this.table[t5<<8|e4[r8]]=s4<<4|i4}}t4.TransitionTable=a2;let h2=160;t4.VT500_TRANSITION_TABLE=function(){let e4=new a2(4095),t5=Array.apply(null,Array(256)).map((e5,t6)=>t6),s4=(e5,s5)=>t5.slice(e5,s5),i4=s4(32,127),r8=s4(0,24);r8.push(25),r8.push.apply(r8,s4(28,32));let n4=s4(0,14),o3;for(o3 in e4.setDefault(1,0),e4.addMany(i4,0,2,0),n4)e4.addMany([24,26,153,154],o3,3,0),e4.addMany(s4(128,144),o3,3,0),e4.addMany(s4(144,152),o3,3,0),e4.add(156,o3,0,0),e4.add(27,o3,11,1),e4.add(157,o3,4,8),e4.addMany([152,158,159],o3,0,7),e4.add(155,o3,11,3),e4.add(144,o3,11,9);return e4.addMany(r8,0,3,0),e4.addMany(r8,1,3,1),e4.add(127,1,0,1),e4.addMany(r8,8,0,8),e4.addMany(r8,3,3,3),e4.add(127,3,0,3),e4.addMany(r8,4,3,4),e4.add(127,4,0,4),e4.addMany(r8,6,3,6),e4.addMany(r8,5,3,5),e4.add(127,5,0,5),e4.addMany(r8,2,3,2),e4.add(127,2,0,2),e4.add(93,1,4,8),e4.addMany(i4,8,5,8),e4.add(127,8,5,8),e4.addMany([156,27,24,26,7],8,6,0),e4.addMany(s4(28,32),8,0,8),e4.addMany([88,94,95],1,0,7),e4.addMany(i4,7,0,7),e4.addMany(r8,7,0,7),e4.add(156,7,0,0),e4.add(127,7,0,7),e4.add(91,1,11,3),e4.addMany(s4(64,127),3,7,0),e4.addMany(s4(48,60),3,8,4),e4.addMany([60,61,62,63],3,9,4),e4.addMany(s4(48,60),4,8,4),e4.addMany(s4(64,127),4,7,0),e4.addMany([60,61,62,63],4,0,6),e4.addMany(s4(32,64),6,0,6),e4.add(127,6,0,6),e4.addMany(s4(64,127),6,0,0),e4.addMany(s4(32,48),3,9,5),e4.addMany(s4(32,48),5,9,5),e4.addMany(s4(48,64),5,0,6),e4.addMany(s4(64,127),5,7,0),e4.addMany(s4(32,48),4,9,5),e4.addMany(s4(32,48),1,9,2),e4.addMany(s4(32,48),2,9,2),e4.addMany(s4(48,127),2,10,0),e4.addMany(s4(48,80),1,10,0),e4.addMany(s4(81,88),1,10,0),e4.addMany([89,90,92],1,10,0),e4.addMany(s4(96,127),1,10,0),e4.add(80,1,11,9),e4.addMany(r8,9,0,9),e4.add(127,9,0,9),e4.addMany(s4(28,32),9,0,9),e4.addMany(s4(32,48),9,9,12),e4.addMany(s4(48,60),9,8,10),e4.addMany([60,61,62,63],9,9,10),e4.addMany(r8,11,0,11),e4.addMany(s4(32,128),11,0,11),e4.addMany(s4(28,32),11,0,11),e4.addMany(r8,10,0,10),e4.add(127,10,0,10),e4.addMany(s4(28,32),10,0,10),e4.addMany(s4(48,60),10,8,10),e4.addMany([60,61,62,63],10,0,11),e4.addMany(s4(32,48),10,9,12),e4.addMany(r8,12,0,12),e4.add(127,12,0,12),e4.addMany(s4(28,32),12,0,12),e4.addMany(s4(32,48),12,9,12),e4.addMany(s4(48,64),12,0,11),e4.addMany(s4(64,127),12,12,13),e4.addMany(s4(64,127),10,12,13),e4.addMany(s4(64,127),9,12,13),e4.addMany(r8,13,13,13),e4.addMany(i4,13,13,13),e4.add(127,13,0,13),e4.addMany([27,156,24,26],13,14,0),e4.add(h2,0,2,0),e4.add(h2,8,5,8),e4.add(h2,6,0,6),e4.add(h2,11,0,11),e4.add(h2,13,13,13),e4}();class c2 extends i3.Disposable{constructor(e4=t4.VT500_TRANSITION_TABLE){super(),this._transitions=e4,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new r7.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e5,t5,s4)=>{},this._executeHandlerFb=(e5)=>{},this._csiHandlerFb=(e5,t5)=>{},this._escHandlerFb=(e5)=>{},this._errorHandlerFb=(e5)=>e5,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register((0,i3.toDisposable)(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new n3.OscParser),this._dcsParser=this._register(new o2.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e4,t5=[64,126]){let s4=0;if(e4.prefix){if(e4.prefix.length>1)throw Error("only one byte as prefix supported");if(s4=e4.prefix.charCodeAt(0),s4&&60>s4||s4>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(e4.intermediates){if(e4.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let t6=0;t6<e4.intermediates.length;++t6){let i5=e4.intermediates.charCodeAt(t6);if(32>i5||i5>47)throw Error("intermediate must be in range 0x20 .. 0x2f");s4<<=8,s4|=i5}}if(e4.final.length!==1)throw Error("final must be a single byte");let i4=e4.final.charCodeAt(0);if(t5[0]>i4||i4>t5[1])throw Error(`final must be in range ${t5[0]} .. ${t5[1]}`);return s4<<=8,s4|=i4,s4}identToString(e4){let t5=[];for(;e4;)t5.push(String.fromCharCode(255&e4)),e4>>=8;return t5.reverse().join("")}setPrintHandler(e4){this._printHandler=e4}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e4,t5){let s4=this._identifier(e4,[48,126]);this._escHandlers[s4]===void 0&&(this._escHandlers[s4]=[]);let i4=this._escHandlers[s4];return i4.push(t5),{dispose:()=>{let e5=i4.indexOf(t5);e5!==-1&&i4.splice(e5,1)}}}clearEscHandler(e4){this._escHandlers[this._identifier(e4,[48,126])]&&delete this._escHandlers[this._identifier(e4,[48,126])]}setEscHandlerFallback(e4){this._escHandlerFb=e4}setExecuteHandler(e4,t5){this._executeHandlers[e4.charCodeAt(0)]=t5}clearExecuteHandler(e4){this._executeHandlers[e4.charCodeAt(0)]&&delete this._executeHandlers[e4.charCodeAt(0)]}setExecuteHandlerFallback(e4){this._executeHandlerFb=e4}registerCsiHandler(e4,t5){let s4=this._identifier(e4);this._csiHandlers[s4]===void 0&&(this._csiHandlers[s4]=[]);let i4=this._csiHandlers[s4];return i4.push(t5),{dispose:()=>{let e5=i4.indexOf(t5);e5!==-1&&i4.splice(e5,1)}}}clearCsiHandler(e4){this._csiHandlers[this._identifier(e4)]&&delete this._csiHandlers[this._identifier(e4)]}setCsiHandlerFallback(e4){this._csiHandlerFb=e4}registerDcsHandler(e4,t5){return this._dcsParser.registerHandler(this._identifier(e4),t5)}clearDcsHandler(e4){this._dcsParser.clearHandler(this._identifier(e4))}setDcsHandlerFallback(e4){this._dcsParser.setHandlerFallback(e4)}registerOscHandler(e4,t5){return this._oscParser.registerHandler(e4,t5)}clearOscHandler(e4){this._oscParser.clearHandler(e4)}setOscHandlerFallback(e4){this._oscParser.setHandlerFallback(e4)}setErrorHandler(e4){this._errorHandler=e4}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e4,t5,s4,i4,r8){this._parseStack.state=e4,this._parseStack.handlers=t5,this._parseStack.handlerPos=s4,this._parseStack.transition=i4,this._parseStack.chunkPos=r8}parse(e4,t5,s4){let i4,r8=0,n4=0,o3=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o3=this._parseStack.chunkPos+1;else{if(s4===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let t6=this._parseStack.handlers,n5=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s4===!1&&n5>-1){for(;n5>=0&&(i4=t6[n5](this._params),i4!==!0);n5--)if(i4 instanceof Promise)return this._parseStack.handlerPos=n5,i4}this._parseStack.handlers=[];break;case 4:if(s4===!1&&n5>-1){for(;n5>=0&&(i4=t6[n5](),i4!==!0);n5--)if(i4 instanceof Promise)return this._parseStack.handlerPos=n5,i4}this._parseStack.handlers=[];break;case 6:if(r8=e4[this._parseStack.chunkPos],i4=this._dcsParser.unhook(r8!==24&&r8!==26,s4),i4)return i4;r8===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r8=e4[this._parseStack.chunkPos],i4=this._oscParser.end(r8!==24&&r8!==26,s4),i4)return i4;r8===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o3=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let s5=o3;s5<t5;++s5){switch(r8=e4[s5],n4=this._transitions.table[this.currentState<<8|(r8<160?r8:h2)],n4>>4){case 2:for(let i5=s5+1;;++i5){if(i5>=t5||(r8=e4[i5])<32||r8>126&&r8<h2){this._printHandler(e4,s5,i5),s5=i5-1;break}if(++i5>=t5||(r8=e4[i5])<32||r8>126&&r8<h2){this._printHandler(e4,s5,i5),s5=i5-1;break}if(++i5>=t5||(r8=e4[i5])<32||r8>126&&r8<h2){this._printHandler(e4,s5,i5),s5=i5-1;break}if(++i5>=t5||(r8=e4[i5])<32||r8>126&&r8<h2){this._printHandler(e4,s5,i5),s5=i5-1;break}}break;case 3:this._executeHandlers[r8]?this._executeHandlers[r8]():this._executeHandlerFb(r8),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:s5,code:r8,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o4=this._csiHandlers[this._collect<<8|r8],a3=o4?o4.length-1:-1;for(;a3>=0&&(i4=o4[a3](this._params),i4!==!0);a3--)if(i4 instanceof Promise)return this._preserveStack(3,o4,a3,n4,s5),i4;a3<0&&this._csiHandlerFb(this._collect<<8|r8,this._params),this.precedingJoinState=0;break;case 8:do switch(r8){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r8-48)}while(++s5<t5&&(r8=e4[s5])>47&&r8<60);s5--;break;case 9:this._collect<<=8,this._collect|=r8;break;case 10:let c3=this._escHandlers[this._collect<<8|r8],l2=c3?c3.length-1:-1;for(;l2>=0&&(i4=c3[l2](),i4!==!0);l2--)if(i4 instanceof Promise)return this._preserveStack(4,c3,l2,n4,s5),i4;l2<0&&this._escHandlerFb(this._collect<<8|r8),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r8,this._params);break;case 13:for(let i5=s5+1;;++i5)if(i5>=t5||(r8=e4[i5])===24||r8===26||r8===27||r8>127&&r8<h2){this._dcsParser.put(e4,s5,i5),s5=i5-1;break}break;case 14:if(i4=this._dcsParser.unhook(r8!==24&&r8!==26),i4)return this._preserveStack(6,[],0,n4,s5),i4;r8===27&&(n4|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i5=s5+1;;i5++)if(i5>=t5||(r8=e4[i5])<32||r8>127&&r8<h2){this._oscParser.put(e4,s5,i5),s5=i5-1;break}break;case 6:if(i4=this._oscParser.end(r8!==24&&r8!==26),i4)return this._preserveStack(5,[],0,n4,s5),i4;r8===27&&(n4|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n4}}}t4.EscapeSequenceParser=c2},1346:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.OscHandler=t4.OscParser=void 0;let i3=s3(1263),r7=s3(726),n3=[];t4.OscParser=class{constructor(){this._state=0,this._active=n3,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e4,t5){this._handlers[e4]===void 0&&(this._handlers[e4]=[]);let s4=this._handlers[e4];return s4.push(t5),{dispose:()=>{let e5=s4.indexOf(t5);e5!==-1&&s4.splice(e5,1)}}}clearHandler(e4){this._handlers[e4]&&delete this._handlers[e4]}setHandlerFallback(e4){this._handlerFb=e4}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=n3}reset(){if(this._state===2)for(let e4=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e4>=0;--e4)this._active[e4].end(!1);this._stack.paused=!1,this._active=n3,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||n3,this._active.length)for(let e4=this._active.length-1;e4>=0;e4--)this._active[e4].start();else this._handlerFb(this._id,"START")}_put(e4,t5,s4){if(this._active.length)for(let i4=this._active.length-1;i4>=0;i4--)this._active[i4].put(e4,t5,s4);else this._handlerFb(this._id,"PUT",(0,r7.utf32ToString)(e4,t5,s4))}start(){this.reset(),this._state=1}put(e4,t5,s4){if(this._state!==3){if(this._state===1)for(;t5<s4;){let s5=e4[t5++];if(s5===59){this._state=2,this._start();break}if(s5<48||57<s5)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+s5-48}this._state===2&&s4-t5>0&&this._put(e4,t5,s4)}}end(e4,t5=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let s4=!1,i4=this._active.length-1,r8=!1;if(this._stack.paused&&(i4=this._stack.loopPosition-1,s4=t5,r8=this._stack.fallThrough,this._stack.paused=!1),!r8&&s4===!1){for(;i4>=0&&(s4=this._active[i4].end(e4),s4!==!0);i4--)if(s4 instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i4,this._stack.fallThrough=!1,s4;i4--}for(;i4>=0;i4--)if(s4=this._active[i4].end(!1),s4 instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i4,this._stack.fallThrough=!0,s4}else this._handlerFb(this._id,"END",e4);this._active=n3,this._id=-1,this._state=0}}},t4.OscHandler=class{constructor(e4){this._handler=e4,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e4,t5,s4){this._hitLimit||(this._data+=(0,r7.utf32ToString)(e4,t5,s4),this._data.length>i3.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(e4){let t5=!1;if(this._hitLimit)t5=!1;else if(e4&&(t5=this._handler(this._data),t5 instanceof Promise))return t5.then((e5)=>(this._data="",this._hitLimit=!1,e5));return this._data="",this._hitLimit=!1,t5}}},7262:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.Params=void 0;let s3=2147483647;class i3{static fromArray(e4){let t5=new i3;if(!e4.length)return t5;for(let s4=Array.isArray(e4[0])?1:0;s4<e4.length;++s4){let i4=e4[s4];if(Array.isArray(i4))for(let e5=0;e5<i4.length;++e5)t5.addSubParam(i4[e5]);else t5.addParam(i4)}return t5}constructor(e4=32,t5=32){if(this.maxLength=e4,this.maxSubParamsLength=t5,t5>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e4),this.length=0,this._subParams=new Int32Array(t5),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e4),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){let e4=new i3(this.maxLength,this.maxSubParamsLength);return e4.params.set(this.params),e4.length=this.length,e4._subParams.set(this._subParams),e4._subParamsLength=this._subParamsLength,e4._subParamsIdx.set(this._subParamsIdx),e4._rejectDigits=this._rejectDigits,e4._rejectSubDigits=this._rejectSubDigits,e4._digitIsSub=this._digitIsSub,e4}toArray(){let e4=[];for(let t5=0;t5<this.length;++t5){e4.push(this.params[t5]);let s4=this._subParamsIdx[t5]>>8,i4=255&this._subParamsIdx[t5];i4-s4>0&&e4.push(Array.prototype.slice.call(this._subParams,s4,i4))}return e4}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e4){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e4<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e4>s3?s3:e4}}addSubParam(e4){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e4<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e4>s3?s3:e4,this._subParamsIdx[this.length-1]++}}hasSubParams(e4){return(255&this._subParamsIdx[e4])-(this._subParamsIdx[e4]>>8)>0}getSubParams(e4){let t5=this._subParamsIdx[e4]>>8,s4=255&this._subParamsIdx[e4];return s4-t5>0?this._subParams.subarray(t5,s4):null}getSubParamsAll(){let e4={};for(let t5=0;t5<this.length;++t5){let s4=this._subParamsIdx[t5]>>8,i4=255&this._subParamsIdx[t5];i4-s4>0&&(e4[t5]=this._subParams.slice(s4,i4))}return e4}addDigit(e4){let t5;if(this._rejectDigits||!(t5=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i4=this._digitIsSub?this._subParams:this.params,r7=i4[t5-1];i4[t5-1]=~r7?Math.min(10*r7+e4,s3):e4}}t4.Params=i3},3027:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.AddonManager=void 0,t4.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let e4=this._addons.length-1;e4>=0;e4--)this._addons[e4].instance.dispose()}loadAddon(e4,t5){let s3={instance:t5,dispose:t5.dispose,isDisposed:!1};this._addons.push(s3),t5.dispose=()=>this._wrappedAddonDispose(s3),t5.activate(e4)}_wrappedAddonDispose(e4){if(e4.isDisposed)return;let t5=-1;for(let s3=0;s3<this._addons.length;s3++)if(this._addons[s3]===e4){t5=s3;break}if(t5===-1)throw Error("Could not dispose an addon that has not been loaded");e4.isDisposed=!0,e4.dispose.apply(e4.instance),this._addons.splice(t5,1)}}},3235:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.BufferApiView=void 0;let i3=s3(793),r7=s3(3055);t4.BufferApiView=class{constructor(e4,t5){this._buffer=e4,this.type=t5}init(e4){return this._buffer=e4,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e4){let t5=this._buffer.lines.get(e4);if(t5)return new i3.BufferLineApiView(t5)}getNullCell(){return new r7.CellData}}},793:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.BufferLineApiView=void 0;let i3=s3(3055);t4.BufferLineApiView=class{constructor(e4){this._line=e4}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e4,t5){if(!(e4<0||e4>=this._line.length))return t5?(this._line.loadCell(e4,t5),t5):this._line.loadCell(e4,new i3.CellData)}translateToString(e4,t5,s4){return this._line.translateToString(e4,t5,s4)}}},5101:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.BufferNamespaceApi=void 0;let i3=s3(3235),r7=s3(7150),n3=s3(802);class o2 extends r7.Disposable{constructor(e4){super(),this._core=e4,this._onBufferChange=this._register(new n3.Emitter),this.onBufferChange=this._onBufferChange.event,this._normal=new i3.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new i3.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}t4.BufferNamespaceApi=o2},6097:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.ParserApi=void 0,t4.ParserApi=class{constructor(e4){this._core=e4}registerCsiHandler(e4,t5){return this._core.registerCsiHandler(e4,(e5)=>t5(e5.toArray()))}addCsiHandler(e4,t5){return this.registerCsiHandler(e4,t5)}registerDcsHandler(e4,t5){return this._core.registerDcsHandler(e4,(e5,s3)=>t5(e5,s3.toArray()))}addDcsHandler(e4,t5){return this.registerDcsHandler(e4,t5)}registerEscHandler(e4,t5){return this._core.registerEscHandler(e4,t5)}addEscHandler(e4,t5){return this.registerEscHandler(e4,t5)}registerOscHandler(e4,t5){return this._core.registerOscHandler(e4,t5)}addOscHandler(e4,t5){return this.registerOscHandler(e4,t5)}}},4335:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.UnicodeApi=void 0,t4.UnicodeApi=class{constructor(e4){this._core=e4}register(e4){this._core.unicodeService.register(e4)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e4){this._core.unicodeService.activeVersion=e4}}},9640:function(e3,t4,s3){var i3=this&&this.__decorate||function(e4,t5,s4,i4){var r8,n4=arguments.length,o3=n4<3?t5:i4===null?i4=Object.getOwnPropertyDescriptor(t5,s4):i4;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o3=Reflect.decorate(e4,t5,s4,i4);else for(var a3=e4.length-1;a3>=0;a3--)(r8=e4[a3])&&(o3=(n4<3?r8(o3):n4>3?r8(t5,s4,o3):r8(t5,s4))||o3);return n4>3&&o3&&Object.defineProperty(t5,s4,o3),o3},r7=this&&this.__param||function(e4,t5){return function(s4,i4){t5(s4,i4,e4)}};Object.defineProperty(t4,"__esModule",{value:!0}),t4.BufferService=t4.MINIMUM_ROWS=t4.MINIMUM_COLS=void 0;let n3=s3(7150),o2=s3(4097),a2=s3(6501),h2=s3(802);t4.MINIMUM_COLS=2,t4.MINIMUM_ROWS=1;let c2=class extends n3.Disposable{get buffer(){return this.buffers.active}constructor(e4){super(),this.isUserScrolling=!1,this._onResize=this._register(new h2.Emitter),this.onResize=this._onResize.event,this._onScroll=this._register(new h2.Emitter),this.onScroll=this._onScroll.event,this.cols=Math.max(e4.rawOptions.cols||0,t4.MINIMUM_COLS),this.rows=Math.max(e4.rawOptions.rows||0,t4.MINIMUM_ROWS),this.buffers=this._register(new o2.BufferSet(e4,this)),this._register(this.buffers.onBufferActivate((e5)=>{this._onScroll.fire(e5.activeBuffer.ydisp)}))}resize(e4,t5){let s4=this.cols!==e4,i4=this.rows!==t5;this.cols=e4,this.rows=t5,this.buffers.resize(e4,t5),this._onResize.fire({cols:e4,rows:t5,colsChanged:s4,rowsChanged:i4})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e4,t5=!1){let s4=this.buffer,i4;i4=this._cachedBlankLine,i4&&i4.length===this.cols&&i4.getFg(0)===e4.fg&&i4.getBg(0)===e4.bg||(i4=s4.getBlankLine(e4,t5),this._cachedBlankLine=i4),i4.isWrapped=t5;let r8=s4.ybase+s4.scrollTop,n4=s4.ybase+s4.scrollBottom;if(s4.scrollTop===0){let e5=s4.lines.isFull;n4===s4.lines.length-1?e5?s4.lines.recycle().copyFrom(i4):s4.lines.push(i4.clone()):s4.lines.splice(n4+1,0,i4.clone()),e5?this.isUserScrolling&&(s4.ydisp=Math.max(s4.ydisp-1,0)):(s4.ybase++,this.isUserScrolling||s4.ydisp++)}else{let e5=n4-r8+1;s4.lines.shiftElements(r8+1,e5-1,-1),s4.lines.set(n4,i4.clone())}this.isUserScrolling||(s4.ydisp=s4.ybase),this._onScroll.fire(s4.ydisp)}scrollLines(e4,t5){let s4=this.buffer;if(e4<0){if(s4.ydisp===0)return;this.isUserScrolling=!0}else e4+s4.ydisp>=s4.ybase&&(this.isUserScrolling=!1);let i4=s4.ydisp;s4.ydisp=Math.max(Math.min(s4.ydisp+e4,s4.ybase),0),i4!==s4.ydisp&&(t5||this._onScroll.fire(s4.ydisp))}};t4.BufferService=c2,t4.BufferService=c2=i3([r7(0,a2.IOptionsService)],c2)},5746:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.CharsetService=void 0,t4.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e4){this.glevel=e4,this.charset=this._charsets[e4]}setgCharset(e4,t5){this._charsets[e4]=t5,this.glevel===e4&&(this.charset=t5)}}},7792:function(e3,t4,s3){var i3=this&&this.__decorate||function(e4,t5,s4,i4){var r8,n4=arguments.length,o3=n4<3?t5:i4===null?i4=Object.getOwnPropertyDescriptor(t5,s4):i4;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o3=Reflect.decorate(e4,t5,s4,i4);else for(var a3=e4.length-1;a3>=0;a3--)(r8=e4[a3])&&(o3=(n4<3?r8(o3):n4>3?r8(t5,s4,o3):r8(t5,s4))||o3);return n4>3&&o3&&Object.defineProperty(t5,s4,o3),o3},r7=this&&this.__param||function(e4,t5){return function(s4,i4){t5(s4,i4,e4)}};Object.defineProperty(t4,"__esModule",{value:!0}),t4.CoreMouseService=void 0;let n3=s3(6501),o2=s3(7150),a2=s3(802),h2={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:(e4)=>e4.button!==4&&e4.action===1&&(e4.ctrl=!1,e4.alt=!1,e4.shift=!1,!0)},VT200:{events:19,restrict:(e4)=>e4.action!==32},DRAG:{events:23,restrict:(e4)=>e4.action!==32||e4.button!==3},ANY:{events:31,restrict:(e4)=>!0}};function c2(e4,t5){let s4=(e4.ctrl?16:0)|(e4.shift?4:0)|(e4.alt?8:0);return e4.button===4?(s4|=64,s4|=e4.action):(s4|=3&e4.button,4&e4.button&&(s4|=64),8&e4.button&&(s4|=128),e4.action===32?s4|=32:e4.action!==0||t5||(s4|=3)),s4}let l2=String.fromCharCode,u2={DEFAULT:(e4)=>{let t5=[c2(e4,!1)+32,e4.col+32,e4.row+32];return t5[0]>255||t5[1]>255||t5[2]>255?"":`\x1B[M${l2(t5[0])}${l2(t5[1])}${l2(t5[2])}`},SGR:(e4)=>{let t5=e4.action===0&&e4.button!==4?"m":"M";return`\x1B[<${c2(e4,!0)};${e4.col};${e4.row}${t5}`},SGR_PIXELS:(e4)=>{let t5=e4.action===0&&e4.button!==4?"m":"M";return`\x1B[<${c2(e4,!0)};${e4.x};${e4.y}${t5}`}},d2=class extends o2.Disposable{constructor(e4,t5,s4){super(),this._bufferService=e4,this._coreService=t5,this._optionsService=s4,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new a2.Emitter),this.onProtocolChange=this._onProtocolChange.event;for(let e5 of Object.keys(h2))this.addProtocol(e5,h2[e5]);for(let e5 of Object.keys(u2))this.addEncoding(e5,u2[e5]);this.reset()}addProtocol(e4,t5){this._protocols[e4]=t5}addEncoding(e4,t5){this._encodings[e4]=t5}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e4){if(!this._protocols[e4])throw Error(`unknown protocol "${e4}"`);this._activeProtocol=e4,this._onProtocolChange.fire(this._protocols[e4].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e4){if(!this._encodings[e4])throw Error(`unknown encoding "${e4}"`);this._activeEncoding=e4}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e4,t5,s4){if(e4.deltaY===0||e4.shiftKey)return 0;if(t5===void 0||s4===void 0)return 0;let i4=t5/s4,r8=this._applyScrollModifier(e4.deltaY,e4);return e4.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r8/=i4+0,Math.abs(e4.deltaY)<50&&(r8*=0.3),this._wheelPartialScroll+=r8,r8=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e4.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r8*=this._bufferService.rows),r8}_applyScrollModifier(e4,t5){return t5.altKey||t5.ctrlKey||t5.shiftKey?e4*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e4*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e4){if(e4.col<0||e4.col>=this._bufferService.cols||e4.row<0||e4.row>=this._bufferService.rows)return!1;if(e4.button===4&&e4.action===32)return!1;if(e4.button===3&&e4.action!==32)return!1;if(e4.button!==4&&(e4.action===2||e4.action===3))return!1;if(e4.col++,e4.row++,e4.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e4,this._activeEncoding==="SGR_PIXELS"))return!1;if(!this._protocols[this._activeProtocol].restrict(e4))return!1;let t5=this._encodings[this._activeEncoding](e4);return t5&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t5):this._coreService.triggerDataEvent(t5,!0)),this._lastEvent=e4,!0}explainEvents(e4){return{down:!!(1&e4),up:!!(2&e4),drag:!!(4&e4),move:!!(8&e4),wheel:!!(16&e4)}}_equalEvents(e4,t5,s4){if(s4){if(e4.x!==t5.x)return!1;if(e4.y!==t5.y)return!1}else{if(e4.col!==t5.col)return!1;if(e4.row!==t5.row)return!1}return e4.button===t5.button&&e4.action===t5.action&&e4.ctrl===t5.ctrl&&e4.alt===t5.alt&&e4.shift===t5.shift}};t4.CoreMouseService=d2,t4.CoreMouseService=d2=i3([r7(0,n3.IBufferService),r7(1,n3.ICoreService),r7(2,n3.IOptionsService)],d2)},4071:function(e3,t4,s3){var i3=this&&this.__decorate||function(e4,t5,s4,i4){var r8,n4=arguments.length,o3=n4<3?t5:i4===null?i4=Object.getOwnPropertyDescriptor(t5,s4):i4;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o3=Reflect.decorate(e4,t5,s4,i4);else for(var a3=e4.length-1;a3>=0;a3--)(r8=e4[a3])&&(o3=(n4<3?r8(o3):n4>3?r8(t5,s4,o3):r8(t5,s4))||o3);return n4>3&&o3&&Object.defineProperty(t5,s4,o3),o3},r7=this&&this.__param||function(e4,t5){return function(s4,i4){t5(s4,i4,e4)}};Object.defineProperty(t4,"__esModule",{value:!0}),t4.CoreService=void 0;let n3=s3(7453),o2=s3(7150),a2=s3(6501),h2=s3(802),c2=Object.freeze({insertMode:!1}),l2=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),u2=class extends o2.Disposable{constructor(e4,t5,s4){super(),this._bufferService=e4,this._logService=t5,this._optionsService=s4,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new h2.Emitter),this.onData=this._onData.event,this._onUserInput=this._register(new h2.Emitter),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new h2.Emitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new h2.Emitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,n3.clone)(c2),this.decPrivateModes=(0,n3.clone)(l2)}reset(){this.modes=(0,n3.clone)(c2),this.decPrivateModes=(0,n3.clone)(l2)}triggerDataEvent(e4,t5=!1){if(this._optionsService.rawOptions.disableStdin)return;let s4=this._bufferService.buffer;t5&&this._optionsService.rawOptions.scrollOnUserInput&&s4.ybase!==s4.ydisp&&this._onRequestScrollToBottom.fire(),t5&&this._onUserInput.fire(),this._logService.debug(`sending data "${e4}"`),this._logService.trace("sending data (codes)",()=>e4.split("").map((e5)=>e5.charCodeAt(0))),this._onData.fire(e4)}triggerBinaryEvent(e4){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e4}"`),this._logService.trace("sending binary (codes)",()=>e4.split("").map((e5)=>e5.charCodeAt(0))),this._onBinary.fire(e4))}};t4.CoreService=u2,t4.CoreService=u2=i3([r7(0,a2.IBufferService),r7(1,a2.ILogService),r7(2,a2.IOptionsService)],u2)},6025:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.InstantiationService=t4.ServiceCollection=void 0;let i3=s3(6501),r7=s3(6201);class n3{constructor(...e4){this._entries=new Map;for(let[t5,s4]of e4)this.set(t5,s4)}set(e4,t5){let s4=this._entries.get(e4);return this._entries.set(e4,t5),s4}forEach(e4){for(let[t5,s4]of this._entries.entries())e4(t5,s4)}has(e4){return this._entries.has(e4)}get(e4){return this._entries.get(e4)}}t4.ServiceCollection=n3,t4.InstantiationService=class{constructor(){this._services=new n3,this._services.set(i3.IInstantiationService,this)}setService(e4,t5){this._services.set(e4,t5)}getService(e4){return this._services.get(e4)}createInstance(e4,...t5){let s4=(0,r7.getServiceDependencies)(e4).sort((e5,t6)=>e5.index-t6.index),i4=[];for(let t6 of s4){let s5=this._services.get(t6.id);if(!s5)throw Error(`[createInstance] ${e4.name} depends on UNKNOWN service ${t6.id._id}.`);i4.push(s5)}let n4=s4.length>0?s4[0].index:t5.length;if(t5.length!==n4)throw Error(`[createInstance] First service dependency of ${e4.name} at position ${n4+1} conflicts with ${t5.length} static arguments`);return new e4(...[...t5,...i4])}}},7276:function(e3,t4,s3){var i3=this&&this.__decorate||function(e4,t5,s4,i4){var r8,n4=arguments.length,o3=n4<3?t5:i4===null?i4=Object.getOwnPropertyDescriptor(t5,s4):i4;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o3=Reflect.decorate(e4,t5,s4,i4);else for(var a3=e4.length-1;a3>=0;a3--)(r8=e4[a3])&&(o3=(n4<3?r8(o3):n4>3?r8(t5,s4,o3):r8(t5,s4))||o3);return n4>3&&o3&&Object.defineProperty(t5,s4,o3),o3},r7=this&&this.__param||function(e4,t5){return function(s4,i4){t5(s4,i4,e4)}};Object.defineProperty(t4,"__esModule",{value:!0}),t4.LogService=void 0,t4.setTraceLogger=function(e4){h2=e4},t4.traceCall=function(e4,t5,s4){if(typeof s4.value!="function")throw Error("not supported");let i4=s4.value;s4.value=function(...e5){if(h2.logLevel!==o2.LogLevelEnum.TRACE)return i4.apply(this,e5);h2.trace(`GlyphRenderer#${i4.name}(${e5.map((e6)=>JSON.stringify(e6)).join(", ")})`);let t6=i4.apply(this,e5);return h2.trace(`GlyphRenderer#${i4.name} return`,t6),t6}};let n3=s3(7150),o2=s3(6501),a2={trace:o2.LogLevelEnum.TRACE,debug:o2.LogLevelEnum.DEBUG,info:o2.LogLevelEnum.INFO,warn:o2.LogLevelEnum.WARN,error:o2.LogLevelEnum.ERROR,off:o2.LogLevelEnum.OFF},h2,c2=class extends n3.Disposable{get logLevel(){return this._logLevel}constructor(e4){super(),this._optionsService=e4,this._logLevel=o2.LogLevelEnum.OFF,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),h2=this}_updateLogLevel(){this._logLevel=a2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e4){for(let t5=0;t5<e4.length;t5++)typeof e4[t5]=="function"&&(e4[t5]=e4[t5]())}_log(e4,t5,s4){this._evalLazyOptionalParams(s4),e4.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t5,...s4)}trace(e4,...t5){this._logLevel<=o2.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e4,t5)}debug(e4,...t5){this._logLevel<=o2.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e4,t5)}info(e4,...t5){this._logLevel<=o2.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e4,t5)}warn(e4,...t5){this._logLevel<=o2.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e4,t5)}error(e4,...t5){this._logLevel<=o2.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e4,t5)}};t4.LogService=c2,t4.LogService=c2=i3([r7(0,o2.IOptionsService)],c2)},56:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.OptionsService=t4.DEFAULT_OPTIONS=void 0;let i3=s3(7150),r7=s3(701),n3=s3(802);t4.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1000,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:r7.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}};let o2=["normal","bold","100","200","300","400","500","600","700","800","900"];class a2 extends i3.Disposable{constructor(e4){super(),this._onOptionChange=this._register(new n3.Emitter),this.onOptionChange=this._onOptionChange.event;let s4={...t4.DEFAULT_OPTIONS};for(let t5 in e4)if(t5 in s4)try{let i4=e4[t5];s4[t5]=this._sanitizeAndValidateOption(t5,i4)}catch(e5){console.error(e5)}this.rawOptions=s4,this.options={...s4},this._setupOptions(),this._register((0,i3.toDisposable)(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e4,t5){return this.onOptionChange((s4)=>{s4===e4&&t5(this.rawOptions[e4])})}onMultipleOptionChange(e4,t5){return this.onOptionChange((s4)=>{e4.indexOf(s4)!==-1&&t5()})}_setupOptions(){let e4=(e5)=>{if(!(e5 in t4.DEFAULT_OPTIONS))throw Error(`No option with key "${e5}"`);return this.rawOptions[e5]},s4=(e5,s5)=>{if(!(e5 in t4.DEFAULT_OPTIONS))throw Error(`No option with key "${e5}"`);s5=this._sanitizeAndValidateOption(e5,s5),this.rawOptions[e5]!==s5&&(this.rawOptions[e5]=s5,this._onOptionChange.fire(e5))};for(let t5 in this.rawOptions){let i4={get:e4.bind(this,t5),set:s4.bind(this,t5)};Object.defineProperty(this.options,t5,i4)}}_sanitizeAndValidateOption(e4,s4){switch(e4){case"cursorStyle":if(s4||(s4=t4.DEFAULT_OPTIONS[e4]),!function(e5){return e5==="block"||e5==="underline"||e5==="bar"}(s4))throw Error(`"${s4}" is not a valid value for ${e4}`);break;case"wordSeparator":s4||(s4=t4.DEFAULT_OPTIONS[e4]);break;case"fontWeight":case"fontWeightBold":if(typeof s4=="number"&&1<=s4&&s4<=1000)break;s4=o2.includes(s4)?s4:t4.DEFAULT_OPTIONS[e4];break;case"cursorWidth":s4=Math.floor(s4);case"lineHeight":case"tabStopWidth":if(s4<1)throw Error(`${e4} cannot be less than 1, value: ${s4}`);break;case"minimumContrastRatio":s4=Math.max(1,Math.min(21,Math.round(10*s4)/10));break;case"scrollback":if((s4=Math.min(s4,4294967295))<0)throw Error(`${e4} cannot be less than 0, value: ${s4}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(s4<=0)throw Error(`${e4} cannot be less than or equal to 0, value: ${s4}`);break;case"rows":case"cols":if(!s4&&s4!==0)throw Error(`${e4} must be numeric, value: ${s4}`);break;case"windowsPty":s4=s4??{}}return s4}}t4.OptionsService=a2},8811:function(e3,t4,s3){var i3=this&&this.__decorate||function(e4,t5,s4,i4){var r8,n4=arguments.length,o3=n4<3?t5:i4===null?i4=Object.getOwnPropertyDescriptor(t5,s4):i4;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o3=Reflect.decorate(e4,t5,s4,i4);else for(var a2=e4.length-1;a2>=0;a2--)(r8=e4[a2])&&(o3=(n4<3?r8(o3):n4>3?r8(t5,s4,o3):r8(t5,s4))||o3);return n4>3&&o3&&Object.defineProperty(t5,s4,o3),o3},r7=this&&this.__param||function(e4,t5){return function(s4,i4){t5(s4,i4,e4)}};Object.defineProperty(t4,"__esModule",{value:!0}),t4.OscLinkService=void 0;let n3=s3(6501),o2=class{constructor(e4){this._bufferService=e4,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e4){let t5=this._bufferService.buffer;if(e4.id===void 0){let s5=t5.addMarker(t5.ybase+t5.y),i5={data:e4,id:this._nextId++,lines:[s5]};return s5.onDispose(()=>this._removeMarkerFromLink(i5,s5)),this._dataByLinkId.set(i5.id,i5),i5.id}let s4=e4,i4=this._getEntryIdKey(s4),r8=this._entriesWithId.get(i4);if(r8)return this.addLineToLink(r8.id,t5.ybase+t5.y),r8.id;let n4=t5.addMarker(t5.ybase+t5.y),o3={id:this._nextId++,key:this._getEntryIdKey(s4),data:s4,lines:[n4]};return n4.onDispose(()=>this._removeMarkerFromLink(o3,n4)),this._entriesWithId.set(o3.key,o3),this._dataByLinkId.set(o3.id,o3),o3.id}addLineToLink(e4,t5){let s4=this._dataByLinkId.get(e4);if(s4&&s4.lines.every((e5)=>e5.line!==t5)){let e5=this._bufferService.buffer.addMarker(t5);s4.lines.push(e5),e5.onDispose(()=>this._removeMarkerFromLink(s4,e5))}}getLinkData(e4){return this._dataByLinkId.get(e4)?.data}_getEntryIdKey(e4){return`${e4.id};;${e4.uri}`}_removeMarkerFromLink(e4,t5){let s4=e4.lines.indexOf(t5);s4!==-1&&(e4.lines.splice(s4,1),e4.lines.length===0&&(e4.data.id!==void 0&&this._entriesWithId.delete(e4.key),this._dataByLinkId.delete(e4.id)))}};t4.OscLinkService=o2,t4.OscLinkService=o2=i3([r7(0,n3.IBufferService)],o2)},6201:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.serviceRegistry=void 0,t4.getServiceDependencies=function(e4){return e4[i3]||[]},t4.createDecorator=function(e4){if(t4.serviceRegistry.has(e4))return t4.serviceRegistry.get(e4);let r7=function(e5,t5,n3){if(arguments.length!==3)throw Error("@IServiceName-decorator can only be used to decorate a parameter");(function(e6,t6,r8){t6[s3]===t6?t6[i3].push({id:e6,index:r8}):(t6[i3]=[{id:e6,index:r8}],t6[s3]=t6)})(r7,e5,n3)};return r7._id=e4,t4.serviceRegistry.set(e4,r7),r7};let s3="di$target",i3="di$dependencies";t4.serviceRegistry=new Map},6501:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.IDecorationService=t4.IUnicodeService=t4.IOscLinkService=t4.IOptionsService=t4.ILogService=t4.LogLevelEnum=t4.IInstantiationService=t4.ICharsetService=t4.ICoreService=t4.ICoreMouseService=t4.IBufferService=void 0;let i3=s3(6201);var r7;t4.IBufferService=(0,i3.createDecorator)("BufferService"),t4.ICoreMouseService=(0,i3.createDecorator)("CoreMouseService"),t4.ICoreService=(0,i3.createDecorator)("CoreService"),t4.ICharsetService=(0,i3.createDecorator)("CharsetService"),t4.IInstantiationService=(0,i3.createDecorator)("InstantiationService"),function(e4){e4[e4.TRACE=0]="TRACE",e4[e4.DEBUG=1]="DEBUG",e4[e4.INFO=2]="INFO",e4[e4.WARN=3]="WARN",e4[e4.ERROR=4]="ERROR",e4[e4.OFF=5]="OFF"}(r7||(t4.LogLevelEnum=r7={})),t4.ILogService=(0,i3.createDecorator)("LogService"),t4.IOptionsService=(0,i3.createDecorator)("OptionsService"),t4.IOscLinkService=(0,i3.createDecorator)("OscLinkService"),t4.IUnicodeService=(0,i3.createDecorator)("UnicodeService"),t4.IDecorationService=(0,i3.createDecorator)("DecorationService")},6415:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.UnicodeService=void 0;let i3=s3(7428),r7=s3(802);class n3{static extractShouldJoin(e4){return!!(1&e4)}static extractWidth(e4){return e4>>1&3}static extractCharKind(e4){return e4>>3}static createPropertyValue(e4,t5,s4=!1){return(16777215&e4)<<3|(3&t5)<<1|(s4?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new r7.Emitter,this.onChange=this._onChange.event;let e4=new i3.UnicodeV6;this.register(e4),this._active=e4.version,this._activeProvider=e4}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e4){if(!this._providers[e4])throw Error(`unknown Unicode version "${e4}"`);this._active=e4,this._activeProvider=this._providers[e4],this._onChange.fire(e4)}register(e4){this._providers[e4.version]=e4}wcwidth(e4){return this._activeProvider.wcwidth(e4)}getStringCellWidth(e4){let t5=0,s4=0,i4=e4.length;for(let r8=0;r8<i4;++r8){let o2=e4.charCodeAt(r8);if(55296<=o2&&o2<=56319){if(++r8>=i4)return t5+this.wcwidth(o2);let s5=e4.charCodeAt(r8);56320<=s5&&s5<=57343?o2=1024*(o2-55296)+s5-56320+65536:t5+=this.wcwidth(s5)}let a2=this.charProperties(o2,s4),h2=n3.extractWidth(a2);n3.extractShouldJoin(a2)&&(h2-=n3.extractWidth(s4)),t5+=h2,s4=a2}return t5}charProperties(e4,t5){return this._activeProvider.charProperties(e4,t5)}}t4.UnicodeService=n3},5856:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.Terminal=void 0;let i3=s3(6107),r7=s3(5777),n3=s3(802);class o2 extends r7.CoreTerminal{constructor(e4={}){super(e4),this._onBell=this._register(new n3.Emitter),this.onBell=this._onBell.event,this._onCursorMove=this._register(new n3.Emitter),this.onCursorMove=this._onCursorMove.event,this._onTitleChange=this._register(new n3.Emitter),this.onTitleChange=this._onTitleChange.event,this._onA11yCharEmitter=this._register(new n3.Emitter),this.onA11yChar=this._onA11yCharEmitter.event,this._onA11yTabEmitter=this._register(new n3.Emitter),this.onA11yTab=this._onA11yTabEmitter.event,this._setup(),this._register(this._inputHandler.onRequestBell(()=>this.bell())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(n3.Event.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(n3.Event.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(n3.Event.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(n3.Event.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter))}get buffer(){return this.buffers.active}get markers(){return this.buffer.markers}addMarker(e4){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e4)}bell(){this._onBell.fire()}input(e4,t5=!0){this.coreService.triggerDataEvent(e4,t5)}resize(e4,t5){e4===this.cols&&t5===this.rows||super.resize(e4,t5)}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e4=1;e4<this.rows;e4++)this.buffer.lines.push(this.buffer.getBlankLine(i3.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp})}}reset(){this.options.rows=this.rows,this.options.cols=this.cols,this._setup(),super.reset()}}t4.Terminal=o2},3058:(e3,t4,s3)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.Permutation=t4.CallbackIterable=t4.ArrayQueue=t4.booleanComparator=t4.numberComparator=t4.CompareResult=void 0,t4.tail=function(e4,t5=0){return e4[e4.length-(1+t5)]},t4.tail2=function(e4){if(e4.length===0)throw Error("Invalid tail call");return[e4.slice(0,e4.length-1),e4[e4.length-1]]},t4.equals=function(e4,t5,s4=(e5,t6)=>e5===t6){if(e4===t5)return!0;if(!e4||!t5)return!1;if(e4.length!==t5.length)return!1;for(let i4=0,r8=e4.length;i4<r8;i4++)if(!s4(e4[i4],t5[i4]))return!1;return!0},t4.removeFastWithoutKeepingOrder=function(e4,t5){let s4=e4.length-1;t5<s4&&(e4[t5]=e4[s4]),e4.pop()},t4.binarySearch=function(e4,t5,s4){return n3(e4.length,(i4)=>s4(e4[i4],t5))},t4.binarySearch2=n3,t4.quickSelect=function e4(t5,s4,i4){if((t5|=0)>=s4.length)throw TypeError("invalid index");let r8=s4[Math.floor(s4.length*Math.random())],n4=[],o3=[],a3=[];for(let e5 of s4){let t6=i4(e5,r8);t6<0?n4.push(e5):t6>0?o3.push(e5):a3.push(e5)}return t5<n4.length?e4(t5,n4,i4):t5<n4.length+a3.length?a3[0]:e4(t5-(n4.length+a3.length),o3,i4)},t4.groupBy=function(e4,t5){let s4=[],i4;for(let r8 of e4.slice(0).sort(t5))i4&&t5(i4[0],r8)===0?i4.push(r8):(i4=[r8],s4.push(i4));return s4},t4.groupAdjacentBy=function*(e4,t5){let s4,i4;for(let r8 of e4)i4!==void 0&&t5(i4,r8)?s4.push(r8):(s4&&(yield s4),s4=[r8]),i4=r8;s4&&(yield s4)},t4.forEachAdjacent=function(e4,t5){for(let s4=0;s4<=e4.length;s4++)t5(s4===0?void 0:e4[s4-1],s4===e4.length?void 0:e4[s4])},t4.forEachWithNeighbors=function(e4,t5){for(let s4=0;s4<e4.length;s4++)t5(s4===0?void 0:e4[s4-1],e4[s4],s4+1===e4.length?void 0:e4[s4+1])},t4.sortedDiff=o2,t4.delta=function(e4,t5,s4){let i4=o2(e4,t5,s4),r8=[],n4=[];for(let t6 of i4)r8.push(...e4.slice(t6.start,t6.start+t6.deleteCount)),n4.push(...t6.toInsert);return{removed:r8,added:n4}},t4.top=function(e4,t5,s4){if(s4===0)return[];let i4=e4.slice(0,s4).sort(t5);return a2(e4,t5,i4,s4,e4.length),i4},t4.topAsync=function(e4,t5,s4,r8,n4){return s4===0?Promise.resolve([]):new Promise((o3,h3)=>{(async()=>{let o4=e4.length,h4=e4.slice(0,s4).sort(t5);for(let c3=s4,l3=Math.min(s4+r8,o4);c3<o4;c3=l3,l3=Math.min(l3+r8,o4)){if(c3>s4&&await new Promise((e5)=>setTimeout(e5)),n4&&n4.isCancellationRequested)throw new i3.CancellationError;a2(e4,t5,h4,c3,l3)}return h4})().then(o3,h3)})},t4.coalesce=function(e4){return e4.filter((e5)=>!!e5)},t4.coalesceInPlace=function(e4){let t5=0;for(let s4=0;s4<e4.length;s4++)e4[s4]&&(e4[t5]=e4[s4],t5+=1);e4.length=t5},t4.move=function(e4,t5,s4){e4.splice(s4,0,e4.splice(t5,1)[0])},t4.isFalsyOrEmpty=function(e4){return!Array.isArray(e4)||e4.length===0},t4.isNonEmptyArray=function(e4){return Array.isArray(e4)&&e4.length>0},t4.distinct=function(e4,t5=(e5)=>e5){let s4=new Set;return e4.filter((e5)=>{let i4=t5(e5);return!s4.has(i4)&&(s4.add(i4),!0)})},t4.uniqueFilter=function(e4){let t5=new Set;return(s4)=>{let i4=e4(s4);return!t5.has(i4)&&(t5.add(i4),!0)}},t4.firstOrDefault=function(e4,t5){return e4.length>0?e4[0]:t5},t4.lastOrDefault=function(e4,t5){return e4.length>0?e4[e4.length-1]:t5},t4.commonPrefixLength=function(e4,t5,s4=(e5,t6)=>e5===t6){let i4=0;for(let r8=0,n4=Math.min(e4.length,t5.length);r8<n4&&s4(e4[r8],t5[r8]);r8++)i4++;return i4},t4.range=function(e4,t5){let s4=typeof t5=="number"?e4:0;typeof t5=="number"?s4=e4:(s4=0,t5=e4);let i4=[];if(s4<=t5)for(let e5=s4;e5<t5;e5++)i4.push(e5);else for(let e5=s4;e5>t5;e5--)i4.push(e5);return i4},t4.index=function(e4,t5,s4){return e4.reduce((e5,i4)=>(e5[t5(i4)]=s4?s4(i4):i4,e5),Object.create(null))},t4.insert=function(e4,t5){return e4.push(t5),()=>h2(e4,t5)},t4.remove=h2,t4.arrayInsert=function(e4,t5,s4){let i4=e4.slice(0,t5),r8=e4.slice(t5);return i4.concat(s4,r8)},t4.shuffle=function(e4,t5){let s4;if(typeof t5=="number"){let e5=t5;s4=()=>{let t6=179426549*Math.sin(e5++);return t6-Math.floor(t6)}}else s4=Math.random;for(let t6=e4.length-1;t6>0;t6-=1){let i4=Math.floor(s4()*(t6+1)),r8=e4[t6];e4[t6]=e4[i4],e4[i4]=r8}},t4.pushToStart=function(e4,t5){let s4=e4.indexOf(t5);s4>-1&&(e4.splice(s4,1),e4.unshift(t5))},t4.pushToEnd=function(e4,t5){let s4=e4.indexOf(t5);s4>-1&&(e4.splice(s4,1),e4.push(t5))},t4.pushMany=function(e4,t5){for(let s4 of t5)e4.push(s4)},t4.mapArrayOrNot=function(e4,t5){return Array.isArray(e4)?e4.map(t5):t5(e4)},t4.asArray=function(e4){return Array.isArray(e4)?e4:[e4]},t4.getRandomElement=function(e4){return e4[Math.floor(Math.random()*e4.length)]},t4.insertInto=c2,t4.splice=function(e4,t5,s4,i4){let r8=l2(e4,t5),n4=e4.splice(r8,s4);return n4===void 0&&(n4=[]),c2(e4,r8,i4),n4},t4.compareBy=function(e4,t5){return(s4,i4)=>t5(e4(s4),e4(i4))},t4.tieBreakComparators=function(...e4){return(t5,s4)=>{for(let i4 of e4){let e5=i4(t5,s4);if(!u2.isNeitherLessOrGreaterThan(e5))return e5}return u2.neitherLessOrGreaterThan}},t4.reverseOrder=function(e4){return(t5,s4)=>-e4(t5,s4)};let i3=s3(9807),r7=s3(8297);function n3(e4,t5){let s4=0,i4=e4-1;for(;s4<=i4;){let e5=(s4+i4)/2|0,r8=t5(e5);if(r8<0)s4=e5+1;else{if(!(r8>0))return e5;i4=e5-1}}return-(s4+1)}function o2(e4,t5,s4){let i4=[];function r8(e5,t6,s5){if(t6===0&&s5.length===0)return;let r9=i4[i4.length-1];r9&&r9.start+r9.deleteCount===e5?(r9.deleteCount+=t6,r9.toInsert.push(...s5)):i4.push({start:e5,deleteCount:t6,toInsert:s5})}let n4=0,o3=0;for(;;){if(n4===e4.length){r8(n4,0,t5.slice(o3));break}if(o3===t5.length){r8(n4,e4.length-n4,[]);break}let i5=e4[n4],a3=t5[o3],h3=s4(i5,a3);h3===0?(n4+=1,o3+=1):h3<0?(r8(n4,1,[]),n4+=1):h3>0&&(r8(n4,0,[a3]),o3+=1)}return i4}function a2(e4,t5,s4,i4,n4){for(let o3=s4.length;i4<n4;i4++){let n5=e4[i4];if(t5(n5,s4[o3-1])<0){s4.pop();let e5=(0,r7.findFirstIdxMonotonousOrArrLen)(s4,(e6)=>t5(n5,e6)<0);s4.splice(e5,0,n5)}}}function h2(e4,t5){let s4=e4.indexOf(t5);if(s4>-1)return e4.splice(s4,1),t5}function c2(e4,t5,s4){let i4=l2(e4,t5),r8=e4.length,n4=s4.length;e4.length=r8+n4;for(let t6=r8-1;t6>=i4;t6--)e4[t6+n4]=e4[t6];for(let t6=0;t6<n4;t6++)e4[t6+i4]=s4[t6]}function l2(e4,t5){return t5<0?Math.max(t5+e4.length,0):Math.min(t5,e4.length)}var u2;(function(e4){e4.isLessThan=function(e5){return e5<0},e4.isLessThanOrEqual=function(e5){return e5<=0},e4.isGreaterThan=function(e5){return e5>0},e4.isNeitherLessOrGreaterThan=function(e5){return e5===0},e4.greaterThan=1,e4.lessThan=-1,e4.neitherLessOrGreaterThan=0})(u2||(t4.CompareResult=u2={})),t4.numberComparator=(e4,t5)=>e4-t5,t4.booleanComparator=(e4,s4)=>(0,t4.numberComparator)(e4?1:0,s4?1:0),t4.ArrayQueue=class{constructor(e4){this.items=e4,this.firstIdx=0,this.lastIdx=this.items.length-1}get length(){return this.lastIdx-this.firstIdx+1}takeWhile(e4){let t5=this.firstIdx;for(;t5<this.items.length&&e4(this.items[t5]);)t5++;let s4=t5===this.firstIdx?null:this.items.slice(this.firstIdx,t5);return this.firstIdx=t5,s4}takeFromEndWhile(e4){let t5=this.lastIdx;for(;t5>=0&&e4(this.items[t5]);)t5--;let s4=t5===this.lastIdx?null:this.items.slice(t5+1,this.lastIdx+1);return this.lastIdx=t5,s4}peek(){if(this.length!==0)return this.items[this.firstIdx]}peekLast(){if(this.length!==0)return this.items[this.lastIdx]}dequeue(){let e4=this.items[this.firstIdx];return this.firstIdx++,e4}removeLast(){let e4=this.items[this.lastIdx];return this.lastIdx--,e4}takeCount(e4){let t5=this.items.slice(this.firstIdx,this.firstIdx+e4);return this.firstIdx+=e4,t5}};class d2{static{this.empty=new d2((e4)=>{})}constructor(e4){this.iterate=e4}forEach(e4){this.iterate((t5)=>(e4(t5),!0))}toArray(){let e4=[];return this.iterate((t5)=>(e4.push(t5),!0)),e4}filter(e4){return new d2((t5)=>this.iterate((s4)=>!e4(s4)||t5(s4)))}map(e4){return new d2((t5)=>this.iterate((s4)=>t5(e4(s4))))}some(e4){let t5=!1;return this.iterate((s4)=>(t5=e4(s4),!t5)),t5}findFirst(e4){let t5;return this.iterate((s4)=>!e4(s4)||(t5=s4,!1)),t5}findLast(e4){let t5;return this.iterate((s4)=>(e4(s4)&&(t5=s4),!0)),t5}findLastMaxBy(e4){let t5,s4=!0;return this.iterate((i4)=>((s4||u2.isGreaterThan(e4(i4,t5)))&&(s4=!1,t5=i4),!0)),t5}}t4.CallbackIterable=d2;class f2{constructor(e4){this._indexMap=e4}static createSortPermutation(e4,t5){let s4=Array.from(e4.keys()).sort((s5,i4)=>t5(e4[s5],e4[i4]));return new f2(s4)}apply(e4){return e4.map((t5,s4)=>e4[this._indexMap[s4]])}inverse(){let e4=this._indexMap.slice();for(let t5=0;t5<this._indexMap.length;t5++)e4[this._indexMap[t5]]=t5;return new f2(e4)}}t4.Permutation=f2},8297:(e3,t4)=>{function s3(e4,t5,s4=e4.length-1){for(let i4=s4;i4>=0;i4--)if(t5(e4[i4]))return i4;return-1}function i3(e4,t5,s4=0,i4=e4.length){let r8=s4,n4=i4;for(;r8<n4;){let s5=Math.floor((r8+n4)/2);t5(e4[s5])?r8=s5+1:n4=s5}return r8-1}function r7(e4,t5,s4=0,i4=e4.length){let r8=s4,n4=i4;for(;r8<n4;){let s5=Math.floor((r8+n4)/2);t5(e4[s5])?n4=s5:r8=s5+1}return r8}Object.defineProperty(t4,"__esModule",{value:!0}),t4.MonotonousArray=void 0,t4.findLast=function(e4,t5){let i4=s3(e4,t5);if(i4!==-1)return e4[i4]},t4.findLastIdx=s3,t4.findLastMonotonous=function(e4,t5){let s4=i3(e4,t5);return s4===-1?void 0:e4[s4]},t4.findLastIdxMonotonous=i3,t4.findFirstMonotonous=function(e4,t5){let s4=r7(e4,t5);return s4===e4.length?void 0:e4[s4]},t4.findFirstIdxMonotonousOrArrLen=r7,t4.findFirstIdxMonotonous=function(e4,t5,s4=0,i4=e4.length){let n4=r7(e4,t5,s4,i4);return n4===e4.length?-1:n4},t4.findFirstMax=o2,t4.findLastMax=function(e4,t5){if(e4.length===0)return;let s4=e4[0];for(let i4=1;i4<e4.length;i4++){let r8=e4[i4];t5(r8,s4)>=0&&(s4=r8)}return s4},t4.findFirstMin=function(e4,t5){return o2(e4,(e5,s4)=>-t5(e5,s4))},t4.findMaxIdx=function(e4,t5){if(e4.length===0)return-1;let s4=0;for(let i4=1;i4<e4.length;i4++)t5(e4[i4],e4[s4])>0&&(s4=i4);return s4},t4.mapFindFirst=function(e4,t5){for(let s4 of e4){let e5=t5(s4);if(e5!==void 0)return e5}};class n3{static{this.assertInvariants=!1}constructor(e4){this._array=e4,this._findLastMonotonousLastIdx=0}findLastMonotonous(e4){if(n3.assertInvariants){if(this._prevFindLastPredicate){for(let t6 of this._array)if(this._prevFindLastPredicate(t6)&&!e4(t6))throw Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=e4}let t5=i3(this._array,e4,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=t5+1,t5===-1?void 0:this._array[t5]}}function o2(e4,t5){if(e4.length===0)return;let s4=e4[0];for(let i4=1;i4<e4.length;i4++){let r8=e4[i4];t5(r8,s4)>0&&(s4=r8)}return s4}t4.MonotonousArray=n3},9087:(e3,t4)=>{var s3;Object.defineProperty(t4,"__esModule",{value:!0}),t4.SetWithKey=void 0,t4.groupBy=function(e4,t5){let s4=Object.create(null);for(let i4 of e4){let e5=t5(i4),r7=s4[e5];r7||(r7=s4[e5]=[]),r7.push(i4)}return s4},t4.diffSets=function(e4,t5){let s4=[],i4=[];for(let i5 of e4)t5.has(i5)||s4.push(i5);for(let s5 of t5)e4.has(s5)||i4.push(s5);return{removed:s4,added:i4}},t4.diffMaps=function(e4,t5){let s4=[],i4=[];for(let[i5,r7]of e4)t5.has(i5)||s4.push(r7);for(let[s5,r7]of t5)e4.has(s5)||i4.push(r7);return{removed:s4,added:i4}},t4.intersection=function(e4,t5){let s4=new Set;for(let i4 of t5)e4.has(i4)&&s4.add(i4);return s4};class i3{static{s3=Symbol.toStringTag}constructor(e4,t5){this.toKey=t5,this._map=new Map,this[s3]="SetWithKey";for(let t6 of e4)this.add(t6)}get size(){return this._map.size}add(e4){let t5=this.toKey(e4);return this._map.set(t5,e4),this}delete(e4){return this._map.delete(this.toKey(e4))}has(e4){return this._map.has(this.toKey(e4))}*entries(){for(let e4 of this._map.values())yield[e4,e4]}keys(){return this.values()}*values(){for(let e4 of this._map.values())yield e4}clear(){this._map.clear()}forEach(e4,t5){this._map.forEach((s4)=>e4.call(t5,s4,s4,this))}[Symbol.iterator](){return this.values()}}t4.SetWithKey=i3},9807:(e3,t4)=>{Object.defineProperty(t4,"__esModule",{value:!0}),t4.BugIndicatingError=t4.ErrorNoTelemetry=t4.ExpectedError=t4.NotSupportedError=t4.NotImplementedError=t4.ReadonlyError=t4.CancellationError=t4.errorHandler=t4.ErrorHandler=void 0,t4.setUnexpectedErrorHandler=function(e4){t4.errorHandler.setUnexpectedErrorHandler(e4)},t4.isSigPipeError=function(e4){if(!e4||typeof e4!="object")return!1;let t5=e4;return t5.code==="EPIPE"&&t5.syscall?.toUpperCase()==="WRITE"},t4.onUnexpectedError=function(e4){r7(e4)||t4.errorHandler.onUnexpectedError(e4)},t4.onUnexpectedExternalError=function(e4){r7(e4)||t4.errorHandler.onUnexpectedExternalError(e4)},t4.transformErrorForSerialization=function(e4){if(e4 instanceof Error){let{name:t5,message:s4}=e4;return{$isError:!0,name:t5,message:s4,stack:e4.stacktrace||e4.stack,noTelemetry:l2.isErrorNoTelemetry(e4)}}return e4},t4.transformErrorFromSerialization=function(e4){let t5;return e4.noTelemetry?t5=new l2:(t5=Error(),t5.name=e4.name),t5.message=e4.message,t5.stack=e4.stack,t5},t4.isCancellationError=r7,t4.canceled=function(){let e4=Error(i3);return e4.name=e4.message,e4},t4.illegalArgument=function(e4){return e4?Error(`Illegal argument: ${e4}`):Error("Illegal argument")},t4.illegalState=function(e4){return e4?Error(`Illegal state: ${e4}`):Error("Illegal state")},t4.getErrorMessage=function(e4){return e4?e4.message?e4.message:e4.stack?e4.stack.split(`
4
4
  `)[0]:String(e4):"Error"};class s3{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e4){setTimeout(()=>{if(e4.stack){if(l2.isErrorNoTelemetry(e4))throw new l2(e4.message+`
5
5
 
@@ -79,7 +79,7 @@ rove: could not relaunch (${result.error.message})
79
79
  `)}function issueProjectPrompt(issue,api){return[...promptHeader(issue),"You are working directly in the project checkout \u2014 no dedicated worktree or branch was created. Keep changes reviewable and do not switch branches unless asked.","Before finishing, verify the acceptance criteria implied by the story and summarize what changed plus any verification still needed.",`When the work lands, run: ${api} issue-set-status --repo . --id ${issue.id} --status done`].join(`
80
80
  `)}function displayProductName(){return ROVE_PRODUCT_NAME.charAt(0).toUpperCase()+ROVE_PRODUCT_NAME.slice(1)}function nextPlaceholderIndex(body){let matches=body.match(/^(?:images|pdf)\[\d+\]:/gm);return matches?matches.length:0}function withImagePlaceholders(body,paths){let next=body.replace(/\s+$/,""),index=nextPlaceholderIndex(body);for(let path of paths){let line=`${attachmentLabel(path,index)}: ${path}`;next=next.length>0?`${next}
81
81
  ${line}`:line,index+=1}return next}var ISSUE_CHAT_PLACEMENTS=["worktree","projectWorktree","project"];function issueChatTaskTitle(issue){return`#${issue.id} ${issue.title}`}function issueWorktreePrompt2(issue,api="rove api"){return issueWorktreePrompt(issue,api,displayProductName())}function issueProjectPrompt2(issue,api="rove api"){return issueProjectPrompt(issue,api)}var import_react44=__toESM(require_react_production(),1);var EVENT_FEED_LIMIT=12,FRAGMENT_MAX=40;function str(value){return typeof value==="string"?value:""}function detailFragment(event){let detail=event.detail;if(!detail)return"";let{tool,compact,subagent}=detail,fragment=str(tool?.name)||str(compact?.trigger)||str(subagent?.type)||str(detail.note);return truncateEnd(fragment,FRAGMENT_MAX)}function eventRows(events,nowMs,limit=EVENT_FEED_LIMIT){return events.slice(-limit).reverse().map((event,index)=>{let tail=[detailFragment(event),str(event.vendor)].filter((part)=>part.length>0);return{key:`${event.at}:${index}`,age:relativeAge(event.at,nowMs),kind:event.kind,tail:tail.join(" \xB7 ")}})}var AGE_CELLS=4;function IssueEventsSection(props){let{theme}=useTheme(),t3=useT(),[rows,setRows]=import_react44.useState(null);return import_react44.useEffect(()=>{let orch=props.orchestrator;if(!orch){setRows([]);return}let live=!0;return orch.recentTaskEvents(props.taskId).then((result)=>{if(live)setRows(eventRows(result.events,Date.now(),EVENT_FEED_LIMIT))}).catch(()=>{if(live)setRows([])}),()=>{live=!1}},[props.orchestrator,props.taskId]),$jsxs("box",{gap:0,children:[$jsx(DialogLabel,{label:t3("kanban.detail.eventsLabel"),focused:!1}),rows===null?$jsx("text",{fg:theme.textMuted,children:t3("kanban.detail.eventsLoading")}):rows.length===0?$jsx("text",{fg:theme.textMuted,children:t3("kanban.detail.eventsNone")}):rows.map((row)=>$jsxs("box",{flexDirection:"row",gap:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:row.age.padStart(AGE_CELLS)}),$jsx("text",{fg:theme.text,wrapMode:"none",children:row.kind}),row.tail?$jsxs("text",{fg:theme.textMuted,wrapMode:"none",children:["\xB7 ",row.tail]}):null]},row.key))]})}var DESCRIPTION_ROWS=8;function IssueDetailDialogView(props){let dialog=useDialog(),{theme}=useTheme(),t3=useT(),padX=useDialogPaddingX(),issue=props.issue,create=props.mode==="create",linkedTaskId=!create&&issue.taskId&&issue.taskId!==""?issue.taskId:null,startable=create||!linkedTaskId&&issue.status!=="done",[vendor,setVendor]=import_react46.useState(props.defaultVendor),[placement,setPlacement]=import_react46.useState(ISSUE_CHAT_PLACEMENTS[0]??"worktree"),[jump,setJump]=import_react46.useState(!1),[draftTitle,setDraftTitle]=import_react46.useState(issue.title),[draftBody,setDraftBody]=import_react46.useState(issue.body),[draftStatus,setDraftStatus]=import_react46.useState(issue.status),[field,setField]=import_react46.useState(create?"title":startable?"workspace":linkedTaskId?"open":"title"),bodyEl=import_react46.useRef(null),fields=create?["title","description","engine","workspace","jump"]:startable?["title","description","status","engine","workspace","jump"]:linkedTaskId?["title","description","status","open","unlink"]:["title","description","status"];function insertPlaceholders(paths){if(paths.length===0)return;let next=withImagePlaceholders(bodyEl.current?.plainText??draftBody,paths);bodyEl.current?.setText(next),setDraftBody(next)}usePaste((event)=>{let paths=asAttachmentPaths(new TextDecoder().decode(event.bytes));if(!paths)return;event.preventDefault(),insertPlaceholders(paths)});function pasteClipboardImage(){captureClipboardAttachment().then((path)=>{if(path)insertPlaceholders([path])})}function cycleField(dir){setField((current)=>{let i2=Math.max(0,fields.indexOf(current));return fields[(i2+dir+fields.length)%fields.length]??"title"})}function stepEngine(dir){let list=props.engines;if(list.length===0)return;setVendor((v3)=>{let i2=Math.max(0,list.indexOf(v3));return list[(i2+dir+list.length)%list.length]??v3})}function stepPlacement(dir){setPlacement((p3)=>{let i2=ISSUE_CHAT_PLACEMENTS.indexOf(p3);return ISSUE_CHAT_PLACEMENTS[(i2+dir+ISSUE_CHAT_PLACEMENTS.length)%ISSUE_CHAT_PLACEMENTS.length]??p3})}function draft(){return{title:draftTitle.trim()||issue.title,body:bodyEl.current?.plainText??draftBody,status:draftStatus}}function stepStatus(dir){setDraftStatus((s2)=>{let i2=Math.max(0,ISSUE_STATUSES.indexOf(s2));return ISSUE_STATUSES[(i2+dir+ISSUE_STATUSES.length)%ISSUE_STATUSES.length]??s2})}function requireTitle(){if(draftTitle.trim().length>0)return!0;return setField("title"),!1}function commit(){if(create){if(!requireTitle())return;let{title,body}=draft();props.onSubmit({kind:"create",start:{vendor,placement,jump},title,body})}else if(startable)props.onSubmit({kind:"start",vendor,placement,jump,...draft()});else if(linkedTaskId)props.onSubmit({kind:"open",taskId:linkedTaskId,...draft()});else return;dialog.clear()}function saveOnly(){if(!create||!requireTitle())return;let{title,body}=draft();props.onSubmit({kind:"create",start:null,title,body}),dialog.clear()}function unlink(){props.onSubmit({kind:"unlink",...draft()}),dialog.clear()}function close(){if(create)props.onCancel();else props.onSubmit({kind:"close",...draft()});dialog.clear()}useBindings(()=>({bindings:[{key:"escape",cmd:()=>close()},{key:"tab",cmd:()=>cycleField(1)},{key:"shift+tab",cmd:()=>cycleField(-1)},{key:"ctrl+return",cmd:()=>commit()},...create?[{key:"ctrl+s",cmd:()=>saveOnly()}]:[],{key:"ctrl+v",cmd:()=>pasteClipboardImage()},...field==="status"?[{key:"left",cmd:()=>stepStatus(-1)},{key:"right",cmd:()=>stepStatus(1)}]:[],...field==="engine"?[{key:"left",cmd:()=>stepEngine(-1)},{key:"right",cmd:()=>stepEngine(1)},{key:"return",cmd:()=>commit()}]:[],...field==="workspace"?[{key:"up",cmd:()=>stepPlacement(-1)},{key:"down",cmd:()=>stepPlacement(1)},{key:"return",cmd:()=>commit()}]:[],...field==="jump"?[{key:"left",cmd:()=>setJump((v3)=>!v3)},{key:"right",cmd:()=>setJump((v3)=>!v3)},{key:"return",cmd:()=>commit()}]:[],...field==="open"?[{key:"return",cmd:()=>commit()}]:[],...field==="unlink"?[{key:"return",cmd:()=>unlink()}]:[]]}));let statusFg=draftStatus==="done"?theme.success:draftStatus==="hold"?theme.warning:draftStatus==="doing"?theme.accent:theme.textMuted;return $jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:1,children:[create?$jsx(DialogHeader,{title:t3("kanban.detail.newStory"),onClose:()=>close()}):$jsx(DialogHeader,{onClose:()=>close(),children:$jsxs("box",{flexDirection:"row",gap:2,children:[$jsxs("text",{fg:theme.textMuted,attributes:TextAttributes14.BOLD,wrapMode:"none",children:["#",issue.id]}),$jsx("text",{fg:statusFg,attributes:TextAttributes14.BOLD,wrapMode:"none",children:t3(`kanban.detail.status.${draftStatus}`)}),$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("kanban.detail.created",{date:issue.created})}),linkedTaskId?$jsx("text",{fg:theme.accent,wrapMode:"none",children:t3("kanban.detail.linked")}):null]})}),$jsx(DialogSection,{label:t3("kanban.detail.titleLabel"),focused:field==="title",onPress:()=>setField("title"),children:$jsx(DialogField,{focused:field==="title",children:$jsx("input",{value:draftTitle,focused:field==="title",onMouseUp:()=>setField("title"),onInput:(v3)=>setDraftTitle(stripNewlines(v3)),onSubmit:()=>setField("description")})})}),$jsx(DialogSection,{label:t3("kanban.detail.description"),focused:field==="description",hint:t3("kanban.detail.attachHint"),onPress:()=>setField("description"),children:$jsx(DialogField,{focused:field==="description",children:$jsx("textarea",{ref:(el)=>{bodyEl.current=el},initialValue:issue.body,placeholder:t3("kanban.detail.noDescription"),focused:field==="description",height:DESCRIPTION_ROWS,wrapMode:"word",onMouseUp:()=>setField("description"),onContentChange:()=>setDraftBody(bodyEl.current?.plainText??"")})})}),create?null:$jsx(DialogSection,{label:t3("kanban.detail.statusLabel"),focused:field==="status",hint:"\u2190/\u2192",paddingBottom:1,onPress:()=>setField("status"),children:$jsx(ChipRow,{choices:ISSUE_STATUSES,selected:draftStatus,display:(option)=>t3(`kanban.detail.status.${option}`),onPick:(option)=>{setField("status"),setDraftStatus(option)}})}),startable?$jsxs("box",{gap:0,children:[$jsx(DialogSection,{label:t3("kanban.detail.engine"),focused:field==="engine",hint:"\u2190/\u2192",children:$jsx(ChipRow,{choices:props.engines,selected:vendor,display:props.engineLabel,paddingBottom:1,onPick:(engine)=>{setField("engine"),setVendor(engine)}})}),$jsx(DialogSection,{label:t3("kanban.detail.workspace"),focused:field==="workspace",hint:"\u2191/\u2193",paddingBottom:1,children:$jsx(DialogField,{focused:field==="workspace",children:ISSUE_CHAT_PLACEMENTS.map((option)=>{let active=option===placement;return $jsxs("text",{fg:active?theme.primary:theme.textMuted,attributes:active?TextAttributes14.BOLD:void 0,onMouseUp:()=>{setField("workspace"),setPlacement(option)},children:[active?"\u25B8 ":" ",t3(`kanban.detail.placement.${option}`)]},option)})})}),$jsx(DialogSection,{label:t3("kanban.detail.jumpLabel"),focused:field==="jump",hint:"\u2190/\u2192",paddingBottom:1,children:$jsx(ChipRow,{choices:["stay","follow"],selected:jump?"follow":"stay",display:(option)=>t3(option==="follow"?"kanban.detail.jump.follow":"kanban.detail.jump.stay"),onPick:(option)=>{setField("jump"),setJump(option==="follow")}})}),$jsx(DialogFooter,{children:create?t3("kanban.detail.createLegend"):t3("kanban.detail.startLegend")})]}):linkedTaskId?$jsxs("box",{gap:1,children:[$jsx(DialogSection,{label:t3("kanban.detail.sessionLabel"),focused:field==="open",children:$jsxs("box",{flexDirection:"row",gap:1,children:[$jsx(ChipButton,{label:t3("kanban.detail.openAction"),selected:field==="open",tone:"text",onPress:()=>{setField("open"),commit()}}),$jsx(ChipButton,{label:t3("kanban.detail.unlinkAction"),selected:field==="unlink",onPress:()=>{setField("unlink"),unlink()}})]})}),$jsx(IssueEventsSection,{taskId:linkedTaskId,orchestrator:props.orchestrator??null}),$jsx(DialogFooter,{children:t3("kanban.detail.openLegend")})]}):$jsx(DialogFooter,{children:t3("kanban.detail.doneNote")})]})}function show2(dialog,opts){return showDialog(dialog,(resolve)=>$jsx(IssueDetailDialogView,{...opts,onSubmit:(outcome)=>resolve(outcome),onCancel:()=>resolve(void 0)}),{size:"large"})}var IssueDetailDialog={show:show2};import{TextAttributes as TextAttributes16}from"@opentui/core";import{TextAttributes as TextAttributes15}from"@opentui/core";var ACTIVITY_BADGE={running:{labelKey:"tasks.activity.working",tone:"accent"},turn_complete:{labelKey:"kanban.turnComplete",tone:"success"},rate_limited:{labelKey:"tasks.activity.rateLimited",tone:"warning"},permission_needed:{labelKey:"tasks.activity.permissionNeeded",tone:"warning"},error:{labelKey:"tasks.activity.error",tone:"error"},dead:{labelKey:"tasks.activity.dead",tone:"error"}};function KanbanCard(props){let{theme,transparentBackground}=useTheme(),t3=useT(),{issue,column,selected}=props,columnBorder=transparentBackground?theme.border:theme.borderSubtle,fg=column==="done"?theme.textMuted:theme.text,description=issue.body.trim(),badge=props.activity?ACTIVITY_BADGE[props.activity]:void 0,needsAttention=isBoardAttentionState(props.activity),badgeTone={accent:theme.accent,warning:theme.warning,error:theme.error,success:theme.success};return $jsxs("box",{ref:props.boxRef,...FRAME,borderColor:selected?theme.primary:needsAttention?theme.warning:columnBorder,backgroundColor:transparentBackground?"transparent":theme.backgroundElement,paddingLeft:1,paddingRight:1,marginBottom:1,onMouseUp:()=>selected?props.onOpen():props.onSelect(),children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsx("text",{fg,attributes:TextAttributes15.BOLD,wrapMode:"word",flexShrink:1,children:issue.title}),$jsxs("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:0,paddingLeft:1,children:["#",issue.id]})]}),$jsx("box",{height:2,overflow:"hidden",children:description?$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:description}):null}),$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:issue.created}),badge?$jsx("text",{fg:badgeTone[badge.tone],wrapMode:"none",children:t3(badge.labelKey)}):null]})]})}var COLUMN_LABEL_KEY={backlog:"kanban.column.backlog",in_progress:"kanban.column.inProgress",parked:"kanban.column.parked",done:"kanban.column.done"},MIN_CARD_CELLS=12,LANE_CHROME=9,BOARD_LANES=4,MIN_BOARD_CELLS=BOARD_LANES*(MIN_CARD_CELLS+LANE_CHROME)+(BOARD_LANES-1);function needsSingleLane(boardCells){return boardCells===null?null:boardCells<MIN_BOARD_CELLS}function KanbanBoard(props){let{theme,transparentBackground}=useTheme(),t3=useT(),columnBorder=transparentBackground?theme.border:theme.borderSubtle,{columns,selectedId}=props,columnAccent={backlog:theme.textMuted,in_progress:theme.accent,parked:theme.warning,done:theme.success};function card(issue,column){let activity=(column==="in_progress"||column==="parked")&&issue.taskId?props.engineStates?.get(issue.taskId)?.state:void 0;return $jsx(KanbanCard,{issue,column,selected:issue.id===selectedId,activity,onSelect:()=>props.onSelect(issue.id),onOpen:()=>props.onOpen(issue),boxRef:props.follow.rowRef(issue.id)},issue.id)}function lane(col,opts){return $jsxs("box",{flexGrow:1,flexBasis:0,...FRAME,borderColor:columnBorder,paddingLeft:1,paddingRight:1,children:[opts?.header??!0?$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsxs("text",{fg:columnAccent[col.key],attributes:TextAttributes16.BOLD,wrapMode:"none",children:[t3(COLUMN_LABEL_KEY[col.key])," (",col.issues.length+col.hiddenCount,")"]}),col.key==="in_progress"&&props.attentionCount>0?$jsx("text",{fg:theme.warning,attributes:TextAttributes16.BOLD,wrapMode:"none",children:t3("kanban.attention",{count:String(props.attentionCount)})}):null]}):null,$jsxs("scrollbox",{ref:props.follow.scrollRef,flexGrow:1,paddingTop:1,paddingRight:1,verticalScrollbarOptions:{showArrows:!1,trackOptions:{foregroundColor:"transparent"}},horizontalScrollbarOptions:{visible:!1},children:[col.issues.map((issue)=>card(issue,col.key)),col.issues.length===0&&col.hiddenCount===0?$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("kanban.columnEmpty")}):null,col.hiddenCount>0?$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("kanban.more",{count:String(col.hiddenCount)})}):null]})]},col.key)}function singleLaneBoard(){let active=columns.find((col)=>col.issues.some((issue)=>issue.id===selectedId))??columns.find((col)=>col.issues.length>0)??columns[0];if(!active)return null;return $jsxs("box",{flexDirection:"column",flexGrow:1,paddingTop:1,children:[$jsx("box",{flexDirection:"row",gap:2,children:columns.map((col)=>$jsxs("text",{fg:col.key===active.key?columnAccent[col.key]:theme.textMuted,attributes:col.key===active.key?TextAttributes16.BOLD:void 0,wrapMode:"none",onMouseUp:()=>{let first=col.issues[0];if(first)props.onSelect(first.id)},children:[t3(COLUMN_LABEL_KEY[col.key])," (",col.issues.length+col.hiddenCount,")"]},col.key))}),lane(active,{header:!1})]})}if(props.singleLane)return singleLaneBoard();return $jsx("box",{flexDirection:"row",gap:1,flexGrow:1,paddingTop:1,children:columns.map((col)=>lane(col))})}var import_react47=__toESM(require_react_production(),1);var POLL_MS2=5000;function useKanbanBoards(args){let[boards,setBoards]=import_react47.useState(null),[reloadTick,setReloadTick]=import_react47.useState(0),[activeRepo,setActiveRepo]=import_react47.useState(null),[selectedId,setSelectedId]=import_react47.useState(null),{orchestrator,focusTask}=args;return import_react47.useEffect(()=>{let disposed=!1;if(!orchestrator){setBoards([]);return}let local=[...getSavedRepos(),...orchestrator.listTasks().map((task)=>task.repo)];orchestrator.listIssueRepos().catch(()=>[]).then((stored)=>{let repos=[...new Set([...local,...stored])].filter((repo)=>repo&&!isRemoteRepoKey(repo));return Promise.all(repos.map((repo)=>orchestrator.listIssues(repo).catch((err)=>({repoRoot:repo,exists:!1,nextId:1,issues:[],skipped:0,readError:errorMessage(err)}))))}).then((results)=>{if(disposed)return;let next=[...results];next.sort((a2,b3)=>a2.repoRoot.localeCompare(b3.repoRoot)),setBoards(next);let norm=(p3)=>p3.replace(/^\/private\//,"/").replace(/\/+$/,""),activeId=orchestrator.activeTaskSignal().get(),targetRepo=focusTask?.repo??orchestrator.listTasks().find((task)=>task.id===activeId)?.repo,initialBoard=targetRepo?next.find((board)=>norm(board.repoRoot)===norm(targetRepo)):void 0;setActiveRepo((prev)=>prev??initialBoard?.repoRoot??null);let focusId=focusTask?.id,linked=focusId?initialBoard?.issues.find((issue)=>issue.taskId===focusId):void 0;if(linked)setSelectedId((prev)=>prev??linked.id)});let timer=setInterval(()=>setReloadTick((tick)=>tick+1),POLL_MS2);return()=>{disposed=!0,clearInterval(timer)}},[orchestrator,reloadTick,focusTask]),{boards,activeRepo,setActiveRepo,selectedId,setSelectedId,reload:()=>setReloadTick((tick)=>tick+1)}}var PAGE_PADDING_CELLS=4;function KanbanPage(props){let{theme}=useTheme(),t3=useT(),dialog=useDialog(),notif=useNotifications();function notifyError(message){notif.notify({kind:"error",taskId:"",tabId:"",title:message})}let narrow=isNarrowWidth(useTerminalDimensions().width),pageRef=import_react49.useRef(null),[pageCells,setPageCells]=import_react49.useState(null),singleLane=needsSingleLane(pageCells===null?null:pageCells-PAGE_PADDING_CELLS)??narrow,[engines,setEngines]=import_react49.useState([]);import_react49.useEffect(()=>{let disposed=!1;return availableEngineIds().then((ids)=>{if(!disposed)setEngines(ids)}),()=>{disposed=!0}},[]);let{boards,activeRepo,setActiveRepo,selectedId,setSelectedId,reload}=useKanbanBoards({orchestrator:props.orchestrator,focusTask:props.focusTask}),boardList=boards??[],activeIndex=Math.max(0,boardList.findIndex((board)=>board.repoRoot===activeRepo)),activeBoard=boardList[activeIndex],repoRoots=boardList.map((board)=>board.repoRoot),readErrorKey=boardList.filter((board)=>board.readError).map((board)=>`${board.repoRoot}\x00${board.readError}`).join(`
82
- `);import_react49.useEffect(()=>{for(let board of boardList){if(!board.readError)continue;notifyError(t3("kanban.readFailedToast",{repo:sidebarProjectLabel(board.repoRoot,repoRoots),error:board.readError}))}},[readErrorKey]);let knownTaskIds=new Set((props.orchestrator?.listTasks()??[]).map((task)=>task.id)),{columns,attentionCount}=applyBoardAttention(activeBoard?buildIssueBoard(activeBoard.issues,knownTaskIds.size===0?void 0:(taskId)=>knownTaskIds.has(taskId)):[],(taskId)=>props.engineStates?.get(taskId)?.state),follow=useCursorFollow(selectedId);function cycleProject(delta){if(boardList.length===0)return;let next=(activeIndex+delta+boardList.length)%boardList.length;setActiveRepo(boardList[next]?.repoRoot??null),setSelectedId(null)}function moveCursor(dir){let next=moveBoardSelection(columns,selectedId,dir);if(next!=null)setSelectedId(next)}function moveOrCycle(dir){if(columns.some((column)=>column.issues.length>0))moveCursor(dir);else cycleProject(dir==="left"?-1:1)}function openDetail(issue){let board=activeBoard;if(!board)return;setSelectedId(issue.id),IssueDetailDialog.show(dialog,{issue,engines,defaultVendor:quickForkDefaultVendor(board.repoRoot,engines),engineLabel:engineDisplayName,orchestrator:props.orchestrator}).then(async(outcome)=>{if(!outcome)return;let patch={};if(outcome.title!==issue.title)patch.title=outcome.title;if(outcome.body!==issue.body)patch.body=outcome.body;if(patch.title!==void 0||patch.body!==void 0)await props.orchestrator?.mutateIssue(board.repoRoot,{type:"update",id:issue.id,...patch}).catch((err)=>{console.error("[rove kanban] issue update failed:",err),notifyError(t3("kanban.updateFailed",{id:String(issue.id),error:errorMessage(err)}))}),reload();if(outcome.kind!=="create"&&outcome.status!==issue.status)await props.orchestrator?.mutateIssue(board.repoRoot,{type:"setStatus",id:issue.id,status:outcome.status}).catch((err)=>{console.error("[rove kanban] issue status change failed:",err),notifyError(t3("kanban.statusFailed",{id:String(issue.id),error:errorMessage(err)}))}),reload();if(outcome.kind==="open"){props.onOpenTask(outcome.taskId);return}if(outcome.kind==="unlink"){await props.orchestrator?.mutateIssue(board.repoRoot,{type:"unlink",id:issue.id}).catch((err)=>{console.error("[rove kanban] issue unlink failed:",err),notifyError(t3("kanban.unlinkFailed",{id:String(issue.id),error:errorMessage(err)}))}),reload();return}if(outcome.kind!=="start")return;props.onStartChat({repoRoot:board.repoRoot,issue:{...issue,...patch},vendor:outcome.vendor,placement:outcome.placement,jump:outcome.jump})})}function openIntake(){let board=activeBoard;if(!board)return;let blank={id:board.nextId,title:"",status:"open",created:new Date().toISOString().slice(0,10),body:""};IssueDetailDialog.show(dialog,{issue:blank,mode:"create",engines,defaultVendor:quickForkDefaultVendor(board.repoRoot,engines),engineLabel:engineDisplayName}).then(async(outcome)=>{if(!outcome||outcome.kind!=="create")return;let orch=props.orchestrator;if(!orch)return;try{let state=await orch.mutateIssue(board.repoRoot,{type:"create",title:outcome.title,body:outcome.body});if(reload(),!outcome.start)return;let created=state.issues.find((entry)=>entry.id===board.nextId)??state.issues.reduce((max,entry)=>max&&max.id>entry.id?max:entry,null);if(!created)return;props.onStartChat({repoRoot:board.repoRoot,issue:created,vendor:outcome.start.vendor,placement:outcome.start.placement,jump:outcome.start.jump})}catch(err){console.error("[rove kanban] issue create failed:",err),notifyError(t3("kanban.createFailed",{error:errorMessage(err)}))}})}function requestDelete(){let board=activeBoard,issue=board?.issues.find((entry)=>entry.id===selectedId);if(!board||!issue)return;DialogConfirm.show(dialog,t3("kanban.confirmDelete.title",{id:String(issue.id)}),t3("kanban.confirmDelete.body",{title:issue.title}),void 0,void 0,{danger:!0}).then((confirmed)=>{if(!confirmed)return;props.orchestrator?.mutateIssue(board.repoRoot,{type:"delete",id:issue.id}).then(()=>{setSelectedId(null),reload()}).catch((err)=>{console.error("[rove kanban] issue delete failed:",err),notifyError(t3("kanban.deleteFailed",{id:String(issue.id),error:errorMessage(err)}))})})}useBindings(()=>({enabled:dialog.stack.length===0&&props.focused!==!1,bindings:[...pageCloseBindings(props.onClose),{key:"r",cmd:()=>reload()},{key:"tab",cmd:()=>cycleProject(1)},{key:"up",cmd:()=>moveCursor("up")},{key:"down",cmd:()=>moveCursor("down")},{key:"right",cmd:()=>moveOrCycle("right")},{key:"left",cmd:()=>moveOrCycle("left")},{key:"return",cmd:()=>{let issue=activeBoard?.issues.find((entry)=>entry.id===selectedId);if(issue)openDetail(issue)}},{key:"n",cmd:()=>openIntake()},{key:"d",cmd:()=>requestDelete()}]}));function projectSelector(active){return $jsxs("box",{flexDirection:"row",justifyContent:"space-between",paddingTop:1,children:[$jsxs("box",{flexDirection:"row",onMouseUp:()=>cycleProject(1),children:[$jsx("text",{fg:theme.primary,attributes:TextAttributes17.BOLD,wrapMode:"none",flexShrink:0,children:sidebarProjectLabel(active.repoRoot,repoRoots)}),boardList.length>1?$jsxs("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:0,children:[" ",activeIndex+1,"/",boardList.length]}):null,singleLane?null:$jsxs("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:1,children:[" ",active.repoRoot]})]}),active.issues.length===0&&!active.readError?$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:1,children:t3("kanban.empty")}):null]})}let loading=boards===null;return $jsxs("box",{ref:(r6)=>{pageRef.current=r6},onSizeChange:()=>setPageCells(pageRef.current?.width??null),flexGrow:1,backgroundColor:theme.background,paddingTop:1,paddingBottom:1,paddingLeft:2,paddingRight:2,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",gap:2,children:[$jsx("text",{attributes:TextAttributes17.BOLD,fg:theme.text,wrapMode:"none",flexShrink:0,children:t3("kanban.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:1,children:t3("kanban.hint")})]}),loading?$jsx("text",{fg:theme.textMuted,children:t3("kanban.loading")}):boardList.length===0||!activeBoard?$jsx("text",{fg:theme.textMuted,children:t3("kanban.noRepos")}):$jsxs($Fragment,{children:[projectSelector(activeBoard),activeBoard.readError?$jsx("text",{fg:theme.error,wrapMode:"none",children:t3("kanban.readFailed",{error:activeBoard.readError})}):$jsx(KanbanBoard,{columns,attentionCount,selectedId,singleLane,...props.engineStates?{engineStates:props.engineStates}:{},follow,onSelect:setSelectedId,onOpen:openDetail})]})]})}import{TextAttributes as TextAttributes23}from"@opentui/core";var import_react57=__toESM(require_react_production(),1);var SECTIONS=[{id:"general",label:"General"},{id:"engines",label:"Engines"},{id:"plugins",label:"Plugins"},{id:"keys",label:"Keybindings"},{id:"feedback",label:"Feedback"},{id:"dev",label:"Dev"}];function themeRowId(name){return`theme:${name}`}function languageRowId(locale){return`language:${locale}`}function focusAccentRowId(slot){return`accent:${slot}`}function engineRowId(vendor){return`engine:${vendor}`}function splitStyleRowId(style){return`split-style:${style}`}function prefixTapPresentationRowId(presentation){return`prefix-tap:${presentation}`}function pluginRowId(pluginId){return`plugin:${pluginId}`}function pluginSettingRowId(pluginId,key){return`plugin:${pluginId}:${key}`}function generalRows(input){return[...input.themeNames.map((name)=>({id:themeRowId(name),kind:"theme",name})),...LOCALES.map((l2)=>({id:languageRowId(l2.id),kind:"language",locale:l2.id})),{id:"transparent",kind:"transparent"},...input.focusAccentSlots.map((slot)=>({id:focusAccentRowId(slot),kind:"focusAccent",slot})),...SPLIT_STYLES.map((style)=>({id:splitStyleRowId(style),kind:"splitStyle",style})),{id:"toast",kind:"toast"},{id:"sound",kind:"sound"},{id:"cross-task",kind:"crossTask"},{id:"key-hints",kind:"keyHints"},{id:"zen-default-on",kind:"zenDefaultOn"},{id:"editor-kind",kind:"editorKind"},{id:"editor-custom",kind:"editorCustom"},{id:"worktree-base",kind:"worktreeBase"},{id:"worktree-custom",kind:"worktreeCustom"},{id:"scrollback-rows",kind:"scrollbackRows"},{id:"tab-strip-hide-single",kind:"tabStripHideSingle"}]}function engineRows(engineList){return[...engineList.map((vendor)=>({id:engineRowId(vendor),kind:"engine",vendor})),{id:"add-engine",kind:"engineAdd"}]}function pluginRows(plugins){return plugins.flatMap(({id,settingKeys})=>[{id:pluginRowId(id),kind:"pluginToggle",pluginId:id},...settingKeys.map((key)=>({id:pluginSettingRowId(id,key),kind:"pluginSetting",pluginId:id,key}))])}function feedbackRows(){return[{id:"feedback-title",kind:"feedbackTitle"},{id:"feedback-body",kind:"feedbackBody"},{id:"feedback-send",kind:"feedbackSend"}]}function keybindingRows(keybindingsFileExists){return[...PREFIX_TAP_PRESENTATIONS.map((presentation)=>({id:prefixTapPresentationRowId(presentation),kind:"prefixTapPresentation",presentation})),...keybindingsFileExists?[]:[{id:"keys-create",kind:"keysCreate"}]]}function devRows(hasDaemon){return[{id:"dev-reset",kind:"devReset"},...hasDaemon?[{id:"dev-restart",kind:"devRestartDaemon"}]:[],{id:"remote-projects",kind:"devRemoteProjects"},{id:"auto-status",kind:"devAutoStatus"},{id:"dispatcher",kind:"devDispatcher"}]}function sectionRows(section,input){switch(section){case"general":return generalRows(input);case"engines":return engineRows(input.engineList);case"keys":return keybindingRows(input.keybindingsFileExists);case"plugins":return pluginRows(input.plugins);case"feedback":return feedbackRows();case"dev":return devRows(input.hasDaemon)}}function rowIndex(rows,id){return rows.findIndex((row)=>row.id===id)}function rowAt(rows,index){return rows[index]}var SECTIONS_SIDEBAR_WIDTH=14,SECTIONS_COLUMN_GAP=2,ROW_PADDING_X=2,LABEL_COLUMN_MAX=30,LABEL_NATURAL_MAX=24,HINT_MIN_CELLS=18;function generalLabelLayout(width,dialogPadX){let rowCells=width-dialogPadX*2-SECTIONS_SIDEBAR_WIDTH-SECTIONS_COLUMN_GAP-ROW_PADDING_X;if(rowCells>=LABEL_COLUMN_MAX+HINT_MIN_CELLS)return{labelColumn:LABEL_COLUMN_MAX,showHint:!0};if(rowCells>=LABEL_NATURAL_MAX+HINT_MIN_CELLS)return{labelColumn:rowCells-HINT_MIN_CELLS,showHint:!0};return{labelColumn:0,showHint:!1}}import{existsSync as existsSync3,mkdirSync as mkdirSync2,writeFileSync as writeFileSync2}from"fs";import{dirname}from"path";var KEYBINDINGS_STARTER=`# Rove keybindings \u2014 every line below is an example, commented out.
82
+ `);import_react49.useEffect(()=>{for(let board of boardList){if(!board.readError)continue;notifyError(t3("kanban.readFailedToast",{repo:sidebarProjectLabel(board.repoRoot,repoRoots),error:board.readError}))}},[readErrorKey]);let knownTaskIds=new Set((props.orchestrator?.listTasks()??[]).map((task)=>task.id)),{columns,attentionCount}=applyBoardAttention(activeBoard?buildIssueBoard(activeBoard.issues,knownTaskIds.size===0?void 0:(taskId)=>knownTaskIds.has(taskId)):[],(taskId)=>props.engineStates?.get(taskId)?.state),follow=useCursorFollow(selectedId);function cycleProject(delta){if(boardList.length===0)return;let next=(activeIndex+delta+boardList.length)%boardList.length;setActiveRepo(boardList[next]?.repoRoot??null),setSelectedId(null)}function moveCursor(dir){let next=moveBoardSelection(columns,selectedId,dir);if(next!=null)setSelectedId(next)}function moveOrCycle(dir){if(columns.some((column)=>column.issues.length>0))moveCursor(dir);else cycleProject(dir==="left"?-1:1)}function openDetail(issue){let board=activeBoard;if(!board)return;setSelectedId(issue.id),IssueDetailDialog.show(dialog,{issue,engines,defaultVendor:quickForkDefaultVendor(board.repoRoot,engines),engineLabel:engineDisplayName,orchestrator:props.orchestrator}).then(async(outcome)=>{if(!outcome)return;let patch={};if(outcome.title!==issue.title)patch.title=outcome.title;if(outcome.body!==issue.body)patch.body=outcome.body;if(patch.title!==void 0||patch.body!==void 0)await props.orchestrator?.mutateIssue(board.repoRoot,{type:"update",id:issue.id,...patch}).catch((err)=>{console.error("[rove kanban] issue update failed:",err),notifyError(t3("kanban.updateFailed",{id:String(issue.id),error:errorMessage(err)}))}),reload();if(outcome.kind!=="create"&&outcome.status!==issue.status)await props.orchestrator?.mutateIssue(board.repoRoot,{type:"setStatus",id:issue.id,status:outcome.status}).catch((err)=>{console.error("[rove kanban] issue status change failed:",err),notifyError(t3("kanban.statusFailed",{id:String(issue.id),error:errorMessage(err)}))}),reload();if(outcome.kind==="open"){props.onOpenTask(outcome.taskId);return}if(outcome.kind==="unlink"){await props.orchestrator?.mutateIssue(board.repoRoot,{type:"unlink",id:issue.id}).catch((err)=>{console.error("[rove kanban] issue unlink failed:",err),notifyError(t3("kanban.unlinkFailed",{id:String(issue.id),error:errorMessage(err)}))}),reload();return}if(outcome.kind!=="start")return;props.onStartChat({repoRoot:board.repoRoot,issue:{...issue,...patch},vendor:outcome.vendor,placement:outcome.placement,jump:outcome.jump})})}function openIntake(){let board=activeBoard;if(!board)return;let blank={id:board.nextId,title:"",status:"open",created:new Date().toISOString().slice(0,10),body:""};IssueDetailDialog.show(dialog,{issue:blank,mode:"create",engines,defaultVendor:quickForkDefaultVendor(board.repoRoot,engines),engineLabel:engineDisplayName}).then(async(outcome)=>{if(!outcome||outcome.kind!=="create")return;let orch=props.orchestrator;if(!orch)return;try{let state=await orch.mutateIssue(board.repoRoot,{type:"create",title:outcome.title,body:outcome.body});if(reload(),!outcome.start)return;let created=state.issues.find((entry)=>entry.id===board.nextId)??state.issues.reduce((max,entry)=>max&&max.id>entry.id?max:entry,null);if(!created)return;props.onStartChat({repoRoot:board.repoRoot,issue:created,vendor:outcome.start.vendor,placement:outcome.start.placement,jump:outcome.start.jump})}catch(err){console.error("[rove kanban] issue create failed:",err),notifyError(t3("kanban.createFailed",{error:errorMessage(err)}))}})}function requestDelete(){let board=activeBoard,issue=board?.issues.find((entry)=>entry.id===selectedId);if(!board||!issue)return;DialogConfirm.show(dialog,t3("kanban.confirmDelete.title",{id:String(issue.id)}),t3("kanban.confirmDelete.body",{title:issue.title}),void 0,void 0,{danger:!0}).then((confirmed)=>{if(!confirmed)return;props.orchestrator?.mutateIssue(board.repoRoot,{type:"delete",id:issue.id}).then(()=>{setSelectedId(null),reload()}).catch((err)=>{console.error("[rove kanban] issue delete failed:",err),notifyError(t3("kanban.deleteFailed",{id:String(issue.id),error:errorMessage(err)}))})})}useBindings(()=>({enabled:dialog.stack.length===0&&props.focused!==!1,bindings:[...pageCloseBindings(props.onClose),{key:"r",cmd:()=>reload()},{key:"tab",cmd:()=>cycleProject(1)},{key:"up",cmd:()=>moveCursor("up")},{key:"down",cmd:()=>moveCursor("down")},{key:"right",cmd:()=>moveOrCycle("right")},{key:"left",cmd:()=>moveOrCycle("left")},{key:"return",cmd:()=>{let issue=activeBoard?.issues.find((entry)=>entry.id===selectedId);if(issue)openDetail(issue)}},{key:"n",cmd:()=>openIntake()},{key:"d",cmd:()=>requestDelete()}]}));function projectSelector(active){return $jsxs("box",{flexDirection:"row",justifyContent:"space-between",paddingTop:1,children:[$jsxs("box",{flexDirection:"row",onMouseUp:()=>cycleProject(1),children:[$jsx("text",{fg:theme.primary,attributes:TextAttributes17.BOLD,wrapMode:"none",flexShrink:0,children:sidebarProjectLabel(active.repoRoot,repoRoots)}),boardList.length>1?$jsxs("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:0,children:[" ",activeIndex+1,"/",boardList.length]}):null,singleLane?null:$jsxs("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:1,children:[" ",active.repoRoot]})]}),active.issues.length===0&&!active.readError?$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:1,children:t3("kanban.empty")}):null]})}let loading=boards===null;return $jsxs("box",{ref:(r6)=>{pageRef.current=r6},onSizeChange:()=>setPageCells(pageRef.current?.width??null),flexGrow:1,backgroundColor:theme.background,paddingTop:1,paddingBottom:1,paddingLeft:2,paddingRight:2,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",gap:2,children:[$jsx("text",{attributes:TextAttributes17.BOLD,fg:theme.text,wrapMode:"none",flexShrink:0,children:t3("kanban.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:1,children:t3("kanban.hint")})]}),loading?$jsx("text",{fg:theme.textMuted,children:t3("kanban.loading")}):boardList.length===0||!activeBoard?$jsx("text",{fg:theme.textMuted,children:t3("kanban.noRepos")}):$jsxs($Fragment,{children:[projectSelector(activeBoard),activeBoard.readError?$jsx("text",{fg:theme.error,wrapMode:"none",children:t3("kanban.readFailed",{error:activeBoard.readError})}):$jsx(KanbanBoard,{columns,attentionCount,selectedId,singleLane,...props.engineStates?{engineStates:props.engineStates}:{},follow,onSelect:setSelectedId,onOpen:openDetail})]})]})}import{TextAttributes as TextAttributes23}from"@opentui/core";var import_react57=__toESM(require_react_production(),1);var SECTIONS=[{id:"general",label:"General"},{id:"engines",label:"Engines"},{id:"plugins",label:"Plugins"},{id:"keys",label:"Keybindings"},{id:"feedback",label:"Feedback"},{id:"dev",label:"Dev"}];function themeRowId(name){return`theme:${name}`}function languageRowId(locale){return`language:${locale}`}function focusAccentRowId(slot){return`accent:${slot}`}function engineRowId(vendor){return`engine:${vendor}`}function splitStyleRowId(style){return`split-style:${style}`}function prefixTapPresentationRowId(presentation){return`prefix-tap:${presentation}`}function pluginRowId(pluginId){return`plugin:${pluginId}`}function pluginSettingRowId(pluginId,key){return`plugin:${pluginId}:${key}`}function generalRows(input){return[...input.themeNames.map((name)=>({id:themeRowId(name),kind:"theme",name})),...LOCALES.map((l2)=>({id:languageRowId(l2.id),kind:"language",locale:l2.id})),{id:"transparent",kind:"transparent"},...input.focusAccentSlots.map((slot)=>({id:focusAccentRowId(slot),kind:"focusAccent",slot})),...SPLIT_STYLES.map((style)=>({id:splitStyleRowId(style),kind:"splitStyle",style})),{id:"toast",kind:"toast"},{id:"sound",kind:"sound"},{id:"sound-volume",kind:"soundVolume"},{id:"cross-task",kind:"crossTask"},{id:"key-hints",kind:"keyHints"},{id:"zen-default-on",kind:"zenDefaultOn"},{id:"editor-kind",kind:"editorKind"},{id:"editor-custom",kind:"editorCustom"},{id:"worktree-base",kind:"worktreeBase"},{id:"worktree-custom",kind:"worktreeCustom"},{id:"scrollback-rows",kind:"scrollbackRows"},{id:"tab-strip-hide-single",kind:"tabStripHideSingle"}]}function engineRows(engineList){return[...engineList.map((vendor)=>({id:engineRowId(vendor),kind:"engine",vendor})),{id:"add-engine",kind:"engineAdd"}]}function pluginRows(plugins){return plugins.flatMap(({id,settingKeys})=>[{id:pluginRowId(id),kind:"pluginToggle",pluginId:id},...settingKeys.map((key)=>({id:pluginSettingRowId(id,key),kind:"pluginSetting",pluginId:id,key}))])}function feedbackRows(){return[{id:"feedback-title",kind:"feedbackTitle"},{id:"feedback-body",kind:"feedbackBody"},{id:"feedback-send",kind:"feedbackSend"}]}function keybindingRows(keybindingsFileExists){return[...PREFIX_TAP_PRESENTATIONS.map((presentation)=>({id:prefixTapPresentationRowId(presentation),kind:"prefixTapPresentation",presentation})),...keybindingsFileExists?[]:[{id:"keys-create",kind:"keysCreate"}]]}function devRows(hasDaemon){return[{id:"dev-reset",kind:"devReset"},...hasDaemon?[{id:"dev-restart",kind:"devRestartDaemon"}]:[],{id:"remote-projects",kind:"devRemoteProjects"},{id:"auto-status",kind:"devAutoStatus"},{id:"dispatcher",kind:"devDispatcher"}]}function sectionRows(section,input){switch(section){case"general":return generalRows(input);case"engines":return engineRows(input.engineList);case"keys":return keybindingRows(input.keybindingsFileExists);case"plugins":return pluginRows(input.plugins);case"feedback":return feedbackRows();case"dev":return devRows(input.hasDaemon)}}function rowIndex(rows,id){return rows.findIndex((row)=>row.id===id)}function rowAt(rows,index){return rows[index]}var SECTIONS_SIDEBAR_WIDTH=14,SECTIONS_COLUMN_GAP=2,ROW_PADDING_X=2,LABEL_COLUMN_MAX=30,LABEL_NATURAL_MAX=24,HINT_MIN_CELLS=18;function generalLabelLayout(width,dialogPadX){let rowCells=width-dialogPadX*2-SECTIONS_SIDEBAR_WIDTH-SECTIONS_COLUMN_GAP-ROW_PADDING_X;if(rowCells>=LABEL_COLUMN_MAX+HINT_MIN_CELLS)return{labelColumn:LABEL_COLUMN_MAX,showHint:!0};if(rowCells>=LABEL_NATURAL_MAX+HINT_MIN_CELLS)return{labelColumn:rowCells-HINT_MIN_CELLS,showHint:!0};return{labelColumn:0,showHint:!1}}import{existsSync as existsSync3,mkdirSync as mkdirSync2,writeFileSync as writeFileSync2}from"fs";import{dirname}from"path";var KEYBINDINGS_STARTER=`# Rove keybindings \u2014 every line below is an example, commented out.
83
83
  # Uncomment what you want; changes reload live, no restart.
84
84
  # Press F1 in Rove for the live keymap with every binding id.
85
85
  #
@@ -98,12 +98,12 @@ ${line}`:line,index+=1}return next}var ISSUE_CHAT_PLACEMENTS=["worktree","projec
98
98
  # bindings:
99
99
  # palette.open: [cmd+p, ctrl+p]
100
100
  `;function createKeybindingsFile(path){if(existsSync3(path))return!1;return mkdirSync2(dirname(path),{recursive:!0}),writeFileSync2(path,KEYBINDINGS_STARTER),!0}import{unlinkSync}from"fs";import{join as join2}from"path";function hasRestartableDaemon(orchestrator){return orchestrator instanceof RemoteOrchestrator}function destroyRendererSafely(renderer,action){try{renderer?.destroy()}catch(err){console.error(`Rove: renderer.destroy() failed during ${action}:`,err)}}function removeTasksFileForReset(){try{unlinkSync(join2(roveStateDir(),"tasks.json"))}catch(err){if(err.code!=="ENOENT")console.error("Rove: failed to delete tasks.json during reset:",err)}}async function confirmResetState(dialog,kv,renderer){if(await DialogConfirm.show(dialog,t("settings.reset.title"),t("settings.reset.body"),"cancel",void 0,{danger:!0})!==!0)return;if(!kv.clear()){await DialogConfirm.show(dialog,t("settings.reset.failedTitle"),t("settings.reset.failedBody"),"cancel");return}removeTasksFileForReset(),destroyRendererSafely(renderer,"reset"),process.stderr.write(`${t("settings.reset.done")}
101
- `),process.exit(0)}async function confirmRestartDaemon(dialog,orchestrator,renderer){if(!hasRestartableDaemon(orchestrator))return;if(await DialogConfirm.show(dialog,t("settings.restart.title"),t("settings.restart.body"),"cancel")!==!0)return;await orchestrator.restartDaemon(),relaunchSelf({renderer,notice:t("settings.restart.done")})}import{TextAttributes as TextAttributes18}from"@opentui/core";function EngineSettingsSection(props){let{theme}=useTheme(),t3=useT(),addRowIndex=props.vendors.length,isBodyCursor=(row)=>props.level==="body"&&props.bodyRow===row,byVendor=new Map((props.statuses??[]).map((s2)=>[s2.vendor,s2])),nameWidth=Math.min(16,props.vendors.reduce((max,v3)=>Math.max(max,displayWidth(props.displayName(v3))),0)),padName=(name)=>name+" ".repeat(Math.max(0,nameWidth-displayWidth(name))),protocolChip=(vendor)=>{if(!props.isCustom(vendor))return;let declared=props.engineProtocol(vendor);return{label:t3("settings.engines.protocolRow",{protocol:declared??t3("settings.engines.protocolGeneric")}),declared:declared!==void 0}};return $jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes18.BOLD,children:t3("settings.engines.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.engines.hint")}),$jsxs("box",{flexDirection:"column",gap:0,children:[props.vendors.map((vendor,i2)=>{let isCursor=isBodyCursor(i2),enabled=props.isEnabled(vendor),nameFg=isCursor?theme.selectedListItemText:enabled?theme.text:theme.textMuted,commandFg=isCursor?theme.selectedListItemText:!enabled||props.isDefault(vendor)?theme.textMuted:theme.accent;return $jsxs("box",{flexDirection:"column",gap:0,ref:props.rowRef(i2),children:[$jsxs("box",{flexDirection:"row",gap:1,paddingLeft:1,paddingRight:1,overflow:"hidden",backgroundColor:isCursor?theme.primary:void 0,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(i2),props.editEngine(vendor)},children:[$jsx("text",{fg:isCursor?theme.selectedListItemText:enabled?theme.text:theme.textMuted,wrapMode:"none",onMouseUp:(evt)=>{evt.stopPropagation(),props.setLevel("body"),props.setBodyRow(i2),props.toggleEngine(vendor)},children:enabled?"[x]":"[ ]"}),$jsx("text",{fg:isCursor?theme.selectedListItemText:props.isDefaultEngine(vendor)?theme.accent:theme.textMuted,attributes:TextAttributes18.BOLD,wrapMode:"none",onMouseUp:(evt)=>{evt.stopPropagation(),props.setLevel("body"),props.setBodyRow(i2),props.chooseDefault(vendor)},children:props.isDefaultEngine(vendor)?"(\u25CF)":"( )"}),$jsx("text",{fg:nameFg,attributes:TextAttributes18.BOLD,wrapMode:"none",children:padName(props.displayName(vendor))}),$jsx("text",{fg:commandFg,wrapMode:"none",flexShrink:1,children:props.commandText(vendor)+(props.isCustom(vendor)?t3("settings.engines.customTag"):"")})]}),$jsx(EngineStatusLine,{status:byVendor.get(vendor)??null,probing:props.statuses===null,protocol:protocolChip(vendor)})]},vendor)}),$jsx("box",{ref:props.rowRef(addRowIndex),flexDirection:"row",paddingLeft:1,paddingRight:1,backgroundColor:isBodyCursor(addRowIndex)?theme.primary:void 0,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(addRowIndex),props.onAddEngine()},children:$jsx("text",{fg:isBodyCursor(addRowIndex)?theme.selectedListItemText:theme.primary,wrapMode:"none",children:t3("settings.engines.addEngine")})})]})]})}function EngineStatusLine(props){let{theme}=useTheme(),t3=useT(),s2=props.status,protocol=props.protocol?$jsx("text",{fg:props.protocol.declared?theme.accent:theme.textMuted,wrapMode:"none",children:props.protocol.label}):null;if(!s2)return $jsxs("box",{flexDirection:"row",gap:1,paddingLeft:6,overflow:"hidden",children:[protocol,$jsx("text",{fg:theme.textMuted,children:props.probing?t3("settings.accounts.checking"):" "})]});return $jsxs("box",{flexDirection:"row",gap:1,paddingLeft:6,overflow:"hidden",children:[protocol,s2.account===null?null:$jsx(AccountLine,{account:s2.account}),s2.accountError?$jsx("text",{fg:theme.warning,wrapMode:"none",children:`! ${s2.accountError}`}):null,$jsx("text",{fg:s2.binary.found?theme.textMuted:theme.warning,wrapMode:"none",flexShrink:1,children:(s2.account===null?"":"\xB7 ")+(s2.binary.found?tildify(s2.binary.path):s2.binary.error)})]})}function AccountLine({account}){let{theme}=useTheme(),t3=useT();if(account.kind==="oauth"){if(!("email"in account))return $jsx("text",{fg:theme.success,wrapMode:"none",children:t3("settings.accounts.detected")});let tail=account.billingType;return $jsx("text",{fg:theme.success,wrapMode:"none",flexShrink:1,children:t3("settings.accounts.loggedIn",{email:account.email})+(tail?` (${tail})`:"")})}if(account.kind==="chatgpt")return $jsx("text",{fg:theme.success,wrapMode:"none",flexShrink:1,children:t3("settings.accounts.chatgptLogin",{email:account.email})+(account.plan?` (${account.plan})`:"")});if(account.kind==="apikey")return $jsx("text",{fg:theme.success,children:t3("settings.accounts.apiKeyConfigured")});if(account.kind==="token")return $jsx("text",{fg:theme.success,children:t3("settings.accounts.tokenConfigured",{source:account.source})});return $jsx("text",{fg:theme.textMuted,children:t3("settings.accounts.notLoggedIn")})}import{TextAttributes as TextAttributes20}from"@opentui/core";var import_react51=__toESM(require_react_production(),1);import{TextAttributes as TextAttributes19}from"@opentui/core";function Row(props){let{theme}=useTheme();return $jsxs("box",{ref:props.rowRef,flexDirection:"row",gap:1,paddingLeft:1,paddingRight:1,overflow:"hidden",backgroundColor:props.cursor?theme.primary:props.idleBackground,onMouseUp:props.onMouseUp,children:[$jsx("text",{fg:props.cursor?theme.selectedListItemText:props.fg,attributes:props.bold?TextAttributes19.BOLD:void 0,wrapMode:"none",children:props.children}),props.hint?$jsx("text",{fg:props.cursor?theme.selectedListItemText:theme.textMuted,wrapMode:"none",flexShrink:1,children:props.hint}):null]})}function SubSection(props){let{theme}=useTheme();return $jsxs("box",{flexDirection:"column",gap:0,paddingTop:props.paddingTop??1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes19.BOLD,children:props.title}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:props.hint}),props.children]})}function SettingsSectionSidebar(props){let{theme}=useTheme(),t3=useT();return $jsx("box",{flexDirection:"column",flexShrink:0,width:SECTIONS_SIDEBAR_WIDTH,gap:1,children:SECTIONS.map((s2,i2)=>{let isSection=i2===props.cursor,isSidebarFocused=isSection&&props.level==="sidebar";return $jsx("box",{paddingLeft:1,paddingRight:1,backgroundColor:isSidebarFocused?theme.primary:void 0,onMouseUp:()=>props.switchSection(s2.id),children:$jsx("text",{fg:isSidebarFocused?theme.selectedListItemText:isSection?theme.accent:theme.textMuted,attributes:isSection?TextAttributes20.BOLD:void 0,wrapMode:"none",children:t3(`settings.sections.${s2.id}`)})},s2.id)})})}function UsageDashboard(props){let{theme}=useTheme(),t3=useT(),toneColor2={ok:theme.success,warn:theme.warning,crit:theme.error},now=Date.now();return $jsx("box",{flexDirection:"column",flexShrink:0,alignSelf:"flex-start",gap:0,children:[...props.usage.entries()].map(([vendor,usage])=>$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes20.BOLD,wrapMode:"none",children:`${engineDisplayName(vendor).toUpperCase()} ${t3("settings.general.usage")}`}),usageRows(usage,now).map((row)=>$jsxs("box",{flexDirection:"row",gap:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:row.label}),$jsx("text",{fg:toneColor2[row.tone],wrapMode:"none",children:`${row.bar} ${row.percentText}`}),row.resetText?$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:row.resetText}):null]},row.label))]},vendor))})}function GeneralSettingsSection(props){let{prefs}=props,themeCtx=useTheme(),{theme}=themeCtx,t3=useT(),kv=useKV(),rows=import_react51.useMemo(()=>generalRows({themeNames:props.themeNames,focusAccentSlots:FOCUS_ACCENT_SLOTS}),[props.themeNames]),rowIdx=(id)=>rowIndex(rows,id),isBodyCursor=(row)=>props.level==="body"&&props.bodyRow===row,activate=(row,action)=>()=>{props.setLevel("body"),props.setBodyRow(row),action()},onOff=(on)=>on?t3("settings.general.on"):t3("settings.general.off"),{labelColumn,showHint}=generalLabelLayout(useTerminalDimensions().width,useDialogPaddingX()),hint=(key)=>showHint?t3(key):void 0,pad=(label)=>label+" ".repeat(Math.max(0,labelColumn-displayWidth(label))),check=(on)=>on?"[x]":"[ ]",radio=(on)=>on?"(\u25CF)":"( )",transparentRow=rowIdx("transparent"),toastRow=rowIdx("toast"),soundRow=rowIdx("sound"),crossTaskRow=rowIdx("cross-task"),keyHintsRow=rowIdx("key-hints"),zenDefaultOnRow=rowIdx("zen-default-on"),editorKindRow=rowIdx("editor-kind"),editorCustomRow=rowIdx("editor-custom"),worktreeBaseRow=rowIdx("worktree-base"),worktreeCustomRow=rowIdx("worktree-custom"),scrollbackRow=rowIdx("scrollback-rows"),tabStripHideSingleRow=rowIdx("tab-strip-hide-single");return $jsxs("box",{flexDirection:"row",gap:2,children:[$jsxs("box",{flexDirection:"column",gap:1,flexGrow:1,flexShrink:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes20.BOLD,children:t3("settings.general.theme")}),$jsx("text",{fg:theme.textMuted,children:t3("settings.general.themeHint")}),$jsx("box",{flexDirection:"column",gap:0,children:props.themeNames.map((name,i2)=>{let isSelected=name===themeCtx.selected;return $jsx(Row,{cursor:isBodyCursor(i2),rowRef:props.rowRef(i2),onMouseUp:activate(i2,()=>props.selectTheme(name)),fg:isSelected?theme.accent:theme.text,bold:isBodyCursor(i2)||isSelected,children:`${radio(isSelected)} ${name}`},name)})}),$jsx(SubSection,{title:t3("settings.general.language"),hint:t3("settings.general.languageHint"),children:LOCALES.map((loc)=>{let langRow=rowIdx(languageRowId(loc.id)),isSelected=props.currentLocale===loc.id;return $jsx(Row,{cursor:isBodyCursor(langRow),rowRef:props.rowRef(langRow),onMouseUp:activate(langRow,()=>props.selectLanguage(loc.id)),fg:isSelected?theme.accent:theme.text,bold:isBodyCursor(langRow)||isSelected,children:`${radio(isSelected)} ${loc.label}`},loc.id)})}),$jsx(SubSection,{title:t3("settings.general.transparent"),hint:t3("settings.general.transparentHint"),children:$jsx(Row,{cursor:isBodyCursor(transparentRow),rowRef:props.rowRef(transparentRow),onMouseUp:activate(transparentRow,props.toggleTransparent),fg:themeCtx.transparentBackground?theme.accent:theme.textMuted,bold:!0,children:onOff(themeCtx.transparentBackground)})}),$jsx(SubSection,{title:t3("settings.general.focusAccent"),hint:t3("settings.general.focusAccentHint"),children:FOCUS_ACCENT_SLOTS.map((slot)=>{let accentRow=rowIdx(focusAccentRowId(slot)),isSelected=themeCtx.focusAccent===slot;return $jsx(Row,{cursor:isBodyCursor(accentRow),rowRef:props.rowRef(accentRow),onMouseUp:activate(accentRow,()=>props.selectFocusAccent(slot)),fg:isSelected?theme.focusAccent:theme.text,bold:isBodyCursor(accentRow)||isSelected,children:`${radio(isSelected)} ${t3(`settings.general.accent${slot.charAt(0).toUpperCase()}${slot.slice(1)}`)}`},slot)})}),$jsx(SubSection,{title:t3("settings.general.appearance"),hint:t3("settings.general.appearanceHint"),children:SPLIT_STYLES.map((style)=>{let styleRow=rowIdx(splitStyleRowId(style)),isSelected=prefs.splitStyle()===style;return $jsx(Row,{cursor:isBodyCursor(styleRow),rowRef:props.rowRef(styleRow),onMouseUp:activate(styleRow,()=>prefs.selectSplitStyle(style)),fg:isSelected?theme.accent:theme.text,bold:isBodyCursor(styleRow)||isSelected,children:`${radio(isSelected)} ${t3(style==="box"?"settings.general.splitBox":"settings.general.splitLine")}`},style)})}),$jsxs(SubSection,{title:t3("settings.general.notifications"),hint:t3("settings.general.notificationsHint"),children:[$jsx(Row,{cursor:isBodyCursor(toastRow),rowRef:props.rowRef(toastRow),onMouseUp:activate(toastRow,prefs.toggleToast),fg:prefs.toastEnabled()?theme.accent:theme.textMuted,bold:!0,hint:hint("settings.general.toastHint"),children:pad(`${check(prefs.toastEnabled())} ${t3("settings.general.toast")}`)}),$jsx(Row,{cursor:isBodyCursor(soundRow),rowRef:props.rowRef(soundRow),onMouseUp:activate(soundRow,prefs.toggleSound),fg:prefs.soundEnabled()?theme.accent:theme.textMuted,bold:!0,hint:hint("settings.general.soundHint"),children:pad(`${check(prefs.soundEnabled())} ${t3("settings.general.sound")}`)}),$jsx(Row,{cursor:isBodyCursor(crossTaskRow),rowRef:props.rowRef(crossTaskRow),onMouseUp:activate(crossTaskRow,prefs.toggleCrossTask),fg:prefs.crossTaskEnabled()?theme.accent:theme.textMuted,bold:!0,hint:hint("settings.general.crossTaskHint"),children:pad(`${check(prefs.crossTaskEnabled())} ${t3("settings.general.crossTask")}`)})]}),$jsx(SubSection,{title:t3("settings.general.keyHints"),hint:t3("settings.general.keyHintsHint"),children:$jsx(Row,{cursor:isBodyCursor(keyHintsRow),rowRef:props.rowRef(keyHintsRow),onMouseUp:activate(keyHintsRow,()=>toggleKeyHints(kv)),fg:keyHintsToggleOn(kv)?theme.accent:theme.textMuted,bold:!0,hint:hint("settings.general.keyHintsShowHint"),children:pad(`${check(keyHintsToggleOn(kv))} ${t3("settings.general.keyHintsShow")}`)})}),$jsx(SubSection,{title:t3("settings.general.zen"),hint:t3("settings.general.zenHint"),children:$jsx(Row,{cursor:isBodyCursor(zenDefaultOnRow),rowRef:props.rowRef(zenDefaultOnRow),onMouseUp:activate(zenDefaultOnRow,prefs.toggleZenDefaultOn),fg:prefs.zenDefaultOn()?theme.accent:theme.textMuted,bold:!0,children:`${check(prefs.zenDefaultOn())} ${t3("settings.general.zenDefaultOn")}`})}),$jsxs(SubSection,{title:t3("settings.general.editor"),hint:t3("settings.general.editorHint"),children:[$jsx(Row,{cursor:isBodyCursor(editorKindRow),rowRef:props.rowRef(editorKindRow),onMouseUp:activate(editorKindRow,prefs.cycleEditorKind),fg:theme.accent,bold:!0,hint:hint("settings.general.editorRowHint"),children:pad(t3("settings.general.editorRow",{kind:prefs.editorKind()}))}),$jsx(Row,{cursor:isBodyCursor(editorCustomRow),rowRef:props.rowRef(editorCustomRow),onMouseUp:activate(editorCustomRow,()=>void prefs.editEditorCustom()),fg:prefs.editorKind()==="custom"?theme.text:theme.textMuted,children:t3("settings.general.editorCustom",{cmd:prefs.editorCustomCommand().trim()||t3("settings.general.editorCustomUnset")})})]}),$jsxs(SubSection,{title:t3("settings.general.worktree"),hint:t3("settings.general.worktreeHint"),children:[$jsx(Row,{cursor:isBodyCursor(worktreeBaseRow),rowRef:props.rowRef(worktreeBaseRow),onMouseUp:activate(worktreeBaseRow,prefs.cycleWorktreeBase),fg:theme.accent,bold:!0,hint:hint("settings.general.worktreeBaseHint"),children:pad(t3("settings.general.worktreeBase",{kind:prefs.worktreeKindLabel()}))}),$jsx(Row,{cursor:isBodyCursor(worktreeCustomRow),rowRef:props.rowRef(worktreeCustomRow),onMouseUp:activate(worktreeCustomRow,()=>void prefs.editWorktreeCustom()),fg:prefs.worktreeKind()==="custom"?theme.text:theme.textMuted,children:t3("settings.general.worktreeCustom",{path:prefs.worktreeCustomPath()||t3("settings.general.worktreeCustomUnset")})})]}),$jsxs(SubSection,{title:t3("settings.general.terminal"),hint:t3("settings.general.terminalHint"),children:[$jsx(Row,{cursor:isBodyCursor(scrollbackRow),rowRef:props.rowRef(scrollbackRow),onMouseUp:activate(scrollbackRow,()=>void prefs.editScrollbackRows()),fg:theme.accent,bold:!0,hint:hint("settings.general.scrollbackRowHint"),children:pad(t3("settings.general.scrollbackRow",{rows:String(prefs.scrollbackRows())}))}),$jsx(Row,{cursor:isBodyCursor(tabStripHideSingleRow),rowRef:props.rowRef(tabStripHideSingleRow),onMouseUp:activate(tabStripHideSingleRow,prefs.cycleTabStripMode),fg:theme.accent,bold:!0,children:t3("settings.general.tabStripRow",{mode:t3(`settings.general.tabStripMode.${prefs.tabStripMode()}`)})})]})]}),props.usage&&props.usage.size>0?$jsx(UsageDashboard,{usage:props.usage}):null]})}var import_react52=__toESM(require_react_production(),1);import{TextAttributes as TextAttributes21}from"@opentui/core";function FeedbackSettingsSection(props){let{theme}=useTheme(),t3=useT(),editing=props.level==="body",titleFocused=editing&&props.bodyRow===0,bodyFocused=editing&&props.bodyRow===1,sendFocused=editing&&props.bodyRow===2,labelFg=(focused)=>focused?theme.primary:theme.textMuted,labelAttrs=(focused)=>focused?TextAttributes21.BOLD|TextAttributes21.UNDERLINE:void 0,bodyEl=import_react52.useRef(null);return import_react52.useEffect(()=>{if(props.body===""&&bodyEl.current&&bodyEl.current.plainText!=="")bodyEl.current.setText("")},[props.body]),$jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.feedback.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.feedback.hint")}),$jsxs("box",{flexDirection:"column",gap:1,children:[$jsxs("box",{gap:0,children:[$jsx("text",{fg:labelFg(titleFocused),attributes:labelAttrs(titleFocused),children:t3("settings.feedback.titleLabel")}),$jsx("input",{value:props.title,placeholder:t3("settings.feedback.titlePlaceholder"),focused:titleFocused,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(0)},onInput:(v3)=>props.setTitle(stripNewlines(v3)),onSubmit:()=>props.onTitleSubmit()})]}),$jsxs("box",{gap:0,children:[$jsx("text",{fg:labelFg(bodyFocused),attributes:labelAttrs(bodyFocused),children:t3("settings.feedback.descriptionLabel")}),$jsx("textarea",{ref:(el)=>{bodyEl.current=el},initialValue:props.body,placeholder:t3("settings.feedback.descriptionPlaceholder"),focused:bodyFocused,height:4,wrapMode:"word",onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(1)},onContentChange:()=>props.setBody(bodyEl.current?.plainText??"")})]}),$jsx("box",{flexDirection:"row",paddingLeft:1,paddingRight:1,backgroundColor:sendFocused?theme.primary:theme.backgroundElement,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(2),props.submit()},children:$jsx("text",{fg:sendFocused?theme.selectedListItemText:theme.accent,attributes:TextAttributes21.BOLD,children:t3("settings.feedback.send")})})]}),props.status?$jsx("text",{fg:props.status.startsWith("error:")?theme.warning:theme.success,wrapMode:"word",children:props.status}):null]})}function DevSettingsSection(props){let{prefs}=props,{theme}=useTheme(),t3=useT(),rows=devRows(props.hasDaemon),isBodyCursor=(row)=>props.level==="body"&&props.bodyRow===row,activate=(row,action)=>()=>{props.setLevel("body"),props.setBodyRow(row),action()},toggleRow=(id,enabled,hintKey,labelKey,act)=>{let row=rowIndex(rows,id);return $jsxs("box",{flexDirection:"column",gap:0,paddingTop:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3(hintKey)}),$jsx(Row,{cursor:isBodyCursor(row),rowRef:props.rowRef(row),onMouseUp:activate(row,act),fg:theme.text,bold:enabled,idleBackground:theme.backgroundElement,children:`${enabled?"[x]":"[ ]"} ${t3(labelKey)}`})]})};return $jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.dev.reset")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.dev.resetHint")}),$jsx(Row,{cursor:isBodyCursor(0),rowRef:props.rowRef(0),onMouseUp:activate(0,props.confirmReset),fg:theme.warning,bold:!0,idleBackground:theme.backgroundElement,children:t3("settings.dev.resetButton")}),props.hasDaemon?$jsx(SubSection,{title:t3("settings.dev.restart"),hint:t3("settings.dev.restartHint"),children:$jsx(Row,{cursor:isBodyCursor(1),rowRef:props.rowRef(1),onMouseUp:activate(1,props.confirmRestartDaemon),fg:theme.accent,bold:!0,idleBackground:theme.backgroundElement,children:t3("settings.dev.restartButton")})}):null,$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.dev.doctorHint")}),$jsxs("box",{flexDirection:"column",gap:0,paddingTop:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.dev.experimental")}),toggleRow("remote-projects",prefs.remoteProjectsEnabled(),"settings.dev.remoteHint","settings.dev.remote",prefs.toggleRemoteProjects),toggleRow("auto-status",prefs.autoStatusOn(),"settings.dev.autoStatusHint","settings.dev.autoStatus",prefs.toggleAutoStatus),toggleRow("dispatcher",prefs.dispatcherOn(),"settings.dev.dispatcherHint","settings.dev.dispatcher",prefs.toggleDispatcher)]})]})}function KeybindingsSettingsSection(props){let{theme}=useTheme(),t3=useT();useKeymapVersion();let report=userKeybindingsReport(),rows=keybindingRows(report.exists),prefix=currentPrefixConfiguration(),fixedIds=Object.keys(FIXED_BINDING_IDS).sort(),appliedIdWidth=Math.min(28,report.applied.reduce((max,o2)=>Math.max(max,o2.id.length),0));return $jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.hint")}),$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.configFile")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:tildify(report.path)+(report.exists?"":t3("settings.keybindings.notCreated"))})]}),$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.tapPresentation")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.tapPresentationHint")}),PREFIX_TAP_PRESENTATIONS.map((presentation)=>{let row=rowIndex(rows,prefixTapPresentationRowId(presentation)),selected=props.prefs.prefixTapPresentation()===presentation;return $jsx(Row,{cursor:props.level==="body"&&props.bodyRow===row,rowRef:props.rowRef(row),onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(row),props.prefs.selectPrefixTapPresentation(presentation)},fg:selected?theme.accent:theme.text,bold:selected||props.level==="body"&&props.bodyRow===row,children:`${selected?"(\u25CF)":"( )"} ${t3(presentation==="local"?"settings.keybindings.tapPresentationLocal":"settings.keybindings.tapPresentationGuide")}`},presentation)})]}),$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.prefixTitle",{prefix:prefix.key??t3("settings.keybindings.prefixDisabled")})}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.prefixHint",{prefix:prefix.key??t3("settings.keybindings.prefixDisabled"),timeout:prefix.timeoutMs})})]}),!report.exists?$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.createHint")}),$jsx(Row,{cursor:props.level==="body"&&props.bodyRow===rowIndex(rows,"keys-create"),rowRef:props.rowRef(rowIndex(rows,"keys-create")),onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(rowIndex(rows,"keys-create")),props.onCreateFile()},fg:theme.text,idleBackground:theme.backgroundElement,children:t3("settings.keybindings.createFile")})]}):$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.overridesApplied")}),report.applied.length===0?$jsx("text",{fg:theme.textMuted,children:t3("settings.keybindings.none")}):null,report.applied.map((o2)=>$jsx("text",{fg:theme.text,wrapMode:"none",children:`${o2.id.padEnd(appliedIdWidth)} ${o2.keys.length>0?o2.keys.join(" / "):t3("settings.keybindings.unbound")} (${t3("settings.keybindings.defaultKeys",{keys:o2.defaultKeys.join(" / ")})})`},o2.id))]}),report.warnings.length>0?$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.warning,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.warnings")}),report.warnings.map((w4)=>$jsx("text",{fg:theme.warning,wrapMode:"word",children:`! ${w4}`},w4))]}):null,fixedIds.length>0?$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.fixed",{ids:fixedIds.join(", ")})}):null]})}import{TextAttributes as TextAttributes22}from"@opentui/core";function pluginSettingRows(schema,values){return schema.map((setting)=>{let stored=values[setting.key],defaultValue=setting.default??"";return{key:setting.key,label:setting.label,type:setting.type,options:setting.options??[],defaultValue,value:stored??defaultValue,defaulted:stored===void 0}})}function displaySettingValue(row){if(row.type!=="secret"||row.value==="")return row.value;return"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}function isBooleanOn(value){return value!==""&&value!=="0"&&value.toLowerCase()!=="false"}function nextEnumValue(options,current){if(options.length===0)return current;let i2=options.indexOf(current);return options[(i2+1)%options.length]}function toggledBooleanValue(row){if(!isBooleanOn(row.value))return"1";return isBooleanOn(row.defaultValue)?"0":""}function normalizeNumberInput(raw){let trimmed=raw.trim();if(trimmed==="")return"";let n2=Number(trimmed);return Number.isFinite(n2)?String(n2):null}function toggleRowOffsets(plugins){let offsets=[],next=0;for(let plugin of plugins)offsets.push(next),next+=1+plugin.settings.length;return offsets}function SettingRow(props){let{theme}=useTheme(),t3=useT(),{setting}=props,value=setting.type==="boolean"?isBooleanOn(setting.value)?t3("settings.general.on"):t3("settings.general.off"):displaySettingValue(setting)||t3("settings.plugins.settingUnset");return $jsxs("box",{ref:props.rowRef,flexDirection:"row",gap:1,paddingLeft:5,paddingRight:1,backgroundColor:props.cursor?theme.primary:void 0,onMouseUp:props.onActivate,children:[$jsx("text",{fg:props.cursor?theme.selectedListItemText:theme.text,wrapMode:"none",children:setting.label}),$jsx("text",{fg:props.cursor?theme.selectedListItemText:setting.defaulted?theme.textMuted:theme.accent,wrapMode:"none",children:value})]})}function PluginSettingsSection(props){let{theme}=useTheme(),t3=useT(),now=Date.now(),isBodyCursor=(row)=>props.level==="body"&&props.bodyRow===row,offsets=toggleRowOffsets(props.plugins);return $jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes22.BOLD,children:t3("settings.plugins.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3(props.plugins.length===0?"settings.plugins.empty":"settings.plugins.hint")}),props.plugins.length===0?null:$jsx("box",{flexDirection:"column",gap:0,children:props.plugins.map((plugin,i2)=>{let toggleRow=offsets[i2]??0,isCursor=isBodyCursor(toggleRow);return $jsxs("box",{flexDirection:"column",gap:0,children:[$jsxs("box",{ref:props.rowRef(toggleRow),flexDirection:"row",gap:1,paddingLeft:1,paddingRight:1,backgroundColor:isCursor?theme.primary:void 0,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(toggleRow),props.toggle(plugin.id)},children:[$jsx("text",{fg:isCursor?theme.selectedListItemText:plugin.enabled?theme.accent:theme.textMuted,attributes:TextAttributes22.BOLD,wrapMode:"none",children:`${plugin.enabled?"[x]":"[ ]"} ${plugin.id}`}),$jsx("text",{fg:isCursor?theme.selectedListItemText:theme.textMuted,wrapMode:"none",children:`v${plugin.version} ${plugin.linked?t3("settings.plugins.sourceLink",{path:plugin.source}):t3("settings.plugins.sourceGithub",{spec:plugin.source})}`}),plugin.updateAvailable?$jsx("text",{fg:theme.warning,wrapMode:"none",children:t3("settings.plugins.updateAvailable")}):null]}),$jsxs("box",{flexDirection:"row",gap:1,paddingLeft:5,paddingRight:1,children:[$jsx("text",{fg:plugin.declares?theme.textMuted:theme.warning,wrapMode:"none",children:plugin.declares?plugin.declares.engines>0?t3("settings.plugins.declaresWithEngines",{actions:String(plugin.declares.actions),events:String(plugin.declares.events),panes:String(plugin.declares.panes),engines:String(plugin.declares.engines)}):t3("settings.plugins.declares",{actions:String(plugin.declares.actions),events:String(plugin.declares.events),panes:String(plugin.declares.panes)}):t3("settings.plugins.manifestUnreadable")}),$jsx("text",{fg:!plugin.platformOk||plugin.lastRun?.running?theme.warning:plugin.lastRun?.ok===!1?theme.error:theme.textMuted,wrapMode:"none",children:!plugin.platformOk?t3("settings.plugins.unsupportedPlatform"):plugin.lastRun?t3("settings.plugins.lastRun",{label:plugin.lastRun.label,status:plugin.lastRun.running?t3("settings.plugins.runRunning"):plugin.lastRun.ok?t3("settings.plugins.runOk"):plugin.lastRun.spawnError?t3("settings.plugins.runFailed"):t3("settings.plugins.runExit",{code:String(plugin.lastRun.exitCode)}),ago:relativeAge(plugin.lastRun.at,now)}):plugin.hooksDeclared?t3("settings.plugins.neverRun"):t3("settings.plugins.noHooks")})]}),plugin.settings.map((setting,s2)=>$jsx(SettingRow,{setting,cursor:isBodyCursor(toggleRow+1+s2),rowRef:props.rowRef(toggleRow+1+s2),onActivate:()=>{props.setLevel("body"),props.setBodyRow(toggleRow+1+s2),props.editSetting(plugin.id,setting.key)}},setting.key))]},plugin.id)})})]})}var import_react54=__toESM(require_react_production(),1);var import_react53=__toESM(require_react_production(),1);var NO_ENGINE_PROTOCOL="",CHOICES=[...ENGINE_PROTOCOLS,NO_ENGINE_PROTOCOL];function EngineProtocolPickerDialogView(props){let dialog=useDialog(),t3=useT(),padX=useDialogPaddingX(),[cursor,setCursor]=import_react53.useState(0),window2={items:[...CHOICES],start:0,total:CHOICES.length};function commit(protocol){if(protocol===void 0)return;props.onSubmit(protocol),dialog.clear()}let rows=CHOICES.map((protocol,i2)=>({key:`${i2}:${protocol||"none"}`,body:protocol?engineEntry(protocol).displayName:t3("settings.engines.protocolNone"),dim:protocol||void 0}));return useBindings(()=>({bindings:[{key:"up",cmd:()=>setCursor((c2)=>clampCursor(c2-1,CHOICES.length))},{key:"down",cmd:()=>setCursor((c2)=>clampCursor(c2+1,CHOICES.length))},{key:"return",cmd:()=>commit(CHOICES[cursor])}]})),$jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:1,children:[$jsx(DialogHeader,{title:t3("settings.engines.protocolTitle",{id:props.engineId}),onClose:()=>props.onCancel()}),$jsx(PickerList,{window:window2,cursor,rows,onPick:(absoluteIndex)=>commit(CHOICES[absoluteIndex]),paddingBottom:1}),$jsx(DialogFooter,{children:t3("settings.engines.protocolFooter")})]})}function show3(dialog,opts){return showDialog(dialog,(resolve)=>$jsx(EngineProtocolPickerDialogView,{engineId:opts.engineId,onSubmit:(v3)=>resolve(v3),onCancel:()=>resolve(void 0)}))}var EngineProtocolPickerDialog={show:show3};function useEngineSettings(kv,dialog,onEngineListShrunk){let[detected,setDetected]=import_react54.useState([]);import_react54.useEffect(()=>{installedEngineIds().then(setDetected)},[]);function customEngines(){let raw=kv.get("customEngineIds",[]);return Array.isArray(raw)?raw.filter((s2)=>typeof s2==="string"&&s2.trim().length>0):[]}function engineList(){return[...new Set([...ALL_VENDORS,...customEngines(),...detected])]}function isCustomEngine(vendor){return customEngines().includes(vendor)}function disabledEngines(){let raw=kv.get("disabledEngineIds",[]);return Array.isArray(raw)?raw.filter((s2)=>typeof s2==="string"&&s2.trim().length>0):[]}function isEngineEnabled(vendor){return!disabledEngines().includes(vendor)}function toggleEngineEnabled(vendor){let off=disabledEngines();if(off.includes(vendor)){kv.set("disabledEngineIds",off.filter((id)=>id!==vendor));return}let nextDefault=engineList().find((id)=>id!==vendor&&!off.includes(id));if(defaultEngine===vendor){if(!nextDefault)return;setEngineDefault(nextDefault)}kv.set("disabledEngineIds",[...off,vendor])}function engineOverride(vendor){let v3=kv.get(engineCommandKey(vendor),"");return typeof v3==="string"?v3.trim():""}function engineCommandText(vendor){return engineOverride(vendor)||defaultEngineCommand(vendor).join(" ")}function engineIsDefault(vendor){return!isCustomEngine(vendor)&&engineOverride(vendor).length===0&&!engineNameIsCustom(vendor)}function engineNameOverride(vendor){let v3=kv.get(engineNameKey(vendor),"");return typeof v3==="string"?v3.trim():""}function engineNameIsCustom(vendor){return engineNameOverride(vendor).length>0}function engineProtocol(vendor){let raw=kv.get(engineProtocolKey(vendor),""),declared=typeof raw==="string"?raw.trim():"";return declared&&ENGINE_PROTOCOLS.includes(declared)?declared:void 0}function engineName(vendor){return engineNameOverride(vendor)||engineEntry(vendor).displayName}let[defaultEngine,setDefaultEngineState]=import_react54.useState(()=>getGlobalDefaultVendor()??DEFAULT_TASK_VENDOR);function setEngineDefault(vendor){setGlobalDefaultVendor(vendor),kv.set("defaultVendor",vendor),setDefaultEngineState(vendor)}function chooseDefaultEngine(vendor){let off=disabledEngines();if(off.includes(vendor))kv.set("disabledEngineIds",off.filter((id)=>id!==vendor));setEngineDefault(vendor)}async function editEngine(vendor){let next=await RenameTaskDialog.show(dialog,engineCommandText(vendor),{dialogTitle:t("settings.engines.launchCommandTitle",{name:engineName(vendor)}),fieldLabel:t("settings.field.command"),submitLabel:t("settings.action.save"),allowEmpty:!0});if(next===void 0)return;kv.set(engineCommandKey(vendor),next.trim())}async function renameEngine(vendor){let next=await RenameTaskDialog.show(dialog,engineName(vendor),{dialogTitle:t("settings.engines.displayNameTitle",{name:engineName(vendor)}),fieldLabel:t("settings.field.name"),submitLabel:t("settings.action.save"),allowEmpty:!0});if(next===void 0)return;kv.set(engineNameKey(vendor),next.trim())}function resetEngine(vendor){if(kv.set(engineCommandKey(vendor),""),kv.set(engineNameKey(vendor),""),isCustomEngine(vendor))kv.set(engineProtocolKey(vendor),""),kv.set("customEngineIds",customEngines().filter((id)=>id!==vendor)),onEngineListShrunk(engineList().length)}async function addEngineFlow(){let idRaw=await RenameTaskDialog.show(dialog,"",{dialogTitle:t("settings.engines.addTitle"),fieldLabel:t("settings.field.id"),submitLabel:t("settings.action.next"),placeholder:t("settings.engines.idPlaceholder")});if(idRaw===void 0)return;let id=idRaw.trim().toLowerCase();if(!id||isBuiltinVendor(id)||customEngines().includes(id))return;let command=await RenameTaskDialog.show(dialog,"",{dialogTitle:t("settings.engines.addStepTitle",{id}),fieldLabel:t("settings.field.command"),submitLabel:t("settings.action.next"),placeholder:t("settings.engines.commandPlaceholder")});if(command===void 0)return;let protocol=await EngineProtocolPickerDialog.show(dialog,{engineId:id});if(protocol===void 0)return;let name=await RenameTaskDialog.show(dialog,id,{dialogTitle:t("settings.engines.addStepTitle",{id}),fieldLabel:t("settings.field.name"),submitLabel:t("settings.action.add"),allowEmpty:!0});if(kv.set("customEngineIds",[...customEngines(),id]),command.trim())kv.set(engineCommandKey(id),command.trim());if(protocol&&ENGINE_PROTOCOLS.includes(protocol))kv.set(engineProtocolKey(id),protocol);let typedName=name?.trim()??"";kv.set(engineNameKey(id),typedName&&typedName!==id?typedName:humanizeSlug(id))}return{engineList,isCustomEngine,isEngineEnabled,toggleEngineEnabled,engineName,engineProtocol,engineCommandText,engineIsDefault,defaultEngine,setEngineDefault,chooseDefaultEngine,editEngine,renameEngine,resetEngine,addEngineFlow}}var import_react55=__toESM(require_react_production(),1);import{closeSync,openSync,readFileSync as readFileSync2,readSync,statSync as statSync2}from"fs";import{mkdirSync as mkdirSync3,readFileSync,writeFileSync as writeFileSync3}from"fs";import{join as join3}from"path";function envPath(pluginId,homeDir){return join3(pluginConfigDir(pluginId,homeDir),".env")}function readPluginSettings(pluginId,homeDir){let text;try{text=readFileSync(envPath(pluginId,homeDir),"utf8")}catch{return{}}let out={};for(let line of text.split(`
101
+ `),process.exit(0)}async function confirmRestartDaemon(dialog,orchestrator,renderer){if(!hasRestartableDaemon(orchestrator))return;if(await DialogConfirm.show(dialog,t("settings.restart.title"),t("settings.restart.body"),"cancel")!==!0)return;await orchestrator.restartDaemon(),relaunchSelf({renderer,notice:t("settings.restart.done")})}import{TextAttributes as TextAttributes18}from"@opentui/core";function EngineSettingsSection(props){let{theme}=useTheme(),t3=useT(),addRowIndex=props.vendors.length,isBodyCursor=(row)=>props.level==="body"&&props.bodyRow===row,byVendor=new Map((props.statuses??[]).map((s2)=>[s2.vendor,s2])),nameWidth=Math.min(16,props.vendors.reduce((max,v3)=>Math.max(max,displayWidth(props.displayName(v3))),0)),padName=(name)=>name+" ".repeat(Math.max(0,nameWidth-displayWidth(name))),protocolChip=(vendor)=>{if(!props.isCustom(vendor))return;let declared=props.engineProtocol(vendor);return{label:t3("settings.engines.protocolRow",{protocol:declared??t3("settings.engines.protocolGeneric")}),declared:declared!==void 0}};return $jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes18.BOLD,children:t3("settings.engines.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.engines.hint")}),$jsxs("box",{flexDirection:"column",gap:0,children:[props.vendors.map((vendor,i2)=>{let isCursor=isBodyCursor(i2),enabled=props.isEnabled(vendor),nameFg=isCursor?theme.selectedListItemText:enabled?theme.text:theme.textMuted,commandFg=isCursor?theme.selectedListItemText:!enabled||props.isDefault(vendor)?theme.textMuted:theme.accent;return $jsxs("box",{flexDirection:"column",gap:0,ref:props.rowRef(i2),children:[$jsxs("box",{flexDirection:"row",gap:1,paddingLeft:1,paddingRight:1,overflow:"hidden",backgroundColor:isCursor?theme.primary:void 0,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(i2),props.editEngine(vendor)},children:[$jsx("text",{fg:isCursor?theme.selectedListItemText:enabled?theme.text:theme.textMuted,wrapMode:"none",onMouseUp:(evt)=>{evt.stopPropagation(),props.setLevel("body"),props.setBodyRow(i2),props.toggleEngine(vendor)},children:enabled?"[x]":"[ ]"}),$jsx("text",{fg:isCursor?theme.selectedListItemText:props.isDefaultEngine(vendor)?theme.accent:theme.textMuted,attributes:TextAttributes18.BOLD,wrapMode:"none",onMouseUp:(evt)=>{evt.stopPropagation(),props.setLevel("body"),props.setBodyRow(i2),props.chooseDefault(vendor)},children:props.isDefaultEngine(vendor)?"(\u25CF)":"( )"}),$jsx("text",{fg:nameFg,attributes:TextAttributes18.BOLD,wrapMode:"none",children:padName(props.displayName(vendor))}),$jsx("text",{fg:commandFg,wrapMode:"none",flexShrink:1,children:props.commandText(vendor)+(props.isCustom(vendor)?t3("settings.engines.customTag"):"")})]}),$jsx(EngineStatusLine,{status:byVendor.get(vendor)??null,probing:props.statuses===null,protocol:protocolChip(vendor)})]},vendor)}),$jsx("box",{ref:props.rowRef(addRowIndex),flexDirection:"row",paddingLeft:1,paddingRight:1,backgroundColor:isBodyCursor(addRowIndex)?theme.primary:void 0,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(addRowIndex),props.onAddEngine()},children:$jsx("text",{fg:isBodyCursor(addRowIndex)?theme.selectedListItemText:theme.primary,wrapMode:"none",children:t3("settings.engines.addEngine")})})]})]})}function EngineStatusLine(props){let{theme}=useTheme(),t3=useT(),s2=props.status,protocol=props.protocol?$jsx("text",{fg:props.protocol.declared?theme.accent:theme.textMuted,wrapMode:"none",children:props.protocol.label}):null;if(!s2)return $jsxs("box",{flexDirection:"row",gap:1,paddingLeft:6,overflow:"hidden",children:[protocol,$jsx("text",{fg:theme.textMuted,children:props.probing?t3("settings.accounts.checking"):" "})]});return $jsxs("box",{flexDirection:"row",gap:1,paddingLeft:6,overflow:"hidden",children:[protocol,s2.account===null?null:$jsx(AccountLine,{account:s2.account}),s2.accountError?$jsx("text",{fg:theme.warning,wrapMode:"none",children:`! ${s2.accountError}`}):null,$jsx("text",{fg:s2.binary.found?theme.textMuted:theme.warning,wrapMode:"none",flexShrink:1,children:(s2.account===null?"":"\xB7 ")+(s2.binary.found?tildify(s2.binary.path):s2.binary.error)})]})}function AccountLine({account}){let{theme}=useTheme(),t3=useT();if(account.kind==="oauth"){if(!("email"in account))return $jsx("text",{fg:theme.success,wrapMode:"none",children:t3("settings.accounts.detected")});let tail=account.billingType;return $jsx("text",{fg:theme.success,wrapMode:"none",flexShrink:1,children:t3("settings.accounts.loggedIn",{email:account.email})+(tail?` (${tail})`:"")})}if(account.kind==="chatgpt")return $jsx("text",{fg:theme.success,wrapMode:"none",flexShrink:1,children:t3("settings.accounts.chatgptLogin",{email:account.email})+(account.plan?` (${account.plan})`:"")});if(account.kind==="apikey")return $jsx("text",{fg:theme.success,children:t3("settings.accounts.apiKeyConfigured")});if(account.kind==="token")return $jsx("text",{fg:theme.success,children:t3("settings.accounts.tokenConfigured",{source:account.source})});return $jsx("text",{fg:theme.textMuted,children:t3("settings.accounts.notLoggedIn")})}import{TextAttributes as TextAttributes20}from"@opentui/core";var import_react51=__toESM(require_react_production(),1);import{TextAttributes as TextAttributes19}from"@opentui/core";function Row(props){let{theme}=useTheme();return $jsxs("box",{ref:props.rowRef,flexDirection:"row",gap:1,paddingLeft:1,paddingRight:1,overflow:"hidden",backgroundColor:props.cursor?theme.primary:props.idleBackground,onMouseUp:props.onMouseUp,children:[$jsx("text",{fg:props.cursor?theme.selectedListItemText:props.fg,attributes:props.bold?TextAttributes19.BOLD:void 0,wrapMode:"none",children:props.children}),props.hint?$jsx("text",{fg:props.cursor?theme.selectedListItemText:theme.textMuted,wrapMode:"none",flexShrink:1,children:props.hint}):null]})}function SubSection(props){let{theme}=useTheme();return $jsxs("box",{flexDirection:"column",gap:0,paddingTop:props.paddingTop??1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes19.BOLD,children:props.title}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:props.hint}),props.children]})}function SettingsSectionSidebar(props){let{theme}=useTheme(),t3=useT();return $jsx("box",{flexDirection:"column",flexShrink:0,width:SECTIONS_SIDEBAR_WIDTH,gap:1,children:SECTIONS.map((s2,i2)=>{let isSection=i2===props.cursor,isSidebarFocused=isSection&&props.level==="sidebar";return $jsx("box",{paddingLeft:1,paddingRight:1,backgroundColor:isSidebarFocused?theme.primary:void 0,onMouseUp:()=>props.switchSection(s2.id),children:$jsx("text",{fg:isSidebarFocused?theme.selectedListItemText:isSection?theme.accent:theme.textMuted,attributes:isSection?TextAttributes20.BOLD:void 0,wrapMode:"none",children:t3(`settings.sections.${s2.id}`)})},s2.id)})})}function UsageDashboard(props){let{theme}=useTheme(),t3=useT(),toneColor2={ok:theme.success,warn:theme.warning,crit:theme.error},now=Date.now();return $jsx("box",{flexDirection:"column",flexShrink:0,alignSelf:"flex-start",gap:0,children:[...props.usage.entries()].map(([vendor,usage])=>$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes20.BOLD,wrapMode:"none",children:`${engineDisplayName(vendor).toUpperCase()} ${t3("settings.general.usage")}`}),usageRows(usage,now).map((row)=>$jsxs("box",{flexDirection:"row",gap:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:row.label}),$jsx("text",{fg:toneColor2[row.tone],wrapMode:"none",children:`${row.bar} ${row.percentText}`}),row.resetText?$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:row.resetText}):null]},row.label))]},vendor))})}function GeneralSettingsSection(props){let{prefs}=props,themeCtx=useTheme(),{theme}=themeCtx,t3=useT(),kv=useKV(),rows=import_react51.useMemo(()=>generalRows({themeNames:props.themeNames,focusAccentSlots:FOCUS_ACCENT_SLOTS}),[props.themeNames]),rowIdx=(id)=>rowIndex(rows,id),isBodyCursor=(row)=>props.level==="body"&&props.bodyRow===row,activate=(row,action)=>()=>{props.setLevel("body"),props.setBodyRow(row),action()},onOff=(on)=>on?t3("settings.general.on"):t3("settings.general.off"),{labelColumn,showHint}=generalLabelLayout(useTerminalDimensions().width,useDialogPaddingX()),hint=(key)=>showHint?t3(key):void 0,pad=(label)=>label+" ".repeat(Math.max(0,labelColumn-displayWidth(label))),check=(on)=>on?"[x]":"[ ]",radio=(on)=>on?"(\u25CF)":"( )",transparentRow=rowIdx("transparent"),toastRow=rowIdx("toast"),soundRow=rowIdx("sound"),soundVolumeRow=rowIdx("sound-volume"),crossTaskRow=rowIdx("cross-task"),keyHintsRow=rowIdx("key-hints"),zenDefaultOnRow=rowIdx("zen-default-on"),editorKindRow=rowIdx("editor-kind"),editorCustomRow=rowIdx("editor-custom"),worktreeBaseRow=rowIdx("worktree-base"),worktreeCustomRow=rowIdx("worktree-custom"),scrollbackRow=rowIdx("scrollback-rows"),tabStripHideSingleRow=rowIdx("tab-strip-hide-single");return $jsxs("box",{flexDirection:"row",gap:2,children:[$jsxs("box",{flexDirection:"column",gap:1,flexGrow:1,flexShrink:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes20.BOLD,children:t3("settings.general.theme")}),$jsx("text",{fg:theme.textMuted,children:t3("settings.general.themeHint")}),$jsx("box",{flexDirection:"column",gap:0,children:props.themeNames.map((name,i2)=>{let isSelected=name===themeCtx.selected;return $jsx(Row,{cursor:isBodyCursor(i2),rowRef:props.rowRef(i2),onMouseUp:activate(i2,()=>props.selectTheme(name)),fg:isSelected?theme.accent:theme.text,bold:isBodyCursor(i2)||isSelected,children:`${radio(isSelected)} ${name}`},name)})}),$jsx(SubSection,{title:t3("settings.general.language"),hint:t3("settings.general.languageHint"),children:LOCALES.map((loc)=>{let langRow=rowIdx(languageRowId(loc.id)),isSelected=props.currentLocale===loc.id;return $jsx(Row,{cursor:isBodyCursor(langRow),rowRef:props.rowRef(langRow),onMouseUp:activate(langRow,()=>props.selectLanguage(loc.id)),fg:isSelected?theme.accent:theme.text,bold:isBodyCursor(langRow)||isSelected,children:`${radio(isSelected)} ${loc.label}`},loc.id)})}),$jsx(SubSection,{title:t3("settings.general.transparent"),hint:t3("settings.general.transparentHint"),children:$jsx(Row,{cursor:isBodyCursor(transparentRow),rowRef:props.rowRef(transparentRow),onMouseUp:activate(transparentRow,props.toggleTransparent),fg:themeCtx.transparentBackground?theme.accent:theme.textMuted,bold:!0,children:onOff(themeCtx.transparentBackground)})}),$jsx(SubSection,{title:t3("settings.general.focusAccent"),hint:t3("settings.general.focusAccentHint"),children:FOCUS_ACCENT_SLOTS.map((slot)=>{let accentRow=rowIdx(focusAccentRowId(slot)),isSelected=themeCtx.focusAccent===slot;return $jsx(Row,{cursor:isBodyCursor(accentRow),rowRef:props.rowRef(accentRow),onMouseUp:activate(accentRow,()=>props.selectFocusAccent(slot)),fg:isSelected?theme.focusAccent:theme.text,bold:isBodyCursor(accentRow)||isSelected,children:`${radio(isSelected)} ${t3(`settings.general.accent${slot.charAt(0).toUpperCase()}${slot.slice(1)}`)}`},slot)})}),$jsx(SubSection,{title:t3("settings.general.appearance"),hint:t3("settings.general.appearanceHint"),children:SPLIT_STYLES.map((style)=>{let styleRow=rowIdx(splitStyleRowId(style)),isSelected=prefs.splitStyle()===style;return $jsx(Row,{cursor:isBodyCursor(styleRow),rowRef:props.rowRef(styleRow),onMouseUp:activate(styleRow,()=>prefs.selectSplitStyle(style)),fg:isSelected?theme.accent:theme.text,bold:isBodyCursor(styleRow)||isSelected,children:`${radio(isSelected)} ${t3(style==="box"?"settings.general.splitBox":"settings.general.splitLine")}`},style)})}),$jsxs(SubSection,{title:t3("settings.general.notifications"),hint:t3("settings.general.notificationsHint"),children:[$jsx(Row,{cursor:isBodyCursor(toastRow),rowRef:props.rowRef(toastRow),onMouseUp:activate(toastRow,prefs.toggleToast),fg:prefs.toastEnabled()?theme.accent:theme.textMuted,bold:!0,hint:hint("settings.general.toastHint"),children:pad(`${check(prefs.toastEnabled())} ${t3("settings.general.toast")}`)}),$jsx(Row,{cursor:isBodyCursor(soundRow),rowRef:props.rowRef(soundRow),onMouseUp:activate(soundRow,prefs.toggleSound),fg:prefs.soundEnabled()?theme.accent:theme.textMuted,bold:!0,hint:hint("settings.general.soundHint"),children:pad(`${check(prefs.soundEnabled())} ${t3("settings.general.sound")}`)}),$jsx(Row,{cursor:isBodyCursor(soundVolumeRow),rowRef:props.rowRef(soundVolumeRow),onMouseUp:activate(soundVolumeRow,prefs.cycleSoundVolume),fg:prefs.soundEnabled()?theme.accent:theme.textMuted,bold:!0,hint:hint("settings.general.soundVolumeHint"),children:pad(t3("settings.general.soundVolume",{percent:String(Math.round(prefs.soundVolume()*100))}))}),$jsx(Row,{cursor:isBodyCursor(crossTaskRow),rowRef:props.rowRef(crossTaskRow),onMouseUp:activate(crossTaskRow,prefs.toggleCrossTask),fg:prefs.crossTaskEnabled()?theme.accent:theme.textMuted,bold:!0,hint:hint("settings.general.crossTaskHint"),children:pad(`${check(prefs.crossTaskEnabled())} ${t3("settings.general.crossTask")}`)})]}),$jsx(SubSection,{title:t3("settings.general.keyHints"),hint:t3("settings.general.keyHintsHint"),children:$jsx(Row,{cursor:isBodyCursor(keyHintsRow),rowRef:props.rowRef(keyHintsRow),onMouseUp:activate(keyHintsRow,()=>toggleKeyHints(kv)),fg:keyHintsToggleOn(kv)?theme.accent:theme.textMuted,bold:!0,hint:hint("settings.general.keyHintsShowHint"),children:pad(`${check(keyHintsToggleOn(kv))} ${t3("settings.general.keyHintsShow")}`)})}),$jsx(SubSection,{title:t3("settings.general.zen"),hint:t3("settings.general.zenHint"),children:$jsx(Row,{cursor:isBodyCursor(zenDefaultOnRow),rowRef:props.rowRef(zenDefaultOnRow),onMouseUp:activate(zenDefaultOnRow,prefs.toggleZenDefaultOn),fg:prefs.zenDefaultOn()?theme.accent:theme.textMuted,bold:!0,children:`${check(prefs.zenDefaultOn())} ${t3("settings.general.zenDefaultOn")}`})}),$jsxs(SubSection,{title:t3("settings.general.editor"),hint:t3("settings.general.editorHint"),children:[$jsx(Row,{cursor:isBodyCursor(editorKindRow),rowRef:props.rowRef(editorKindRow),onMouseUp:activate(editorKindRow,prefs.cycleEditorKind),fg:theme.accent,bold:!0,hint:hint("settings.general.editorRowHint"),children:pad(t3("settings.general.editorRow",{kind:prefs.editorKind()}))}),$jsx(Row,{cursor:isBodyCursor(editorCustomRow),rowRef:props.rowRef(editorCustomRow),onMouseUp:activate(editorCustomRow,()=>void prefs.editEditorCustom()),fg:prefs.editorKind()==="custom"?theme.text:theme.textMuted,children:t3("settings.general.editorCustom",{cmd:prefs.editorCustomCommand().trim()||t3("settings.general.editorCustomUnset")})})]}),$jsxs(SubSection,{title:t3("settings.general.worktree"),hint:t3("settings.general.worktreeHint"),children:[$jsx(Row,{cursor:isBodyCursor(worktreeBaseRow),rowRef:props.rowRef(worktreeBaseRow),onMouseUp:activate(worktreeBaseRow,prefs.cycleWorktreeBase),fg:theme.accent,bold:!0,hint:hint("settings.general.worktreeBaseHint"),children:pad(t3("settings.general.worktreeBase",{kind:prefs.worktreeKindLabel()}))}),$jsx(Row,{cursor:isBodyCursor(worktreeCustomRow),rowRef:props.rowRef(worktreeCustomRow),onMouseUp:activate(worktreeCustomRow,()=>void prefs.editWorktreeCustom()),fg:prefs.worktreeKind()==="custom"?theme.text:theme.textMuted,children:t3("settings.general.worktreeCustom",{path:prefs.worktreeCustomPath()||t3("settings.general.worktreeCustomUnset")})})]}),$jsxs(SubSection,{title:t3("settings.general.terminal"),hint:t3("settings.general.terminalHint"),children:[$jsx(Row,{cursor:isBodyCursor(scrollbackRow),rowRef:props.rowRef(scrollbackRow),onMouseUp:activate(scrollbackRow,()=>void prefs.editScrollbackRows()),fg:theme.accent,bold:!0,hint:hint("settings.general.scrollbackRowHint"),children:pad(t3("settings.general.scrollbackRow",{rows:String(prefs.scrollbackRows())}))}),$jsx(Row,{cursor:isBodyCursor(tabStripHideSingleRow),rowRef:props.rowRef(tabStripHideSingleRow),onMouseUp:activate(tabStripHideSingleRow,prefs.cycleTabStripMode),fg:theme.accent,bold:!0,children:t3("settings.general.tabStripRow",{mode:t3(`settings.general.tabStripMode.${prefs.tabStripMode()}`)})})]})]}),props.usage&&props.usage.size>0?$jsx(UsageDashboard,{usage:props.usage}):null]})}var import_react52=__toESM(require_react_production(),1);import{TextAttributes as TextAttributes21}from"@opentui/core";function FeedbackSettingsSection(props){let{theme}=useTheme(),t3=useT(),editing=props.level==="body",titleFocused=editing&&props.bodyRow===0,bodyFocused=editing&&props.bodyRow===1,sendFocused=editing&&props.bodyRow===2,labelFg=(focused)=>focused?theme.primary:theme.textMuted,labelAttrs=(focused)=>focused?TextAttributes21.BOLD|TextAttributes21.UNDERLINE:void 0,bodyEl=import_react52.useRef(null);return import_react52.useEffect(()=>{if(props.body===""&&bodyEl.current&&bodyEl.current.plainText!=="")bodyEl.current.setText("")},[props.body]),$jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.feedback.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.feedback.hint")}),$jsxs("box",{flexDirection:"column",gap:1,children:[$jsxs("box",{gap:0,children:[$jsx("text",{fg:labelFg(titleFocused),attributes:labelAttrs(titleFocused),children:t3("settings.feedback.titleLabel")}),$jsx("input",{value:props.title,placeholder:t3("settings.feedback.titlePlaceholder"),focused:titleFocused,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(0)},onInput:(v3)=>props.setTitle(stripNewlines(v3)),onSubmit:()=>props.onTitleSubmit()})]}),$jsxs("box",{gap:0,children:[$jsx("text",{fg:labelFg(bodyFocused),attributes:labelAttrs(bodyFocused),children:t3("settings.feedback.descriptionLabel")}),$jsx("textarea",{ref:(el)=>{bodyEl.current=el},initialValue:props.body,placeholder:t3("settings.feedback.descriptionPlaceholder"),focused:bodyFocused,height:4,wrapMode:"word",onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(1)},onContentChange:()=>props.setBody(bodyEl.current?.plainText??"")})]}),$jsx("box",{flexDirection:"row",paddingLeft:1,paddingRight:1,backgroundColor:sendFocused?theme.primary:theme.backgroundElement,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(2),props.submit()},children:$jsx("text",{fg:sendFocused?theme.selectedListItemText:theme.accent,attributes:TextAttributes21.BOLD,children:t3("settings.feedback.send")})})]}),props.status?$jsx("text",{fg:props.status.startsWith("error:")?theme.warning:theme.success,wrapMode:"word",children:props.status}):null]})}function DevSettingsSection(props){let{prefs}=props,{theme}=useTheme(),t3=useT(),rows=devRows(props.hasDaemon),isBodyCursor=(row)=>props.level==="body"&&props.bodyRow===row,activate=(row,action)=>()=>{props.setLevel("body"),props.setBodyRow(row),action()},toggleRow=(id,enabled,hintKey,labelKey,act)=>{let row=rowIndex(rows,id);return $jsxs("box",{flexDirection:"column",gap:0,paddingTop:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3(hintKey)}),$jsx(Row,{cursor:isBodyCursor(row),rowRef:props.rowRef(row),onMouseUp:activate(row,act),fg:theme.text,bold:enabled,idleBackground:theme.backgroundElement,children:`${enabled?"[x]":"[ ]"} ${t3(labelKey)}`})]})};return $jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.dev.reset")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.dev.resetHint")}),$jsx(Row,{cursor:isBodyCursor(0),rowRef:props.rowRef(0),onMouseUp:activate(0,props.confirmReset),fg:theme.warning,bold:!0,idleBackground:theme.backgroundElement,children:t3("settings.dev.resetButton")}),props.hasDaemon?$jsx(SubSection,{title:t3("settings.dev.restart"),hint:t3("settings.dev.restartHint"),children:$jsx(Row,{cursor:isBodyCursor(1),rowRef:props.rowRef(1),onMouseUp:activate(1,props.confirmRestartDaemon),fg:theme.accent,bold:!0,idleBackground:theme.backgroundElement,children:t3("settings.dev.restartButton")})}):null,$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.dev.doctorHint")}),$jsxs("box",{flexDirection:"column",gap:0,paddingTop:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.dev.experimental")}),toggleRow("remote-projects",prefs.remoteProjectsEnabled(),"settings.dev.remoteHint","settings.dev.remote",prefs.toggleRemoteProjects),toggleRow("auto-status",prefs.autoStatusOn(),"settings.dev.autoStatusHint","settings.dev.autoStatus",prefs.toggleAutoStatus),toggleRow("dispatcher",prefs.dispatcherOn(),"settings.dev.dispatcherHint","settings.dev.dispatcher",prefs.toggleDispatcher)]})]})}function KeybindingsSettingsSection(props){let{theme}=useTheme(),t3=useT();useKeymapVersion();let report=userKeybindingsReport(),rows=keybindingRows(report.exists),prefix=currentPrefixConfiguration(),fixedIds=Object.keys(FIXED_BINDING_IDS).sort(),appliedIdWidth=Math.min(28,report.applied.reduce((max,o2)=>Math.max(max,o2.id.length),0));return $jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.hint")}),$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.configFile")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:tildify(report.path)+(report.exists?"":t3("settings.keybindings.notCreated"))})]}),$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.tapPresentation")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.tapPresentationHint")}),PREFIX_TAP_PRESENTATIONS.map((presentation)=>{let row=rowIndex(rows,prefixTapPresentationRowId(presentation)),selected=props.prefs.prefixTapPresentation()===presentation;return $jsx(Row,{cursor:props.level==="body"&&props.bodyRow===row,rowRef:props.rowRef(row),onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(row),props.prefs.selectPrefixTapPresentation(presentation)},fg:selected?theme.accent:theme.text,bold:selected||props.level==="body"&&props.bodyRow===row,children:`${selected?"(\u25CF)":"( )"} ${t3(presentation==="local"?"settings.keybindings.tapPresentationLocal":"settings.keybindings.tapPresentationGuide")}`},presentation)})]}),$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.prefixTitle",{prefix:prefix.key??t3("settings.keybindings.prefixDisabled")})}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.prefixHint",{prefix:prefix.key??t3("settings.keybindings.prefixDisabled"),timeout:prefix.timeoutMs})})]}),!report.exists?$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.createHint")}),$jsx(Row,{cursor:props.level==="body"&&props.bodyRow===rowIndex(rows,"keys-create"),rowRef:props.rowRef(rowIndex(rows,"keys-create")),onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(rowIndex(rows,"keys-create")),props.onCreateFile()},fg:theme.text,idleBackground:theme.backgroundElement,children:t3("settings.keybindings.createFile")})]}):$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.overridesApplied")}),report.applied.length===0?$jsx("text",{fg:theme.textMuted,children:t3("settings.keybindings.none")}):null,report.applied.map((o2)=>$jsx("text",{fg:theme.text,wrapMode:"none",children:`${o2.id.padEnd(appliedIdWidth)} ${o2.keys.length>0?o2.keys.join(" / "):t3("settings.keybindings.unbound")} (${t3("settings.keybindings.defaultKeys",{keys:o2.defaultKeys.join(" / ")})})`},o2.id))]}),report.warnings.length>0?$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{fg:theme.warning,attributes:TextAttributes21.BOLD,children:t3("settings.keybindings.warnings")}),report.warnings.map((w4)=>$jsx("text",{fg:theme.warning,wrapMode:"word",children:`! ${w4}`},w4))]}):null,fixedIds.length>0?$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3("settings.keybindings.fixed",{ids:fixedIds.join(", ")})}):null]})}import{TextAttributes as TextAttributes22}from"@opentui/core";function pluginSettingRows(schema,values){return schema.map((setting)=>{let stored=values[setting.key],defaultValue=setting.default??"";return{key:setting.key,label:setting.label,type:setting.type,options:setting.options??[],defaultValue,value:stored??defaultValue,defaulted:stored===void 0}})}function displaySettingValue(row){if(row.type!=="secret"||row.value==="")return row.value;return"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}function isBooleanOn(value){return value!==""&&value!=="0"&&value.toLowerCase()!=="false"}function nextEnumValue(options,current){if(options.length===0)return current;let i2=options.indexOf(current);return options[(i2+1)%options.length]}function toggledBooleanValue(row){if(!isBooleanOn(row.value))return"1";return isBooleanOn(row.defaultValue)?"0":""}function normalizeNumberInput(raw){let trimmed=raw.trim();if(trimmed==="")return"";let n2=Number(trimmed);return Number.isFinite(n2)?String(n2):null}function toggleRowOffsets(plugins){let offsets=[],next=0;for(let plugin of plugins)offsets.push(next),next+=1+plugin.settings.length;return offsets}function SettingRow(props){let{theme}=useTheme(),t3=useT(),{setting}=props,value=setting.type==="boolean"?isBooleanOn(setting.value)?t3("settings.general.on"):t3("settings.general.off"):displaySettingValue(setting)||t3("settings.plugins.settingUnset");return $jsxs("box",{ref:props.rowRef,flexDirection:"row",gap:1,paddingLeft:5,paddingRight:1,backgroundColor:props.cursor?theme.primary:void 0,onMouseUp:props.onActivate,children:[$jsx("text",{fg:props.cursor?theme.selectedListItemText:theme.text,wrapMode:"none",children:setting.label}),$jsx("text",{fg:props.cursor?theme.selectedListItemText:setting.defaulted?theme.textMuted:theme.accent,wrapMode:"none",children:value})]})}function PluginSettingsSection(props){let{theme}=useTheme(),t3=useT(),now=Date.now(),isBodyCursor=(row)=>props.level==="body"&&props.bodyRow===row,offsets=toggleRowOffsets(props.plugins);return $jsxs("box",{flexDirection:"column",gap:1,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes22.BOLD,children:t3("settings.plugins.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t3(props.plugins.length===0?"settings.plugins.empty":"settings.plugins.hint")}),props.plugins.length===0?null:$jsx("box",{flexDirection:"column",gap:0,children:props.plugins.map((plugin,i2)=>{let toggleRow=offsets[i2]??0,isCursor=isBodyCursor(toggleRow);return $jsxs("box",{flexDirection:"column",gap:0,children:[$jsxs("box",{ref:props.rowRef(toggleRow),flexDirection:"row",gap:1,paddingLeft:1,paddingRight:1,backgroundColor:isCursor?theme.primary:void 0,onMouseUp:()=>{props.setLevel("body"),props.setBodyRow(toggleRow),props.toggle(plugin.id)},children:[$jsx("text",{fg:isCursor?theme.selectedListItemText:plugin.enabled?theme.accent:theme.textMuted,attributes:TextAttributes22.BOLD,wrapMode:"none",children:`${plugin.enabled?"[x]":"[ ]"} ${plugin.id}`}),$jsx("text",{fg:isCursor?theme.selectedListItemText:theme.textMuted,wrapMode:"none",children:`v${plugin.version} ${plugin.linked?t3("settings.plugins.sourceLink",{path:plugin.source}):t3("settings.plugins.sourceGithub",{spec:plugin.source})}`}),plugin.updateAvailable?$jsx("text",{fg:theme.warning,wrapMode:"none",children:t3("settings.plugins.updateAvailable")}):null]}),$jsxs("box",{flexDirection:"row",gap:1,paddingLeft:5,paddingRight:1,children:[$jsx("text",{fg:plugin.declares?theme.textMuted:theme.warning,wrapMode:"none",children:plugin.declares?plugin.declares.engines>0?t3("settings.plugins.declaresWithEngines",{actions:String(plugin.declares.actions),events:String(plugin.declares.events),panes:String(plugin.declares.panes),engines:String(plugin.declares.engines)}):t3("settings.plugins.declares",{actions:String(plugin.declares.actions),events:String(plugin.declares.events),panes:String(plugin.declares.panes)}):t3("settings.plugins.manifestUnreadable")}),$jsx("text",{fg:!plugin.platformOk||plugin.lastRun?.running?theme.warning:plugin.lastRun?.ok===!1?theme.error:theme.textMuted,wrapMode:"none",children:!plugin.platformOk?t3("settings.plugins.unsupportedPlatform"):plugin.lastRun?t3("settings.plugins.lastRun",{label:plugin.lastRun.label,status:plugin.lastRun.running?t3("settings.plugins.runRunning"):plugin.lastRun.ok?t3("settings.plugins.runOk"):plugin.lastRun.spawnError?t3("settings.plugins.runFailed"):t3("settings.plugins.runExit",{code:String(plugin.lastRun.exitCode)}),ago:relativeAge(plugin.lastRun.at,now)}):plugin.hooksDeclared?t3("settings.plugins.neverRun"):t3("settings.plugins.noHooks")})]}),plugin.settings.map((setting,s2)=>$jsx(SettingRow,{setting,cursor:isBodyCursor(toggleRow+1+s2),rowRef:props.rowRef(toggleRow+1+s2),onActivate:()=>{props.setLevel("body"),props.setBodyRow(toggleRow+1+s2),props.editSetting(plugin.id,setting.key)}},setting.key))]},plugin.id)})})]})}var import_react54=__toESM(require_react_production(),1);var import_react53=__toESM(require_react_production(),1);var NO_ENGINE_PROTOCOL="",CHOICES=[...ENGINE_PROTOCOLS,NO_ENGINE_PROTOCOL];function EngineProtocolPickerDialogView(props){let dialog=useDialog(),t3=useT(),padX=useDialogPaddingX(),[cursor,setCursor]=import_react53.useState(0),window2={items:[...CHOICES],start:0,total:CHOICES.length};function commit(protocol){if(protocol===void 0)return;props.onSubmit(protocol),dialog.clear()}let rows=CHOICES.map((protocol,i2)=>({key:`${i2}:${protocol||"none"}`,body:protocol?engineEntry(protocol).displayName:t3("settings.engines.protocolNone"),dim:protocol||void 0}));return useBindings(()=>({bindings:[{key:"up",cmd:()=>setCursor((c2)=>clampCursor(c2-1,CHOICES.length))},{key:"down",cmd:()=>setCursor((c2)=>clampCursor(c2+1,CHOICES.length))},{key:"return",cmd:()=>commit(CHOICES[cursor])}]})),$jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:1,children:[$jsx(DialogHeader,{title:t3("settings.engines.protocolTitle",{id:props.engineId}),onClose:()=>props.onCancel()}),$jsx(PickerList,{window:window2,cursor,rows,onPick:(absoluteIndex)=>commit(CHOICES[absoluteIndex]),paddingBottom:1}),$jsx(DialogFooter,{children:t3("settings.engines.protocolFooter")})]})}function show3(dialog,opts){return showDialog(dialog,(resolve)=>$jsx(EngineProtocolPickerDialogView,{engineId:opts.engineId,onSubmit:(v3)=>resolve(v3),onCancel:()=>resolve(void 0)}))}var EngineProtocolPickerDialog={show:show3};function useEngineSettings(kv,dialog,onEngineListShrunk){let[detected,setDetected]=import_react54.useState([]);import_react54.useEffect(()=>{installedEngineIds().then(setDetected)},[]);function customEngines(){let raw=kv.get("customEngineIds",[]);return Array.isArray(raw)?raw.filter((s2)=>typeof s2==="string"&&s2.trim().length>0):[]}function engineList(){return[...new Set([...ALL_VENDORS,...customEngines(),...detected])]}function isCustomEngine(vendor){return customEngines().includes(vendor)}function disabledEngines(){let raw=kv.get("disabledEngineIds",[]);return Array.isArray(raw)?raw.filter((s2)=>typeof s2==="string"&&s2.trim().length>0):[]}function isEngineEnabled(vendor){return!disabledEngines().includes(vendor)}function toggleEngineEnabled(vendor){let off=disabledEngines();if(off.includes(vendor)){kv.set("disabledEngineIds",off.filter((id)=>id!==vendor));return}let nextDefault=engineList().find((id)=>id!==vendor&&!off.includes(id));if(defaultEngine===vendor){if(!nextDefault)return;setEngineDefault(nextDefault)}kv.set("disabledEngineIds",[...off,vendor])}function engineOverride(vendor){let v3=kv.get(engineCommandKey(vendor),"");return typeof v3==="string"?v3.trim():""}function engineCommandText(vendor){return engineOverride(vendor)||defaultEngineCommand(vendor).join(" ")}function engineIsDefault(vendor){return!isCustomEngine(vendor)&&engineOverride(vendor).length===0&&!engineNameIsCustom(vendor)}function engineNameOverride(vendor){let v3=kv.get(engineNameKey(vendor),"");return typeof v3==="string"?v3.trim():""}function engineNameIsCustom(vendor){return engineNameOverride(vendor).length>0}function engineProtocol(vendor){let raw=kv.get(engineProtocolKey(vendor),""),declared=typeof raw==="string"?raw.trim():"";return declared&&ENGINE_PROTOCOLS.includes(declared)?declared:void 0}function engineName(vendor){return engineNameOverride(vendor)||engineEntry(vendor).displayName}let[defaultEngine,setDefaultEngineState]=import_react54.useState(()=>getGlobalDefaultVendor()??DEFAULT_TASK_VENDOR);function setEngineDefault(vendor){setGlobalDefaultVendor(vendor),kv.set("defaultVendor",vendor),setDefaultEngineState(vendor)}function chooseDefaultEngine(vendor){let off=disabledEngines();if(off.includes(vendor))kv.set("disabledEngineIds",off.filter((id)=>id!==vendor));setEngineDefault(vendor)}async function editEngine(vendor){let next=await RenameTaskDialog.show(dialog,engineCommandText(vendor),{dialogTitle:t("settings.engines.launchCommandTitle",{name:engineName(vendor)}),fieldLabel:t("settings.field.command"),submitLabel:t("settings.action.save"),allowEmpty:!0});if(next===void 0)return;kv.set(engineCommandKey(vendor),next.trim())}async function renameEngine(vendor){let next=await RenameTaskDialog.show(dialog,engineName(vendor),{dialogTitle:t("settings.engines.displayNameTitle",{name:engineName(vendor)}),fieldLabel:t("settings.field.name"),submitLabel:t("settings.action.save"),allowEmpty:!0});if(next===void 0)return;kv.set(engineNameKey(vendor),next.trim())}function resetEngine(vendor){if(kv.set(engineCommandKey(vendor),""),kv.set(engineNameKey(vendor),""),isCustomEngine(vendor))kv.set(engineProtocolKey(vendor),""),kv.set("customEngineIds",customEngines().filter((id)=>id!==vendor)),onEngineListShrunk(engineList().length)}async function addEngineFlow(){let idRaw=await RenameTaskDialog.show(dialog,"",{dialogTitle:t("settings.engines.addTitle"),fieldLabel:t("settings.field.id"),submitLabel:t("settings.action.next"),placeholder:t("settings.engines.idPlaceholder")});if(idRaw===void 0)return;let id=idRaw.trim().toLowerCase();if(!id||isBuiltinVendor(id)||customEngines().includes(id))return;let command=await RenameTaskDialog.show(dialog,"",{dialogTitle:t("settings.engines.addStepTitle",{id}),fieldLabel:t("settings.field.command"),submitLabel:t("settings.action.next"),placeholder:t("settings.engines.commandPlaceholder")});if(command===void 0)return;let protocol=await EngineProtocolPickerDialog.show(dialog,{engineId:id});if(protocol===void 0)return;let name=await RenameTaskDialog.show(dialog,id,{dialogTitle:t("settings.engines.addStepTitle",{id}),fieldLabel:t("settings.field.name"),submitLabel:t("settings.action.add"),allowEmpty:!0});if(kv.set("customEngineIds",[...customEngines(),id]),command.trim())kv.set(engineCommandKey(id),command.trim());if(protocol&&ENGINE_PROTOCOLS.includes(protocol))kv.set(engineProtocolKey(id),protocol);let typedName=name?.trim()??"";kv.set(engineNameKey(id),typedName&&typedName!==id?typedName:humanizeSlug(id))}return{engineList,isCustomEngine,isEngineEnabled,toggleEngineEnabled,engineName,engineProtocol,engineCommandText,engineIsDefault,defaultEngine,setEngineDefault,chooseDefaultEngine,editEngine,renameEngine,resetEngine,addEngineFlow}}var import_react55=__toESM(require_react_production(),1);import{closeSync,openSync,readFileSync as readFileSync2,readSync,statSync as statSync2}from"fs";import{mkdirSync as mkdirSync3,readFileSync,writeFileSync as writeFileSync3}from"fs";import{join as join3}from"path";function envPath(pluginId,homeDir){return join3(pluginConfigDir(pluginId,homeDir),".env")}function readPluginSettings(pluginId,homeDir){let text;try{text=readFileSync(envPath(pluginId,homeDir),"utf8")}catch{return{}}let out={};for(let line of text.split(`
102
102
  `)){let m3=line.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);if(m3)out[m3[1]]=m3[2]}return out}function oneLine(value){return value.replace(/[\r\n]/g,"")}function writePluginSettings(pluginId,values,homeDir){let path=envPath(pluginId,homeDir),lines=[];try{lines=readFileSync(path,"utf8").split(`
103
103
  `)}catch{}let remaining={...values},next=[];for(let line of lines){let key=line.match(/^([A-Za-z_][A-Za-z0-9_]*)=/)?.[1];if(key&&key in remaining){let value=oneLine(remaining[key]);if(delete remaining[key],value!=="")next.push(`${key}=${value}`);continue}next.push(line)}for(let[key,raw]of Object.entries(remaining)){let value=oneLine(raw);if(value!=="")next.push(`${key}=${value}`)}while(next.length>0&&next[next.length-1]==="")next.pop();mkdirSync3(pluginConfigDir(pluginId,homeDir),{recursive:!0,mode:OWNER_ONLY_DIR_MODE}),writeFileSync3(path,next.length>0?`${next.join(`
104
104
  `)}
105
105
  `:"",{mode:OWNER_ONLY_FILE_MODE}),tightenPluginPermissions(pluginId,homeDir)}function findFileHandler(fileName,homeDir){for(let entry of loadPluginRegistry(homeDir).plugins){if(!entry.enabled)continue;let manifest;try{manifest=readPluginManifest(entry.root).manifest}catch{continue}for(let handler of manifest.fileHandlers)try{if(new RegExp(handler.pattern,"i").test(fileName))return{qualifiedAction:qualifiedActionId(entry.id,handler.action)}}catch{}}return null}function parseLastRun(logText){if(!logText)return null;let lines=logText.trimEnd().split(`
106
- `);for(let i2=lines.length-1;i2>=0;i2--){let line=lines[i2]?.trim();if(!line)continue;let record;try{record=JSON.parse(line)}catch{continue}if(typeof record.at!=="number")continue;let exitCode=typeof record.exitCode==="number"?record.exitCode:null,spawnError=typeof record.spawnError==="string"?record.spawnError:void 0,running=record.phase==="running";return{at:record.at,label:typeof record.label==="string"?record.label:typeof record.kind==="string"?record.kind:"run",exitCode,ok:!running&&spawnError===void 0&&exitCode===0,running,...spawnError?{spawnError}:{}}}return null}function pluginRowView(outdated,entry,manifestText,logText,settingValues={}){let declares=null,settings=[],platformOk=!0,hooksDeclared=!1;if(manifestText!==null)try{let{manifest}=parsePluginManifest(manifestText);declares={actions:manifest.actions.length,events:manifest.events.length,panes:manifest.panes.length,engines:manifest.engines.length},hooksDeclared=manifest.actions.length+manifest.events.length+manifest.startup.length>0,platformOk=supportsPlatform({},manifest,currentPluginPlatform()),settings=pluginSettingRows(manifest.settings,settingValues)}catch{declares=null}return{id:entry.id,version:entry.version,enabled:entry.enabled,linked:entry.source.kind==="link",source:entry.source.kind==="link"?entry.root:entry.source.spec,declares,platformOk,hooksDeclared,lastRun:parseLastRun(logText),settings,updateAvailable:outdated.has(entry.id)}}var LOG_TAIL_BYTES=65536;function readTail(path){let fd;try{let size=statSync2(path).size,length=Math.min(size,LOG_TAIL_BYTES),buf=Buffer.alloc(length);return fd=openSync(path,"r"),readSync(fd,buf,0,length,size-length),buf.toString("utf8")}catch{return null}finally{if(fd!==void 0)closeSync(fd)}}function readTextOrNull(path){if(!path)return null;try{return readFileSync2(path,"utf8")}catch{return null}}function readPluginRows(homeDir){let outdated=new Set(readOutdatedCache(homeDir));return loadPluginRegistry(homeDir).plugins.map((entry)=>pluginRowView(outdated,entry,readTextOrNull(pluginManifestPath(entry.root)),readTail(pluginLogPath(entry.id,homeDir)),readPluginSettings(entry.id,homeDir)))}function setPluginSetting(pluginId,key,value,homeDir){writePluginSettings(pluginId,{[key]:value},homeDir)}function setPluginEnabled(id,enabled,homeDir){let registry=loadPluginRegistry(homeDir);savePluginRegistry({plugins:registry.plugins.map((p3)=>p3.id===id?{...p3,enabled}:p3)},homeDir),reloadPluginEngines(homeDir)}function useAccountProbes(section,vendors){let[statuses,setStatuses]=import_react55.useState(null),key=vendors.join(",");return import_react55.useEffect(()=>{if(section!=="engines")return;let cancelled=!1;return detectEngineStatuses(key?key.split(","):[]).then((s2)=>{if(!cancelled)setStatuses(s2)}),()=>{cancelled=!0}},[section,key]),statuses}function usePluginSettings(section,dialog){let[rows,setRows]=import_react55.useState([]),t3=useT();import_react55.useEffect(()=>{if(section!=="plugins")return;setRows(readPluginRows())},[section]);function store(pluginId,key,value){try{setPluginSetting(pluginId,key,value)}catch{}setRows(readPluginRows())}return{rows,toggle:(id)=>{let row=rows.find((p3)=>p3.id===id);if(!row)return;try{setPluginEnabled(id,!row.enabled)}catch{}setRows(readPluginRows())},editSetting:async(pluginId,key)=>{let setting=rows.find((p3)=>p3.id===pluginId)?.settings.find((s2)=>s2.key===key);if(!setting)return;if(setting.type==="enum"){store(pluginId,key,nextEnumValue(setting.options,setting.value));return}if(setting.type==="boolean"){store(pluginId,key,toggledBooleanValue(setting));return}let initial=setting.type==="secret"?"":setting.value,next=await RenameTaskDialog.show(dialog,initial,{dialogTitle:setting.label,fieldLabel:key,submitLabel:t3("settings.action.save"),allowEmpty:!0,placeholder:setting.type==="secret"&&setting.value!==""?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":setting.defaultValue});if(next===void 0)return;if(setting.type!=="number"){store(pluginId,key,next.trim());return}let numeric=normalizeNumberInput(next);if(numeric===null){await DialogConfirm.show(dialog,t3("settings.plugins.settingInvalidTitle"),t3("settings.plugins.settingInvalidBody",{label:setting.label}),"cancel");return}store(pluginId,key,numeric)}}}import{accessSync,constants as fsConstants,mkdirSync as mkdirSync4}from"fs";var TAB_STRIP_MODE_KEY="chat.tabStrip.mode",TAB_STRIP_MODES=["always","multipleOnly","never"];var TAB_STRIP_HIDE_SINGLE_KEY="chat.tabStrip.hideSingle";function resolveTabStripMode(stored,legacyHideSingle){if(typeof stored==="string"&&TAB_STRIP_MODES.includes(stored))return stored;if(legacyHideSingle===!0)return"multipleOnly";if(legacyHideSingle===!1)return"always";return"never"}function tabStripVisible(mode,tabCount){if(mode==="never")return!1;if(mode==="multipleOnly")return tabCount>=2;return!0}var ZEN_ACTIVE_KEY="zen.active";function useSettingsPrefs(kv,dialog){let t3=useT();function toastEnabled(){return kv.get("notifications.toast.enabled",!0)!==!1}function soundEnabled(){return kv.get("notifications.sound.enabled",!0)!==!1}function toggleToast(){kv.set("notifications.toast.enabled",!toastEnabled())}function toggleSound(){kv.set("notifications.sound.enabled",!soundEnabled())}function crossTaskEnabled(){return kv.get("notifications.crossTask.enabled",!0)!==!1}function toggleCrossTask(){kv.set("notifications.crossTask.enabled",!crossTaskEnabled())}function prefixTapPresentation(){return normalizePrefixTapPresentation(kv.get(PREFIX_TAP_PRESENTATION_KEY))}function selectPrefixTapPresentation(next){kv.set(PREFIX_TAP_PRESENTATION_KEY,next)}function splitStyle(){return normalizeSplitStyle(kv.get(SPLIT_STYLE_KEY))}function selectSplitStyle(style){kv.set(SPLIT_STYLE_KEY,style)}function zenDefaultOn(){return kv.get(ZEN_ACTIVE_KEY,!1)===!0}function toggleZenDefaultOn(){kv.set(ZEN_ACTIVE_KEY,!zenDefaultOn())}function tabStripMode(){return resolveTabStripMode(kv.get(TAB_STRIP_MODE_KEY,void 0),kv.get(TAB_STRIP_HIDE_SINGLE_KEY,void 0))}function cycleTabStripMode(){let next=TAB_STRIP_MODES[(TAB_STRIP_MODES.indexOf(tabStripMode())+1)%TAB_STRIP_MODES.length];kv.set(TAB_STRIP_MODE_KEY,next)}function remoteProjectsEnabled(){return kv.get("experimental.remoteProjects",!1)===!0}function toggleRemoteProjects(){kv.set("experimental.remoteProjects",!remoteProjectsEnabled())}function autoStatusOn(){return kv.get(AUTO_STATUS_KEY,!1)===!0}function toggleAutoStatus(){kv.set(AUTO_STATUS_KEY,!autoStatusOn())}function dispatcherOn(){return kv.get(DISPATCHER_KEY,!1)===!0}function toggleDispatcher(){kv.set(DISPATCHER_KEY,!dispatcherOn())}function editorKind(){return normalizeEditorKind(kv.get(EDITOR_KIND_KEY,DEFAULT_EDITOR_KIND))}function cycleEditorKind(){let i2=EDITOR_KINDS.indexOf(editorKind()),next=EDITOR_KINDS[(i2+1)%EDITOR_KINDS.length];if(next)kv.set(EDITOR_KIND_KEY,next)}function editorCustomCommand(){let v3=kv.get(EDITOR_CUSTOM_KEY,"");return typeof v3==="string"?v3:""}async function editEditorCustom(){let next=await RenameTaskDialog.show(dialog,editorCustomCommand(),{dialogTitle:t3("settings.general.editorCustomTitle"),fieldLabel:t3("settings.field.command"),submitLabel:t3("settings.action.save"),allowEmpty:!0});if(next===void 0)return;let cmd=next.trim();if(kv.set(EDITOR_CUSTOM_KEY,cmd),cmd)kv.set(EDITOR_KIND_KEY,"custom")}function scrollbackRows(){return normalizeScrollbackRows(kv.get(SCROLLBACK_ROWS_KEY,DEFAULT_SCROLLBACK_ROWS))}async function editScrollbackRows(){let next=await RenameTaskDialog.show(dialog,String(scrollbackRows()),{dialogTitle:t3("settings.general.scrollbackTitle"),fieldLabel:t3("settings.general.scrollbackField"),submitLabel:t3("settings.action.save"),placeholder:String(DEFAULT_SCROLLBACK_ROWS)});if(next===void 0)return;let n2=Number.parseInt(next.trim(),10);if(!Number.isFinite(n2)){await DialogConfirm.show(dialog,t3("settings.general.scrollbackInvalidTitle"),t3("settings.general.scrollbackInvalidBody"),"cancel");return}kv.set(SCROLLBACK_ROWS_KEY,normalizeScrollbackRows(n2))}function worktreeBasePath(){let v3=kv.get(WORKTREE_BASE_KEY,"");return typeof v3==="string"?v3:""}let worktreeKind=()=>worktreeBaseKindOf(worktreeBasePath());function worktreeKindLabel(){let kind=worktreeKind();if(kind==="default")return t3("settings.general.worktreeKindDefault");if(kind==="nextToProject")return t3("settings.general.worktreeKindNext");return t3("settings.general.worktreeKindCustom")}function worktreeCustomPath(){let v3=kv.get(WORKTREE_BASE_CUSTOM_KEY,"");return(typeof v3==="string"?v3.trim():"")||(worktreeKind()==="custom"?worktreeBasePath().trim():"")}function cycleWorktreeBase(){let kind=worktreeKind();if(kind==="default")kv.set(WORKTREE_BASE_KEY,PROJECT_SIBLING_BASE);else if(kind==="nextToProject")kv.set(WORKTREE_BASE_KEY,worktreeCustomPath());else kv.set(WORKTREE_BASE_CUSTOM_KEY,worktreeBasePath().trim()),kv.set(WORKTREE_BASE_KEY,"")}async function editWorktreeCustom(){let next=await RenameTaskDialog.show(dialog,worktreeCustomPath(),{dialogTitle:t3("settings.general.worktreeBaseTitle"),fieldLabel:t3("settings.general.worktreeBaseField"),submitLabel:t3("settings.action.save"),placeholder:`${PROJECT_DIR_TOKEN}/../worktrees`,allowEmpty:!0});if(next===void 0)return;let raw=next.trim();if(raw.includes(PROJECT_DIR_TOKEN)){if(!hasProjectDirToken(raw)){await DialogConfirm.show(dialog,t3("settings.general.worktreeBaseInvalidTitle"),t3("settings.general.worktreeBaseTokenBody",{token:PROJECT_DIR_TOKEN}),"cancel");return}}else if(raw){let resolved=normalizeWorktreeBase(raw)??raw;try{mkdirSync4(resolved,{recursive:!0}),accessSync(resolved,fsConstants.W_OK)}catch(err){await DialogConfirm.show(dialog,t3("settings.general.worktreeBaseInvalidTitle"),t3("settings.general.worktreeBaseUnusableBody",{path:resolved,error:errorMessage(err)}),"cancel");return}}if(kv.set(WORKTREE_BASE_CUSTOM_KEY,raw),raw)kv.set(WORKTREE_BASE_KEY,raw);else if(worktreeKind()==="custom")kv.set(WORKTREE_BASE_KEY,"")}return{toastEnabled,toggleToast,soundEnabled,toggleSound,crossTaskEnabled,toggleCrossTask,prefixTapPresentation,selectPrefixTapPresentation,splitStyle,selectSplitStyle,zenDefaultOn,toggleZenDefaultOn,remoteProjectsEnabled,toggleRemoteProjects,autoStatusOn,toggleAutoStatus,dispatcherOn,toggleDispatcher,editorKind,cycleEditorKind,editorCustomCommand,editEditorCustom,scrollbackRows,editScrollbackRows,tabStripMode,cycleTabStripMode,worktreeKind,worktreeKindLabel,worktreeCustomPath,cycleWorktreeBase,editWorktreeCustom}}var EMPTY_USAGE_SIGNAL=createStateCell(null);function SettingsDialog(props){let dialog=useDialog(),themeCtx=useTheme(),renderer=useRenderer(),{theme}=themeCtx,t3=useT(),padX=useDialogPaddingX(),[level,setLevel]=import_react57.useState("sidebar"),[section,setSection]=import_react57.useState("general"),[cursor,setCursor]=import_react57.useState(0),[bodyRow,setBodyRow]=import_react57.useState(0),[feedbackTitle,setFeedbackTitle]=import_react57.useState(""),[feedbackBody,setFeedbackBody]=import_react57.useState(""),[feedbackStatus,setFeedbackStatus]=import_react57.useState(""),themeNames=import_react57.useMemo(()=>themeCtx.all().slice().sort(),[themeCtx]),hasDaemon=hasRestartableDaemon(props.orchestrator),remote=props.orchestrator instanceof RemoteOrchestrator?props.orchestrator:null,prefs=useSettingsPrefs(props.kv,dialog),engines=useEngineSettings(props.kv,dialog,(max)=>setBodyRow((r6)=>Math.max(0,Math.min(r6,max)))),usage=useAccessor(remote?remote.usageSnapshotSignal():EMPTY_USAGE_SIGNAL),engineStatuses=useAccountProbes(section,engines.engineList()),[keysFileExists,setKeysFileExists]=import_react57.useState(()=>userKeybindingsReport().exists);function createKeysFile(){try{createKeybindingsFile(userKeybindingsReport().path),reloadUserKeybindings()}catch{}setKeysFileExists(userKeybindingsReport().exists)}let plugins=usePluginSettings(section,dialog);function bodyRows(){return sectionRows(section,{themeNames,focusAccentSlots:FOCUS_ACCENT_SLOTS,engineList:engines.engineList(),plugins:plugins.rows.map((p3)=>({id:p3.id,settingKeys:p3.settings.map((s2)=>s2.key)})),hasDaemon,keybindingsFileExists:keysFileExists})}function bodyRowCount(){return bodyRows().length}function selectTheme(name){if(themeCtx.selected===name)return;if(!themeCtx.set(name))return;props.kv.set("activeTheme",name)}function selectLanguage(locale){if(currentLang()===locale)return;setLocaleLang(locale),props.kv.set(LOCALE_KEY,locale)}function toggleTransparent(){let next=!themeCtx.transparentBackground;themeCtx.setTransparentBackground(next),props.kv.set("transparentBackground",next)}function selectFocusAccent(slot){if(themeCtx.focusAccent===slot)return;themeCtx.setFocusAccent(slot),props.kv.set("focusAccent",slot)}function currentEngineRow(){if(section!=="engines"||level!=="body")return null;let row=rowAt(bodyRows(),bodyRow);return row?.kind==="engine"?row.vendor:null}async function sendFeedback(){setFeedbackStatus("submitting...");try{let result=submitFeedback({title:feedbackTitle,body:feedbackBody});setFeedbackStatus(`sent: ${result.url}`),setFeedbackTitle(""),setFeedbackBody(""),setBodyRow(0)}catch(err){setFeedbackStatus(`error: ${errorMessage(err)}`)}}let editingFeedback=section==="feedback"&&level==="body";function feedbackFieldStep(delta){let next=bodyRow+delta;if(next<0||next>2){setLevel("sidebar");return}setBodyRow(next)}function enterBody(){if(level!=="sidebar"||bodyRowCount()===0)return;setLevel("body"),setBodyRow(0)}function moveCursor(delta){if(level==="sidebar"){let next=(cursor+delta+SECTIONS.length)%SECTIONS.length;setCursor(next);let nextSection=SECTIONS[next];if(nextSection)setSection(nextSection.id),setBodyRow(0);return}let len=bodyRowCount();if(len===0)return;setBodyRow((bodyRow+delta+len)%len)}function switchSection(id){setSection(id),setCursor(SECTIONS.findIndex((s2)=>s2.id===id)),setBodyRow(0),setLevel("sidebar")}let rowActivators={theme:(row)=>selectTheme(row.name),language:(row)=>selectLanguage(row.locale),transparent:()=>toggleTransparent(),focusAccent:(row)=>selectFocusAccent(row.slot),toast:()=>prefs.toggleToast(),sound:()=>prefs.toggleSound(),crossTask:()=>prefs.toggleCrossTask(),keyHints:()=>toggleKeyHints(props.kv),prefixTapPresentation:(row)=>prefs.selectPrefixTapPresentation(row.presentation),splitStyle:(row)=>prefs.selectSplitStyle(row.style),zenDefaultOn:()=>prefs.toggleZenDefaultOn(),editorKind:()=>prefs.cycleEditorKind(),editorCustom:()=>void prefs.editEditorCustom(),worktreeBase:()=>prefs.cycleWorktreeBase(),worktreeCustom:()=>void prefs.editWorktreeCustom(),scrollbackRows:()=>void prefs.editScrollbackRows(),tabStripHideSingle:()=>prefs.cycleTabStripMode(),engine:(row)=>void engines.editEngine(row.vendor),engineAdd:()=>void engines.addEngineFlow(),keysCreate:()=>createKeysFile(),pluginToggle:(row)=>plugins.toggle(row.pluginId),pluginSetting:(row)=>void plugins.editSetting(row.pluginId,row.key),feedbackTitle:()=>setBodyRow(0),feedbackBody:()=>setBodyRow(1),feedbackSend:()=>void sendFeedback(),devReset:()=>void confirmResetState(dialog,props.kv,renderer),devRestartDaemon:()=>void confirmRestartDaemon(dialog,props.orchestrator,renderer),devRemoteProjects:()=>prefs.toggleRemoteProjects(),devAutoStatus:()=>prefs.toggleAutoStatus(),devDispatcher:()=>prefs.toggleDispatcher()};function activateBodyRow(){let row=rowAt(bodyRows(),bodyRow);if(!row)return;rowActivators[row.kind](row)}useBindings(()=>({enabled:dialog.stack.length===0&&!editingFeedback,bindings:[{key:"down",cmd:()=>moveCursor(1)},{key:"up",cmd:()=>moveCursor(-1)},{key:"j",cmd:()=>moveCursor(1)},{key:"k",cmd:()=>moveCursor(-1)},{key:"tab",cmd:()=>moveCursor(1)},{key:"right",cmd:enterBody},{key:"l",cmd:enterBody},{key:"left",cmd:()=>setLevel("sidebar")},{key:"h",cmd:()=>setLevel("sidebar")},{key:"return",cmd:()=>{if(level==="sidebar"){enterBody();return}activateBodyRow()}},{key:"r",cmd:()=>{let v3=currentEngineRow();if(v3)engines.renameEngine(v3)}},{key:"x",cmd:()=>{let v3=currentEngineRow();if(v3)engines.resetEngine(v3)}},{key:"d",cmd:()=>{let v3=currentEngineRow();if(v3)engines.chooseDefaultEngine(v3)}},{key:"space",cmd:()=>{let v3=currentEngineRow();if(v3)engines.toggleEngineEnabled(v3)}}]})),useBindings(()=>({enabled:editingFeedback,bindings:[{key:"tab",cmd:()=>feedbackFieldStep(1)},{key:"shift+tab",cmd:()=>feedbackFieldStep(-1)}]})),useBindings(()=>({enabled:editingFeedback&&bodyRow===2,bindings:[{key:"return",cmd:()=>void sendFeedback()}]}));let follow=useCursorFollow(level==="body"?bodyRow:-1),cursorProps={level,bodyRow,setLevel,setBodyRow,rowRef:follow.rowRef},navHint=$jsx("box",{paddingTop:0,children:$jsx("text",{fg:theme.textMuted,children:editingFeedback?t3("settings.nav.feedback"):t3("settings.nav.default")})}),body=$jsxs("box",{paddingLeft:padX,paddingRight:padX,paddingBottom:1,gap:1,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsx("text",{attributes:TextAttributes23.BOLD,fg:theme.text,children:t3("settings.title")}),$jsx("text",{fg:theme.textMuted,onMouseUp:()=>props.onClose(),children:t3("settings.esc")})]}),$jsxs("box",{flexDirection:"row",gap:2,children:[$jsx(SettingsSectionSidebar,{level,cursor,switchSection}),$jsxs("box",{flexGrow:1,flexShrink:1,flexDirection:"column",gap:1,children:[section==="general"?$jsx(GeneralSettingsSection,{...cursorProps,prefs,themeNames,selectTheme,currentLocale:currentLang(),selectLanguage,toggleTransparent,selectFocusAccent,usage}):null,section==="engines"?$jsx(EngineSettingsSection,{...cursorProps,vendors:engines.engineList(),statuses:engineStatuses,isCustom:engines.isCustomEngine,engineProtocol:engines.engineProtocol,isEnabled:engines.isEngineEnabled,toggleEngine:engines.toggleEngineEnabled,chooseDefault:engines.chooseDefaultEngine,displayName:engines.engineName,commandText:engines.engineCommandText,isDefault:engines.engineIsDefault,isDefaultEngine:(v3)=>engines.defaultEngine===v3,editEngine:(v3)=>void engines.editEngine(v3),onAddEngine:()=>void engines.addEngineFlow()}):null,section==="plugins"?$jsx(PluginSettingsSection,{...cursorProps,plugins:plugins.rows,toggle:plugins.toggle,editSetting:(id,key)=>void plugins.editSetting(id,key)}):null,section==="keys"?$jsx(KeybindingsSettingsSection,{...cursorProps,prefs,onCreateFile:createKeysFile}):null,section==="feedback"?$jsx(FeedbackSettingsSection,{...cursorProps,title:feedbackTitle,setTitle:(v3)=>{setFeedbackTitle(v3),setFeedbackStatus("")},body:feedbackBody,setBody:(v3)=>{setFeedbackBody(v3),setFeedbackStatus("")},status:feedbackStatus,onTitleSubmit:()=>setBodyRow(1),submit:()=>void sendFeedback()}):null,section==="dev"?$jsx(DevSettingsSection,{...cursorProps,prefs,hasDaemon,confirmReset:()=>void confirmResetState(dialog,props.kv,renderer),confirmRestartDaemon:()=>void confirmRestartDaemon(dialog,props.orchestrator,renderer)}):null]})]})]});return $jsxs("box",{flexDirection:"column",flexGrow:1,children:[$jsx("scrollbox",{ref:follow.scrollRef,flexGrow:1,flexShrink:1,flexBasis:0,verticalScrollbarOptions:{trackOptions:{foregroundColor:"transparent"}},children:body}),$jsx("box",{paddingLeft:padX,paddingRight:padX,children:navHint})]})}import{TextAttributes as TextAttributes24}from"@opentui/core";var import_react58=__toESM(require_react_production(),1);function reposOf(orch){if(!orch)return[];let seen=[];for(let task of orch.listTasks())if(task.repo&&!seen.some((repo)=>samePath(repo,task.repo)))seen.push(task.repo);return seen}function linkedTaskFor(orch,repo,number){return orch?.listTasks().find((task)=>samePath(task.repo,repo)&&task.linkedWorkItem?.number===number)}function errorHint(error,t3){let colon=error.indexOf(": ");switch(colon>=0?error.slice(0,colon):"failed"){case"no-remote":return t3("workItems.errorHint.noRemote");case"gh-missing":return t3("workItems.errorHint.ghMissing");case"auth":return t3("workItems.errorHint.auth");default:return t3("workItems.errorHint.fallback",{message:error})}}function relativeAge2(iso,now){let at2=Date.parse(iso);if(!Number.isFinite(at2))return"";return relativeAge(at2,now)}function WorkItemsPage(props){let{theme}=useTheme(),t3=useT(),notif=useNotifications();function notifyError(message){notif.notify({kind:"error",taskId:"",tabId:"",title:message})}let repos=reposOf(props.orchestrator),[repoIndex,setRepoIndex]=import_react58.useState(()=>{let wanted=props.focusRepo?repos.findIndex((repo2)=>samePath(repo2,props.focusRepo)):-1;return wanted>=0?wanted:0}),repo=repos[repoIndex],[items,setItems]=import_react58.useState(null),[error,setError]=import_react58.useState(null),[reloadTick,setReloadTick]=import_react58.useState(0),[assignedToMe,setAssignedToMe]=import_react58.useState(!1),[starting,setStarting]=import_react58.useState(!1),[notice,setNotice]=import_react58.useState(null);import_react58.useEffect(()=>{let disposed=!1,orch=props.orchestrator;if(!orch||!repo){setItems([]);return}return setError(null),orch.listWorkItems({repo,limit:30,...assignedToMe?{assignee:"@me"}:{},...reloadTick>0?{refresh:!0}:{}}).then((result)=>{if(!disposed)setItems(result.items)}).catch((err)=>{if(disposed)return;setError(err instanceof Error?err.message:String(err)),setItems([])}),()=>{disposed=!0}},[props.orchestrator,repo,assignedToMe,reloadTick]);let rows=items??[],[cursor,setCursor]=import_react58.useState(0);import_react58.useEffect(()=>{setCursor((c2)=>clampCursor(c2,rows.length))},[rows.length]);let follow=useCursorFollow(cursor);import_react58.useEffect(()=>{setNotice(null)},[repo,assignedToMe]);async function startSelected(){let orch=props.orchestrator,item=rows[cursor];if(!orch||!item||!repo||starting)return;let linked=linkedTaskFor(orch,repo,item.number);if(linked){setNotice(t3("workItems.openingLinked",{title:linked.title})),props.onOpenTask?.(linked.id);return}setStarting(!0),setNotice(t3("workItems.starting",{number:item.number}));try{let result=await orch.startWorkItem({repo,number:item.number});if(result.started)props.onOpenTask?.(result.taskId);else setNotice(t3("workItems.startedNoEngine",{title:result.title}))}catch(err){console.error("[rove work-items] start failed:",err),notifyError(t3("workItems.startFailed",{number:item.number,error:errorMessage(err)}))}finally{setStarting(!1)}}useBindings(()=>({enabled:props.focused!==!1,bindings:[...pageCloseBindings(props.onClose),{key:"j",cmd:()=>setCursor((c2)=>clampCursor(c2+1,rows.length))},{key:"down",cmd:()=>setCursor((c2)=>clampCursor(c2+1,rows.length))},{key:"k",cmd:()=>setCursor((c2)=>clampCursor(c2-1,rows.length))},{key:"up",cmd:()=>setCursor((c2)=>clampCursor(c2-1,rows.length))},{key:"tab",cmd:()=>setRepoIndex((i2)=>repos.length?(i2+1)%repos.length:0)},{key:"a",cmd:()=>setAssignedToMe((on)=>!on)},{key:"r",cmd:()=>setReloadTick((tick)=>tick+1)},{key:"return",cmd:()=>void startSelected()}]}));let now=Date.now();return $jsxs("box",{flexDirection:"column",flexGrow:1,paddingTop:1,paddingBottom:1,paddingLeft:2,paddingRight:2,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsx("text",{attributes:TextAttributes24.BOLD,fg:theme.text,children:t3("workItems.title")}),$jsxs("text",{fg:theme.textMuted,children:[repo?sidebarProjectLabel(repo,repos):t3("workItems.noRepo"),assignedToMe?` ${t3("workItems.assignedFilter")}`:""]})]}),error?$jsxs("box",{flexDirection:"column",marginTop:1,children:[$jsx("text",{fg:theme.error,children:error}),$jsx("box",{marginTop:1,children:$jsx("text",{fg:theme.textMuted,children:errorHint(error,t3)})})]}):items===null?$jsx("text",{fg:theme.textMuted,children:t3("common.loading")}):rows.length===0?$jsx("text",{fg:theme.textMuted,children:t3("workItems.empty")}):$jsx("scrollbox",{ref:follow.scrollRef,flexGrow:1,flexShrink:1,flexBasis:0,marginTop:1,verticalScrollbarOptions:{trackOptions:{foregroundColor:"transparent"}},children:rows.map((item,index)=>{let chrome=resolveRowSelectionChrome(theme,{cursor:index===cursor,selected:!1}),linked=linkedTaskFor(props.orchestrator,repo,item.number);return $jsxs("box",{ref:follow.rowRef(index),flexDirection:"column",flexShrink:0,...chrome.backgroundColor?{backgroundColor:chrome.backgroundColor}:{},children:[$jsxs("box",{flexDirection:"row",gap:0,children:[$jsx("text",{fg:chrome.markerColor,wrapMode:"none",children:chrome.marker}),$jsxs("box",{flexDirection:"row",flexGrow:1,paddingLeft:1,paddingRight:1,gap:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:`#${item.number}`}),$jsx("text",{fg:theme.text,attributes:index===cursor?TextAttributes24.BOLD:void 0,wrapMode:"none",flexGrow:1,children:item.title})]})]}),$jsxs("box",{flexDirection:"row",gap:0,children:[$jsx("text",{fg:chrome.markerColor,wrapMode:"none",children:chrome.marker}),$jsxs("box",{flexDirection:"row",flexGrow:1,paddingLeft:2,paddingRight:1,gap:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexGrow:1,children:[item.author,...item.labels.slice(0,2)].filter(Boolean).join(" \xB7 ")}),linked?$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("workItems.linkedChip",{title:linked.title})}):null,$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:relativeAge2(item.updatedAt,now)})]})]})]},`${item.number}`)})}),notice?$jsx("text",{fg:theme.textMuted,flexShrink:0,children:notice}):null]})}import{TextAttributes as TextAttributes25}from"@opentui/core";var import_react59=__toESM(require_react_production(),1);var LAND_CONFLICT_RE=/LAND_CONFLICT/,MAIN_DIRTY_RE=/MAIN_CHECKOUT_DIRTY/;async function landTaskAction(deps,taskId,branchLabel){let{t:t3}=deps,preflight;try{preflight=await deps.orchestrator.landPreflight(taskId)}catch(err){return deps.notifyError(t3("worktrees.land.failed",{error:err instanceof Error?err.message:String(err)})),console.error("[rove land] preflight failed:",err),!1}if(preflight.refusal){if(preflight.refusal==="MAIN_CHECKOUT_DIRTY")deps.notifyNeedsInput(t3("worktrees.land.dirtyBase"));else deps.notifyError(t3("worktrees.land.failed",{error:preflight.message??preflight.refusal}));return!1}let body=t3(preflight.ahead===1?"worktrees.land.confirmBodyOne":"worktrees.land.confirmBody",{branch:branchLabel,landedOn:preflight.landedOn,commits:preflight.ahead??"?"});if(!await deps.confirm(body))return!1;try{let res=await deps.orchestrator.landTask(taskId,{callerCwd:deps.callerCwd});deps.notifyInfo(t3("worktrees.land.done",{branch:res.branch,landedOn:res.landedOn,commit:res.commit}));let cleanup=res.worktree;if(cleanup&&!cleanup.removed)deps.notifyNeedsInput(t3("worktrees.land.worktreeKept",{reason:cleanup.reason??"refused"}));else if(cleanup?.reason)deps.notifyNeedsInput(t3("worktrees.land.worktreePathStale",{reason:cleanup.reason}));if(cleanup?.residue)deps.notifyNeedsInput(t3("worktrees.land.worktreeResidue",{path:cleanup.residue.path,reason:cleanup.residue.reason}));return!0}catch(err){let msg=err instanceof Error?err.message:String(err);if(LAND_CONFLICT_RE.test(msg))deps.notifyNeedsInput(t3("worktrees.land.conflict",{files:msg}));else if(MAIN_DIRTY_RE.test(msg))deps.notifyNeedsInput(t3("worktrees.land.dirtyBase"));else deps.notifyError(t3("worktrees.land.failed",{error:msg}));return console.error("[rove land] failed:",err),!1}}function flattenRows(projects){return projects.flatMap((p3)=>p3.worktrees)}function dirtyRefusalReason(err){if(!(err instanceof Error))return null;let at2=err.message.indexOf(DIRTY_WORKTREE_CODE);if(at2<0)return null;return err.message.slice(at2+DIRTY_WORKTREE_CODE.length).replace(/^:\s*/,"")}function taskIdForPath(orch,wtPath){let norm=(p3)=>p3.replace(/^\/private\//,"/");return orch.listTasks().find((task)=>task.worktreePath&&samePath(norm(task.worktreePath),norm(wtPath)))?.id}function WorktreesPage(props){let{theme}=useTheme(),dialog=useDialog(),t3=useT(),notif=useNotifications();function notifyError(message){notif.notify({kind:"error",taskId:"",tabId:"",title:message})}function notifyNeedsInput(message){notif.notify({kind:"needs_input",taskId:"",tabId:"",title:message})}function notifyInfo(message){notif.notify({kind:"done",taskId:"",tabId:"",title:message})}let[projects,setProjects]=import_react59.useState(null),[reloadTick,setReloadTick]=import_react59.useState(0),refetch=()=>setReloadTick((tick)=>tick+1);import_react59.useEffect(()=>{let disposed=!1,fullLanded=!1,orch=props.orchestrator;if(!orch){setProjects([]);return}return orch.listWorktrees({network:!1}).then((rows)=>{if(!disposed&&!fullLanded)setProjects(rows)}).catch(()=>{}),orch.listWorktrees().then((rows)=>{if(fullLanded=!0,disposed)return;setProjects(rows);let live=new Set(flattenRows(rows).map((r6)=>r6.path));setRemovingPaths((paths)=>paths.filter((p3)=>live.has(p3)))}).catch(()=>{}),()=>{disposed=!0}},[props.orchestrator,reloadTick]);let[removingPaths,setRemovingPaths]=import_react59.useState([]),visibleProjects=(projects??[]).map((p3)=>({...p3,worktrees:p3.worktrees.filter((w4)=>!removingPaths.includes(w4.path))})),flatRows=flattenRows(visibleProjects),[cursor,setCursor]=import_react59.useState(0);import_react59.useEffect(()=>{setCursor((c2)=>clampCursor(c2,flatRows.length))},[flatRows.length]);let follow=useCursorFollow(cursor),[busyPath,setBusyPath]=import_react59.useState(null);async function deleteInBackground(row,force){let orch=props.orchestrator;if(!orch)return;setRemovingPaths((paths)=>[...paths,row.path]);try{let residue=await orch.removeWorktree(row.path,force);if(residue)notifyNeedsInput(t3("worktrees.delete.residue",{path:residue.path,reason:residue.reason}));refetch()}catch(err){setRemovingPaths((paths)=>paths.filter((p3)=>p3!==row.path));let reason=force?null:dirtyRefusalReason(err);if(reason!==null){if(await DialogConfirm.show(dialog,t3("worktrees.delete.forceTitle"),`${t3("worktrees.delete.forceBody",{branch:row.branch||row.path})}
106
+ `);for(let i2=lines.length-1;i2>=0;i2--){let line=lines[i2]?.trim();if(!line)continue;let record;try{record=JSON.parse(line)}catch{continue}if(typeof record.at!=="number")continue;let exitCode=typeof record.exitCode==="number"?record.exitCode:null,spawnError=typeof record.spawnError==="string"?record.spawnError:void 0,running=record.phase==="running";return{at:record.at,label:typeof record.label==="string"?record.label:typeof record.kind==="string"?record.kind:"run",exitCode,ok:!running&&spawnError===void 0&&exitCode===0,running,...spawnError?{spawnError}:{}}}return null}function pluginRowView(outdated,entry,manifestText,logText,settingValues={}){let declares=null,settings=[],platformOk=!0,hooksDeclared=!1;if(manifestText!==null)try{let{manifest}=parsePluginManifest(manifestText);declares={actions:manifest.actions.length,events:manifest.events.length,panes:manifest.panes.length,engines:manifest.engines.length},hooksDeclared=manifest.actions.length+manifest.events.length+manifest.startup.length>0,platformOk=supportsPlatform({},manifest,currentPluginPlatform()),settings=pluginSettingRows(manifest.settings,settingValues)}catch{declares=null}return{id:entry.id,version:entry.version,enabled:entry.enabled,linked:entry.source.kind==="link",source:entry.source.kind==="link"?entry.root:entry.source.spec,declares,platformOk,hooksDeclared,lastRun:parseLastRun(logText),settings,updateAvailable:outdated.has(entry.id)}}var LOG_TAIL_BYTES=65536;function readTail(path){let fd;try{let size=statSync2(path).size,length=Math.min(size,LOG_TAIL_BYTES),buf=Buffer.alloc(length);return fd=openSync(path,"r"),readSync(fd,buf,0,length,size-length),buf.toString("utf8")}catch{return null}finally{if(fd!==void 0)closeSync(fd)}}function readTextOrNull(path){if(!path)return null;try{return readFileSync2(path,"utf8")}catch{return null}}function readPluginRows(homeDir){let outdated=new Set(readOutdatedCache(homeDir));return loadPluginRegistry(homeDir).plugins.map((entry)=>pluginRowView(outdated,entry,readTextOrNull(pluginManifestPath(entry.root)),readTail(pluginLogPath(entry.id,homeDir)),readPluginSettings(entry.id,homeDir)))}function setPluginSetting(pluginId,key,value,homeDir){writePluginSettings(pluginId,{[key]:value},homeDir)}function setPluginEnabled(id,enabled,homeDir){let registry=loadPluginRegistry(homeDir);savePluginRegistry({plugins:registry.plugins.map((p3)=>p3.id===id?{...p3,enabled}:p3)},homeDir),reloadPluginEngines(homeDir)}function useAccountProbes(section,vendors){let[statuses,setStatuses]=import_react55.useState(null),key=vendors.join(",");return import_react55.useEffect(()=>{if(section!=="engines")return;let cancelled=!1;return detectEngineStatuses(key?key.split(","):[]).then((s2)=>{if(!cancelled)setStatuses(s2)}),()=>{cancelled=!0}},[section,key]),statuses}function usePluginSettings(section,dialog){let[rows,setRows]=import_react55.useState([]),t3=useT();import_react55.useEffect(()=>{if(section!=="plugins")return;setRows(readPluginRows())},[section]);function store(pluginId,key,value){try{setPluginSetting(pluginId,key,value)}catch{}setRows(readPluginRows())}return{rows,toggle:(id)=>{let row=rows.find((p3)=>p3.id===id);if(!row)return;try{setPluginEnabled(id,!row.enabled)}catch{}setRows(readPluginRows())},editSetting:async(pluginId,key)=>{let setting=rows.find((p3)=>p3.id===pluginId)?.settings.find((s2)=>s2.key===key);if(!setting)return;if(setting.type==="enum"){store(pluginId,key,nextEnumValue(setting.options,setting.value));return}if(setting.type==="boolean"){store(pluginId,key,toggledBooleanValue(setting));return}let initial=setting.type==="secret"?"":setting.value,next=await RenameTaskDialog.show(dialog,initial,{dialogTitle:setting.label,fieldLabel:key,submitLabel:t3("settings.action.save"),allowEmpty:!0,placeholder:setting.type==="secret"&&setting.value!==""?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":setting.defaultValue});if(next===void 0)return;if(setting.type!=="number"){store(pluginId,key,next.trim());return}let numeric=normalizeNumberInput(next);if(numeric===null){await DialogConfirm.show(dialog,t3("settings.plugins.settingInvalidTitle"),t3("settings.plugins.settingInvalidBody",{label:setting.label}),"cancel");return}store(pluginId,key,numeric)}}}import{accessSync,constants as fsConstants,mkdirSync as mkdirSync4}from"fs";var TAB_STRIP_MODE_KEY="chat.tabStrip.mode",TAB_STRIP_MODES=["always","multipleOnly","never"];var TAB_STRIP_HIDE_SINGLE_KEY="chat.tabStrip.hideSingle";function resolveTabStripMode(stored,legacyHideSingle){if(typeof stored==="string"&&TAB_STRIP_MODES.includes(stored))return stored;if(legacyHideSingle===!0)return"multipleOnly";if(legacyHideSingle===!1)return"always";return"never"}function tabStripVisible(mode,tabCount){if(mode==="never")return!1;if(mode==="multipleOnly")return tabCount>=2;return!0}var ZEN_ACTIVE_KEY="zen.active";function useSettingsPrefs(kv,dialog){let t3=useT();function toastEnabled(){return kv.get("notifications.toast.enabled",!0)!==!1}function soundEnabled(){return kv.get("notifications.sound.enabled",!0)!==!1}function toggleToast(){kv.set("notifications.toast.enabled",!toastEnabled())}function toggleSound(){kv.set("notifications.sound.enabled",!soundEnabled())}function soundVolume(){return normalizeSoundVolume(kv.get(SOUND_VOLUME_KEY,DEFAULT_SOUND_VOLUME))}function cycleSoundVolume(){kv.set(SOUND_VOLUME_KEY,nextSoundVolume(soundVolume()))}function crossTaskEnabled(){return kv.get("notifications.crossTask.enabled",!0)!==!1}function toggleCrossTask(){kv.set("notifications.crossTask.enabled",!crossTaskEnabled())}function prefixTapPresentation(){return normalizePrefixTapPresentation(kv.get(PREFIX_TAP_PRESENTATION_KEY))}function selectPrefixTapPresentation(next){kv.set(PREFIX_TAP_PRESENTATION_KEY,next)}function splitStyle(){return normalizeSplitStyle(kv.get(SPLIT_STYLE_KEY))}function selectSplitStyle(style){kv.set(SPLIT_STYLE_KEY,style)}function zenDefaultOn(){return kv.get(ZEN_ACTIVE_KEY,!1)===!0}function toggleZenDefaultOn(){kv.set(ZEN_ACTIVE_KEY,!zenDefaultOn())}function tabStripMode(){return resolveTabStripMode(kv.get(TAB_STRIP_MODE_KEY,void 0),kv.get(TAB_STRIP_HIDE_SINGLE_KEY,void 0))}function cycleTabStripMode(){let next=TAB_STRIP_MODES[(TAB_STRIP_MODES.indexOf(tabStripMode())+1)%TAB_STRIP_MODES.length];kv.set(TAB_STRIP_MODE_KEY,next)}function remoteProjectsEnabled(){return kv.get("experimental.remoteProjects",!1)===!0}function toggleRemoteProjects(){kv.set("experimental.remoteProjects",!remoteProjectsEnabled())}function autoStatusOn(){return kv.get(AUTO_STATUS_KEY,!1)===!0}function toggleAutoStatus(){kv.set(AUTO_STATUS_KEY,!autoStatusOn())}function dispatcherOn(){return kv.get(DISPATCHER_KEY,!1)===!0}function toggleDispatcher(){kv.set(DISPATCHER_KEY,!dispatcherOn())}function editorKind(){return normalizeEditorKind(kv.get(EDITOR_KIND_KEY,DEFAULT_EDITOR_KIND))}function cycleEditorKind(){let i2=EDITOR_KINDS.indexOf(editorKind()),next=EDITOR_KINDS[(i2+1)%EDITOR_KINDS.length];if(next)kv.set(EDITOR_KIND_KEY,next)}function editorCustomCommand(){let v3=kv.get(EDITOR_CUSTOM_KEY,"");return typeof v3==="string"?v3:""}async function editEditorCustom(){let next=await RenameTaskDialog.show(dialog,editorCustomCommand(),{dialogTitle:t3("settings.general.editorCustomTitle"),fieldLabel:t3("settings.field.command"),submitLabel:t3("settings.action.save"),allowEmpty:!0});if(next===void 0)return;let cmd=next.trim();if(kv.set(EDITOR_CUSTOM_KEY,cmd),cmd)kv.set(EDITOR_KIND_KEY,"custom")}function scrollbackRows(){return normalizeScrollbackRows(kv.get(SCROLLBACK_ROWS_KEY,DEFAULT_SCROLLBACK_ROWS))}async function editScrollbackRows(){let next=await RenameTaskDialog.show(dialog,String(scrollbackRows()),{dialogTitle:t3("settings.general.scrollbackTitle"),fieldLabel:t3("settings.general.scrollbackField"),submitLabel:t3("settings.action.save"),placeholder:String(DEFAULT_SCROLLBACK_ROWS)});if(next===void 0)return;let n2=Number.parseInt(next.trim(),10);if(!Number.isFinite(n2)){await DialogConfirm.show(dialog,t3("settings.general.scrollbackInvalidTitle"),t3("settings.general.scrollbackInvalidBody"),"cancel");return}kv.set(SCROLLBACK_ROWS_KEY,normalizeScrollbackRows(n2))}function worktreeBasePath(){let v3=kv.get(WORKTREE_BASE_KEY,"");return typeof v3==="string"?v3:""}let worktreeKind=()=>worktreeBaseKindOf(worktreeBasePath());function worktreeKindLabel(){let kind=worktreeKind();if(kind==="default")return t3("settings.general.worktreeKindDefault");if(kind==="nextToProject")return t3("settings.general.worktreeKindNext");return t3("settings.general.worktreeKindCustom")}function worktreeCustomPath(){let v3=kv.get(WORKTREE_BASE_CUSTOM_KEY,"");return(typeof v3==="string"?v3.trim():"")||(worktreeKind()==="custom"?worktreeBasePath().trim():"")}function cycleWorktreeBase(){let kind=worktreeKind();if(kind==="default")kv.set(WORKTREE_BASE_KEY,PROJECT_SIBLING_BASE);else if(kind==="nextToProject")kv.set(WORKTREE_BASE_KEY,worktreeCustomPath());else kv.set(WORKTREE_BASE_CUSTOM_KEY,worktreeBasePath().trim()),kv.set(WORKTREE_BASE_KEY,"")}async function editWorktreeCustom(){let next=await RenameTaskDialog.show(dialog,worktreeCustomPath(),{dialogTitle:t3("settings.general.worktreeBaseTitle"),fieldLabel:t3("settings.general.worktreeBaseField"),submitLabel:t3("settings.action.save"),placeholder:`${PROJECT_DIR_TOKEN}/../worktrees`,allowEmpty:!0});if(next===void 0)return;let raw=next.trim();if(raw.includes(PROJECT_DIR_TOKEN)){if(!hasProjectDirToken(raw)){await DialogConfirm.show(dialog,t3("settings.general.worktreeBaseInvalidTitle"),t3("settings.general.worktreeBaseTokenBody",{token:PROJECT_DIR_TOKEN}),"cancel");return}}else if(raw){let resolved=normalizeWorktreeBase(raw)??raw;try{mkdirSync4(resolved,{recursive:!0}),accessSync(resolved,fsConstants.W_OK)}catch(err){await DialogConfirm.show(dialog,t3("settings.general.worktreeBaseInvalidTitle"),t3("settings.general.worktreeBaseUnusableBody",{path:resolved,error:errorMessage(err)}),"cancel");return}}if(kv.set(WORKTREE_BASE_CUSTOM_KEY,raw),raw)kv.set(WORKTREE_BASE_KEY,raw);else if(worktreeKind()==="custom")kv.set(WORKTREE_BASE_KEY,"")}return{toastEnabled,toggleToast,soundEnabled,soundVolume,cycleSoundVolume,toggleSound,crossTaskEnabled,toggleCrossTask,prefixTapPresentation,selectPrefixTapPresentation,splitStyle,selectSplitStyle,zenDefaultOn,toggleZenDefaultOn,remoteProjectsEnabled,toggleRemoteProjects,autoStatusOn,toggleAutoStatus,dispatcherOn,toggleDispatcher,editorKind,cycleEditorKind,editorCustomCommand,editEditorCustom,scrollbackRows,editScrollbackRows,tabStripMode,cycleTabStripMode,worktreeKind,worktreeKindLabel,worktreeCustomPath,cycleWorktreeBase,editWorktreeCustom}}var EMPTY_USAGE_SIGNAL=createStateCell(null);function SettingsDialog(props){let dialog=useDialog(),themeCtx=useTheme(),renderer=useRenderer(),{theme}=themeCtx,t3=useT(),padX=useDialogPaddingX(),[level,setLevel]=import_react57.useState("sidebar"),[section,setSection]=import_react57.useState("general"),[cursor,setCursor]=import_react57.useState(0),[bodyRow,setBodyRow]=import_react57.useState(0),[feedbackTitle,setFeedbackTitle]=import_react57.useState(""),[feedbackBody,setFeedbackBody]=import_react57.useState(""),[feedbackStatus,setFeedbackStatus]=import_react57.useState(""),themeNames=import_react57.useMemo(()=>themeCtx.all().slice().sort(),[themeCtx]),hasDaemon=hasRestartableDaemon(props.orchestrator),remote=props.orchestrator instanceof RemoteOrchestrator?props.orchestrator:null,prefs=useSettingsPrefs(props.kv,dialog),engines=useEngineSettings(props.kv,dialog,(max)=>setBodyRow((r6)=>Math.max(0,Math.min(r6,max)))),usage=useAccessor(remote?remote.usageSnapshotSignal():EMPTY_USAGE_SIGNAL),engineStatuses=useAccountProbes(section,engines.engineList()),[keysFileExists,setKeysFileExists]=import_react57.useState(()=>userKeybindingsReport().exists);function createKeysFile(){try{createKeybindingsFile(userKeybindingsReport().path),reloadUserKeybindings()}catch{}setKeysFileExists(userKeybindingsReport().exists)}let plugins=usePluginSettings(section,dialog);function bodyRows(){return sectionRows(section,{themeNames,focusAccentSlots:FOCUS_ACCENT_SLOTS,engineList:engines.engineList(),plugins:plugins.rows.map((p3)=>({id:p3.id,settingKeys:p3.settings.map((s2)=>s2.key)})),hasDaemon,keybindingsFileExists:keysFileExists})}function bodyRowCount(){return bodyRows().length}function selectTheme(name){if(themeCtx.selected===name)return;if(!themeCtx.set(name))return;props.kv.set("activeTheme",name)}function selectLanguage(locale){if(currentLang()===locale)return;setLocaleLang(locale),props.kv.set(LOCALE_KEY,locale)}function toggleTransparent(){let next=!themeCtx.transparentBackground;themeCtx.setTransparentBackground(next),props.kv.set("transparentBackground",next)}function selectFocusAccent(slot){if(themeCtx.focusAccent===slot)return;themeCtx.setFocusAccent(slot),props.kv.set("focusAccent",slot)}function currentEngineRow(){if(section!=="engines"||level!=="body")return null;let row=rowAt(bodyRows(),bodyRow);return row?.kind==="engine"?row.vendor:null}async function sendFeedback(){setFeedbackStatus("submitting...");try{let result=submitFeedback({title:feedbackTitle,body:feedbackBody});setFeedbackStatus(`sent: ${result.url}`),setFeedbackTitle(""),setFeedbackBody(""),setBodyRow(0)}catch(err){setFeedbackStatus(`error: ${errorMessage(err)}`)}}let editingFeedback=section==="feedback"&&level==="body";function feedbackFieldStep(delta){let next=bodyRow+delta;if(next<0||next>2){setLevel("sidebar");return}setBodyRow(next)}function enterBody(){if(level!=="sidebar"||bodyRowCount()===0)return;setLevel("body"),setBodyRow(0)}function moveCursor(delta){if(level==="sidebar"){let next=(cursor+delta+SECTIONS.length)%SECTIONS.length;setCursor(next);let nextSection=SECTIONS[next];if(nextSection)setSection(nextSection.id),setBodyRow(0);return}let len=bodyRowCount();if(len===0)return;setBodyRow((bodyRow+delta+len)%len)}function switchSection(id){setSection(id),setCursor(SECTIONS.findIndex((s2)=>s2.id===id)),setBodyRow(0),setLevel("sidebar")}let rowActivators={theme:(row)=>selectTheme(row.name),language:(row)=>selectLanguage(row.locale),transparent:()=>toggleTransparent(),focusAccent:(row)=>selectFocusAccent(row.slot),toast:()=>prefs.toggleToast(),sound:()=>prefs.toggleSound(),soundVolume:()=>prefs.cycleSoundVolume(),crossTask:()=>prefs.toggleCrossTask(),keyHints:()=>toggleKeyHints(props.kv),prefixTapPresentation:(row)=>prefs.selectPrefixTapPresentation(row.presentation),splitStyle:(row)=>prefs.selectSplitStyle(row.style),zenDefaultOn:()=>prefs.toggleZenDefaultOn(),editorKind:()=>prefs.cycleEditorKind(),editorCustom:()=>void prefs.editEditorCustom(),worktreeBase:()=>prefs.cycleWorktreeBase(),worktreeCustom:()=>void prefs.editWorktreeCustom(),scrollbackRows:()=>void prefs.editScrollbackRows(),tabStripHideSingle:()=>prefs.cycleTabStripMode(),engine:(row)=>void engines.editEngine(row.vendor),engineAdd:()=>void engines.addEngineFlow(),keysCreate:()=>createKeysFile(),pluginToggle:(row)=>plugins.toggle(row.pluginId),pluginSetting:(row)=>void plugins.editSetting(row.pluginId,row.key),feedbackTitle:()=>setBodyRow(0),feedbackBody:()=>setBodyRow(1),feedbackSend:()=>void sendFeedback(),devReset:()=>void confirmResetState(dialog,props.kv,renderer),devRestartDaemon:()=>void confirmRestartDaemon(dialog,props.orchestrator,renderer),devRemoteProjects:()=>prefs.toggleRemoteProjects(),devAutoStatus:()=>prefs.toggleAutoStatus(),devDispatcher:()=>prefs.toggleDispatcher()};function activateBodyRow(){let row=rowAt(bodyRows(),bodyRow);if(!row)return;rowActivators[row.kind](row)}useBindings(()=>({enabled:dialog.stack.length===0&&!editingFeedback,bindings:[{key:"down",cmd:()=>moveCursor(1)},{key:"up",cmd:()=>moveCursor(-1)},{key:"j",cmd:()=>moveCursor(1)},{key:"k",cmd:()=>moveCursor(-1)},{key:"tab",cmd:()=>moveCursor(1)},{key:"right",cmd:enterBody},{key:"l",cmd:enterBody},{key:"left",cmd:()=>setLevel("sidebar")},{key:"h",cmd:()=>setLevel("sidebar")},{key:"return",cmd:()=>{if(level==="sidebar"){enterBody();return}activateBodyRow()}},{key:"r",cmd:()=>{let v3=currentEngineRow();if(v3)engines.renameEngine(v3)}},{key:"x",cmd:()=>{let v3=currentEngineRow();if(v3)engines.resetEngine(v3)}},{key:"d",cmd:()=>{let v3=currentEngineRow();if(v3)engines.chooseDefaultEngine(v3)}},{key:"space",cmd:()=>{let v3=currentEngineRow();if(v3)engines.toggleEngineEnabled(v3)}}]})),useBindings(()=>({enabled:editingFeedback,bindings:[{key:"tab",cmd:()=>feedbackFieldStep(1)},{key:"shift+tab",cmd:()=>feedbackFieldStep(-1)}]})),useBindings(()=>({enabled:editingFeedback&&bodyRow===2,bindings:[{key:"return",cmd:()=>void sendFeedback()}]}));let follow=useCursorFollow(level==="body"?bodyRow:-1),cursorProps={level,bodyRow,setLevel,setBodyRow,rowRef:follow.rowRef},navHint=$jsx("box",{paddingTop:0,children:$jsx("text",{fg:theme.textMuted,children:editingFeedback?t3("settings.nav.feedback"):t3("settings.nav.default")})}),body=$jsxs("box",{paddingLeft:padX,paddingRight:padX,paddingBottom:1,gap:1,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsx("text",{attributes:TextAttributes23.BOLD,fg:theme.text,children:t3("settings.title")}),$jsx("text",{fg:theme.textMuted,onMouseUp:()=>props.onClose(),children:t3("settings.esc")})]}),$jsxs("box",{flexDirection:"row",gap:2,children:[$jsx(SettingsSectionSidebar,{level,cursor,switchSection}),$jsxs("box",{flexGrow:1,flexShrink:1,flexDirection:"column",gap:1,children:[section==="general"?$jsx(GeneralSettingsSection,{...cursorProps,prefs,themeNames,selectTheme,currentLocale:currentLang(),selectLanguage,toggleTransparent,selectFocusAccent,usage}):null,section==="engines"?$jsx(EngineSettingsSection,{...cursorProps,vendors:engines.engineList(),statuses:engineStatuses,isCustom:engines.isCustomEngine,engineProtocol:engines.engineProtocol,isEnabled:engines.isEngineEnabled,toggleEngine:engines.toggleEngineEnabled,chooseDefault:engines.chooseDefaultEngine,displayName:engines.engineName,commandText:engines.engineCommandText,isDefault:engines.engineIsDefault,isDefaultEngine:(v3)=>engines.defaultEngine===v3,editEngine:(v3)=>void engines.editEngine(v3),onAddEngine:()=>void engines.addEngineFlow()}):null,section==="plugins"?$jsx(PluginSettingsSection,{...cursorProps,plugins:plugins.rows,toggle:plugins.toggle,editSetting:(id,key)=>void plugins.editSetting(id,key)}):null,section==="keys"?$jsx(KeybindingsSettingsSection,{...cursorProps,prefs,onCreateFile:createKeysFile}):null,section==="feedback"?$jsx(FeedbackSettingsSection,{...cursorProps,title:feedbackTitle,setTitle:(v3)=>{setFeedbackTitle(v3),setFeedbackStatus("")},body:feedbackBody,setBody:(v3)=>{setFeedbackBody(v3),setFeedbackStatus("")},status:feedbackStatus,onTitleSubmit:()=>setBodyRow(1),submit:()=>void sendFeedback()}):null,section==="dev"?$jsx(DevSettingsSection,{...cursorProps,prefs,hasDaemon,confirmReset:()=>void confirmResetState(dialog,props.kv,renderer),confirmRestartDaemon:()=>void confirmRestartDaemon(dialog,props.orchestrator,renderer)}):null]})]})]});return $jsxs("box",{flexDirection:"column",flexGrow:1,children:[$jsx("scrollbox",{ref:follow.scrollRef,flexGrow:1,flexShrink:1,flexBasis:0,verticalScrollbarOptions:{trackOptions:{foregroundColor:"transparent"}},children:body}),$jsx("box",{paddingLeft:padX,paddingRight:padX,children:navHint})]})}import{TextAttributes as TextAttributes24}from"@opentui/core";var import_react58=__toESM(require_react_production(),1);function reposOf(orch){if(!orch)return[];let seen=[];for(let task of orch.listTasks())if(task.repo&&!seen.some((repo)=>samePath(repo,task.repo)))seen.push(task.repo);return seen}function linkedTaskFor(orch,repo,number){return orch?.listTasks().find((task)=>samePath(task.repo,repo)&&task.linkedWorkItem?.number===number)}function errorHint(error,t3){let colon=error.indexOf(": ");switch(colon>=0?error.slice(0,colon):"failed"){case"no-remote":return t3("workItems.errorHint.noRemote");case"gh-missing":return t3("workItems.errorHint.ghMissing");case"auth":return t3("workItems.errorHint.auth");default:return t3("workItems.errorHint.fallback",{message:error})}}function relativeAge2(iso,now){let at2=Date.parse(iso);if(!Number.isFinite(at2))return"";return relativeAge(at2,now)}function WorkItemsPage(props){let{theme}=useTheme(),t3=useT(),notif=useNotifications();function notifyError(message){notif.notify({kind:"error",taskId:"",tabId:"",title:message})}let repos=reposOf(props.orchestrator),[repoIndex,setRepoIndex]=import_react58.useState(()=>{let wanted=props.focusRepo?repos.findIndex((repo2)=>samePath(repo2,props.focusRepo)):-1;return wanted>=0?wanted:0}),repo=repos[repoIndex],[items,setItems]=import_react58.useState(null),[error,setError]=import_react58.useState(null),[reloadTick,setReloadTick]=import_react58.useState(0),[assignedToMe,setAssignedToMe]=import_react58.useState(!1),[starting,setStarting]=import_react58.useState(!1),[notice,setNotice]=import_react58.useState(null);import_react58.useEffect(()=>{let disposed=!1,orch=props.orchestrator;if(!orch||!repo){setItems([]);return}return setError(null),orch.listWorkItems({repo,limit:30,...assignedToMe?{assignee:"@me"}:{},...reloadTick>0?{refresh:!0}:{}}).then((result)=>{if(!disposed)setItems(result.items)}).catch((err)=>{if(disposed)return;setError(err instanceof Error?err.message:String(err)),setItems([])}),()=>{disposed=!0}},[props.orchestrator,repo,assignedToMe,reloadTick]);let rows=items??[],[cursor,setCursor]=import_react58.useState(0);import_react58.useEffect(()=>{setCursor((c2)=>clampCursor(c2,rows.length))},[rows.length]);let follow=useCursorFollow(cursor);import_react58.useEffect(()=>{setNotice(null)},[repo,assignedToMe]);async function startSelected(){let orch=props.orchestrator,item=rows[cursor];if(!orch||!item||!repo||starting)return;let linked=linkedTaskFor(orch,repo,item.number);if(linked){setNotice(t3("workItems.openingLinked",{title:linked.title})),props.onOpenTask?.(linked.id);return}setStarting(!0),setNotice(t3("workItems.starting",{number:item.number}));try{let result=await orch.startWorkItem({repo,number:item.number});if(result.started)props.onOpenTask?.(result.taskId);else setNotice(t3("workItems.startedNoEngine",{title:result.title}))}catch(err){console.error("[rove work-items] start failed:",err),notifyError(t3("workItems.startFailed",{number:item.number,error:errorMessage(err)}))}finally{setStarting(!1)}}useBindings(()=>({enabled:props.focused!==!1,bindings:[...pageCloseBindings(props.onClose),{key:"j",cmd:()=>setCursor((c2)=>clampCursor(c2+1,rows.length))},{key:"down",cmd:()=>setCursor((c2)=>clampCursor(c2+1,rows.length))},{key:"k",cmd:()=>setCursor((c2)=>clampCursor(c2-1,rows.length))},{key:"up",cmd:()=>setCursor((c2)=>clampCursor(c2-1,rows.length))},{key:"tab",cmd:()=>setRepoIndex((i2)=>repos.length?(i2+1)%repos.length:0)},{key:"a",cmd:()=>setAssignedToMe((on)=>!on)},{key:"r",cmd:()=>setReloadTick((tick)=>tick+1)},{key:"return",cmd:()=>void startSelected()}]}));let now=Date.now();return $jsxs("box",{flexDirection:"column",flexGrow:1,paddingTop:1,paddingBottom:1,paddingLeft:2,paddingRight:2,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsx("text",{attributes:TextAttributes24.BOLD,fg:theme.text,children:t3("workItems.title")}),$jsxs("text",{fg:theme.textMuted,children:[repo?sidebarProjectLabel(repo,repos):t3("workItems.noRepo"),assignedToMe?` ${t3("workItems.assignedFilter")}`:""]})]}),error?$jsxs("box",{flexDirection:"column",marginTop:1,children:[$jsx("text",{fg:theme.error,children:error}),$jsx("box",{marginTop:1,children:$jsx("text",{fg:theme.textMuted,children:errorHint(error,t3)})})]}):items===null?$jsx("text",{fg:theme.textMuted,children:t3("common.loading")}):rows.length===0?$jsx("text",{fg:theme.textMuted,children:t3("workItems.empty")}):$jsx("scrollbox",{ref:follow.scrollRef,flexGrow:1,flexShrink:1,flexBasis:0,marginTop:1,verticalScrollbarOptions:{trackOptions:{foregroundColor:"transparent"}},children:rows.map((item,index)=>{let chrome=resolveRowSelectionChrome(theme,{cursor:index===cursor,selected:!1}),linked=linkedTaskFor(props.orchestrator,repo,item.number);return $jsxs("box",{ref:follow.rowRef(index),flexDirection:"column",flexShrink:0,...chrome.backgroundColor?{backgroundColor:chrome.backgroundColor}:{},children:[$jsxs("box",{flexDirection:"row",gap:0,children:[$jsx("text",{fg:chrome.markerColor,wrapMode:"none",children:chrome.marker}),$jsxs("box",{flexDirection:"row",flexGrow:1,paddingLeft:1,paddingRight:1,gap:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:`#${item.number}`}),$jsx("text",{fg:theme.text,attributes:index===cursor?TextAttributes24.BOLD:void 0,wrapMode:"none",flexGrow:1,children:item.title})]})]}),$jsxs("box",{flexDirection:"row",gap:0,children:[$jsx("text",{fg:chrome.markerColor,wrapMode:"none",children:chrome.marker}),$jsxs("box",{flexDirection:"row",flexGrow:1,paddingLeft:2,paddingRight:1,gap:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexGrow:1,children:[item.author,...item.labels.slice(0,2)].filter(Boolean).join(" \xB7 ")}),linked?$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("workItems.linkedChip",{title:linked.title})}):null,$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:relativeAge2(item.updatedAt,now)})]})]})]},`${item.number}`)})}),notice?$jsx("text",{fg:theme.textMuted,flexShrink:0,children:notice}):null]})}import{TextAttributes as TextAttributes25}from"@opentui/core";var import_react59=__toESM(require_react_production(),1);var LAND_CONFLICT_RE=/LAND_CONFLICT/,MAIN_DIRTY_RE=/MAIN_CHECKOUT_DIRTY/;async function landTaskAction(deps,taskId,branchLabel){let{t:t3}=deps,preflight;try{preflight=await deps.orchestrator.landPreflight(taskId)}catch(err){return deps.notifyError(t3("worktrees.land.failed",{error:err instanceof Error?err.message:String(err)})),console.error("[rove land] preflight failed:",err),!1}if(preflight.refusal){if(preflight.refusal==="MAIN_CHECKOUT_DIRTY")deps.notifyNeedsInput(t3("worktrees.land.dirtyBase"));else deps.notifyError(t3("worktrees.land.failed",{error:preflight.message??preflight.refusal}));return!1}let body=t3(preflight.ahead===1?"worktrees.land.confirmBodyOne":"worktrees.land.confirmBody",{branch:branchLabel,landedOn:preflight.landedOn,commits:preflight.ahead??"?"});if(!await deps.confirm(body))return!1;try{let res=await deps.orchestrator.landTask(taskId,{callerCwd:deps.callerCwd});deps.notifyInfo(t3("worktrees.land.done",{branch:res.branch,landedOn:res.landedOn,commit:res.commit}));let cleanup=res.worktree;if(cleanup&&!cleanup.removed)deps.notifyNeedsInput(t3("worktrees.land.worktreeKept",{reason:cleanup.reason??"refused"}));else if(cleanup?.reason)deps.notifyNeedsInput(t3("worktrees.land.worktreePathStale",{reason:cleanup.reason}));if(cleanup?.residue)deps.notifyNeedsInput(t3("worktrees.land.worktreeResidue",{path:cleanup.residue.path,reason:cleanup.residue.reason}));return!0}catch(err){let msg=err instanceof Error?err.message:String(err);if(LAND_CONFLICT_RE.test(msg))deps.notifyNeedsInput(t3("worktrees.land.conflict",{files:msg}));else if(MAIN_DIRTY_RE.test(msg))deps.notifyNeedsInput(t3("worktrees.land.dirtyBase"));else deps.notifyError(t3("worktrees.land.failed",{error:msg}));return console.error("[rove land] failed:",err),!1}}function flattenRows(projects){return projects.flatMap((p3)=>p3.worktrees)}function dirtyRefusalReason(err){if(!(err instanceof Error))return null;let at2=err.message.indexOf(DIRTY_WORKTREE_CODE);if(at2<0)return null;return err.message.slice(at2+DIRTY_WORKTREE_CODE.length).replace(/^:\s*/,"")}function taskIdForPath(orch,wtPath){let norm=(p3)=>p3.replace(/^\/private\//,"/");return orch.listTasks().find((task)=>task.worktreePath&&samePath(norm(task.worktreePath),norm(wtPath)))?.id}function WorktreesPage(props){let{theme}=useTheme(),dialog=useDialog(),t3=useT(),notif=useNotifications();function notifyError(message){notif.notify({kind:"error",taskId:"",tabId:"",title:message})}function notifyNeedsInput(message){notif.notify({kind:"needs_input",taskId:"",tabId:"",title:message})}function notifyInfo(message){notif.notify({kind:"done",taskId:"",tabId:"",title:message})}let[projects,setProjects]=import_react59.useState(null),[reloadTick,setReloadTick]=import_react59.useState(0),refetch=()=>setReloadTick((tick)=>tick+1);import_react59.useEffect(()=>{let disposed=!1,fullLanded=!1,orch=props.orchestrator;if(!orch){setProjects([]);return}return orch.listWorktrees({network:!1}).then((rows)=>{if(!disposed&&!fullLanded)setProjects(rows)}).catch(()=>{}),orch.listWorktrees().then((rows)=>{if(fullLanded=!0,disposed)return;setProjects(rows);let live=new Set(flattenRows(rows).map((r6)=>r6.path));setRemovingPaths((paths)=>paths.filter((p3)=>live.has(p3)))}).catch(()=>{}),()=>{disposed=!0}},[props.orchestrator,reloadTick]);let[removingPaths,setRemovingPaths]=import_react59.useState([]),visibleProjects=(projects??[]).map((p3)=>({...p3,worktrees:p3.worktrees.filter((w4)=>!removingPaths.includes(w4.path))})),flatRows=flattenRows(visibleProjects),[cursor,setCursor]=import_react59.useState(0);import_react59.useEffect(()=>{setCursor((c2)=>clampCursor(c2,flatRows.length))},[flatRows.length]);let follow=useCursorFollow(cursor),[busyPath,setBusyPath]=import_react59.useState(null);async function deleteInBackground(row,force){let orch=props.orchestrator;if(!orch)return;setRemovingPaths((paths)=>[...paths,row.path]);try{let residue=await orch.removeWorktree(row.path,force);if(residue)notifyNeedsInput(t3("worktrees.delete.residue",{path:residue.path,reason:residue.reason}));refetch()}catch(err){setRemovingPaths((paths)=>paths.filter((p3)=>p3!==row.path));let reason=force?null:dirtyRefusalReason(err);if(reason!==null){if(await DialogConfirm.show(dialog,t3("worktrees.delete.forceTitle"),`${t3("worktrees.delete.forceBody",{branch:row.branch||row.path})}
107
107
 
108
108
  ${t3("worktrees.delete.forceReason",{reason})}`,t3("common.cancel"),t3("worktrees.delete.button"),{danger:!0})===!0)await deleteInBackground(row,!0);return}notifyError(t3("worktrees.delete.failed",{error:String(err)})),console.error("[rove worktrees] delete failed:",err)}}async function requestDelete(row){if(!props.orchestrator||busyPath||removingPaths.includes(row.path))return;if(await DialogConfirm.show(dialog,t3("worktrees.delete.confirmTitle"),t3("worktrees.delete.confirmBody",{branch:row.branch||row.path}),t3("common.cancel"),t3("worktrees.delete.button"),{danger:!0})!==!0)return;deleteInBackground(row,!1)}async function requestLand(row){let orch=props.orchestrator;if(!orch||busyPath)return;let taskId=taskIdForPath(orch,row.path);if(!taskId){notifyError(t3("worktrees.land.noTask")),console.error("[rove worktrees] land refused: no tracked task for",row.path);return}setBusyPath(row.path);try{await landTaskAction({orchestrator:orch,confirm:(body)=>DialogConfirm.show(dialog,t3("worktrees.land.confirmTitle"),body,t3("common.cancel"),t3("worktrees.land.button")).then((ok)=>ok===!0),notifyInfo,notifyNeedsInput,notifyError,t:t3,callerCwd:process.cwd()},taskId,row.branch||row.path),refetch()}finally{setBusyPath(null)}}useBindings(()=>({enabled:dialog.stack.length===0,bindings:[...pageCloseBindings(props.onClose),{key:"up",cmd:()=>setCursor((c2)=>clampCursor(c2-1,flatRows.length))},{key:"k",cmd:()=>setCursor((c2)=>clampCursor(c2-1,flatRows.length))},{key:"down",cmd:()=>setCursor((c2)=>clampCursor(c2+1,flatRows.length))},{key:"j",cmd:()=>setCursor((c2)=>clampCursor(c2+1,flatRows.length))},{key:"d",cmd:()=>{let row=flatRows[cursor];if(row)requestDelete(row)}},{key:"l",cmd:()=>{let row=flatRows[cursor];if(row)requestLand(row)}}]}));function remoteBadge(status){if(status===!0)return $jsxs("text",{fg:theme.success,children:[" ",t3("worktrees.badge.remoteOn")]});if(status===!1)return $jsxs("text",{fg:theme.warning,children:[" ",t3("worktrees.badge.remoteOff")]});return $jsxs("text",{fg:theme.textMuted,children:[" ",t3("worktrees.badge.remoteUnknown")]})}function verdictBadge(row){if(row.verdictReason==="dirty"||row.verdictReason==="fresh")return null;let fg=row.verdict==="merged"?theme.success:row.verdict==="stale"?theme.warning:theme.accent;return $jsxs("text",{fg,children:[" ",t3(`worktrees.verdict.${row.verdictReason}`)]})}let loading=projects===null,rowBase=0;return $jsxs("scrollbox",{ref:follow.scrollRef,flexGrow:1,backgroundColor:theme.background,paddingTop:1,paddingLeft:2,paddingRight:2,paddingBottom:1,verticalScrollbarOptions:{trackOptions:{foregroundColor:"transparent"}},children:[$jsx("box",{flexDirection:"row",justifyContent:"space-between",children:$jsx("text",{attributes:TextAttributes25.BOLD,fg:theme.text,children:t3("worktrees.title")})}),loading?$jsx("text",{fg:theme.textMuted,children:t3("worktrees.loading")}):visibleProjects.length===0?$jsx("text",{fg:theme.textMuted,children:t3("worktrees.noProjects")}):visibleProjects.map((project)=>{let base=rowBase;return rowBase+=project.worktrees.length,$jsxs("box",{gap:0,paddingTop:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:project.repo}),project.worktrees.length===0?$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("worktrees.noWorktrees")}):project.worktrees.map((row,i2)=>{let absoluteIndex=base+i2,isCursor=absoluteIndex===cursor,chrome=resolveRowSelectionChrome(theme,{cursor:isCursor});return $jsxs("box",{ref:follow.rowRef(absoluteIndex),gap:0,backgroundColor:chrome.backgroundColor,onMouseUp:()=>setCursor(absoluteIndex),children:[$jsxs("box",{flexDirection:"row",children:[$jsx("text",{fg:chrome.markerColor,wrapMode:"none",children:chrome.marker}),$jsx("text",{fg:theme.text,attributes:isCursor?TextAttributes25.BOLD:void 0,wrapMode:"none",children:` ${row.branch||t3("worktrees.row.detached")}`}),row.kobeManaged?$jsxs("text",{fg:theme.textMuted,children:[" ",t3("worktrees.badge.kobeManaged")]}):null,row.dirty===!0?$jsxs("text",{fg:theme.warning,children:[" ",t3("worktrees.badge.dirty")]}):null,row.dirty===null?$jsxs("text",{fg:theme.textMuted,children:[" ",t3("worktrees.badge.dirtyUnknown")]}):null,remoteBadge(row.branchOnRemote),verdictBadge(row),busyPath===row.path?$jsx("text",{fg:theme.textMuted,children:" \u2026"}):null]}),$jsxs("box",{flexDirection:"row",children:[$jsx("text",{fg:chrome.markerColor,wrapMode:"none",children:chrome.marker}),$jsxs("box",{flexDirection:"row",justifyContent:"space-between",flexGrow:1,paddingLeft:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:row.path}),row.createdAtMs>0?$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("worktrees.row.created",{age:relativeAge(row.createdAtMs)})}):null]})]})]},row.path)})]},project.repo)})]})}function useHostPagesState(focus){let[settingsOpen,setSettingsOpen]=import_react60.useState(!1),[worktreesOpen,setWorktreesOpen]=import_react60.useState(!1),[updateOpen,setUpdateOpen]=import_react60.useState(!1),[nav,setNav]=import_react60.useState("terminal"),goToNav=(next)=>{setNav(next),focus.setFocused(focusPaneForNav(next))};return{nav,setNav,goToNav,settingsOpen,openSettings:()=>setSettingsOpen(!0),closeSettings:()=>setSettingsOpen(!1),worktreesOpen,openWorktrees:()=>setWorktreesOpen(!0),closeWorktrees:()=>setWorktreesOpen(!1),updateOpen,openUpdate:()=>setUpdateOpen(!0),closeUpdate:()=>setUpdateOpen(!1),kanbanOpen:nav==="kanban",openKanban:()=>goToNav("kanban"),closeKanban:()=>goToNav("terminal"),automationsOpen:nav==="automations",openAutomations:()=>goToNav("automations"),closeAutomations:()=>goToNav("terminal"),workItemsOpen:nav==="issues",openWorkItems:()=>goToNav("issues"),closeWorkItems:()=>goToNav("terminal")}}function renderFullWindowPage(deps){if(deps.worktreesOpen)return $jsx(WorktreesPage,{orchestrator:deps.orchestrator,onClose:deps.closeWorktrees});if(deps.updateOpen)return $jsx(UpdatePage,{onClose:deps.closeUpdate});return null}function renderContentPage(deps){let orch=deps.orchestrator;if(deps.automationsOpen)return $jsx(AutomationsPage,{orchestrator:orch,focused:deps.contentFocused,...deps.selectedTask?{focusRepo:deps.selectedTask.repo}:{},onClose:deps.closeAutomations,onOpenTask:(taskId)=>{deps.closeAutomations(),deps.activateTask(taskId)}});if(deps.workItemsOpen)return $jsx(WorkItemsPage,{orchestrator:orch,focused:deps.contentFocused,onClose:deps.closeWorkItems,...deps.selectedTask?{focusRepo:deps.selectedTask.repo}:{},onOpenTask:(taskId)=>{deps.closeWorkItems(),deps.activateTask(taskId)}});if(deps.kanbanOpen)return $jsx(KanbanPage,{orchestrator:orch,focused:deps.contentFocused,onClose:deps.closeKanban,onStartChat:deps.startIssueChat,engineStates:deps.engineStates,focusTask:deps.selectedTask?{id:deps.selectedTask.id,repo:deps.selectedTask.repo}:void 0,onOpenTask:(taskId)=>{deps.closeKanban(),deps.activateTask(taskId)}});return null}function useHostPagesRender(opts){let{orchestrator,pages,focus,dialog,kv,dims,selectedTask,activeTaskId,tasks,engineState,startIssueChat,activateTask}=opts,activePane=dialog.stack.length>0?null:focus.focused,pageDeps=import_react60.useMemo(()=>({orchestrator,selectedTask,worktreesOpen:pages.worktreesOpen,automationsOpen:pages.automationsOpen,workItemsOpen:pages.workItemsOpen,kanbanOpen:pages.kanbanOpen,updateOpen:pages.updateOpen,closeWorktrees:pages.closeWorktrees,closeAutomations:pages.closeAutomations,closeWorkItems:pages.closeWorkItems,closeKanban:pages.closeKanban,closeUpdate:pages.closeUpdate,activateTask:(taskId)=>void activateTask(taskId),startIssueChat,engineStates:engineState,contentFocused:activePane==="workspace"}),[orchestrator,selectedTask,pages,startIssueChat,engineState,activePane,activateTask]),fullWindowPage=import_react60.useMemo(()=>renderFullWindowPage(pageDeps),[pageDeps]),contentPage=import_react60.useMemo(()=>renderContentPage(pageDeps),[pageDeps]),narrow=isNarrowWidth(dims.width);import_react60.useEffect(()=>{if(narrow&&focus.focused==="files")focus.setFocused("workspace")},[narrow,focus]);let surface=narrow?narrowSurface({focusedPane:focus.focused,hasSelection:selectedTask!=null,hasOpenPage:contentPage!=null}):null,showSidebar=surface!=="content",showContent=surface!=="sidebar",recentTask=import_react60.useMemo(()=>(narrow?tasks.find((task)=>task.id===activeTaskId&&!task.deletion):null)??null,[narrow,tasks,activeTaskId]);return{settingsPage:pages.settingsOpen?$jsx("box",{flexGrow:1,backgroundColor:"transparent",paddingTop:1,children:$jsx(SettingsDialog,{kv,orchestrator,onClose:pages.closeSettings})}):null,fullWindowPage,contentPage,showSidebar,showContent,recentTask}}var import_react73=__toESM(require_react_production(),1);var import_react72=__toESM(require_react_production(),1);function createSidebarController(opts){let schedule=opts.scheduleTimeout??((cb,ms)=>{let t3=setTimeout(cb,ms);return()=>clearTimeout(t3)}),pendingG=!1,cancelTimer=null,armChord=()=>{pendingG=!0,cancelTimer?.(),cancelTimer=schedule(()=>{pendingG=!1,cancelTimer=null},700)},disarm=()=>{pendingG=!1,cancelTimer?.(),cancelTimer=null},move=(delta)=>{let ids=opts.getFlatIds();if(ids.length===0)return;let cur=opts.getCursor(),start=cur<0?0:cur,next=Math.min(ids.length-1,Math.max(0,start+delta));opts.setCursor(next)},jumpTo=(index)=>{let ids=opts.getFlatIds();if(ids.length===0)return;opts.setCursor(Math.min(ids.length-1,Math.max(0,index)))};return{moveDown(){disarm(),move(1)},moveUp(){disarm(),move(-1)},selectCurrent(){disarm();let ids=opts.getFlatIds(),cur=opts.getCursor();if(cur<0||cur>=ids.length)return;let id=ids[cur];if(id!==void 0)opts.onSelect(id)},pressG(){if(pendingG)disarm(),jumpTo(0);else armChord()},pressShiftG(){disarm(),jumpTo(opts.getFlatIds().length-1)},isChordArmed(){return pendingG},disarmChord(){disarm()}}}import{homedir}from"os";function rowHaystacks(row,liveBranch){if(row.kind==="project")return[row.label];if(row.kind==="routines")return[];if(row.kind==="tab")return[row.tab.label];let task=row.task,title=task.kind==="dir"?"":task.title;return[worktreeRowLabel(task,{liveBranch:liveBranch?.(task)}),title,repoBasename(task.repo)]}function matchesRow(query,row,liveBranch){return rowHaystacks(row,liveBranch).some((field)=>field!==""&&fuzzyMatch(query,field))}function filterTreeRows(rows,query,liveBranch){let q2=query.trim();if(q2==="")return[...rows];let selfMatch=new Set,keep=new Set;for(let row of rows){if(!matchesRow(q2,row,liveBranch))continue;if(selfMatch.add(row.id),keep.add(row.id),row.kind==="project"||row.kind==="routines")continue;if(row.kind==="tab")keep.add(row.task.id);let project=ownerProjectKey(row.task);if(project!==null)keep.add(project)}let out=[];for(let row of rows){if(row.kind==="project"){if(keep.has(row.id))out.push(row);continue}if(row.kind==="routines")continue;let project=ownerProjectKey(row.task),underMatchedProject=project!==null&&selfMatch.has(project);if(row.kind==="worktree"){if(underMatchedProject||keep.has(row.id))out.push(row);continue}if(underMatchedProject||selfMatch.has(row.task.id)||keep.has(row.id))out.push(row)}return out}function tabRowActivity(args){if(args.tabActivity!==void 0)return args.tabActivity;if(!args.active||args.reportedTabCount>0)return;return args.taskActivity}var TAB_ROW_SEPARATOR="::",RECENT_ROW_ID="~recent",SCRATCH_SECTION_ID="~scratch";function routinesRowId(projectKey){return`~routines:${projectKey}`}function projectKeyOfRoutinesRow(id){return id.startsWith("~routines:")?id.slice(10):null}function isRoutineTask(task){return task.routine!==void 0}function withRecentRow(rows,recent){if(!recent)return[...rows];return[{kind:"recent",id:RECENT_ROW_ID,task:recent,depth:1},...rows]}function tabRowId(taskId,tabId){return`${taskId}${TAB_ROW_SEPARATOR}${tabId}`}function parseRowId(rowId){let at2=rowId.indexOf(TAB_ROW_SEPARATOR);if(at2<0)return{taskId:rowId,tabId:null};return{taskId:rowId.slice(0,at2),tabId:rowId.slice(at2+TAB_ROW_SEPARATOR.length)}}var PATH_LABEL_MAX=24;function rowLiveBranchPath(task){if(task.kind!=="main"&&task.kind!=="dir")return"";return task.worktreePath||task.repo||""}function worktreeRowLabel(task,opts={}){let branch=(opts.liveBranch??task.branch)||task.branch;if(branch)return branch;if(task.kind!=="dir"&&task.title)return task.title;let path=task.worktreePath||task.repo;if(path){let home=opts.home??homedir(),tildified=tildify(path,home);return truncateStart(tildified,PATH_LABEL_MAX)}return task.title||"scratch"}function isClosedDownProject(tasks,tabsByTask2){let only=tasks.length===1?tasks[0]:void 0;if(!only||only.kind!=="main"&&only.kind!=="dir")return!1;return tabsByTask2.get(only.id)?.length===0}function buildTreeRows(input){let{tasks,tabsByTask:tabsByTask2}=input,sortMode=input.sortMode??"default",byProject=new Map,scratchTasks=tasks.filter((task)=>task.kind==="dir"&&task.scratch===!0);if(sortMode==="recent")scratchTasks.sort(compareRecent);for(let task of tasks){if(task.kind==="dir"&&task.scratch===!0)continue;let key=sidebarProjectKey(task.repo),entry=byProject.get(key)??{repo:task.repo,tasks:[]};if(task.kind==="main")entry.repo=task.repo,entry.tasks.unshift(task);else entry.tasks.push(task);byProject.set(key,entry)}let orderedKeys=[],seen=new Set;for(let task of tasks){if(task.kind!=="main")continue;let key=sidebarProjectKey(task.repo);if(!seen.has(key))seen.add(key),orderedKeys.push(key)}for(let key of byProject.keys())if(!seen.has(key))seen.add(key),orderedKeys.push(key);if(sortMode==="recent")for(let entry of byProject.values())entry.tasks.sort((a2,b3)=>{if(a2.kind==="main"&&b3.kind!=="main")return-1;if(b3.kind==="main"&&a2.kind!=="main")return 1;return compareRecent(a2,b3)});let rows=[];if(scratchTasks.length>0){rows.push({kind:"project",id:SCRATCH_SECTION_ID,repo:"",label:"Scratch",depth:0});for(let task of scratchTasks){let tabs=tabsByTask2.get(task.id)??[];if(tabs.length===0){rows.push({kind:"worktree",id:task.id,task,depth:1});continue}for(let tab of tabs)rows.push({kind:"tab",id:tabRowId(task.id,tab.id),task,tab,depth:2})}}let visibleKeys=orderedKeys.filter((key)=>{let entry=byProject.get(key);return entry?!isClosedDownProject(entry.tasks,tabsByTask2):!1}),projectRepos=visibleKeys.map((key)=>byProject.get(key)?.repo??"");for(let key of visibleKeys){let entry=byProject.get(key);if(!entry)continue;rows.push({kind:"project",id:key,repo:entry.repo,label:sidebarProjectLabel(entry.repo,projectRepos),depth:0});let routineTasks=entry.tasks.filter(isRoutineTask);for(let task of entry.tasks)if(!isRoutineTask(task))pushWorktree(rows,task,tabsByTask2);if(routineTasks.length>0){let expanded=input.expandedRoutines?.has(key)===!0;if(rows.push({kind:"routines",id:routinesRowId(key),projectKey:key,count:routineTasks.length,expanded,depth:1}),expanded)for(let task of routineTasks)pushWorktree(rows,task,tabsByTask2)}}return rows}function pushWorktree(rows,task,tabsByTask2){rows.push({kind:"worktree",id:task.id,task,depth:1});for(let tab of tabsByTask2.get(task.id)??[])rows.push({kind:"tab",id:tabRowId(task.id,tab.id),task,tab,depth:2})}function treeFlatIds(rows){let ids=[];for(let row of rows)if(row.kind!=="project")ids.push(row.id);return ids}function ownerProjectKey(task){if(task.kind==="dir"&&task.scratch===!0)return SCRATCH_SECTION_ID;return sidebarProjectKey(task.repo)}function projectKeysOf(tasks){let keys=[],seen=new Set;for(let task of tasks){let key=ownerProjectKey(task);if(key===null||seen.has(key))continue;seen.add(key),keys.push(key)}return keys}function mainTaskIdOfProject(tasks,projectKey){for(let task of tasks){if(task.kind!=="main")continue;if(sidebarProjectKey(task.repo)===projectKey)return String(task.id)}return null}import{TextAttributes as TextAttributes26}from"@opentui/core";var SIDEBAR_HOVER_TOOLTIP_Z_INDEX=2750,SIDEBAR_HOVER_TOOLTIP_MAX_WIDTH=72;function resolveSidebarHoverTooltipLayout(opts){let maxWidth=opts.maxWidth??SIDEBAR_HOVER_TOOLTIP_MAX_WIDTH,widest=Math.max(1,...opts.lines.map((line)=>approxCellWidth(line.text))),innerWidth=Math.min(maxWidth-4,widest),boxWidth=innerWidth+4,boxHeight=opts.lines.length+2;return{innerWidth,boxWidth,boxHeight,left:Math.max(0,Math.min(opts.hoverX+2,opts.screenWidth-boxWidth-1)),top:Math.max(0,Math.min(opts.hoverY+1,opts.screenHeight-boxHeight-1))}}function truncateTitle(title,max){return truncateEndCells(title,max,approxCharCells)}var CONTEXT_MENU_Z_INDEX=SIDEBAR_HOVER_TOOLTIP_Z_INDEX+10;function capCells(entry){return entry.cap?approxCellWidth(entry.cap)+1:0}function ContextMenu(props){let{theme}=useTheme();if(props.entries.length===0)return null;let layout=resolveSidebarHoverTooltipLayout({hoverX:props.x,hoverY:props.y,screenWidth:props.dims.width,screenHeight:props.dims.height,lines:props.entries.map((entry)=>({text:entry.label+" ".repeat(capCells(entry))}))});return $jsx("box",{position:"absolute",zIndex:CONTEXT_MENU_Z_INDEX,left:layout.left,top:layout.top,width:layout.boxWidth,flexDirection:"column",...FRAME,borderColor:theme.focusAccent,backgroundColor:theme.backgroundMenu,paddingLeft:1,paddingRight:1,onMouseDown:(e2)=>e2.stopPropagation(),children:props.entries.map((entry,i2)=>{let active=i2===props.cursor;return $jsxs("box",{flexShrink:0,flexDirection:"row",backgroundColor:active?theme.focusAccent:void 0,onMouseUp:()=>props.onPick(entry.id),children:[$jsx("text",{fg:active?theme.selectedListItemText:entry.danger?theme.error:theme.text,attributes:active?TextAttributes26.BOLD:void 0,wrapMode:"none",flexGrow:1,children:truncateTitle(entry.label,layout.innerWidth-capCells(entry))}),entry.cap?$jsx("text",{fg:active?theme.selectedListItemText:theme.textMuted,attributes:active?void 0:TextAttributes26.DIM,wrapMode:"none",flexShrink:0,children:entry.cap}):null]},entry.id)})})}import{MouseButton,TextAttributes as TextAttributes27}from"@opentui/core";function zenChipGlyph(platform2=process.platform){return platform2==="darwin"?"\u262F":"\u25D0"}function SectionHeader(props){let{theme,transparentBackground}=useTheme(),dividerColor=transparentBackground?theme.border:theme.borderSubtle,dims=useTerminalDimensions();return $jsxs("box",{flexDirection:"column",flexShrink:0,children:[props.topPad?$jsx("box",{flexShrink:0,children:$jsx("text",{wrapMode:"none",children:" "})}):null,$jsxs("box",{flexDirection:"row",flexShrink:0,gap:1,paddingLeft:1,paddingRight:1,onMouseUp:props.onPress||props.onContextMenu?(evt)=>{if(evt.button===MouseButton.RIGHT&&props.onContextMenu){props.onContextMenu(evt.x,evt.y);return}props.onPress?.()}:void 0,children:[props.prefix?$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:0,children:props.prefix}):null,$jsx("text",{fg:theme.textMuted,attributes:TextAttributes27.BOLD,wrapMode:"none",flexShrink:0,children:props.label}),$jsx("text",{fg:dividerColor,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:dividerRule(dims.width)}),props.suffix?$jsx("text",{fg:theme.info,attributes:TextAttributes27.BOLD,wrapMode:"none",flexShrink:0,children:props.suffix}):null]})]})}function SidebarSearchInput(props){let{theme}=useTheme(),t3=useT();return $jsxs("box",{flexDirection:"row",gap:0,flexShrink:0,paddingBottom:1,paddingLeft:1,children:[$jsx("text",{fg:theme.info,wrapMode:"none",children:"/"}),$jsx("text",{fg:theme.text,wrapMode:"none",children:props.query}),$jsx("text",{fg:theme.info,attributes:TextAttributes27.BLINK,wrapMode:"none",children:"\u2588"}),props.query.length===0?$jsxs("text",{fg:theme.textMuted,wrapMode:"none",children:[" ",t3("tasks.search.placeholder")]}):$jsxs("text",{fg:theme.textMuted,wrapMode:"none",children:[" ",props.matchCount,"/",props.totalCount]})]})}function SidebarBrandHeader(props){let{theme}=useTheme();return $jsxs("box",{flexDirection:"row",justifyContent:"space-between",gap:1,flexShrink:0,paddingLeft:1,paddingRight:1,children:[$jsxs("box",{flexDirection:"row",gap:1,children:[$jsx("text",{fg:props.focused?theme.focusAccent:theme.textMuted,attributes:TextAttributes27.BOLD,wrapMode:"none",children:"ROVE"}),props.status?$jsxs("box",{position:"relative",onMouseUp:()=>props.onStatusClick?.(),children:[$jsx("text",{fg:props.status.emphasize?theme.warningOnHost:theme.textMuted,attributes:props.status.emphasize?TextAttributes27.BOLD:TextAttributes27.DIM,wrapMode:"none",children:props.status.label}),props.onStatusClick?$jsx(ShortcutRevealBadge,{bindingId:"inbox.show"}):null]}):null]}),props.update?$jsxs("box",{position:"relative",flexShrink:0,onMouseUp:()=>props.onUpdateClick?.(),children:[$jsx("text",{fg:theme.warningOnHost,attributes:TextAttributes27.BOLD,wrapMode:"none",children:props.update.label}),props.onUpdateClick?$jsx(ShortcutRevealBadge,{bindingId:"tasks.update"}):null]}):null]})}function SidebarCreateAction(props){let{theme,transparentBackground}=useTheme(),t3=useT(),keycap=legendCap("task.new");if(!props.onAddTask)return null;return $jsx("box",{flexShrink:0,paddingRight:1,children:$jsxs("box",{position:"relative",flexDirection:"row",flexShrink:0,gap:1,paddingLeft:1,paddingRight:1,backgroundColor:transparentBackground?void 0:theme.backgroundElement,onMouseUp:()=>props.onAddTask?.(),children:[$jsx("text",{fg:theme.text,attributes:TextAttributes27.BOLD,wrapMode:"none",flexGrow:1,children:t3("tasks.menu.newTask")}),$jsx("text",{fg:theme.primary,attributes:TextAttributes27.BOLD,wrapMode:"none",flexShrink:0,children:"+"}),keycap?$jsx("text",{fg:theme.textMuted,attributes:TextAttributes27.DIM,wrapMode:"none",flexShrink:0,children:keycap}):null,$jsx(ShortcutRevealBadge,{bindingId:"task.new"})]})})}function SidebarNavRail(props){let{theme}=useTheme(),t3=useT();return $jsx("box",{flexDirection:"column",flexShrink:0,paddingBottom:1,children:SIDEBAR_NAV_ITEMS.map((item)=>{let active=props.nav===item.nav;return $jsxs("box",{position:"relative",flexDirection:"row",flexShrink:0,paddingLeft:1,paddingRight:1,onMouseUp:(e2)=>{e2.stopPropagation(),props.setNav(item.nav)},children:[$jsx("text",{fg:active?theme.text:theme.textMuted,attributes:active?TextAttributes27.BOLD:void 0,wrapMode:"none",flexGrow:1,children:t3(item.labelKey)}),$jsx(ShortcutRevealBadge,{bindingId:item.bindingId})]},item.nav)})})}function SidebarZenChip(props){let{theme}=useTheme();return $jsxs("box",{position:"relative",flexShrink:0,paddingLeft:1,paddingRight:1,paddingTop:1,children:[$jsx("text",{fg:theme.accent,attributes:TextAttributes27.BOLD,wrapMode:"none",onMouseUp:(e2)=>{e2.stopPropagation(),props.onZenClick?.()},children:`${zenChipGlyph()} ZEN`}),$jsx(ShortcutRevealBadge,{bindingId:"workspace.zenToggle"})]})}var import_react63=__toESM(require_react_production(),1);import{stat}from"fs/promises";import{join as join4}from"path";function createBackgroundPoller(cfg){let entries=new Map,equals=cfg.equals??((a2,b3)=>a2===b3);function entryFor(key){let entry=entries.get(key);if(!entry){let current=cfg.initial;entry={read:()=>current,write:(next)=>{if(!equals(current,next))current=next},inFlight:!1,nextAllowedAt:0},entries.set(key,entry)}return entry}return{read(key){if(!key)return cfg.initial;return entryFor(key).read()},poll(key){if(!key)return;let entry=entryFor(key);maybeStartScheduledRun(entry,cfg,(signal)=>cfg.run(key,signal),(value)=>entry.write(value))},reset(){entries.clear()}}}var BRANCH_POLL_TIMEOUT_MS=2000,BRANCH_SLOW_RETRY_MS=30000,BRANCH_MIN_POLL_INTERVAL_MS=1500,headCache=new Map;async function headFingerprint(repo){try{let st2=await stat(join4(repo,".git","HEAD"));return`${st2.mtimeMs}:${st2.size}`}catch{return null}}async function resolveBranchHead(repo,signal,spawn4=spawnCapture){let fingerprint=await headFingerprint(repo);if(fingerprint!==null){let cached=headCache.get(repo);if(cached&&cached.fingerprint===fingerprint)return cached.value}let value="",resolved=!1,ref=await spawn4("git",["symbolic-ref","--short","HEAD"],{cwd:repo,env:readOnlyGitProcessEnv(),signal}),name=ref.status===0?ref.stdout.trim():"";if(name&&name!=="HEAD")value=name,resolved=!0;else if((await spawn4("git",["rev-parse","--verify","HEAD"],{cwd:repo,env:readOnlyGitProcessEnv(),signal})).status===0)value="(detached)",resolved=!0;if(resolved&&fingerprint!==null)headCache.set(repo,{fingerprint,value});return value}var poller=createBackgroundPoller({initial:"",timeoutMs:BRANCH_POLL_TIMEOUT_MS,slowRetryMs:BRANCH_SLOW_RETRY_MS,minIntervalMs:BRANCH_MIN_POLL_INTERVAL_MS,run:(repo,signal)=>resolveBranchHead(repo,signal)});function currentBranch(repo){return poller.read(repo)}function pollCurrentBranch(repo){poller.poll(repo)}function prChip(task){let pr=task.prStatus;if(!pr)return null;let stale=pr.lastError!==void 0;if((pr.mergeable??"").toUpperCase()==="CONFLICTING")return{glyph:"\u2260",tone:stale?"textMuted":"error"};if(pr.checkState==="failing")return{glyph:"\u2717",tone:stale?"textMuted":"error"};if(pr.checkState==="passing")return{glyph:"\u2713",tone:stale?"textMuted":"success"};return null}var DEFAULT_SPINNER_FRAMES=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function activityToneFor(state){return ATTENTION_STATES.has(state)?"error":null}var IN_PROGRESS_SPINNER=DEFAULT_SPINNER_FRAMES,SPINNER_FRAME_MS=100,SPINNER_TICK_CYCLE=600,NO_STATE_GLYPH="\u25CB",ATTENTION_GLYPH="!",ATTENTION_STATES=new Set(["rate_limited","permission_needed","error","dead"]);function noTrackingSubtitle(){return t("tasks.subtitle.noTracking")}function materializingSubtitle(){return t("tasks.subtitle.materializing")}function deletionSubtitle(failed){return failed?t("tasks.subtitle.deleteFailed"):t("tasks.subtitle.deleting")}function isCustomEngineTask(task){if(task.kind==="main")return!1;return task.vendor!==void 0&&!isBuiltinVendor(task.vendor)}var COMPLETION_TRANSCRIPT_GRACE_MS=2000;function stillWorkingAfterCompletion(activity,transcript){if(activity?.state!=="turn_complete"||!transcript)return!1;if(!activity.at||!transcript.mtimeMs)return!1;return transcript.mtimeMs>activity.at+COMPLETION_TRANSCRIPT_GRACE_MS}function rowIsLoading(opts){let{task}=opts,activityState=opts.activity?.state,hasActivity=activityState!==void 0,untrackedCustomEngine=isCustomEngineTask(task)&&!hasActivity,materializing=opts.job!==void 0,deleting=task.deletion?.phase==="queued"||task.deletion?.phase==="running",working=activityState==="running"||stillWorkingAfterCompletion(opts.activity,opts.transcript);return deleting||materializing||!untrackedCustomEngine&&working}function buildSidebarRowView(opts){let{task}=opts,isMain=task.kind==="main",branch=isMain?opts.mainBranch??"":task.branch,activityState=opts.activity?.state,hasActivity=activityState!==void 0,activityBadge=stillWorkingAfterCompletion(opts.activity,opts.transcript)?null:activityBadgeFor(activityState,opts.completionSeen===!0),activityTone=activityToneFor(activityState),untrackedCustomEngine=isCustomEngineTask(task)&&!hasActivity,materializing=opts.job!==void 0,deleting=task.deletion?.phase==="queued"||task.deletion?.phase==="running",deleteFailed=task.deletion?.phase==="error",loading=rowIsLoading({task,activity:opts.activity,job:opts.job,transcript:opts.transcript}),spinnerFrames=DEFAULT_SPINNER_FRAMES,spinner=spinnerFrames[opts.spinnerFrame%spinnerFrames.length]??spinnerFrames[0],tone=deleteFailed?"error":deleting||materializing?"primary":untrackedCustomEngine?"textMuted":activityTone??(loading?"primary":activityBadge?.tone??"textMuted"),fallbackSubtitle=untrackedCustomEngine?noTrackingSubtitle():"\u2014",subagents=loading?opts.lifecycle?.subagents??0:0,branchWithMarks=subagents>0&&branch.length>0?`\u25C7${subagents} ${branch}`:branch,subtitleText=deleting||deleteFailed?opts.truncateBranch(deletionSubtitle(deleteFailed),opts.subtitleBudget):materializing?opts.truncateBranch(materializingSubtitle(),opts.subtitleBudget):branchWithMarks.length>0?opts.truncateBranch(branchWithMarks,opts.subtitleBudget):opts.truncateBranch(fallbackSubtitle,opts.subtitleBudget),restGlyph=deleteFailed?ATTENTION_GLYPH:activityBadge?.glyph??NO_STATE_GLYPH;return{isMain,titleText:isMain?repoBasename(task.repo):task.title,subtitleText,loading,stateGlyph:loading?spinner:restGlyph,tone,spinnerFrames,materializing}}function withSpinnerFrame(view,frame){if(!view.loading)return view;let frames=view.spinnerFrames,spinner=frames[frame()%frames.length]??frames[0]??"\u280B";if(spinner===view.stateGlyph)return view;return{...view,stateGlyph:spinner}}function activityBadgeFor(state,completionSeen){if(ATTENTION_STATES.has(state))return{glyph:ATTENTION_GLYPH,tone:"error"};if(state==="turn_complete"&&!completionSeen)return{glyph:"\u25CF",tone:"primary"};return null}var import_react62=__toESM(require_react_production(),1);var listeners=new Set,frame=0,timer=null;function tick(){frame=(frame+1)%SPINNER_TICK_CYCLE;for(let listener of listeners)try{listener()}catch{}}function spinnerFrameSnapshot(){return frame}function subscribeSpinnerFrame(listener){if(listeners.add(listener),timer===null)timer=setInterval(tick,SPINNER_FRAME_MS),timer.unref?.();return()=>{if(listeners.delete(listener),listeners.size===0&&timer!==null)clearInterval(timer),timer=null,frame=0}}var POLL_TIMEOUT_MS=4000,SLOW_REPO_RETRY_MS=60000,MIN_POLL_INTERVAL_MS=1500,poller2=createBackgroundPoller({initial:null,equals:sameWorktreeChanges,timeoutMs:POLL_TIMEOUT_MS,slowRetryMs:SLOW_REPO_RETRY_MS,minIntervalMs:MIN_POLL_INTERVAL_MS,run:async(worktreePath,signal)=>{let res=await spawnCapture("git",["status","--porcelain=v1"],{cwd:worktreePath,env:readOnlyGitProcessEnv(),signal});if(res.status!==0)throw Error("git status failed");return parsePorcelain(res.stdout)}});function worktreeChanges(worktreePath){return poller2.read(worktreePath)}function pollWorktreeChanges(worktreePath){poller2.poll(worktreePath)}function completionSeenKey(taskId,tabId){return tabId===void 0?taskId:`${taskId}\x00${tabId}`}function parseCompletionSeen(stored){if(typeof stored!=="object"||stored===null||Array.isArray(stored))return{};let out={};for(let[key,at2]of Object.entries(stored))if(typeof at2==="number"&&Number.isFinite(at2))out[key]=at2;return out}function foldCompletionSeen(seen,key,at2,limit=200){let known=seen[key];if(known!==void 0&&known>=at2)return seen;let next={...seen,[key]:at2},keys=Object.keys(next);if(keys.length<=limit)return next;let pruned={};for(let k3 of keys.sort((a2,b3)=>next[b3]-next[a2]).slice(0,limit))pruned[k3]=next[k3];return pruned}function completionSeenAt(kv,key,at2){if(!kv||at2===void 0)return!1;let stored=kv.get("completionSeen");if(typeof stored!=="object"||stored===null||Array.isArray(stored))return!1;let known=stored[key];return typeof known==="number"&&known>=at2}function markCompletionSeen(kv,key,at2){let seen=parseCompletionSeen(kv.get("completionSeen")),next=foldCompletionSeen(seen,key,at2);if(next!==seen)kv.set("completionSeen",next)}function seenCompletionTabs(kv,taskId,stamps){let seen=new Set;for(let[tabId,at2]of stamps)if(completionSeenAt(kv,completionSeenKey(taskId,tabId),at2))seen.add(tabId);return seen}var NOOP_SUBSCRIBE=()=>()=>{},ZERO_FRAME=()=>0;function useSpinnerFrame(active){return import_react62.useSyncExternalStore(active?subscribeSpinnerFrame:NOOP_SUBSCRIBE,active?spinnerFrameSnapshot:ZERO_FRAME)}var NO_CHANGES={added:0,deleted:0};function useChanges(sources,task){let pushed=pickPushedChanges(sources.worktreeChanges,task.worktreePath),hasPushed=pushed!==null;if(import_react62.useEffect(()=>{if(sources.branchTick,hasPushed)return;pollWorktreeChanges(task.worktreePath)},[hasPushed,task.worktreePath,sources.branchTick]),!task.worktreePath)return NO_CHANGES;if(pushed==="unknown")return null;return pushed??worktreeChanges(task.worktreePath)}var UNKNOWN_CHANGES_MARK="?";function ChangeStats(props){let{theme}=useTheme();if(props.changes===null)return $jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:0,children:UNKNOWN_CHANGES_MARK});let ahead=props.changes.ahead??0,behind=props.changes.behind??0;if(props.changes.added<=0&&props.changes.deleted<=0&&ahead<=0&&behind<=0)return null;return $jsxs("box",{flexDirection:"row",gap:1,flexShrink:0,children:[ahead>0?$jsxs("text",{fg:theme.success,wrapMode:"none",flexShrink:0,children:["\u2191",ahead]}):null,props.changes.added>0?$jsxs("text",{fg:theme.success,wrapMode:"none",flexShrink:0,children:["+",props.changes.added]}):null,props.changes.deleted>0?$jsxs("text",{fg:theme.error,wrapMode:"none",flexShrink:0,children:["\u2212",props.changes.deleted]}):null,behind>0?$jsxs("text",{fg:theme.warning,wrapMode:"none",flexShrink:0,children:["\u2193",behind]}):null]})}var completionSeenIds=new Set;function completionSeenFor(taskId,activityState,viewing,tabId,durableSeen=!1){let key=completionSeenKey(taskId,tabId);if(activityState==="turn_complete"){if(viewing)completionSeenIds.add(key)}else completionSeenIds.delete(key);return completionSeenIds.has(key)||durableSeen}function completionStampOf(activity){return activity?.state==="turn_complete"?activity.at:void 0}function useDurableCompletionSeen(taskId,tabId,completionAt,viewing){let kv=useOptionalKV(),key=completionSeenKey(taskId,tabId),seen=completionSeenAt(kv,key,completionAt);return import_react62.useEffect(()=>{if(!kv||!viewing||completionAt===void 0||seen)return;markCompletionSeen(kv,key,completionAt)},[kv,key,completionAt,viewing,seen]),seen}function JumpDigit(props){let{theme}=useTheme(),digit=taskJumpDigit(props.flatIndex);if(digit===null)return null;return $jsx("text",{fg:props.dim?theme.textMuted:theme.accent,wrapMode:"none",flexShrink:0,children:digit})}import{MouseButton as MouseButton2}from"@opentui/core";var INDENT_CELLS=1;function treeLabelBudget(shared2,reserved){let width=shared2.width??SIDEBAR_WIDTH;return Math.max(6,width-3-reserved)}function clusterCells(text){let cells=1;for(let ch of text)cells+=charWidth(ch.codePointAt(0)??0);return cells}function jumpDigitCells(flatIndex){let digit=taskJumpDigit(flatIndex);return digit===null?0:clusterCells(digit)}function MoveChip(props){let{theme}=useTheme(),t3=useT();if(props.shared.movingRowId!==props.rowId)return null;return $jsx("text",{fg:theme.info,wrapMode:"none",flexShrink:0,children:t3("tasks.moveChip").trim()})}function RowShell(props){let{theme}=useTheme(),shared2=props.shared,selection=resolveRowSelectionChrome(theme,{cursor:shared2.cursorIndex===props.flatIndex,selected:shared2.activeRowId===props.rowId});return $jsxs("box",{ref:(renderable)=>{if(!renderable)return;return shared2.rowEls.set(props.flatIndex,renderable),()=>{if(shared2.rowEls.get(props.flatIndex)===renderable)shared2.rowEls.delete(props.flatIndex)}},width:"100%",flexDirection:"row",gap:0,backgroundColor:selection.backgroundColor,onMouseUp:(evt)=>{if(evt.stopPropagation(),evt.button===MouseButton2.RIGHT&&shared2.onContextMenu){shared2.onContextMenu(props.flatIndex,props.rowId,evt.x,evt.y);return}shared2.onPress(props.flatIndex,props.rowId)},children:[$jsx("text",{fg:selection.markerColor,wrapMode:"none",children:selection.marker}),$jsx("text",{wrapMode:"none",flexShrink:0,children:" ".repeat(props.depth*INDENT_CELLS)}),props.children]})}function WorktreeTreeRow(props){let{theme}=useTheme(),t3=useT(),shared2=props.shared,task=props.task,isCursor=shared2.cursorIndex===props.flatIndex,changes=useChanges(shared2,task),chip=prChip(task),livePath=rowLiveBranchPath(task);import_react63.useEffect(()=>{if(shared2.branchTick,livePath)pollCurrentBranch(livePath)},[livePath,shared2.branchTick]);let label=worktreeRowLabel(task,livePath?{liveBranch:currentBranch(livePath)}:{}),moving=shared2.movingRowId===props.rowId,materializing=shared2.taskJobs?.get(task.id)!==void 0,deletionPhase=task.deletion?.phase,deleting=deletionPhase==="queued"||deletionPhase==="running",deleteFailed=deletionPhase==="error",spinning=materializing||deleting,frame2=useSpinnerFrame(spinning),deletionWord=deleting||deleteFailed?t3(deleteFailed?"tasks.subtitle.deleteFailed":"tasks.subtitle.deleting"):null,reserved=(spinning||deleteFailed?2:0)+(deletionWord?clusterCells(deletionWord):0)+jumpDigitCells(props.flatIndex)+(task.pinned===!0?2:0)+(chip?2:0)+(changes===null?clusterCells(UNKNOWN_CHANGES_MARK):0)+((changes?.ahead??0)>0?clusterCells(`\u2191${changes?.ahead}`):0)+((changes?.added??0)>0?clusterCells(`+${changes?.added}`):0)+((changes?.deleted??0)>0?clusterCells(`\u2212${changes?.deleted}`):0)+((changes?.behind??0)>0?clusterCells(`\u2193${changes?.behind}`):0)+(moving?clusterCells(t3("tasks.moveChip").trim()):0);return $jsxs(RowShell,{rowId:props.rowId,flatIndex:props.flatIndex,depth:1,shared:shared2,children:[spinning?$jsx("text",{fg:theme.primary,wrapMode:"none",width:2,flexShrink:0,children:`${IN_PROGRESS_SPINNER[frame2%IN_PROGRESS_SPINNER.length]??IN_PROGRESS_SPINNER[0]} `}):deleteFailed?$jsx("text",{fg:theme.error,wrapMode:"none",width:2,flexShrink:0,children:`${ATTENTION_GLYPH} `}):null,$jsxs("box",{flexDirection:"row",flexGrow:1,paddingRight:1,gap:1,children:[$jsx("text",{fg:theme.text,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:truncateEndCells(label,treeLabelBudget(shared2,reserved),charWidth)}),task.pinned===!0?$jsx("text",{fg:theme.warning,wrapMode:"none",flexShrink:0,children:"\u25B4"}):null,chip?$jsx("text",{fg:toneColor(theme,chip.tone),wrapMode:"none",flexShrink:0,children:chip.glyph}):null,$jsx(ChangeStats,{changes}),deletionWord?$jsx("text",{fg:deleteFailed?theme.error:theme.textMuted,wrapMode:"none",flexShrink:0,children:deletionWord}):null,$jsx(MoveChip,{rowId:props.rowId,shared:shared2}),$jsx(JumpDigit,{flatIndex:props.flatIndex,dim:!isCursor})]})]})}function useTabRowBaseView(args){let t3=useT(),{task,activity,lifecycle,job,transcript,completionSeen}=args;return import_react63.useMemo(()=>{return buildSidebarRowView({task,activity,lifecycle,job,transcript,spinnerFrame:0,subtitleBudget:0,truncateBranch:truncateBranchLabel,completionSeen})},[task,activity,lifecycle,job,transcript,completionSeen,t3])}function TabTreeRow(props){let{theme}=useTheme(),t3=useT(),shared2=props.shared,isCursor=shared2.cursorIndex===props.flatIndex,isAgent=props.tab.engine===!0,taskTabStates=isAgent?shared2.engineTabState?.get(props.task.id):void 0,activity=isAgent?tabRowActivity({tabActivity:taskTabStates?.get(props.tab.id),reportedTabCount:taskTabStates?.size??0,taskActivity:shared2.engineState?.get(props.task.id),active:props.tab.active===!0}):void 0,carriesState=activity!==void 0,viewing=shared2.selectedTaskId===props.task.id&&props.tab.active===!0,durableSeen=useDurableCompletionSeen(props.task.id,props.tab.id,carriesState?completionStampOf(activity):void 0,viewing),completionSeen=carriesState?completionSeenFor(props.task.id,activity?.state,viewing,props.tab.id,durableSeen):!1,baseView=useTabRowBaseView({task:props.task,activity,lifecycle:carriesState?shared2.engineLifecycle?.get(props.task.id):void 0,job:carriesState?shared2.taskJobs?.get(props.task.id):void 0,transcript:shared2.transcriptActivity?.get(props.task.worktreePath),completionSeen}),frame2=useSpinnerFrame(carriesState&&baseView.loading),rowView=withSpinnerFrame(baseView,()=>frame2),restored=props.tab.restored===!0,glyph=restored?ATTENTION_GLYPH:isAgent&&carriesState?rowView.stateGlyph:NO_STATE_GLYPH;return $jsxs(RowShell,{rowId:props.rowId,flatIndex:props.flatIndex,depth:1,shared:props.shared,children:[$jsx("text",{fg:restored?theme.error:carriesState?toneColor(theme,rowView.tone):theme.textMuted,wrapMode:"none",width:2,flexShrink:0,children:`${glyph} `}),$jsxs("box",{flexDirection:"row",flexGrow:1,paddingRight:1,gap:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:truncateEndCells(props.tab.label,treeLabelBudget(shared2,2+jumpDigitCells(props.flatIndex)+(shared2.movingRowId===props.rowId?clusterCells(t3("tasks.moveChip").trim()):0)),charWidth)}),$jsx(MoveChip,{rowId:props.rowId,shared:shared2}),$jsx(JumpDigit,{flatIndex:props.flatIndex,dim:!isCursor})]})]})}function RoutinesTreeRow(props){let{theme}=useTheme(),t3=useT();return $jsxs(RowShell,{rowId:props.rowId,flatIndex:props.flatIndex,depth:1,shared:props.shared,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",width:2,flexShrink:0,children:props.expanded?"\u25BE ":"\u25B8 "}),$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:1,children:t3("tasks.routinesRow",{count:String(props.count)})})]})}function RecentJumpRow(props){let{theme}=useTheme(),t3=useT();return $jsxs(RowShell,{rowId:props.rowId,flatIndex:props.flatIndex,depth:1,shared:props.shared,children:[$jsx("text",{fg:theme.accent,wrapMode:"none",width:2,flexShrink:0,children:"\u21A9 "}),$jsx("text",{fg:theme.text,wrapMode:"none",flexShrink:1,children:t3("tasks.recentJump",{title:props.task.title})})]})}function SidebarTreeBody(props){let{theme}=useTheme(),t3=useT();return $jsx("scrollbox",{ref:props.setScrollRef,flexGrow:1,minHeight:0,stickyScroll:!1,verticalScrollbarOptions:{visible:!1},children:$jsxs("box",{flexShrink:0,gap:0,children:[props.rows.map((row,i2)=>{if(row.kind==="project"){let isScratch=row.id===SCRATCH_SECTION_ID;return $jsx(SectionHeader,{label:isScratch?t3("tasks.header.scratch"):row.label,suffix:props.movingProjectId===row.id?t3("tasks.moveChip"):void 0,topPad:i2>0,onContextMenu:props.onProjectContextMenu&&!isScratch?(x2,y3)=>props.onProjectContextMenu?.(row.id,x2,y3):void 0},row.id)}if(row.kind==="recent")return $jsx(RecentJumpRow,{rowId:row.id,flatIndex:props.flatIndexOf.get(row.id)??-1,task:row.task,shared:props.shared},row.id);if(row.kind==="routines")return $jsx(RoutinesTreeRow,{rowId:row.id,flatIndex:props.flatIndexOf.get(row.id)??-1,count:row.count,expanded:row.expanded,shared:props.shared},row.id);if(row.kind==="worktree")return $jsx(WorktreeTreeRow,{rowId:row.id,flatIndex:props.flatIndexOf.get(row.id)??-1,task:row.task,shared:props.shared},row.id);return $jsx(TabTreeRow,{rowId:row.id,flatIndex:props.flatIndexOf.get(row.id)??-1,task:row.task,tab:row.tab,shared:props.shared},row.id)}),props.rows.length===0?$jsx("box",{paddingTop:1,paddingLeft:1,children:$jsx("text",{fg:theme.textMuted,children:t3(sidebarEmptyStateKey({searching:props.searching,projectFilter:!1}))})}):null]})})}function cursorTaskIdOf(rowId){if(rowId===void 0||rowId===RECENT_ROW_ID)return null;return parseRowId(rowId).taskId}function useTreeBindings(opts){let{focused,search,menu,moveMode,onMoveModeExit,controller,flatIdsRef,cursorRef,moveCursorRow,onDeleteRequest,onRenameRequest,onPinRequest,onLocalMergeRequest,markKeysUsed}=opts;function withCursorTask(fn){let taskId=cursorTaskIdOf(flatIdsRef.current[cursorRef.current]);if(taskId!==null&&fn)fn(taskId)}useBindings(()=>({enabled:focused&&!search.active&&!menu.open,bindings:bindByIds({"sidebar.nav":(_evt,slot)=>{markKeysUsed();let down=(slot??0)%2===0;if(moveMode){moveCursorRow(down?1:-1);return}if(down)controller.moveDown();else controller.moveUp()},"sidebar.select":()=>{if(markKeysUsed(),moveMode){onMoveModeExit?.();return}controller.selectCurrent()},"sidebar.goto":(_evt,slot)=>{if(moveMode)return;if((slot??0)%2===1)controller.pressShiftG();else controller.pressG()},"sidebar.tree.open":()=>{if(moveMode)return;controller.selectCurrent()},"sidebar.search.enter":()=>{if(moveMode)return;search.enter()},"sidebar.delete":()=>{if(moveMode)return;markKeysUsed(),withCursorTask(onDeleteRequest)},"sidebar.rename":()=>{if(moveMode)return;markKeysUsed(),withCursorTask(onRenameRequest)},"sidebar.localMerge":()=>withCursorTask(onLocalMergeRequest),"sidebar.pin":()=>{if(moveMode)return;markKeysUsed(),withCursorTask(onPinRequest)}})})),useBindings(()=>({enabled:focused&&moveMode,bindings:[{key:"escape",cmd:()=>onMoveModeExit?.()}]})),useBindings(()=>({enabled:focused&&search.active,bindings:bindByIds({"sidebar.search.nav":(_evt,slot)=>{if((slot??0)%2===0)controller.moveDown();else controller.moveUp()},"sidebar.search.submit":()=>{controller.selectCurrent(),search.exit()},"sidebar.search.cancel":()=>search.exit()})})),useBindings(()=>({enabled:focused&&menu.open,bindings:[...bindByIds({"sidebar.nav":(_evt,slot)=>menu.moveCursor((slot??0)%2===0?1:-1),"sidebar.select":()=>menu.pickCurrent()}),{key:"escape",cmd:()=>menu.close()}]}))}var import_react66=__toESM(require_react_production(),1);function newTabVerbs(){return[{action:"newChat",labelKey:"tasks.menu.newChat",bindingId:"chat.tab.chooseEngine"},{action:"newShell",labelKey:"tasks.menu.newShell"}]}function taskVerbs(task){let verbs=[{action:"rename",labelKey:"tasks.menu.rename",bindingId:"sidebar.rename"}];if(task.kind!=="main")verbs.push({action:"pin",labelKey:task.pinned===!0?"tasks.menu.unpin":"tasks.menu.pin",bindingId:"sidebar.pin"});if(verbs.push({action:"reorder",labelKey:"tasks.menu.reorder",bindingId:"sidebar.localMerge"}),task.prompt!==void 0)verbs.push({action:"runAgain",labelKey:"tasks.menu.runAgain"});if(verbs.push({action:"setStatus",labelKey:"tasks.menu.setStatus"}),task.branch!=="")verbs.push({action:"copyBranch",labelKey:"tasks.menu.copyBranch"});if(task.worktreePath!=="")verbs.push({action:"copyPath",labelKey:"tasks.menu.copyPath"});if(verbs.push({action:"openEditor",labelKey:"tasks.menu.openEditor",bindingId:"tasks.openWorktree"}),task.branch!=="")verbs.push({action:"renameBranch",labelKey:"tasks.menu.renameBranch",bindingId:"tasks.renameBranch"});if(verbs.push({action:"changeEngine",labelKey:"tasks.menu.changeEngine",bindingId:"tasks.cycleEngine"}),task.prStatus?.checkState==="failing")verbs.push({action:"fixChecks",labelKey:"tasks.menu.fixChecks",bindingId:"files.fixChecks"});if(task.kind==="task"&&task.branch!=="")verbs.push({action:"syncBase",labelKey:"tasks.menu.syncBase",bindingId:"files.syncBase"});if(task.kind==="task"&&task.branch!=="")verbs.push({action:"land",labelKey:"tasks.menu.land"});return verbs.push({action:"delete",labelKey:"tasks.menu.delete",danger:!0,bindingId:"sidebar.delete"}),verbs}function treeMenuItems(row,ctx={}){if(row.kind==="project")return[{action:"newTask",labelKey:"tasks.menu.newTask",bindingId:"task.new"},{action:"fieldNotes",labelKey:"tasks.menu.fieldNotes"},{action:"forgetProject",labelKey:"tasks.menu.forgetProject",danger:!0,bindingId:"sidebar.delete"}];if(row.kind==="worktree")return[{action:"open",labelKey:"tasks.menu.open",bindingId:"sidebar.select"},...newTabVerbs(),...taskVerbs(row.task)];if(row.kind==="routines")return[];let tabItems=[{action:"open",labelKey:"tasks.menu.openTab",bindingId:"sidebar.select"}];if((ctx.tabCount??0)>0)tabItems.push({action:"closeTab",labelKey:"tasks.menu.closeTab",bindingId:"chat.tab.close"});return[...tabItems,...newTabVerbs(),...taskVerbs(row.task)]}var import_react65=__toESM(require_react_production(),1);var subscribers=new Set,installedHost=null;function dispatch(event){for(let handler of[...subscribers])handler(event)}function subscribeGlobalMouseDown(host,handler){if(subscribers.add(handler),installedHost!==host){if(installedHost)installedHost.onMouseDown=void 0;installedHost=host,host.onMouseDown=dispatch}return()=>{if(subscribers.delete(handler),subscribers.size===0&&installedHost)installedHost.onMouseDown=void 0,installedHost=null}}function useGlobalMouseDown(enabled,handler){let renderer=useRenderer(),latest=useLatest(handler);import_react65.useEffect(()=>{let root=renderer?.root;if(!enabled||!root)return;return subscribeGlobalMouseDown(root,()=>latest.current())},[enabled,renderer])}function menuCap(bindingId){if(!bindingId)return;let cap=legendCap(bindingId);return cap?formatChord(cap):void 0}function useTreeMenu(deps){let t3=useT(),{tree,activateRow,setCursorIndex,actions}=deps,[menu,setMenu]=import_react66.useState(null),[cursor,setCursor]=import_react66.useState(0),openAt=import_react66.useCallback((row,ctx,x2,y3)=>{let items=treeMenuItems(row,ctx);setMenu({row,actions:items.map((item)=>item.action),entries:items.map((item)=>({id:item.action,label:t3(item.labelKey),danger:item.danger,cap:menuCap(item.bindingId)})),x:x2,y:y3}),setCursor(0)},[t3]),openForRow=import_react66.useCallback((flatIndex,rowId,x2,y3)=>{let row=tree.rows.find((candidate)=>candidate.id===rowId);if(!row||row.kind==="project"||row.kind==="recent"||row.kind==="routines")return;setCursorIndex(flatIndex),openAt(row,{tabCount:tree.tabCount(row.task.id)},x2,y3)},[tree.rows,tree.tabCount,openAt,setCursorIndex]),openForProject=import_react66.useCallback((projectId,x2,y3)=>{let row=tree.rows.find((candidate)=>candidate.kind==="project"&&candidate.id===projectId);if(!row)return;openAt(row,{},x2,y3)},[tree.rows,openAt]),close=import_react66.useCallback(()=>setMenu(null),[]);useGlobalMouseDown(menu!==null,close);let moveCursor=import_react66.useCallback((delta)=>{let count=menu?.entries.length??0;if(count===0)return;setCursor((prev)=>(prev+delta+count)%count)},[menu]),fire=import_react66.useCallback((action)=>{if(!menu||action===void 0)return;let row=menu.row;if(setMenu(null),row.kind==="project"){if(action==="newTask")deps.onAddTask?.();if(action==="fieldNotes")actions.onFieldNotesRequest?.(row.repo);if(action==="forgetProject"){let mainId=deps.tree.mainTaskIdOfProject(row.id);if(mainId)actions.onDeleteRequest?.(mainId)}return}if(row.kind==="routines")return;let taskId=row.task.id;switch(action){case"open":activateRow(row.id);break;case"closeTab":if(row.kind==="tab")deps.onCloseTab?.(taskId,row.tab.id);break;case"newChat":deps.onNewTab?.(taskId,"chat");break;case"newShell":deps.onNewTab?.(taskId,"shell");break;case"rename":actions.onRenameRequest?.(taskId);break;case"pin":actions.onPinRequest?.(taskId);break;case"reorder":actions.onLocalMergeRequest?.(taskId);break;case"runAgain":actions.onRunAgainRequest?.(taskId);break;case"setStatus":actions.onSetStatusRequest?.(taskId);break;case"copyBranch":actions.onCopyRequest?.(taskId,"branch");break;case"copyPath":actions.onCopyRequest?.(taskId,"path");break;case"openEditor":actions.onOpenEditorRequest?.(taskId);break;case"renameBranch":actions.onRenameBranchRequest?.(taskId);break;case"changeEngine":actions.onChangeEngineRequest?.(taskId);break;case"fixChecks":actions.onFixChecksRequest?.(taskId);break;case"syncBase":actions.onSyncBaseRequest?.(taskId);break;case"land":actions.onLandRequest?.(taskId);break;case"delete":actions.onDeleteRequest?.(taskId);break;default:break}},[menu,activateRow,actions,deps.onAddTask,deps.onCloseTab,deps.onNewTab,deps.tree.mainTaskIdOfProject]),pickCurrent=import_react66.useCallback(()=>fire(menu?.actions[cursor]),[fire,menu,cursor]),pick=import_react66.useCallback((action)=>fire(menu?.actions.find((candidate)=>candidate===action)),[fire,menu]);return{open:menu!==null,entries:menu?.entries??[],cursor,x:menu?.x??0,y:menu?.y??0,close,moveCursor,pickCurrent,pick,openForRow,openForProject}}var import_react68=__toESM(require_react_production(),1);function useTreeSearch(opts){let[active,setActive]=import_react68.useState(!1),[query,setQuery]=import_react68.useState(""),focusedRef=useLatest(opts.focused),onActiveChange=opts.onActiveChange,onActiveChangeRef=useLatest(onActiveChange);import_react68.useEffect(()=>()=>{onActiveChangeRef.current?.(!1)},[]);let enter=import_react68.useCallback(()=>{setQuery(""),setActive(!0),onActiveChange?.(!0)},[onActiveChange]),exit=import_react68.useCallback(()=>{setActive(!1),setQuery(""),onActiveChange?.(!1)},[onActiveChange]),renderer=useRenderer();return import_react68.useEffect(()=>{if(!active||!renderer)return;let listener=(evt)=>{if(!focusedRef.current||modalActive())return;setQuery((q2)=>searchQueryKeystroke(q2,evt)??q2)};return renderer.keyInput.on("keypress",listener),()=>{renderer.keyInput.off("keypress",listener)}},[active,renderer]),{active,query,enter,exit}}var import_react70=__toESM(require_react_production(),1);function ordinalOf(tabId,fallback){let match=/^tab-(\d+)$/.exec(tabId);return match?Number(match[1]):fallback}function adoptTabs(state,tabIds){let known=new Set(state.tabs.map((tab)=>tab.id)),fresh=[];for(let id of tabIds){if(known.has(id))continue;known.add(id),fresh.push(id)}if(fresh.length===0)return state;let minted=state.nextOrdinal,adopted=fresh.map((id)=>({kind:"engine",id,title:null,ordinal:ordinalOf(id,minted++),spawned:!0}));adopted.sort((a2,b3)=>a2.ordinal-b3.ordinal);let tabs=[...state.tabs,...adopted],maxOrdinal=tabs.reduce((max,tab)=>Math.max(max,tab.ordinal),0);return{tabs,activeId:state.activeId,nextOrdinal:Math.max(state.nextOrdinal,maxOrdinal+1)}}function adoptTaskTabs(kv,taskId,tabIds){if(tabIds.length===0)return!1;if(requestTabAdopt(taskId,tabIds),!takeUnclaimedTabAdopt())return!1;let state=knownTabsState(kv,taskId),empty={tabs:[],activeId:tabIds[0],nextOrdinal:1},next=adoptTabs(state??empty,tabIds);if(state&&next===state)return!1;return setTaskTabs(taskId,next),kv.set(terminalTabsKey(taskId),next),!0}function orphanTabsByTask(sessions,registered){let byTask=new Map,known=new Set(registered);for(let session of sessions){if(session.alive===!1)continue;let{taskId,tabId:rawTabId}=parseRowId(session.key);if(!rawTabId)continue;let tabId=rawTabId.split("::")[0],rowId=tabRowId(taskId,tabId);if(known.has(rowId))continue;known.add(rowId);let tabs=byTask.get(taskId)??[];tabs.push({id:tabId,label:`\u26A0 ${stripEngineStatusPrefix(session.title?.trim()??"",null).trim()||tabId}`,active:tabs.length===0,engine:!0}),byTask.set(taskId,tabs)}return byTask}function filterKnownOrphanTabs(tasks,orphans){let taskIds=new Set(tasks.map((task)=>task.id)),known=new Map;for(let[taskId,tabs]of orphans)if(taskIds.has(taskId))known.set(taskId,tabs);return known}var import_react69=__toESM(require_react_production(),1);var POLL_MS3=2000,EMPTY=[];function sameSessions(a2,b3){if(a2.length!==b3.length)return!1;return a2.every((s2,i2)=>{let other=b3[i2];return other!==void 0&&s2.key===other.key&&s2.alive===other.alive&&s2.title===other.title&&s2.pid===other.pid&&s2.restored===other.restored})}function pollingAllowed(){return process.env.BUN_TEST!=="1"&&process.env.VITEST!=="true"}function useHostSessions(enabled=pollingAllowed()){let[sessions,setSessions]=import_react69.useState(EMPTY);return import_react69.useEffect(()=>{if(!enabled)return;let cancelled=!1,poll=async()=>{try{let client=await getSharedPtyClient(),{sessions:live=[]}=await client.request("pty.list",{});if(!cancelled)setSessions((prev)=>sameSessions(prev,live)?prev:live)}catch{if(!cancelled)setSessions((prev)=>prev.length===0?prev:EMPTY)}};poll();let timer2=setInterval(()=>void poll(),POLL_MS3);return()=>{cancelled=!0,clearInterval(timer2)}},[enabled]),sessions}function useTreeState(opts){let{tasks,kv,selectedTaskId,selectedTabId}=opts,query=opts.query??"",searching=query.trim()!=="",[expandedRoutines,setExpandedRoutines]=import_react70.useState(()=>new Set),toggleRoutines=import_react70.useCallback((projectKey)=>{setExpandedRoutines((current)=>{let next=new Set(current);if(!next.delete(projectKey))next.add(projectKey);return next})},[]),liveEngines=getDefaultLiveEngines(),[liveTick,setLiveTick]=import_react70.useState(0);import_react70.useEffect(()=>liveEngines.subscribe(()=>setLiveTick((tick2)=>tick2+1)),[liveEngines]);let hostSessions=useHostSessions();import_react70.useEffect(()=>{let pids=new Map;for(let session of hostSessions)if(session.alive!==!1&&typeof session.pid==="number"&&session.pid>0)pids.set(session.key,session.pid);return liveEngines.setAuxPids(pids),()=>liveEngines.setAuxPids(new Map)},[hostSessions,liveEngines]);let liveTitles=import_react70.useMemo(()=>{let map=new Map;for(let session of hostSessions){let title=session.title?.trim();if(title)map.set(session.key,title)}return map},[hostSessions]),restoredKeys=import_react70.useMemo(()=>{let keys=new Set;for(let session of hostSessions)if(session.restored===!0)keys.add(session.key);return keys},[hostSessions]),snapshotTabs=import_react70.useMemo(()=>{let map=new Map;for(let task of tasks){let known=knownTaskTabs(kv,task.id);if(!known)continue;let vendor=task.vendor??DEFAULT_TASK_VENDOR;map.set(task.id,known.tabs.map((tab)=>{let ptyKey=tabPtyKeyFor(task.id,tab),probed=liveEngines.resolve(ptyKey),live=probed===void 0?tab.liveVendor:probed;return{id:tab.id,label:tabTitleStable(tab,vendor,live,liveTitles.get(ptyKey)),active:tab.id===known.activeId,engine:tab.kind==="engine"||(live??null)!==null,restored:restoredKeys.has(ptyKey)}}))}return map},[tasks,kv,liveEngines,liveTick,liveTitles,restoredKeys]),orphansByTask=import_react70.useMemo(()=>{let registered=new Set;for(let[taskId,tabs]of snapshotTabs)for(let tab of tabs)registered.add(tabRowId(taskId,tab.id));let sessions=hostSessions.filter((session)=>!isRecentlyClosedPtyKey(session.key));return filterKnownOrphanTabs(tasks,orphanTabsByTask(sessions,registered))},[snapshotTabs,hostSessions,tasks]);import_react70.useEffect(()=>{if(!kv)return;for(let[taskId,orphans]of orphansByTask)adoptTaskTabs(kv,taskId,orphans.map((tab)=>tab.id))},[orphansByTask,kv]);let tabsByTask2=import_react70.useMemo(()=>{if(orphansByTask.size===0)return snapshotTabs;let map=new Map(snapshotTabs);for(let[taskId,orphans]of orphansByTask){let existing=map.get(taskId);map.set(taskId,existing?[...existing,...orphans.map((tab)=>({...tab,active:!1}))]:orphans)}return map},[snapshotTabs,orphansByTask]),recentTask=opts.recentTask??null,sortMode=opts.sortMode??"default",{rows,totalCount}=import_react70.useMemo(()=>{let all=searching?buildTreeRows({tasks,tabsByTask:tabsByTask2,sortMode,expandedRoutines:new Set(projectKeysOf(tasks))}):buildTreeRows({tasks,tabsByTask:tabsByTask2,sortMode,expandedRoutines}),total=treeFlatIds(all).length;return opts.branchTick,{rows:searching?filterTreeRows(all,query,(task)=>{let path=rowLiveBranchPath(task);return path?currentBranch(path):""}):withRecentRow(all,recentTask),totalCount:total}},[tasks,tabsByTask2,searching,query,recentTask,sortMode,expandedRoutines,opts.branchTick]),flatIds=import_react70.useMemo(()=>treeFlatIds(rows),[rows]),activeRowId=import_react70.useMemo(()=>{if(selectedTaskId===null)return null;if(selectedTabId!==null)return tabRowId(selectedTaskId,selectedTabId);return selectedTaskId},[selectedTaskId,selectedTabId]),tabCount=import_react70.useCallback((taskId)=>tabsByTask2.get(taskId)?.length??0,[tabsByTask2]),mainTaskOfProject=import_react70.useCallback((projectId)=>mainTaskIdOfProject(tasks,projectId),[tasks]),projectIdOfTask=import_react70.useCallback((taskId)=>{let task=tasks.find((candidate)=>candidate.id===taskId);if(!task||task.kind==="dir")return null;return sidebarProjectKey(task.repo)},[tasks]);return{rows,flatIds,totalCount,tabCount,activeRowId,projectIdOfTask,mainTaskIdOfProject:mainTaskOfProject,toggleRoutinesRow:import_react70.useCallback((rowId)=>{let projectKey=projectKeyOfRoutinesRow(rowId);if(projectKey===null)return!1;return toggleRoutines(projectKey),!0},[toggleRoutines])}}function SidebarTree(props){let{theme}=useTheme(),kv=useOptionalKV(),focused=props.focused??!0,dims=useTerminalDimensions(),[branchTick,setBranchTick]=import_react72.useState(0);import_react72.useEffect(()=>{let timer2=setInterval(()=>setBranchTick((n2)=>n2+1),MAIN_BRANCH_POLL_MS);return()=>clearInterval(timer2)},[]);let search=useTreeSearch({focused,onActiveChange:props.onSearchActiveChange}),tree=useTreeState({tasks:props.tasks,kv,selectedTaskId:props.selectedId,selectedTabId:props.selectedTabId??null,query:search.active?search.query:"",recentTask:props.recentTask??null,sortMode:props.sortMode,branchTick}),flatIndexOf=import_react72.useMemo(()=>{let map=new Map;return tree.flatIds.forEach((id,i2)=>map.set(id,i2)),map},[tree.flatIds]),[cursorIndex,setCursorIndexState]=import_react72.useState(-1),cursorRef=import_react72.useRef(cursorIndex),setCursorIndex=import_react72.useCallback((next)=>{cursorRef.current=next,setCursorIndexState(next)},[]),flatIdsRef=useLatest(tree.flatIds),cursorTaskIdRef=props.cursorTaskIdRef;import_react72.useEffect(()=>{if(!cursorTaskIdRef)return;cursorTaskIdRef.current=()=>cursorTaskIdOf(flatIdsRef.current[cursorRef.current])},[cursorTaskIdRef]);let prevActiveRef=import_react72.useRef(null),cursorRowIdRef=import_react72.useRef(null),moveMode=props.moveMode===!0;import_react72.useEffect(()=>{let ids=tree.flatIds;if(moveMode){let wanted=cursorRowIdRef.current,at3=wanted===null?-1:ids.indexOf(wanted);if(at3>=0){if(at3!==cursorRef.current)setCursorIndex(at3);return}}let active=tree.activeRowId,activeMoved=active!==prevActiveRef.current;prevActiveRef.current=active;let at2=active===null?-1:ids.indexOf(active);if(activeMoved&&at2>=0){if(at2!==cursorRef.current)setCursorIndex(at2);return}if(cursorRef.current>=ids.length)setCursorIndex(Math.max(0,ids.length-1));else if(cursorRef.current<0&&ids.length>0)setCursorIndex(at2>=0?at2:0)},[tree.flatIds,tree.activeRowId,moveMode,setCursorIndex]),import_react72.useEffect(()=>{cursorRowIdRef.current=tree.flatIds[cursorRef.current]??null}),import_react72.useEffect(()=>{if(search.query,!search.active)return;setCursorIndex(0)},[search.active,search.query,setCursorIndex]);let recentTaskRef=useLatest(props.recentTask??null),toggleRoutinesRow=tree.toggleRoutinesRow,activateRow=import_react72.useCallback((rowId)=>{if(toggleRoutinesRow(rowId))return;let recent=rowId===RECENT_ROW_ID?recentTaskRef.current:null,{taskId,tabId}=recent?{taskId:recent.id,tabId:null}:parseRowId(rowId);if(props.onSelect(taskId),tabId===null){props.onActivate?.(taskId);return}props.onSelectTab?.(taskId,tabId),props.onActivate?.(taskId)},[props.onSelect,props.onActivate,props.onSelectTab,toggleRoutinesRow]),activateRowRef=useLatest(activateRow),controllerRef=import_react72.useRef(null);if(controllerRef.current===null)controllerRef.current=createSidebarController({getCursor:()=>cursorRef.current,setCursor:setCursorIndex,getFlatIds:()=>flatIdsRef.current,onSelect:(id)=>activateRowRef.current(id)});let ctrl=controllerRef.current,tasksRef=useLatest(props.tasks),moveCursorRow=import_react72.useCallback((delta)=>{let rowId=flatIdsRef.current[cursorRef.current];if(rowId===void 0||rowId===RECENT_ROW_ID)return;let{taskId,tabId}=parseRowId(rowId);if(tabId!==null){props.onMoveTabRequest?.(taskId,tabId,delta);return}let task=tasksRef.current.find((candidate)=>candidate.id===taskId);if(!task)return;if(task.kind!=="main"){props.onMoveRequest?.(taskId,delta);return}let projectId=tree.projectIdOfTask(taskId);if(projectId===null)return;let mainId=tree.mainTaskIdOfProject(projectId);if(mainId===null)return;props.onMoveRequest?.(mainId,delta)},[tree.projectIdOfTask,tree.mainTaskIdOfProject,props.onMoveRequest,props.onMoveTabRequest]),cursorRowId=tree.flatIds[cursorIndex],cursorMove=import_react72.useMemo(()=>{if(cursorRowId===void 0||cursorRowId===RECENT_ROW_ID)return{projectId:null,rowId:null};let{taskId,tabId}=parseRowId(cursorRowId);if(tabId===null){if(props.tasks.find((candidate)=>candidate.id===taskId)?.kind==="main")return{projectId:tree.projectIdOfTask(taskId),rowId:null}}return{projectId:null,rowId:cursorRowId}},[cursorRowId,props.tasks,tree.projectIdOfTask]),menu=useTreeMenu({tree,activateRow,setCursorIndex,onAddTask:props.onAddTask,onCloseTab:props.onCloseTab,onNewTab:props.onNewTab,actions:props}),markKeysUsed=usePaneHintMark("sidebar");useTreeBindings({focused,search,menu,moveMode,onMoveModeExit:props.onMoveModeExit,controller:ctrl,flatIdsRef,cursorRef,moveCursorRow,onDeleteRequest:props.onDeleteRequest,onRenameRequest:props.onRenameRequest,onPinRequest:props.onPinRequest,onLocalMergeRequest:props.onLocalMergeRequest,markKeysUsed}),useBindings(()=>({enabled:!0,bindings:bindByIds({"tasks.jump":(_evt,slot)=>{let id=flatIdsRef.current[slot??0];if(id===void 0)return;setCursorIndex(slot??0),activateRowRef.current(id)}})}));let scrollRef=import_react72.useRef(null),rowElsRef=import_react72.useRef(null);if(rowElsRef.current===null)rowElsRef.current=new Map;let rowEls=rowElsRef.current;import_react72.useEffect(()=>{let scroll=scrollRef.current;if(!scroll||cursorIndex<0||scroll.viewport.height<=0)return;let el=rowEls.get(cursorIndex);if(el)scroll.scrollChildIntoView(el.id)},[cursorIndex,rowEls]);let outerRef=import_react72.useRef(null),effectiveWidth=props.width??SIDEBAR_WIDTH;import_react72.useEffect(()=>{let el=outerRef.current;if(!el)return;el.width=effectiveWidth,el.flexShrink=1,el.minHeight=0},[effectiveWidth]);let shared2={width:effectiveWidth,cursorIndex,activeRowId:tree.activeRowId,selectedTaskId:props.selectedId,movingRowId:moveMode?cursorMove.rowId:null,rowEls,onPress:(flatIndex,rowId)=>{menu.close(),setCursorIndex(flatIndex),activateRow(rowId)},onContextMenu:menu.openForRow,branchTick,engineState:props.engineState,engineTabState:props.engineTabState,engineLifecycle:props.engineLifecycle,taskJobs:props.taskJobs,worktreeChanges:props.worktreeChanges,transcriptActivity:props.transcriptActivity};return $jsxs("box",{ref:outerRef,flexGrow:1,minHeight:0,flexDirection:"column",backgroundColor:theme.backgroundPanel,paddingTop:1,paddingBottom:1,children:[$jsx(SidebarBrandHeader,{focused,status:props.headerStatus??null,onStatusClick:props.onHeaderStatusClick,update:props.updateChip??null,onUpdateClick:props.onUpdateChipClick}),$jsx(SidebarCreateAction,{onAddTask:props.onAddTask}),search.active?$jsx(SidebarSearchInput,{query:search.query,matchCount:tree.flatIds.length,totalCount:tree.totalCount}):null,$jsx(SidebarNavRail,{nav:props.nav??"terminal",setNav:(next)=>props.onNavChange?.(next)}),$jsx(SidebarTreeBody,{rows:tree.rows,flatIndexOf,searching:search.active&&search.query.trim().length>0,shared:shared2,onProjectContextMenu:menu.openForProject,movingProjectId:moveMode?cursorMove.projectId:null,setScrollRef:(r6)=>{scrollRef.current=r6}}),props.zenActive?$jsx(SidebarZenChip,{onZenClick:props.onZenClick}):null,menu.open?$jsx(ContextMenu,{entries:menu.entries,cursor:menu.cursor,x:menu.x,y:menu.y,dims:{width:effectiveWidth,height:dims.height},onPick:menu.pick}):null,dims.height<0?$jsx("text",{children:""}):null]})}function moveTaskTab(kv,taskId,tabId,delta){if(requestTabMove(taskId,tabId,delta),!takeUnclaimedTabMove())return!0;let state=knownTabsState(kv,taskId);if(!state)return!1;let next=moveTab(state,tabId,delta);if(next===state)return!1;return setTaskTabs(taskId,next),kv.set(terminalTabsKey(taskId),next),!0}function HostSidebar(props){let{onFocusRequest:_rail,recentTask:_recent,...treeProps}=props,{theme}=useTheme(),kv=useKV(),notif=useNotifications(),t3=useT(),closeTab2=import_react73.useCallback((taskId,tabId)=>{if(!closeTaskTab(kv,taskId,tabId))notif.notify({kind:"error",taskId,tabId,title:t3("terminal.tab.tabGone")})},[kv,notif,t3]),moveTab2=import_react73.useCallback((taskId,tabId,delta)=>{moveTaskTab(kv,taskId,tabId,delta)},[kv]),newTab=import_react73.useCallback((taskId,kind)=>{props.onActivate(taskId),requestNewTab(taskId,kind)},[props.onActivate]);return $jsxs("box",{width:props.width,flexShrink:0,flexDirection:"column",backgroundColor:theme.backgroundPanel,onMouseUp:props.onFocusRequest,children:[$jsx(SidebarTree,{...treeProps,onCloseTab:closeTab2,onNewTab:newTab,onMoveTabRequest:moveTab2,recentTask:props.recentTask??null}),$jsx("box",{flexShrink:0,paddingLeft:1,paddingBottom:0,children:$jsx(PaneKeyHint,{pane:"sidebar"})})]})}function HostSidebarMount(props){let{actions,pages,focus,inbox,t:t3}=props;return $jsx(HostSidebar,{width:props.showContent?sidebarWidthFor(props.terminalWidth):props.terminalWidth,nav:pages.nav,onNavChange:pages.goToNav,tasks:props.tasks,selectedId:props.selectedId,selectedTabId:props.selectedTabId,onSelect:(id)=>{props.selectTask(id),pages.setNav("terminal")},onActivate:(id)=>{pages.setNav("terminal"),props.activateTask(id)},onSelectTab:(taskId,tabId)=>{let reClick=pages.nav==="terminal"&&focus.focused!=="sidebar"&&taskId===props.selectedId&&tabId===props.selectedTabId;pages.setNav("terminal"),requestTabActivation(taskId,tabId),focus.setFocused(reClick?"sidebar":"workspace")},engineState:props.daemon.sidebarEngineState,engineTabState:props.daemon.engineTabState,engineLifecycle:props.daemon.engineLifecycle,taskJobs:props.daemon.taskJobs,worktreeChanges:props.daemon.worktreeChanges,transcriptActivity:props.daemon.transcriptActivity,focused:props.activePane==="sidebar",onAddTask:()=>void actions.createTask(),onDeleteRequest:(id)=>void actions.deleteTask(id),onLandRequest:(id)=>void actions.landTask(id),onSyncBaseRequest:(id)=>void actions.syncBase(id),onRenameRequest:(id)=>void actions.renameTask(id),onPinRequest:(id)=>void actions.togglePin(id),onSetStatusRequest:(id)=>void actions.setStatus(id),onCopyRequest:(id,field)=>actions.copyTaskField(id,field),onOpenEditorRequest:props.openTaskWorktree,onRenameBranchRequest:(id)=>void actions.renameBranch(id),onChangeEngineRequest:(id)=>void actions.pickVendor(id),onFieldNotesRequest:actions.showFieldNotes,onFixChecksRequest:props.onFixChecks,onRunAgainRequest:(id)=>void actions.confirmRunAgain(id).then((task)=>task&&props.runAgain(task)),moveMode:props.moveMode,onMoveRequest:(id,delta)=>void actions.moveTask(id,delta),onMoveModeExit:props.exitMoveMode,onLocalMergeRequest:props.onLocalMergeRequest,onSearchActiveChange:props.onSearchActiveChange,sortMode:props.sortMode,headerStatus:{label:`${t3("workspace.inbox.title")} ${inbox.counts.total}`,emphasize:inbox.counts.total>0},onHeaderStatusClick:inbox.show,updateChip:props.update?.hasUpdate?{label:t3("update.chip",{version:props.update.latest})}:null,onUpdateChipClick:pages.openUpdate,zenActive:props.zen,onZenClick:props.toggleZen,onFocusRequest:()=>focus.setFocused("sidebar"),recentTask:props.recentTask,cursorTaskIdRef:props.cursorTaskIdRef})}function nextActiveTask(tasks,excludeId){return tasks.find((t3)=>t3.id!==excludeId)}async function stopHostedTask(taskId,logger,logPrefix){let host=await openHostedSessionHost();if(!host)return;try{await killHostedSessions(host.rpc,hostedTaskKeys(await listHostedSessions(host.rpc),taskId))}catch(err){logger.error(`${logPrefix} kill hosted session failed:`,err)}finally{host.close()}}function removedTaskIsActive(orch,taskId){let read=orch.activeTaskSignal;if(typeof read!=="function")return!0;return read.call(orch)()===taskId}async function finishDeletedTaskFlow(opts){let nextTask=nextActiveTask(opts.tasks,opts.taskId);if(opts.updateActiveTask&&opts.orch&&removedTaskIsActive(opts.orch,opts.taskId))await opts.orch.setActiveTask(nextTask?.id??null).catch(()=>{});return await stopHostedTask(opts.taskId,opts.logger,opts.logPrefix),{nextTask}}async function deleteTaskFlow(ctx,taskId){if(!ctx.orch)return;let task=ctx.tasks().find((t3)=>t3.id===taskId);if(!task)return;if(task.kind==="main"){if(!await ctx.confirm({title:t("tasks.confirm.forgetProjectTitle",{title:task.title}),body:t("tasks.confirm.forgetProjectBody"),cancelLabel:t("tasks.confirm.cancel"),confirmLabel:t("tasks.confirm.forgetProjectConfirm")}))return;try{await ctx.orch.forgetProject(task.repo)}catch(err){ctx.logger.error(`${ctx.logPrefix} forget project failed:`,err),ctx.notifyError?.(t("tasks.toast.forgetProjectFailed",{error:errorMessage(err)}));return}await ctx.reload?.();return}if(!await ctx.confirm({title:t("tasks.confirm.deleteTitle",{title:task.title}),body:t(task.kind==="dir"?"tasks.confirm.deleteBodyDir":"tasks.confirm.deleteBodyTask"),cancelLabel:t("tasks.confirm.cancel"),confirmLabel:t("tasks.confirm.deleteConfirm"),danger:!0}))return;let deleted=!1;try{await ctx.orch.deleteTask(taskId),deleted=!0}catch(err){if(errorMessage(err).includes(DIRTY_WORKTREE_CODE)){if(await ctx.confirm({title:t("tasks.confirm.forceDeleteTitle",{title:task.title}),body:t("worktrees.delete.forceBody",{branch:task.branch||task.title}),cancelLabel:t("tasks.confirm.cancel"),confirmLabel:t("tasks.confirm.forceDeleteConfirm"),danger:!0}))try{await ctx.orch.deleteTask(taskId,{force:!0}),deleted=!0}catch(forceErr){ctx.logger.error(`${ctx.logPrefix} force delete failed:`,forceErr),ctx.notifyError?.(t("tasks.toast.deleteFailed",{title:task.title,error:errorMessage(forceErr)}))}}else ctx.logger.error(`${ctx.logPrefix} delete failed:`,err),ctx.notifyError?.(t("tasks.toast.deleteFailed",{title:task.title,error:errorMessage(err)}))}if(!deleted)return;let{nextTask}=await finishDeletedTaskFlow({orch:ctx.orch,tasks:ctx.tasks(),taskId,logger:ctx.logger,logPrefix:ctx.logPrefix,updateActiveTask:ctx.updateActiveTask});await ctx.reload?.(),ctx.onTaskDeleted?.(taskId,nextTask)}async function renameTaskFlow(ctx,taskId){let task=ctx.tasks().find((t3)=>t3.id===taskId);if(!task)return;let next=await ctx.promptText(task.title);if(!next||!ctx.orch)return;try{await ctx.orch.setTitle(taskId,next)}catch(err){ctx.logger.error(`${ctx.logPrefix} task.rename failed:`,err),ctx.notifyError?.(t("tasks.toast.renameFailed",{error:errorMessage(err)}));return}await ctx.reload?.()}async function applyVendorChange(ctx,taskId,next,opts={}){if(!ctx.orch)return!1;try{await ctx.orch.setVendor(taskId,next,opts.effort)}catch(err){return ctx.logger.error(`${ctx.logPrefix} task.setVendor failed:`,err),ctx.notifyError?.(t("tasks.toast.switchEngineFailed",{error:errorMessage(err)})),!1}if(!opts.silentSuccess)ctx.notifyInfo?.(t("tasks.toast.engineSwitched",{engine:engineDisplayName(next)}));return!0}async function cycleVendorFlow(ctx,taskId){let task=ctx.tasks().find((t3)=>t3.id===taskId);if(!task||!ctx.orch)return;let engines=await availableEngineIds(),next=nextVendorWithin(engines,task.vendor??DEFAULT_TASK_VENDOR);if(!await applyVendorChange(ctx,taskId,next))return;await ctx.reload?.()}async function setStatusFlow(ctx,taskId){let task=ctx.tasks().find((t3)=>t3.id===taskId);if(!task||!ctx.orch||!ctx.pickStatus)return;let next=await ctx.pickStatus(task.status);if(!next||next===task.status)return;try{await ctx.orch.setStatus(taskId,next)}catch(err){ctx.logger.error(`${ctx.logPrefix} task.status failed:`,err),ctx.notifyError?.(t("tasks.toast.setStatusFailed",{status:task.status,error:errorMessage(err)}));return}ctx.notifyInfo?.(t("tasks.toast.statusSet",{status:next})),await ctx.reload?.()}async function copyTaskFieldFlow(ctx,taskId,field){let task=ctx.tasks().find((candidate)=>candidate.id===taskId);if(!task||!ctx.copyText)return;let text=field==="branch"?task.branch:task.worktreePath;if(text==="")return;if(!await ctx.copyText(text)){ctx.notifyError?.(t("tasks.toast.copyFailed"));return}ctx.notifyInfo?.(t(field==="branch"?"tasks.toast.copiedBranch":"tasks.toast.copiedPath",{text}))}function mainRepoSet(tasks){let out=new Set;for(let task of tasks){if(task.kind!=="main")continue;let key=task.repo.trim().replace(/[\\/]+$/,"");if(key)out.add(key)}return out}async function createTaskFlow(ctx){let repos=getSavedRepos(),defaultRepo=ctx.cursorRepo()??repos[0]??process.cwd(),defaultVendor=ctx.lastVendor(defaultRepo)??DEFAULT_TASK_VENDOR,availableVendors=await availableEngineIds();if(availableVendors.length===0)ctx.notifyInfo?.("No engine CLI detected \u2014 install a supported engine, or add one in Settings \u2192 Engines");let orch=ctx.orch,result=await ctx.promptNewTask(defaultRepo,repos,{defaultVendor,availableVendors,discoverAdoptable:orch?(repo2)=>orch.discoverAdoptableWorktrees(repo2):void 0,mainRepos:mainRepoSet(ctx.tasks())});if(!result)return;let repo=addSavedRepo(result.repo).path;if(ctx.rememberVendor(repo,result.vendor),ctx.onRepoSaved?.(),!orch){ctx.logger.error(`${ctx.logPrefix} no daemon; cannot create task`),ctx.notifyError?.(t("tasks.toast.noDaemonWorktree"));return}if(result.mode==="open"){try{let main=await orch.ensureMainTask(repo);await ctx.reload?.(),ctx.selectTask?.(main.id),await ctx.enterTask?.(main.id)}catch(err){ctx.logger.error(`${ctx.logPrefix} ensureMainTask failed:`,err),ctx.notifyError?.(t("newTask.open.failed",{error:errorMessage(err)}))}return}ctx.notifyInfo?.("Creating task\u2026");let createdId;if(result.mode==="adopt"){let total=result.adopt.length,adopted=0,firstError;for(let w4 of result.adopt)try{createdId=(await orch.adoptWorktree({repo,worktreePath:w4.worktreePath,branch:w4.branch,vendor:result.vendor})).id,adopted++}catch(err){if(firstError===void 0)firstError=errorMessage(err);ctx.logger.error(`${ctx.logPrefix} adoptWorktree failed for ${w4.worktreePath}:`,err)}if(adopted===0){ctx.notifyError?.(t("newTask.adopt.summaryNone",{error:firstError??""}));return}if(adopted<total)ctx.notifyInfo?.(t("newTask.adopt.summaryPartial",{done:adopted,total}));else ctx.notifyInfo?.(t("newTask.adopt.summaryAll",{count:adopted}))}else try{createdId=(await orch.createTask({repo,baseRef:result.baseRef,vendor:result.vendor})).id}catch(err){ctx.logger.error(`${ctx.logPrefix} task.create failed:`,err),ctx.notifyError?.(t("tasks.toast.createFailed",{error:errorMessage(err)}));return}if(await ctx.reload?.(),createdId)ctx.selectTask?.(createdId),await ctx.enterTask?.(createdId)}import{TextAttributes as TextAttributes28}from"@opentui/core";var import_react75=__toESM(require_react_production(),1);function BranchPickerDialogView(props){let dialog=useDialog(),{theme}=useTheme(),t3=useT(),padX=useDialogPaddingX(),[value,setValue]=import_react75.useState(props.currentBranch),[cursor,setCursor]=import_react75.useState(0),branches=import_react75.useMemo(()=>listLocalBranches(props.repo),[props.repo]),filtered=import_react75.useMemo(()=>filterBranches(branches,value),[branches,value]),window2=windowAround(filtered,cursor,pickerVisibleRows(useTerminalDimensions().height));function move(delta){if(filtered.length===0)return;setCursor((c2)=>clampCursor(c2+delta,filtered.length))}function commit(name){let next=name.trim();if(!next)return;props.onSubmit(next),dialog.clear()}let rows=window2.items.map((name,i2)=>({key:`${window2.start+i2}:${name}`,body:name,accent:value.trim()===name}));return useBindings(()=>({bindings:[{key:"up",cmd:()=>move(-1)},{key:"down",cmd:()=>move(1)}]})),$jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:1,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsx("text",{attributes:TextAttributes28.BOLD,fg:theme.text,children:t3("tasks.reBranch.title")}),$jsx("text",{fg:theme.textMuted,onMouseUp:()=>props.onCancel(),children:"esc"})]}),$jsx(DialogSection,{label:t3("tasks.reBranch.fieldLabel"),focused:!0,children:$jsx(DialogField,{focused:!0,children:$jsx("input",{value,placeholder:props.currentBranch,focused:!0,onInput:(v3)=>{setValue(stripNewlines(v3)),setCursor(0)},onSubmit:()=>commit(resolveBaseRef(value,filtered,cursor))})})}),filtered.length===0?$jsx("box",{gap:0,paddingBottom:1,children:$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:branches.length===0?t3("tasks.reBranch.hintNoBranches"):t3("tasks.reBranch.hintNoMatch")})}):$jsx(PickerList,{window:window2,cursor,rows,onPick:(absoluteIndex)=>commit(filtered[absoluteIndex]??value),paddingBottom:1}),$jsx("box",{paddingBottom:1,children:$jsx("text",{fg:theme.textMuted,children:t3("tasks.reBranch.footer")})})]})}function show4(dialog,opts){return showDialog(dialog,(resolve)=>$jsx(BranchPickerDialogView,{currentBranch:opts.currentBranch,repo:opts.repo,onSubmit:(v3)=>resolve(v3),onCancel:()=>resolve(void 0)}))}var BranchPickerDialog={show:show4};var import_react76=__toESM(require_react_production(),1);import{TextAttributes as TextAttributes29}from"@opentui/core";var NO_EFFORT="";function effortLevelsOf(vendor){return engineEntry(vendor).effortLevels??[]}function seedEffort(vendor,current){let trimmed=current?.trim();return trimmed&&effortLevelsOf(vendor).includes(trimmed)?trimmed:NO_EFFORT}function EnginePickerDialogView(props){let dialog=useDialog(),{theme}=useTheme(),t3=useT(),padX=useDialogPaddingX(),{engines}=props,[cursor,setCursor]=import_react76.useState(()=>Math.max(0,engines.indexOf(props.current))),[effort,setEffort]=import_react76.useState(()=>seedEffort(props.current,props.currentEffort)),window2={items:[...engines],start:0,total:engines.length},cursorEngine=engines[cursor]??props.current,levels=effortLevelsOf(cursorEngine),effortChoices=levels.length>0?[NO_EFFORT,...levels]:[];function move(delta){setCursor((c2)=>{let next=clampCursor(c2+delta,engines.length);return setEffort((e2)=>seedEffort(engines[next]??props.current,e2)),next})}function stepEffort(delta){if(effortChoices.length===0)return;let i2=effortChoices.indexOf(effort);setEffort(effortChoices[clampCursor((i2<0?0:i2)+delta,effortChoices.length)]??NO_EFFORT)}function commit(engine){let applicable=effortLevelsOf(engine);props.onSubmit({vendor:engine,...applicable.length>0?{effort:seedEffort(engine,effort)}:{}}),dialog.clear()}let rows=engines.map((engine,i2)=>({key:`${i2}:${engine}`,body:engineDisplayName(engine),accent:engine===props.current,dim:engine===props.current?t3("tasks.changeEngine.current"):void 0}));return useBindings(()=>({bindings:[{key:"up",cmd:()=>move(-1)},{key:"down",cmd:()=>move(1)},{key:"left",cmd:()=>stepEffort(-1)},{key:"right",cmd:()=>stepEffort(1)},{key:"return",cmd:()=>commit(engines[cursor]??props.current)}]})),$jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:1,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsx("text",{attributes:TextAttributes29.BOLD,fg:theme.text,children:t3("tasks.changeEngine.title")}),$jsx("text",{fg:theme.textMuted,onMouseUp:()=>props.onCancel(),children:"esc"})]}),$jsx(PickerList,{window:window2,cursor,rows,onPick:(absoluteIndex)=>commit(engines[absoluteIndex]??props.current),paddingBottom:effortChoices.length>0?0:1}),effortChoices.length>0?$jsx(DialogSection,{label:t3("tasks.changeEngine.effortLabel"),focused:!1,hint:"\u2190/\u2192",children:$jsx(ChipRow,{choices:effortChoices,selected:effort,display:(choice)=>choice===NO_EFFORT?t3("tasks.changeEngine.noEffort"):choice,onPick:(choice)=>setEffort(choice)})}):null,$jsx("box",{paddingBottom:1,children:$jsx("text",{fg:theme.textMuted,children:effortChoices.length>0?t3("tasks.changeEngine.footerEffort"):t3("tasks.changeEngine.footer")})})]})}function show5(dialog,opts){return showDialog(dialog,(resolve)=>$jsx(EnginePickerDialogView,{engines:opts.engines,current:opts.current,currentEffort:opts.currentEffort,onSubmit:(v3)=>resolve(v3),onCancel:()=>resolve(void 0)}))}var EnginePickerDialog={show:show5};var import_react77=__toESM(require_react_production(),1);import{TextAttributes as TextAttributes30}from"@opentui/core";function formatAt(at2){let d2=new Date(at2);if(Number.isNaN(d2.getTime()))return at2;let pad=(n2)=>String(n2).padStart(2,"0");return`${d2.getFullYear()}-${pad(d2.getMonth()+1)}-${pad(d2.getDate())} ${pad(d2.getHours())}:${pad(d2.getMinutes())}`}function FieldNotesDialogView(props){let{theme}=useTheme(),t3=useT(),dialog=useDialog(),padX=useDialogPaddingX(),[state,setState]=import_react77.useState({kind:"loading"}),[cursor,setCursor]=import_react77.useState(0);import_react77.useEffect(()=>{let live=!0;return props.load().then((notes2)=>{if(live)setState({kind:"ready",notes:notes2})}).catch((err)=>{if(live)setState({kind:"error",message:err instanceof Error?err.message:String(err)})}),()=>{live=!1}},[props.load]);let notes=state.kind==="ready"?state.notes:[];import_react77.useEffect(()=>{setCursor((c2)=>Math.max(0,Math.min(c2,notes.length-1)))},[notes.length]);let follow=useCursorFollow(cursor),scrollRef=import_react77.useRef(null),moveCursor=(delta)=>{if(notes.length===0)return;setCursor((c2)=>Math.max(0,Math.min(notes.length-1,c2+delta)))};function requestDelete(){let note=notes[cursor],remove=props.remove;if(!note||!remove||note.id===void 0)return;let id=note.id;DialogConfirm.show(dialog,t3("tasks.fieldNotes.confirmDelete.title"),t3("tasks.fieldNotes.confirmDelete.body",{text:note.text}),void 0,void 0,{danger:!0}).then(async(confirmed)=>{if(confirmed!==!0)return;await remove(id).catch(()=>!1)})}return useBindings(()=>({bindings:[{key:"up",cmd:()=>moveCursor(-1)},{key:"down",cmd:()=>moveCursor(1)},{key:"pageup",cmd:()=>moveCursor(-(scrollRef.current?.viewport.height??10))},{key:"pagedown",cmd:()=>moveCursor(scrollRef.current?.viewport.height??10)},...props.remove?[{key:"d",cmd:()=>requestDelete()}]:[]]})),$jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:1,flexShrink:1,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",flexShrink:0,children:[$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{attributes:TextAttributes30.BOLD,fg:theme.text,children:t3("tasks.fieldNotes.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:props.repo})]}),$jsx("text",{fg:theme.textMuted,onMouseUp:props.onClose,children:"esc"})]}),$jsx("scrollbox",{ref:(r6)=>{return scrollRef.current=r6,follow.scrollRef(r6)},flexShrink:1,stickyScroll:!1,verticalScrollbarOptions:{trackOptions:{backgroundColor:theme.backgroundDialog,foregroundColor:theme.borderActive}},children:$jsxs("box",{gap:1,paddingRight:1,children:[state.kind==="loading"?$jsx("text",{fg:theme.textMuted,children:t3("tasks.fieldNotes.loading")}):null,state.kind==="error"?$jsx("text",{fg:theme.error,children:state.message}):null,state.kind==="ready"&&notes.length===0?$jsx("text",{fg:theme.textMuted,children:t3("tasks.fieldNotes.empty")}):null,notes.map((note,i2)=>{let selected=i2===cursor;return $jsxs("box",{gap:0,ref:follow.rowRef(i2),onMouseUp:()=>setCursor(i2),children:[$jsx("text",{fg:theme.accent,wrapMode:"none",children:`${selected?"\u25B8 ":" "}${formatAt(note.at)} \xB7 ${note.author}`}),$jsx("text",{fg:selected?theme.text:theme.textMuted,children:` ${note.text}`})]},`${note.at}:${i2}`)})]})}),$jsx("box",{paddingBottom:1,flexShrink:0,children:$jsx("text",{fg:theme.textMuted,children:props.remove?t3("tasks.fieldNotes.footerDeletable"):t3("tasks.fieldNotes.footer")})})]})}function show6(dialog,opts){let{repo,orchestrator}=opts;showDialog(dialog,(resolve)=>$jsx(FieldNotesDialogView,{repo,load:()=>orchestrator.listFieldNotes(repo),remove:async(id)=>{let deleted=await orchestrator.deleteFieldNote(repo,id);if(deleted)show6(dialog,opts);return deleted},onClose:()=>resolve(void 0)}))}var FieldNotesDialog={show:show6};var import_react78=__toESM(require_react_production(),1);import{TextAttributes as TextAttributes31}from"@opentui/core";function RunAgainDialogView(props){let{theme}=useTheme(),t3=useT(),dialog=useDialog(),padX=useDialogPaddingX(),[active,setActive]=import_react78.useState("confirm"),commit=()=>{props.onConfirm(),dialog.clear({refocus:!1})},cancel=()=>{props.onCancel(),dialog.clear()},scrollRef=import_react78.useRef(null),scrollBy=(lines)=>{let scroll=scrollRef.current;if(!scroll)return;scroll.scrollTo({x:0,y:Math.max(0,scroll.scrollTop+lines)})};return useBindings(()=>({bindings:[{key:"up",cmd:()=>scrollBy(-1)},{key:"down",cmd:()=>scrollBy(1)},{key:"pageup",cmd:()=>scrollBy(-(scrollRef.current?.viewport.height??10))},{key:"pagedown",cmd:()=>scrollBy(scrollRef.current?.viewport.height??10)},{key:"left",cmd:()=>setActive((a2)=>a2==="confirm"?"cancel":"confirm")},{key:"right",cmd:()=>setActive((a2)=>a2==="confirm"?"cancel":"confirm")},{key:"return",cmd:()=>active==="confirm"?commit():cancel()}]})),$jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:1,flexShrink:1,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",flexShrink:0,children:[$jsxs("box",{flexDirection:"column",gap:0,children:[$jsx("text",{attributes:TextAttributes31.BOLD,fg:theme.text,children:t3("tasks.runAgain.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("tasks.runAgain.source",{title:props.taskTitle})})]}),$jsx("text",{fg:theme.textMuted,onMouseUp:cancel,children:"esc"})]}),$jsx("scrollbox",{ref:(r6)=>{scrollRef.current=r6},flexShrink:1,stickyScroll:!1,verticalScrollbarOptions:{trackOptions:{backgroundColor:theme.backgroundDialog,foregroundColor:theme.borderActive}},children:$jsx("box",{paddingRight:1,children:$jsx("text",{fg:theme.text,children:props.prompt})})}),$jsx("text",{fg:theme.textMuted,flexShrink:0,children:t3("tasks.runAgain.hint")}),$jsx("box",{flexDirection:"row",justifyContent:"flex-end",flexShrink:0,children:["cancel","confirm"].map((key)=>$jsx("box",{paddingLeft:1,paddingRight:1,backgroundColor:key===active?theme.primary:void 0,onMouseUp:()=>key==="confirm"?commit():cancel(),children:$jsx("text",{fg:key===active?theme.selectedListItemText:theme.textMuted,children:key==="cancel"?t3("common.cancel"):t3("tasks.runAgain.confirm")})},key))}),$jsx("box",{paddingBottom:1,flexShrink:0,children:$jsx("text",{fg:theme.textMuted,children:t3("tasks.runAgain.footer")})})]})}function show7(dialog,opts){return showDialog(dialog,(resolve)=>$jsx(RunAgainDialogView,{taskTitle:opts.taskTitle,prompt:opts.prompt,onConfirm:()=>resolve(!0),onCancel:()=>resolve(!1)}),{size:"medium"})}var RunAgainDialog={show:show7};var import_react79=__toESM(require_react_production(),1);var STATUS_LABEL_KEY={backlog:"tasks.status.backlog",in_progress:"tasks.status.inProgress",in_review:"tasks.status.inReview",done:"tasks.status.done",canceled:"tasks.status.canceled",error:"tasks.status.error"};function StatusPickerDialogView(props){let dialog=useDialog(),t3=useT(),padX=useDialogPaddingX(),[cursor,setCursor]=import_react79.useState(()=>Math.max(0,TASK_STATUSES.indexOf(props.current))),window2={items:[...TASK_STATUSES],start:0,total:TASK_STATUSES.length};function move(delta){setCursor((c2)=>clampCursor(c2+delta,TASK_STATUSES.length))}function commit(status){props.onSubmit(status),dialog.clear()}let rows=TASK_STATUSES.map((status,i2)=>({key:`${i2}:${status}`,body:t3(STATUS_LABEL_KEY[status]),accent:status===props.current,dim:status===props.current?t3("tasks.setStatus.current"):void 0}));return useBindings(()=>({bindings:[{key:"up",cmd:()=>move(-1)},{key:"down",cmd:()=>move(1)},{key:"return",cmd:()=>commit(TASK_STATUSES[cursor]??props.current)}]})),$jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:1,children:[$jsx(DialogHeader,{title:t3("tasks.setStatus.title"),onClose:()=>props.onCancel()}),$jsx(PickerList,{window:window2,cursor,rows,onPick:(absoluteIndex)=>commit(TASK_STATUSES[absoluteIndex]??props.current),paddingBottom:1}),$jsx(DialogFooter,{children:t3("tasks.setStatus.footer")})]})}function show8(dialog,opts){return showDialog(dialog,(resolve)=>$jsx(StatusPickerDialogView,{current:opts.current,onSubmit:(v3)=>resolve(v3),onCancel:()=>resolve(void 0)}))}var StatusPickerDialog={show:show8};function AdoptTab({vm}){let{theme}=useTheme(),t3=useT(),rows=vm.adoptVisible.map((w4)=>{let tags=[w4.dirty===!0?"dirty":w4.dirty===null?"dirty?":"",w4.kobeManaged?"":"external"].filter(Boolean).join(",");return{key:w4.path,body:`${vm.adoptSelected.has(w4.path)?"[x] ":"[ ] "}${w4.branch}${tags?` (${tags})`:""}`,accent:vm.adoptSelected.has(w4.path)}});return $jsxs($Fragment,{children:[$jsx(DialogSection,{label:t3("newTask.field.adoptFilter"),focused:vm.field==="adoptFilter",onPress:()=>vm.setField("adoptFilter"),children:$jsx(DialogField,{focused:vm.field==="adoptFilter",children:$jsx("input",{value:vm.adoptFilter,placeholder:t3("newTask.placeholder.adoptFilter"),focused:vm.field==="adoptFilter",onMouseUp:()=>vm.setField("adoptFilter"),onInput:(v3)=>vm.setAdoptFilterText(v3),onSubmit:()=>vm.toggleAdoptCursor()})})}),$jsx("box",{paddingLeft:2,children:$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("newTask.adopt.repoLine",{path:vm.expandedRepo||t3("newTask.adopt.repoNone")})})}),vm.adoptLoading?$jsx("box",{paddingLeft:2,children:$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("newTask.hint.scanningWorktrees")})}):null,!vm.adoptLoading&&vm.adoptList.length===0?$jsx("box",{paddingLeft:2,children:$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:vm.adoptDiscoveredCount===0?t3("newTask.adopt.noUnlinked"):t3("newTask.adopt.noMatch")})}):null,vm.adoptList.length>0?$jsx(PickerList,{window:vm.adoptWindow,cursor:vm.adoptCursor,rows,onPick:vm.pickAdoptAt,footer:$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:vm.adoptSelected.size>0?t3("newTask.adopt.hintSelected",{count:vm.adoptSelected.size}):t3("newTask.adopt.hintDefault")})}):null]})}function CloneTab({vm}){let{theme}=useTheme(),t3=useT(),parentRows=vm.cloneParentWindow.items.map((name,i2)=>({key:`${vm.cloneParentWindow.start+i2}:${name}`,body:`${name}/`}));return $jsxs($Fragment,{children:[$jsx(DialogSection,{label:t3("newTask.field.gitUrl"),focused:vm.field==="cloneUrl",onPress:()=>vm.setField("cloneUrl"),children:$jsx(DialogField,{focused:vm.field==="cloneUrl",children:$jsx("input",{value:vm.cloneUrl,placeholder:"https://github.com/user/repo.git",focused:vm.field==="cloneUrl",onMouseUp:()=>vm.setField("cloneUrl"),onInput:(v3)=>vm.setCloneUrlText(v3),onSubmit:()=>{if(!vm.cloneUrl.trim())return;vm.setField("cloneParent")}})})}),$jsx(DialogSection,{label:t3("newTask.field.parentDir"),focused:vm.field==="cloneParent",onPress:()=>vm.setField("cloneParent"),children:$jsx(DialogField,{focused:vm.field==="cloneParent",children:$jsx("input",{value:vm.cloneParent,placeholder:"~/",focused:vm.field==="cloneParent",onMouseUp:()=>vm.setField("cloneParent"),onInput:(v3)=>vm.setCloneParentText(v3),onSubmit:()=>vm.onCloneParentSubmit()})})}),vm.field==="cloneParent"?$jsx("box",{paddingLeft:2,children:$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("newTask.hint.remembered")})}):null,vm.field==="cloneParent"&&vm.cloneParentFiltered.length>0&&!vm.cloneParentPicked?$jsx(PickerList,{window:vm.cloneParentWindow,cursor:vm.cloneParentCursor,rows:parentRows,onPick:vm.selectCloneParentAt}):null,$jsx(DialogSection,{label:t3("newTask.field.folderName"),focused:vm.field==="cloneFolder",onPress:()=>vm.setField("cloneFolder"),children:$jsx(DialogField,{focused:vm.field==="cloneFolder",children:$jsx("input",{value:vm.cloneFolder,placeholder:t3("newTask.placeholder.folderName"),focused:vm.field==="cloneFolder",onMouseUp:()=>vm.setField("cloneFolder"),onInput:(v3)=>vm.setCloneFolderText(v3),onSubmit:()=>vm.setField("cloneBaseRef")})})}),$jsx(DialogSection,{label:t3("newTask.field.baseBranch"),focused:vm.field==="cloneBaseRef",onPress:()=>vm.setField("cloneBaseRef"),children:$jsx(DialogField,{focused:vm.field==="cloneBaseRef",children:$jsx("input",{value:vm.cloneBaseRef,placeholder:DEFAULT_BASE_REF,focused:vm.field==="cloneBaseRef",onMouseUp:()=>vm.setField("cloneBaseRef"),onInput:(v3)=>vm.setCloneBaseRefText(v3),onSubmit:()=>void vm.commitClone()})})}),vm.cloneInFlight?$jsx("box",{gap:0,paddingLeft:2,children:$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:vm.cloneProgress||t3("newTask.clone.progressFallback")})}):null]})}var REPO_INPUT_CELLS=28;function ExistingTab({vm}){let{theme}=useTheme(),t3=useT(),repoRows=vm.activeWindow.items.map((name,i2)=>{let tag=vm.mode==="saved"&&name===vm.defaultRepo?` ${t3("newTask.hint.currentDir")}`:"";if(vm.mode==="browse")return{key:`${vm.activeWindow.start+i2}:${name}`,body:`${name}/${tag}`,accent:!1};let{base,dir}=splitRepoRow(name);return{key:`${vm.activeWindow.start+i2}:${name}`,body:`${base}${tag}`,accent:vm.expandedRepo===name,...dir?{dim:dir}:{}}}),branchRows=vm.branchWindow.items.map((name,i2)=>({key:`${vm.branchWindow.start+i2}:${name}`,body:name,accent:vm.baseRef.trim()===name})),intents=["task","project"],intentLabel={task:t3("newTask.intent.task"),project:t3("newTask.intent.project")};return $jsxs($Fragment,{children:[$jsx(DialogSection,{label:t3("newTask.field.repo"),focused:vm.field==="repo",onPress:()=>vm.setField("repo"),children:$jsx(DialogField,{focused:vm.field==="repo",children:$jsxs("box",{flexDirection:"row",children:[$jsx("input",{value:vm.repo,placeholder:splitRepoRow(vm.defaultRepo).base,focused:vm.field==="repo",onMouseUp:()=>vm.setField("repo"),onInput:(v3)=>vm.setRepoText(v3),onSubmit:()=>vm.onRepoSubmit(),flexGrow:vm.repoDir?0:1,flexShrink:0,...vm.repoDir?{flexBasis:REPO_INPUT_CELLS}:{}}),vm.repoDir?$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:1,children:` ${vm.repoDir}`}):null]})})}),vm.field==="repo"&&vm.activeList.length>0&&!vm.repoPicked?$jsx(PickerList,{window:vm.activeWindow,cursor:vm.repoCursor,rows:repoRows,onPick:vm.selectRepoAt}):null,vm.canOpenProject?$jsx(DialogSection,{label:t3("newTask.field.opens"),focused:vm.field==="intent",hint:"\u2190/\u2192",onPress:()=>vm.setField("intent"),children:$jsx(ChipRow,{choices:intents,selected:vm.intent,display:(choice)=>intentLabel[choice],onPick:(choice)=>{vm.setIntent(choice),vm.setField("intent")}})}):null,vm.intent==="project"&&vm.canOpenProject?null:$jsx(DialogSection,{label:t3("newTask.field.fromBranch"),focused:vm.field==="baseRef",onPress:()=>vm.setField("baseRef"),children:$jsx(DialogField,{focused:vm.field==="baseRef",children:$jsx("input",{value:vm.baseRef,placeholder:DEFAULT_BASE_REF,focused:vm.field==="baseRef",onMouseUp:()=>vm.setField("baseRef"),onInput:(v3)=>vm.setBaseRefText(v3),onSubmit:()=>vm.onBaseRefSubmit()})})}),vm.field==="baseRef"&&vm.branchFiltered.length===0&&vm.submitError==null?$jsx("box",{gap:0,paddingLeft:2,paddingBottom:1,children:$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:vm.branches.length===0?t3("newTask.hint.noBranchesFound"):t3("newTask.hint.noMatchBranch")})}):null,vm.field==="baseRef"&&vm.branchFiltered.length>0?$jsx(PickerList,{window:vm.branchWindow,cursor:vm.branchCursor,rows:branchRows,onPick:vm.pickBranchAt,paddingBottom:1}):null]})}var import_react88=__toESM(require_react_production(),1);function resolveVendorSet(available){return available&&available.length>0?available:ALL_VENDORS}function resolveInitialVendor(set,preferred){let pref=preferred??DEFAULT_TASK_VENDOR;return set.includes(pref)?pref:set[0]??DEFAULT_TASK_VENDOR}function toggleInSet(prev,path){let next=new Set(prev);if(next.has(path))next.delete(path);else next.add(path);return next}function toggleSelectAll(prev,paths){if(paths.length===0)return prev;return paths.every((p3)=>prev.has(p3))?new Set:new Set(paths)}var import_react81=__toESM(require_react_production(),1);function useAdoptState(args){let[adoptFilter,setAdoptFilter]=import_react81.useState(""),[adoptCursor,setAdoptCursor]=import_react81.useState(0),[adoptSelected,setAdoptSelected]=import_react81.useState(new Set),[adoptable,setAdoptable]=import_react81.useState(void 0),[adoptLoading,setAdoptLoading]=import_react81.useState(!1),adoptList=import_react81.useMemo(()=>filterAdoptableByGlob(adoptable??[],adoptFilter),[adoptable,adoptFilter]),adoptWindow=windowAround(adoptList.map((w4)=>w4.path),adoptCursor,pickerVisibleRows(useTerminalDimensions().height)),adoptVisible=adoptList.slice(adoptWindow.start,adoptWindow.start+adoptWindow.items.length),adoptDiscoveredCount=(adoptable??[]).length,{active,expandedRepo,discoverAdoptable}=args;import_react81.useEffect(()=>{if(!active)return;let disposed=!1;return setAdoptLoading(!0),(async()=>{let list=[];try{list=discoverAdoptable?await discoverAdoptable(expandedRepo):[]}catch{list=[]}if(disposed)return;setAdoptable(list),setAdoptLoading(!1)})(),()=>{disposed=!0}},[active,expandedRepo,discoverAdoptable]),import_react81.useEffect(()=>{setAdoptCursor((c2)=>clampCursor(c2,adoptList.length))},[adoptList]);let prevRepo=import_react81.useRef(void 0);import_react81.useEffect(()=>{if(prevRepo.current!==void 0&&prevRepo.current!==expandedRepo)setAdoptSelected(new Set),setAdoptCursor(0);prevRepo.current=expandedRepo},[expandedRepo]);function setAdoptFilterText(v3){setAdoptFilter(stripNewlines(v3))}function toggleAdopt(path){setAdoptSelected((prev)=>toggleInSet(prev,path))}function toggleAdoptCursor(){let w4=adoptList[adoptCursor];if(w4)toggleAdopt(w4.path)}function pickAdoptAt(absoluteIndex){let w4=adoptList[absoluteIndex];if(!w4)return;setAdoptCursor(absoluteIndex),toggleAdopt(w4.path)}function adoptSelectAll(){setAdoptSelected((prev)=>toggleSelectAll(prev,adoptList.map((w4)=>w4.path)))}function moveAdoptCursor(delta){if(adoptList.length===0)return;setAdoptCursor((c2)=>clampCursor(c2+delta,adoptList.length))}function commitAdopt(){if(adoptList.length===0){args.setSubmitError(t("newTask.error.noAdoptable"));return}let chosen=adoptSelected.size>0?adoptList.filter((w4)=>adoptSelected.has(w4.path)):adoptList.slice(adoptCursor,adoptCursor+1);if(chosen.length===0)return;args.onSubmit({mode:"adopt",repo:expandedRepo,vendor:args.vendor,adopt:chosen.map((w4)=>({worktreePath:w4.path,branch:w4.branch}))}),args.clearDialog()}return{adoptFilter,adoptLoading,adoptDiscoveredCount,adoptList,adoptWindow,adoptVisible,adoptCursor,adoptSelected,setAdoptFilterText,toggleAdoptCursor,pickAdoptAt,adoptSelectAll,moveAdoptCursor,commitAdopt}}var import_react82=__toESM(require_react_production(),1);function useBranchField(opts){let[baseRef,setBaseRef]=import_react82.useState(()=>getCurrentBranch(expandHome(opts.defaultRepo.trim()))??DEFAULT_BASE_REF),[baseRefTouched,setBaseRefTouched]=import_react82.useState(!1),[branchCursor,setBranchCursor]=import_react82.useState(0),branches=import_react82.useMemo(()=>listLocalBranches(opts.expandedRepo),[opts.expandedRepo]),branchFiltered=import_react82.useMemo(()=>filterBranches(branches,baseRef),[branches,baseRef]),branchWindow=windowAround(branchFiltered,branchCursor,opts.pickerRows);import_react82.useEffect(()=>{if(!opts.expandedRepo||baseRefTouched)return;let current=getCurrentBranch(opts.expandedRepo);if(current)setBaseRef(current)},[opts.expandedRepo,baseRefTouched]);function setBaseRefText(v3){setBaseRefTouched(!0),setBaseRef(stripNewlines(v3)),setBranchCursor(0)}function pickBranchAt(absoluteIndex){let name=branchFiltered[absoluteIndex];if(!name)return;setBaseRef(name),setBaseRefTouched(!0),setBranchCursor(absoluteIndex),opts.onPicked()}function onBaseRefSubmit(){setBaseRef(resolveBaseRef(baseRef,branchFiltered,branchCursor)),setBaseRefTouched(!0),opts.commit()}function moveBranchCursor(delta){if(branchFiltered.length===0)return;setBranchCursor((c2)=>clampCursor(c2+delta,branchFiltered.length))}function resetBranchCursor(){setBranchCursor(0)}return{baseRef,branches,branchFiltered,branchWindow,branchCursor,setBaseRefText,pickBranchAt,onBaseRefSubmit,moveBranchCursor,resetBranchCursor}}var import_react85=__toESM(require_react_production(),1);import{spawn as spawn4}from"child_process";import*as fs2 from"fs";import*as path from"path";function deriveFolderName(url){let trimmed=url.trim().replace(/\/+$/,"");if(!trimmed)return"";let lastSlash=trimmed.lastIndexOf("/"),lastColon=trimmed.lastIndexOf(":"),cutAt=Math.max(lastSlash,lastColon);return(cutAt>=0?trimmed.slice(cutAt+1):trimmed).replace(/\.git$/i,"")}function validateGitUrl(url){let trimmed=url.trim();if(!trimmed)return t("newTask.error.gitUrlRequired");let hasProtocol=trimmed.includes("://"),hasScpSep=trimmed.includes("@")&&trimmed.includes(":"),hasPathSep=trimmed.includes("/");if(!hasProtocol&&!hasScpSep&&!hasPathSep)return t("newTask.error.gitUrlInvalid",{url:trimmed});return null}function validateCloneTarget(parentDir,folder){let folderTrimmed=folder.trim();if(!folderTrimmed)return t("newTask.error.folderRequired");if(folderTrimmed.includes("/")||folderTrimmed.includes("\\"))return t("newTask.error.folderHasSeparator");let parentTrimmed=parentDir.trim();if(!parentTrimmed)return t("newTask.error.parentRequired");let parentExpanded=expandHome(parentTrimmed),parentStat;try{parentStat=fs2.statSync(parentExpanded)}catch{return t("newTask.error.parentNotFound",{path:parentExpanded})}if(!parentStat.isDirectory())return t("newTask.error.parentNotDir",{path:parentExpanded});let target2=path.join(parentExpanded,folderTrimmed);if(fs2.existsSync(target2))return t("newTask.error.targetExists",{path:target2});return null}function resolveCloneTarget(parentDir,folder){return path.join(expandHome(parentDir.trim()),folder.trim())}function findAvailableFolderName(parentDir,base){let trimmed=base.trim();if(!trimmed)return base;let parentExpanded=expandHome(parentDir.trim());if(!parentExpanded)return base;try{if(!fs2.statSync(parentExpanded).isDirectory())return base}catch{return base}if(!fs2.existsSync(path.join(parentExpanded,trimmed)))return trimmed;for(let n2=2;n2<1000;n2++){let candidate=`${trimmed}-${n2}`;if(!fs2.existsSync(path.join(parentExpanded,candidate)))return candidate}return trimmed}function cloneRepo(url,target2,onProgress){return new Promise((resolve)=>{let stderrBuf="";try{let child=spawn4("git",["clone","--progress",url,target2],{stdio:["ignore","ignore","pipe"],env:{...process.env,GIT_TERMINAL_PROMPT:"0",GIT_ASKPASS:""}});child.stderr?.setEncoding("utf-8"),child.stderr?.on("data",(chunk)=>{if(stderrBuf+=chunk,onProgress){let lines=chunk.split(/[\r\n]+/).filter((s2)=>s2.trim().length>0),last=lines[lines.length-1];if(last)onProgress(last)}}),child.on("error",(err)=>{resolve({ok:!1,error:err.message})}),child.on("close",(code)=>{if(code===0){resolve({ok:!0,path:target2});return}let tail=stderrBuf.split(/[\r\n]+/).filter((s2)=>s2.trim().length>0).pop()??`git clone exited with ${code}`;resolve({ok:!1,error:tail})})}catch(err){resolve({ok:!1,error:errorMessage(err)})}})}function splitRepoInput(value,resolved){if(!resolved)return{name:value,dir:""};let{base,dir}=splitRepoRow(value.trim());return{name:base,dir}}function resolveRepoInput(value,repoOptions){let trimmed=value.trim();if(!trimmed||isRepoPathInput(trimmed))return{kind:"path",path:trimmed};let matches=repoOptions.filter((p3)=>splitRepoRow(p3).base===trimmed);if(matches.length===1)return{kind:"path",path:matches[0]};if(matches.length>1)return{kind:"ambiguous",name:trimmed,matches};return{kind:"path",path:trimmed}}function nameOrPath(path2,repoOptions){let name=splitRepoInput(path2,!0).name,back=resolveRepoInput(name,repoOptions);return back.kind==="path"&&samePath(back.path,path2)?name:path2}function completeRepoInput(args){let{value,mode,highlighted,baseExpanded,repoOptions}=args;if(!highlighted)return null;if(mode==="browse"){let next2=joinDrill(value,baseExpanded,highlighted);return next2===value?null:{value:next2,collapse:!1}}let next=nameOrPath(highlighted,repoOptions);return next===value.trim()?null:{value:next,collapse:!0}}var import_react83=__toESM(require_react_production(),1);function useDerivedDir(value){let split=import_react83.useMemo(()=>splitPathForDirSuggest(value),[value]),filtered=import_react83.useMemo(()=>filterSubdirs(listSubdirs(split.base),split.filter),[split]);return{split,filtered}}function useCloneState(args){let[cloneUrl,setCloneUrl]=import_react85.useState(""),[cloneParent,setCloneParent]=import_react85.useState(args.defaultCloneParent?.trim()?args.defaultCloneParent:"~/"),[cloneFolder,setCloneFolder]=import_react85.useState(""),[cloneFolderTouched,setCloneFolderTouched]=import_react85.useState(!1),[cloneBaseRef,setCloneBaseRef]=import_react85.useState(DEFAULT_BASE_REF),[cloneInFlight,setCloneInFlight]=import_react85.useState(!1),[cloneProgress,setCloneProgress]=import_react85.useState(""),[cloneParentCursor,setCloneParentCursor]=import_react85.useState(0),[cloneParentPicked,setCloneParentPicked]=import_react85.useState(!1),{split:cloneParentSplit,filtered:cloneParentFiltered}=useDerivedDir(cloneParent),cloneParentWindow=windowAround(cloneParentFiltered,cloneParentCursor,pickerVisibleRows(useTerminalDimensions().height));import_react85.useEffect(()=>{if(cloneFolderTouched)return;setCloneFolder(findAvailableFolderName(cloneParent,deriveFolderName(cloneUrl)))},[cloneUrl,cloneParent,cloneFolderTouched]);function setCloneUrlText(v3){setCloneUrl(stripNewlines(v3))}function setCloneParentText(v3){setCloneParentPicked(!1),setCloneParent(stripNewlines(v3)),setCloneParentCursor(0)}function setCloneFolderText(v3){setCloneFolderTouched(!0),setCloneFolder(stripNewlines(v3))}function setCloneBaseRefText(v3){setCloneBaseRef(stripNewlines(v3))}function onCloneParentSubmit(){let picked=cloneParentFiltered[cloneParentCursor];if(picked)setCloneParent(joinPicked(cloneParent,cloneParentSplit.base,picked)),setCloneParentCursor(0),setCloneParentPicked(!0);args.setField("cloneFolder")}function completeCloneParent(){if(cloneParentPicked)return!1;let done=completeRepoInput({value:cloneParent,mode:"browse",highlighted:cloneParentFiltered[cloneParentCursor],baseExpanded:cloneParentSplit.base,repoOptions:[]});if(!done)return!1;return setCloneParent(done.value),setCloneParentCursor(0),!0}function selectCloneParentAt(absoluteIndex){let picked=cloneParentFiltered[absoluteIndex];if(!picked)return;setCloneParent(joinPicked(cloneParent,cloneParentSplit.base,picked)),setCloneParentCursor(absoluteIndex),setCloneParentPicked(!0),args.setField("cloneFolder")}function moveParentCursor(delta){if(cloneParentFiltered.length===0)return;setCloneParentCursor((c2)=>clampCursor(c2+delta,cloneParentFiltered.length))}async function commitClone(){if(cloneInFlight)return;let urlReason=validateGitUrl(cloneUrl);if(urlReason){args.setSubmitError(urlReason),args.setField("cloneUrl");return}let targetReason=validateCloneTarget(cloneParent,cloneFolder);if(targetReason){args.setSubmitError(targetReason);let folder=cloneFolder.trim(),parentAtFault=!(!folder||folder.includes("/")||folder.includes("\\"))&&validateCloneTarget(cloneParent,"__kobe_probe__")!=null;args.setField(parentAtFault?"cloneParent":"cloneFolder");return}let target2=resolveCloneTarget(cloneParent,cloneFolder);setCloneInFlight(!0),setCloneProgress(t("newTask.clone.progressInto",{target:target2}));let result=await cloneRepo(cloneUrl.trim(),target2,(line)=>setCloneProgress(line));if(setCloneInFlight(!1),!result.ok){args.setSubmitError(t("newTask.error.cloneFailed",{error:result.error})),args.setField("cloneUrl");return}let b3=cloneBaseRef.trim()||DEFAULT_BASE_REF;args.onSubmit({repo:result.path,baseRef:b3,vendor:args.vendor,cloned:{parentDir:expandHome(cloneParent.trim())}}),args.clearDialog()}return{cloneUrl,cloneParent,cloneFolder,cloneBaseRef,cloneInFlight,cloneProgress,cloneParentFiltered,cloneParentWindow,cloneParentCursor,cloneParentPicked,completeCloneParent,setCloneUrlText,setCloneParentText,setCloneFolderText,setCloneBaseRefText,onCloneParentSubmit,selectCloneParentAt,moveParentCursor,commitClone}}var import_react86=__toESM(require_react_production(),1);function useRepoField(opts){let[repo,setRepo]=import_react86.useState(()=>nameOrPath(opts.defaultRepo,computeRepoOptions(opts.defaultRepo,opts.savedRepos))),[repoCursor,setRepoCursor]=import_react86.useState(0),[repoPicked,setRepoPicked]=import_react86.useState(!1),repoOptions=import_react86.useMemo(()=>computeRepoOptions(opts.defaultRepo,opts.savedRepos),[opts.defaultRepo,opts.savedRepos]),mode=pickerModeFor(repo,repoOptions),repoResolution=resolveRepoInput(repo,repoOptions),repoDir=repoResolution.kind==="path"&&repoResolution.path!==repo.trim()?splitRepoInput(repoResolution.path,!0).dir:"",{split:subdirSplit,filtered:subdirFiltered}=useDerivedDir(repo),savedFiltered=import_react86.useMemo(()=>filterRepos(repoOptions,repo),[repoOptions,repo]),activeList=mode==="browse"?subdirFiltered:savedFiltered,activeWindow=windowAround(activeList,repoCursor,opts.pickerRows),expandedRepo=repoResolution.kind==="path"?stripTrailingSlash(expandHome(repoResolution.path)):"";function changeRepo(next){setRepo(next),opts.onChanged()}function pickRepo(path2){changeRepo(nameOrPath(path2,repoOptions))}function setRepoText(v3){setRepoPicked(!1),changeRepo(stripNewlines(v3)),setRepoCursor(0)}function completeRepo(){if(repoPicked)return!1;let done=completeRepoInput({value:repo,mode,highlighted:activeList[repoCursor],baseExpanded:subdirSplit.base,repoOptions});if(!done)return!1;return changeRepo(done.value),setRepoPicked(done.collapse),setRepoCursor(0),!0}function onRepoSubmit(){if(!repo.trim()&&mode==="saved"){let picked2=activeList[0];if(picked2){pickRepo(picked2),opts.onAnswered();return}}if(mode==="browse"){let picked2=subdirFiltered[repoCursor];if(picked2)pickRepo(joinPicked(repo,subdirSplit.base,picked2)),setRepoCursor(0),setRepoPicked(!0);opts.onAnswered();return}let picked=activeList[repoCursor];if(picked)pickRepo(picked);opts.onAnswered()}function selectRepoAt(absoluteIndex){let picked=activeList[absoluteIndex];if(!picked)return;if(mode==="browse")pickRepo(joinPicked(repo,subdirSplit.base,picked)),setRepoPicked(!0);else pickRepo(picked);setRepoCursor(absoluteIndex),opts.onAnswered()}function moveRepoCursor(delta){if(activeList.length===0)return;setRepoCursor((c2)=>clampCursor(c2+delta,activeList.length))}function reopenPicker(){setRepoPicked(!1)}return{repo,repoDir,repoOptions,repoResolution,mode,activeList,activeWindow,repoCursor,repoPicked,expandedRepo,setRepoText,completeRepo,onRepoSubmit,selectRepoAt,moveRepoCursor,reopenPicker}}var EMPTY_MAIN_REPOS=new Set;function useNewTaskViewModel(props){let dialog=useDialog(),[tab,setTab]=import_react88.useState("existing"),vendors=resolveVendorSet(props.availableVendors),[vendor,setVendor]=import_react88.useState(()=>resolveInitialVendor(resolveVendorSet(props.availableVendors),props.defaultVendor)),[field,setField]=import_react88.useState("tabs"),[intent,setIntent]=import_react88.useState("task"),[submitError,setSubmitError]=import_react88.useState(null),pickerRows=pickerVisibleRows(useTerminalDimensions().height),repoField=useRepoField({defaultRepo:props.defaultRepo,savedRepos:props.savedRepos,pickerRows,onChanged:()=>setIntent("task"),onAnswered:()=>setField(advanceField("repo"))}),expandedRepo=repoField.expandedRepo,canOpenProject=offersProjectIntent(expandedRepo,props.mainRepos??EMPTY_MAIN_REPOS),branch=useBranchField({expandedRepo,pickerRows,defaultRepo:props.defaultRepo,commit:()=>commitExisting(),onPicked:()=>setField("confirm")}),clone=useCloneState({defaultCloneParent:props.defaultCloneParent,vendor,onSubmit:props.onSubmit,clearDialog:()=>dialog.clear(),setField,setSubmitError}),adopt=useAdoptState({active:tab==="adopt",expandedRepo,vendor,discoverAdoptable:props.discoverAdoptable,onSubmit:props.onSubmit,clearDialog:()=>dialog.clear(),setSubmitError});import_react88.useEffect(()=>{setSubmitError(null)},[repoField.repo,clone.cloneUrl,clone.cloneParent,clone.cloneFolder,adopt.adoptFilter]);function commitExisting(){if(repoField.repoResolution.kind==="ambiguous"){setSubmitError(t("newTask.error.repoAmbiguous",{name:repoField.repoResolution.name})),setField("repo"),repoField.reopenPicker();return}let r6=expandedRepo;if(!r6)return;let reason=validateRepoPath(r6);if(reason){setSubmitError(reason),setField("repo");return}if(intent==="project"&&canOpenProject){props.onSubmit({mode:"open",repo:r6,vendor}),dialog.clear();return}let b3=branch.baseRef.trim()||DEFAULT_BASE_REF;props.onSubmit({repo:r6,baseRef:b3,vendor}),dialog.clear()}function commit(){if(tab==="clone"){clone.commitClone();return}if(tab==="adopt"){adopt.commitAdopt();return}commitExisting()}function advanceField(from){let next=nextField(from,tab,{intentVisible:tab==="existing"&&canOpenProject});if(next==="baseRef"&&tab==="existing"&&intent==="project"&&canOpenProject)return nextField(next,tab);return next}function switchToTab(next){if(clone.cloneInFlight||next===tab)return;setTab(next),setField(firstFieldFor(next)),setSubmitError(null)}function cycleTab2(dir){if(clone.cloneInFlight)return;let next=dir===1?nextDialogTab(tab):prevDialogTab(tab);if(next===tab)return;setTab(next),setSubmitError(null),setField("tabs")}function cycleEngine(dir){setVendor((v3)=>dir===1?nextVendorWithin(vendors,v3):prevVendorWithin(vendors,v3))}function completeFocusedField(){if(tab==="existing"&&field==="repo")return repoField.completeRepo();if(tab==="clone"&&field==="cloneParent")return clone.completeCloneParent();return!1}function moveCursor(delta){if(clone.cloneInFlight)return;if(tab==="existing"&&field==="repo"){repoField.moveRepoCursor(delta);return}if(tab==="existing"&&field==="baseRef"){branch.moveBranchCursor(delta);return}if(tab==="clone"&&field==="cloneParent"){clone.moveParentCursor(delta);return}if(tab==="adopt")adopt.moveAdoptCursor(delta)}return useBindings(()=>({bindings:[{key:"tab",cmd:()=>{if(!completeFocusedField())setField(advanceField)}},{key:"ctrl+]",cmd:()=>switchToTab(nextDialogTab(tab))},{key:"ctrl+[",cmd:()=>switchToTab(prevDialogTab(tab))},{key:"ctrl+e",cmd:()=>cycleEngine(1)},{key:"up",cmd:()=>moveCursor(-1)},{key:"down",cmd:()=>moveCursor(1)},...field==="tabs"||field==="engine"||field==="intent"?[{key:"left",cmd:()=>{if(field==="tabs")cycleTab2(-1);else if(field==="engine")cycleEngine(-1);else setIntent("task")}},{key:"right",cmd:()=>{if(field==="tabs")cycleTab2(1);else if(field==="engine")cycleEngine(1);else setIntent("project")}},{key:"return",cmd:()=>setField(advanceField)}]:[],...tab==="adopt"?[{key:"ctrl+a",cmd:adopt.adoptSelectAll}]:[]]})),useBindings(()=>({enabled:field==="confirm"&&!clone.cloneInFlight,bindings:[{key:"return",cmd:()=>commit()}]})),{...clone,...adopt,...branch,...repoField,defaultRepo:props.defaultRepo,tab,vendors,vendor,setVendor,field,setField,intent,setIntent,canOpenProject,submitError,switchToTab,commit,commitExisting}}var TAB_ORDER2=["existing","clone","adopt"];function NewTaskDialogView(props){let{theme}=useTheme(),t3=useT(),padX=useDialogPaddingX(),vm=useNewTaskViewModel(props),tabLabel={existing:t3("newTask.tabs.existing"),clone:t3("newTask.tabs.clone"),adopt:t3("newTask.tabs.adopt")};return $jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:0,children:[$jsx(DialogHeader,{title:t3("newTask.title"),onClose:()=>props.onCancel()}),$jsxs("box",{gap:1,paddingTop:1,children:[$jsx(DialogSection,{label:t3("newTask.field.mode"),focused:vm.field==="tabs",hint:t3("newTask.hint.modeCycle"),onPress:()=>vm.setField("tabs"),children:$jsx(ChipRow,{choices:TAB_ORDER2,selected:vm.tab,display:(tabId)=>tabLabel[tabId],onPick:(tabId)=>vm.switchToTab(tabId)})}),$jsx(DialogSection,{label:t3("newTask.field.engine"),focused:vm.field==="engine",hint:t3("newTask.hint.engineCycle"),onPress:()=>vm.setField("engine"),children:$jsx(ChipRow,{choices:vm.vendors,selected:vm.vendor,onPick:(vendor)=>{vm.setVendor(vendor),vm.setField("engine")}})}),vm.tab==="existing"?$jsx(ExistingTab,{vm}):null,vm.tab==="clone"?$jsx(CloneTab,{vm}):null,vm.tab==="adopt"?$jsx(AdoptTab,{vm}):null,vm.submitError?$jsxs("text",{fg:theme.error,wrapMode:"word",children:["\u203B ",vm.submitError]}):null]}),$jsx(DialogFooter,{children:t3("newTask.legend",{enter:t3(vm.field==="confirm"?"newTask.enterCreate":"newTask.enterNext")})}),$jsx(DialogActions,{label:vm.cloneInFlight?t3("newTask.button.cloning"):t3("newTask.button.create"),focused:vm.field==="confirm",onPress:()=>vm.commit()})]})}function show9(dialog,defaultRepo,savedRepos,options){return showDialog(dialog,(resolve)=>$jsx(NewTaskDialogView,{defaultRepo,savedRepos,defaultCloneParent:options?.defaultCloneParent,defaultVendor:options?.defaultVendor,availableVendors:options?.availableVendors,discoverAdoptable:options?.discoverAdoptable,mainRepos:options?.mainRepos,onSubmit:(v3)=>resolve(v3),onCancel:()=>resolve(void 0)}),{size:"medium"})}var NewTaskDialog={show:show9};function taskDialogAdapters(dialog){return{confirm:async(p3)=>await DialogConfirm.show(dialog,p3.title,p3.body,p3.cancelLabel,p3.confirmLabel,{danger:p3.danger})===!0,promptText:(initial,opts)=>RenameTaskDialog.show(dialog,initial,opts),promptNewTask:(defaultRepo,repos,opts)=>NewTaskDialog.show(dialog,defaultRepo,repos,opts)}}var vendorPrefAdapters={lastVendor:(repo)=>resolvePreferredVendor(repo),rememberVendor:(repo,vendor)=>setRepoLastActiveVendor(repo,vendor)};function selectNextAfterDelete(args){return(taskId,nextTask)=>{if(args.selectedId()!==taskId)return;let remaining=args.tasks();args.setSelectedId(nextTask?.id??remaining[0]?.id??null)}}function buildBaseCreateTaskContext(deps){return{orch:deps.orch,tasks:()=>deps.tasks(),...taskDialogAdapters(deps.dialog),...vendorPrefAdapters,logger:console,logPrefix:deps.logPrefix,notifyError:deps.notifyError,notifyInfo:deps.notifyInfo,updateActiveTask:!0,onTaskDeleted:selectNextAfterDelete(deps),cursorRepo:()=>{let list=deps.tasks();return(list.find((t3)=>t3.id===deps.selectedId())??list[0])?.repo},selectTask:(id)=>deps.setSelectedId(id),enterTask:(id)=>deps.enterTask(id)}}var CONFLICT_RE=/SYNC_CONFLICT(?:: )?(.*)/,DIRTY_RE=/SYNC_WORKTREE_DIRTY(?:: )?(.*)/;async function syncBaseAction(deps,taskId){let{t:t3}=deps;try{let res=await deps.orchestrator.syncBase(taskId);return deps.notifyInfo(res.alreadyCurrent?t3("tasks.sync.alreadyCurrent",{base:res.baseRef}):t3("tasks.sync.done",{base:res.baseRef})),!0}catch(err){let msg=err instanceof Error?err.message:String(err),conflict=CONFLICT_RE.exec(msg),dirty=DIRTY_RE.exec(msg);if(conflict)deps.notifyNeedsInput(t3("tasks.sync.conflict",{files:conflict[1]?.trim()||"?"}));else if(dirty)deps.notifyNeedsInput(t3("tasks.sync.dirty",{files:dirty[1]?.trim()||"?"}));else deps.notifyError(t3("tasks.sync.failed",{error:msg}));return!1}}function useWorkspaceTaskActions(deps){let{orchestrator,tasks,dialog,notifyError}=deps,renderer=useRenderer(),t3=deps.t,taskActions={...buildBaseCreateTaskContext({orch:orchestrator,tasks,dialog,notifyError,notifyInfo:deps.notifyInfo,selectedId:deps.selectedId,setSelectedId:deps.setSelectedId,logPrefix:"[rove workspace]",enterTask:deps.activateTask}),pickStatus:(current)=>StatusPickerDialog.show(dialog,{current}),copyText:(text)=>copyTextToSystemClipboard(text,(payload)=>renderer?.copyToClipboardOSC52(payload)),onTaskDeleted:(()=>{let moveSelection=selectNextAfterDelete({tasks,selectedId:deps.selectedId,setSelectedId:deps.setSelectedId});return(taskId,nextTask)=>{deps.forgetTaskTabs(taskId),moveSelection(taskId,nextTask)}})()};async function togglePin(id){let task=tasks().find((t4)=>t4.id===id);if(!task)return;await orchestrator.setPinned(id,!task.pinned).catch((err)=>{notifyError(t3("tasks.toast.pinFailed",{error:userFacingErrorMessage(err)}))})}async function moveTask(id,delta){await orchestrator.moveTask(id,delta).catch((err)=>{notifyError(t3("tasks.toast.moveFailed",{error:userFacingErrorMessage(err)}))})}async function renameBranch(id){let task=tasks().find((t4)=>t4.id===id);if(!task||task.kind==="main"||task.kind==="dir")return;let next=await BranchPickerDialog.show(dialog,{currentBranch:task.branch,repo:task.repo});if(!next)return;await orchestrator.setBranch(id,next).catch((err)=>{notifyError(t3("tasks.toast.renameBranchFailed",{branch:task.branch,error:userFacingErrorMessage(err)}))})}async function confirmRunAgain(id){let task=tasks().find((t4)=>t4.id===id);if(task?.prompt===void 0)return;return await RunAgainDialog.show(dialog,{taskTitle:task.title,prompt:task.prompt})===!0?task:void 0}async function pickVendor(id){let task=tasks().find((t4)=>t4.id===id);if(!task)return;let current=task.vendor??DEFAULT_TASK_VENDOR,engines=await availableEngineIds(),pick=await EnginePickerDialog.show(dialog,{engines:engines.length>0?engines:[current],current,currentEffort:task.modelEffort});if(!pick)return;if(pick.vendor===current&&(pick.effort===void 0||pick.effort===(task.modelEffort??"")))return;await applyVendorChange(taskActions,id,pick.vendor,{effort:pick.effort})}async function landTask(id){let task=tasks().find((candidate)=>String(candidate.id)===id);if(!task)return;await landTaskAction({orchestrator,confirm:(body)=>DialogConfirm.show(dialog,t3("worktrees.land.confirmTitle"),body,t3("common.cancel"),t3("worktrees.land.button")).then((ok)=>ok===!0),notifyInfo:deps.notifyInfo,notifyNeedsInput:deps.notifyNeedsInput,notifyError,t:t3,callerCwd:process.cwd()},id,task.branch||task.title)}return{syncBase:(id)=>syncBaseAction({orchestrator,notifyInfo:deps.notifyInfo,notifyNeedsInput:deps.notifyNeedsInput,notifyError,t:t3},id),createTask:()=>createTaskFlow(taskActions),deleteTask:(id)=>deleteTaskFlow(taskActions,id),renameTask:(id)=>renameTaskFlow(taskActions,id),renameBranch,cycleVendor:(id)=>cycleVendorFlow(taskActions,id),pickVendor,setVendor:async(id,vendor)=>{await applyVendorChange(taskActions,id,vendor,{silentSuccess:!0})},togglePin,moveTask,setStatus:(id)=>setStatusFlow(taskActions,id),copyTaskField:(id,field)=>{copyTaskFieldFlow(taskActions,id,field)},showFieldNotes:(repo)=>FieldNotesDialog.show(dialog,{repo,orchestrator}),confirmRunAgain,landTask}}import{existsSync as existsSync6}from"fs";import{spawn as spawn5}from"child_process";import{existsSync as existsSync5}from"fs";import{basename,delimiter,isAbsolute as isAbsolute2,join as join6}from"path";var CLI_CANDIDATES=[{id:"code",label:"VS Code",command:"code"},{id:"cursor",label:"Cursor",command:"cursor"},{id:"windsurf",label:"Windsurf",command:"windsurf"},{id:"zed",label:"Zed",command:"zed"}],MAC_APP_CANDIDATES=[{id:"vscode.app",label:"VS Code",appName:"Visual Studio Code",paths:["/Applications/Visual Studio Code.app"]},{id:"cursor.app",label:"Cursor",appName:"Cursor",paths:["/Applications/Cursor.app","/System/Applications/Cursor.app"]},{id:"windsurf.app",label:"Windsurf",appName:"Windsurf",paths:["/Applications/Windsurf.app"]},{id:"zed.app",label:"Zed",appName:"Zed",paths:["/Applications/Zed.app"]}];function executableOnPath(command,env,exists){if(isAbsolute2(command))return exists(command);let pathEnv=env.PATH??"";for(let dir of pathEnv.split(delimiter)){if(!dir)continue;if(exists(join6(dir,command)))return!0}return!1}function labelForOverride(command){let name=basename(command);if(name==="code")return"VS Code";if(name==="cursor")return"Cursor";if(name==="windsurf")return"Windsurf";if(name==="zed")return"Zed";return name||command}function detectWorktreeOpener(deps={}){let env=deps.env??process.env,platform2=deps.platform??process.platform,exists=deps.exists??existsSync5,override=readRoveEnv("OPEN_EDITOR",env)?.trim();if(override)return{id:"env",label:labelForOverride(override),command:override,args:[]};for(let c2 of CLI_CANDIDATES)if(executableOnPath(c2.command,env,exists))return{id:c2.id,label:c2.label,command:c2.command,args:[]};if(platform2==="darwin"&&executableOnPath("open",env,exists)){for(let app of MAC_APP_CANDIDATES)if(app.paths.some((path2)=>exists(path2)))return{id:app.id,label:app.label,command:"open",args:["-a",app.appName]};return{id:"mac-open",label:"Finder",command:"open",args:[]}}if(platform2==="linux"&&executableOnPath("xdg-open",env,exists))return{id:"xdg-open",label:"Open",command:"xdg-open",args:[]};return null}function buildOpenWorktreeCommand(worktreePath,opener){return[opener.command,[...opener.args,worktreePath]]}function openWorktree(worktreePath,opener,deps={}){if(!worktreePath)return!1;let spawnFn=deps.spawn??spawn5,[command,args]=buildOpenWorktreeCommand(worktreePath,opener);try{let child=spawnFn(command,args,{detached:!0,stdio:"ignore"});if(child.pid===void 0)return!1;return child.unref(),!0}catch{return!1}}async function requestTaskWorktreeOpen(id,deps){let path2=deps.taskPath;if(!path2||!existsSync6(path2))try{path2=await deps.ensureWorktree(id)}catch(error){deps.notifyError(t("tasks.toast.worktreeErrorGeneric",{message:userFacingErrorMessage(error)}));return}if(!path2||!existsSync6(path2))return;let opener=detectWorktreeOpener();if(!opener){deps.notifyError(deps.noEditorMessage);return}if(!openWorktree(path2,opener))deps.notifyError(deps.openFailedMessage(opener.label))}function openTaskWorktreeFor(id,opts){requestTaskWorktreeOpen(id,{taskPath:opts.tasks.find((task)=>task.id===id)?.worktreePath,ensureWorktree:opts.ensureWorktree,notifyError:opts.notifyError,noEditorMessage:t("tasks.toast.noEditor"),openFailedMessage:(label)=>t("tasks.toast.openWorktreeFailed",{label})})}async function selfRefreshAction(deps,inputs){let plan=planSelfRefresh(inputs);if(plan.kind==="unavailable")return deps.notifyError(deps.t("update.refresh.installGone")),!1;if(plan.kind==="current")return deps.notifyError(deps.t("update.refresh.alreadyCurrent")),!1;if(!await deps.confirm())return!1;if(plan.restartDaemon)await deps.orchestrator.restartDaemon();(deps.relaunch??relaunchSelf)({renderer:deps.renderer,notice:deps.t("update.refresh.relaunching")})}var import_react102=__toESM(require_react_production(),1);import{randomUUID}from"crypto";import{existsSync as existsSync7}from"fs";import{join as join7}from"path";function formatDiffComment(c2,stale=!1){let escaped=c2.body.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\r/g,"\\r").replace(/\n/g,"\\n"),location=c2.startLine!==void 0&&c2.startLine!==c2.line?`Lines: ${c2.startLine}-${c2.line}`:`Line: ${c2.line}`,staleNote=stale?["Note: this path is no longer in the branch \u2014 it was renamed or deleted after the note was written."]:[];return[`File: ${c2.filePath}`,location,...staleNote,`User comment: "${escaped}"`].join(`
109
109
  `)}function formatDiffComments(comments,worktreePath){return comments.map((c2)=>formatDiffComment(c2,worktreePath?!existsSync7(join7(worktreePath,c2.filePath)):!1)).join(`