@sma1lboy/rove 0.9.279-next.27 → 0.9.280
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/{chunk-6908yyyk.js → chunk-02x0ahxk.js} +1 -1
- package/dist/cli/{chunk-k04qvy42.js → chunk-0g1h35mr.js} +1 -1
- package/dist/cli/{chunk-v3yf3gmy.js → chunk-2pfh3zm0.js} +1 -1
- package/dist/cli/{chunk-4a82zjaq.js → chunk-2wrt80ft.js} +1 -1
- package/dist/cli/{chunk-a60qwvyq.js → chunk-3a7x7jg7.js} +3 -3
- package/dist/cli/{chunk-90qathy6.js → chunk-4drm07mp.js} +1 -1
- package/dist/cli/{chunk-cydytp2v.js → chunk-4z1a65bz.js} +1 -1
- package/dist/cli/{chunk-zbdwz30h.js → chunk-5dq0n3h7.js} +1 -1
- package/dist/cli/{chunk-37wbxna9.js → chunk-5g6v6tq5.js} +1 -1
- package/dist/cli/{chunk-cntrqw1e.js → chunk-5kgq379z.js} +1 -1
- package/dist/cli/{chunk-7tbemfgm.js → chunk-6mk6ceb6.js} +2 -2
- package/dist/cli/{chunk-e2zv4b2x.js → chunk-7aaw17vr.js} +1 -1
- package/dist/cli/{chunk-jtf8ag8v.js → chunk-7fya3y0n.js} +1 -1
- package/dist/cli/{chunk-mfp8ax3c.js → chunk-7nnpp89t.js} +1 -1
- package/dist/cli/{chunk-z8eg7tnp.js → chunk-amq030gb.js} +2 -2
- package/dist/cli/{chunk-t9x54xs5.js → chunk-azt0c2b5.js} +1 -1
- package/dist/cli/{chunk-2m22fy6d.js → chunk-bw2y7670.js} +1 -1
- package/dist/cli/{chunk-692jsg07.js → chunk-byh32qnx.js} +1 -1
- package/dist/cli/{chunk-ney5fnem.js → chunk-d2wndk4q.js} +1 -1
- package/dist/cli/{chunk-9192at57.js → chunk-f262ywvg.js} +1 -1
- package/dist/cli/{chunk-hqpfg53t.js → chunk-fkgemeww.js} +1 -1
- package/dist/cli/{chunk-bv7z8jsy.js → chunk-gk8efsx0.js} +1 -1
- package/dist/cli/{chunk-1pcqw0x7.js → chunk-hd1szhba.js} +1 -1
- package/dist/cli/{chunk-apgfbg20.js → chunk-j54c5a0a.js} +1 -1
- package/dist/cli/{chunk-5wt8ect1.js → chunk-jk4f0xsh.js} +1 -1
- package/dist/cli/{chunk-tw3hfkbv.js → chunk-jkgp816v.js} +1 -1
- package/dist/cli/{chunk-g2wwgt6t.js → chunk-mey3vksj.js} +1 -1
- package/dist/cli/{chunk-hzqfb00a.js → chunk-mjzjah9d.js} +1 -1
- package/dist/cli/{chunk-np765y1f.js → chunk-q6tsx6zc.js} +1 -1
- package/dist/cli/{chunk-y7ypda6a.js → chunk-qc9sj5wh.js} +1 -1
- package/dist/cli/{chunk-3btnwykt.js → chunk-qzhfs668.js} +1 -1
- package/dist/cli/{chunk-ngq02svt.js → chunk-r98h6b42.js} +2 -2
- package/dist/cli/{chunk-hg8c3ze3.js → chunk-rvjnafyt.js} +1 -1
- package/dist/cli/{chunk-a5dqhn9k.js → chunk-t7dyf50m.js} +1 -1
- package/dist/cli/{chunk-02bcfavz.js → chunk-tqxbbg3k.js} +1 -1
- package/dist/cli/{chunk-q3wzpn85.js → chunk-txvjg1g9.js} +1 -1
- package/dist/cli/{chunk-1pk5genq.js → chunk-w003rpr2.js} +1 -1
- package/dist/cli/{chunk-qg5wexks.js → chunk-wz307hf6.js} +1 -1
- package/dist/cli/{chunk-qd97s6pt.js → chunk-xmjknfy2.js} +1 -1
- package/dist/cli/{chunk-tt47sn82.js → chunk-xy5mrrqk.js} +1 -1
- package/dist/cli/{chunk-phmt9a1k.js → chunk-zkby63ej.js} +1 -1
- package/dist/cli/{chunk-dsm31j1n.js → chunk-zp0q931y.js} +1 -1
- package/dist/cli/{chunk-56rjpxzc.js → chunk-zv0rrhck.js} +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/rove.js +1 -1
- package/dist/web/assets/{index-CcqHr-Sc.js → index-DIN0Lz5C.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{APPEARANCE_SETTINGS,COLORBLIND_KEY,DEFAULT_BASE_REF,DEFAULT_COLORBLIND,DEFAULT_GLYPHS,DEFAULT_GLYPH_SET,DEFAULT_RUNNING_TITLE,DEFAULT_SCROLLBACK_ROWS,DEFAULT_TASK_COLORS,DEFAULT_WORKING_BORDER,EVENT_FEED_LIMIT,GLYPH_SETS,GLYPH_SET_KEY,ISSUE_CHAT_PLACEMENTS,PREFIX_TAP_PRESENTATIONS,PREFIX_TAP_PRESENTATION_KEY,RUNNING_TITLE_KEY,SCROLLBACK_ROWS_KEY,SECTIONS,SECTIONS_SIDEBAR_WIDTH,SPLIT_STYLE_KEY,TAB_STRIP_HIDE_SINGLE_KEY,TAB_STRIP_MODES,TAB_STRIP_MODE_KEY,TASK_COLORS_KEY,WORKING_BORDER_KEY,appearanceChoices,appendAttachmentRefs,applyAppearanceChoice,asAttachmentPaths,attachmentLabel,autoRoutingRows,buildDiffReview,buildPRPrompt,captureClipboardAttachment,cloneRepo,commentAtRow,commentRange,compareName,compareNewest,compareRecent,computeReviewPaint,conversationTitleOf,createBackgroundPoller,createKeybindingsFile,currentAppearanceChoice,deriveFolderName,detectWorktreeOpener,devRows,displayEndpoint,displaySettingValue,engineIntegrations,enginesNeedingHookInstall,enginesWithHooksInstalled,eventRows,findAvailableFolderName,findFileHandler,fuzzyMatch,gatherPRPromptState,generalLabelLayout,generalRows,getCurrentBranch,isBooleanOn,isNoProjectTask,issueChatTaskTitle,issueProjectPrompt,issueWorktreePrompt,keybindingRows,languageRowId,listLocalBranches,nextEnumValue,normalizeColorblind,normalizeGlyphSet,normalizeNumberInput,normalizePrefixTapPresentation,normalizeRunningTitle,normalizeScrollbackRows,normalizeSplitStyle,normalizeTaskColors,normalizeWorkingBorder,openExternally,openWorktree,persistedScrollbackRows,pluginPageErrorState,prefixTapPresentationRowId,readPluginRows,reconcileStableRows,relativeAge,relativeBuckets,repoBasename,resolveCloneTarget,resolveTabStripMode,rowAt,rowIndex,rowLiveBranchPath,sectionRows,setPluginEnabled,setPluginSetting,sidebarPrChip,sidebarProjectKeyOfTask,sidebarProjectKeyResolver,sidebarProjectLabel,sidebarRepoLabel,spawnDetached,subscribeBackgroundPolls,tabStripVisible,taskColor,toggledBooleanValue,truncateEnd,truncateEndCells,truncateStartCells,unifiedDiffRows,unsentComments,validateCloneTarget,validateGitUrl,validateRepoPath,withImagePlaceholders,worktreeRowLabel}from"./chunk-vbvbwjad.js";import{machineOfTask,useMachineRows,useMergedTasks}from"./chunk-stng29vp.js";import{trackWelcomeWrite}from"./chunk-dsm31j1n.js";import{installSkillNow,skillMissing}from"./chunk-hfvzvj91.js";import{fetchMarketplace}from"./chunk-grr2fn38.js";import"./chunk-c25vea1q.js";import{failureHint}from"./chunk-t2p22ww7.js";import{preparePluginInstall}from"./chunk-37wbxna9.js";import{formatBytes}from"./chunk-my20q579.js";import"./chunk-p2cbtrzg.js";import{humanOnlyFix,noEngineFix}from"./chunk-am5cpb9n.js";import{embeddedTerminalEnv}from"./chunk-7bgbansg.js";import{deriveTitleFromSessionId,startTaskSessionWithPromptAdapter}from"./chunk-8hernv9y.js";import{buildCIPromptForWorktree}from"./chunk-vkz6kkmm.js";import{canonPath,checkResolutionNotify}from"./chunk-1wwqf6kx.js";import{readLastActiveTaskId}from"./chunk-c1dz3qg3.js";import{isValidCron,nextCronAfter}from"./chunk-a4hsqj1b.js";import{tabStatus,taskStatus}from"./chunk-6hcyvg0m.js";import{installSkillErrors,skillTargets}from"./chunk-y7mjhjby.js";import{DIRECT_GUIDE_PREFIX_ACTION_ID,MarkdownText,PaneErrorBoundary,ReleaseNotesBody,RenderProfiler,armPrefixFromCurrentStack,bindByIds,bootPaneHost,currentBindingReachability,currentPaletteActions,defaultChordsOf,findBinding,formatChord,hostTargetFps,imeAnchorController,invokeArmedPrefixActionFromCurrentStack,isNarrowWidth,keymapVersion,modalActive,narrowSurface,pageCloseBindings,pluginKeybindings,redrawScreen,reloadUserKeybindings,runShellUpdater,shortcutCaption,showDialog,subscribeBindingStack,subscribeKeymapVersion,useAccessor,useBindingStackVersion,useBindings,useDialog,useDialogPaddingX,useFocus,useKV,useLatest,useNotifications,useOptionalDialog,useOptionalFocus,useOptionalKV,useOptionalNotifications,useT,useTerminalSize,useTheme,userKeybindingsReport}from"./chunk-a5dqhn9k.js";import{DEFAULT_SOUND_VOLUME,FINISHED_ALERTS_KEY,FIXED_BINDING_IDS,PREFIX_GUIDE_DELAY_MS,PREFIX_HUD_TTL_MS,RAIL_FOLD_STYLE_KEY,RoveKeymap,SIDEBAR_COLLAPSED_KEY,SIDEBAR_WIDTH_KEY,SOUND_VOLUME_KEY,ZEN_ACTIVE_KEY,ZEN_DEFAULT,attentionEdges,attentionKindFor,chipAttentionKind,currentPrefixConfiguration,isKittyModifierKeyEvent,nextSoundVolume,normalizeSoundVolume,prefixAction,prefixHudClock,prefixHudState}from"./chunk-x85rcep5.js";import{$Fragment,$jsx,$jsxs,flushSync,usePaste,useRenderer}from"./chunk-29kvfqeh.js";import{require_react_production}from"./chunk-2wd4744g.js";import{RemoteOrchestrator,absorbTab,adoptTabs,liveRowTokens}from"./chunk-apgfbg20.js";import"./chunk-cpgnm1xr.js";import"./chunk-r3s2t9af.js";import"./chunk-6xr1prk6.js";import"./chunk-764bsyb0.js";import{UPDATE_CHANNEL_KEY,UPDATE_NOTIFY_KEY,normalizeReleaseChannel,preferredReleaseChannel,updateNotifyEnabled}from"./chunk-cydytp2v.js";import"./chunk-1pk5genq.js";import{AUTO_ROUTING_TIERS,autoRoutingKey,classifyScreen,contentFirstLine,deriveTaskGroup,describeTierBlock,filetypeOf,isCombinedPathspec,isImagePath,listFiles,liveSourceProtocol,loadPreviewData,patchFirstLine,planChatContinuation,planWorktreeHandoff,readAutoRoutingTable,readClassifierConfig,resolveBase,searchTasks,secretStatus,statusFiles,statusFilesBranch,taskGroupRank,tierBlock,unifiedDiffFiles,worktreeFilePath,writeSecret}from"./chunk-k2j0tg1h.js";import{reloadPluginEngines}from"./chunk-kdnk8m5j.js";import{listPaneLaunches}from"./chunk-rjfdzjhj.js";import{detectEngineStatus,detectEngineStatuses,probeableEngineIds,summarizeEngines}from"./chunk-zpxpwgds.js";import{DEFAULT_EDITOR_KIND,EDITOR_CUSTOM_KEY,EDITOR_KINDS,EDITOR_KIND_KEY,normalizeEditorKind,resolveEditorLaunch}from"./chunk-agvtzads.js";import{SHELL_TASK_TITLE,deriveTitleFromPrompt}from"./chunk-2xsxcdp6.js";import"./chunk-17e2tgyg.js";import{FORK_UNSUPPORTED_CODE,PROJECT_SIBLING_BASE,TASK_DELETING_CODE,TaskDeletingError,WORKTREE_BASE_CUSTOM_KEY,dirtyRefusalReason,worktreeBaseKindOf}from"./chunk-1vxtd8rh.js";import{ISSUE_STATUSES}from"./chunk-4hestsjp.js";import"./chunk-qgrg9a5n.js";import"./chunk-2bgmby1d.js";import{loadPluginRegistry,readPluginManifest}from"./chunk-n0rdn2fn.js";import"./chunk-5mhvjytn.js";import"./chunk-atn06ncf.js";import{submitFeedback}from"./chunk-v3yf3gmy.js";import{forwardVerb,requireMachine}from"./chunk-p11emdb2.js";import"./chunk-vytrhm50.js";import"./chunk-vp29jgbt.js";import{PROJECT_DIR_TOKEN,WORKTREE_BASE_KEY,hasProjectDirToken,normalizeWorktreeBase}from"./chunk-gq36nzg8.js";import"./chunk-sq6zj3fb.js";import{ulid}from"./chunk-qkehg2c1.js";import{approxCellWidth,approxCharCells,charWidth,displayWidth,padEndCells}from"./chunk-dvcb6mk4.js";import{hostedTaskKeys,killHostedSessions,listHostedSessions,openHostedSessionHost,pastePromptWhenEngineUp}from"./chunk-nv8eyjep.js";import{ensurePtyHostReachable}from"./chunk-z43e08kw.js";import"./chunk-w77s2df8.js";import{DEFAULT_TERMINAL_COLORS,formatDefaultColorReply,parseTerminalDefaultColors}from"./chunk-mqfvzdpr.js";import{LOCALE_KEY,breathColor,breathGlyph,diffInks,mixInk,turnHue}from"./chunk-f7egph8g.js";import"./chunk-rxqdw6s5.js";import"./chunk-kxp04jnp.js";import{addTab,closeActiveTab,closeTab,collapseSplit,conversationTitle,cycleLeaf,cycleTab,engineTabSpawnFor,expandHome,filterSubdirs,findEditorTab,gotoTab,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,tabCwdFor,tabExitAction,tabPtyKey,tabPtyKeyFor,tabTitle,tabTitleStable,visibleNativeStatus}from"./chunk-3hxm56h6.js";import{AUTO_STATUS_KEY,DISPATCHER_KEY,repoEnv}from"./chunk-qecygh3f.js";import{ENGINE_PROTOCOLS,applyTabOps,defaultEngineCommand,diffTabs,engineCommandKey,engineDisplayName,engineLaunchArgv,engineNameKey,engineProtocolKey,engineRenamedFrom,humanizeSlug,interactiveEngineCommand,pickUnclaimedSessionId,protocolEntry,roveApiInvocation,withPinnedSessionId}from"./chunk-rjq38twt.js";import"./chunk-r5j8fycq.js";import{isBuiltinModInstalled,setBuiltinModInstalled}from"./chunk-xfgqae9t.js";import{builtinModsPath}from"./chunk-j1z9kgyd.js";import{aliasedKeys,isUnderKey,teardownScope}from"./chunk-g9ba25q5.js";import"./chunk-ggnq2vvk.js";import"./chunk-hpay0ax8.js";import"./chunk-catrr0z3.js";import{terminalTabsKey}from"./chunk-mdc7b01e.js";import{resolveSessionShell}from"./chunk-tn9gtf18.js";import{execHostForWorktreePath,remoteKeyForRepo}from"./chunk-895yqjjz.js";import"./chunk-sak1tphp.js";import"./chunk-y1xnjx8x.js";import{connectOrStartDaemon}from"./chunk-e58kj4gm.js";import"./chunk-0a65j1zj.js";import"./chunk-bcyex84w.js";import{foregroundEngineIn,parsePsSnapshot,psSnapshot}from"./chunk-5rgrde6b.js";import{createEngineHookAdapter,engineEntry,engineSessionIdFromTitle,engineTitleTurnHint,getCapabilities,stripEngineStatusPrefix}from"./chunk-4gjvmfa9.js";import{spawnCapture}from"./chunk-2tfnscxk.js";import{availableEngineIds,installedEngineIds}from"./chunk-hzz020xx.js";import"./chunk-w7zv47mp.js";import"./chunk-etfh8f4z.js";import{getGlobalDefaultVendor,resolvePreferredVendor,setGlobalDefaultVendor,setRepoLastActiveVendor}from"./chunk-9rj2fx6v.js";import{addSavedRepo,getSavedRepos,isGitRepo,isRemoteRepoKey,resolveMainRepoRoot}from"./chunk-rfp0ayra.js";import{parsePorcelain,sameWorktreeChanges}from"./chunk-0r1jf8m9.js";import"./chunk-t7j8g9f6.js";import"./chunk-dmzg9zdc.js";import{recordSpawn}from"./chunk-40dgv828.js";import"./chunk-kg9kmwt9.js";import{readOnlyGitProcessEnv}from"./chunk-6xppe9bj.js";import{processCwd}from"./chunk-3n0y9vpj.js";import{matchPathGlob}from"./chunk-kg11c1py.js";import{CURRENT_VERSION,RELEASE_CHANNELS,channelOf,checkLatestVersion,fetchReleaseNotesRange,releasePageUrl,updateCommandFor}from"./chunk-4a82zjaq.js";import"./chunk-zsfyj36g.js";import{tildify}from"./chunk-2r1fgng9.js";import{errorMessage,userFacingErrorMessage}from"./chunk-2brn8e1y.js";import"./chunk-7mwvvj46.js";import{loadStateFile}from"./chunk-32j6y5d1.js";import{currentLang,intlLocale,registerMessages,setLocaleLang,t,tKeys}from"./chunk-nqwza8b0.js";import{LOCALES}from"./chunk-ve76p2mx.js";import{createStateCell,profileSpan,profileTick}from"./chunk-cmp64q4j.js";import{CHANNEL_NAMES,RoveDaemonClient,attentionInboxItemKey,automationRunNeedsAttention,isRoutineInboxState,routineRunResponseState}from"./chunk-qzzmd63x.js";import"./chunk-96kvwzj8.js";import"./chunk-7bakcyes.js";import{roveCliInvocation}from"./chunk-8qkyd589.js";import"./chunk-7kysxgbq.js";import"./chunk-hz1x3hak.js";import{MULTI_REPO_CAP,childrenOf,isSharedChild,rollupPr,taskCwd,taskRepos,workspaceCapabilities}from"./chunk-x1jxxmtc.js";import{DEFAULT_TASK_VENDOR,TASK_STATUSES}from"./chunk-xy8be792.js";import{ALL_VENDORS,isBuiltinVendor,nextVendorWithin,prevVendorWithin}from"./chunk-h2m7em1e.js";import"./chunk-7ghwdjdc.js";import"./chunk-8t7qbr1e.js";import"./chunk-bejhca6z.js";import"./chunk-br8r72bf.js";import"./chunk-yt15y085.js";import{isDev,roveStateDir}from"./chunk-z1nj22va.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import{logClientError}from"./chunk-0g4wc808.js";import{pathIdentity,pathSyntax,pathWithin,samePath}from"./chunk-pn5ygqn6.js";import{defaultDaemonSocketPath}from"./chunk-eqdbfgq5.js";import"./chunk-f8gg8cqh.js";import{readRoveEnv}from"./chunk-nc46gddg.js";import"./chunk-pxk2c2vj.js";import{__commonJS,__require,__toESM}from"./chunk-91sykzqq.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{APPEARANCE_SETTINGS,COLORBLIND_KEY,DEFAULT_BASE_REF,DEFAULT_COLORBLIND,DEFAULT_GLYPHS,DEFAULT_GLYPH_SET,DEFAULT_RUNNING_TITLE,DEFAULT_SCROLLBACK_ROWS,DEFAULT_TASK_COLORS,DEFAULT_WORKING_BORDER,EVENT_FEED_LIMIT,GLYPH_SETS,GLYPH_SET_KEY,ISSUE_CHAT_PLACEMENTS,PREFIX_TAP_PRESENTATIONS,PREFIX_TAP_PRESENTATION_KEY,RUNNING_TITLE_KEY,SCROLLBACK_ROWS_KEY,SECTIONS,SECTIONS_SIDEBAR_WIDTH,SPLIT_STYLE_KEY,TAB_STRIP_HIDE_SINGLE_KEY,TAB_STRIP_MODES,TAB_STRIP_MODE_KEY,TASK_COLORS_KEY,WORKING_BORDER_KEY,appearanceChoices,appendAttachmentRefs,applyAppearanceChoice,asAttachmentPaths,attachmentLabel,autoRoutingRows,buildDiffReview,buildPRPrompt,captureClipboardAttachment,cloneRepo,commentAtRow,commentRange,compareName,compareNewest,compareRecent,computeReviewPaint,conversationTitleOf,createBackgroundPoller,createKeybindingsFile,currentAppearanceChoice,deriveFolderName,detectWorktreeOpener,devRows,displayEndpoint,displaySettingValue,engineIntegrations,enginesNeedingHookInstall,enginesWithHooksInstalled,eventRows,findAvailableFolderName,findFileHandler,fuzzyMatch,gatherPRPromptState,generalLabelLayout,generalRows,getCurrentBranch,isBooleanOn,isNoProjectTask,issueChatTaskTitle,issueProjectPrompt,issueWorktreePrompt,keybindingRows,languageRowId,listLocalBranches,nextEnumValue,normalizeColorblind,normalizeGlyphSet,normalizeNumberInput,normalizePrefixTapPresentation,normalizeRunningTitle,normalizeScrollbackRows,normalizeSplitStyle,normalizeTaskColors,normalizeWorkingBorder,openExternally,openWorktree,persistedScrollbackRows,pluginPageErrorState,prefixTapPresentationRowId,readPluginRows,reconcileStableRows,relativeAge,relativeBuckets,repoBasename,resolveCloneTarget,resolveTabStripMode,rowAt,rowIndex,rowLiveBranchPath,sectionRows,setPluginEnabled,setPluginSetting,sidebarPrChip,sidebarProjectKeyOfTask,sidebarProjectKeyResolver,sidebarProjectLabel,sidebarRepoLabel,spawnDetached,subscribeBackgroundPolls,tabStripVisible,taskColor,toggledBooleanValue,truncateEnd,truncateEndCells,truncateStartCells,unifiedDiffRows,unsentComments,validateCloneTarget,validateGitUrl,validateRepoPath,withImagePlaceholders,worktreeRowLabel}from"./chunk-vbvbwjad.js";import{machineOfTask,useMachineRows,useMergedTasks}from"./chunk-stng29vp.js";import{trackWelcomeWrite}from"./chunk-zp0q931y.js";import{installSkillNow,skillMissing}from"./chunk-hfvzvj91.js";import{fetchMarketplace}from"./chunk-grr2fn38.js";import"./chunk-c25vea1q.js";import{failureHint}from"./chunk-t2p22ww7.js";import{preparePluginInstall}from"./chunk-5g6v6tq5.js";import{formatBytes}from"./chunk-my20q579.js";import"./chunk-p2cbtrzg.js";import{humanOnlyFix,noEngineFix}from"./chunk-am5cpb9n.js";import{embeddedTerminalEnv}from"./chunk-7bgbansg.js";import{deriveTitleFromSessionId,startTaskSessionWithPromptAdapter}from"./chunk-8hernv9y.js";import{buildCIPromptForWorktree}from"./chunk-vkz6kkmm.js";import{canonPath,checkResolutionNotify}from"./chunk-1wwqf6kx.js";import{readLastActiveTaskId}from"./chunk-c1dz3qg3.js";import{isValidCron,nextCronAfter}from"./chunk-a4hsqj1b.js";import{tabStatus,taskStatus}from"./chunk-6hcyvg0m.js";import{installSkillErrors,skillTargets}from"./chunk-y7mjhjby.js";import{DIRECT_GUIDE_PREFIX_ACTION_ID,MarkdownText,PaneErrorBoundary,ReleaseNotesBody,RenderProfiler,armPrefixFromCurrentStack,bindByIds,bootPaneHost,currentBindingReachability,currentPaletteActions,defaultChordsOf,findBinding,formatChord,hostTargetFps,imeAnchorController,invokeArmedPrefixActionFromCurrentStack,isNarrowWidth,keymapVersion,modalActive,narrowSurface,pageCloseBindings,pluginKeybindings,redrawScreen,reloadUserKeybindings,runShellUpdater,shortcutCaption,showDialog,subscribeBindingStack,subscribeKeymapVersion,useAccessor,useBindingStackVersion,useBindings,useDialog,useDialogPaddingX,useFocus,useKV,useLatest,useNotifications,useOptionalDialog,useOptionalFocus,useOptionalKV,useOptionalNotifications,useT,useTerminalSize,useTheme,userKeybindingsReport}from"./chunk-t7dyf50m.js";import{DEFAULT_SOUND_VOLUME,FINISHED_ALERTS_KEY,FIXED_BINDING_IDS,PREFIX_GUIDE_DELAY_MS,PREFIX_HUD_TTL_MS,RAIL_FOLD_STYLE_KEY,RoveKeymap,SIDEBAR_COLLAPSED_KEY,SIDEBAR_WIDTH_KEY,SOUND_VOLUME_KEY,ZEN_ACTIVE_KEY,ZEN_DEFAULT,attentionEdges,attentionKindFor,chipAttentionKind,currentPrefixConfiguration,isKittyModifierKeyEvent,nextSoundVolume,normalizeSoundVolume,prefixAction,prefixHudClock,prefixHudState}from"./chunk-x85rcep5.js";import{$Fragment,$jsx,$jsxs,flushSync,usePaste,useRenderer}from"./chunk-29kvfqeh.js";import{require_react_production}from"./chunk-2wd4744g.js";import{RemoteOrchestrator,absorbTab,adoptTabs,liveRowTokens}from"./chunk-j54c5a0a.js";import"./chunk-cpgnm1xr.js";import"./chunk-r3s2t9af.js";import"./chunk-6xr1prk6.js";import"./chunk-764bsyb0.js";import{UPDATE_CHANNEL_KEY,UPDATE_NOTIFY_KEY,normalizeReleaseChannel,preferredReleaseChannel,updateNotifyEnabled}from"./chunk-4z1a65bz.js";import"./chunk-w003rpr2.js";import{AUTO_ROUTING_TIERS,autoRoutingKey,classifyScreen,contentFirstLine,deriveTaskGroup,describeTierBlock,filetypeOf,isCombinedPathspec,isImagePath,listFiles,liveSourceProtocol,loadPreviewData,patchFirstLine,planChatContinuation,planWorktreeHandoff,readAutoRoutingTable,readClassifierConfig,resolveBase,searchTasks,secretStatus,statusFiles,statusFilesBranch,taskGroupRank,tierBlock,unifiedDiffFiles,worktreeFilePath,writeSecret}from"./chunk-k2j0tg1h.js";import{reloadPluginEngines}from"./chunk-kdnk8m5j.js";import{listPaneLaunches}from"./chunk-rjfdzjhj.js";import{detectEngineStatus,detectEngineStatuses,probeableEngineIds,summarizeEngines}from"./chunk-zpxpwgds.js";import{DEFAULT_EDITOR_KIND,EDITOR_CUSTOM_KEY,EDITOR_KINDS,EDITOR_KIND_KEY,normalizeEditorKind,resolveEditorLaunch}from"./chunk-agvtzads.js";import{SHELL_TASK_TITLE,deriveTitleFromPrompt}from"./chunk-2xsxcdp6.js";import"./chunk-17e2tgyg.js";import{FORK_UNSUPPORTED_CODE,PROJECT_SIBLING_BASE,TASK_DELETING_CODE,TaskDeletingError,WORKTREE_BASE_CUSTOM_KEY,dirtyRefusalReason,worktreeBaseKindOf}from"./chunk-1vxtd8rh.js";import{ISSUE_STATUSES}from"./chunk-4hestsjp.js";import"./chunk-qgrg9a5n.js";import"./chunk-2bgmby1d.js";import{loadPluginRegistry,readPluginManifest}from"./chunk-n0rdn2fn.js";import"./chunk-5mhvjytn.js";import"./chunk-atn06ncf.js";import{submitFeedback}from"./chunk-2pfh3zm0.js";import{forwardVerb,requireMachine}from"./chunk-p11emdb2.js";import"./chunk-vytrhm50.js";import"./chunk-vp29jgbt.js";import{PROJECT_DIR_TOKEN,WORKTREE_BASE_KEY,hasProjectDirToken,normalizeWorktreeBase}from"./chunk-gq36nzg8.js";import"./chunk-sq6zj3fb.js";import{ulid}from"./chunk-qkehg2c1.js";import{approxCellWidth,approxCharCells,charWidth,displayWidth,padEndCells}from"./chunk-dvcb6mk4.js";import{hostedTaskKeys,killHostedSessions,listHostedSessions,openHostedSessionHost,pastePromptWhenEngineUp}from"./chunk-nv8eyjep.js";import{ensurePtyHostReachable}from"./chunk-z43e08kw.js";import"./chunk-w77s2df8.js";import{DEFAULT_TERMINAL_COLORS,formatDefaultColorReply,parseTerminalDefaultColors}from"./chunk-mqfvzdpr.js";import{LOCALE_KEY,breathColor,breathGlyph,diffInks,mixInk,turnHue}from"./chunk-f7egph8g.js";import"./chunk-rxqdw6s5.js";import"./chunk-kxp04jnp.js";import{addTab,closeActiveTab,closeTab,collapseSplit,conversationTitle,cycleLeaf,cycleTab,engineTabSpawnFor,expandHome,filterSubdirs,findEditorTab,gotoTab,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,tabCwdFor,tabExitAction,tabPtyKey,tabPtyKeyFor,tabTitle,tabTitleStable,visibleNativeStatus}from"./chunk-3hxm56h6.js";import{AUTO_STATUS_KEY,DISPATCHER_KEY,repoEnv}from"./chunk-qecygh3f.js";import{ENGINE_PROTOCOLS,applyTabOps,defaultEngineCommand,diffTabs,engineCommandKey,engineDisplayName,engineLaunchArgv,engineNameKey,engineProtocolKey,engineRenamedFrom,humanizeSlug,interactiveEngineCommand,pickUnclaimedSessionId,protocolEntry,roveApiInvocation,withPinnedSessionId}from"./chunk-rjq38twt.js";import"./chunk-r5j8fycq.js";import{isBuiltinModInstalled,setBuiltinModInstalled}from"./chunk-xfgqae9t.js";import{builtinModsPath}from"./chunk-j1z9kgyd.js";import{aliasedKeys,isUnderKey,teardownScope}from"./chunk-g9ba25q5.js";import"./chunk-ggnq2vvk.js";import"./chunk-hpay0ax8.js";import"./chunk-catrr0z3.js";import{terminalTabsKey}from"./chunk-mdc7b01e.js";import{resolveSessionShell}from"./chunk-tn9gtf18.js";import{execHostForWorktreePath,remoteKeyForRepo}from"./chunk-895yqjjz.js";import"./chunk-sak1tphp.js";import"./chunk-y1xnjx8x.js";import{connectOrStartDaemon}from"./chunk-e58kj4gm.js";import"./chunk-0a65j1zj.js";import"./chunk-bcyex84w.js";import{foregroundEngineIn,parsePsSnapshot,psSnapshot}from"./chunk-5rgrde6b.js";import{createEngineHookAdapter,engineEntry,engineSessionIdFromTitle,engineTitleTurnHint,getCapabilities,stripEngineStatusPrefix}from"./chunk-4gjvmfa9.js";import{spawnCapture}from"./chunk-2tfnscxk.js";import{availableEngineIds,installedEngineIds}from"./chunk-hzz020xx.js";import"./chunk-w7zv47mp.js";import"./chunk-etfh8f4z.js";import{getGlobalDefaultVendor,resolvePreferredVendor,setGlobalDefaultVendor,setRepoLastActiveVendor}from"./chunk-9rj2fx6v.js";import{addSavedRepo,getSavedRepos,isGitRepo,isRemoteRepoKey,resolveMainRepoRoot}from"./chunk-rfp0ayra.js";import{parsePorcelain,sameWorktreeChanges}from"./chunk-0r1jf8m9.js";import"./chunk-t7j8g9f6.js";import"./chunk-dmzg9zdc.js";import{recordSpawn}from"./chunk-40dgv828.js";import"./chunk-kg9kmwt9.js";import{readOnlyGitProcessEnv}from"./chunk-6xppe9bj.js";import{processCwd}from"./chunk-3n0y9vpj.js";import{matchPathGlob}from"./chunk-kg11c1py.js";import{CURRENT_VERSION,RELEASE_CHANNELS,channelOf,checkLatestVersion,fetchReleaseNotesRange,releasePageUrl,updateCommandFor}from"./chunk-2wrt80ft.js";import"./chunk-zsfyj36g.js";import{tildify}from"./chunk-2r1fgng9.js";import{errorMessage,userFacingErrorMessage}from"./chunk-2brn8e1y.js";import"./chunk-7mwvvj46.js";import{loadStateFile}from"./chunk-32j6y5d1.js";import{currentLang,intlLocale,registerMessages,setLocaleLang,t,tKeys}from"./chunk-nqwza8b0.js";import{LOCALES}from"./chunk-ve76p2mx.js";import{createStateCell,profileSpan,profileTick}from"./chunk-cmp64q4j.js";import{CHANNEL_NAMES,RoveDaemonClient,attentionInboxItemKey,automationRunNeedsAttention,isRoutineInboxState,routineRunResponseState}from"./chunk-qzzmd63x.js";import"./chunk-96kvwzj8.js";import"./chunk-7bakcyes.js";import{roveCliInvocation}from"./chunk-8qkyd589.js";import"./chunk-7kysxgbq.js";import"./chunk-hz1x3hak.js";import{MULTI_REPO_CAP,childrenOf,isSharedChild,rollupPr,taskCwd,taskRepos,workspaceCapabilities}from"./chunk-x1jxxmtc.js";import{DEFAULT_TASK_VENDOR,TASK_STATUSES}from"./chunk-xy8be792.js";import{ALL_VENDORS,isBuiltinVendor,nextVendorWithin,prevVendorWithin}from"./chunk-h2m7em1e.js";import"./chunk-7ghwdjdc.js";import"./chunk-8t7qbr1e.js";import"./chunk-bejhca6z.js";import"./chunk-br8r72bf.js";import"./chunk-yt15y085.js";import{isDev,roveStateDir}from"./chunk-z1nj22va.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import{logClientError}from"./chunk-0g4wc808.js";import{pathIdentity,pathSyntax,pathWithin,samePath}from"./chunk-pn5ygqn6.js";import{defaultDaemonSocketPath}from"./chunk-eqdbfgq5.js";import"./chunk-f8gg8cqh.js";import{readRoveEnv}from"./chunk-nc46gddg.js";import"./chunk-pxk2c2vj.js";import{__commonJS,__require,__toESM}from"./chunk-91sykzqq.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
|
|
|
@@ -53,7 +53,7 @@ ${D3.join(`
|
|
|
53
53
|
`)),r5.length=0)},3000),re2=new FinalizationRegistry((e2)=>{typeof e2=="string"&&r5.push(e2)})}var C2=class{constructor(e2){this._size=0,this._options=e2,this._leakageMon=We>0||this._options?.leakWarningThreshold?new Ee(e2?.onListenerError??Y2,this._options?.leakWarningThreshold??We):void 0,this._perfMon=this._options?._profName?new be(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Ve){let e2=this._listeners;queueMicrotask(()=>{at(e2,(t3)=>t3.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e2,t3,n2)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let p3=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(p3);let b3=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],D3=new Ae(`${p3}. HINT: Stack shows most frequent listener (${b3[1]}-times)`,b3[0]);return(this._options?.onListenerError||Y2)(D3),_3.None}if(this._disposed)return _3.None;t3&&(e2=e2.bind(t3));let o2=new N2(e2),d2,v3;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*0.2)&&(o2.stack=K2.create(),d2=this._leakageMon.check(o2.stack,this._size+1)),Ve&&(o2.stack=v3??K2.create()),this._listeners?this._listeners instanceof N2?(this._deliveryQueue??=new Fe,this._listeners=[this._listeners,o2]):this._listeners.push(o2):(this._options?.onWillAddFirstListener?.(this),this._listeners=o2,this._options?.onDidAddFirstListener?.(this)),this._size++;let E3=me(()=>{re2?.unregister(E3),d2?.(),this._removeListener(o2)});if(n2 instanceof U2?n2.add(E3):Array.isArray(n2)&&n2.push(E3),re2){let p3=Error().stack.split(`
|
|
54
54
|
`).slice(2,3).join(`
|
|
55
55
|
`).trim(),b3=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(p3);re2.register(E3,b3?.[2]??p3,E3)}return E3},this._event}_removeListener(e2){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t3=this._listeners,n2=t3.indexOf(e2);if(n2===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,t3[n2]=void 0;let o2=this._deliveryQueue.current===this;if(this._size*ot<=t3.length){let d2=0;for(let v3=0;v3<t3.length;v3++)t3[v3]?t3[d2++]=t3[v3]:o2&&(this._deliveryQueue.end--,d2<this._deliveryQueue.i&&this._deliveryQueue.i--);t3.length=d2}}_deliver(e2,t3){if(!e2)return;let n2=this._options?.onListenerError||Y2;if(!n2){e2.value(t3);return}try{e2.value(t3)}catch(o2){n2(o2)}}_deliverQueue(e2){let t3=e2.current._listeners;for(;e2.i<e2.end;)this._deliver(t3[e2.i++],e2.value);e2.reset()}fire(e2){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof N2)this._deliver(this._listeners,e2);else{let t3=this._deliveryQueue;t3.enqueue(this,e2,this._listeners.length),this._deliverQueue(t3)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Fe=class{constructor(){this.i=-1,this.end=0}enqueue(e2,t3,n2){this.i=0,this.end=n2,this.current=e2,this.value=t3}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},w3=class r5{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new C2,this.onChange=this._onChange.event;let e2=new H2;this.register(e2),this._active=e2.version,this._activeProvider=e2}static extractShouldJoin(e2){return(e2&1)!==0}static extractWidth(e2){return e2>>1&3}static extractCharKind(e2){return e2>>3}static createPropertyValue(e2,t3,n2=!1){return(e2&16777215)<<3|(t3&3)<<1|(n2?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e2){if(!this._providers[e2])throw Error(`unknown Unicode version "${e2}"`);this._active=e2,this._activeProvider=this._providers[e2],this._onChange.fire(e2)}register(e2){this._providers[e2.version]=e2}wcwidth(e2){return this._activeProvider.wcwidth(e2)}getStringCellWidth(e2){let t3=0,n2=0,o2=e2.length;for(let d2=0;d2<o2;++d2){let v3=e2.charCodeAt(d2);if(55296<=v3&&v3<=56319){if(++d2>=o2)return t3+this.wcwidth(v3);let b3=e2.charCodeAt(d2);56320<=b3&&b3<=57343?v3=(v3-55296)*1024+b3-56320+65536:t3+=this.wcwidth(b3)}let E3=this.charProperties(v3,n2),p3=r5.extractWidth(E3);r5.extractShouldJoin(E3)&&(p3-=r5.extractWidth(n2)),t3+=p3,n2=E3}return t3}charProperties(e2,t3){return this._activeProvider.charProperties(e2,t3)}},ye=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],lt=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],ge=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],xt=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],I3;function je(r6,e2){let t3=0,n2=e2.length-1,o2;if(r6<e2[0][0]||r6>e2[n2][1])return!1;for(;n2>=t3;)if(o2=t3+n2>>1,r6>e2[o2][1])t3=o2+1;else if(r6<e2[o2][0])n2=o2-1;else return!0;return!1}var se=class{constructor(){if(this.version="11",!I3){I3=new Uint8Array(65536),I3.fill(1),I3[0]=0,I3.fill(0,1,32),I3.fill(0,127,160);for(let e2=0;e2<ye.length;++e2)I3.fill(0,ye[e2][0],ye[e2][1]+1);for(let e2=0;e2<ge.length;++e2)I3.fill(2,ge[e2][0],ge[e2][1]+1)}}wcwidth(e2){return e2<32?0:e2<127?1:e2<65536?I3[e2]:je(e2,lt)?0:je(e2,xt)?2:1}charProperties(e2,t3){let n2=this.wcwidth(e2),o2=n2===0&&t3!==0;if(o2){let d2=w3.extractWidth(t3);d2===0?o2=!1:d2>n2&&(n2=d2)}return w3.createPropertyValue(0,n2,o2)}},Ke=class{activate(e2){e2.unicode.register(new se)}dispose(){}};var import_headless=__toESM(require_xterm_headless(),1);var OPEN=Buffer.from("\x1B_G"),ST=Buffer.from("\x1B\\");var CONTROL_SHAPE=/^[A-Za-z0-9=,+.-]*$/;function parseControl(control){if(!CONTROL_SHAPE.test(control))return null;let keys=new Map;for(let pair of control.split(",")){if(pair.length===0)continue;let eq=pair.indexOf("=");if(eq<=0)return null;keys.set(pair.slice(0,eq),pair.slice(eq+1))}return keys}function isContinuation(keys){for(let key of keys.keys())if(key!=="m"&&key!=="q")return!1;return!0}function classify(keys){let medium=keys.get("t");if(medium!==void 0&&medium!=="d")return"drop";let virtual=keys.get("U")==="1";switch(keys.get("a")??"t"){case"t":return"forward";case"T":case"p":return virtual?"forward":"drop";case"d":{let target=keys.get("d")??"a";return(target==="i"||target==="I")&&keys.has("i")?"forward":"drop"}default:return"drop"}}function forceQuiet(apc,keys,payloadStart){let control=[...[...keys].filter(([key])=>key!=="q").map(([key,value])=>`${key}=${value}`),"q=2"].join(",");return Buffer.concat([OPEN,Buffer.from(control),apc.subarray(payloadStart)])}function partialOpenerLength(bytes,from){let end=bytes.length;if(end-from>=2&&bytes[end-2]===27&&bytes[end-1]===95)return 2;if(end-from>=1&&bytes[end-1]===27)return 1;return 0}function asBuffer(data){if(typeof data==="string")return Buffer.from(data);return Buffer.from(data.buffer,data.byteOffset,data.byteLength)}class KittyGraphicsFilter{pending=null;discarding=!1;transfer=null;push(data,forward){if(this.pending===null&&!this.discarding&&!this.mayContainApc(data))return data;let incoming=asBuffer(data),bytes=this.pending===null?incoming:Buffer.concat([this.pending,incoming]);this.pending=null;let out=[],pos=0;if(this.discarding){let end=bytes.indexOf(ST);if(end<0)return Buffer.alloc(0);this.discarding=!1,pos=end+ST.length}while(pos<bytes.length){let open=bytes.indexOf(OPEN,pos);if(open<0){let keep=partialOpenerLength(bytes,pos);if(out.push(bytes.subarray(pos,bytes.length-keep)),keep>0)this.pending=Buffer.from(bytes.subarray(bytes.length-keep));break}out.push(bytes.subarray(pos,open));let end=bytes.indexOf(ST,open+OPEN.length);if(end<0){let rest=bytes.subarray(open);if(rest.length>16777216)this.discarding=!0,this.transfer="drop";else this.pending=Buffer.from(rest);break}this.dispatch(bytes.subarray(open,end+ST.length),forward),pos=end+ST.length}return out.length===1?out[0]:Buffer.concat(out)}mayContainApc(data){if(typeof data==="string")return data.includes("\x1B_G")||data.endsWith("\x1B")||data.endsWith("\x1B_");let bytes=asBuffer(data);return bytes.indexOf(OPEN)>=0||partialOpenerLength(bytes,0)>0}dispatch(apc,forward){let semi=apc.indexOf(59,OPEN.length),payloadStart=semi<0?apc.length-ST.length:semi,keys=parseControl(apc.toString("latin1",OPEN.length,payloadStart));if(keys===null){this.transfer=null;return}let decision=isContinuation(keys)?this.transfer??"drop":classify(keys);if(this.transfer=keys.get("m")==="1"?decision:null,decision==="forward")forward(forceQuiet(apc,keys,payloadStart))}}class PtyListeners{data=new Set;exits=new Set;titles=new Set;get dataCount(){return this.data.size}addData(listener){return this.data.add(listener),()=>this.data.delete(listener)}addExit(listener){return this.exits.add(listener),()=>this.exits.delete(listener)}addTitle(listener){return this.titles.add(listener),()=>this.titles.delete(listener)}publishData(snapshot,cursor,window2,wrapped){for(let listener of this.data)try{listener(snapshot,cursor,window2,wrapped)}catch{}}publishTitle(title){for(let listener of this.titles)try{listener(title)}catch{}}drainExits(){let listeners=[...this.exits];return this.exits.clear(),listeners}clearData(){this.data.clear()}clearAll(){this.data.clear(),this.exits.clear(),this.titles.clear()}}class TerminalCursorSettlement{platform;settled=null;settledRow;candidate=null;constructor(platform){this.platform=platform}get pending(){return this.candidate!==null}reset(){this.settled=null,this.settledRow=void 0,this.candidate=null}update(cursor,rows,atSynchronizedFrameEnd,now){if(!cursor)return this.candidate=null,null;if(this.platform==="win32"&&atSynchronizedFrameEnd&&cursor.y!==this.settled?.y){if(this.candidate?.row!==cursor.y)this.candidate={row:cursor.y,since:now};if(now-this.candidate.since<80)return this.settled&&rows[this.settled.y]===this.settledRow?this.settled:null}return this.candidate=null,this.settled=cursor,this.settledRow=rows[cursor.y],cursor}}function sameRgb(a2,b3){if(a2===b3)return!0;return a2!==void 0&&b3!==void 0&&a2[0]===b3[0]&&a2[1]===b3[1]&&a2[2]===b3[2]}function sameChunk(a2,b3){return a2.text===b3.text&&(a2.attributes??0)===(b3.attributes??0)&&sameRgb(a2.fg,b3.fg)&&sameRgb(a2.bg,b3.bg)}function sameRow(a2,b3){if(a2===b3)return!0;if(a2.length!==b3.length)return!1;for(let i2=0;i2<a2.length;i2++)if(!sameChunk(a2[i2],b3[i2]))return!1;return!0}function reconcileTerminalRow(previous,next){return previous&&sameRow(previous,next)?previous:next}function reconcileTerminalRows(previous,next){if(previous.length!==next.length)return next;let changed=!1;for(let i2=0;i2<next.length;i2++){let stable=reconcileTerminalRow(previous[i2],next[i2]);if(next[i2]=stable,stable!==previous[i2])changed=!0}return changed?next:previous}function reconcileTerminalCursor(previous,next){if(previous===next)return previous;if(previous&&next&&previous.x===next.x&&previous.y===next.y)return previous;return next}var ATTR=Object.freeze({BOLD:1,DIM:2,ITALIC:4,UNDERLINE:8,BLINK:16,INVERSE:32,HIDDEN:64,STRIKETHROUGH:128}),EMPTY_STYLE=Object.freeze({fg:void 0,bg:void 0,attributes:0});function ansi256ToRgb(index){if(index<0)return[0,0,0];if(index<16)return SYSTEM_PALETTE[index]??[0,0,0];if(index<232){let i2=index-16,r6=Math.floor(i2/36),g3=Math.floor(i2/6%6),b3=i2%6,step=(n2)=>n2===0?0:55+40*n2;return[step(r6),step(g3),step(b3)]}if(index<256){let gray=8+10*(index-232);return[gray,gray,gray]}return[0,0,0]}var SYSTEM_PALETTE=[[21,22,30],[247,118,142],[158,206,106],[224,175,104],[122,162,247],[187,154,247],[125,207,255],[169,177,214],[65,72,104],[255,137,157],[158,224,68],[250,186,74],[141,176,255],[199,169,255],[164,218,255],[192,202,245]];function applySgr(prev,rawParams){let params=rawParams.length===0?[0]:rawParams.map((p3)=>p3===""?0:Number.parseInt(p3,10)||0),fg=prev.fg,bg=prev.bg,attr=prev.attributes,i2=0;while(i2<params.length){let p3=params[i2];if(p3===void 0)break;if(p3===0){fg=void 0,bg=void 0,attr=0,i2+=1;continue}if(p3===1){attr|=ATTR.BOLD,i2+=1;continue}if(p3===2){attr|=ATTR.DIM,i2+=1;continue}if(p3===3){attr|=ATTR.ITALIC,i2+=1;continue}if(p3===4){attr|=ATTR.UNDERLINE,i2+=1;continue}if(p3===5||p3===6){attr|=ATTR.BLINK,i2+=1;continue}if(p3===7){attr|=ATTR.INVERSE,i2+=1;continue}if(p3===8){attr|=ATTR.HIDDEN,i2+=1;continue}if(p3===9){attr|=ATTR.STRIKETHROUGH,i2+=1;continue}if(p3===22){attr&=~(ATTR.BOLD|ATTR.DIM),i2+=1;continue}if(p3===23){attr&=~ATTR.ITALIC,i2+=1;continue}if(p3===24){attr&=~ATTR.UNDERLINE,i2+=1;continue}if(p3===25){attr&=~ATTR.BLINK,i2+=1;continue}if(p3===27){attr&=~ATTR.INVERSE,i2+=1;continue}if(p3===28){attr&=~ATTR.HIDDEN,i2+=1;continue}if(p3===29){attr&=~ATTR.STRIKETHROUGH,i2+=1;continue}if(p3>=30&&p3<=37){fg=ansi256ToRgb(p3-30),i2+=1;continue}if(p3>=90&&p3<=97){fg=ansi256ToRgb(p3-90+8),i2+=1;continue}if(p3===39){fg=void 0,i2+=1;continue}if(p3>=40&&p3<=47){bg=ansi256ToRgb(p3-40),i2+=1;continue}if(p3>=100&&p3<=107){bg=ansi256ToRgb(p3-100+8),i2+=1;continue}if(p3===49){bg=void 0,i2+=1;continue}if(p3===38){let sub=params[i2+1];if(sub===5){let idx=params[i2+2]??0;fg=ansi256ToRgb(idx),i2+=3;continue}if(sub===2){let r6=params[i2+2]??0,g3=params[i2+3]??0,b3=params[i2+4]??0;fg=[r6,g3,b3],i2+=5;continue}i2+=1;continue}if(p3===48){let sub=params[i2+1];if(sub===5){let idx=params[i2+2]??0;bg=ansi256ToRgb(idx),i2+=3;continue}if(sub===2){let r6=params[i2+2]??0,g3=params[i2+3]??0,b3=params[i2+4]??0;bg=[r6,g3,b3],i2+=5;continue}i2+=1;continue}i2+=1}return{fg,bg,attributes:attr}}function sgrParamsFromRaw(raw){let body=raw;if(body.charCodeAt(0)===27)body=body.slice(2);else if(body.charCodeAt(0)===155)body=body.slice(1);if(body.endsWith("m"))body=body.slice(0,-1);return body.split(";")}function parseAnsiLine(input,initial=EMPTY_STYLE){if(input.length===0)return{chunks:[],endStyle:initial};let out=[],style={...initial},buf="",flush=()=>{if(buf.length===0)return;let c2={text:buf,...style.fg?{fg:style.fg}:{},...style.bg?{bg:style.bg}:{},...style.attributes!==0?{attributes:style.attributes}:{}};out.push(c2),buf=""},codes=ie(input);for(let code of codes){if(code.type==="TEXT"){buf+=code.raw;continue}if(code.type==="CSI"&&code.command==="m"){flush(),style=applySgr(style,sgrParamsFromRaw(code.raw));continue}if(code.type==="OSC"&&code.command==="8"){flush();let url=code.params[code.params.length-1]??"";style={...style,attributes:url?style.attributes|ATTR.UNDERLINE:style.attributes&~ATTR.UNDERLINE}}}return flush(),{chunks:out,endStyle:style}}function parseAnsiSnapshot(input){let lines=input.split(`
|
|
56
|
-
`),rows=[],carry=EMPTY_STYLE;for(let line of lines){let{chunks,endStyle}=parseAnsiLine(line,carry);rows.push(chunks),carry=endStyle}return rows}var XTERM_COLOR_MODE_DEFAULT=0,XTERM_COLOR_MODE_PALETTE=16777216,XTERM_COLOR_MODE_RGB=50331648,DEFAULT_RENDER_STYLE=Object.freeze({fg:"",bg:"",attrs:0});function colorKeyToRGB(key){if(key==="")return;let sep=key.indexOf(":"),value=Number(key.slice(sep+1));if(key.startsWith("rgb:"))return[value>>16&255,value>>8&255,value&255];if(key.startsWith("pal:"))return ansi256ToRgb(value);return}function colorKey(cell,kind){if(kind==="fg"?cell.isFgDefault():cell.isBgDefault())return"";let mode=kind==="fg"?cell.getFgColorMode():cell.getBgColorMode(),color=kind==="fg"?cell.getFgColor():cell.getBgColor();if(mode===XTERM_COLOR_MODE_RGB||(kind==="fg"?cell.isFgRGB():cell.isBgRGB()))return`rgb:${color}`;if(mode===XTERM_COLOR_MODE_PALETTE||(kind==="fg"?cell.isFgPalette():cell.isBgPalette()))return`pal:${color}`;if(mode===XTERM_COLOR_MODE_DEFAULT)return"";return""}function cellAttributes(cell){let attrs=0;if(cell.isBold())attrs|=ATTR.BOLD;if(cell.isDim())attrs|=ATTR.DIM;if(cell.isItalic())attrs|=ATTR.ITALIC;if(cell.isUnderline())attrs|=ATTR.UNDERLINE;if(cell.isBlink())attrs|=ATTR.BLINK;if(cell.isInverse())attrs|=ATTR.INVERSE;if(cell.isInvisible())attrs|=ATTR.HIDDEN;if(cell.isStrikethrough())attrs|=ATTR.STRIKETHROUGH;return attrs}function matchingStyleRewrite(cell,styleRewrites){if(!styleRewrites||styleRewrites.length===0||!cell.isFgDefault()||cell.isBgDefault())return;let background=colorKeyToRGB(colorKey(cell,"bg"));return styleRewrites.find((rewrite)=>sameRgb2(background,rewrite.matchBackground))}function rgbKey([red,green,blue]){return`rgb:${red<<16|green<<8|blue}`}function cellStyle(cell,styleRewrites){let style={fg:colorKey(cell,"fg"),bg:colorKey(cell,"bg"),attrs:cellAttributes(cell)},rewrite=matchingStyleRewrite(cell,styleRewrites);return rewrite?{...style,fg:rgbKey(rewrite.foreground),bg:rgbKey(rewrite.background)}:style}function styleEquals(a2,b3){return a2.fg===b3.fg&&a2.bg===b3.bg&&a2.attrs===b3.attrs}function renderStyleToChunkFields(style){let fg=colorKeyToRGB(style.fg),bg=colorKeyToRGB(style.bg);return{...fg?{fg}:{},...bg?{bg}:{},...style.attrs!==0?{attributes:style.attrs}:{}}}function isSolidBlock(chars){return chars==="\u2580"||chars==="\u2584"||chars==="\u2588"}function paintsSamePixel(fg,bg){if(fg===void 0||bg===void 0)return!1;return fg[0]===bg[0]&&fg[1]===bg[1]&&fg[2]===bg[2]}function isVisibleCell(cell){let chars=cell.getChars();if(chars!==""&&chars!==" ")return!0;return!cell.isAttributeDefault()||!cell.isFgDefault()||!cell.isBgDefault()}var scratchCell;function getCellReusing(line,x2){if(scratchCell===void 0){let seeded=line.getCell(x2);if(seeded)scratchCell=seeded;return seeded}return line.getCell(x2,scratchCell)}function xtermLineToChunks(line,minLast=-1,styleRewrites){let last=Math.min(line.length-1,minLast);for(let x2=0;x2<line.length;x2++){let cell=getCellReusing(line,x2);if(!cell||cell.getWidth()===0)continue;if(isVisibleCell(cell))last=Math.max(last,x2)}if(last===-1)return[];let out=[],active=DEFAULT_RENDER_STYLE,activeIsFill=!1,buf="",flush=()=>{if(buf==="")return;out.push({text:buf,...renderStyleToChunkFields(active)}),buf=""};for(let x2=0;x2<=last;x2++){let cell=getCellReusing(line,x2);if(!cell||cell.getWidth()===0)continue;let next=cellStyle(cell,styleRewrites);if(!styleEquals(active,next))flush(),active=next,activeIsFill=paintsSamePixel(colorKeyToRGB(next.fg),colorKeyToRGB(next.bg));let chars=cell.getChars()||" ";buf+=isSolidBlock(chars)&&activeIsFill?" ":chars}return flush(),out}function chunkColorMatchesCell(rgb,cell,kind){if(kind==="fg"?cell.isFgDefault():cell.isBgDefault())return rgb===void 0;if(!rgb)return!1;let mode=kind==="fg"?cell.getFgColorMode():cell.getBgColorMode(),color=kind==="fg"?cell.getFgColor():cell.getBgColor();if(mode===XTERM_COLOR_MODE_RGB||(kind==="fg"?cell.isFgRGB():cell.isBgRGB()))return rgb[0]===(color>>16&255)&&rgb[1]===(color>>8&255)&&rgb[2]===(color&255);if(mode===XTERM_COLOR_MODE_PALETTE||(kind==="fg"?cell.isFgPalette():cell.isBgPalette())){let palette=ansi256ToRgb(color);return rgb[0]===palette[0]&&rgb[1]===palette[1]&&rgb[2]===palette[2]}return!1}function sameRgb2(a2,b3){return Boolean(a2&&b3&&a2[0]===b3[0]&&a2[1]===b3[1]&&a2[2]===b3[2])}function chunkStyleMatchesCell(chunk,cell,styleRewrites){let rewrite=matchingStyleRewrite(cell,styleRewrites);if(rewrite)return(chunk.attributes??0)===cellAttributes(cell)&&sameRgb2(chunk.fg,rewrite.foreground)&&sameRgb2(chunk.bg,rewrite.background);return(chunk.attributes??0)===cellAttributes(cell)&&chunkColorMatchesCell(chunk.fg,cell,"fg")&&chunkColorMatchesCell(chunk.bg,cell,"bg")}function xtermLineMatchesChunks(line,row,minLast=-1,styleRewrites){if(!line)return row.length===0;let last=Math.min(line.length-1,minLast);for(let x2=0;x2<line.length;x2++){let cell=getCellReusing(line,x2);if(!cell||cell.getWidth()===0)continue;if(isVisibleCell(cell))last=Math.max(last,x2)}if(last===-1)return row.length===0;let chunkIndex=0,textOffset=0;for(let x2=0;x2<=last;x2++){let cell=getCellReusing(line,x2);if(!cell||cell.getWidth()===0)continue;let chunk=row[chunkIndex];if(!chunk||!chunkStyleMatchesCell(chunk,cell,styleRewrites))return!1;let raw=cell.getChars()||" ",text=isSolidBlock(raw)&&paintsSamePixel(chunk.fg,chunk.bg)?" ":raw;if(!chunk.text.startsWith(text,textOffset))return!1;if(textOffset+=text.length,textOffset===chunk.text.length)chunkIndex++,textOffset=0;else if(textOffset>chunk.text.length)return!1}return chunkIndex===row.length&&textOffset===0}function wireXtermChannels(term,hooks){term.onData(hooks.onReply),term.onTitleChange(hooks.onTitle)}function wireXtermDefaultColorQueries(term,colors,reply){let resolved=parseTerminalDefaultColors(colors)??DEFAULT_TERMINAL_COLORS;for(let slot of[10,11])term.parser.registerOscHandler(slot,(payload)=>{if(payload!=="?")return!1;return reply(formatDefaultColorReply(slot,resolved)),!0})}function wireXtermCellSizeQuery(term,cellPixelSize,reply){term.parser.registerCsiHandler({final:"t"},(params)=>{if(params.length!==1||params[0]!==16)return!1;let size=cellPixelSize();if(!size)return!1;return reply(`\x1B[6;${size.height};${size.width}t`),!0})}class XtermRefreshTracker{dirty=null;subscription;synchronizedCursorSubscription;lastSynchronizedCursor=null;supported;constructor(term){this.synchronizedCursorSubscription=term.parser.registerCsiHandler({prefix:"?",final:"l"},(params)=>{if(params.includes(2026)){let active=term.buffer.active;this.lastSynchronizedCursor={x:active.cursorX,y:active.baseY+active.cursorY}}return!1});let event=term._core?._inputHandler?.onRequestRefreshRows;if(!event){this.supported=!1,this.subscription=null;return}this.supported=!0,this.subscription=event((range)=>{if(!range){this.dirty={kind:"all"};return}if(!this.dirty)this.dirty={kind:"range",start:range.start,end:range.end};else if(this.dirty.kind==="range")this.dirty.start=Math.min(this.dirty.start,range.start),this.dirty.end=Math.max(this.dirty.end,range.end)})}markAll(){this.dirty={kind:"all"}}get synchronizedCursor(){return this.lastSynchronizedCursor}peek(){return this.dirty}clear(){this.dirty=null}dispose(){this.subscription?.dispose(),this.synchronizedCursorSubscription.dispose()}}function snapshotMeta(active,viewportRows,scrollbackRows){return{type:active.type,baseY:active.baseY,length:active.length,start:Math.max(0,active.length-(viewportRows+scrollbackRows))}}function sameMeta(a2,b3){return a2.type===b3.type&&a2.baseY===b3.baseY&&a2.length===b3.length&&a2.start===b3.start}function dirtyRowsMatchSnapshot(active,snapshot,previousMeta,currentMeta,dirty,cursorHidden,frozen=null,styleRewrites){if(!previousMeta||!sameMeta(previousMeta,currentMeta)||!dirty)return!1;let first=currentMeta.start,last=currentMeta.length-1;if(dirty.kind==="range")first=Math.max(first,active.baseY+dirty.start),last=Math.min(last,active.baseY+dirty.end);let cursorY=active.baseY+active.cursorY;for(let y3=first;y3<=last;y3++){let row=snapshot[y3-currentMeta.start];if(!row)return!1;if(frozen&&y3<frozen.baseY&&frozen.cache.get(frozen.absBase+y3)===row)continue;let minLast=!cursorHidden&&y3===cursorY?active.cursorX-1:-1;if(!xtermLineMatchesChunks(active.getLine(y3),row,minLast,styleRewrites))return!1}return!0}function xtermSynchronizedOutput(term){try{return term.modes.synchronizedOutputMode===!0}catch{return!1}}function xtermCursorHidden(term){try{return term._core?.coreService?.isCursorHidden===!0}catch{return!1}}function sameFlags(previous,next){if(previous.length!==next.length)return!1;for(let i2=0;i2<next.length;i2++)if(previous[i2]!==next[i2])return!1;return!0}class XtermSnapshotEngine{alternateScreenStyleRewrites;scrollbackCache=new Map;wrappedCache=new Map;wrapped=[];anchor;anchorId=0;snapshotEpoch=0;publishedMeta=null;cursorSettlement;constructor(alternateScreenStyleRewrites,platform=process.platform){this.alternateScreenStyleRewrites=alternateScreenStyleRewrites;this.cursorSettlement=new TerminalCursorSettlement(platform)}invalidate(){this.scrollbackCache.clear(),this.wrappedCache.clear(),this.wrapped=[],this.anchor?.dispose(),this.anchor=void 0,this.anchorId=0,this.publishedMeta=null,this.cursorSettlement.reset()}refresh(term,rows,scrollbackRows,refreshTracker,previousSnapshot,previousCursor,previousWindow){if(xtermSynchronizedOutput(term))return null;let active=term.buffer.active,styleRewrites=active.type==="alternate"?this.alternateScreenStyleRewrites:void 0,cursorHidden=xtermCursorHidden(term),currentMeta=snapshotMeta(active,rows,scrollbackRows),nextCursor=reconcileTerminalCursor(previousCursor,cursorHidden?null:{x:active.cursorX,y:active.baseY+active.cursorY-currentMeta.start}),frameCursor=refreshTracker.synchronizedCursor,atFrameEnd=nextCursor!==null&&frameCursor?.x===nextCursor.x&&frameCursor.y===nextCursor.y+currentMeta.start,verifyAnchor=this.anchor,verifyFrozen=active.type!=="alternate"&&verifyAnchor!==void 0&&!verifyAnchor.isDisposed?{baseY:active.baseY,absBase:this.anchorId-verifyAnchor.line,cache:this.scrollbackCache}:null;if(dirtyRowsMatchSnapshot(active,previousSnapshot,this.publishedMeta,currentMeta,refreshTracker.peek(),cursorHidden,verifyFrozen,styleRewrites)){refreshTracker.clear(),this.publishedMeta=currentMeta;let cursor2=this.cursorSettlement.update(nextCursor,previousSnapshot,atFrameEnd,Date.now());return{snapshot:previousSnapshot,cursor:cursor2,snapshotWindow:previousWindow,wrapped:this.wrapped,changed:cursor2!==previousCursor,cursorPending:this.cursorSettlement.pending}}let canAnchor=active.type!=="alternate"&&active.baseY>0;if(canAnchor&&(this.anchor===void 0||this.anchor.isDisposed)){this.scrollbackCache.clear(),this.wrappedCache.clear();let fresh=term.registerMarker(-active.cursorY-1);if(fresh)this.snapshotEpoch+=1,this.anchor=fresh,this.anchorId=fresh.line}let anchorAlive=canAnchor&&this.anchor!==void 0&&!this.anchor.isDisposed,absBase=anchorAlive?this.anchorId-this.anchor.line:0,cache=this.scrollbackCache,wrappedCache=this.wrappedCache,rowsOut=[],wrappedOut=[],cursorY=active.baseY+active.cursorY,start=currentMeta.start;for(let y3=start;y3<active.length;y3++){let frozen=anchorAlive&&y3<active.baseY;if(frozen){let cached=cache.get(absBase+y3);if(cached){rowsOut.push(cached),wrappedOut.push(wrappedCache.get(absBase+y3)??!1);continue}}let line=active.getLine(y3),minLast=!cursorHidden&&y3===cursorY?active.cursorX-1:-1,previousRow=previousSnapshot[rowsOut.length],row=previousRow&&xtermLineMatchesChunks(line,previousRow,minLast,styleRewrites)?previousRow:line?xtermLineToChunks(line,minLast,styleRewrites):[],wraps=y3>start&&line?.isWrapped===!0,stableRow=frozen?reconcileTerminalRow(previousSnapshot[rowsOut.length],row):row;if(rowsOut.push(stableRow),wrappedOut.push(wraps),frozen)cache.set(absBase+y3,stableRow),wrappedCache.set(absBase+y3,wraps)}if(anchorAlive){let min=absBase+start;for(let id of cache.keys())if(id<min)cache.delete(id);for(let id of wrappedCache.keys())if(id<min)wrappedCache.delete(id)}if(canAnchor){let next=term.registerMarker(-active.cursorY-1);if(next)this.anchorId=anchorAlive?absBase+next.line:0,this.anchor?.dispose(),this.anchor=next}let snapshot=reconcileTerminalRows(previousSnapshot,rowsOut),cursor=this.cursorSettlement.update(nextCursor,snapshot,atFrameEnd,Date.now()),nextStartLine=absBase+start,snapshotWindow=anchorAlive?previousWindow?.epoch===this.snapshotEpoch&&previousWindow.startLine===nextStartLine?previousWindow:{epoch:this.snapshotEpoch,startLine:nextStartLine}:null;refreshTracker.clear(),this.publishedMeta=currentMeta;let wrapLayoutMoved=!sameFlags(this.wrapped,wrappedOut);if(wrapLayoutMoved)this.wrapped=wrappedOut;let changed=snapshot!==previousSnapshot||cursor!==previousCursor||snapshotWindow!==previousWindow||wrapLayoutMoved;return{snapshot,cursor,snapshotWindow,wrapped:this.wrapped,changed,cursorPending:this.cursorSettlement.pending}}}var KITTY_CSI_U_RE=/^\x1b\[[\d:;]*u$/;function containsControlCharacter(value){for(let character of value){let codePoint=character.codePointAt(0);if(codePoint===void 0||codePoint<=31||codePoint>=127&&codePoint<=159)return!0}return!1}var CTRL_PUNCT_C0={"@":"\x00","[":"\x1B","\\":"\x1C","]":"\x1D","^":"\x1E",_:"\x1F","?":"\x7F"},LEGACY_FUNCTION_KEYS={f1:{kind:"ss3",final:"P"},f2:{kind:"ss3",final:"Q"},f3:{kind:"ss3",final:"R"},f4:{kind:"ss3",final:"S"},f5:{kind:"tilde",number:15},f6:{kind:"tilde",number:17},f7:{kind:"tilde",number:18},f8:{kind:"tilde",number:19},f9:{kind:"tilde",number:20},f10:{kind:"tilde",number:21},f11:{kind:"tilde",number:23},f12:{kind:"tilde",number:24}},XTERM_MODIFIER_NAMED_KEYS=new Set(["delete","kpdelete","insert","kpinsert","up","kpup","down","kpdown","right","kpright","left","kpleft","home","kphome","end","kpend","pageup","kppageup","pagedown","kppagedown"]);function legacyModifier(evt){return 1+(evt.shift?1:0)+(evt.option||evt.meta?2:0)+(evt.ctrl?4:0)+(evt.super?8:0)+(evt.hyper?16:0)}function legacyCursorSequence(evt,final,applicationCursorKeys){let modifier=legacyModifier(evt);if(modifier!==1)return`\x1B[1;${modifier}${final}`;return applicationCursorKeys?`\x1BO${final}`:`\x1B[${final}`}function legacyTildeSequence(evt,number){let modifier=legacyModifier(evt);return modifier===1?`\x1B[${number}~`:`\x1B[${number};${modifier}~`}function legacyFunctionSequence(evt,key){if(key.kind==="tilde")return legacyTildeSequence(evt,key.number);let modifier=legacyModifier(evt);return modifier===1?`\x1BO${key.final}`:`\x1B[1;${modifier}${key.final}`}var NORMAL_TERMINAL_INPUT_MODES={applicationCursorKeys:!1,applicationKeypad:!1};function keyEventToShellBytes(evt,modes=NORMAL_TERMINAL_INPUT_MODES){if(isKittyModifierKeyEvent(evt))return null;let e2=evt,seq=typeof e2.sequence==="string"&&e2.sequence.length>0?e2.sequence:null,kittyInput=e2.source==="kitty"||typeof e2.raw==="string"&&KITTY_CSI_U_RE.test(e2.raw)||seq!=null&&KITTY_CSI_U_RE.test(seq);if(seq!=null&&!kittyInput)return seq;if(seq!=null&&!containsControlCharacter(seq)&&!evt.ctrl&&!e2.option&&!e2.meta&&!evt.super)return seq;return synthesizeShellBytes(evt,modes)}function synthesizeShellBytes(evt,modes){let name=evt.name;if(!name)return null;if(evt.shift&&name==="tab")return"\x1B[Z";let functionKey=LEGACY_FUNCTION_KEYS[name],xtermModifiedNamedKey=functionKey!==void 0||XTERM_MODIFIER_NAMED_KEYS.has(name);if((evt.option||evt.meta)&&!xtermModifiedNamedKey){let inner=synthesizeShellBytes({...evt,option:!1,meta:!1},modes);return inner==null?null:`\x1B${inner}`}if(functionKey)return legacyFunctionSequence(evt,functionKey);switch(name){case"return":case"enter":return"\r";case"kpenter":return modes.applicationKeypad&&legacyModifier(evt)===1?"\x1BOM":"\r";case"tab":return"\t";case"backspace":return"\x7F";case"delete":case"kpdelete":return legacyTildeSequence(evt,3);case"insert":case"kpinsert":return legacyTildeSequence(evt,2);case"up":case"kpup":return legacyCursorSequence(evt,"A",modes.applicationCursorKeys);case"down":case"kpdown":return legacyCursorSequence(evt,"B",modes.applicationCursorKeys);case"right":case"kpright":return legacyCursorSequence(evt,"C",modes.applicationCursorKeys);case"left":case"kpleft":return legacyCursorSequence(evt,"D",modes.applicationCursorKeys);case"home":case"kphome":return legacyCursorSequence(evt,"H",modes.applicationCursorKeys);case"end":case"kpend":return legacyCursorSequence(evt,"F",modes.applicationCursorKeys);case"pageup":case"kppageup":return legacyTildeSequence(evt,5);case"pagedown":case"kppagedown":return legacyTildeSequence(evt,6);case"clear":return"\x1B[E";case"escape":return"\x1B";case"space":return evt.ctrl?"\x00":" ";default:if(name.length===1){if(evt.ctrl){let code=name.toLowerCase().charCodeAt(0);if(code>=97&&code<=122)return String.fromCharCode(code-96);let c0=CTRL_PUNCT_C0[name];if(c0!=null)return c0;return null}if(evt.super)return null;if(evt.shift&&name>="a"&&name<="z")return name.toUpperCase();return name}return null}}var COPY_CHORDS=["cmd+c","ctrl+shift+c"],DEFAULT_PAGE_SIZE=10;var RESERVED_SPEC=[{id:"help.open"},{id:"focus.sidebar"},{id:"chat.tab.new"},{id:"chat.tab.close"},{id:"chat.tab.cycle-next"},{id:"chat.tab.cycle-prev"},{id:"chat.tab.goto"},{id:"chat.tab.rename"},"ctrl+e","ctrl+f",{id:"workspace.split.right"},{id:"workspace.split.down"},{id:"workspace.split.focus-next"},{id:"focus.next"},{id:"terminal.reset"},{id:"attention.next"}],RESERVED_GLOBAL_CHORDS=[...new Set(RESERVED_SPEC.flatMap((entry)=>typeof entry==="string"?[entry]:defaultChordsOf(entry.id)))],PASSTHROUGH_NAMES=[..."abcdefghijklmnopqrstuvwxyz".split(""),..."ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),..."0123456789".split(""),..." `~!@#$%^&*()-_=+[]{}\\|;:'\",.<>/?".split(""),"return","enter","space","tab","backspace","delete","up","down","left","right","home","end","pageup","pagedown","escape","insert","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12"],PASSTHROUGH_MODIFIER_PREFIXES=["","ctrl+","alt+","shift+","ctrl+shift+","alt+shift+","ctrl+alt+"],PASSTHROUGH_CHORDS=PASSTHROUGH_NAMES.flatMap((name)=>PASSTHROUGH_MODIFIER_PREFIXES.map((prefix)=>`${prefix}${name}`)).filter((chord)=>!RESERVED_GLOBAL_CHORDS.includes(chord));function encodeWheel(modes,direction,col,row,shift=!1){if(modes.mouseTracking&&(modes.alternateScreen||shift))return`\x1B[<${direction==="up"?64:65};${Math.max(1,col)};${Math.max(1,row)}M`;if(modes.alternateScreen)return(modes.applicationCursorKeys?direction==="up"?"\x1BOA":"\x1BOB":direction==="up"?"\x1B[A":"\x1B[B").repeat(3);return null}function encodeMouseButton(modes,kind,button,col,row,modifiers){if(modes.mouseTracking==="none")return null;if(kind==="drag"&&modes.mouseTracking!=="drag"&&modes.mouseTracking!=="any")return null;if(kind==="move"&&modes.mouseTracking!=="any")return null;let code=kind==="move"?35:button;if(kind==="drag")code+=32;if(modifiers?.shift)code+=4;if(modifiers?.alt)code+=8;if(modifiers?.ctrl)code+=16;return`\x1B[<${code};${Math.max(1,col)};${Math.max(1,row)}${kind==="up"?"m":"M"}`}function readInputModes(term){try{return{applicationCursorKeys:term.modes.applicationCursorKeysMode===!0,applicationKeypad:term.modes.applicationKeypadMode===!0}}catch{return{applicationCursorKeys:!1,applicationKeypad:!1}}}function appOwnsMouse(term){try{return term.modes.mouseTrackingMode!=="none"}catch{return!1}}function wheelSequence(term,direction,col,row,shift=!1){try{return encodeWheel({mouseTracking:term.modes.mouseTrackingMode!=="none",applicationCursorKeys:term.modes.applicationCursorKeysMode===!0,alternateScreen:term.buffer.active.type==="alternate"},direction,col,row,shift)}catch{return null}}function mouseButtonSequence(term,kind,button,col,row,modifiers){try{return encodeMouseButton({mouseTracking:term.modes.mouseTrackingMode},kind,button,col,row,modifiers)}catch{return null}}var SNAPSHOT_COALESCE_MS=Math.round(1000/hostTargetFps());class XtermTaskPty{taskId;cwd;term;listeners=new PtyListeners;snapshot=[];cursor=null;snapshotWindow=null;snapshotWrapped=[];snapshotDirty=!1;snapshotEngine;_title=null;_unwatchedSince=Date.now();_killed=!1;muteReplies=!1;cols;rows;cancelRefresh=null;scheduleRefresh;lastRefreshAt=0;refreshTracker;scrollbackRows;graphicsFilter=new KittyGraphicsFilter;constructor(opts,options={}){if(this.taskId=opts.taskId,this.cwd=opts.cwd,this.scheduleRefresh=opts.scheduleRefresh,this.cols=opts.cols??DEFAULT_COLS,this.rows=opts.rows??DEFAULT_ROWS,opts.restore?.title)this._title=opts.restore.title;this.scrollbackRows=opts.scrollback??persistedScrollbackRows(),this.term=new import_headless.Terminal({allowProposedApi:!0,cols:this.cols,rows:this.rows,scrollback:this.scrollbackRows,windowOptions:{getCellSizePixels:!0}}),this.snapshotEngine=new XtermSnapshotEngine(opts.alternateScreenStyleRewrites),this.term.loadAddon(new Ke),this.term.unicode.activeVersion="11",this.refreshTracker=new XtermRefreshTracker(this.term);let reply=(data)=>{if(this._killed||this.muteReplies)return;try{this.transportWrite(data)}catch{}};if(wireXtermChannels(this.term,{onReply:reply,onTitle:(title)=>{if(!title||title===this._title)return;this._title=title,this.listeners.publishTitle(title)}}),options.respondToDefaultColorQueries!==!1)wireXtermDefaultColorQueries(this.term,opts.defaultColors,reply);wireXtermCellSizeQuery(this.term,()=>terminalGraphics()?.cellPixelSize??null,reply)}get killed(){return this._killed}write(data){if(this._killed||data.length===0)return;try{this.transportWrite(data)}catch{this.markDead(!1)}}inputModes(){return readInputModes(this.term)}onExit(cb){if(this._killed)return cb(),()=>{};return this.listeners.addExit(cb)}onTitleChange(cb){let off=this.listeners.addTitle(cb);if(this._title)try{cb(this._title)}catch{}return off}paste(text){if(this._killed||text.length===0)return;let bracketed=!1;try{bracketed=this.term.modes.bracketedPasteMode===!0}catch{}this.write(bracketed?`\x1B[200~${text}\x1B[201~`:text)}wheel(direction,col,row,shift=!1){return this.emit(this._killed?null:wheelSequence(this.term,direction,col,row,shift))}click(kind,button,col,row,modifiers){return this.emit(this._killed?null:mouseButtonSequence(this.term,kind,button,col,row,modifiers))}emit(seq){if(seq===null)return!1;return this.write(seq),!0}get appOwnsMouse(){return this._killed?!1:appOwnsMouse(this.term)}onData(cb){this.ensureFreshSnapshot();let off=this.listeners.addData(cb);if(this._unwatchedSince=null,this.snapshot.length>0)try{cb(this.snapshot,this.cursor,this.snapshotWindow,this.snapshotWrapped)}catch{}return()=>{if(off(),this.listeners.dataCount===0){if(this.cancelRefresh)this.snapshotDirty=!0;if(this.cancelQueuedRefresh(),this._unwatchedSince===null)this._unwatchedSince=Date.now()}}}unwatchedSinceMs(){return this._unwatchedSince}get windowTitle(){return this._title}get scrollback(){return this.scrollbackRows}resizeEmulator(cols,rows){this.cols=cols,this.rows=rows,this.term.resize(cols,rows),this.invalidateScrollbackCache(),this.refreshTracker.markAll()}get size(){return{cols:this.cols,rows:this.rows}}resize(cols,rows){if(this._killed)return;this.cols=cols,this.rows=rows;try{this.term.resize(cols,rows),this.invalidateScrollbackCache(),this.transportResize(cols,rows),this.refreshTracker.markAll(),this.refreshSnapshot()}catch{this.markDead(!1)}}invalidateScrollbackCache(){this.snapshotEngine.invalidate(),this.snapshotWindow=null}capture(){return this.ensureFreshSnapshot(),this.snapshot}captureCursor(){return this.ensureFreshSnapshot(),this.cursor}captureWindow(){return this.ensureFreshSnapshot(),this.snapshotWindow}captureWrapped(){return this.ensureFreshSnapshot(),this.snapshotWrapped}ensureFreshSnapshot(){if(!this.snapshotDirty||this._killed)return;this.refreshSnapshot()}kill(){if(this._killed)return;this.markDead(!0)}feed(data){this.feedInternal(data,!1)}feedReplay(data){this.feedInternal(data,!0)}feedInternal(data,muteReplies){if(this._killed)return;if(muteReplies)this.muteReplies=!0;profileTick("feed"),this.term.write(this.liftGraphics(data),()=>{if(muteReplies)this.muteReplies=!1;if(!this.refreshTracker.supported)this.refreshTracker.markAll();this.queueRefresh()})}liftGraphics(data){let write=terminalGraphics()?.writeKitty;return write?this.graphicsFilter.push(data,write):data}queueRefresh(){if(this.listeners.dataCount===0){this.snapshotDirty=!0;return}if(this.cancelRefresh)return;if(this.scheduleRefresh){this.snapshotDirty=!0,this.cancelRefresh=this.scheduleRefresh(()=>{this.cancelRefresh=null,this.refreshSnapshot()});return}let since=Date.now()-this.lastRefreshAt;if(since>=SNAPSHOT_COALESCE_MS){this.refreshSnapshot();return}let timer=setTimeout(()=>{this.cancelRefresh=null,this.refreshSnapshot()},SNAPSHOT_COALESCE_MS-since);this.cancelRefresh=()=>clearTimeout(timer)}cancelQueuedRefresh(){this.cancelRefresh?.(),this.cancelRefresh=null}refreshSnapshot(){if(this._killed)return;this.cancelQueuedRefresh(),this.lastRefreshAt=Date.now();let result=profileSpan("refresh",()=>this.snapshotEngine.refresh(this.term,this.rows,this.scrollbackRows,this.refreshTracker,this.snapshot,this.cursor,this.snapshotWindow));if(result===null){this.queueRefresh();return}if(this.snapshot=result.snapshot,this.cursor=result.cursor,this.snapshotWindow=result.snapshotWindow,this.snapshotWrapped=result.wrapped,this.snapshotDirty=!1,result.changed)this.publishSnapshot();if(result.cursorPending)this.queueRefresh()}publishSnapshot(){profileTick("publish"),this.listeners.publishData(this.snapshot,this.cursor,this.snapshotWindow,this.snapshotWrapped)}disposeEmulator(){try{this.term.dispose()}catch{}}markDead(killProcess){if(this._killed)return;if(this._killed=!0,this.cancelQueuedRefresh(),this.refreshTracker.dispose(),this.disposeEmulator(),killProcess)try{this.transportKill()}catch{}let exitCbs=this.listeners.drainExits();this.listeners.clearData();for(let cb of exitCbs)try{cb()}catch{}}silentDispose(){this._killed=!0,this.cancelQueuedRefresh(),this.refreshTracker.dispose(),this.disposeEmulator(),this.listeners.clearAll()}}function sessionRecovery(result){if(!result.alive)return result.replay.length>0?"restored":null;if(result.respawned===!0)return"relaunched";if(result.created===!1)return"live";return null}var WIGGLE_MIN_GAP_MS=150;class HostedTaskPty extends XtermTaskPty{client=null;recovery=null;recoveryListeners=new Set;onRecovery(listener){return this.recoveryListeners.add(listener),listener(this.recovery),()=>{this.recoveryListeners.delete(listener)}}opened=!1;pendingInput=[];pendingResize=null;unsubs=[];deadOnAttach=!1;sessionPid=void 0;pendingExitPid=null;get shellPid(){return this.machine?null:this.sessionPid??null}machine;serializer=new D;hostOffset=null;constructor(opts){super(opts,{respondToDefaultColorQueries:!1});this.term.loadAddon(this.serializer),this.openRemote(opts)}static createdFresh(res){return res.alive&&(res.created??res.replay.length===0)}async openRemote(opts){try{this.machine=opts.machine;let client=opts.machine?await getMachinePtyClient(opts.machine):await getSharedPtyClient();if(this.killed)return;if(this.client=client,opts.machine){let{sessions}=await client.request("pty.list");if(!sessions.some((s2)=>s2.key===this.taskId)){this.remoteGone();return}}routeAdd(this),this.unsubs.push(client.onLifecycle("close",()=>this.remoteGone()));let res=await client.request("pty.open",{key:this.taskId,cwd:this.cwd,command:opts.machine?void 0:opts.command,shell:opts.machine?void 0:opts.shell,cols:this.cols,rows:this.rows,defaultColors:opts.defaultColors,sinceOffset:opts.restore?.byteOffset,sincePid:opts.restore?.pid??void 0,answersQueries:!0});if(this.killed)return;this.recovery=sessionRecovery(res);for(let listener of this.recoveryListeners)listener(this.recovery);this.sessionPid=res.pid??null,this.hostOffset=res.offset??null;let restored=opts.restore!==void 0&&res.sinceValid===!0&&res.created!==!0&&(res.pid??null)===opts.restore.pid;if(restored&&opts.restore){if(await this.restoreParked(opts.restore,Buffer.from(res.replay,"base64")),this.killed)return}else if(res.replay.length>0)this.feedReplay(Buffer.from(res.replay,"base64"));if(this.opened=!0,this.pendingResize){let{cols,rows}=this.pendingResize;this.pendingResize=null,this.sendResize(cols,rows)}let fresh=HostedTaskPty.createdFresh(res);if(opts.initialInput&&fresh&&!opts.machine)this.sendInput(opts.initialInput);if(opts.firstMessage&&fresh&&!opts.machine)pastePromptWhenEngineUp(client,this.taskId,opts.engineBin,opts.firstMessage).catch((err)=>logClientError("pty-hosted",err));for(let data of this.pendingInput.splice(0))this.sendInput(data);let parkedExitPid=this.pendingExitPid;if(this.pendingExitPid=null,!res.alive)this.deadOnAttach=res.replay.length>0||restored,this.remoteGone();else if(parkedExitPid!==null&&parkedExitPid===this.sessionPid)this.remoteGone();else if(res.replay.length>0&&!restored){if(this.sendResize(this.cols,Math.max(1,this.rows-1)),await Promise.all([this.nextDataOrTimeout(500),new Promise((r6)=>setTimeout(r6,WIGGLE_MIN_GAP_MS))]),!this.killed)this.sendResize(this.cols,this.rows)}}catch(err){logClientError("pty-hosted",err),this.remoteGone()}}transportWrite(data){if(!this.opened){this.pendingInput.push(data);return}this.sendInput(data)}transportResize(cols,rows){if(!this.opened){this.pendingResize={cols,rows};return}this.sendResize(cols,rows)}transportKill(){let client=this.client;if(client)client.request("pty.kill",{key:this.taskId}).catch(()=>{});this.cleanup()}kill(){if(this.killed){this.client?.request("pty.kill",{key:this.taskId}).catch(()=>{});return}super.kill()}capturePark(){if(this.killed||!this.opened||this.hostOffset===null||this.sessionPid===void 0)return null;try{return{serialized:Buffer.from(this.serializer.serialize({scrollback:this.scrollback}),"utf8").toString(),title:this.windowTitle,cursorHidden:xtermCursorHidden(this.term),cols:this.cols,rows:this.rows,byteOffset:this.hostOffset,pid:this.sessionPid}}catch{return null}}async restoreParked(state,delta){let targetCols=this.cols,targetRows=this.rows;if(state.cols!==targetCols||state.rows!==targetRows)this.resizeEmulator(state.cols,state.rows);if(this.feedReplay(state.serialized+(state.cursorHidden?"\x1B[?25l":"")),delta.byteLength>0)this.feedReplay(delta);if(await new Promise((resolve)=>{let off=this.onExit(resolve);this.term.write("",()=>{off(),resolve()})}),!this.killed&&(this.cols!==targetCols||this.rows!==targetRows))this.resizeEmulator(targetCols,targetRows)}detach(opts={}){let client=this.client;this.cleanup();let siblings=routeCount(this.taskId);if(client&&siblings===0)client.request("pty.detach",{key:this.taskId,parked:opts.parked===!0,parkedScreenBytes:opts.parkedScreenBytes}).catch(()=>{});this.silentDispose()}sendInput(data){this.client?.request("pty.write",{key:this.taskId,data}).catch(()=>this.remoteGone())}sendResize(cols,rows){this.client?.request("pty.resize",{key:this.taskId,cols,rows}).catch(()=>{})}dataWaiter=null;_lastOutputAt=null;lastOutputAtMs(){return this._lastOutputAt}nextDataOrTimeout(ms){return new Promise((resolve)=>{let timer=setTimeout(()=>{this.dataWaiter=null,resolve()},ms);this.dataWaiter=()=>{this.dataWaiter=null,clearTimeout(timer),resolve()}})}feedFrame(dataB64){this.dataWaiter?.(),this._lastOutputAt=Date.now();let buf=Buffer.from(dataB64,"base64");if(this.hostOffset!==null)this.hostOffset+=buf.byteLength;this.feed(buf)}remoteExited(pid){if(this.killed)return;if(pid===void 0){this.remoteGone();return}if(this.sessionPid===void 0){this.pendingExitPid=pid;return}if(pid!==null&&pid===this.sessionPid)this.remoteGone()}remoteGone(){this.cleanup(),this.markDead(!1)}cleanup(){routeRemove(this);for(let unsub of this.unsubs.splice(0))try{unsub()}catch{}}}class MockTaskPty{taskId;cwd;listeners=new Set;buffer="";writes=[];_killed=!1;_title=null;exitListeners=new Set;titleListeners=new Set;pastes=[];deadOnAttach=!1;wheels=[];clicks=[];appOwnsMouse=!1;_cols;_rows;_cursor=null;modes={applicationCursorKeys:!1,applicationKeypad:!1};constructor(opts){if(this.taskId=opts.taskId,this.cwd=opts.cwd,this._cols=opts.cols??DEFAULT_COLS,this._rows=opts.rows??DEFAULT_ROWS,opts.initialInput)this.writes.push(opts.initialInput)}get killed(){return this._killed}get writeLog(){return this.writes}get geometry(){return{cols:this._cols,rows:this._rows}}feed(data){if(this._killed)return;this.buffer+=data;let title=extractOscTitle(data);if(title&&title!==this._title){this._title=title;for(let cb of this.titleListeners)try{cb(title)}catch{}}let rows=this.capture();for(let cb of this.listeners)try{cb(rows,this._cursor,null)}catch{}}write(data){if(this._killed)return;this.writes.push(data)}inputModes(){return this.modes}replaceScreen(data){if(this._killed)return;this.buffer="",this.feed(data)}onData(cb){if(this.listeners.add(cb),this.buffer!=="")try{cb(this.capture(),this._cursor,null)}catch{}return()=>{this.listeners.delete(cb)}}resize(cols,rows){if(this._killed)return;this._cols=cols,this._rows=rows}capture(){return parseAnsiSnapshot(this.buffer)}setCursor(pos){this._cursor=pos}captureCursor(){if(this._killed)return null;return this._cursor}captureWindow(){return null}kill(){if(this._killed)return;this._killed=!0,this.listeners.clear();let exitCbs=[...this.exitListeners];this.exitListeners.clear();for(let cb of exitCbs)cb()}paste(text){if(this._killed)return;this.pastes.push(text)}wheel(direction,col,row){if(this._killed)return!1;return this.wheels.push({direction,col,row}),!1}click(kind,button,col,row){if(this._killed)return!1;return this.clicks.push({kind,button,col,row}),this.appOwnsMouse}onExit(cb){if(this._killed)return cb(),()=>{};return this.exitListeners.add(cb),()=>{this.exitListeners.delete(cb)}}onTitleChange(cb){if(this.titleListeners.add(cb),this._title)try{cb(this._title)}catch{}return()=>{this.titleListeners.delete(cb)}}}import{spawn}from"child_process";class PipeTaskPty{taskId;cwd;proc;listeners=new Set;buffer="";_killed=!1;_title=null;exitListeners=new Set;titleListeners=new Set;cols;rows;constructor(opts){this.taskId=opts.taskId,this.cwd=opts.cwd,this.cols=opts.cols??DEFAULT_COLS,this.rows=opts.rows??DEFAULT_ROWS;let argv=resolveArgv(opts),exe=argv[0]??defaultShell(),args=argv.slice(1);if(this.proc=spawn(exe,args,{cwd:opts.cwd,env:embeddedTerminalEnv(process.env,{TERM:process.env.TERM??"xterm-256color",COLUMNS:String(this.cols),LINES:String(this.rows),ROVE_TERMINAL_PIPE:"1"}),stdio:["pipe","pipe","pipe"]}),this.proc.stdout?.setEncoding("utf8"),this.proc.stderr?.setEncoding("utf8"),this.proc.stdout?.on("data",(chunk)=>this.append(chunk)),this.proc.stderr?.on("data",(chunk)=>this.append(chunk)),this.proc.stdin?.on("error",()=>this.markDead(!1)),this.proc.on("error",(err)=>{this.append(`
|
|
56
|
+
`),rows=[],carry=EMPTY_STYLE;for(let line of lines){let{chunks,endStyle}=parseAnsiLine(line,carry);rows.push(chunks),carry=endStyle}return rows}var XTERM_COLOR_MODE_DEFAULT=0,XTERM_COLOR_MODE_PALETTE=16777216,XTERM_COLOR_MODE_RGB=50331648,DEFAULT_RENDER_STYLE=Object.freeze({fg:"",bg:"",attrs:0});function colorKeyToRGB(key){if(key==="")return;let sep=key.indexOf(":"),value=Number(key.slice(sep+1));if(key.startsWith("rgb:"))return[value>>16&255,value>>8&255,value&255];if(key.startsWith("pal:"))return ansi256ToRgb(value);return}function colorKey(cell,kind){if(kind==="fg"?cell.isFgDefault():cell.isBgDefault())return"";let mode=kind==="fg"?cell.getFgColorMode():cell.getBgColorMode(),color=kind==="fg"?cell.getFgColor():cell.getBgColor();if(mode===XTERM_COLOR_MODE_RGB||(kind==="fg"?cell.isFgRGB():cell.isBgRGB()))return`rgb:${color}`;if(mode===XTERM_COLOR_MODE_PALETTE||(kind==="fg"?cell.isFgPalette():cell.isBgPalette()))return`pal:${color}`;if(mode===XTERM_COLOR_MODE_DEFAULT)return"";return""}function cellAttributes(cell){let attrs=0;if(cell.isBold())attrs|=ATTR.BOLD;if(cell.isDim())attrs|=ATTR.DIM;if(cell.isItalic())attrs|=ATTR.ITALIC;if(cell.isUnderline())attrs|=ATTR.UNDERLINE;if(cell.isBlink())attrs|=ATTR.BLINK;if(cell.isInverse())attrs|=ATTR.INVERSE;if(cell.isInvisible())attrs|=ATTR.HIDDEN;if(cell.isStrikethrough())attrs|=ATTR.STRIKETHROUGH;return attrs}function matchingStyleRewrite(cell,styleRewrites){if(!styleRewrites||styleRewrites.length===0||!cell.isFgDefault()||cell.isBgDefault())return;let background=colorKeyToRGB(colorKey(cell,"bg"));return styleRewrites.find((rewrite)=>sameRgb2(background,rewrite.matchBackground))}function rgbKey([red,green,blue]){return`rgb:${red<<16|green<<8|blue}`}function cellStyle(cell,styleRewrites){let style={fg:colorKey(cell,"fg"),bg:colorKey(cell,"bg"),attrs:cellAttributes(cell)},rewrite=matchingStyleRewrite(cell,styleRewrites);return rewrite?{...style,fg:rgbKey(rewrite.foreground),bg:rgbKey(rewrite.background)}:style}function styleEquals(a2,b3){return a2.fg===b3.fg&&a2.bg===b3.bg&&a2.attrs===b3.attrs}function renderStyleToChunkFields(style){let fg=colorKeyToRGB(style.fg),bg=colorKeyToRGB(style.bg);return{...fg?{fg}:{},...bg?{bg}:{},...style.attrs!==0?{attributes:style.attrs}:{}}}function isSolidBlock(chars){return chars==="\u2580"||chars==="\u2584"||chars==="\u2588"}function paintsSamePixel(fg,bg){if(fg===void 0||bg===void 0)return!1;return fg[0]===bg[0]&&fg[1]===bg[1]&&fg[2]===bg[2]}function isVisibleCell(cell){let chars=cell.getChars();if(chars!==""&&chars!==" ")return!0;return!cell.isAttributeDefault()||!cell.isFgDefault()||!cell.isBgDefault()}var scratchCell;function getCellReusing(line,x2){if(scratchCell===void 0){let seeded=line.getCell(x2);if(seeded)scratchCell=seeded;return seeded}return line.getCell(x2,scratchCell)}function xtermLineToChunks(line,minLast=-1,styleRewrites){let last=Math.min(line.length-1,minLast);for(let x2=0;x2<line.length;x2++){let cell=getCellReusing(line,x2);if(!cell||cell.getWidth()===0)continue;if(isVisibleCell(cell))last=Math.max(last,x2)}if(last===-1)return[];let out=[],active=DEFAULT_RENDER_STYLE,activeIsFill=!1,buf="",flush=()=>{if(buf==="")return;out.push({text:buf,...renderStyleToChunkFields(active)}),buf=""};for(let x2=0;x2<=last;x2++){let cell=getCellReusing(line,x2);if(!cell||cell.getWidth()===0)continue;let next=cellStyle(cell,styleRewrites);if(!styleEquals(active,next))flush(),active=next,activeIsFill=paintsSamePixel(colorKeyToRGB(next.fg),colorKeyToRGB(next.bg));let chars=cell.getChars()||" ";buf+=isSolidBlock(chars)&&activeIsFill?" ":chars}return flush(),out}function chunkColorMatchesCell(rgb,cell,kind){if(kind==="fg"?cell.isFgDefault():cell.isBgDefault())return rgb===void 0;if(!rgb)return!1;let mode=kind==="fg"?cell.getFgColorMode():cell.getBgColorMode(),color=kind==="fg"?cell.getFgColor():cell.getBgColor();if(mode===XTERM_COLOR_MODE_RGB||(kind==="fg"?cell.isFgRGB():cell.isBgRGB()))return rgb[0]===(color>>16&255)&&rgb[1]===(color>>8&255)&&rgb[2]===(color&255);if(mode===XTERM_COLOR_MODE_PALETTE||(kind==="fg"?cell.isFgPalette():cell.isBgPalette())){let palette=ansi256ToRgb(color);return rgb[0]===palette[0]&&rgb[1]===palette[1]&&rgb[2]===palette[2]}return!1}function sameRgb2(a2,b3){return Boolean(a2&&b3&&a2[0]===b3[0]&&a2[1]===b3[1]&&a2[2]===b3[2])}function chunkStyleMatchesCell(chunk,cell,styleRewrites){let rewrite=matchingStyleRewrite(cell,styleRewrites);if(rewrite)return(chunk.attributes??0)===cellAttributes(cell)&&sameRgb2(chunk.fg,rewrite.foreground)&&sameRgb2(chunk.bg,rewrite.background);return(chunk.attributes??0)===cellAttributes(cell)&&chunkColorMatchesCell(chunk.fg,cell,"fg")&&chunkColorMatchesCell(chunk.bg,cell,"bg")}function xtermLineMatchesChunks(line,row,minLast=-1,styleRewrites){if(!line)return row.length===0;let last=Math.min(line.length-1,minLast);for(let x2=0;x2<line.length;x2++){let cell=getCellReusing(line,x2);if(!cell||cell.getWidth()===0)continue;if(isVisibleCell(cell))last=Math.max(last,x2)}if(last===-1)return row.length===0;let chunkIndex=0,textOffset=0;for(let x2=0;x2<=last;x2++){let cell=getCellReusing(line,x2);if(!cell||cell.getWidth()===0)continue;let chunk=row[chunkIndex];if(!chunk||!chunkStyleMatchesCell(chunk,cell,styleRewrites))return!1;let raw=cell.getChars()||" ",text=isSolidBlock(raw)&&paintsSamePixel(chunk.fg,chunk.bg)?" ":raw;if(!chunk.text.startsWith(text,textOffset))return!1;if(textOffset+=text.length,textOffset===chunk.text.length)chunkIndex++,textOffset=0;else if(textOffset>chunk.text.length)return!1}return chunkIndex===row.length&&textOffset===0}function wireXtermChannels(term,hooks){term.onData(hooks.onReply),term.onTitleChange(hooks.onTitle)}function wireXtermDefaultColorQueries(term,colors,reply){let resolved=parseTerminalDefaultColors(colors)??DEFAULT_TERMINAL_COLORS;for(let slot of[10,11])term.parser.registerOscHandler(slot,(payload)=>{if(payload!=="?")return!1;return reply(formatDefaultColorReply(slot,resolved)),!0})}function wireXtermCellSizeQuery(term,cellPixelSize,reply){term.parser.registerCsiHandler({final:"t"},(params)=>{if(params.length!==1||params[0]!==16)return!1;let size=cellPixelSize();if(!size)return!1;return reply(`\x1B[6;${size.height};${size.width}t`),!0})}class XtermRefreshTracker{dirty=null;subscription;synchronizedCursorSubscription;lastSynchronizedCursor=null;supported;constructor(term){this.synchronizedCursorSubscription=term.parser.registerCsiHandler({prefix:"?",final:"l"},(params)=>{if(params.includes(2026)){let active=term.buffer.active;this.lastSynchronizedCursor={x:active.cursorX,y:active.baseY+active.cursorY}}return!1});let event=term._core?._inputHandler?.onRequestRefreshRows;if(!event){this.supported=!1,this.subscription=null;return}this.supported=!0,this.subscription=event((range)=>{if(!range){this.dirty={kind:"all"};return}if(!this.dirty)this.dirty={kind:"range",start:range.start,end:range.end};else if(this.dirty.kind==="range")this.dirty.start=Math.min(this.dirty.start,range.start),this.dirty.end=Math.max(this.dirty.end,range.end)})}markAll(){this.dirty={kind:"all"}}get synchronizedCursor(){return this.lastSynchronizedCursor}peek(){return this.dirty}clear(){this.dirty=null}dispose(){this.subscription?.dispose(),this.synchronizedCursorSubscription.dispose()}}function snapshotMeta(active,viewportRows,scrollbackRows){return{type:active.type,baseY:active.baseY,length:active.length,start:Math.max(0,active.length-(viewportRows+scrollbackRows))}}function sameMeta(a2,b3){return a2.type===b3.type&&a2.baseY===b3.baseY&&a2.length===b3.length&&a2.start===b3.start}function dirtyRowsMatchSnapshot(active,snapshot,previousMeta,currentMeta,dirty,cursorHidden,frozen=null,styleRewrites){if(!previousMeta||!sameMeta(previousMeta,currentMeta)||!dirty)return!1;let first=currentMeta.start,last=currentMeta.length-1;if(dirty.kind==="range")first=Math.max(first,active.baseY+dirty.start),last=Math.min(last,active.baseY+dirty.end);let cursorY=active.baseY+active.cursorY;for(let y3=first;y3<=last;y3++){let row=snapshot[y3-currentMeta.start];if(!row)return!1;if(frozen&&y3<frozen.baseY&&frozen.cache.get(frozen.absBase+y3)===row)continue;let minLast=!cursorHidden&&y3===cursorY?active.cursorX-1:-1;if(!xtermLineMatchesChunks(active.getLine(y3),row,minLast,styleRewrites))return!1}return!0}function xtermSynchronizedOutput(term){try{return term.modes.synchronizedOutputMode===!0}catch{return!1}}function xtermCursorHidden(term){try{return term._core?.coreService?.isCursorHidden===!0}catch{return!1}}function sameFlags(previous,next){if(previous.length!==next.length)return!1;for(let i2=0;i2<next.length;i2++)if(previous[i2]!==next[i2])return!1;return!0}class XtermSnapshotEngine{alternateScreenStyleRewrites;scrollbackCache=new Map;wrappedCache=new Map;wrapped=[];anchor;anchorId=0;snapshotEpoch=0;publishedMeta=null;cursorSettlement;constructor(alternateScreenStyleRewrites,platform=process.platform){this.alternateScreenStyleRewrites=alternateScreenStyleRewrites;this.cursorSettlement=new TerminalCursorSettlement(platform)}invalidate(){this.scrollbackCache.clear(),this.wrappedCache.clear(),this.wrapped=[],this.anchor?.dispose(),this.anchor=void 0,this.anchorId=0,this.publishedMeta=null,this.cursorSettlement.reset()}refresh(term,rows,scrollbackRows,refreshTracker,previousSnapshot,previousCursor,previousWindow){if(xtermSynchronizedOutput(term))return null;let active=term.buffer.active,styleRewrites=active.type==="alternate"?this.alternateScreenStyleRewrites:void 0,cursorHidden=xtermCursorHidden(term),currentMeta=snapshotMeta(active,rows,scrollbackRows),nextCursor=reconcileTerminalCursor(previousCursor,cursorHidden?null:{x:active.cursorX,y:active.baseY+active.cursorY-currentMeta.start}),frameCursor=refreshTracker.synchronizedCursor,atFrameEnd=nextCursor!==null&&frameCursor?.x===nextCursor.x&&frameCursor.y===nextCursor.y+currentMeta.start,verifyAnchor=this.anchor,verifyFrozen=active.type!=="alternate"&&verifyAnchor!==void 0&&!verifyAnchor.isDisposed?{baseY:active.baseY,absBase:this.anchorId-verifyAnchor.line,cache:this.scrollbackCache}:null;if(dirtyRowsMatchSnapshot(active,previousSnapshot,this.publishedMeta,currentMeta,refreshTracker.peek(),cursorHidden,verifyFrozen,styleRewrites)){refreshTracker.clear(),this.publishedMeta=currentMeta;let cursor2=this.cursorSettlement.update(nextCursor,previousSnapshot,atFrameEnd,Date.now());return{snapshot:previousSnapshot,cursor:cursor2,snapshotWindow:previousWindow,wrapped:this.wrapped,changed:cursor2!==previousCursor,cursorPending:this.cursorSettlement.pending}}let canAnchor=active.type!=="alternate"&&active.baseY>0;if(canAnchor&&(this.anchor===void 0||this.anchor.isDisposed)){this.scrollbackCache.clear(),this.wrappedCache.clear();let fresh=term.registerMarker(-active.cursorY-1);if(fresh)this.snapshotEpoch+=1,this.anchor=fresh,this.anchorId=fresh.line}let anchorAlive=canAnchor&&this.anchor!==void 0&&!this.anchor.isDisposed,absBase=anchorAlive?this.anchorId-this.anchor.line:0,cache=this.scrollbackCache,wrappedCache=this.wrappedCache,rowsOut=[],wrappedOut=[],cursorY=active.baseY+active.cursorY,start=currentMeta.start;for(let y3=start;y3<active.length;y3++){let frozen=anchorAlive&&y3<active.baseY;if(frozen){let cached=cache.get(absBase+y3);if(cached){rowsOut.push(cached),wrappedOut.push(wrappedCache.get(absBase+y3)??!1);continue}}let line=active.getLine(y3),minLast=!cursorHidden&&y3===cursorY?active.cursorX-1:-1,previousRow=previousSnapshot[rowsOut.length],row=previousRow&&xtermLineMatchesChunks(line,previousRow,minLast,styleRewrites)?previousRow:line?xtermLineToChunks(line,minLast,styleRewrites):[],wraps=y3>start&&line?.isWrapped===!0,stableRow=frozen?reconcileTerminalRow(previousSnapshot[rowsOut.length],row):row;if(rowsOut.push(stableRow),wrappedOut.push(wraps),frozen)cache.set(absBase+y3,stableRow),wrappedCache.set(absBase+y3,wraps)}if(anchorAlive){let min=absBase+start;for(let id of cache.keys())if(id<min)cache.delete(id);for(let id of wrappedCache.keys())if(id<min)wrappedCache.delete(id)}if(canAnchor){let next=term.registerMarker(-active.cursorY-1);if(next)this.anchorId=anchorAlive?absBase+next.line:0,this.anchor?.dispose(),this.anchor=next}let snapshot=reconcileTerminalRows(previousSnapshot,rowsOut),cursor=this.cursorSettlement.update(nextCursor,snapshot,atFrameEnd,Date.now()),nextStartLine=absBase+start,snapshotWindow=anchorAlive?previousWindow?.epoch===this.snapshotEpoch&&previousWindow.startLine===nextStartLine?previousWindow:{epoch:this.snapshotEpoch,startLine:nextStartLine}:null;refreshTracker.clear(),this.publishedMeta=currentMeta;let wrapLayoutMoved=!sameFlags(this.wrapped,wrappedOut);if(wrapLayoutMoved)this.wrapped=wrappedOut;let changed=snapshot!==previousSnapshot||cursor!==previousCursor||snapshotWindow!==previousWindow||wrapLayoutMoved;return{snapshot,cursor,snapshotWindow,wrapped:this.wrapped,changed,cursorPending:this.cursorSettlement.pending}}}var KITTY_CSI_U_RE=/^\x1b\[[\d:;]*u$/;function containsControlCharacter(value){for(let character of value){let codePoint=character.codePointAt(0);if(codePoint===void 0||codePoint<=31||codePoint>=127&&codePoint<=159)return!0}return!1}var CTRL_PUNCT_C0={"@":"\x00","[":"\x1B","\\":"\x1C","]":"\x1D","^":"\x1E",_:"\x1F","?":"\x7F"},LEGACY_FUNCTION_KEYS={f1:{kind:"ss3",final:"P"},f2:{kind:"ss3",final:"Q"},f3:{kind:"ss3",final:"R"},f4:{kind:"ss3",final:"S"},f5:{kind:"tilde",number:15},f6:{kind:"tilde",number:17},f7:{kind:"tilde",number:18},f8:{kind:"tilde",number:19},f9:{kind:"tilde",number:20},f10:{kind:"tilde",number:21},f11:{kind:"tilde",number:23},f12:{kind:"tilde",number:24}},XTERM_MODIFIER_NAMED_KEYS=new Set(["delete","kpdelete","insert","kpinsert","up","kpup","down","kpdown","right","kpright","left","kpleft","home","kphome","end","kpend","pageup","kppageup","pagedown","kppagedown"]);function legacyModifier(evt){return 1+(evt.shift?1:0)+(evt.option||evt.meta?2:0)+(evt.ctrl?4:0)+(evt.super?8:0)+(evt.hyper?16:0)}function legacyCursorSequence(evt,final,applicationCursorKeys){let modifier=legacyModifier(evt);if(modifier!==1)return`\x1B[1;${modifier}${final}`;return applicationCursorKeys?`\x1BO${final}`:`\x1B[${final}`}function legacyTildeSequence(evt,number){let modifier=legacyModifier(evt);return modifier===1?`\x1B[${number}~`:`\x1B[${number};${modifier}~`}function legacyFunctionSequence(evt,key){if(key.kind==="tilde")return legacyTildeSequence(evt,key.number);let modifier=legacyModifier(evt);return modifier===1?`\x1BO${key.final}`:`\x1B[1;${modifier}${key.final}`}var NORMAL_TERMINAL_INPUT_MODES={applicationCursorKeys:!1,applicationKeypad:!1};function keyEventToShellBytes(evt,modes=NORMAL_TERMINAL_INPUT_MODES){if(isKittyModifierKeyEvent(evt))return null;let e2=evt,seq=typeof e2.sequence==="string"&&e2.sequence.length>0?e2.sequence:null,kittyInput=e2.source==="kitty"||typeof e2.raw==="string"&&KITTY_CSI_U_RE.test(e2.raw)||seq!=null&&KITTY_CSI_U_RE.test(seq);if(seq!=null&&!kittyInput)return seq;if(seq!=null&&!containsControlCharacter(seq)&&!evt.ctrl&&!e2.option&&!e2.meta&&!evt.super)return seq;return synthesizeShellBytes(evt,modes)}function synthesizeShellBytes(evt,modes){let name=evt.name;if(!name)return null;if(evt.shift&&name==="tab")return"\x1B[Z";let functionKey=LEGACY_FUNCTION_KEYS[name],xtermModifiedNamedKey=functionKey!==void 0||XTERM_MODIFIER_NAMED_KEYS.has(name);if((evt.option||evt.meta)&&!xtermModifiedNamedKey){let inner=synthesizeShellBytes({...evt,option:!1,meta:!1},modes);return inner==null?null:`\x1B${inner}`}if(functionKey)return legacyFunctionSequence(evt,functionKey);switch(name){case"return":case"enter":return"\r";case"kpenter":return modes.applicationKeypad&&legacyModifier(evt)===1?"\x1BOM":"\r";case"tab":return"\t";case"backspace":return"\x7F";case"delete":case"kpdelete":return legacyTildeSequence(evt,3);case"insert":case"kpinsert":return legacyTildeSequence(evt,2);case"up":case"kpup":return legacyCursorSequence(evt,"A",modes.applicationCursorKeys);case"down":case"kpdown":return legacyCursorSequence(evt,"B",modes.applicationCursorKeys);case"right":case"kpright":return legacyCursorSequence(evt,"C",modes.applicationCursorKeys);case"left":case"kpleft":return legacyCursorSequence(evt,"D",modes.applicationCursorKeys);case"home":case"kphome":return legacyCursorSequence(evt,"H",modes.applicationCursorKeys);case"end":case"kpend":return legacyCursorSequence(evt,"F",modes.applicationCursorKeys);case"pageup":case"kppageup":return legacyTildeSequence(evt,5);case"pagedown":case"kppagedown":return legacyTildeSequence(evt,6);case"clear":return"\x1B[E";case"escape":return"\x1B";case"space":return evt.ctrl?"\x00":" ";default:if(name.length===1){if(evt.ctrl){let code=name.toLowerCase().charCodeAt(0);if(code>=97&&code<=122)return String.fromCharCode(code-96);let c0=CTRL_PUNCT_C0[name];if(c0!=null)return c0;return null}if(evt.super)return null;if(evt.shift&&name>="a"&&name<="z")return name.toUpperCase();return name}return null}}var COPY_CHORDS=["cmd+c","ctrl+shift+c"],DEFAULT_PAGE_SIZE=10;var RESERVED_SPEC=[{id:"help.open"},{id:"focus.sidebar"},{id:"chat.tab.new"},{id:"chat.tab.close"},{id:"chat.tab.cycle-next"},{id:"chat.tab.cycle-prev"},{id:"chat.tab.goto"},{id:"chat.tab.rename"},"ctrl+e","ctrl+f",{id:"workspace.split.right"},{id:"workspace.split.down"},{id:"workspace.split.focus-next"},{id:"focus.next"},{id:"terminal.reset"},{id:"attention.next"}],RESERVED_GLOBAL_CHORDS=[...new Set(RESERVED_SPEC.flatMap((entry)=>typeof entry==="string"?[entry]:defaultChordsOf(entry.id)))],PASSTHROUGH_NAMES=[..."abcdefghijklmnopqrstuvwxyz".split(""),..."ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),..."0123456789".split(""),..." `~!@#$%^&*()-_=+[]{}\\|;:'\",.<>/?".split(""),"return","enter","space","tab","backspace","delete","up","down","left","right","home","end","pageup","pagedown","escape","insert","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12"],PASSTHROUGH_MODIFIER_PREFIXES=["","ctrl+","alt+","shift+","ctrl+shift+","alt+shift+","ctrl+alt+"],PASSTHROUGH_CHORDS=PASSTHROUGH_NAMES.flatMap((name)=>PASSTHROUGH_MODIFIER_PREFIXES.map((prefix)=>`${prefix}${name}`)).filter((chord)=>!RESERVED_GLOBAL_CHORDS.includes(chord));function encodeWheel(modes,direction,col,row,shift=!1){if(modes.mouseTracking&&(modes.alternateScreen||shift))return`\x1B[<${direction==="up"?64:65};${Math.max(1,col)};${Math.max(1,row)}M`;if(modes.alternateScreen)return(modes.applicationCursorKeys?direction==="up"?"\x1BOA":"\x1BOB":direction==="up"?"\x1B[A":"\x1B[B").repeat(3);return null}function encodeMouseButton(modes,kind,button,col,row,modifiers){if(modes.mouseTracking==="none")return null;if(kind==="drag"&&modes.mouseTracking!=="drag"&&modes.mouseTracking!=="any")return null;if(kind==="move"&&modes.mouseTracking!=="any")return null;let code=kind==="move"?35:button;if(kind==="drag")code+=32;if(modifiers?.shift)code+=4;if(modifiers?.alt)code+=8;if(modifiers?.ctrl)code+=16;return`\x1B[<${code};${Math.max(1,col)};${Math.max(1,row)}${kind==="up"?"m":"M"}`}function readInputModes(term){try{return{applicationCursorKeys:term.modes.applicationCursorKeysMode===!0,applicationKeypad:term.modes.applicationKeypadMode===!0}}catch{return{applicationCursorKeys:!1,applicationKeypad:!1}}}function appOwnsMouse(term){try{return term.modes.mouseTrackingMode!=="none"}catch{return!1}}function wheelSequence(term,direction,col,row,shift=!1){try{return encodeWheel({mouseTracking:term.modes.mouseTrackingMode!=="none",applicationCursorKeys:term.modes.applicationCursorKeysMode===!0,alternateScreen:term.buffer.active.type==="alternate"},direction,col,row,shift)}catch{return null}}function mouseButtonSequence(term,kind,button,col,row,modifiers){try{return encodeMouseButton({mouseTracking:term.modes.mouseTrackingMode},kind,button,col,row,modifiers)}catch{return null}}var SNAPSHOT_COALESCE_MS=Math.round(1000/hostTargetFps());class XtermTaskPty{taskId;cwd;term;listeners=new PtyListeners;snapshot=[];cursor=null;snapshotWindow=null;snapshotWrapped=[];snapshotDirty=!1;snapshotEngine;_title=null;_unwatchedSince=Date.now();_killed=!1;muteReplies=!1;cols;rows;cancelRefresh=null;scheduleRefresh;lastRefreshAt=0;refreshTracker;scrollbackRows;graphicsFilter=new KittyGraphicsFilter;constructor(opts,options={}){if(this.taskId=opts.taskId,this.cwd=opts.cwd,this.scheduleRefresh=opts.scheduleRefresh,this.cols=opts.cols??DEFAULT_COLS,this.rows=opts.rows??DEFAULT_ROWS,opts.restore?.title)this._title=opts.restore.title;this.scrollbackRows=opts.scrollback??persistedScrollbackRows(),this.term=new import_headless.Terminal({allowProposedApi:!0,cols:this.cols,rows:this.rows,scrollback:this.scrollbackRows,windowOptions:{getCellSizePixels:!0}}),this.snapshotEngine=new XtermSnapshotEngine(opts.alternateScreenStyleRewrites),this.term.loadAddon(new Ke),this.term.unicode.activeVersion="11",this.refreshTracker=new XtermRefreshTracker(this.term);let reply=(data)=>{if(this._killed||this.muteReplies)return;try{this.transportWrite(data)}catch{}};if(wireXtermChannels(this.term,{onReply:reply,onTitle:(title)=>{if(!title||title===this._title)return;this._title=title,this.listeners.publishTitle(title)}}),options.respondToDefaultColorQueries!==!1)wireXtermDefaultColorQueries(this.term,opts.defaultColors,reply);wireXtermCellSizeQuery(this.term,()=>terminalGraphics()?.cellPixelSize??null,reply)}get killed(){return this._killed}write(data){if(this._killed||data.length===0)return;try{this.transportWrite(data)}catch{this.markDead(!1)}}inputModes(){return readInputModes(this.term)}onExit(cb){if(this._killed)return cb(),()=>{};return this.listeners.addExit(cb)}onTitleChange(cb){let off=this.listeners.addTitle(cb);if(this._title)try{cb(this._title)}catch{}return off}paste(text){if(this._killed||text.length===0)return;let bracketed=!1;try{bracketed=this.term.modes.bracketedPasteMode===!0}catch{}this.write(bracketed?`\x1B[200~${text}\x1B[201~`:text)}wheel(direction,col,row,shift=!1){return this.emit(this._killed?null:wheelSequence(this.term,direction,col,row,shift))}click(kind,button,col,row,modifiers){return this.emit(this._killed?null:mouseButtonSequence(this.term,kind,button,col,row,modifiers))}emit(seq){if(seq===null)return!1;return this.write(seq),!0}get appOwnsMouse(){return this._killed?!1:appOwnsMouse(this.term)}onData(cb){this.ensureFreshSnapshot();let off=this.listeners.addData(cb);if(this._unwatchedSince=null,this.snapshot.length>0)try{cb(this.snapshot,this.cursor,this.snapshotWindow,this.snapshotWrapped)}catch{}return()=>{if(off(),this.listeners.dataCount===0){if(this.cancelRefresh)this.snapshotDirty=!0;if(this.cancelQueuedRefresh(),this._unwatchedSince===null)this._unwatchedSince=Date.now()}}}unwatchedSinceMs(){return this._unwatchedSince}get windowTitle(){return this._title}get scrollback(){return this.scrollbackRows}resizeEmulator(cols,rows){this.cols=cols,this.rows=rows,this.term.resize(cols,rows),this.invalidateScrollbackCache(),this.refreshTracker.markAll()}get size(){return{cols:this.cols,rows:this.rows}}resize(cols,rows){if(this._killed)return;this.cols=cols,this.rows=rows;try{this.term.resize(cols,rows),this.invalidateScrollbackCache(),this.transportResize(cols,rows),this.refreshTracker.markAll(),this.refreshSnapshot()}catch{this.markDead(!1)}}invalidateScrollbackCache(){this.snapshotEngine.invalidate(),this.snapshotWindow=null}capture(){return this.ensureFreshSnapshot(),this.snapshot}captureCursor(){return this.ensureFreshSnapshot(),this.cursor}captureWindow(){return this.ensureFreshSnapshot(),this.snapshotWindow}captureWrapped(){return this.ensureFreshSnapshot(),this.snapshotWrapped}ensureFreshSnapshot(){if(!this.snapshotDirty||this._killed)return;this.refreshSnapshot()}kill(){if(this._killed)return;this.markDead(!0)}feed(data){this.feedInternal(data,!1)}feedReplay(data){this.feedInternal(data,!0)}feedInternal(data,muteReplies){if(this._killed)return;if(muteReplies)this.muteReplies=!0;profileTick("feed"),this.term.write(this.liftGraphics(data),()=>{if(muteReplies)this.muteReplies=!1;if(!this.refreshTracker.supported)this.refreshTracker.markAll();this.queueRefresh()})}liftGraphics(data){let write=terminalGraphics()?.writeKitty;return write?this.graphicsFilter.push(data,write):data}queueRefresh(){if(this.listeners.dataCount===0){this.snapshotDirty=!0;return}if(this.cancelRefresh)return;if(this.scheduleRefresh){this.snapshotDirty=!0,this.cancelRefresh=this.scheduleRefresh(()=>{this.cancelRefresh=null,this.refreshSnapshot()});return}let since=Date.now()-this.lastRefreshAt;if(since>=SNAPSHOT_COALESCE_MS){this.refreshSnapshot();return}let timer=setTimeout(()=>{this.cancelRefresh=null,this.refreshSnapshot()},SNAPSHOT_COALESCE_MS-since);this.cancelRefresh=()=>clearTimeout(timer)}cancelQueuedRefresh(){this.cancelRefresh?.(),this.cancelRefresh=null}refreshSnapshot(){if(this._killed)return;this.cancelQueuedRefresh(),this.lastRefreshAt=Date.now();let result=profileSpan("refresh",()=>this.snapshotEngine.refresh(this.term,this.rows,this.scrollbackRows,this.refreshTracker,this.snapshot,this.cursor,this.snapshotWindow));if(result===null){this.queueRefresh();return}if(this.snapshot=result.snapshot,this.cursor=result.cursor,this.snapshotWindow=result.snapshotWindow,this.snapshotWrapped=result.wrapped,this.snapshotDirty=!1,result.changed)this.publishSnapshot();if(result.cursorPending)this.queueRefresh()}publishSnapshot(){profileTick("publish"),this.listeners.publishData(this.snapshot,this.cursor,this.snapshotWindow,this.snapshotWrapped)}disposeEmulator(){try{this.term.dispose()}catch{}}markDead(killProcess){if(this._killed)return;if(this._killed=!0,this.cancelQueuedRefresh(),this.refreshTracker.dispose(),this.disposeEmulator(),killProcess)try{this.transportKill()}catch{}let exitCbs=this.listeners.drainExits();this.listeners.clearData();for(let cb of exitCbs)try{cb()}catch{}}silentDispose(){this._killed=!0,this.cancelQueuedRefresh(),this.refreshTracker.dispose(),this.disposeEmulator(),this.listeners.clearAll()}}function sessionRecovery(result){if(!result.alive)return result.replay.length>0?"restored":null;if(result.respawned===!0)return"relaunched";if(result.created===!1)return"live";return null}var WIGGLE_MIN_GAP_MS=150;class HostedTaskPty extends XtermTaskPty{client=null;recovery=null;recoveryListeners=new Set;onRecovery(listener){return this.recoveryListeners.add(listener),listener(this.recovery),()=>{this.recoveryListeners.delete(listener)}}opened=!1;pendingInput=[];pendingResize=null;unsubs=[];deadOnAttach=!1;sessionPid=void 0;pendingExitPid=null;get shellPid(){return this.machine?null:this.sessionPid??null}machine;serializer=new D;hostOffset=null;constructor(opts){super(opts,{respondToDefaultColorQueries:!1});this.term.loadAddon(this.serializer),this.openRemote(opts)}static createdFresh(res){return res.alive&&(res.created??res.replay.length===0)}async openRemote(opts){try{this.machine=opts.machine;let client=opts.machine?await getMachinePtyClient(opts.machine):await getSharedPtyClient();if(this.killed)return;if(this.client=client,opts.machine){let{sessions}=await client.request("pty.list");if(!sessions.some((s2)=>s2.key===this.taskId)){this.remoteGone();return}}routeAdd(this),this.unsubs.push(client.onLifecycle("close",()=>this.remoteGone()));let res=await client.request("pty.open",{key:this.taskId,cwd:this.cwd,command:opts.machine?void 0:opts.command,shell:opts.machine?void 0:opts.shell,cols:this.cols,rows:this.rows,defaultColors:opts.defaultColors,sinceOffset:opts.restore?.byteOffset,sincePid:opts.restore?.pid??void 0,answersQueries:!0});if(this.killed)return;this.recovery=sessionRecovery(res);for(let listener of this.recoveryListeners)listener(this.recovery);this.sessionPid=res.pid??null,this.hostOffset=res.offset??null;let restored=opts.restore!==void 0&&res.sinceValid===!0&&res.created!==!0&&(res.pid??null)===opts.restore.pid;if(restored&&opts.restore){if(await this.restoreParked(opts.restore,Buffer.from(res.replay,"base64")),this.killed)return}else if(res.replay.length>0)this.feedReplay(Buffer.from(res.replay,"base64"));if(this.opened=!0,this.pendingResize){let{cols,rows}=this.pendingResize;this.pendingResize=null,this.sendResize(cols,rows)}let fresh=HostedTaskPty.createdFresh(res);if(opts.initialInput&&fresh&&!opts.machine)this.sendInput(opts.initialInput);if(opts.firstMessage&&fresh&&!opts.machine)pastePromptWhenEngineUp(client,this.taskId,opts.engineBin,opts.firstMessage).catch((err)=>logClientError("pty-hosted",err));for(let data of this.pendingInput.splice(0))this.sendInput(data);let parkedExitPid=this.pendingExitPid;if(this.pendingExitPid=null,!res.alive)this.deadOnAttach=res.replay.length>0||restored,this.remoteGone();else if(parkedExitPid!==null&&parkedExitPid===this.sessionPid)this.remoteGone();else if(res.replay.length>0&&!restored){if(this.sendResize(this.cols,Math.max(1,this.rows-1)),await Promise.all([this.nextDataOrTimeout(500),new Promise((r6)=>setTimeout(r6,WIGGLE_MIN_GAP_MS))]),!this.killed)this.sendResize(this.cols,this.rows)}}catch(err){logClientError("pty-hosted",err),this.remoteGone()}}transportWrite(data){if(!this.opened){this.pendingInput.push(data);return}this.sendInput(data)}transportResize(cols,rows){if(!this.opened){this.pendingResize={cols,rows};return}this.sendResize(cols,rows)}transportKill(){let client=this.client;if(client)client.request("pty.kill",{key:this.taskId}).catch(()=>{});this.cleanup()}kill(){if(this.killed){this.client?.request("pty.kill",{key:this.taskId}).catch(()=>{});return}super.kill()}capturePark(){if(this.killed||!this.opened||this.hostOffset===null||this.sessionPid===void 0)return null;try{return{serialized:Buffer.from(this.serializer.serialize({scrollback:this.scrollback}),"utf8").toString(),title:this.windowTitle,cursorHidden:xtermCursorHidden(this.term),cols:this.cols,rows:this.rows,byteOffset:this.hostOffset,pid:this.sessionPid}}catch{return null}}async restoreParked(state,delta){let targetCols=this.cols,targetRows=this.rows;if(state.cols!==targetCols||state.rows!==targetRows)this.resizeEmulator(state.cols,state.rows);if(this.feedReplay(state.serialized+(state.cursorHidden?"\x1B[?25l":"")),delta.byteLength>0)this.feedReplay(delta);if(await new Promise((resolve)=>{let off=this.onExit(resolve);this.term.write("",()=>{off(),resolve()})}),!this.killed&&(this.cols!==targetCols||this.rows!==targetRows))this.resizeEmulator(targetCols,targetRows)}detach(opts={}){let client=this.client;this.cleanup();let siblings=routeCount(this.taskId);if(client&&siblings===0)client.request("pty.detach",{key:this.taskId,parked:opts.parked===!0,parkedScreenBytes:opts.parkedScreenBytes}).catch(()=>{});this.silentDispose()}sendInput(data){this.client?.request("pty.write",{key:this.taskId,data}).catch(()=>this.remoteGone())}sendResize(cols,rows){this.client?.request("pty.resize",{key:this.taskId,cols,rows}).catch(()=>{})}dataWaiter=null;_lastOutputAt=null;lastOutputAtMs(){return this._lastOutputAt}nextDataOrTimeout(ms){return new Promise((resolve)=>{let timer=setTimeout(()=>{this.dataWaiter=null,resolve()},ms);this.dataWaiter=()=>{this.dataWaiter=null,clearTimeout(timer),resolve()}})}feedFrame(dataB64){this.dataWaiter?.(),this._lastOutputAt=Date.now();let buf=Buffer.from(dataB64,"base64");if(this.hostOffset!==null)this.hostOffset+=buf.byteLength;this.feed(buf)}remoteExited(pid){if(this.killed)return;if(pid===void 0){this.remoteGone();return}if(this.sessionPid===void 0){this.pendingExitPid=pid;return}if(pid!==null&&pid===this.sessionPid)this.remoteGone()}remoteGone(){this.cleanup(),this.markDead(!1)}cleanup(){routeRemove(this);for(let unsub of this.unsubs.splice(0))try{unsub()}catch{}}}class MockTaskPty{taskId;cwd;listeners=new Set;buffer="";writes=[];_killed=!1;_title=null;exitListeners=new Set;titleListeners=new Set;pastes=[];deadOnAttach=!1;wheels=[];clicks=[];appOwnsMouse=!1;_cols;_rows;_cursor=null;modes={applicationCursorKeys:!1,applicationKeypad:!1};constructor(opts){if(this.taskId=opts.taskId,this.cwd=opts.cwd,this._cols=opts.cols??DEFAULT_COLS,this._rows=opts.rows??DEFAULT_ROWS,opts.initialInput)this.writes.push(opts.initialInput)}get killed(){return this._killed}get attached(){return this.listeners.size>0}get writeLog(){return this.writes}get geometry(){return{cols:this._cols,rows:this._rows}}feed(data){if(this._killed)return;this.buffer+=data;let title=extractOscTitle(data);if(title&&title!==this._title){this._title=title;for(let cb of this.titleListeners)try{cb(title)}catch{}}let rows=this.capture();for(let cb of this.listeners)try{cb(rows,this._cursor,null)}catch{}}write(data){if(this._killed)return;this.writes.push(data)}inputModes(){return this.modes}replaceScreen(data){if(this._killed)return;this.buffer="",this.feed(data)}onData(cb){if(this.listeners.add(cb),this.buffer!=="")try{cb(this.capture(),this._cursor,null)}catch{}return()=>{this.listeners.delete(cb)}}resize(cols,rows){if(this._killed)return;this._cols=cols,this._rows=rows}capture(){return parseAnsiSnapshot(this.buffer)}setCursor(pos){this._cursor=pos}captureCursor(){if(this._killed)return null;return this._cursor}captureWindow(){return null}kill(){if(this._killed)return;this._killed=!0,this.listeners.clear();let exitCbs=[...this.exitListeners];this.exitListeners.clear();for(let cb of exitCbs)cb()}paste(text){if(this._killed)return;this.pastes.push(text)}wheel(direction,col,row){if(this._killed)return!1;return this.wheels.push({direction,col,row}),!1}click(kind,button,col,row){if(this._killed)return!1;return this.clicks.push({kind,button,col,row}),this.appOwnsMouse}onExit(cb){if(this._killed)return cb(),()=>{};return this.exitListeners.add(cb),()=>{this.exitListeners.delete(cb)}}onTitleChange(cb){if(this.titleListeners.add(cb),this._title)try{cb(this._title)}catch{}return()=>{this.titleListeners.delete(cb)}}}import{spawn}from"child_process";class PipeTaskPty{taskId;cwd;proc;listeners=new Set;buffer="";_killed=!1;_title=null;exitListeners=new Set;titleListeners=new Set;cols;rows;constructor(opts){this.taskId=opts.taskId,this.cwd=opts.cwd,this.cols=opts.cols??DEFAULT_COLS,this.rows=opts.rows??DEFAULT_ROWS;let argv=resolveArgv(opts),exe=argv[0]??defaultShell(),args=argv.slice(1);if(this.proc=spawn(exe,args,{cwd:opts.cwd,env:embeddedTerminalEnv(process.env,{TERM:process.env.TERM??"xterm-256color",COLUMNS:String(this.cols),LINES:String(this.rows),ROVE_TERMINAL_PIPE:"1"}),stdio:["pipe","pipe","pipe"]}),this.proc.stdout?.setEncoding("utf8"),this.proc.stderr?.setEncoding("utf8"),this.proc.stdout?.on("data",(chunk)=>this.append(chunk)),this.proc.stderr?.on("data",(chunk)=>this.append(chunk)),this.proc.stdin?.on("error",()=>this.markDead(!1)),this.proc.on("error",(err)=>{this.append(`
|
|
57
57
|
[Rove terminal] failed to start shell: ${err.message}
|
|
58
58
|
`),this.markDead(!1)}),this.proc.on("exit",()=>this.markDead(!1)),this.proc.unref?.(),opts.initialInput)this.write(opts.initialInput)}get killed(){return this._killed}write(data){if(this._killed||data.length===0)return;let stdin=this.proc.stdin;if(!stdin||stdin.destroyed)return;let bytes=data.replace(/\r/g,`
|
|
59
59
|
`);try{stdin.write(bytes)}catch{this.markDead(!1)}}inputModes(){return{applicationCursorKeys:!1,applicationKeypad:!1}}onData(cb){if(this.listeners.add(cb),this.buffer!=="")try{cb(this.capture(),null,null)}catch{}return()=>{this.listeners.delete(cb)}}resize(cols,rows){if(this._killed)return;this.cols=cols,this.rows=rows}capture(){return parseAnsiSnapshot(this.buffer)}captureCursor(){return null}captureWindow(){return null}kill(){if(this._killed)return;this.markDead(!0)}append(chunk){if(this._killed)return;if(this.buffer+=chunk,this.buffer.length>PIPE_SCROLLBACK_LIMIT)this.buffer=this.buffer.slice(this.buffer.length-PIPE_SCROLLBACK_LIMIT);let title=extractOscTitle(chunk);if(title&&title!==this._title){this._title=title;for(let cb of this.titleListeners)try{cb(title)}catch{}}let rows=this.capture();for(let cb of this.listeners)try{cb(rows,null,null)}catch{}}markDead(killProcess){if(this._killed)return;if(this._killed=!0,killProcess)try{this.proc.kill("SIGTERM")}catch{}let exitCbs=[...this.exitListeners];this.listeners.clear(),this.exitListeners.clear();for(let cb of exitCbs)try{cb()}catch{}}paste(text){this.write(text)}wheel(){return!1}click(){return!1}onExit(cb){if(this._killed)return cb(),()=>{};return this.exitListeners.add(cb),()=>{this.exitListeners.delete(cb)}}onTitleChange(cb){if(this.titleListeners.add(cb),this._title)try{cb(this._title)}catch{}return()=>{this.titleListeners.delete(cb)}}}class BunTerminalTaskPty extends XtermTaskPty{proc;constructor(opts){super(opts);if(this.proc=Bun.spawn(resolveArgv(opts),{cwd:opts.cwd,env:embeddedTerminalEnv(process.env,{TERM:"xterm-256color",COLUMNS:String(this.cols),LINES:String(this.rows),BASH_SILENCE_DEPRECATION_WARNING:"1",ROVE_TERMINAL_PTY:"1"}),terminal:{cols:this.cols,rows:this.rows,name:"xterm-256color",data:(_terminal,data)=>this.feed(data),exit:()=>this.markDead(!1)}}),this.proc.exited.then(()=>this.markDead(!1),()=>this.markDead(!1)),this.proc.unref?.(),opts.initialInput)this.transportWrite(opts.initialInput)}get shellPid(){return this.proc.pid??null}transportWrite(data){this.proc.terminal?.write(data)}transportResize(cols,rows){this.proc.terminal?.resize(cols,rows)}transportKill(){try{this.proc.terminal?.close()}catch{}try{this.proc.kill("SIGTERM")}catch{}}}function createTaskPty(opts){let backend=process.env.ROVE_TERMINAL_BACKEND??"hosted";if(backend==="mock")return new MockTaskPty(opts);if(backend==="pipe")return new PipeTaskPty(opts);if(backend==="bun-pty")return new BunTerminalTaskPty(opts);if(backend==="hosted")return new HostedTaskPty(opts);throw Error(`unknown terminal backend: ${backend}`)}var PARK_AFTER_MS=120000,PARK_SWEEP_MS=30000,PARK_QUIET_MS=30000;class PtyRegistry{map=new Map;parked=new Map;factory;sweepTimer=null;constructor(factory=createTaskPty){this.factory=factory}ensureSweeper(){if(this.sweepTimer)return;let timer=setInterval(()=>this.parkIdle(PARK_AFTER_MS),PARK_SWEEP_MS);timer.unref?.(),this.sweepTimer=timer}stopSweeper(){if(this.sweepTimer)clearInterval(this.sweepTimer);this.sweepTimer=null}parkIdle(idleMs,now=Date.now()){let parked=[];for(let[id,pty]of this.map){if(pty.killed)continue;if(!pty.detach||!pty.unwatchedSinceMs)continue;let since=pty.unwatchedSinceMs();if(since===null||now-since<idleMs)continue;let lastOut=pty.lastOutputAtMs?.()??null;if(lastOut!==null&&now-lastOut<PARK_QUIET_MS)continue;let screen=pty.capturePark?.()??null;try{pty.detach({parked:screen!==null,parkedScreenBytes:screen?Buffer.byteLength(screen.serialized):void 0})}catch{}if(this.map.delete(id),screen)this.parked.set(id,screen);parked.push(id)}if(parked.length>0&&isDev()){let rss=Math.round(process.memoryUsage().rss/1048576);console.error(`[rove pty] parked ${parked.length} idle terminal(s); ${this.map.size} live; rss=${rss}MB`)}return parked}acquire(taskId,cwd,opts={}){let existing=this.map.get(taskId);if(existing&&!existing.killed)return existing;if(existing)this.map.delete(taskId);let restore=this.parked.get(taskId);if(restore)this.parked.delete(taskId);let pty=this.factory({taskId,cwd,...opts,...restore?{restore}:{}});return this.map.set(taskId,pty),this.ensureSweeper(),pty}get(taskId){let pty=this.map.get(taskId);if(!pty)return null;if(pty.killed)return this.map.delete(taskId),null;return pty}has(taskId){return this.get(taskId)!==null}release(taskId){let pty=this.map.get(taskId);if(this.map.delete(taskId),this.parked.delete(taskId),!pty)return;try{pty.kill()}catch{}}releaseWhere(predicate){let ids=Array.from(this.map.keys()).filter(predicate);for(let id of ids)this.release(id);for(let id of Array.from(this.parked.keys()).filter(predicate))this.parked.delete(id)}releaseAll(){let ids=Array.from(this.map.keys());for(let id of ids)this.release(id);this.parked.clear(),this.stopSweeper()}detachAll(){let ptys=Array.from(this.map.values());this.map.clear(),this.parked.clear(),this.stopSweeper();for(let pty of ptys)try{if(pty.detach)pty.detach();else pty.kill()}catch{}}reset(taskId,cwd,opts={}){return this.release(taskId),this.acquire(taskId,cwd,opts)}resetIfCurrent(taskId,expected,cwd,opts={}){if(expected.killed||this.map.get(taskId)!==expected)return null;return this.reset(taskId,cwd,opts)}get size(){return this.map.size}entries(){return[...this.map]}}var defaultRegistry=null;function getDefaultPtyRegistry(){if(!defaultRegistry)defaultRegistry=new PtyRegistry;return defaultRegistry}import{unwatchFile,watchFile}from"fs";var bound;function bindHost(host){bound=host}function host(){if(!bound)throw Error("issues: the page host is not bound yet");return bound}function hostFn(pick){return(...args)=>pick(host())(...args)}var import_react=__toESM(require_react_production(),1);import{TextAttributes}from"@opentui/core";var samePath2=hostFn((h2)=>h2.paths.samePath),errorMessage2=hostFn((h2)=>h2.text.errorMessage),sharedRelativeAge=hostFn((h2)=>h2.text.relativeAge),clampCursor=hostFn((h2)=>h2.text.clampCursor),sidebarProjectLabel2=hostFn((h2)=>h2.projects.sidebarProjectLabel),useNotifications2=hostFn((h2)=>h2.notifications.useNotifications),useTheme2=hostFn((h2)=>h2.theme.useTheme),useT2=hostFn((h2)=>h2.i18n.useT),pageCloseBindings2=hostFn((h2)=>h2.keymap.pageCloseBindings),useBindings2=hostFn((h2)=>h2.keymap.useBindings),useCursorFollow=hostFn((h2)=>h2.layout.useCursorFollow),resolveRowSelectionChrome=hostFn((h2)=>h2.ui.resolveRowSelectionChrome),FailureHint=hostFn((h2)=>h2.ui.FailureHint);function reposOf(orch){if(!orch)return[];let seen=[];for(let task of orch.listTasks())if(task.repo&&!seen.some((repo)=>samePath2(repo,task.repo)))seen.push(task.repo);return seen}function linkedTaskFor(orch,repo,number){return orch?.listTasks().find((task)=>samePath2(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 sharedRelativeAge(at2,now)}function WorkItemsPage(props){let{theme}=useTheme2(),t3=useT2(),notif=useNotifications2();function notifyError(message){notif.notify({kind:"error",taskId:"",tabId:"",title:message})}let repos=reposOf(props.orchestrator),[repoIndex,setRepoIndex]=import_react.useState(()=>{let wanted=props.focusRepo?repos.findIndex((repo2)=>samePath2(repo2,props.focusRepo)):-1;return wanted>=0?wanted:0}),repo=repos[repoIndex],[items,setItems]=import_react.useState(null),[error,setError]=import_react.useState(null),[reloadTick,setReloadTick]=import_react.useState(0),[assignedToMe,setAssignedToMe]=import_react.useState(!1),[starting,setStarting]=import_react.useState(!1),[notice,setNotice]=import_react.useState(null);import_react.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_react.useState(0);import_react.useEffect(()=>{setCursor((c2)=>clampCursor(c2,rows.length))},[rows.length]);let follow=useCursorFollow(cursor);import_react.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:errorMessage2(err)}))}finally{setStarting(!1)}}useBindings2(()=>({enabled:props.focused!==!1,bindings:[...pageCloseBindings2(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:TextAttributes.BOLD,fg:theme.text,children:t3("workItems.title")}),$jsxs("text",{fg:theme.textMuted,children:[repo?sidebarProjectLabel2(repo,repos):t3("workItems.noRepo"),assignedToMe?` ${t3("workItems.assignedFilter")}`:""]})]}),error?$jsxs("box",{flexDirection:"column",marginTop:1,children:[$jsxs("box",{children:[$jsx("text",{fg:theme.error,children:error}),$jsx(FailureHint,{})]}),$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?TextAttributes.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]})}function IssuesRailPage(props){return $jsx(WorkItemsPage,{orchestrator:props.orchestrator,focused:props.focused,onClose:props.onClose,...props.selectedTask?{focusRepo:props.selectedTask.repo}:{},onOpenTask:props.onOpenTask})}var issuesPlugin={id:"issues",name:"Issues",description:"Open GitHub issues for the selected project, via `gh`",pages:[{id:"github",title:(h2)=>h2.i18n.t("tasks.nav.issues"),order:30,action:"workItems.open",factory:(h2)=>{return bindHost(h2),IssuesRailPage}}]};var bound2;function bindHost2(host2){bound2=host2}function host2(){if(!bound2)throw Error("kanban: the page host is not bound yet");return bound2}function hostFn2(pick){return(...args)=>pick(host2())(...args)}var import_react7=__toESM(require_react_production(),1);import{TextAttributes as TextAttributes5}from"@opentui/core";import{TextAttributes as TextAttributes2}from"@opentui/core";var import_react4=__toESM(require_react_production(),1);var import_react2=__toESM(require_react_production(),1);var useTheme3=hostFn2((h2)=>h2.theme.useTheme),useT3=hostFn2((h2)=>h2.i18n.useT),DialogLabel=hostFn2((h2)=>h2.dialog.DialogLabel),eventRows2=hostFn2((h2)=>h2.issues.events.eventRows),AGE_CELLS=4;function IssueEventsSection(props){let{theme}=useTheme3(),t3=useT3(),[rows,setRows]=import_react2.useState(null);return import_react2.useEffect(()=>{let orch=props.orchestrator;if(!orch){setRows([]);return}let live=!0;return orch.recentTaskEvents(props.taskId).then((result)=>{if(live)setRows(eventRows2(result.events,Date.now(),host2().issues.events.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 withImagePlaceholders2=hostFn2((h2)=>h2.issues.withImagePlaceholders),stripNewlines=hostFn2((h2)=>h2.text.stripNewlines),asAttachmentPaths2=hostFn2((h2)=>h2.attachments.asAttachmentPaths),captureClipboardAttachment2=hostFn2((h2)=>h2.attachments.captureClipboardAttachment),useTheme4=hostFn2((h2)=>h2.theme.useTheme),useT4=hostFn2((h2)=>h2.i18n.useT),useBindings3=hostFn2((h2)=>h2.keymap.useBindings),showDialog2=hostFn2((h2)=>h2.dialog.showDialog),useDialog2=hostFn2((h2)=>h2.dialog.useDialog),useDialogPaddingX2=hostFn2((h2)=>h2.dialog.useDialogPaddingX),ChipButton=hostFn2((h2)=>h2.dialog.ChipButton),ChipRow=hostFn2((h2)=>h2.dialog.ChipRow),DialogField=hostFn2((h2)=>h2.dialog.DialogField),DialogFooter=hostFn2((h2)=>h2.dialog.DialogFooter),DialogHeader=hostFn2((h2)=>h2.dialog.DialogHeader),DialogSection=hostFn2((h2)=>h2.dialog.DialogSection),DESCRIPTION_ROWS=8;function IssueDetailDialogView(props){let dialog=useDialog2(),{theme}=useTheme4(),t3=useT4(),padX=useDialogPaddingX2(),{ISSUE_CHAT_PLACEMENTS:ISSUE_CHAT_PLACEMENTS2,ISSUE_STATUSES:ISSUE_STATUSES2}=host2().issues,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_react4.useState(props.defaultVendor),[placement,setPlacement]=import_react4.useState(ISSUE_CHAT_PLACEMENTS2[0]??"worktree"),[jump,setJump]=import_react4.useState(!1),[draftTitle,setDraftTitle]=import_react4.useState(issue.title),[draftBody,setDraftBody]=import_react4.useState(issue.body),[draftStatus,setDraftStatus]=import_react4.useState(issue.status),[field,setField]=import_react4.useState(create?"title":startable?"workspace":linkedTaskId?"open":"title"),bodyEl=import_react4.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=withImagePlaceholders2(bodyEl.current?.plainText??draftBody,paths);bodyEl.current?.setText(next),setDraftBody(next)}usePaste((event)=>{let paths=asAttachmentPaths2(new TextDecoder().decode(event.bytes));if(!paths)return;event.preventDefault(),insertPlaceholders(paths)});function pasteClipboardImage(){captureClipboardAttachment2().then((path)=>{if(path)insertPlaceholders([path])})}function cycleField(dir){setField((current2)=>{let i2=Math.max(0,fields.indexOf(current2));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_PLACEMENTS2.indexOf(p3);return ISSUE_CHAT_PLACEMENTS2[(i2+dir+ISSUE_CHAT_PLACEMENTS2.length)%ISSUE_CHAT_PLACEMENTS2.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_STATUSES2.indexOf(s2));return ISSUE_STATUSES2[(i2+dir+ISSUE_STATUSES2.length)%ISSUE_STATUSES2.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()}useBindings3(()=>({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)},{key:"h",cmd:()=>stepStatus(-1)},{key:"l",cmd:()=>stepStatus(1)}]:[],...field==="engine"?[{key:"left",cmd:()=>stepEngine(-1)},{key:"right",cmd:()=>stepEngine(1)},{key:"h",cmd:()=>stepEngine(-1)},{key:"l",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:"h",cmd:()=>setJump((v3)=>!v3)},{key:"l",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:TextAttributes2.BOLD,wrapMode:"none",children:["#",issue.id]}),$jsx("text",{fg:statusFg,attributes:TextAttributes2.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_STATUSES2,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_PLACEMENTS2.map((option)=>{let active=option===placement;return $jsxs("text",{fg:active?theme.primary:theme.textMuted,attributes:active?TextAttributes2.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 show(dialog,opts){return showDialog2(dialog,(resolve)=>$jsx(IssueDetailDialogView,{...opts,onSubmit:(outcome)=>resolve(outcome),onCancel:()=>resolve(void 0)}),{size:"large"})}var IssueDetailDialog={show};import{TextAttributes as TextAttributes4}from"@opentui/core";import{MouseButton,TextAttributes as TextAttributes3}from"@opentui/core";var taskGroupLabel=hostFn2((h2)=>h2.tasks.taskGroupLabel),taskGroupTone=hostFn2((h2)=>h2.tasks.taskGroupTone),useTheme5=hostFn2((h2)=>h2.theme.useTheme);function KanbanCard(props){let{theme,transparentBackground}=useTheme5(),{issue,column,selected}=props,columnBorder=transparentBackground?theme.border:theme.borderSubtle,fg=column==="done"?theme.textMuted:theme.text,description=issue.body.trim(),badgeLabel=props.group?taskGroupLabel(props.group):null,badgeTone=props.group?taskGroupTone(props.group):null,needsAttention=props.group==="waiting-on-you",toneColors={accent:theme.accent,warning:theme.warning,error:theme.error,success:theme.success,primary:theme.primary,textMuted:theme.textMuted};return $jsxs("box",{ref:props.boxRef,...host2().ui.FRAME,borderColor:selected?theme.primary:needsAttention?theme.warning:columnBorder,backgroundColor:transparentBackground?"transparent":theme.backgroundElement,paddingLeft:1,paddingRight:1,marginBottom:1,onMouseUp:(evt)=>{if(evt.button===MouseButton.RIGHT&&props.onContextMenu){props.onContextMenu(evt.x,evt.y);return}if(selected)props.onOpen();else props.onSelect()},children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",children:[$jsx("text",{fg,attributes:TextAttributes3.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}),badgeLabel&&badgeTone?$jsx("text",{fg:toneColors[badgeTone],wrapMode:"none",children:badgeLabel}):null]})]})}var useTheme6=hostFn2((h2)=>h2.theme.useTheme),useT5=hostFn2((h2)=>h2.i18n.useT),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}=useTheme6(),t3=useT5(),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 group=(column==="in_progress"||column==="parked")&&issue.taskId?props.taskGroupOf?.(issue.taskId):void 0;return $jsx(KanbanCard,{issue,column,selected:issue.id===selectedId,group,onSelect:()=>props.onSelect(issue.id),onOpen:()=>props.onOpen(issue),onContextMenu:props.onCardContextMenu?(x2,y3)=>props.onCardContextMenu?.(issue,x2,y3):void 0,boxRef:props.follow.rowRef(issue.id)},issue.id)}function lane(col,opts){return $jsxs("box",{flexGrow:1,flexBasis:0,...host2().ui.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:TextAttributes4.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:TextAttributes4.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?TextAttributes4.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_react5=__toESM(require_react_production(),1);var pathIdentity2=hostFn2((h2)=>h2.paths.pathIdentity),samePath3=hostFn2((h2)=>h2.paths.samePath),errorMessage3=hostFn2((h2)=>h2.text.errorMessage),isRemoteRepoKey2=hostFn2((h2)=>h2.projects.isRemoteRepoKey),getSavedRepos2=hostFn2((h2)=>h2.projects.getSavedRepos),POLL_MS=5000;function useKanbanBoards(args){let[boards,setBoards]=import_react5.useState(null),[reloadTick,setReloadTick]=import_react5.useState(0),[activeRepo,setActiveRepo]=import_react5.useState(null),[selectedId,setSelectedId]=import_react5.useState(null),{orchestrator,focusTask}=args;return import_react5.useEffect(()=>{let disposed=!1;if(!orchestrator){setBoards([]);return}let local=[...getSavedRepos2(),...orchestrator.listTasks().map((task)=>task.repo)];orchestrator.listIssueRepos().catch(()=>[]).then((stored)=>{let seen=new Set,repos=[...local,...stored].filter((repo)=>{if(!repo||isRemoteRepoKey2(repo))return!1;let key=pathIdentity2(repo.replace(/^\/private\//,"/"));if(seen.has(key))return!1;return seen.add(key),!0});return Promise.all(repos.map((repo)=>orchestrator.listIssues(repo).catch((err)=>({repoRoot:repo,exists:!1,nextId:1,issues:[],skipped:0,readError:errorMessage3(err)}))))}).then((results)=>{if(disposed)return;let next=[...results];next.sort((a2,b3)=>a2.repoRoot.localeCompare(b3.repoRoot)),setBoards(next);let activeId=orchestrator.activeTaskSignal().get(),targetRepo=focusTask?.repo??orchestrator.listTasks().find((task)=>task.id===activeId)?.repo,initialBoard=targetRepo?next.find((board)=>samePath3(board.repoRoot.replace(/^\/private\//,"/"),targetRepo.replace(/^\/private\//,"/"))):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_MS);return()=>{disposed=!0,clearInterval(timer)}},[orchestrator,reloadTick,focusTask]),{boards,activeRepo,setActiveRepo,selectedId,setSelectedId,reload:()=>setReloadTick((tick)=>tick+1)}}var import_react6=__toESM(require_react_production(),1);var useT6=hostFn2((h2)=>h2.i18n.useT),useBindings4=hostFn2((h2)=>h2.keymap.useBindings),useGlobalMouseDown=hostFn2((h2)=>h2.layout.useGlobalMouseDown),STATUS_LABEL_KEY={open:"kanban.detail.status.open",doing:"kanban.detail.status.doing",hold:"kanban.detail.status.hold",done:"kanban.detail.status.done"};function useKanbanCardMenu(deps){let t3=useT6(),[menu,setMenu]=import_react6.useState(null),[cursor,setCursor]=import_react6.useState(0),openForCard=import_react6.useCallback((issue,x2,y3)=>{let statuses=host2().issues.ISSUE_STATUSES.filter((status)=>status!==issue.status);deps.onSelect(issue.id),setMenu({issue,statuses,x:x2,y:y3}),setCursor(0)},[deps.onSelect]),close=import_react6.useCallback(()=>setMenu(null),[]);useGlobalMouseDown(menu!==null,close);let moveCursor=import_react6.useCallback((delta)=>{let count=menu?.statuses.length??0;if(count===0)return;setCursor((prev)=>(prev+delta+count)%count)},[menu]),fire=import_react6.useCallback((status)=>{if(!menu||status===void 0)return;let issue=menu.issue;setMenu(null),deps.setStatus(issue,status)},[menu,deps.setStatus]);return useBindings4(()=>({enabled:menu!==null,bindings:[{key:"up",cmd:()=>moveCursor(-1)},{key:"down",cmd:()=>moveCursor(1)},{key:"return",cmd:()=>fire(menu?.statuses[cursor])},{key:"escape",cmd:close}]})),{open:menu!==null,issue:menu?.issue??null,entries:(menu?.statuses??[]).map((status)=>({id:status,label:t3("kanban.menu.setStatus",{status:t3(STATUS_LABEL_KEY[status])})})),cursor,x:menu?.x??0,y:menu?.y??0,close,moveCursor,pickCurrent:()=>fire(menu?.statuses[cursor]),pick:(id)=>fire(menu?.statuses.find((status)=>status===id)),openForCard}}var applyBoardAttention=hostFn2((h2)=>h2.issues.board.applyBoardAttention),buildIssueBoard=hostFn2((h2)=>h2.issues.board.buildIssueBoard),moveBoardSelection=hostFn2((h2)=>h2.issues.board.moveBoardSelection),availableEngineIds2=hostFn2((h2)=>h2.engines.availableEngineIds),engineDisplayName2=hostFn2((h2)=>h2.engines.engineDisplayName),errorMessage4=hostFn2((h2)=>h2.text.errorMessage),sidebarProjectLabel3=hostFn2((h2)=>h2.projects.sidebarProjectLabel),taskGroupIn=hostFn2((h2)=>h2.tasks.taskGroupIn),useNotifications3=hostFn2((h2)=>h2.notifications.useNotifications),useTheme7=hostFn2((h2)=>h2.theme.useTheme),useT7=hostFn2((h2)=>h2.i18n.useT),pageCloseBindings3=hostFn2((h2)=>h2.keymap.pageCloseBindings),useBindings5=hostFn2((h2)=>h2.keymap.useBindings),isNarrowWidth2=hostFn2((h2)=>h2.layout.isNarrowWidth),useCursorFollow2=hostFn2((h2)=>h2.layout.useCursorFollow),useTerminalSize2=hostFn2((h2)=>h2.layout.useTerminalSize),ContextMenu=hostFn2((h2)=>h2.ui.ContextMenu),useDialog3=hostFn2((h2)=>h2.dialog.useDialog),quickForkDefaultVendor=hostFn2((h2)=>h2.engines.quickForkDefaultVendor),PAGE_PADDING_CELLS=4;function KanbanPage(props){let{theme}=useTheme7(),t3=useT7(),dialog=useDialog3(),notif=useNotifications3();function notifyError(message){notif.notify({kind:"error",taskId:"",tabId:"",title:message})}let dims=useTerminalSize2(),narrow=isNarrowWidth2(dims.width),pageRef=import_react7.useRef(null),[pageCells,setPageCells]=import_react7.useState(null),singleLane=needsSingleLane(pageCells===null?null:pageCells-PAGE_PADDING_CELLS)??narrow,[engines,setEngines]=import_react7.useState([]);import_react7.useEffect(()=>{let disposed=!1;return availableEngineIds2().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(`
|
|
@@ -94,4 +94,4 @@ ${t("worktrees.delete.forceReason",{reason:reason.replace(`task ${taskId} `,"")}
|
|
|
94
94
|
${result.prompt}`}:result,{taskId:deps.taskId,branch:getCurrentBranch(deps.worktree)})};return{requestRename,requestNewChat:(preset={})=>{(async()=>{let tabVendor=(active.kind==="engine"?active.vendor:void 0)??deps.vendor,source=liveSourceProtocol(active,tabVendor),available=await availableEngineIds(),panes=[];try{panes=listPaneLaunches({socketPath:defaultDaemonSocketPath(),binPath:ROVE_PRODUCT_NAME,taskId:deps.taskId})}catch{}let choice=await NewChatDialog.show(dialog,available,preset.context==="continue"?tabVendor:deps.vendor,{allowShell:!0,allowScratch:deps.onOpenScratch!==void 0,extraChoices:panes.map((p3)=>({key:`pane:${p3.pluginId}.${p3.paneId}`,label:p3.title})),initialDestination:preset.destination,initialContext:preset.context});if(choice===void 0)return;if(choice.destination==="fork"){await forkChildTask(choice,source,available);return}if(choice.destination==="scratch"){deps.onOpenScratch?.(choice.pick==="shell"?void 0:choice.pick);return}let pane=panes.find((p3)=>`pane:${p3.pluginId}.${p3.paneId}`===choice.pick);if(pane){update(openPluginPane(state,pane.argv,pane.title,pane.placement,void 0,deps.activeLeafSize()));return}if(choice.pick==="shell"){newShell();return}await openTabHere(choice,tabVendor,source)})()},newConversation,newShell}}var import_react111=__toESM(require_react_production(),1);function resolveEnginePty(io){let{stateRef,propsRef,engineTabSpawnRef}=io,activeTab=stateRef.current.tabs.find((tab)=>tab.id===stateRef.current.activeId),target=activeTab?.kind==="engine"?activeTab:stateRef.current.tabs.find((t3)=>t3.kind==="engine");if(!target)return null;let reg=getDefaultPtyRegistry(),key=tabPtyKey(propsRef.current.taskId,target.id),pty=reg.get(key);if(!pty&&target.kind==="engine")try{pty=reg.acquire(key,propsRef.current.worktree,{...engineTabSpawnRef.current(target)})}catch{return null}if(!pty||pty.killed)return null;return pty}function buildEngineSend(io){return(text)=>{let pty=resolveEnginePty(io);if(!pty)return!1;return pty.paste(text),pty.write("\r"),!0}}function buildEnginePaste(io){return(text)=>{let pty=resolveEnginePty(io);if(!pty)return!1;return pty.paste(text),!0}}function useTabHandoffs(io){let{stateRef,propsRef,update}=io,sendToEngine=buildEngineSend(io),pasteToEngine=buildEnginePaste(io);return import_react111.useEffect(()=>{propsRef.current.onEditorTabReady?.((command,label)=>{let current2=stateRef.current,existing=findEditorTab(current2);if(existing){let key=tabPtyKey(propsRef.current.taskId,existing.id);releaseSplitLeaves(key,existing.splitTree??null),getDefaultPtyRegistry().release(key)}if(update(openEditorTab(current2,command,label)),existing?.id===current2.activeId)io.bumpResetToken()})},[]),import_react111.useEffect(()=>{propsRef.current.onDiffTabReady?.((relPath,label,base)=>{update(openContentTab(stateRef.current,relPath,label,base))})},[]),import_react111.useEffect(()=>{propsRef.current.onEngineSendReady?.(sendToEngine)},[]),import_react111.useEffect(()=>{propsRef.current.onEnginePasteReady?.(pasteToEngine)},[]),{sendToEngine,pasteToEngine}}async function sessionIds(vendor,worktree){if(!worktree)return[];try{return await protocolEntry(vendor).history.listSessionIdsForWorktree(worktree)}catch{return[]}}async function engineSessionExists(vendor,worktree,sessionId){if(!sessionId)return!1;return(await sessionIds(vendor,worktree)).includes(sessionId)}async function discoverSessionId(vendor,worktree,claimed){return pickUnclaimedSessionId(await sessionIds(vendor,worktree),claimed)}var import_react112=__toESM(require_react_production(),1);var NAMING_POLL_MS=5000;function claimedIds(io){return new Set(io.stateRef.current.tabs.flatMap((t3)=>t3.kind==="engine"&&t3.sessionId?[t3.sessionId]:[]))}function useTabHydration(rehydrated,io){let[hydrating,setHydrating]=import_react112.useState(rehydrated);return import_react112.useEffect(()=>{if(!rehydrated)return;let cancelled=!1;return(async()=>{try{let engines=io.stateRef.current.tabs.filter((tab)=>tab.kind==="engine"),worktree=io.propsRef.current.worktree,vendorOfTab=(tab)=>tab.vendor??io.propsRef.current.vendor;for(let tab of engines){let vendor=vendorOfTab(tab);if(tab.sessionId){let exists=await engineSessionExists(vendor,worktree,tab.sessionId);if(cancelled)return;if(io.update(setTabSpawned(io.stateRef.current,tab.id,exists)),exists||protocolEntry(vendor).sessionIdentity?.pinFlag)continue}let found=await discoverSessionId(vendor,worktree,claimedIds(io));if(cancelled)return;if(!found)continue;io.update(setTabSpawned(setTabSessionId(io.stateRef.current,tab.id,found),tab.id,!0))}}finally{if(!cancelled)setHydrating(!1)}})(),()=>{cancelled=!0}},[]),hydrating}function useTabNaming(io){import_react112.useEffect(()=>{let namingBusy=!1,cancelled=!1,vendorOf=(tab)=>tab.vendor??io.propsRef.current.vendor,namingSessionId=(tab)=>tab.sessionId??engineSessionIdFromTitle(vendorOf(tab),tab.lastTitle??""),timer3=setInterval(()=>{if(namingBusy)return;let undiscovered=io.stateRef.current.tabs.filter((tab)=>tab.kind==="engine"&&!namingSessionId(tab)),candidates=io.stateRef.current.tabs.filter((tab)=>tab.kind==="engine"&&!!namingSessionId(tab)&&(!tab.spawned||!tab.title&&!tab.autoTitle));if(candidates.length===0&&undiscovered.length===0)return;namingBusy=!0,(async()=>{try{for(let tab of undiscovered){let found=await discoverSessionId(vendorOf(tab),io.propsRef.current.worktree,claimedIds(io));if(cancelled)return;if(!found)continue;io.update(setTabSpawned(setTabSessionId(io.stateRef.current,tab.id,found),tab.id,!0))}for(let tab of candidates){let sessionId=namingSessionId(tab);if(!sessionId)continue;let title=await deriveTitleFromSessionId(vendorOf(tab),sessionId);if(cancelled)return;if(!title)continue;let next=setTabSpawned(io.stateRef.current,tab.id,!0);if(!tab.title&&!tab.autoTitle)next=setTabAutoTitle(next,tab.id,title);io.update(next)}}finally{namingBusy=!1}})()},NAMING_POLL_MS);return()=>{cancelled=!0,clearInterval(timer3)}},[])}var import_react113=__toESM(require_react_production(),1);function engineExitOf(tab,status,hook,retriedSince,engineRunning=!1){if(tab.kind!=="engine"||status?.reason!=="dead"||engineRunning)return null;if(retriedSince===status.since)return null;let code=hook?.detail?.exit?.code;return{code:typeof code==="number"?code:null}}function useEngineExit(io){let status=useTabRowStatus(io.taskId,io.tab.id),[retried,setRetried]=import_react113.useState(null),[,redraw]=import_react113.useState(0);import_react113.useEffect(()=>getDefaultLiveEngines().subscribe(()=>redraw((n2)=>n2+1)),[]);let key=tabPtyKeyFor(io.taskId,io.tab),view=engineExitOf(io.tab,status,io.hook,retried?.tabId===io.tab.id?retried.since:void 0,!!getDefaultLiveEngines().resolve(key));if(!view)return;return{code:view.code,onRetry:()=>{if(getDefaultLiveEngines().resolve(key)){redraw((n2)=>n2+1);return}if(status)setRetried({tabId:io.tab.id,since:status.since});io.retry()},onSettings:io.onOpenSettings?()=>io.onOpenSettings?.("engines"):void 0,onAnotherEngine:()=>io.requestNewChat(),onContinueInEngine:()=>io.requestNewChat({context:"continue"})}}var import_react114=__toESM(require_react_production(),1);function useUsageLimit(io){let status=useTabRowStatus(io.taskId,io.tab.id),[dismissed,setDismissed]=import_react114.useState(null);if(io.tab.kind!=="engine"||io.suppressed||status?.reason!=="rate_limited")return;if(dismissed?.tabId===io.tab.id&&dismissed.since===status.since)return;return{onContinueInEngine:()=>io.requestNewChat({context:"continue"}),onDismiss:()=>setDismissed({tabId:io.tab.id,since:status.since})}}function useTabNotices(io){let engineExit=useEngineExit(io),usageLimit=useUsageLimit({...io,suppressed:engineExit!==void 0});return{engineExit,usageLimit}}var import_react115=__toESM(require_react_production(),1);function useTabRequests(io){let{stateRef,propsRef,updateRef,tabCloseRef,activeLeafSizeRef,openNewConversationRef,openNewShellRef,continueInEngineRef}=io;import_react115.useEffect(()=>{let consume=()=>{let taskId=propsRef.current.taskId,tabId=takeTabActivation(taskId);if(tabId){let s2=stateRef.current;if(s2.activeId!==tabId&&s2.tabs.some((tab)=>tab.id===tabId))updateRef.current(selectTab(s2,tabId))}let open=takeTabOpen(taskId);if(open){let size=activeLeafSizeRef.current();updateRef.current(openPluginPane(stateRef.current,open.argv,open.title,open.placement,open.direction,size,open.tabId))}let paneClose=takePaneClose(taskId);if(paneClose){let prev=stateRef.current,{next,closedLeaves,closedTabIds}=closePluginPanes(prev,paneClose.title,paneClose.tabId);if(next!==prev)updateRef.current(next);for(let{tabId:id,leafId}of closedLeaves){let tab=prev.tabs.find((x2)=>x2.id===id);if(tab)getDefaultPtyRegistry().release(splitLeafPtyKey(tabPtyKeyFor(taskId,tab),leafId))}for(let id of closedTabIds)tabCloseRef.current.closeById(id)}let newTab=takeNewTab(taskId);if(newTab==="chat")openNewConversationRef.current();else if(newTab==="shell")openNewShellRef.current();else if(newTab==="continue")continueInEngineRef.current();let adopt=takeTabAdopt(taskId);if(adopt){let prev=stateRef.current,next=adoptTabs(prev,adopt);if(next!==prev)updateRef.current(next)}let move=takeTabMove(taskId);if(move){let prev=stateRef.current,next=moveTab(prev,move.tabId,move.delta);if(next!==prev)updateRef.current(next)}let rename=takeTabRename(taskId);if(rename){let prev=stateRef.current,next=setTabTitle(prev,rename.tabId,rename.title);if(next!==prev)updateRef.current(next)}let added=takeTabAdd(taskId);if(added){let prev=stateRef.current,next=absorbTab(prev,added);if(next!==prev)updateRef.current(next)}let closeId=takeTabClose(taskId);if(closeId)tabCloseRef.current.closeById(closeId)};return consume(),tabActivationListeners.add(consume),()=>{tabActivationListeners.delete(consume)}},[])}var import_react117=__toESM(require_react_production(),1);function tabStripMenuItems(tab,tabCount){let items=[{action:"rename",labelKey:"terminal.tab.menu.rename",bindingId:"chat.tab.rename"}];if(tab.kind==="engine")items.push({action:"continueEngine",labelKey:"terminal.tab.menu.continueEngine",bindingId:"chat.tab.fork"});if(tab.kind!=="content")items.push({action:"copyAddress",labelKey:"terminal.tab.menu.copyAddress"});if(tabCount>1)items.push({action:"closeOthers",labelKey:"terminal.tab.menu.closeOthers",danger:!0});return items.push({action:"close",labelKey:"terminal.tab.menu.close",bindingId:"chat.tab.close"}),items}function useTabStripMenu(deps){let t3=useT(),kv=useKV(),notif=useNotifications(),dialog=useDialog(),renderer=useRenderer(),anchor=import_react117.useRef(null),[openMenu,setMenu]=import_react117.useState(null),menu=openMenu?.tabId===deps.activeId&&deps.tabs.some((tab)=>tab.id===openMenu.tabId)?openMenu:null;if(openMenu&&!menu)setMenu(null);let[cursor,setCursor]=import_react117.useState(0),close=()=>setMenu(null),openForTab=(tabId,x2,y3)=>{let tab=deps.tabs.find((candidate)=>candidate.id===tabId);if(!tab)return;deps.select(tabId);let box=anchor.current;setMenu({tabId,items:tabStripMenuItems(tab,deps.tabs.length),x:x2-(box?.x??0),y:y3-(box?.y??0)}),setCursor(0)};useGlobalMouseDown2(menu!==null,close);let closeOthers=async(tabId)=>{let count=deps.tabs.length-1;if(count<1)return;if(await DialogConfirm.show(dialog,t3("terminal.tab.closeOthersTitle"),t3("terminal.tab.closeOthersBody",{count:String(count)}),t3("terminal.tab.closeOthersCancel"),t3("terminal.tab.closeOthersConfirm"),{danger:!0})!==!0)return;if(closeOtherTaskTabs(kv,deps.taskId,tabId)===0)notif.notify({kind:"error",taskId:deps.taskId,tabId,title:t3("terminal.tab.tabGone")})},copyAddress=async(tabId)=>{let text=tabAddress(deps.taskId,tabId),copied=await copyTextToSystemClipboard(text,(payload)=>renderer?.copyToClipboardOSC52(payload));notif.notify({kind:copied?"done":"error",taskId:deps.taskId,tabId,title:copied?t3("tasks.toast.copiedTab",{text}):t3("tasks.toast.copyFailed")})},fire=(action)=>{if(!menu||action===void 0)return;let tabId=menu.tabId;if(setMenu(null),action==="rename")deps.rename();else if(action==="continueEngine")deps.continueEngine();else if(action==="close")deps.closeActive();else if(action==="closeOthers")closeOthers(tabId);else copyAddress(tabId)},move=(delta)=>{let count=menu?.items.length??0;if(count>0)setCursor((prev)=>(prev+delta+count)%count)};useBindings(()=>({enabled:menu!==null,bindings:[{key:"up",cmd:()=>move(-1)},{key:"k",cmd:()=>move(-1)},{key:"down",cmd:()=>move(1)},{key:"j",cmd:()=>move(1)},{key:"return",cmd:()=>fire(menu?.items[cursor]?.action)},{key:"escape",cmd:close}]}));let overlay=menu?$jsx(ContextMenu2,{entries:menu.items.map((item)=>{let cap=item.bindingId?legendCap(item.bindingId):void 0;return{id:item.action,label:t3(item.labelKey),danger:item.danger,cap:cap?formatChord(cap):void 0}}),cursor,x:menu.x,y:menu.y,dims:{width:anchor.current?.width??0,height:anchor.current?.height??0},onPick:(id)=>fire(menu.items.find((item)=>item.action===id)?.action)}):null;return{anchorRef:(box)=>{anchor.current=box},openForTab,overlay}}var import_react119=__toESM(require_react_production(),1);var INTERRUPT_CONFIRM_MS=2500;function disagrees(obs){if(!obs.hookRunning||!obs.vendor||obs.rawTitle===void 0)return!1;return engineTitleTurnHint(obs.vendor,obs.rawTitle)==="rest"}class InterruptObserver{opts;pending=new Map;constructor(opts){this.opts=opts}observe(tabId,obs){if(disagrees(obs)){if(this.pending.has(tabId))return;let timer3=setTimeout(()=>{if(this.pending.delete(tabId),this.opts.confirm(tabId))this.opts.report(tabId)},this.opts.confirmMs??INTERRUPT_CONFIRM_MS);timer3.unref?.(),this.pending.set(tabId,timer3);return}this.disarm(tabId)}disarm(tabId){let timer3=this.pending.get(tabId);if(timer3===void 0)return;clearTimeout(timer3),this.pending.delete(tabId)}dispose(){for(let timer3 of this.pending.values())clearTimeout(timer3);this.pending.clear()}}function createTabIdentityObserver(){let observed=new Map;return(tab,live,shell)=>{let previous=observed.get(tab.id);if(live)observed.set(tab.id,live);else observed.delete(tab.id);return demoteExitedEngine(tab,previous,live,shell)}}function demoteExitedEngine(tab,prev,live,shell){if(tab.kind!=="engine"||live!==null||!prev)return tab;if(tab.ptyTask)return tab;return{kind:"command",command:shell,id:tab.id,title:tab.title,ordinal:tab.ordinal,...tab.autoTitle!==void 0?{autoTitle:tab.autoTitle}:{},...tab.splitTree!==void 0?{splitTree:tab.splitTree}:{},lastTitle:null,liveVendor:null}}function soloKey(taskId,tab){let tabKey=tabPtyKey(taskId,tab.id);if(!tab.splitTree)return tabKey;let ls=leaves(tab.splitTree.root);return ls.length===1?splitLeafPtyKey(tabKey,ls[0].id):null}function targetFor(taskId,tab,taskVendor,vendorOf){let key=soloKey(taskId,tab),pinned=tab.kind==="engine"&&hasEngineLeaf(tab.splitTree)?tab.vendor??taskVendor:null;if(!key)return pinned?{vendor:pinned,key:tabPtyKey(taskId,tab.id)}:null;let live=vendorOf(key);if(live)return{vendor:live,key};if(live===void 0&&pinned)return{vendor:pinned,key};return null}var import_react118=__toESM(require_react_production(),1);import{createHash}from"crypto";var TURN_STATUS_POLL_MS=1500;function nextTurnStatusPollDelay(currentMs,sessionMtimeAdvanced,published){if(sessionMtimeAdvanced)return 1500;if(published==="running")return 1500;return Math.min(currentMs*2,6000)}function sameSession(a2,b3){return a2?.id===b3?.id&&a2?.transcriptPath===b3?.transcriptPath}function startTurnStatusPoll(opts,io){let disposed=!1,primed=!1,session=null,baseline=null,paneHash="",changed=!1,stable=0,published=null,lastMtime=0,delay=TURN_STATUS_POLL_MS,timer3;async function publish3(state){if(disposed||state===published)return;published=state,await io.setTurnState(state)}function screenState(text){if(!opts.screenManifest)return"unknown";switch(classifyScreen(opts.screenManifest,text)){case"working":return"running";case"blocked":return"needs_input";case"idle":return"idle";default:return published===null||published==="needs_input"?"unknown":null}}async function poll(){try{if(!await io.sessionAttached()||disposed)return;let current2=opts.session(),text=await io.capturePane();if(disposed||!sameSession(current2,opts.session()))return;if(opts.screenManifest)await io.setScreenBlocked?.(classifyScreen(opts.screenManifest,text)==="blocked");let markerMode=opts.detector.supportsCompletionMarkers()&¤t2!==null,scan=markerMode?await opts.detector.latestActivityInFile(current2.transcriptPath):null;if(disposed||!sameSession(current2,opts.session()))return;let hash=createHash("sha1").update(text).digest("hex");if(!primed||!sameSession(session,current2)){session=current2,baseline=scan?.marker?.id??null,paneHash=hash,changed=!1,stable=0,lastMtime=scan?.mtimeMs??0,primed=!0,published=null,await publish3(markerMode?scan?"idle":"unknown":screenState(text)??"unknown"),delay=TURN_STATUS_POLL_MS;return}if(hash!==paneHash){if(paneHash=hash,changed=!0,stable=0,markerMode)await publish3("running")}else if(changed)stable++;if(!markerMode){let state=screenState(text);if(state!==null)await publish3(state)}else if(scan&&changed&&stable>=2&&scan.marker&&scan.marker.id!==baseline)baseline=scan.marker.id,changed=!1,stable=0,await publish3("done");let mtime=scan?.mtimeMs??0;delay=nextTurnStatusPollDelay(delay,mtime>lastMtime,published),lastMtime=mtime}catch{delay=TURN_STATUS_POLL_MS}finally{if(!disposed)timer3=setTimeout(()=>void poll(),delay)}}return poll(),()=>{if(disposed=!0,opts.screenManifest)io.setScreenBlocked?.(!1).catch(()=>{});if(timer3)clearTimeout(timer3)}}var TURN_POLL_ATTACH_MS=2000;function useTurnPolls(deps){let[liveTitles,setLiveTitles]=import_react118.useState(new Map),[rawTitles,setRawTitles]=import_react118.useState(new Map),[turnVendors,setTurnVendors]=import_react118.useState(new Map),turnPollsRef=import_react118.useRef(new Map),titleStoreRef=import_react118.useRef(null);if(titleStoreRef.current===null)titleStoreRef.current=createTitleSubscriptions();let hookTabStatesRef=useLatest(deps.hookTabStates),screenInputRef=useLatest(deps.onScreenInput),stateRef=useLatest(deps.state),taskIdRef=useLatest(deps.taskId),vendorRef=useLatest(deps.vendor),reconcile=import_react118.useCallback(()=>{let reg=getDefaultPtyRegistry(),attached=new Set,turnPolls=turnPollsRef.current,titleStore=titleStoreRef.current,liveEngines=getDefaultLiveEngines();if(!titleStore)return;let taskId=taskIdRef.current,state=stateRef.current,soloKeys=new Map;for(let tab of state.tabs){let key=soloKey(taskId,tab);if(key)soloKeys.set(key,tab.id)}titleStore.reconcile(soloKeys.keys()),setRawTitles((prev)=>{let next=new Map;for(let[key,tabId]of soloKeys){let title=titleStore.get(key);if(title!==void 0)next.set(tabId,title)}if(next.size===prev.size&&[...next].every(([id,v3])=>prev.get(id)===v3))return prev;return next}),setLiveTitles((prev)=>{let next=new Map;for(let[key,tabId]of soloKeys){let title=titleStore.get(key);if(title===void 0)continue;next.set(tabId,stripEngineStatusPrefix(title,liveEngines.resolve(key)))}if(next.size===prev.size&&[...next].every(([id,v3])=>prev.get(id)===v3))return prev;return next});for(let tab of state.tabs){let target=targetFor(taskId,tab,vendorRef.current,(key)=>liveEngines.resolve(key));if(!target)continue;let existing=turnPolls.get(tab.id);if(existing&&existing.vendor===target.vendor&&existing.key===target.key){attached.add(tab.id);continue}if(existing)existing.dispose(),turnPolls.delete(tab.id);if(!reg.has(target.key))continue;let tabId=tab.id,entry2=engineEntry(target.vendor);if(!entry2.screenManifest){turnPolls.set(tabId,{dispose:()=>{},vendor:target.vendor,key:target.key}),attached.add(tabId);continue}let screenManifest=entry2.screenManifest,detector=entry2.createTurnDetector(),dispose=startTurnStatusPoll({detector,screenManifest,session:()=>{let state2=hookTabStatesRef.current?.get(tabId);return state2?.sessionId&&state2.transcriptPath?{id:state2.sessionId,transcriptPath:state2.transcriptPath}:null}},{setScreenBlocked:(blocked)=>screenInputRef.current?.(tabId,blocked)??Promise.resolve(),sessionAttached:async()=>!0,capturePane:async()=>{let pty=getDefaultPtyRegistry().get(target.key);if(!pty)throw Error("pty gone");return pty.capture().map((row)=>row.map((chunk)=>chunk.text).join("")).join(`
|
|
95
95
|
`)},setTurnState:async()=>{}});turnPolls.set(tabId,{dispose,vendor:target.vendor,key:target.key}),attached.add(tabId)}for(let[id,poll]of turnPolls){if(attached.has(id))continue;poll.dispose(),turnPolls.delete(id)}setTurnVendors((prev)=>{let next=new Map;for(let[id,poll]of turnPolls)next.set(id,poll.vendor);if(next.size===prev.size&&[...next].every(([id,v3])=>prev.get(id)===v3))return prev;return next})},[]);return import_react118.useEffect(()=>{let active=!0,scheduled=!1,unsub=titleStoreRef.current?.subscribe(()=>{if(scheduled)return;scheduled=!0,queueMicrotask(()=>{if(scheduled=!1,active)reconcile()})});return()=>{active=!1,unsub?.()}},[reconcile]),import_react118.useEffect(()=>{return getDefaultLiveEngines().subscribe(reconcile)},[reconcile]),import_react118.useEffect(()=>{let timer3=setInterval(reconcile,TURN_POLL_ATTACH_MS);return()=>clearInterval(timer3)},[reconcile]),import_react118.useEffect(()=>{deps.taskId,deps.worktree,deps.vendor,deps.state,reconcile()},[deps.taskId,deps.worktree,deps.vendor,deps.state,reconcile]),import_react118.useEffect(()=>{return()=>{for(let poll of turnPollsRef.current.values())poll.dispose();titleStoreRef.current?.dispose()}},[]),{liveTitles,rawTitles,turnVendors}}function useTabTurnState(deps){let{liveTitles,rawTitles,turnVendors}=useTurnPolls(deps),tabStatuses=useRowStatusMap()[deps.taskId]?.tabs,turnStates=import_react119.useMemo(()=>notifyTurns(tabStatuses),[tabStatuses]),hookStatesRef=useLatest(deps.hookTabStates),onInterruptRef=useLatest(deps.onEngineInterrupt),observerRef=import_react119.useRef(null);if(observerRef.current===null)observerRef.current=new InterruptObserver({confirm:(tabId)=>hookStatesRef.current?.get(tabId)?.state==="running",report:(tabId)=>onInterruptRef.current?.(tabId)});import_react119.useEffect(()=>{let observer=observerRef.current;if(!observer)return;let running=new Set;for(let[tabId,entry2]of deps.hookTabStates??[])if(entry2.state==="running")running.add(tabId);let tabIds=new Set([...running,...rawTitles.keys()]);for(let tabId of tabIds)observer.observe(tabId,{rawTitle:rawTitles.get(tabId),vendor:turnVendors.get(tabId),hookRunning:running.has(tabId)})},[deps.hookTabStates,rawTitles,turnVendors]),import_react119.useEffect(()=>()=>observerRef.current?.dispose(),[]);let updateRef=useLatest(deps.update),titleStateRef=useLatest(deps.state),identityObserver=import_react119.useRef(null);if(!identityObserver.current)identityObserver.current=createTabIdentityObserver();import_react119.useEffect(()=>{let apply=updateRef.current;if(!apply)return;let engines=getDefaultLiveEngines(),record=()=>{let current2=titleStateRef.current,next=current2;for(let[tabId,title]of liveTitles){let tab=next.tabs.find((t3)=>t3.id===tabId);if(!tab)continue;let key=soloKey(deps.taskId,tab),live=key?engines.resolve(key):void 0,demoted=identityObserver.current?.(tab,live,[defaultShell()]);if(demoted&&demoted!==tab){next={...next,tabs:next.tabs.map((t3)=>t3.id===tabId?demoted:t3)};continue}if(next=setTabLastTitle(next,tabId,title),live!==void 0)next=setTabLiveVendor(next,tabId,live)}if(next!==current2)apply(next)};return record(),engines.subscribe(record)},[liveTitles,deps.taskId]);let prevRef=import_react119.useRef(null),stateRef=useLatest(deps.state),notifRef=useLatest(deps.notif),vendorRef=useLatest(deps.vendor),taskIdRef=useLatest(deps.taskId),taskTitleRef=useLatest(deps.taskTitle),dispatchedRef=useLatest(deps.taskDispatched);return import_react119.useEffect(()=>{if(turnStates===null)return;let next=turnStates,edges=attentionEdges(prevRef.current,next,stateRef.current.activeId,chipAttentionKind);prevRef.current=next;for(let{key:tabId,kind}of edges){let tab=stateRef.current.tabs.find((tb)=>tb.id===tabId);if(!tab)continue;notifRef.current.notify({kind,taskId:taskIdRef.current,tabId,title:tabTitle(tab,vendorRef.current),body:taskTitleRef.current,silent:dispatchedRef.current,turnEnd:!0})}},[turnStates]),{liveTitles,turnVendors}}function notifyTurns(tabs){if(tabs===void 0)return null;let out=new Map;for(let[tabId,status]of Object.entries(tabs))switch(status.kind){case"unseen":out.set(tabId,"done");break;case"needs-input":out.set(tabId,"needs_input");break;case"attention":out.set(tabId,status.reason??"error");break;default:out.set(tabId,status.kind)}return out}function TerminalTabs(props){let{theme}=useTheme(),dialog=useDialog(),notif=useNotifications(),kv=useKV(),t3=useT(),persistKey=terminalTabsKey(props.taskId),propsRef=useLatest(props),pinSession=(s2,vendor)=>{let base=vendor?engineLaunchArgv({vendor,effort:props.modelEffort}):props.command,{sessionId}=withPinnedSessionId(base,vendor??props.vendor);return setTabSessionId(s2,s2.activeId,sessionId)},rehydratedRef=import_react120.useRef(!1),initState=()=>{let saved=tabsByTask.get(props.taskId)??taskTabsView(props.taskId)??(tabsLoaded()?null:kv.get(persistKey,null)),fromDaemon=saved&&Array.isArray(saved.tabs)?rehydrateTabs(saved,[defaultShell()]):null;if(rehydratedRef.current=fromDaemon!==null,fromDaemon)return fromDaemon;return props.scratch===!0&&!engineScratchTasks.delete(props.taskId)?initialShellTabs(defaultShell()):pinSession(initialTabs(),void 0)},[state,setState]=import_react120.useState(initState),stateRef=useLatest(state),update=(next)=>{reportTabsDelta(propsRef.current.taskId,stateRef.current.tabs,next.tabs);let shown=setTaskTabs2(propsRef.current.taskId,next,stateRef.current);stateRef.current=shown,setState(shown)};import_react120.useEffect(()=>{let taskId=props.taskId;if(!tabsByTask.has(taskId)){let shown=setTaskTabs2(taskId,stateRef.current);stateRef.current=shown,setState(shown)}ensureTabReservation(taskId);let off=tabsRevision.subscribe(()=>{let live=tabsByTask.get(taskId);if(!live||live===stateRef.current)return;stateRef.current=live,setState(live)});return()=>{off(),releaseTabReservation(taskId)}},[props.taskId]);let updateRef=useLatest(update),activeLeafSize=()=>activeLeafCells(stateRef.current,propsRef.current.taskId),activeLeafSizeRef=useLatest(activeLeafSize),engineTabSpawn=(tab)=>{let base=tab.engineCommand||tab.vendor?engineLaunchArgv({command:tab.engineCommand,vendor:tab.vendor,effort:props.modelEffort}):props.command,live=getDefaultPtyRegistry().has(tabPtyKeyFor(props.taskId,tab));return engineTabSpawnFor(stateRef.current,tab,base,{live,shell:defaultShell(),prompt:propsRef.current.initialPrompt,task:{id:props.taskId,kind:props.taskKind,vendor:tab.vendor??props.vendor,repo:props.repo,repos:props.repos},worktreePath:props.worktree,inlineImages:terminalDrawsKitty()})},engineTabSpawnRef=useLatest(engineTabSpawn),[resetToken,setResetToken]=import_react120.useState(0),hydrating=useTabHydration(rehydratedRef.current,{stateRef,propsRef,update}),{sendToEngine}=useTabHandoffs({stateRef,propsRef,update,engineTabSpawnRef,bumpResetToken:()=>setResetToken((n2)=>n2+1)});import_react120.useEffect(()=>{warmHostedShell(props.worktree)},[props.worktree]);let active=state.tabs.find((tab)=>tab.id===state.activeId)??state.tabs[0];useTabNaming({stateRef,propsRef,update});let{liveTitles,turnVendors}=useTabTurnState({taskId:props.taskId,worktree:props.worktree,vendor:props.vendor,state,hookTabStates:props.hookTabStates,taskTitle:props.taskTitle,taskDispatched:props.taskDispatched,notif,update,onEngineInterrupt:props.onEngineInterrupt,onScreenInput:props.onScreenInput});import_react120.useEffect(()=>{notif.markRead(props.taskId,state.activeId),propsRef.current.onTabVisited?.(state.activeId)},[state.activeId]);let activeSpawn=()=>active.kind==="command"?{command:active.command,...active.purpose!=="editor"&&active.command.length===1&&active.command[0]===defaultShell()?{initialInput:shellIdentityInput(props.taskId,active.id,props.repos&&repoEnv(props.repos))}:{}}:active.kind==="content"?{command:[]}:engineTabSpawn(active),resumeTriedRef=import_react120.useRef(new Set),tabClose=useTabClose({stateRef,propsRef,updateRef,active,pinSession,bumpResetToken:()=>setResetToken((n2)=>n2+1),resumeTriedRef,notifyCannotCloseLast:(tabId)=>notif.notify({kind:"error",taskId:props.taskId,tabId,title:t3("terminal.tab.cannotCloseLast")}),onScratchExit:props.scratch===!0?props.onScratchExit:void 0}),tabCloseRef=useLatest(tabClose),engineDeadRef=import_react120.useRef(!1),{requestRename,requestNewChat,newConversation,newShell}=useTabDialogs({dialog,t:t3,state,active,vendor:props.vendor,taskId:props.taskId,taskTitle:props.taskTitle,worktree:props.worktree,liveTitles,update,pinSession,activeLeafSize,onChooseEngine:props.onChooseEngine,onSpawnChild:remoteOf(props.taskId)?void 0:props.onSpawnChild,onQuickFork:props.onQuickFork,onOpenScratch:props.onOpenScratch,notifyError:(title)=>notif.notify({kind:"error",taskId:props.taskId,tabId:active.id,title}),sourceDead:()=>engineDeadRef.current,restartActive:tabClose.retryActive}),{engineExit,usageLimit}=useTabNotices({taskId:props.taskId,tab:active,hook:props.hookTabStates?.get(active.id),retry:tabClose.retryActive,requestNewChat,onOpenSettings:props.onOpenSettings});engineDeadRef.current=engineExit!==void 0;let openNewConversation=()=>{let vendor=props.vendor;try{vendor=resolvePreferredVendor(resolveMainRepoRoot(props.worktree))}catch{}return newConversation(vendor)},openNewConversationRef=useLatest(openNewConversation),openNewShellRef=useLatest(newShell),continueInEngineRef=useLatest(()=>requestNewChat({context:"continue"}));useTabRequests({stateRef,propsRef,updateRef,tabCloseRef,activeLeafSizeRef,openNewConversationRef,openNewShellRef,continueInEngineRef}),useBindings(()=>({enabled:props.focused,bindings:bindByIds({"chat.tab.new":prefixAction(()=>{if(!openNewConversation())return;showSharedFilesHint(kv,(title,body)=>notif.notify({kind:"done",silent:!0,taskId:props.taskId,tabId:active.id,title,body}),t3)}),"chat.tab.chooseEngine":prefixAction(()=>requestNewChat()),"chat.tab.fork":prefixAction(()=>requestNewChat({context:"continue"})),"chat.tab.cycle-next":prefixAction(()=>update(cycleTab(state,1))),"chat.tab.cycle-prev":prefixAction(()=>update(cycleTab(state,-1))),"chat.tab.goto":(_evt,slot)=>update(gotoTab(state,slot??0)),"chat.fork.new":prefixAction(()=>requestNewChat({destination:"fork"}))})}));let activeIsSplit=isTabSplit(active.splitTree),spawn3=activeSpawn();useBindings(()=>({enabled:props.focused&&!activeIsSplit,bindings:bindByIds({"chat.tab.close":prefixAction(()=>tabClose.closeActive()),"chat.tab.rename":prefixAction(requestRename)})}));let tabMenu=useTabStripMenu({taskId:props.taskId,tabs:state.tabs,activeId:state.activeId,select:(tabId)=>update(selectTab(stateRef.current,tabId)),rename:requestRename,continueEngine:()=>requestNewChat({context:"continue"}),closeActive:()=>tabClose.closeActive()});return $jsxs("box",{ref:tabMenu.anchorRef,flexDirection:"column",flexGrow:1,children:[$jsx(TabStrip,{taskId:props.taskId,tabs:state.tabs,activeId:state.activeId,onSelect:(tabId)=>update(selectTab(state,tabId)),onContextMenu:tabMenu.openForTab,vendor:props.vendor,liveTitles,turnVendors}),active.kind==="engine"?$jsx(EngineHookReadiness,{vendor:active.vendor??props.vendor,hookSessionId:props.hookTabStates?.get(active.id)?.sessionId},active.id):null,hydrating?$jsx("box",{flexGrow:1,paddingLeft:1,paddingTop:1,children:$jsx("text",{fg:theme.textMuted,children:t3("terminal.restoring")})}):active.kind==="content"?$jsx(PreviewScreen,{worktree:props.worktree,relPath:active.relPath,base:active.base,remote:remoteOf(props.taskId),focused:props.focused,onClose:()=>tabClose.closeExited(active.id),review:buildDiffReview(kv,props.taskId,sendToEngine)}):$jsx(TerminalSplit,{tabKey:tabPtyKeyFor(props.taskId,active),cwd:tabCwdFor(active,props.worktree),command:spawn3.command,initialInput:spawn3.initialInput,firstMessage:spawn3.firstMessage,engineBin:spawn3.engineBin,terminalPresentation:active.kind==="engine"?getCapabilities(active.vendor??props.vendor)?.terminalPresentation:void 0,onUserInput:active.kind==="engine"?(data)=>noteAnswerInput(data,props.taskId,active.id):void 0,splitTree:active.splitTree??null,engineExit,usageLimit,onSplitChange:(next)=>update(setTabSplit(state,active.id,next)),onExit:tabClose.handleActiveExit,resetToken,focused:props.focused,onRequestFocus:props.onRequestFocus,engineTitle:active.title??active.autoTitle??null}),tabMenu.overlay]})}function remoteOf(taskId){let machine=machineOfTask(taskId);return machine?{machine,taskId}:void 0}var import_react121=__toESM(require_react_production(),1);function EmptyWorkspacePane(props){let{theme}=useTheme(),t3=useT(),kv=useOptionalKV(),dialog=useDialog(),vendor=props.vendor??DEFAULT_TASK_VENDOR,reopen=()=>{reviveEmptiedTabs(kv,props.taskId,defaultShell(),knownTabsState(kv,props.taskId)?void 0:{vendor,engineCommand:props.command??vendor})},chooseEngine=()=>{(async()=>{let choice=await NewChatDialog.show(dialog,await availableEngineIds(),vendor,{freshTabOnly:!0});if(!choice)return;reviveEmptiedTabs(kv,props.taskId,defaultShell(),{vendor:choice.pick,engineCommand:choice.pick})})()},startRequestedTab=useLatest((kind)=>{if(kind!=="shell")chooseEngine();else if(props.onSpawnChild)props.onSpawnChild({parentTaskId:props.taskId,vendor,title:SHELL_TASK_TITLE,tabs:initialShellTabs(defaultShell())});else{let empty=knownTabsState(kv,props.taskId)??{tabs:[],activeId:"",nextOrdinal:1};setTaskTabs2(props.taskId,openCommandTab(empty,[defaultShell()],null))}});import_react121.useEffect(()=>{let consume=()=>{let kind=takeNewTab(props.taskId);if(kind)startRequestedTab.current(kind)};return consume(),tabActivationListeners.add(consume),()=>{tabActivationListeners.delete(consume)}},[props.taskId]),useBindings(()=>({enabled:props.focused,bindings:bindByIds({"workspace.reopenSession":reopen,"chat.tab.chooseEngine":chooseEngine})}));let reopensShell=knownTabsState(kv,props.taskId)?.reopenAs?.kind==="command";return $jsx("box",{flexGrow:1,alignItems:"center",justifyContent:"center",children:$jsx("text",{fg:theme.info,onMouseUp:(event)=>{if(event.button===0)reopen()},children:reopensShell?t3("workspace.empty.noSessionsShell"):t3("workspace.empty.noSessions",{engine:engineDisplayName(vendor)})})})}var import_react122=__toESM(require_react_production(),1);var POLL_MS4=2000;async function verbOn(machine,verb,params){let envelope=await forwardVerb(requireMachine(machine),verb,params);if(!envelope.ok)throw Error(envelope.error.message);return envelope.result}function sessionKey(taskId,tab){return tab.viewOf?`${tab.viewOf}::tab-1`:`${taskId}::${tab.id}`}function tabLabel(tab){return tab.title??tab.autoTitle??tab.lastTitle??tab.liveVendor??tab.vendor??tab.id}function RemoteTerminalTabs(props){let{theme}=useTheme(),t3=useT(),[tabs,setTabs]=import_react122.useState(null),[activeId,setActiveId]=import_react122.useState(null),[error,setError]=import_react122.useState(null),[tick3,setTick]=import_react122.useState(0);import_react122.useEffect(()=>{let live=!0,load=()=>verbOn(props.machine,"get-task",{"task-id":props.taskId}).then((res)=>{if(!live)return;let rows=(res.tabs??[]).filter((tab)=>tab.kind!=="content");setTabs(rows),setError(null),setActiveId((cur)=>cur&&rows.some((tab)=>tab.id===cur)?cur:rows[0]?.id??null)},(err)=>live&&setError(err instanceof Error?err.message:String(err)));load();let timer3=setInterval(load,POLL_MS4);return()=>{live=!1,clearInterval(timer3)}},[props.machine,props.taskId,tick3]);let refresh=()=>setTick((n2)=>n2+1),list=tabs??[],index=Math.max(0,list.findIndex((tab)=>tab.id===activeId)),active=list[index]??null,step=(dir)=>{if(list.length===0)return;setActiveId(list[(index+dir+list.length)%list.length]?.id??null)},run=(verb,params)=>void verbOn(props.machine,verb,{"task-id":props.taskId,...params}).then((res)=>{if(res?.tabId)setActiveId(res.tabId);refresh()}).catch((err)=>setError(err instanceof Error?err.message:String(err)));return useBindings(()=>({enabled:props.focused,bindings:bindByIds({"chat.tab.new":prefixAction(()=>run("tab-new",{kind:"engine"})),"chat.tab.cycle-next":prefixAction(()=>step(1)),"chat.tab.cycle-prev":prefixAction(()=>step(-1)),"chat.tab.goto":(_evt,slot)=>setActiveId(list[slot??0]?.id??activeId),"chat.tab.close":prefixAction(()=>active&&run("tab-close",{tab:active.id}))})})),$jsxs("box",{flexDirection:"column",flexGrow:1,children:[$jsxs("box",{flexDirection:"row",gap:2,paddingLeft:1,flexShrink:0,children:[$jsx("text",{fg:theme.textMuted,children:t3("tasks.machine.runsOn",{host:props.host})}),list.map((tab,i2)=>$jsx("text",{fg:tab.id===active?.id?theme.focusAccent:theme.textMuted,children:`${i2+1} ${tabLabel(tab)}${tab.alive===!1?" \u2715":""}`},tab.id))]}),error?$jsx("text",{fg:theme.textMuted,paddingLeft:1,children:error}):null,tabs===null?$jsx("text",{fg:theme.textMuted,paddingLeft:1,children:t3("terminal.restoring")}):active?$jsx(Terminal,{taskId:sessionKey(props.taskId,active),machine:props.machine,cwd:props.worktree,command:[],focused:props.focused},sessionKey(props.taskId,active)):$jsx("text",{fg:theme.textMuted,paddingLeft:1,children:t3("tasks.machine.noTabs",{host:props.host})})]})}function ShowWorkspace(props){let{theme}=useTheme(),t3=useT(),kv=useOptionalKV();useAccessor(tabsRevision);let engineTabStates=useAccessor(props.orchestrator.engineTabStatesSignal()),tasks2=useAccessor(props.orchestrator.tasksSignal()),viewingTaskId=props.worktree&&props.task&&(props.task.origin?.machineId??"local")==="local"&&props.task?String(props.task.id):null;if(useViewingReport(viewingTaskId,viewingTaskId?knownTaskTabs(kv,viewingTaskId)?.activeId??null:null),!props.worktree){if(!tasks2.some((task)=>!task.deletion))return $jsx(WelcomePane,{onQuickTask:props.onQuickFork});return $jsx("box",{flexGrow:1,alignItems:"center",justifyContent:"center",children:$jsx("text",{fg:theme.textMuted,children:t3("workspace.empty.selectTask")})})}let path=props.task?taskCwd({worktreePath:props.worktree,cwdSubpath:props.task.cwdSubpath}):props.worktree,remoteKey=remoteKeyForRepo(props.task?.repo)??remoteKeyForRepo(path);if(remoteKey)return $jsx("box",{flexGrow:1,alignItems:"center",justifyContent:"center",children:$jsx("text",{fg:theme.textMuted,children:t3("workspace.empty.remoteUnsupported",{host:remoteKey})})});let origin=props.task?.origin&&props.task.origin.machineId!=="local"?props.task.origin:null;if(origin&&props.task){if(origin.stale)return $jsx("box",{flexGrow:1,alignItems:"center",justifyContent:"center",children:$jsx("text",{fg:theme.textMuted,children:t3("tasks.machine.terminalElsewhere",{host:origin.hostLabel})})});return $jsx(RemoteTerminalTabs,{taskId:String(props.task.id),machine:origin.machineId,host:origin.hostLabel,worktree:path??"",focused:props.focused})}let known=props.task?knownTaskTabs(kv,String(props.task.id)):null;if(props.task&&(known?known.tabs.length===0:!props.task.scratch&&(props.task.kind==="main"||props.task.kind==="dir")))return $jsx(EmptyWorkspacePane,{taskId:String(props.task.id),focused:props.focused,vendor:props.task.vendor,command:props.task.command,onSpawnChild:props.onSpawnChild});let taskReposView=props.task?taskRepos(props.task,tasks2):void 0,taskReposIfMulti=taskReposView&&taskReposView.length>1?taskReposView:void 0;return $jsx(TerminalTabs,{repos:taskReposIfMulti,taskId:props.task?.id??path,worktree:path,repo:props.task?.repo,taskKind:props.task?.kind,scratch:props.task?.scratch===!0,onScratchExit:()=>{let taskId=props.task?.id;if(taskId)props.onScratchExit?.(taskId)},onOpenScratch:props.onOpenScratch,command:engineLaunchArgv({command:props.task?.command,vendor:props.task?.vendor,effort:props.task?.modelEffort,model:props.task?.model}),vendor:props.task?.vendor??DEFAULT_TASK_VENDOR,modelEffort:props.task?.modelEffort,onChooseEngine:props.task?(vendor)=>{let taskId=props.task?.id;if(!taskId)return;props.onEngineChosen?.(taskId,vendor)}:void 0,focused:props.focused,onRequestFocus:props.onRequestFocus,onEditorTabReady:props.onEditorTabReady,onEngineSendReady:props.onEngineSendReady,onEnginePasteReady:props.onEnginePasteReady,onDiffTabReady:props.onDiffTabReady,onSpawnChild:props.onSpawnChild,onOpenSettings:props.onOpenSettings,onQuickFork:props.onQuickFork,initialPrompt:props.initialPrompt,hookTabStates:props.task?engineTabStates.get(props.task.id):void 0,taskTitle:props.task?.title,taskDispatched:props.task?.dispatcher!==void 0,onTabVisited:(tabId)=>{let taskId=props.task?.id;if(taskId)props.onTabVisited?.(taskId,tabId)},onScreenInput:async(tabId,blocked)=>{if(props.task)await props.orchestrator.reportScreenInput(props.task.id,tabId,blocked)},onEngineInterrupt:(tabId)=>{let taskId=props.task?.id;if(taskId)props.orchestrator.reportEngineInterrupt(taskId,tabId)}},props.task?.id??path)}var import_react123=__toESM(require_react_production(),1),DOUBLE_CLICK_MS=400;function useSidebarResizeGesture(opts){let armed=import_react123.useRef(null),lastRelease=import_react123.useRef(0);return{onGripDown:(event)=>{armed.current={x:event.x,width:opts.width,moved:!1}},onPaneDrag:(event)=>{let from=armed.current;if(from==null)return;let delta=event.x-from.x;if(delta===0)return;from.moved=!0,opts.onResize(from.width+delta)},onPaneRelease:()=>{let from=armed.current;if(from==null)return;if(armed.current=null,from.moved){lastRelease.current=0;return}let now=Date.now();if(now-lastRelease.current<DOUBLE_CLICK_MS){lastRelease.current=0,opts.onReset();return}lastRelease.current=now}}}function SidebarResizeGrip(props){return $jsx("box",{position:"absolute",top:0,bottom:0,left:props.width-1,width:1,onMouseDown:props.onGripDown})}var import_react124=__toESM(require_react_production(),1);function isVisit(value){if(typeof value!=="object"||value===null)return!1;let candidate=value;return typeof candidate.taskId==="string"&&(candidate.tabId===null||typeof candidate.tabId==="string")&&typeof candidate.at==="number"}function parseInboxVisits(stored){if(!Array.isArray(stored))return[];return stored.filter(isVisit).slice(0,60)}function inboxVisitKey(visit){return`${visit.taskId}\x00${visit.tabId??""}`}function recordInboxVisit(visits,visit,limit=60){let key=inboxVisitKey(visit),rest=visits.filter((entry2)=>inboxVisitKey(entry2)!==key);return[visit,...rest].slice(0,limit)}function inboxVisitIndex(visits){let byTarget=new Map;for(let visit of visits){let key=inboxVisitKey(visit);if(!byTarget.has(key))byTarget.set(key,visit)}return byTarget}function readInboxVisits(kv){return parseInboxVisits(kv.get("inboxVisits"))}function writeInboxVisit(kv,visit){let visits=readInboxVisits(kv),[previous]=visits;if(previous?.taskId===visit.taskId&&previous.tabId===visit.tabId)return;kv.setQuiet("inboxVisits",recordInboxVisit(visits,visit))}var attentionInboxKey=attentionInboxItemKey;function attentionInboxCounts(items){return{total:items.length}}function visitResolvedEpisodes(items,visit){return items.filter((item)=>item.state!=="decision_needed"&&item.state!=="report_missing"&&item.taskId===visit.taskId&&(item.tabId===null||item.tabId===visit.tabId))}function isAttentionInboxItemAvailable(item,task,hasTab){if(isRoutineInboxState(item.state))return!0;if(item.state==="decision_needed")return!0;if(item.state==="report_missing")return item.taskId!==null&&task!==void 0&&!task.deletion;if(item.taskId===null||task===void 0||task.deletion)return!1;if(item.tabId===null)return!0;return hasTab(item.tabId)!==!1}function partitionAttentionInboxAvailability(items,tasks2,hasTab){let tasksById=new Map(tasks2.map((task)=>[task.id,task])),availableItems=[],unavailableItems=[];for(let item of items){let taskId=item.taskId;if(isAttentionInboxItemAvailable(item,taskId===null?void 0:tasksById.get(taskId),(tabId)=>taskId===null?void 0:hasTab(taskId,tabId)))availableItems.push(item);else unavailableItems.push(item)}return{availableItems,unavailableItems}}function inboxBand(item){return item.state==="turn_complete"?1:0}function sortAttentionInbox(items,taskOrder){let taskIndex=new Map(taskOrder.map((id,index)=>[id,index]));return[...items].sort((a2,b3)=>{let band=inboxBand(a2)-inboxBand(b3);if(band!==0)return band;let age=a2.at-b3.at;if(age!==0)return age;let task=(taskIndex.get(a2.taskId??"")??Number.MAX_SAFE_INTEGER)-(taskIndex.get(b3.taskId??"")??Number.MAX_SAFE_INTEGER);if(task!==0)return task;return attentionInboxItemKey(a2).localeCompare(attentionInboxItemKey(b3))})}var INBOX_RECENT_LIMIT=5;function inboxRows(items,tasks2,options={}){let attention=sortAttentionInbox(items,tasks2.map((task)=>task.id)),tasksById=new Map(tasks2.map((task)=>[String(task.id),task])),pendingTasks=new Set(items.map((item)=>item.taskId)),coveredTab=(taskId,tabId)=>items.some((item)=>item.taskId===taskId&&(item.tabId===null||item.tabId===tabId)),visited=[...inboxVisitIndex(options.visits??[]).values()],isSelected=(taskId,tabId)=>taskId===options.selectedId&&(options.selectedTabId==null||tabId===options.selectedTabId),tabAlive=(visit)=>visit.tabId===null||options.tabExists?.(visit.taskId,visit.tabId)!==!1,visitedRows=visited.map((visit)=>({visit,task:tasksById.get(visit.taskId)})).filter((entry2)=>entry2.task!==void 0&&!entry2.task.deletion&&tabAlive(entry2.visit)&&!coveredTab(entry2.visit.taskId,entry2.visit.tabId)&&!isSelected(entry2.visit.taskId,entry2.visit.tabId)).map(({visit,task})=>({kind:"recent",id:visit.tabId?`r:${visit.taskId}:${visit.tabId}`:`r:${visit.taskId}`,task,tabId:visit.tabId,at:visit.at})),seenTasks=new Set(visitedRows.map((row)=>row.task.id)),unvisitedRows=tasks2.filter((task)=>!task.deletion&&!seenTasks.has(task.id)&&!pendingTasks.has(task.id)&&task.id!==options.selectedId).sort(compareRecent).map((task)=>({kind:"recent",id:`r:${task.id}`,task,tabId:null,at:taskMtime(task)})),recent=[...visitedRows,...unvisitedRows].slice(0,options.recentLimit??INBOX_RECENT_LIMIT),rows=[];if(attention.length>0){rows.push({kind:"header",id:"header:attention",section:"attention"});for(let item of attention)rows.push({kind:"attention",id:`a:${attentionInboxItemKey(item)}`,item})}if(recent.length>0)rows.push({kind:"header",id:"header:recent",section:"recent"}),rows.push(...recent);return rows}function taskMtime(task){let parsed=Date.parse(task.updatedAt||task.createdAt);return Number.isFinite(parsed)?parsed:0}function nextSelectableRow(rows,from,delta){let total=rows.length,index=from;for(let step=0;step<total;step++)if(index=(index+delta+total)%total,rows[index]?.kind!=="header")return index;return from}function clampSelectableRow(rows,cursor){if(rows.length===0)return 0;let bounded=Math.min(Math.max(cursor,0),rows.length-1);return rows[bounded]?.kind==="header"?nextSelectableRow(rows,bounded,1):bounded}function windowInboxRows(rows,cursor,budget){let cardIndexes=rows.reduce((acc,row,index)=>{if(row.kind!=="header")acc.push(index);return acc},[]);if(cardIndexes.length<=budget)return{visible:[...rows],hiddenAbove:0,hiddenBelow:0};let cursorCard=Math.max(0,cardIndexes.indexOf(clampSelectableRow(rows,cursor))),firstCard=Math.max(0,Math.min(cursorCard-budget+1,cardIndexes.length-budget)),lastCard=firstCard+budget-1,start=firstCard===0?0:cardIndexes[firstCard]??0,startWithHeader=start>0&&rows[start-1]?.kind==="header"?start-1:start,end=(cardIndexes[lastCard]??rows.length-1)+1;return{visible:rows.slice(startWithHeader,end),hiddenAbove:firstCard,hiddenBelow:cardIndexes.length-lastCard-1}}function nextAttentionInboxTarget(items,taskOrder,current2,isAvailable=()=>!0){let liveTasks=new Set(taskOrder),ordered=sortAttentionInbox(items,taskOrder).filter((item)=>(isRoutineInboxState(item.state)||item.taskId===null||liveTasks.has(item.taskId))&&isAvailable(item));if(ordered.length===0)return null;let currentKey=current2.taskId===null?null:attentionInboxItemKey(current2),currentIndex=currentKey===null?-1:ordered.findIndex((item)=>attentionInboxItemKey(item)===currentKey);if(currentIndex<0)return ordered[0]??null;if(ordered.length===1)return ordered[0]??null;return ordered[(currentIndex+1)%ordered.length]??null}var CROSS_TASK_KEY="notifications.crossTask.enabled";function notifyTargetKey(taskId,tabId){return`${taskId}:${tabId}`}function notifyTargetStates(engineState,engineTabState){let states=new Map,targets=new Map;for(let[taskId,es]of engineState){let tabs=engineTabState?.get(taskId),liveTabs=tabs?[...tabs].filter(([,tabEs])=>tabEs.state!=="idle"):[];if(liveTabs.length>0){for(let[tabId,tabEs]of liveTabs){let key2=notifyTargetKey(taskId,tabId);states.set(key2,tabEs.state),targets.set(key2,{taskId,tabId})}continue}let key=notifyTargetKey(taskId,"");states.set(key,es.state),targets.set(key,{taskId,tabId:""})}return{states,targets}}function useAttention(args){let{tasks:tasks2,engineState,engineTabState,inboxItems,selectedId,kv,notif,openAttention,noTasksMessage}=args,prevStates=import_react124.useRef(null);import_react124.useEffect(()=>{let{states:next,targets}=notifyTargetStates(engineState,engineTabState),edges=attentionEdges(prevStates.current,next,null,attentionKindFor);if(prevStates.current=next,kv.get(CROSS_TASK_KEY,!0)===!1)return;let repos=[...new Set(tasks2.map((t3)=>t3.repo))],taskById=new Map(tasks2.map((task)=>[task.id,task]));for(let{key,kind}of edges){let target=targets.get(key);if(!target||target.taskId===selectedId)continue;let task=taskById.get(target.taskId),project=task?sidebarProjectLabel(task.repo,repos):"",tab=target.tabId?knownTaskTab(kv,target.taskId,target.tabId):void 0,tabLabel2=tab?tabTitleStable(tab,task?.vendor??DEFAULT_TASK_VENDOR):"";notif.notify({kind,taskId:target.taskId,tabId:target.tabId,title:task?.title??target.taskId,body:tabLabel2?`${project} \u203A ${tabLabel2}`:project||void 0,silent:task?.dispatcher!==void 0,turnEnd:!0})}},[engineState,engineTabState,selectedId,tasks2,kv,notif]);function jumpToNextAttention(){let order=tasks2.filter((t3)=>!t3.deletion).map((t3)=>t3.id),target=nextAttentionInboxTarget(inboxItems,order,{taskId:selectedId,tabId:selectedId?activeTabIdFor(selectedId):null},(item)=>isAttentionInboxItemAvailable(item,tasks2.find((task)=>task.id===item.taskId),(tabId)=>item.taskId===null?void 0:taskTabExists(kv,item.taskId,tabId)));if(!target){notif.notify({kind:"done",taskId:selectedId??"",tabId:"",title:noTasksMessage});return}openAttention(target)}return{jumpToNextAttention}}function createPRAction(deps){let gather=deps.gather??gatherPRPromptState,build=deps.build??buildPRPrompt;return async function(){let wt=deps.worktree,send2=deps.sendToEngineFn.current;if(!wt||!send2)return;let state=await gather(wt);if(state.branch===state.targetBranch)return deps.notifyError(deps.t("files.toast.prOnTargetBranch",{branch:state.branch}));let prompt=await build(wt,state);if(deps.selectedWorktreeRef.current!==wt||deps.sendToEngineFn.current!==send2)return;send2(prompt)}}var pendingCreatePR=null;function requestCreatePR(taskId){pendingCreatePR=taskId}function takeCreatePR(taskId){if(taskId===null||pendingCreatePR!==taskId)return!1;return pendingCreatePR=null,!0}function useCreatePR(args){let t3=useT();return createPRAction({...args,t:t3})}function useDaemonState(orchestrator){let tasks2=useMergedTasks(orchestrator),activeTaskId=useAccessor(orchestrator.activeTaskSignal()),engineState=useAccessor(orchestrator.engineStateSignal()),engineLifecycle=useAccessor(orchestrator.engineLifecycleSignal()),engineTabState=useAccessor(orchestrator.engineTabStatesSignal()),inboxItems=useAccessor(orchestrator.attentionInboxSignal()),taskJobs=useAccessor(orchestrator.taskJobsSignal()),rowTokens=useAccessor(orchestrator.rowTokensSignal()),worktreeChanges2=useAccessor(orchestrator.worktreeChangesSignal());return{tasks:tasks2,activeTaskId,engineState,engineLifecycle,engineTabState,inboxItems,taskJobs,rowTokens,worktreeChanges:worktreeChanges2}}var import_react125=__toESM(require_react_production(),1);import{join as join4}from"path";import{basename}from"path";function tryPluginFileOpen(absPath){let handler=null;try{handler=findFileHandler(basename(absPath))}catch{return!1}if(!handler)return!1;let[cmd,...rest]=[...roveCliInvocation(),"plugin","action","invoke",handler.qualifiedAction,absPath];return spawnDetached(cmd,rest,{onError:(err)=>console.warn(`[rove/plugins] ${handler?.qualifiedAction}: ${String(err)}`)})}function useFileOpenActions(deps){let{orch,worktree,selectedId,focus,openEditorTabFn,openDiffTabFn,selectedWorktreeRef}=deps;async function openFileInEditor(relPath){let wt=worktree;if(!wt)return;let abs=join4(wt,relPath);orch.reportUiEvent("file.will-open",selectedId??void 0,{path:abs});let opened=(via)=>orch.reportUiEvent("file.opened",selectedId??void 0,{path:abs,via});if(tryPluginFileOpen(abs))return opened("plugin");let openEditorTab2=openEditorTabFn.current,launch=openEditorTab2?await resolveEditorLaunch(wt,abs):null;if(!launch)return openExternally(abs),opened("external");if(selectedWorktreeRef.current!==wt||openEditorTabFn.current!==openEditorTab2)return;openEditorTab2?.(["sh","-c",launch.command],launch.label),opened("editor"),focus.setFocused("workspace")}function openDiff(relPath,base){let label=relPath==="."?"all":relPath.endsWith("/")?relPath:pathLeaf(relPath);openDiffTabFn.current?.(relPath,label,base)}return{openFileInEditor,openDiff}}function firstLine2(detail){return detail.split(`
|
|
96
96
|
`).find((line)=>line.trim().length>0)?.trim()??detail.trim()}function fixCIAction(deps){let build=deps.build??buildCIPromptForWorktree;return async function(taskId){let wt=deps.worktree,send2=deps.sendToEngineFn.current,task=deps.getTask(taskId);if(!wt||!send2||!task)return;let{checks,totalFailing,unavailable}=await deps.fetchChecks(taskId);if(unavailable)return deps.notifyError(deps.t("files.toast.ciChecksUnavailable",{detail:firstLine2(unavailable.detail)}));if(checks.length===0)return deps.notifyError(deps.t("files.toast.ciNoFailingChecks"));let prompt=await build(wt,{branch:task.branch||"HEAD",...task.prNumber===void 0?{}:{prNumber:task.prNumber},checks,totalFailing});if(deps.selectedWorktreeRef.current!==wt||deps.sendToEngineFn.current!==send2)return;send2(prompt)}}var pendingFixCI=null;function requestFixCI(taskId){pendingFixCI=taskId}function takeFixCI(taskId){if(taskId===null||pendingFixCI!==taskId)return null;return pendingFixCI=null,taskId}function useFixCI(args){let t3=useT();return fixCIAction({...args,t:t3})}function resolveConflictsAction(deps){let readOperation=deps.readOperation??pausedGitOperation,readConflicts=deps.readConflicts??conflictedPaths;return async function(taskId){let wt=deps.worktree,send2=deps.sendToEngineFn.current,branch=deps.getBranch(taskId);if(!wt||!send2||branch===null)return;let operation=readOperation(wt);if(!operation)return deps.notifyError(deps.t("files.toast.noPausedOperation"));let files=await readConflicts(wt);if(deps.selectedWorktreeRef.current!==wt||deps.sendToEngineFn.current!==send2)return;if(files===null)return deps.notifyError(deps.t("files.toast.conflictReadFailed"));if(!send2(buildConflictPrompt({operation,branch:branch||"HEAD",files})))deps.notifyError(deps.t("files.toast.conflictSendFailed"))}}var pendingResolve=null;function requestResolveConflicts(taskId){pendingResolve=taskId}function takeResolveConflicts(taskId){if(taskId===null||pendingResolve!==taskId)return null;return pendingResolve=null,taskId}function useResolveConflicts(args){let t3=useT();return resolveConflictsAction({...args,t:t3})}function mentionText(relPath){return`@${relPath}`}function mentionAction(pasteToEngineFn,onRefused){return(relPath)=>{let paste=pasteToEngineFn.current;if(!paste||!paste(mentionText(relPath)))onRefused()}}function useEditorHandles(opts){let{orchestrator,worktree,selectedId,focus,notifyError,activateTask}=opts,t3=useT(),openEditorTabFn=import_react125.useRef(null),sendToEngineFn=import_react125.useRef(null),pasteToEngineFn=import_react125.useRef(null),openDiffTabFn=import_react125.useRef(null),selectedWorktreeRef=useLatest(worktree),createPR=useCreatePR({worktree,sendToEngineFn,selectedWorktreeRef,notifyError}),fixCI=useFixCI({worktree,sendToEngineFn,selectedWorktreeRef,notifyError,getTask:(taskId)=>{let task=orchestrator.getTask(taskId);return task?{branch:task.branch,...task.prStatus?.number===void 0?{}:{prNumber:task.prStatus.number}}:null},fetchChecks:(taskId)=>orchestrator.failingChecks(taskId)}),resolveConflicts=useResolveConflicts({worktree,sendToEngineFn,selectedWorktreeRef,notifyError,getBranch:(taskId)=>orchestrator.getTask(taskId)?.branch??null}),{openFileInEditor,openDiff}=useFileOpenActions({orch:orchestrator,worktree,selectedId,focus,openEditorTabFn,openDiffTabFn,selectedWorktreeRef});return{onEditorTabReady:(open)=>{openEditorTabFn.current=open},onEngineSendReady:(send2)=>{if(sendToEngineFn.current=send2,takeCreatePR(selectedId))createPR();let parked=takeFixCI(selectedId);if(parked)fixCI(parked);let parkedResolve=takeResolveConflicts(selectedId);if(parkedResolve)resolveConflicts(parkedResolve)},onEnginePasteReady:(paste)=>{pasteToEngineFn.current=paste},onDiffTabReady:(open)=>{openDiffTabFn.current=open},onOpenFile:openFileInEditor,onOpenDiff:openDiff,onCreatePR:()=>void createPR(),onFixChecks:(taskId)=>{if(taskId===selectedId)return void fixCI(taskId);requestFixCI(taskId),activateTask(taskId)},onResolveConflicts:(taskId)=>{if(taskId===selectedId)return void resolveConflicts(taskId);requestResolveConflicts(taskId),activateTask(taskId)},onMention:mentionAction(pasteToEngineFn,()=>notifyError(t3("files.mentionNoEngine")))}}function useHostNotifiers(args){let{notif,t:t3,selectedId}=args,post=(kind,title)=>{notif.notify({kind,taskId:selectedId()??"",tabId:"",title})};return{notifyError:(message)=>post("error",message),notifyInfo:(message)=>post("done",message),notifyNeedsInput:(message)=>post("needs_input",message),notifyWorktreeGone:(event)=>notif.notify({kind:"error",taskId:event.taskId,tabId:"",title:t3("tasks.toast.worktreeGoneTitle",{title:event.title}),body:t3("tasks.toast.worktreeGoneBody",{count:String(event.closed),branch:event.branch||"\u2014"})})}}var import_react128=__toESM(require_react_production(),1);var import_react126=__toESM(require_react_production(),1);var CONTEXT_MAX_CHARS=400;function GateDecisionDialogView(props){let dialog=useDialog(),t3=useT(),padX=useDialogPaddingX(),{theme}=useTheme(),{options,recommended,question,context}=props.gate,hasOptions=options.length>0,[cursor,setCursor]=import_react126.useState(()=>Math.max(0,options.findIndex((o2)=>o2.key===recommended))),[note,setNote]=import_react126.useState(""),[field,setField]=import_react126.useState(hasOptions?"options":"note"),[error,setError]=import_react126.useState(null);function commit(){let text=note.trim();if(!hasOptions&&isBlankText(text)){setError(t3("gates.decision.needsText"));return}let option=hasOptions?options[cursor]?.key:void 0;props.onSubmit({...option!==void 0?{option}:{},...isBlankText(text)?{}:{text}}),dialog.clear()}function toggleField(){if(hasOptions)setField((f2)=>f2==="options"?"note":"options")}useBindings(()=>({bindings:[{key:"tab",cmd:toggleField},{key:"shift+tab",cmd:toggleField},...field==="options"?[{key:"up",cmd:()=>setCursor((c2)=>clampCursor2(c2-1,options.length))},{key:"down",cmd:()=>setCursor((c2)=>clampCursor2(c2+1,options.length))},{key:"return",cmd:()=>commit()}]:[]]}));let window2={items:options.map((o2)=>o2.key),start:0,total:options.length},rows=options.map((option)=>({key:option.key,body:`${option.key} ${option.label}`,accent:option.key===recommended,dim:option.key===recommended?t3("gates.decision.recommended"):option.detail})),clippedContext=context&&context.length>CONTEXT_MAX_CHARS?`${context.slice(0,CONTEXT_MAX_CHARS)}\u2026`:context;return $jsxs("box",{paddingLeft:padX,paddingRight:padX,gap:1,children:[$jsx(DialogHeader2,{title:`${t3("gates.decision.title")} \xB7 ${props.taskTitle}`,onClose:()=>props.onCancel()}),$jsx("text",{fg:theme.text,wrapMode:"word",children:question}),clippedContext?$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:clippedContext}):null,hasOptions?$jsx(DialogSection2,{label:t3("gates.decision.optionsLabel"),focused:field==="options",children:$jsx(PickerList,{window:window2,cursor,focused:field==="options",rows,onPick:(index)=>{setCursor(index),setField("options")}})}):null,$jsx(DialogSection2,{label:t3("gates.decision.noteLabel"),focused:field==="note",hint:hasOptions?t3("gates.decision.noteOptionalHint"):t3("gates.decision.noteRequiredHint"),onPress:()=>setField("note"),children:$jsx(DialogField2,{focused:field==="note",children:$jsx("input",{value:note,placeholder:t3("gates.decision.notePlaceholder"),focused:field==="note",onInput:(v3)=>{setNote(stripNewlines2(v3)),setError(null)},onSubmit:()=>commit()})})}),error?$jsx("text",{fg:theme.error,wrapMode:"word",children:error}):null,$jsx(DialogFooter2,{children:hasOptions?field==="options"?t3("gates.decision.footerOptions"):t3("gates.decision.footerNoteWithOptions"):t3("gates.decision.footerNote")})]})}function show15(dialog,opts){return showDialog(dialog,(resolve3)=>$jsx(GateDecisionDialogView,{gate:opts.gate,taskTitle:opts.taskTitle,onSubmit:(answer)=>resolve3(answer),onCancel:()=>resolve3(void 0)}))}var GateDecisionDialog={show:show15};var import_react127=__toESM(require_react_production(),1);import{TextAttributes as TextAttributes49}from"@opentui/core";function itemColor(state,theme){if(state==="permission_needed")return theme.warning;if(state==="turn_complete")return theme.success;if(state==="rate_limited"||state==="report_missing")return theme.warning;if(state==="decision_needed")return theme.warning;return theme.error}function itemGlyph(state,glyphs=DEFAULT_GLYPHS){if(state==="permission_needed")return glyphs.needsInput;if(state==="turn_complete")return glyphs.done;if(state==="rate_limited")return glyphs.rateLimited;if(state==="dead")return glyphs.dead;if(state==="routine_failed")return glyphs.routineFailed;if(state==="decision_needed")return glyphs.needsInput;return glyphs.attention}var GATE_ANSWERED_STATE_KEY="workspace.inbox.state.gateAnswered";function itemStateKey(state){if(state==="permission_needed")return"workspace.inbox.state.needsInput";if(state==="turn_complete")return"workspace.inbox.state.done";if(state==="rate_limited")return"workspace.inbox.state.rateLimited";if(state==="dead")return"workspace.inbox.state.dead";if(state==="routine_failed")return"workspace.inbox.state.routineFailed";if(state==="report_missing")return"workspace.inbox.state.reportMissing";if(state==="decision_needed")return"workspace.inbox.state.decisionNeeded";return"workspace.inbox.state.error"}function reportMissingNote(item){if(item.state!=="report_missing")return null;return item.detail?.note?.trim()||null}function quotaResumeNote(state,task,t3){if(state!=="rate_limited")return null;let raw=task?.quotaResume?.resumeAt;if(!raw)return null;let at2=Date.parse(raw);if(!Number.isFinite(at2))return null;return t3("workspace.inbox.resumesAt",{time:new Date(at2).toLocaleTimeString(intlLocale(),{hour:"numeric",minute:"2-digit"})})}function isDismissible(row){if(row?.kind!=="attention")return!1;return row.item.state!=="decision_needed"||row.item.detail?.gate?.undelivered===!0}var MAX_VISIBLE_CARDS=6,CARD_ROWS_WITH_GAP=3,DIALOG_CHROME_ROWS=12,AGE_REFRESH_MS=30000,IDENTITY_FLOOR_CELLS=16;function taskTabLabel(taskId,tabId,task,kv){let tab=tabId&&taskId?knownTaskTab(kv,taskId,tabId):void 0;return tab?tabTitleStable(tab,task?.vendor??DEFAULT_TASK_VENDOR):""}function tabLabel2(item,task,kv){return{label:taskTabLabel(item.taskId,item.tabId,task,kv),available:isAttentionInboxItemAvailable(item,task,(tabId)=>item.taskId===null?void 0:taskTabExists(kv,item.taskId,tabId))}}function runningBadge(opts){if(opts.activity?.state!=="running")return;return{glyph:breathGlyph(opts.glyphs.spinner,opts.frame),label:opts.t("workspace.inbox.state.running"),color:opts.theme.textMuted}}var NOOP_SUBSCRIBE2=()=>()=>{},ZERO_FRAME2=()=>0;function useSpinnerFrame2(active){return import_react127.useSyncExternalStore(active?subscribeSpinnerFrame:NOOP_SUBSCRIBE2,active?spinnerFrameSnapshot:ZERO_FRAME2)}function InboxCard(props){let{theme}=useTheme(),dimensions=useTerminalSize(),rowCells=Math.min(80,dimensions.width-2)-6,ageText=` ${props.age}`,fullBadge=props.badge?` ${props.badge.glyph} ${props.badge.label}`:"",cells=(s2)=>[...s2].reduce((n2,ch)=>n2+approxCharCells(ch.codePointAt(0)??0),0),identityRoom=rowCells-cells(ageText)-cells(fullBadge),dropLabel=props.badge!==void 0&&identityRoom<IDENTITY_FLOOR_CELLS,badgeText=props.badge?dropLabel?` ${props.badge.glyph}`:fullBadge:"",identity=truncateEndCells(props.identity,rowCells-cells(ageText)-cells(badgeText),approxCharCells),subtitle=truncateEndCells(props.subtitle,rowCells,approxCharCells),selection=resolveRowSelectionChrome2(theme,{cursor:props.active});return $jsxs("box",{flexDirection:"row",paddingRight:2,backgroundColor:selection.backgroundColor,onMouseUp:(event)=>{event.stopPropagation(),props.onOpen()},children:[$jsxs("box",{flexDirection:"column",flexShrink:0,paddingRight:1,children:[$jsx("text",{fg:selection.markerColor,wrapMode:"none",children:selection.marker}),$jsx("text",{fg:selection.markerColor,wrapMode:"none",children:selection.marker})]}),$jsxs("box",{flexDirection:"column",flexBasis:0,flexGrow:1,flexShrink:1,children:[$jsxs("box",{flexDirection:"row",children:[$jsx("text",{fg:theme.text,attributes:props.active?TextAttributes49.BOLD:void 0,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:identity}),props.badge?$jsx("text",{fg:props.badge.color,wrapMode:"none",flexShrink:0,children:badgeText}):null,$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:0,children:ageText})]}),$jsx("box",{flexDirection:"row",children:$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:subtitle})})]})]})}function AttentionInboxPane(props){let{theme}=useTheme(),t3=useT(),dimensions=useTerminalSize(),[cursor,setCursor]=import_react127.useState(0),[now,setNow]=import_react127.useState(()=>Date.now()),tabsRev=useAccessor(tabsRevision),{availableItems}=import_react127.useMemo(()=>{return partitionAttentionInboxAvailability(props.items,props.tasks,(taskId,tabId)=>taskTabExists(props.kv,taskId,tabId))},[props.items,props.tasks,props.kv,tabsRev]),visits=import_react127.useMemo(()=>readInboxVisits(props.kv),[props.kv]),selectedTabId=props.selectedId?activeTabIdFor(props.selectedId):null,rows=import_react127.useMemo(()=>{return inboxRows(availableItems,props.tasks,{selectedId:props.selectedId,selectedTabId,visits,tabExists:(taskId,tabId)=>taskTabExists(props.kv,taskId,tabId)})},[availableItems,props.tasks,props.selectedId,selectedTabId,visits,props.kv,tabsRev]),attentionCount=rows.filter((row)=>row.kind==="attention").length,anyRunning=rows.some((row)=>row.kind==="recent"&&props.engineStates?.get(row.task.id)?.state==="running"),spinnerFrame=useSpinnerFrame2(anyRunning),glyphs=useGlyphs(),maxVisibleCards=Math.max(1,Math.min(MAX_VISIBLE_CARDS,Math.floor((dimensions.height-DIALOG_CHROME_ROWS)/CARD_ROWS_WITH_GAP))),safeCursor=clampSelectableRow(rows,cursor),{visible,hiddenAbove,hiddenBelow}=windowInboxRows(rows,safeCursor,maxVisibleCards),repos=[...new Set(props.tasks.map((task)=>task.repo))];import_react127.useEffect(()=>{if(cursor!==safeCursor)setCursor(safeCursor)},[cursor,safeCursor]),import_react127.useEffect(()=>{let timer3=setInterval(()=>setNow(Date.now()),AGE_REFRESH_MS);return()=>clearInterval(timer3)},[]);function move(delta){if(rows.length===0)return;setCursor(nextSelectableRow(rows,safeCursor,delta))}function selected(){return rows[safeCursor]}function open(row){if(row.kind==="recent"){props.onOpenTask(row.task.id,row.tabId);return}if(row.kind!=="attention")return;let task=props.tasks.find((candidate)=>candidate.id===row.item.taskId);props.onOpen(row.item,tabLabel2(row.item,task,props.kv).available)}return useBindings(()=>({bindings:bindByIds({"inbox.nav":(_event,slot)=>move((slot??0)%2===0?1:-1),"inbox.open":()=>{let row=selected();if(row)open(row)},"inbox.delete":()=>{let row=selected();if(row?.kind==="attention"&&isDismissible(row))props.onDelete(row.item)}})})),$jsxs("box",{flexDirection:"column",paddingLeft:1,paddingRight:1,children:[$jsxs("box",{flexDirection:"row",flexShrink:0,justifyContent:"space-between",children:[$jsxs("box",{flexDirection:"row",children:[$jsx("text",{fg:theme.focusAccent,attributes:TextAttributes49.BOLD,wrapMode:"none",children:t3("workspace.inbox.title")}),$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:` ${attentionCount}`})]}),$jsx("text",{fg:theme.textMuted,wrapMode:"none",onMouseUp:props.onClose,children:"esc"})]}),rows.length===0?$jsx("box",{paddingTop:1,paddingBottom:1,children:$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("workspace.inbox.empty")})}):$jsxs("box",{flexDirection:"column",gap:1,paddingTop:1,paddingBottom:1,children:[hiddenAbove>0?$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:0,children:t3("workspace.inbox.more",{count:String(hiddenAbove)})}):null,visible.map((row)=>{let absoluteIndex=rows.indexOf(row);if(row.kind==="header")return $jsx("text",{fg:theme.textMuted,attributes:TextAttributes49.BOLD,wrapMode:"none",flexShrink:0,children:t3(`workspace.inbox.section.${row.section}`)},row.id);let active=absoluteIndex===safeCursor,openRow=()=>{setCursor(absoluteIndex),open(row)};if(row.kind==="recent"){let project2=sidebarProjectLabel(row.task.repo,repos),title2=row.task.kind==="main"?project2:row.task.title,tab2=taskTabLabel(row.task.id,row.tabId,row.task,props.kv);return $jsx(InboxCard,{identity:tab2?`${project2} \u203A ${tab2}`:title2===project2?project2:`${project2} \u203A ${title2}`,subtitle:title2,badge:runningBadge({activity:props.engineStates?.get(row.task.id),task:row.task,frame:spinnerFrame,glyphs,theme,t:t3}),age:relativeAge(row.at,now),active,onOpen:openRow},row.id)}let item=row.item,task=props.tasks.find((candidate)=>candidate.id===item.taskId),tab=tabLabel2(item,task,props.kv),routine=item.detail?.routine,gate=item.detail?.gate,title=routine?.name??task?.title??item.taskId??"",resumeNote=quotaResumeNote(item.state,task,t3)??reportMissingNote(item),contextLine=resumeNote?`${title} \xB7 ${resumeNote}`:title,project=task?sidebarProjectLabel(task.repo,repos):"";return $jsx(InboxCard,{identity:routine?`${t3("automations.title")} \u203A ${routine.name}`:tab.label?`${project} \u203A ${tab.label}`:project||title,subtitle:routine?routine.error??routine.status:gate?gate.question:contextLine,badge:{glyph:gate?.undelivered?glyphs.done:itemGlyph(item.state,glyphs),label:t3(gate?.undelivered?GATE_ANSWERED_STATE_KEY:itemStateKey(item.state)),color:itemColor(item.state,theme)},age:relativeAge(item.at,now),active,onOpen:openRow},row.id)}),hiddenBelow>0?$jsx("text",{fg:theme.textMuted,wrapMode:"none",flexShrink:0,children:t3("workspace.inbox.more",{count:String(hiddenBelow)})}):null]}),$jsxs("box",{flexDirection:"row",flexShrink:0,gap:2,paddingTop:1,children:[$jsx("text",{fg:theme.textMuted,wrapMode:"none",children:t3("workspace.inbox.openHint")}),$jsx("text",{fg:theme.textMuted,attributes:isDismissible(selected())?void 0:TextAttributes49.DIM,wrapMode:"none",children:t3("workspace.inbox.clearHint")})]})]})}function AttentionInboxDialog(props){let dialog=useDialog(),kv=useKV(),items=useAccessor(props.orchestrator.attentionInboxSignal()),tasks2=useAccessor(props.orchestrator.tasksSignal()),engineStates=useAccessor(props.orchestrator.engineStateSignal());return $jsx(AttentionInboxPane,{items,tasks:tasks2,kv,selectedId:props.selectedId,engineStates,onOpen:props.onOpen,onOpenTask:props.onOpenTask,onDelete:props.onDelete,onClose:()=>dialog.clear()})}AttentionInboxDialog.show=(dialog,props)=>{dialog.replace(()=>$jsx(AttentionInboxDialog,{...props})),dialog.setSize("medium"),dialog.setPlacement("upper-fifth")};var FAILURE_KEY={"mark read":"tasks.toast.inboxMarkReadFailed",dismiss:"tasks.toast.inboxDismissFailed"};function notifyInboxRpcFailure(request,action,notifyError){request.catch((err)=>notifyError(t(FAILURE_KEY[action],{error:userFacingErrorMessage(err)})))}function requestInboxItemOpen(item,available,rpc,notifyError){return notifyInboxRpcFailure(dismissEpisode(item,rpc),"dismiss",notifyError),available}function dismissEpisode(item,rpc,explicit=!1){let automationId=item.detail?.routine?.automationId;if(isRoutineInboxState(item.state)&&automationId)return rpc.dismissRoutineAttention(automationId);if(item.state==="decision_needed")return Promise.resolve(!1);if(item.state==="report_missing"&&!explicit)return Promise.resolve(!1);if(item.taskId===null)return Promise.resolve(!1);let deliveryId=item.state==="report_missing"?item.detail?.delivery?.id:void 0;if(deliveryId===void 0)return rpc.dismissAttention(item.taskId,item.tabId,item.at);return rpc.dismissAttention(item.taskId,item.tabId,item.at,deliveryId)}function episodeKey(item){return`${attentionInboxKey(item)}\x00${item.at}`}function episodeSignature(items){return items.map(episodeKey).sort().join(`
|
|
97
|
-
`)}function useInboxHost(args){let{orchestrator:orch}=args,tabsRev=useAccessor(tabsRevision),{availableItems,unavailableItems}=import_react128.useMemo(()=>{return partitionAttentionInboxAvailability(args.items,args.tasks,(taskId,tabId)=>taskTabExists(args.kv,taskId,tabId))},[args.items,args.tasks,args.kv,tabsRev]),viewingResolved=args.selectedId?new Set(visitResolvedEpisodes(availableItems,{taskId:args.selectedId,tabId:activeTabIdFor(args.selectedId)}).map(episodeKey)):null,visibleItems=viewingResolved&&viewingResolved.size>0?availableItems.filter((item)=>!viewingResolved.has(episodeKey(item))):availableItems,counts=attentionInboxCounts(visibleItems),notifyErrorRef=useLatest(args.notifyError),unavailableItemsRef=useLatest(unavailableItems),unavailableSignature=episodeSignature(unavailableItems),attemptedUnavailable=import_react128.useRef(new Set);import_react128.useEffect(()=>{let currentItems=unavailableItemsRef.current;if(episodeSignature(currentItems)!==unavailableSignature)return;let currentKeys=new Set(currentItems.map(episodeKey));for(let attempted of attemptedUnavailable.current)if(!currentKeys.has(attempted))attemptedUnavailable.current.delete(attempted);for(let item of currentItems){let key=episodeKey(item);if(attemptedUnavailable.current.has(key))continue;attemptedUnavailable.current.add(key),notifyInboxRpcFailure(dismissEpisode(item,orch),"dismiss",notifyErrorRef.current)}},[unavailableSignature,orch]);function openItem(item,knownAvailable){if(isRoutineInboxState(item.state)){if(notifyInboxRpcFailure(dismissEpisode(item,orch),"dismiss",args.notifyError),args.dialog.stack.length>0)args.dialog.clear({refocus:!1});args.openAutomations();return}let gate=item.state==="decision_needed"?item.detail?.gate:void 0;if(gate&&!gate.undelivered&&item.taskId!==null){let taskTitle=orch.getTask(item.taskId)?.title??item.taskId;GateDecisionDialog.show(args.dialog,{gate,taskTitle}).then((answer)=>{if(!answer)return;orch.answerGate(gate.id,answer).catch((err)=>args.notifyError(t("gates.toast.answerFailed",{error:userFacingErrorMessage(err)})))});return}let taskId=item.taskId;if(taskId===null)return;let task=orch.getTask(taskId),available=knownAvailable??isAttentionInboxItemAvailable(item,task,(tabId)=>taskTabExists(args.kv,taskId,tabId));if(!requestInboxItemOpen(item,available,orch,args.notifyError))return;if(args.dialog.stack.length>0)args.dialog.clear({refocus:!1});if(args.selectTask(taskId),item.tabId)requestTabActivation(taskId,item.tabId);args.focusWorkspace()}function openTask(taskId,tabId){if(args.dialog.stack.length>0)args.dialog.clear({refocus:!1});if(args.selectTask(taskId),tabId)requestTabActivation(taskId,tabId);args.focusWorkspace()}function closeItem(item){let gate=item.state==="decision_needed"?item.detail?.gate:void 0;if(!gate){notifyInboxRpcFailure(dismissEpisode(item,orch,!0),"dismiss",args.notifyError);return}if(!gate.undelivered)return;orch.withdrawGate(gate.id).catch((err)=>args.notifyError(t("gates.toast.withdrawFailed",{error:userFacingErrorMessage(err)})))}function show16(){AttentionInboxDialog.show(args.dialog,{orchestrator:orch,selectedId:args.selectedId,onOpen:openItem,onOpenTask:openTask,onDelete:closeItem})}let availableItemsRef=useLatest(availableItems),availableSignature=episodeSignature(availableItems),selectedIdRef=useLatest(args.selectedId),attemptedResolved=import_react128.useRef(new Set),resolveEpisodes=import_react128.useCallback((items,visit)=>{let currentKeys=new Set(items.map(episodeKey));for(let attempted of attemptedResolved.current)if(!currentKeys.has(attempted))attemptedResolved.current.delete(attempted);for(let item of visitResolvedEpisodes(items,visit)){let key=episodeKey(item);if(attemptedResolved.current.has(key))continue;attemptedResolved.current.add(key),notifyInboxRpcFailure(dismissEpisode(item,orch),"dismiss",notifyErrorRef.current)}},[orch]);function resolveVisited(taskId,tabId){resolveEpisodes(availableItemsRef.current,{taskId,tabId}),writeInboxVisit(args.kv,{taskId,tabId,at:Date.now()})}return import_react128.useEffect(()=>{let currentItems=availableItemsRef.current;if(episodeSignature(currentItems)!==availableSignature)return;let selectedId=selectedIdRef.current;if(!selectedId)return;let activeTab=activeTabIdFor(selectedId);if(!activeTab)return;resolveEpisodes(currentItems,{taskId:selectedId,tabId:activeTab})},[availableSignature,resolveEpisodes]),{availableItems:visibleItems,counts,openItem,show:show16,resolveVisited}}function buildIssueChatBackgroundSpawn(input){let base=interactiveEngineCommand(input.vendor),{sessionId}=withPinnedSessionId(base,input.vendor),fresh=initialTabs(),tab={...fresh.tabs[0],sessionId},state={...fresh,tabs:[tab]},spawn3=engineTabSpawnFor(state,tab,base,{live:!1,shell:input.shell??defaultShell(),prompt:input.prompt??issueWorktreePrompt(input.issue,input.api),task:{id:input.taskId,kind:input.kind??"task",vendor:input.vendor,repo:input.repoRoot},worktreePath:input.worktreePath,inlineImages:terminalDrawsKitty()});return{ptyKey:tabPtyKey(input.taskId,tab.id),command:spawn3.command,initialInput:spawn3.initialInput,firstMessage:spawn3.firstMessage,engineBin:spawn3.engineBin,tabsSnapshot:setTabSpawned(state,tab.id,!0)}}function useIssueChat(orch,hooks){let t3=useT();async function enter(taskId){hooks.closeKanban(),hooks.selectTask(taskId),await hooks.enterTask(taskId)}async function finish(request,enterTaskId){if(request.jump)await enter(enterTaskId);else hooks.notifyInfo(t3("kanban.detail.startedBackground",{title:issueChatTaskTitle(request.issue)}))}async function startProjectTab(request,api){let{repoRoot,issue,vendor}=request,main=await orch.ensureMainTask(repoRoot);await orch.mutateIssue(repoRoot,{type:"setStatus",id:issue.id,status:"doing"}).catch((err)=>{console.error("[rove kanban] issue setStatus failed:",err),hooks.notifyError(t3("kanban.statusFailed",{id:String(issue.id),error:userFacingErrorMessage(err)}))});let{task:child}=await orch.spawnChildTask({parentTaskId:main.id,worktree:!1,vendor}),spawn3=buildIssueChatBackgroundSpawn({issue,taskId:child.id,repoRoot,worktreePath:taskCwd(child),vendor,api,kind:child.kind,prompt:issueProjectPrompt(issue,api)});getDefaultPtyRegistry().acquire(spawn3.ptyKey,taskCwd(child),{command:spawn3.command,initialInput:spawn3.initialInput,firstMessage:spawn3.firstMessage,engineBin:spawn3.engineBin}),setTaskTabs2(child.id,spawn3.tabsSnapshot),await finish(request,child.id)}async function startWorktreeTask(request,api){let{repoRoot,issue,vendor}=request;setRepoLastActiveVendor(repoRoot,vendor),addSavedRepo(repoRoot);let task=await orch.createTask({repo:repoRoot,title:issueChatTaskTitle(issue),vendor});await orch.mutateIssue(repoRoot,{type:"link",id:issue.id,taskId:task.id}).catch((err)=>{console.error("[rove kanban] issue link failed:",err),hooks.notifyError(t3("kanban.linkFailed",{id:String(issue.id),error:userFacingErrorMessage(err)}))});let worktreePath=await orch.ensureWorktree(task.id),spawn3=buildIssueChatBackgroundSpawn({issue,taskId:task.id,repoRoot,worktreePath,vendor,api});return getDefaultPtyRegistry().acquire(spawn3.ptyKey,worktreePath,{command:spawn3.command,initialInput:spawn3.initialInput,firstMessage:spawn3.firstMessage,engineBin:spawn3.engineBin}),setTaskTabs2(task.id,spawn3.tabsSnapshot),{task,worktreePath,tab:spawn3.tabsSnapshot.tabs[0]}}async function start(request){try{let api=roveApiInvocation();if(request.placement==="project"){await startProjectTab(request,api);return}let{task,worktreePath,tab}=await startWorktreeTask(request,api);if(request.placement==="projectWorktree"){let main=await orch.ensureMainTask(request.repoRoot);await appendBackgroundEngineTab(main.id,{vendor:request.vendor,sessionId:tab.sessionId??null,ptyTask:{id:task.id,worktree:worktreePath}}),await finish(request,main.id);return}await finish(request,task.id)}catch(err){hooks.notifyError(t3("tasks.toast.issueChatFailed",{error:userFacingErrorMessage(err)}))}}return{start}}var import_react129=__toESM(require_react_production(),1);function usePrCheckNotifier(args){let notif=useLatest(args.notif),t3=useLatest(useT()),prev=import_react129.useRef(new Map);import_react129.useEffect(()=>{let next=new Map;for(let task of args.tasks){let pr=rollupPr(task),state=pr?.checkState;if(state===void 0)continue;next.set(task.id,state);let landed2=checkResolutionNotify(prev.current.get(task.id),state);if(!landed2)continue;notif.current.notify({kind:landed2==="passing"?"done":"error",taskId:task.id,tabId:"",title:t3.current(landed2==="passing"?"tasks.toast.checksPassingTitle":"tasks.toast.checksFailingTitle",{title:task.title}),body:t3.current("tasks.toast.checksResolvedBody",{pr:pr?.number===void 0?"\u2014":`#${pr.number}`,branch:task.branch||"\u2014"})})}prev.current=next},[args.tasks])}import{homedir}from"os";var import_react130=__toESM(require_react_production(),1);function decideScratchAdopt(input){if(!input.repoRoot||!input.harnessLive)return{kind:"stay"};let owners=input.ownerTasks.filter((task)=>task.dir!==""&&!task.sharesWorkspaceOf);if(input.cwd){let cwd=input.cwd,managed=owners.find((task)=>task.kind==="task"&&pathWithin(task.dir,cwd)!==null);if(managed)return{kind:"fold",taskId:managed.id}}for(let kind of["main","dir"]){let owned=owners.find((task)=>task.kind===kind&&(samePath(task.dir,input.cwd)||samePath(task.dir,input.repoRoot)));if(owned)return{kind:"fold",taskId:owned.id}}return{kind:"adopt",repo:input.repoRoot,known:[...input.knownRepos].some((repo)=>samePath(repo,input.repoRoot))}}async function renameHostedSession(from,to){if((process.env.ROVE_TERMINAL_BACKEND??"hosted")!=="hosted")return!1;try{return(await(await getSharedPtyClient()).request("pty.rename",{from,to})).renamed===!0}catch{return!1}}var tabNumber=(id)=>Number(/^tab-(\d+)$/.exec(id)?.[1]??0);async function foldScratchShell(io,scratchTaskId,targetTaskId){let rename=io.rename??renameHostedSession,scratchTabIds=(knownTaskTabs(io.kv,scratchTaskId)?.tabs??[{id:"tab-1"}]).map((tab)=>tab.id),reserved=await(io.reserve??reserveTabOrdinals)(targetTaskId,scratchTabIds.length*2).catch(()=>null),fallback=1+(knownTaskTabs(io.kv,targetTaskId)?.tabs??[]).reduce((max,tab)=>Math.max(max,tabNumber(tab.id)),0),nextId=()=>`tab-${reserved?.shift()??fallback++}`,folded=[];for(let tabId of scratchTabIds){let from=tabPtyKey(scratchTaskId,tabId),to=nextId(),ok=await rename(from,tabPtyKey(targetTaskId,to));if(!ok)to=nextId(),ok=await rename(from,tabPtyKey(targetTaskId,to));if(!ok)continue;folded.push(to)}if(folded.length===0)return null;return adoptTaskTabs(io.kv,targetTaskId,folded),{activeTabId:folded[0]}}var POLL_MS5=5000;function scratchOwnerTasks(tasks2){return tasks2.filter((task)=>!task.deletion&&task.scratch!==!0&&task.worktreePath!=="").map((task)=>({id:task.id,kind:task.kind??"task",dir:canonPath(task.worktreePath),...task.sharesWorkspaceOf?{sharesWorkspaceOf:task.sharesWorkspaceOf}:{}}))}function useScratchAdopt(deps){let{tasks:tasks2,orchestrator,kv,notifyInfo}=deps,onFoldRef=useLatest(deps.onFold),enabled=deps.enabled??!0,scratchIds=tasks2.filter((t3)=>t3.kind==="dir"&&t3.scratch===!0).map((t3)=>t3.id).join(",");import_react130.useEffect(()=>{if(!enabled||scratchIds==="")return;let cancelled=!1,inFlight=new Set,tick3=async()=>{let scratch=tasks2.filter((t3)=>t3.kind==="dir"&&t3.scratch===!0);if(scratch.length===0)return;let known=new Set([...getSavedRepos(),...tasks2.map((t3)=>t3.repo)]),owners=scratchOwnerTasks(tasks2),registry=getDefaultPtyRegistry(),liveEngines=getDefaultLiveEngines();for(let task of scratch){if(inFlight.has(task.id))continue;let key=tabPtyKey(task.id,"tab-1"),pid=registry.get(key)?.shellPid??null;if(pid===null||pid===void 0)continue;if(!liveEngines.get(key))continue;let rawCwd=await processCwd(pid);if(cancelled||!rawCwd)continue;let cwd=canonPath(rawCwd),repoRoot=canonPath(resolveMainRepoRoot(cwd)),decision=decideScratchAdopt({cwd,repoRoot:isGitRepo(repoRoot)?repoRoot:null,harnessLive:!0,knownRepos:known,ownerTasks:owners});if(cancelled||decision.kind==="stay")continue;inFlight.add(task.id);try{if(decision.kind==="fold"){let folded=await foldScratchShell({kv},task.id,decision.taskId);if(!folded)throw Error("fold did not move any session");await onFoldRef.current(task.id,decision.taskId,folded.activeTabId);continue}if(await orchestrator.adoptScratchRepo(task.id,decision.repo),!decision.known)notifyInfo(t("tasks.toast.scratchAdopted",{repo:repoBasename(decision.repo)}))}catch{inFlight.delete(task.id)}}};tick3();let timer3=setInterval(()=>void tick3(),POLL_MS5);return()=>{cancelled=!0,clearInterval(timer3)}},[enabled,scratchIds,orchestrator,kv,notifyInfo,tasks2])}var scratchTeardowns=new Set;function useScratchShell(deps){let{orchestrator,enterTask,forgetTaskTabs:forgetTaskTabs2,notifyError}=deps;return useScratchAdopt({tasks:deps.tasks,orchestrator,kv:deps.kv,notifyInfo:deps.notifyInfo,onFold:async(scratchTaskId,targetTaskId,tabId)=>{if(deps.selectedId()===scratchTaskId)deps.selectTask(targetTaskId),requestTabActivation(targetTaskId,tabId);await orchestrator.deleteTask(scratchTaskId),forgetTaskTabs2(scratchTaskId)}}),{openScratchShell:(vendor)=>{orchestrator.openDirectoryTask({dir:homedir(),scratch:!0,...vendor?{vendor}:{}}).then((task)=>{if(vendor)engineScratchTasks.add(task.id);enterTask(task.id)}).catch((err)=>notifyError(t("tasks.toast.scratchOpenFailed",{message:userFacingErrorMessage(err)})))},onScratchExit:(taskId)=>{if(scratchTeardowns.has(taskId))return;scratchTeardowns.add(taskId),(async()=>{try{await orchestrator.deleteTask(taskId),forgetTaskTabs2(taskId),await finishDeletedTaskFlow({orch:orchestrator,tasks:deps.tasks,taskId,logger:console,logPrefix:"[rove scratch]",updateActiveTask:!0})}catch(err){notifyError(t("tasks.toast.scratchCloseFailed",{message:userFacingErrorMessage(err)}))}})()}}}var import_react131=__toESM(require_react_production(),1);function activationErrorMessage(error,translate){let message=errorMessage(error);if(message.includes(TASK_DELETING_CODE))return translate("tasks.toast.worktreeErrorDeleting");if(/not a git repository|does not appear to be a git repo/i.test(message))return translate("tasks.toast.worktreeErrorNotGit");return translate("tasks.toast.worktreeErrorGeneric",{message:userFacingErrorMessage(error)})}async function activateWorkspaceTask(opts,id){let task=opts.getTask(id);if(task?.deletion)return opts.reportError(new TaskDeletingError(id)),!1;if(task?.origin&&task.origin.machineId!=="local")return opts.selectTask(id),opts.focusWorkspace(),!0;if(!task?.worktreePath)try{await opts.ensureWorktree(id)}catch(error){return opts.reportError(error),!1}if(opts.isCurrent?.()===!1)return!1;return opts.selectTask(id),opts.focusWorkspace(),!0}function firstSelectableTask(tasks2,activeId,lastActiveId){let alive=(id)=>id?tasks2.find((task)=>task.id===id&&!task.deletion):void 0,active=alive(activeId)??alive(lastActiveId);if(active)return active;let live=tasks2.filter((task)=>!task.deletion),newest=(pool)=>pool.length>0?pool.reduce((best,task)=>task.updatedAt>best.updatedAt?task:best):void 0;return newest(live.filter((task)=>task.routine===void 0))??newest(live)??tasks2.find((task)=>!task.deletion)}function useWorkspaceSelection(args){let{orch,tasks:tasks2,activeTaskId,kv}=args,t3=useT(),[selectedId,setSelectedId]=import_react131.useState(()=>orch.activeTaskSignal()()??readLastActiveTaskId()),focusRestoredRef=import_react131.useRef(!1),userPickedRef=import_react131.useRef(!1),bootFocusRef=import_react131.useRef(!1),liveSelectedRef=import_react131.useRef(null);import_react131.useEffect(()=>{if(!focusRestoredRef.current&&activeTaskId&&tasks2.some((task)=>task.id===activeTaskId)){if(focusRestoredRef.current=!0,!userPickedRef.current&&selectedId!==activeTaskId){setSelectedId(activeTaskId);return}}if(!bootFocusRef.current&&!userPickedRef.current&&selectedId&&tasks2.some((task)=>task.id===selectedId))bootFocusRef.current=!0,args.focusWorkspace();let selected=selectedId?tasks2.find((task)=>task.id===selectedId):void 0,wasLive=selectedId!==null&&liveSelectedRef.current===selectedId;if(liveSelectedRef.current=selected&&selected.archived!==!0&&!selected.deletion?selectedId:null,wasLive&&selected?.archived===!0){setSelectedId(firstSelectableTask(tasks2.filter((task)=>task.archived!==!0),null)?.id??null);return}if(selectedId&&tasks2.some((task)=>task.id===selectedId&&!task.deletion))return;setSelectedId(firstSelectableTask(tasks2,activeTaskId,readLastActiveTaskId())?.id??null)},[tasks2,activeTaskId,selectedId,args.focusWorkspace]);let notifyWorktreeGoneRef=useLatest(args.notifyWorktreeGone),liveTaskIdsRef=import_react131.useRef(new Set),worktreePathsRef=import_react131.useRef(new Map);import_react131.useEffect(()=>{let next=new Set(tasks2.filter((task)=>!task.deletion).map((task)=>task.id)),registry=getDefaultPtyRegistry(),aliased=aliasedKeys(tasks2.filter((task)=>!task.deletion));for(let id of liveTaskIdsRef.current){if(next.has(id))continue;registry.releaseWhere((key)=>(key===id||key.startsWith(`${id}::`))&&!aliased.some((base)=>isUnderKey(key,base)))}liveTaskIdsRef.current=next;let paths=new Map;for(let task of tasks2)paths.set(task.id,task.worktreePath);for(let[id,prevPath]of worktreePathsRef.current)if(paths.get(id)===""&&prevPath!==""){let closed=knownTaskTabs(kv,id)?.tabs.length??0;registry.releaseWhere((key)=>key===id||key.startsWith(`${id}::`)),forgetTaskTabs(kv,id);let task=tasks2.find((candidate)=>candidate.id===id);notifyWorktreeGoneRef.current?.({taskId:id,title:task?.title??id,branch:task?.branch??"",closed})}worktreePathsRef.current=paths},[tasks2,kv]);function selectTask(id){if(userPickedRef.current=!0,selectedId===id){if(orch.activeTaskSignal()()!==id)orch.setActiveTask(id).catch((error)=>console.error("[rove workspace] setActiveTask failed:",error));return}setSelectedId(id),orch.setActiveTask(id).catch((error)=>console.error("[rove workspace] setActiveTask failed:",error));let kind=tasks2.find((task)=>task.id===id)?.kind==="main"?"project.opened":"task.opened";orch.reportUiEvent(kind,id)}let activationGenerationRef=import_react131.useRef(0);async function activateTask(id){let generation=++activationGenerationRef.current;reviveEmptiedTabs(kv,id,defaultShell()),await activateWorkspaceTask({getTask:(taskId)=>tasks2.find((task)=>task.id===taskId),ensureWorktree:(taskId)=>orch.ensureWorktree(taskId),selectTask,focusWorkspace:args.focusWorkspace,reportError:(error)=>{console.error("[rove workspace] task.ensureWorktree failed:",error),args.notifyError?.(activationErrorMessage(error,t3))},isCurrent:()=>activationGenerationRef.current===generation},id)}let selectedTask=selectedId?tasks2.find((task)=>task.id===selectedId):void 0;return{selectedId,setSelectedId,selectedTask,selectTask,activateTask}}var import_react132=__toESM(require_react_production(),1);function useZenMode(deps){let{kv,focus}=deps,[zen,setZen]=import_react132.useState(()=>kv.get(ZEN_ACTIVE_KEY,ZEN_DEFAULT)===!0);function toggleZen(){let next=!zen;if(setZen(next),kv.set(ZEN_ACTIVE_KEY,next),next)focus.setFocused("workspace")}return import_react132.useEffect(()=>{if(focus.focused==="files")setZen(!1)},[focus.focused]),{zen,toggleZen}}function WorkspaceRoot(props){let{theme}=useTheme(),inactiveBorder=theme.borderActive,dialog=useDialog(),kv=useKV(),focus=useFocus(),dims=useTerminalSize(),sidebarWidth=useSidebarWidth(),[sidebarCollapsed]=useSidebarCollapsed(),sidebarResize=useSidebarResizeGesture({width:sidebarWidth.width,onResize:sidebarWidth.pin,onReset:sidebarWidth.reset}),renderer=useRenderer(),notif=useNotifications(),orch=props.orchestrator;useDaemonNotices(orch,notif.notify,dialog);let{tasks:tasks2,activeTaskId,engineState,engineLifecycle,engineTabState,inboxItems,taskJobs,rowTokens,worktreeChanges:worktreeChanges2}=useDaemonState(orch),[searchActive,setSearchActive]=import_react134.useState(!1),t3=useT(),{notifyError,notifyInfo,notifyNeedsInput,notifyWorktreeGone}=useHostNotifiers({notif,t:t3,selectedId:()=>selectedId}),{selectedId,setSelectedId,selectedTask,selectTask,activateTask}=useWorkspaceSelection({orch,tasks:tasks2,activeTaskId,focusWorkspace:()=>focus.setFocused("workspace"),kv,notifyWorktreeGone,notifyError}),worktree=selectedTask?.worktreePath||null,workingFlow=selectedId!==null&&engineState?.get(selectedId)?.state==="running"&&normalizeWorkingBorder(kv.get(WORKING_BORDER_KEY,DEFAULT_WORKING_BORDER))==="flow",breath=useSpinnerFrame(workingFlow),taskInk=useTaskColor(selectedId),{sortMode,toggleSortMode,moveMode,setMoveMode,onLocalMergeRequest}=useSidebarHostState({kv,tasks:tasks2,focusSidebar:()=>focus.setFocused("sidebar"),notify:notifyInfo}),inbox=useInboxHost({orchestrator:orch,items:inboxItems,tasks:tasks2,kv,dialog,selectedId,selectTask,openAutomations:()=>pages.openPage("automations"),focusWorkspace:()=>focus.setFocused("workspace"),notifyError}),{jumpToNextAttention}=useAttention({tasks:tasks2,engineState,engineTabState,inboxItems:inbox.availableItems,selectedId,kv,notif,openAttention:inbox.openItem,noTasksMessage:t3("workspace.attention.none")});usePrCheckNotifier({tasks:tasks2,notif});let taskActions=useWorkspaceTaskActions({orchestrator:orch,tasks:()=>tasks2,dialog,notifyError,notifyInfo,notifyNeedsInput,t:t3,selectedId:()=>selectedId,setSelectedId,selectedTask:()=>selectedTask,activateTask,forgetTaskTabs:(id)=>forgetTaskTabs(kv,id),closeTaskTabs:(id)=>closeAllTaskTabs(kv,id),startWithPrompt:(repo,start)=>quickFork.onQuickFork(repo,{...start,attachments:[],attempts:1})}),editor=useEditorHandles({orchestrator:orch,worktree,selectedId,focus,notifyError,activateTask}),quickFork=useQuickFork(orch,{selectTask:setSelectedId,enterTask:activateTask,notifyError,notify:notifyInfo,t:t3}),scratch=useScratchShell({orchestrator:orch,tasks:tasks2,kv,selectedId:()=>selectedId,selectTask:setSelectedId,enterTask:(id)=>void activateTask(id),forgetTaskTabs:(id)=>forgetTaskTabs(kv,id),notifyError,notifyInfo}),{zen,toggleZen}=useZenMode({kv,focus}),filesActions=useFilesPaneActions({onOpenFile:(relPath)=>void editor.onOpenFile(relPath),onOpenDiff:editor.onOpenDiff,onMention:editor.onMention,onZenToggle:toggleZen,onCreatePR:()=>void editor.onCreatePR()});import_react134.useEffect(()=>{return setUiEventReporter((kind,taskId,detail)=>orch.reportUiEvent(kind,taskId,detail)),()=>setUiEventReporter(null)},[orch]),useTabsSync(orch.tabs,orch.connectionStateSignal()),useRowStatusSync(orch.rowStatus,orch.connectionStateSignal());let pages=useHostPagesState(focus,props);useWhatsNewDialog(pages.whatsNewFrom,pages.closeWhatsNew),useWelcomeDialog(pages.welcome,pages.closeWelcome);let selectedTabId=selectedId===null?null:activeTabIdFor(selectedId),issueChat=useIssueChat(orch,{selectTask:setSelectedId,enterTask:activateTask,closeKanban:pages.closePage,notifyError,notifyInfo}),pageRender=useHostPagesRender({orchestrator:orch,pages,focus,dialog,kv,dims,selectedTask,activeTaskId,tasks:tasks2,engineState,activateTask}),openTaskWorktree=(id)=>openTaskWorktreeFor(id,{tasks:tasks2,ensureWorktree:orch.ensureWorktree.bind(orch),notifyError}),cursorTaskIdRef=import_react134.useRef(()=>null),banner=useHostBanner(orch,dims.width),refreshRove=()=>{selfRefreshAction({orchestrator:orch,renderer,confirm:()=>DialogConfirm.show(dialog,t3("update.refresh.confirmTitle"),t3("update.refresh.confirmBody"),t3("common.cancel"),t3("update.refresh.confirmLabel")).then((ok)=>ok===!0),notifyError,t:t3},banner.refresh.inputs)};useWorkspaceKeybindings({focus,dialog,pages,filesPaneVisible:!zen&&pages.nav==="terminal"&&pageRender.showSidebar&&pageRender.showContent,searchActive,selectedId,cursorTaskId:()=>cursorTaskIdRef.current(),openTaskWorktree,createTask:()=>void taskActions.createTask(),renameBranch:(id)=>void taskActions.renameBranch(id),cycleVendor:(id)=>void taskActions.cycleVendor(id),toggleZen,jumpToNextAttention,openInbox:inbox.show,paletteSearch:{orchestrator:orch,tasks:tasks2,openTask:openTaskOnTab(pages.closePage,activateTask)},createPR:()=>void editor.onCreatePR(),createPRFor:(id)=>{requestCreatePR(id),activateTask(id)},fixChecksFor:editor.onFixChecks,syncBaseFor:(id)=>void taskActions.syncBase(id),enterMoveMode:()=>{let target=selectedId??tasks2[0]?.id;if(!target)return;focus.setFocused("sidebar"),setSelectedId(String(target)),setMoveMode(!0)},toggleSortMode,refresh:{available:banner.refresh.available,run:refreshRove}});let activePane=dialog.stack.length>0?null:focus.focused,fullWindow=pageRender.settingsPage??pageRender.fullWindowPage,contentPageType=import_react134.isValidElement(pageRender.contentPage)?pageRender.contentPage.type:null;if(fullWindow)return $jsx(FullWindowPage,{banner:banner.element,background:theme.background,children:$jsx(PaneErrorBoundary,{region:"page",children:fullWindow})});return $jsxs(WorkspaceFrame,{orchestrator:orch,onOpenSettings:()=>pages.openSettings(),banner:banner.element,activeTaskId:selectedId,activeTabId:selectedTabId,onPaneDrag:sidebarResize.onPaneDrag,onPaneRelease:sidebarResize.onPaneRelease,children:[pageRender.showSidebar?$jsx(RenderProfiler,{id:"sidebar",children:$jsx(PaneErrorBoundary,{region:"sidebar",width:pageRender.showContent?sidebarWidth.width:dims.width,children:$jsx(HostSidebarMount,{terminalWidth:dims.width,showContent:pageRender.showContent,recentTask:pageRender.recentTask,tasks:tasks2,selectedId,selectTask,activateTask,daemon:{engineState,engineTabState,engineLifecycle,taskJobs,rowTokens,worktreeChanges:worktreeChanges2},actions:taskActions,pages,focus,inbox,update:banner.update,onFixChecks:editor.onFixChecks,onResolveConflicts:editor.onResolveConflicts,runAgain:quickFork.runAgain,openScratch:scratch.openScratchShell,activePane,zen,toggleZen,sortMode,moveMode,exitMoveMode:()=>setMoveMode(!1),onLocalMergeRequest,onSearchActiveChange:setSearchActive,cursorTaskIdRef,openTaskWorktree,t:t3})})}):null,pageRender.showContent?$jsxs("box",{flexGrow:1,flexShrink:1,borderStyle:"rounded",borderColor:focus.focused==="workspace"?theme.focusAccent:inactiveBorder,renderAfter:workingFlow?runningPaneFlow(taskInk??theme.focusAccent,inactiveBorder,focus.focused==="workspace",breath,taskInk?TASK_PARTNER_HUE_DEG:void 0):void 0,title:workingFlow&&selectedTask?runningPaneTitle(selectedTask.title,t3("workspace.inbox.state.running")):void 0,onMouseUp:()=>focus.setFocused("workspace"),children:[isNarrowWidth(dims.width)?$jsx(NarrowBackBar,{onBack:()=>focus.setFocused("sidebar")}):null,$jsx(PaneErrorBoundary,{region:"workspace",resetKeys:[selectedId,contentPageType],children:pageRender.contentPage?$jsx(PageServicesProvider,{value:{startIssueChat:issueChat.start},children:pageRender.contentPage}):$jsx(RenderProfiler,{id:"workspace",children:$jsx(ShowWorkspace,{task:selectedTask,worktree,orchestrator:orch,focused:activePane==="workspace",onRequestFocus:()=>focus.setFocused("workspace"),onEditorTabReady:editor.onEditorTabReady,onEngineSendReady:editor.onEngineSendReady,onEnginePasteReady:editor.onEnginePasteReady,onDiffTabReady:editor.onDiffTabReady,onSpawnChild:quickFork.onSpawnChild,onQuickFork:quickFork.onQuickFork,initialPrompt:quickFork.initialPromptFor(selectedTask?.id),onTabVisited:inbox.resolveVisited,onScratchExit:scratch.onScratchExit,onOpenScratch:scratch.openScratchShell,onEngineChosen:taskActions.setVendor,onOpenSettings:pages.openSettings})})})]}):null,!zen&&pageRender.contentPage==null&&pageRender.showSidebar&&pageRender.showContent?$jsx(HostFilesPane,{sidebarWidth:sidebarWidth.width,worktree,prBaseRef:selectedTask?.prStatus?.baseRef,focused:activePane==="files",actions:filesActions,taskKind:selectedTask?.kind,remoteHost:selectedTask?.origin&&selectedTask.origin.machineId!=="local"?selectedTask.origin.hostLabel:void 0,remote:selectedTask?.origin&&selectedTask.origin.machineId!=="local"&&!selectedTask.origin.stale?{machine:selectedTask.origin.machineId,taskId:String(selectedTask.id)}:void 0}):null,$jsx(ToastOverlay,{}),$jsx(PrefixHud,{left:1,width:sidebarWidth.width-2}),pageRender.showSidebar&&pageRender.showContent&&!sidebarCollapsed?$jsx(SidebarResizeGrip,{width:sidebarWidth.width,onGripDown:sidebarResize.onGripDown}):null]})}async function startWorkspaceHost(opts={}){await bootPaneHost({logContext:"workspace",providers:{kv:!0,focus:!0,notifications:!0},setup:async()=>{let cellPixelSize=await queryCellPixelSize({stdin:process.stdin,stdout:process.stdout}),client=await connectOrStartDaemon(),channels=CHANNEL_NAMES.filter((name)=>name!=="state"),orchestrator=new RemoteOrchestrator(client,{role:"gui",cellPixelSize,channels});await orchestrator.init(),process.env.ROVE_DAEMON_SOCKET_PATH=client.socketPath,installTerminalGraphics(createTerminalGraphics({env:process.env,stdoutIsTTY:process.stdout.isTTY===!0,cellPixelSize,write:(data)=>orchestrator.writeGraphics(data)}));let{MachineFeed}=await import("./chunk-e2zv4b2x.js"),{setMachineHub}=await import("./chunk-wv6d96t6.js"),machines=new MachineFeed(orchestrator);setMachineHub(machines);let stopRemoteStatus=followRemoteActivity(machines.liveSignal());registerCorePages();let stopModsPage=registerModsPage(orchestrator);registerBundledPlugins();let stopBundledPlugins=followBundledPlugins();return loadPluginPages(),{root:()=>$jsx(WorkspaceRoot,{orchestrator,whatsNewFrom:opts.whatsNewFrom??null,welcome:opts.welcome??null}),onDestroy:()=>{stopBundledPlugins(),stopModsPage(),stopRemoteStatus(),setMachineHub(null),machines.dispose(),orchestrator.dispose(),installTerminalGraphics(null),getDefaultPtyRegistry().detachAll()}}}})}export{startWorkspaceHost};
|
|
97
|
+
`)}function useInboxHost(args){let{orchestrator:orch}=args,tabsRev=useAccessor(tabsRevision),{availableItems,unavailableItems}=import_react128.useMemo(()=>{return partitionAttentionInboxAvailability(args.items,args.tasks,(taskId,tabId)=>taskTabExists(args.kv,taskId,tabId))},[args.items,args.tasks,args.kv,tabsRev]),viewingResolved=args.selectedId?new Set(visitResolvedEpisodes(availableItems,{taskId:args.selectedId,tabId:activeTabIdFor(args.selectedId)}).map(episodeKey)):null,visibleItems=viewingResolved&&viewingResolved.size>0?availableItems.filter((item)=>!viewingResolved.has(episodeKey(item))):availableItems,counts=attentionInboxCounts(visibleItems),notifyErrorRef=useLatest(args.notifyError),unavailableItemsRef=useLatest(unavailableItems),unavailableSignature=episodeSignature(unavailableItems),attemptedUnavailable=import_react128.useRef(new Set);import_react128.useEffect(()=>{let currentItems=unavailableItemsRef.current;if(episodeSignature(currentItems)!==unavailableSignature)return;let currentKeys=new Set(currentItems.map(episodeKey));for(let attempted of attemptedUnavailable.current)if(!currentKeys.has(attempted))attemptedUnavailable.current.delete(attempted);for(let item of currentItems){let key=episodeKey(item);if(attemptedUnavailable.current.has(key))continue;attemptedUnavailable.current.add(key),notifyInboxRpcFailure(dismissEpisode(item,orch),"dismiss",notifyErrorRef.current)}},[unavailableSignature,orch]);function openItem(item,knownAvailable){if(isRoutineInboxState(item.state)){if(notifyInboxRpcFailure(dismissEpisode(item,orch),"dismiss",args.notifyError),args.dialog.stack.length>0)args.dialog.clear({refocus:!1});args.openAutomations();return}let gate=item.state==="decision_needed"?item.detail?.gate:void 0;if(gate&&!gate.undelivered&&item.taskId!==null){let taskTitle=orch.getTask(item.taskId)?.title??item.taskId;GateDecisionDialog.show(args.dialog,{gate,taskTitle}).then((answer)=>{if(!answer)return;orch.answerGate(gate.id,answer).catch((err)=>args.notifyError(t("gates.toast.answerFailed",{error:userFacingErrorMessage(err)})))});return}let taskId=item.taskId;if(taskId===null)return;let task=orch.getTask(taskId),available=knownAvailable??isAttentionInboxItemAvailable(item,task,(tabId)=>taskTabExists(args.kv,taskId,tabId));if(!requestInboxItemOpen(item,available,orch,args.notifyError))return;if(args.dialog.stack.length>0)args.dialog.clear({refocus:!1});if(args.selectTask(taskId),item.tabId)requestTabActivation(taskId,item.tabId);args.focusWorkspace()}function openTask(taskId,tabId){if(args.dialog.stack.length>0)args.dialog.clear({refocus:!1});if(args.selectTask(taskId),tabId)requestTabActivation(taskId,tabId);args.focusWorkspace()}function closeItem(item){let gate=item.state==="decision_needed"?item.detail?.gate:void 0;if(!gate){notifyInboxRpcFailure(dismissEpisode(item,orch,!0),"dismiss",args.notifyError);return}if(!gate.undelivered)return;orch.withdrawGate(gate.id).catch((err)=>args.notifyError(t("gates.toast.withdrawFailed",{error:userFacingErrorMessage(err)})))}function show16(){AttentionInboxDialog.show(args.dialog,{orchestrator:orch,selectedId:args.selectedId,onOpen:openItem,onOpenTask:openTask,onDelete:closeItem})}let availableItemsRef=useLatest(availableItems),availableSignature=episodeSignature(availableItems),selectedIdRef=useLatest(args.selectedId),attemptedResolved=import_react128.useRef(new Set),resolveEpisodes=import_react128.useCallback((items,visit)=>{let currentKeys=new Set(items.map(episodeKey));for(let attempted of attemptedResolved.current)if(!currentKeys.has(attempted))attemptedResolved.current.delete(attempted);for(let item of visitResolvedEpisodes(items,visit)){let key=episodeKey(item);if(attemptedResolved.current.has(key))continue;attemptedResolved.current.add(key),notifyInboxRpcFailure(dismissEpisode(item,orch),"dismiss",notifyErrorRef.current)}},[orch]);function resolveVisited(taskId,tabId){resolveEpisodes(availableItemsRef.current,{taskId,tabId}),writeInboxVisit(args.kv,{taskId,tabId,at:Date.now()})}return import_react128.useEffect(()=>{let currentItems=availableItemsRef.current;if(episodeSignature(currentItems)!==availableSignature)return;let selectedId=selectedIdRef.current;if(!selectedId)return;let activeTab=activeTabIdFor(selectedId);if(!activeTab)return;resolveEpisodes(currentItems,{taskId:selectedId,tabId:activeTab})},[availableSignature,resolveEpisodes]),{availableItems:visibleItems,counts,openItem,show:show16,resolveVisited}}function buildIssueChatBackgroundSpawn(input){let base=interactiveEngineCommand(input.vendor),{sessionId}=withPinnedSessionId(base,input.vendor),fresh=initialTabs(),tab={...fresh.tabs[0],sessionId},state={...fresh,tabs:[tab]},spawn3=engineTabSpawnFor(state,tab,base,{live:!1,shell:input.shell??defaultShell(),prompt:input.prompt??issueWorktreePrompt(input.issue,input.api),task:{id:input.taskId,kind:input.kind??"task",vendor:input.vendor,repo:input.repoRoot},worktreePath:input.worktreePath,inlineImages:terminalDrawsKitty()});return{ptyKey:tabPtyKey(input.taskId,tab.id),command:spawn3.command,initialInput:spawn3.initialInput,firstMessage:spawn3.firstMessage,engineBin:spawn3.engineBin,tabsSnapshot:setTabSpawned(state,tab.id,!0)}}function useIssueChat(orch,hooks){let t3=useT();async function enter(taskId){hooks.closeKanban(),hooks.selectTask(taskId),await hooks.enterTask(taskId)}async function finish(request,enterTaskId){if(request.jump)await enter(enterTaskId);else hooks.notifyInfo(t3("kanban.detail.startedBackground",{title:issueChatTaskTitle(request.issue)}))}async function startProjectTab(request,api){let{repoRoot,issue,vendor}=request,main=await orch.ensureMainTask(repoRoot);await orch.mutateIssue(repoRoot,{type:"setStatus",id:issue.id,status:"doing"}).catch((err)=>{console.error("[rove kanban] issue setStatus failed:",err),hooks.notifyError(t3("kanban.statusFailed",{id:String(issue.id),error:userFacingErrorMessage(err)}))});let{task:child}=await orch.spawnChildTask({parentTaskId:main.id,worktree:!1,vendor}),spawn3=buildIssueChatBackgroundSpawn({issue,taskId:child.id,repoRoot,worktreePath:taskCwd(child),vendor,api,kind:child.kind,prompt:issueProjectPrompt(issue,api)});getDefaultPtyRegistry().acquire(spawn3.ptyKey,taskCwd(child),{command:spawn3.command,initialInput:spawn3.initialInput,firstMessage:spawn3.firstMessage,engineBin:spawn3.engineBin}),setTaskTabs2(child.id,spawn3.tabsSnapshot),await finish(request,child.id)}async function startWorktreeTask(request,api){let{repoRoot,issue,vendor}=request;setRepoLastActiveVendor(repoRoot,vendor),addSavedRepo(repoRoot);let task=await orch.createTask({repo:repoRoot,title:issueChatTaskTitle(issue),vendor});await orch.mutateIssue(repoRoot,{type:"link",id:issue.id,taskId:task.id}).catch((err)=>{console.error("[rove kanban] issue link failed:",err),hooks.notifyError(t3("kanban.linkFailed",{id:String(issue.id),error:userFacingErrorMessage(err)}))});let worktreePath=await orch.ensureWorktree(task.id),spawn3=buildIssueChatBackgroundSpawn({issue,taskId:task.id,repoRoot,worktreePath,vendor,api});return getDefaultPtyRegistry().acquire(spawn3.ptyKey,worktreePath,{command:spawn3.command,initialInput:spawn3.initialInput,firstMessage:spawn3.firstMessage,engineBin:spawn3.engineBin}),setTaskTabs2(task.id,spawn3.tabsSnapshot),{task,worktreePath,tab:spawn3.tabsSnapshot.tabs[0]}}async function start(request){try{let api=roveApiInvocation();if(request.placement==="project"){await startProjectTab(request,api);return}let{task,worktreePath,tab}=await startWorktreeTask(request,api);if(request.placement==="projectWorktree"){let main=await orch.ensureMainTask(request.repoRoot);await appendBackgroundEngineTab(main.id,{vendor:request.vendor,sessionId:tab.sessionId??null,ptyTask:{id:task.id,worktree:worktreePath}}),await finish(request,main.id);return}await finish(request,task.id)}catch(err){hooks.notifyError(t3("tasks.toast.issueChatFailed",{error:userFacingErrorMessage(err)}))}}return{start}}var import_react129=__toESM(require_react_production(),1);function usePrCheckNotifier(args){let notif=useLatest(args.notif),t3=useLatest(useT()),prev=import_react129.useRef(new Map);import_react129.useEffect(()=>{let next=new Map;for(let task of args.tasks){let pr=rollupPr(task),state=pr?.checkState;if(state===void 0)continue;next.set(task.id,state);let landed2=checkResolutionNotify(prev.current.get(task.id),state);if(!landed2)continue;notif.current.notify({kind:landed2==="passing"?"done":"error",taskId:task.id,tabId:"",title:t3.current(landed2==="passing"?"tasks.toast.checksPassingTitle":"tasks.toast.checksFailingTitle",{title:task.title}),body:t3.current("tasks.toast.checksResolvedBody",{pr:pr?.number===void 0?"\u2014":`#${pr.number}`,branch:task.branch||"\u2014"})})}prev.current=next},[args.tasks])}import{homedir}from"os";var import_react130=__toESM(require_react_production(),1);function decideScratchAdopt(input){if(!input.repoRoot||!input.harnessLive)return{kind:"stay"};let owners=input.ownerTasks.filter((task)=>task.dir!==""&&!task.sharesWorkspaceOf);if(input.cwd){let cwd=input.cwd,managed=owners.find((task)=>task.kind==="task"&&pathWithin(task.dir,cwd)!==null);if(managed)return{kind:"fold",taskId:managed.id}}for(let kind of["main","dir"]){let owned=owners.find((task)=>task.kind===kind&&(samePath(task.dir,input.cwd)||samePath(task.dir,input.repoRoot)));if(owned)return{kind:"fold",taskId:owned.id}}return{kind:"adopt",repo:input.repoRoot,known:[...input.knownRepos].some((repo)=>samePath(repo,input.repoRoot))}}async function renameHostedSession(from,to){if((process.env.ROVE_TERMINAL_BACKEND??"hosted")!=="hosted")return!1;try{return(await(await getSharedPtyClient()).request("pty.rename",{from,to})).renamed===!0}catch{return!1}}var tabNumber=(id)=>Number(/^tab-(\d+)$/.exec(id)?.[1]??0);async function foldScratchShell(io,scratchTaskId,targetTaskId){let rename=io.rename??renameHostedSession,scratchTabIds=(knownTaskTabs(io.kv,scratchTaskId)?.tabs??[{id:"tab-1"}]).map((tab)=>tab.id),reserved=await(io.reserve??reserveTabOrdinals)(targetTaskId,scratchTabIds.length*2).catch(()=>null),fallback=1+(knownTaskTabs(io.kv,targetTaskId)?.tabs??[]).reduce((max,tab)=>Math.max(max,tabNumber(tab.id)),0),nextId=()=>`tab-${reserved?.shift()??fallback++}`,folded=[];for(let tabId of scratchTabIds){let from=tabPtyKey(scratchTaskId,tabId),to=nextId(),ok=await rename(from,tabPtyKey(targetTaskId,to));if(!ok)to=nextId(),ok=await rename(from,tabPtyKey(targetTaskId,to));if(!ok)continue;folded.push(to)}if(folded.length===0)return null;return adoptTaskTabs(io.kv,targetTaskId,folded),{activeTabId:folded[0]}}var POLL_MS5=5000;function scratchOwnerTasks(tasks2){return tasks2.filter((task)=>!task.deletion&&task.scratch!==!0&&task.worktreePath!=="").map((task)=>({id:task.id,kind:task.kind??"task",dir:canonPath(task.worktreePath),...task.sharesWorkspaceOf?{sharesWorkspaceOf:task.sharesWorkspaceOf}:{}}))}function useScratchAdopt(deps){let{tasks:tasks2,orchestrator,kv,notifyInfo}=deps,onFoldRef=useLatest(deps.onFold),enabled=deps.enabled??!0,scratchIds=tasks2.filter((t3)=>t3.kind==="dir"&&t3.scratch===!0).map((t3)=>t3.id).join(",");import_react130.useEffect(()=>{if(!enabled||scratchIds==="")return;let cancelled=!1,inFlight=new Set,tick3=async()=>{let scratch=tasks2.filter((t3)=>t3.kind==="dir"&&t3.scratch===!0);if(scratch.length===0)return;let known=new Set([...getSavedRepos(),...tasks2.map((t3)=>t3.repo)]),owners=scratchOwnerTasks(tasks2),registry=getDefaultPtyRegistry(),liveEngines=getDefaultLiveEngines();for(let task of scratch){if(inFlight.has(task.id))continue;let key=tabPtyKey(task.id,"tab-1"),pid=registry.get(key)?.shellPid??null;if(pid===null||pid===void 0)continue;if(!liveEngines.get(key))continue;let rawCwd=await processCwd(pid);if(cancelled||!rawCwd)continue;let cwd=canonPath(rawCwd),repoRoot=canonPath(resolveMainRepoRoot(cwd)),decision=decideScratchAdopt({cwd,repoRoot:isGitRepo(repoRoot)?repoRoot:null,harnessLive:!0,knownRepos:known,ownerTasks:owners});if(cancelled||decision.kind==="stay")continue;inFlight.add(task.id);try{if(decision.kind==="fold"){let folded=await foldScratchShell({kv},task.id,decision.taskId);if(!folded)throw Error("fold did not move any session");await onFoldRef.current(task.id,decision.taskId,folded.activeTabId);continue}if(await orchestrator.adoptScratchRepo(task.id,decision.repo),!decision.known)notifyInfo(t("tasks.toast.scratchAdopted",{repo:repoBasename(decision.repo)}))}catch{inFlight.delete(task.id)}}};tick3();let timer3=setInterval(()=>void tick3(),POLL_MS5);return()=>{cancelled=!0,clearInterval(timer3)}},[enabled,scratchIds,orchestrator,kv,notifyInfo,tasks2])}var scratchTeardowns=new Set;function useScratchShell(deps){let{orchestrator,enterTask,forgetTaskTabs:forgetTaskTabs2,notifyError}=deps;return useScratchAdopt({tasks:deps.tasks,orchestrator,kv:deps.kv,notifyInfo:deps.notifyInfo,onFold:async(scratchTaskId,targetTaskId,tabId)=>{if(deps.selectedId()===scratchTaskId)deps.selectTask(targetTaskId),requestTabActivation(targetTaskId,tabId);await orchestrator.deleteTask(scratchTaskId),forgetTaskTabs2(scratchTaskId)}}),{openScratchShell:(vendor)=>{orchestrator.openDirectoryTask({dir:homedir(),scratch:!0,...vendor?{vendor}:{}}).then((task)=>{if(vendor)engineScratchTasks.add(task.id);enterTask(task.id)}).catch((err)=>notifyError(t("tasks.toast.scratchOpenFailed",{message:userFacingErrorMessage(err)})))},onScratchExit:(taskId)=>{if(scratchTeardowns.has(taskId))return;scratchTeardowns.add(taskId),(async()=>{try{await orchestrator.deleteTask(taskId),forgetTaskTabs2(taskId),await finishDeletedTaskFlow({orch:orchestrator,tasks:deps.tasks,taskId,logger:console,logPrefix:"[rove scratch]",updateActiveTask:!0})}catch(err){notifyError(t("tasks.toast.scratchCloseFailed",{message:userFacingErrorMessage(err)}))}})()}}}var import_react131=__toESM(require_react_production(),1);function activationErrorMessage(error,translate){let message=errorMessage(error);if(message.includes(TASK_DELETING_CODE))return translate("tasks.toast.worktreeErrorDeleting");if(/not a git repository|does not appear to be a git repo/i.test(message))return translate("tasks.toast.worktreeErrorNotGit");return translate("tasks.toast.worktreeErrorGeneric",{message:userFacingErrorMessage(error)})}async function activateWorkspaceTask(opts,id){let task=opts.getTask(id);if(task?.deletion)return opts.reportError(new TaskDeletingError(id)),!1;if(task?.origin&&task.origin.machineId!=="local")return opts.selectTask(id),opts.focusWorkspace(),!0;if(!task?.worktreePath)try{await opts.ensureWorktree(id)}catch(error){return opts.reportError(error),!1}if(opts.isCurrent?.()===!1)return!1;return opts.selectTask(id),opts.focusWorkspace(),!0}function firstSelectableTask(tasks2,activeId,lastActiveId){let alive=(id)=>id?tasks2.find((task)=>task.id===id&&!task.deletion):void 0,active=alive(activeId)??alive(lastActiveId);if(active)return active;let live=tasks2.filter((task)=>!task.deletion),newest=(pool)=>pool.length>0?pool.reduce((best,task)=>task.updatedAt>best.updatedAt?task:best):void 0;return newest(live.filter((task)=>task.routine===void 0))??newest(live)??tasks2.find((task)=>!task.deletion)}function useWorkspaceSelection(args){let{orch,tasks:tasks2,activeTaskId,kv}=args,t3=useT(),[selectedId,setSelectedId]=import_react131.useState(()=>orch.activeTaskSignal()()??readLastActiveTaskId()),focusRestoredRef=import_react131.useRef(!1),userPickedRef=import_react131.useRef(!1),bootFocusRef=import_react131.useRef(!1),liveSelectedRef=import_react131.useRef(null);import_react131.useEffect(()=>{if(!focusRestoredRef.current&&activeTaskId&&tasks2.some((task)=>task.id===activeTaskId)){if(focusRestoredRef.current=!0,!userPickedRef.current&&selectedId!==activeTaskId){setSelectedId(activeTaskId);return}}if(!bootFocusRef.current&&!userPickedRef.current&&selectedId&&tasks2.some((task)=>task.id===selectedId))bootFocusRef.current=!0,args.focusWorkspace();let selected=selectedId?tasks2.find((task)=>task.id===selectedId):void 0,wasLive=selectedId!==null&&liveSelectedRef.current===selectedId;if(liveSelectedRef.current=selected&&selected.archived!==!0&&!selected.deletion?selectedId:null,wasLive&&selected?.archived===!0){setSelectedId(firstSelectableTask(tasks2.filter((task)=>task.archived!==!0),null)?.id??null);return}if(selectedId&&tasks2.some((task)=>task.id===selectedId&&!task.deletion))return;setSelectedId(firstSelectableTask(tasks2,activeTaskId,readLastActiveTaskId())?.id??null)},[tasks2,activeTaskId,selectedId,args.focusWorkspace]);let notifyWorktreeGoneRef=useLatest(args.notifyWorktreeGone),liveTaskIdsRef=import_react131.useRef(new Set),worktreePathsRef=import_react131.useRef(new Map);import_react131.useEffect(()=>{let next=new Set(tasks2.filter((task)=>!task.deletion).map((task)=>task.id)),registry=getDefaultPtyRegistry(),aliased=aliasedKeys(tasks2.filter((task)=>!task.deletion));for(let id of liveTaskIdsRef.current){if(next.has(id))continue;registry.releaseWhere((key)=>(key===id||key.startsWith(`${id}::`))&&!aliased.some((base)=>isUnderKey(key,base)))}liveTaskIdsRef.current=next;let paths=new Map;for(let task of tasks2)paths.set(task.id,task.worktreePath);for(let[id,prevPath]of worktreePathsRef.current)if(paths.get(id)===""&&prevPath!==""){let closed=knownTaskTabs(kv,id)?.tabs.length??0;registry.releaseWhere((key)=>key===id||key.startsWith(`${id}::`)),forgetTaskTabs(kv,id);let task=tasks2.find((candidate)=>candidate.id===id);notifyWorktreeGoneRef.current?.({taskId:id,title:task?.title??id,branch:task?.branch??"",closed})}worktreePathsRef.current=paths},[tasks2,kv]);function selectTask(id){if(userPickedRef.current=!0,selectedId===id){if(orch.activeTaskSignal()()!==id)orch.setActiveTask(id).catch((error)=>console.error("[rove workspace] setActiveTask failed:",error));return}setSelectedId(id),orch.setActiveTask(id).catch((error)=>console.error("[rove workspace] setActiveTask failed:",error));let kind=tasks2.find((task)=>task.id===id)?.kind==="main"?"project.opened":"task.opened";orch.reportUiEvent(kind,id)}let activationGenerationRef=import_react131.useRef(0);async function activateTask(id){let generation=++activationGenerationRef.current;reviveEmptiedTabs(kv,id,defaultShell()),await activateWorkspaceTask({getTask:(taskId)=>tasks2.find((task)=>task.id===taskId),ensureWorktree:(taskId)=>orch.ensureWorktree(taskId),selectTask,focusWorkspace:args.focusWorkspace,reportError:(error)=>{console.error("[rove workspace] task.ensureWorktree failed:",error),args.notifyError?.(activationErrorMessage(error,t3))},isCurrent:()=>activationGenerationRef.current===generation},id)}let selectedTask=selectedId?tasks2.find((task)=>task.id===selectedId):void 0;return{selectedId,setSelectedId,selectedTask,selectTask,activateTask}}var import_react132=__toESM(require_react_production(),1);function useZenMode(deps){let{kv,focus}=deps,[zen,setZen]=import_react132.useState(()=>kv.get(ZEN_ACTIVE_KEY,ZEN_DEFAULT)===!0);function toggleZen(){let next=!zen;if(setZen(next),kv.set(ZEN_ACTIVE_KEY,next),next)focus.setFocused("workspace")}return import_react132.useEffect(()=>{if(focus.focused==="files")setZen(!1)},[focus.focused]),{zen,toggleZen}}function WorkspaceRoot(props){let{theme}=useTheme(),inactiveBorder=theme.borderActive,dialog=useDialog(),kv=useKV(),focus=useFocus(),dims=useTerminalSize(),sidebarWidth=useSidebarWidth(),[sidebarCollapsed]=useSidebarCollapsed(),sidebarResize=useSidebarResizeGesture({width:sidebarWidth.width,onResize:sidebarWidth.pin,onReset:sidebarWidth.reset}),renderer=useRenderer(),notif=useNotifications(),orch=props.orchestrator;useDaemonNotices(orch,notif.notify,dialog);let{tasks:tasks2,activeTaskId,engineState,engineLifecycle,engineTabState,inboxItems,taskJobs,rowTokens,worktreeChanges:worktreeChanges2}=useDaemonState(orch),[searchActive,setSearchActive]=import_react134.useState(!1),t3=useT(),{notifyError,notifyInfo,notifyNeedsInput,notifyWorktreeGone}=useHostNotifiers({notif,t:t3,selectedId:()=>selectedId}),{selectedId,setSelectedId,selectedTask,selectTask,activateTask}=useWorkspaceSelection({orch,tasks:tasks2,activeTaskId,focusWorkspace:()=>focus.setFocused("workspace"),kv,notifyWorktreeGone,notifyError}),worktree=selectedTask?.worktreePath||null,workingFlow=selectedId!==null&&engineState?.get(selectedId)?.state==="running"&&normalizeWorkingBorder(kv.get(WORKING_BORDER_KEY,DEFAULT_WORKING_BORDER))==="flow",breath=useSpinnerFrame(workingFlow),taskInk=useTaskColor(selectedId),{sortMode,toggleSortMode,moveMode,setMoveMode,onLocalMergeRequest}=useSidebarHostState({kv,tasks:tasks2,focusSidebar:()=>focus.setFocused("sidebar"),notify:notifyInfo}),inbox=useInboxHost({orchestrator:orch,items:inboxItems,tasks:tasks2,kv,dialog,selectedId,selectTask,openAutomations:()=>pages.openPage("automations"),focusWorkspace:()=>focus.setFocused("workspace"),notifyError}),{jumpToNextAttention}=useAttention({tasks:tasks2,engineState,engineTabState,inboxItems:inbox.availableItems,selectedId,kv,notif,openAttention:inbox.openItem,noTasksMessage:t3("workspace.attention.none")});usePrCheckNotifier({tasks:tasks2,notif});let taskActions=useWorkspaceTaskActions({orchestrator:orch,tasks:()=>tasks2,dialog,notifyError,notifyInfo,notifyNeedsInput,t:t3,selectedId:()=>selectedId,setSelectedId,selectedTask:()=>selectedTask,activateTask,forgetTaskTabs:(id)=>forgetTaskTabs(kv,id),closeTaskTabs:(id)=>closeAllTaskTabs(kv,id),startWithPrompt:(repo,start)=>quickFork.onQuickFork(repo,{...start,attachments:[],attempts:1})}),editor=useEditorHandles({orchestrator:orch,worktree,selectedId,focus,notifyError,activateTask}),quickFork=useQuickFork(orch,{selectTask:setSelectedId,enterTask:activateTask,notifyError,notify:notifyInfo,t:t3}),scratch=useScratchShell({orchestrator:orch,tasks:tasks2,kv,selectedId:()=>selectedId,selectTask:setSelectedId,enterTask:(id)=>void activateTask(id),forgetTaskTabs:(id)=>forgetTaskTabs(kv,id),notifyError,notifyInfo}),{zen,toggleZen}=useZenMode({kv,focus}),filesActions=useFilesPaneActions({onOpenFile:(relPath)=>void editor.onOpenFile(relPath),onOpenDiff:editor.onOpenDiff,onMention:editor.onMention,onZenToggle:toggleZen,onCreatePR:()=>void editor.onCreatePR()});import_react134.useEffect(()=>{return setUiEventReporter((kind,taskId,detail)=>orch.reportUiEvent(kind,taskId,detail)),()=>setUiEventReporter(null)},[orch]),useTabsSync(orch.tabs,orch.connectionStateSignal()),useRowStatusSync(orch.rowStatus,orch.connectionStateSignal());let pages=useHostPagesState(focus,props);useWhatsNewDialog(pages.whatsNewFrom,pages.closeWhatsNew),useWelcomeDialog(pages.welcome,pages.closeWelcome);let selectedTabId=selectedId===null?null:activeTabIdFor(selectedId),issueChat=useIssueChat(orch,{selectTask:setSelectedId,enterTask:activateTask,closeKanban:pages.closePage,notifyError,notifyInfo}),pageRender=useHostPagesRender({orchestrator:orch,pages,focus,dialog,kv,dims,selectedTask,activeTaskId,tasks:tasks2,engineState,activateTask}),openTaskWorktree=(id)=>openTaskWorktreeFor(id,{tasks:tasks2,ensureWorktree:orch.ensureWorktree.bind(orch),notifyError}),cursorTaskIdRef=import_react134.useRef(()=>null),banner=useHostBanner(orch,dims.width),refreshRove=()=>{selfRefreshAction({orchestrator:orch,renderer,confirm:()=>DialogConfirm.show(dialog,t3("update.refresh.confirmTitle"),t3("update.refresh.confirmBody"),t3("common.cancel"),t3("update.refresh.confirmLabel")).then((ok)=>ok===!0),notifyError,t:t3},banner.refresh.inputs)};useWorkspaceKeybindings({focus,dialog,pages,filesPaneVisible:!zen&&pages.nav==="terminal"&&pageRender.showSidebar&&pageRender.showContent,searchActive,selectedId,cursorTaskId:()=>cursorTaskIdRef.current(),openTaskWorktree,createTask:()=>void taskActions.createTask(),renameBranch:(id)=>void taskActions.renameBranch(id),cycleVendor:(id)=>void taskActions.cycleVendor(id),toggleZen,jumpToNextAttention,openInbox:inbox.show,paletteSearch:{orchestrator:orch,tasks:tasks2,openTask:openTaskOnTab(pages.closePage,activateTask)},createPR:()=>void editor.onCreatePR(),createPRFor:(id)=>{requestCreatePR(id),activateTask(id)},fixChecksFor:editor.onFixChecks,syncBaseFor:(id)=>void taskActions.syncBase(id),enterMoveMode:()=>{let target=selectedId??tasks2[0]?.id;if(!target)return;focus.setFocused("sidebar"),setSelectedId(String(target)),setMoveMode(!0)},toggleSortMode,refresh:{available:banner.refresh.available,run:refreshRove}});let activePane=dialog.stack.length>0?null:focus.focused,fullWindow=pageRender.settingsPage??pageRender.fullWindowPage,contentPageType=import_react134.isValidElement(pageRender.contentPage)?pageRender.contentPage.type:null;if(fullWindow)return $jsx(FullWindowPage,{banner:banner.element,background:theme.background,children:$jsx(PaneErrorBoundary,{region:"page",children:fullWindow})});return $jsxs(WorkspaceFrame,{orchestrator:orch,onOpenSettings:()=>pages.openSettings(),banner:banner.element,activeTaskId:selectedId,activeTabId:selectedTabId,onPaneDrag:sidebarResize.onPaneDrag,onPaneRelease:sidebarResize.onPaneRelease,children:[pageRender.showSidebar?$jsx(RenderProfiler,{id:"sidebar",children:$jsx(PaneErrorBoundary,{region:"sidebar",width:pageRender.showContent?sidebarWidth.width:dims.width,children:$jsx(HostSidebarMount,{terminalWidth:dims.width,showContent:pageRender.showContent,recentTask:pageRender.recentTask,tasks:tasks2,selectedId,selectTask,activateTask,daemon:{engineState,engineTabState,engineLifecycle,taskJobs,rowTokens,worktreeChanges:worktreeChanges2},actions:taskActions,pages,focus,inbox,update:banner.update,onFixChecks:editor.onFixChecks,onResolveConflicts:editor.onResolveConflicts,runAgain:quickFork.runAgain,openScratch:scratch.openScratchShell,activePane,zen,toggleZen,sortMode,moveMode,exitMoveMode:()=>setMoveMode(!1),onLocalMergeRequest,onSearchActiveChange:setSearchActive,cursorTaskIdRef,openTaskWorktree,t:t3})})}):null,pageRender.showContent?$jsxs("box",{flexGrow:1,flexShrink:1,borderStyle:"rounded",borderColor:focus.focused==="workspace"?theme.focusAccent:inactiveBorder,renderAfter:workingFlow?runningPaneFlow(taskInk??theme.focusAccent,inactiveBorder,focus.focused==="workspace",breath,taskInk?TASK_PARTNER_HUE_DEG:void 0):void 0,title:workingFlow&&selectedTask?runningPaneTitle(selectedTask.title,t3("workspace.inbox.state.running")):void 0,onMouseUp:()=>focus.setFocused("workspace"),children:[isNarrowWidth(dims.width)?$jsx(NarrowBackBar,{onBack:()=>focus.setFocused("sidebar")}):null,$jsx(PaneErrorBoundary,{region:"workspace",resetKeys:[selectedId,contentPageType],children:pageRender.contentPage?$jsx(PageServicesProvider,{value:{startIssueChat:issueChat.start},children:pageRender.contentPage}):$jsx(RenderProfiler,{id:"workspace",children:$jsx(ShowWorkspace,{task:selectedTask,worktree,orchestrator:orch,focused:activePane==="workspace",onRequestFocus:()=>focus.setFocused("workspace"),onEditorTabReady:editor.onEditorTabReady,onEngineSendReady:editor.onEngineSendReady,onEnginePasteReady:editor.onEnginePasteReady,onDiffTabReady:editor.onDiffTabReady,onSpawnChild:quickFork.onSpawnChild,onQuickFork:quickFork.onQuickFork,initialPrompt:quickFork.initialPromptFor(selectedTask?.id),onTabVisited:inbox.resolveVisited,onScratchExit:scratch.onScratchExit,onOpenScratch:scratch.openScratchShell,onEngineChosen:taskActions.setVendor,onOpenSettings:pages.openSettings})})})]}):null,!zen&&pageRender.contentPage==null&&pageRender.showSidebar&&pageRender.showContent?$jsx(HostFilesPane,{sidebarWidth:sidebarWidth.width,worktree,prBaseRef:selectedTask?.prStatus?.baseRef,focused:activePane==="files",actions:filesActions,taskKind:selectedTask?.kind,remoteHost:selectedTask?.origin&&selectedTask.origin.machineId!=="local"?selectedTask.origin.hostLabel:void 0,remote:selectedTask?.origin&&selectedTask.origin.machineId!=="local"&&!selectedTask.origin.stale?{machine:selectedTask.origin.machineId,taskId:String(selectedTask.id)}:void 0}):null,$jsx(ToastOverlay,{}),$jsx(PrefixHud,{left:1,width:sidebarWidth.width-2}),pageRender.showSidebar&&pageRender.showContent&&!sidebarCollapsed?$jsx(SidebarResizeGrip,{width:sidebarWidth.width,onGripDown:sidebarResize.onGripDown}):null]})}async function startWorkspaceHost(opts={}){await bootPaneHost({logContext:"workspace",providers:{kv:!0,focus:!0,notifications:!0},setup:async()=>{let cellPixelSize=await queryCellPixelSize({stdin:process.stdin,stdout:process.stdout}),client=await connectOrStartDaemon(),channels=CHANNEL_NAMES.filter((name)=>name!=="state"),orchestrator=new RemoteOrchestrator(client,{role:"gui",cellPixelSize,channels});await orchestrator.init(),process.env.ROVE_DAEMON_SOCKET_PATH=client.socketPath,installTerminalGraphics(createTerminalGraphics({env:process.env,stdoutIsTTY:process.stdout.isTTY===!0,cellPixelSize,write:(data)=>orchestrator.writeGraphics(data)}));let{MachineFeed}=await import("./chunk-7aaw17vr.js"),{setMachineHub}=await import("./chunk-wv6d96t6.js"),machines=new MachineFeed(orchestrator);setMachineHub(machines);let stopRemoteStatus=followRemoteActivity(machines.liveSignal());registerCorePages();let stopModsPage=registerModsPage(orchestrator);registerBundledPlugins();let stopBundledPlugins=followBundledPlugins();return loadPluginPages(),{root:()=>$jsx(WorkspaceRoot,{orchestrator,whatsNewFrom:opts.whatsNewFrom??null,welcome:opts.welcome??null}),onDestroy:()=>{stopBundledPlugins(),stopModsPage(),stopRemoteStatus(),setMachineHub(null),machines.dispose(),orchestrator.dispose(),installTerminalGraphics(null),getDefaultPtyRegistry().detachAll()}}}})}export{startWorkspaceHost};
|