waterplane 0.1.6 → 0.1.14
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/CHANGELOG.md +146 -1
- package/README.md +47 -24
- package/SECURITY.md +11 -3
- package/deploy/node-version +1 -1
- package/node_modules/@waterplane/shared/dist/agentfiles.d.ts +17 -0
- package/node_modules/@waterplane/shared/dist/agentfiles.js +60 -5
- package/node_modules/@waterplane/shared/dist/agentfiles.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/alwaysonwords.d.ts +83 -0
- package/node_modules/@waterplane/shared/dist/alwaysonwords.js +215 -0
- package/node_modules/@waterplane/shared/dist/alwaysonwords.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/assess/sasswords.js +4 -0
- package/node_modules/@waterplane/shared/dist/assess/sasswords.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/autocompact.js +3 -2
- package/node_modules/@waterplane/shared/dist/autocompact.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/backendsources.d.ts +11 -1
- package/node_modules/@waterplane/shared/dist/backendsources.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/branchmode.d.ts +33 -0
- package/node_modules/@waterplane/shared/dist/branchmode.js +88 -0
- package/node_modules/@waterplane/shared/dist/branchmode.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/budget.d.ts +7 -1
- package/node_modules/@waterplane/shared/dist/budget.js +11 -3
- package/node_modules/@waterplane/shared/dist/budget.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/buildstamp.d.ts +37 -0
- package/node_modules/@waterplane/shared/dist/buildstamp.js +95 -0
- package/node_modules/@waterplane/shared/dist/buildstamp.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/burn.d.ts +16 -1
- package/node_modules/@waterplane/shared/dist/burn.js +30 -0
- package/node_modules/@waterplane/shared/dist/burn.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/calday.d.ts +4 -0
- package/node_modules/@waterplane/shared/dist/calday.js +25 -0
- package/node_modules/@waterplane/shared/dist/calday.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/changebrief.d.ts +77 -0
- package/node_modules/@waterplane/shared/dist/changebrief.js +70 -0
- package/node_modules/@waterplane/shared/dist/changebrief.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/clihealth/healthrecord.js +1 -0
- package/node_modules/@waterplane/shared/dist/clihealth/healthrecord.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/costwindow.d.ts +24 -5
- package/node_modules/@waterplane/shared/dist/costwindow.js +35 -15
- package/node_modules/@waterplane/shared/dist/costwindow.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/desktopfiles.d.ts +100 -0
- package/node_modules/@waterplane/shared/dist/desktopfiles.js +192 -0
- package/node_modules/@waterplane/shared/dist/desktopfiles.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/exposure.d.ts +175 -0
- package/node_modules/@waterplane/shared/dist/exposure.js +357 -0
- package/node_modules/@waterplane/shared/dist/exposure.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/exposurepush.d.ts +60 -0
- package/node_modules/@waterplane/shared/dist/exposurepush.js +103 -0
- package/node_modules/@waterplane/shared/dist/exposurepush.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/commits.d.ts +26 -0
- package/node_modules/@waterplane/shared/dist/healthindex/commits.js +57 -0
- package/node_modules/@waterplane/shared/dist/healthindex/commits.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/move.d.ts +25 -0
- package/node_modules/@waterplane/shared/dist/healthindex/move.js +79 -0
- package/node_modules/@waterplane/shared/dist/healthindex/move.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/readings.d.ts +53 -0
- package/node_modules/@waterplane/shared/dist/healthindex/readings.js +154 -0
- package/node_modules/@waterplane/shared/dist/healthindex/readings.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/repoindex.d.ts +41 -0
- package/node_modules/@waterplane/shared/dist/healthindex/repoindex.js +19 -0
- package/node_modules/@waterplane/shared/dist/healthindex/repoindex.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/score.d.ts +26 -0
- package/node_modules/@waterplane/shared/dist/healthindex/score.js +156 -0
- package/node_modules/@waterplane/shared/dist/healthindex/score.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/types.d.ts +206 -0
- package/node_modules/@waterplane/shared/dist/healthindex/types.js +58 -0
- package/node_modules/@waterplane/shared/dist/healthindex/types.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/vs.d.ts +26 -0
- package/node_modules/@waterplane/shared/dist/healthindex/vs.js +38 -0
- package/node_modules/@waterplane/shared/dist/healthindex/vs.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/words.d.ts +28 -0
- package/node_modules/@waterplane/shared/dist/healthindex/words.js +124 -0
- package/node_modules/@waterplane/shared/dist/healthindex/words.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex.d.ts +15 -411
- package/node_modules/@waterplane/shared/dist/healthindex.js +8 -602
- package/node_modules/@waterplane/shared/dist/healthindex.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/hints.js +15 -0
- package/node_modules/@waterplane/shared/dist/hints.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/index.d.ts +37 -0
- package/node_modules/@waterplane/shared/dist/index.js +37 -0
- package/node_modules/@waterplane/shared/dist/index.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/intent/clean.d.ts +87 -0
- package/node_modules/@waterplane/shared/dist/intent/clean.js +51 -3
- package/node_modules/@waterplane/shared/dist/intent/clean.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/intent/kind.d.ts +40 -1
- package/node_modules/@waterplane/shared/dist/intent/kind.js +36 -3
- package/node_modules/@waterplane/shared/dist/intent/kind.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/intent/types.d.ts +13 -0
- package/node_modules/@waterplane/shared/dist/intent/types.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/intent/verdict.js +9 -16
- package/node_modules/@waterplane/shared/dist/intent/verdict.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/intent/words.js +5 -0
- package/node_modules/@waterplane/shared/dist/intent/words.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/intent.d.ts +2 -2
- package/node_modules/@waterplane/shared/dist/intent.js +2 -2
- package/node_modules/@waterplane/shared/dist/intent.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/launchmodes.d.ts +2 -0
- package/node_modules/@waterplane/shared/dist/launchmodes.js +12 -0
- package/node_modules/@waterplane/shared/dist/launchmodes.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/ledgerspan.d.ts +106 -0
- package/node_modules/@waterplane/shared/dist/ledgerspan.js +196 -0
- package/node_modules/@waterplane/shared/dist/ledgerspan.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/naming.d.ts +3 -1
- package/node_modules/@waterplane/shared/dist/naming.js +6 -2
- package/node_modules/@waterplane/shared/dist/naming.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/netfuse.d.ts +5 -0
- package/node_modules/@waterplane/shared/dist/netfuse.js +6 -1
- package/node_modules/@waterplane/shared/dist/netfuse.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/netretry.d.ts +78 -0
- package/node_modules/@waterplane/shared/dist/netretry.js +85 -0
- package/node_modules/@waterplane/shared/dist/netretry.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/netretrycfg.d.ts +12 -0
- package/node_modules/@waterplane/shared/dist/netretrycfg.js +27 -0
- package/node_modules/@waterplane/shared/dist/netretrycfg.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/nodemin.d.ts +6 -4
- package/node_modules/@waterplane/shared/dist/nodemin.js +6 -4
- package/node_modules/@waterplane/shared/dist/nodemin.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/optins.d.ts +35 -1
- package/node_modules/@waterplane/shared/dist/optins.js +39 -1
- package/node_modules/@waterplane/shared/dist/optins.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/pairing.js +4 -0
- package/node_modules/@waterplane/shared/dist/pairing.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/passive.js +3 -0
- package/node_modules/@waterplane/shared/dist/passive.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/plugin/api.d.ts +394 -0
- package/node_modules/@waterplane/shared/dist/plugin/api.js +2 -0
- package/node_modules/@waterplane/shared/dist/plugin/api.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/plugin/backend.d.ts +197 -0
- package/node_modules/@waterplane/shared/dist/plugin/backend.js +9 -0
- package/node_modules/@waterplane/shared/dist/plugin/backend.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/plugin/manifest.d.ts +160 -0
- package/node_modules/@waterplane/shared/dist/plugin/manifest.js +98 -0
- package/node_modules/@waterplane/shared/dist/plugin/manifest.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/plugin/module.d.ts +98 -0
- package/node_modules/@waterplane/shared/dist/plugin/module.js +13 -0
- package/node_modules/@waterplane/shared/dist/plugin/module.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/plugin/version.d.ts +66 -0
- package/node_modules/@waterplane/shared/dist/plugin/version.js +86 -0
- package/node_modules/@waterplane/shared/dist/plugin/version.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/plugin.d.ts +5 -867
- package/node_modules/@waterplane/shared/dist/plugin.js +27 -186
- package/node_modules/@waterplane/shared/dist/plugin.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/pluginlaunch.d.ts +7 -0
- package/node_modules/@waterplane/shared/dist/prview.d.ts +23 -0
- package/node_modules/@waterplane/shared/dist/prview.js +107 -0
- package/node_modules/@waterplane/shared/dist/prview.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/queue/queueserial.d.ts +11 -2
- package/node_modules/@waterplane/shared/dist/queue/queueserial.js +13 -4
- package/node_modules/@waterplane/shared/dist/queue/queueserial.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/queue/queuewords.js +1 -0
- package/node_modules/@waterplane/shared/dist/queue/queuewords.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/repohealth.d.ts +4 -0
- package/node_modules/@waterplane/shared/dist/repohealth.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/repotwins.d.ts +31 -0
- package/node_modules/@waterplane/shared/dist/repotwins.js +52 -0
- package/node_modules/@waterplane/shared/dist/repotwins.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/requirements.js +4 -1
- package/node_modules/@waterplane/shared/dist/requirements.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/schedule/schedaction.d.ts +29 -0
- package/node_modules/@waterplane/shared/dist/schedule/schedaction.js +22 -0
- package/node_modules/@waterplane/shared/dist/schedule/schedaction.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/schedule/schedclean.js +26 -0
- package/node_modules/@waterplane/shared/dist/schedule/schedclean.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/schedule/schedhorizon.d.ts +1 -0
- package/node_modules/@waterplane/shared/dist/schedule/schedhorizon.js +1 -0
- package/node_modules/@waterplane/shared/dist/schedule/schedhorizon.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/schedule.d.ts +1 -1
- package/node_modules/@waterplane/shared/dist/schedule.js +1 -1
- package/node_modules/@waterplane/shared/dist/schedule.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/sessionbudget.d.ts +34 -7
- package/node_modules/@waterplane/shared/dist/sessionbudget.js +59 -21
- package/node_modules/@waterplane/shared/dist/sessionbudget.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/sweep.d.ts +2 -1
- package/node_modules/@waterplane/shared/dist/sweep.js +2 -1
- package/node_modules/@waterplane/shared/dist/sweep.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/tokens.d.ts +4 -3
- package/node_modules/@waterplane/shared/dist/tokens.js +9 -7
- package/node_modules/@waterplane/shared/dist/tokens.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/weekburn.d.ts +144 -0
- package/node_modules/@waterplane/shared/dist/weekburn.js +250 -0
- package/node_modules/@waterplane/shared/dist/weekburn.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/wire/alwayson.d.ts +64 -0
- package/node_modules/@waterplane/shared/dist/wire/alwayson.js +7 -0
- package/node_modules/@waterplane/shared/dist/wire/alwayson.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/wire/backend.d.ts +4 -0
- package/node_modules/@waterplane/shared/dist/wire/backendtokens.d.ts +6 -0
- package/node_modules/@waterplane/shared/dist/wire/backendtokens.js +0 -9
- package/node_modules/@waterplane/shared/dist/wire/backendtokens.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/wire/costwindow.d.ts +25 -0
- package/node_modules/@waterplane/shared/dist/wire/messages/clienthost.d.ts +15 -1
- package/node_modules/@waterplane/shared/dist/wire/messages/clientsession.d.ts +24 -0
- package/node_modules/@waterplane/shared/dist/wire/messages/hosttools.d.ts +12 -2
- package/node_modules/@waterplane/shared/dist/wire/notify.d.ts +194 -1
- package/node_modules/@waterplane/shared/dist/wire/notify.js +139 -1
- package/node_modules/@waterplane/shared/dist/wire/notify.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/wire/pullrequest.d.ts +42 -0
- package/node_modules/@waterplane/shared/dist/wire/pullrequest.js +2 -0
- package/node_modules/@waterplane/shared/dist/wire/pullrequest.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/wire/repo.d.ts +131 -0
- package/node_modules/@waterplane/shared/dist/wire/repo.js +8 -3
- package/node_modules/@waterplane/shared/dist/wire/repo.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/wire/sent.d.ts +3 -1
- package/node_modules/@waterplane/shared/dist/wire/session/contextspark.d.ts +7 -0
- package/node_modules/@waterplane/shared/dist/wire/session/info.d.ts +4 -1
- package/node_modules/@waterplane/shared/dist/wire/session/launch.d.ts +36 -0
- package/node_modules/@waterplane/shared/dist/wire/session.d.ts +1 -1
- package/node_modules/@waterplane/shared/dist/wire/telemetry.d.ts +30 -0
- package/node_modules/@waterplane/shared/dist/wire/work.d.ts +13 -0
- package/node_modules/@waterplane/shared/dist/wire/work.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/wordof.d.ts +11 -0
- package/node_modules/@waterplane/shared/dist/wordof.js +14 -0
- package/node_modules/@waterplane/shared/dist/wordof.js.map +1 -0
- package/npm-shrinkwrap.json +3 -3
- package/package.json +2 -2
- package/packages/extensions/scorecard/waterplane-plugin.json +10 -0
- package/packages/host/dist/agentexposure.d.ts +13 -0
- package/packages/host/dist/agentexposure.js +90 -0
- package/packages/host/dist/agentexposure.js.map +1 -0
- package/packages/host/dist/agentintents.js +7 -8
- package/packages/host/dist/agentintents.js.map +1 -1
- package/packages/host/dist/agentwatch.d.ts +3 -7
- package/packages/host/dist/agentwatch.js.map +1 -1
- package/packages/host/dist/alwayson.d.ts +18 -0
- package/packages/host/dist/alwayson.js +159 -0
- package/packages/host/dist/alwayson.js.map +1 -0
- package/packages/host/dist/answergate.d.ts +3 -7
- package/packages/host/dist/answergate.js.map +1 -1
- package/packages/host/dist/attentionstore.d.ts +94 -0
- package/packages/host/dist/attentionstore.js +232 -0
- package/packages/host/dist/attentionstore.js.map +1 -0
- package/packages/host/dist/backends/claude-sources.d.ts +2 -0
- package/packages/host/dist/backends/claude-sources.js +12 -0
- package/packages/host/dist/backends/claude-sources.js.map +1 -1
- package/packages/host/dist/backends/claude.js +3 -2
- package/packages/host/dist/backends/claude.js.map +1 -1
- package/packages/host/dist/backends/derive.js +1 -0
- package/packages/host/dist/backends/derive.js.map +1 -1
- package/packages/host/dist/backends/overhead.d.ts +7 -5
- package/packages/host/dist/backends/overhead.js +15 -13
- package/packages/host/dist/backends/overhead.js.map +1 -1
- package/packages/host/dist/backends/registry.js +4 -1
- package/packages/host/dist/backends/registry.js.map +1 -1
- package/packages/host/dist/backends/types.d.ts +2 -0
- package/packages/host/dist/besidespend.d.ts +22 -0
- package/packages/host/dist/besidespend.js +65 -0
- package/packages/host/dist/besidespend.js.map +1 -0
- package/packages/host/dist/boxkit.d.ts +19 -0
- package/packages/host/dist/boxkit.js +38 -0
- package/packages/host/dist/boxkit.js.map +1 -0
- package/packages/host/dist/branchrules.d.ts +14 -0
- package/packages/host/dist/branchrules.js +47 -0
- package/packages/host/dist/branchrules.js.map +1 -0
- package/packages/host/dist/budget.d.ts +3 -2
- package/packages/host/dist/budget.js +5 -3
- package/packages/host/dist/budget.js.map +1 -1
- package/packages/host/dist/builds.d.ts +31 -1
- package/packages/host/dist/builds.js +55 -3
- package/packages/host/dist/builds.js.map +1 -1
- package/packages/host/dist/buildversions.d.ts +2 -0
- package/packages/host/dist/buildversions.js +36 -0
- package/packages/host/dist/buildversions.js.map +1 -0
- package/packages/host/dist/burnwatch.d.ts +23 -11
- package/packages/host/dist/burnwatch.js +57 -3
- package/packages/host/dist/burnwatch.js.map +1 -1
- package/packages/host/dist/changebrief.d.ts +37 -0
- package/packages/host/dist/changebrief.js +157 -0
- package/packages/host/dist/changebrief.js.map +1 -0
- package/packages/host/dist/cli/index.js +1 -1
- package/packages/host/dist/cli/index.js.map +1 -1
- package/packages/host/dist/clihealth.d.ts +2 -0
- package/packages/host/dist/clihealth.js +11 -2
- package/packages/host/dist/clihealth.js.map +1 -1
- package/packages/host/dist/compliance.d.ts +5 -1
- package/packages/host/dist/compliance.js +70 -31
- package/packages/host/dist/compliance.js.map +1 -1
- package/packages/host/dist/composer.d.ts +3 -1
- package/packages/host/dist/composer.js +3 -1
- package/packages/host/dist/composer.js.map +1 -1
- package/packages/host/dist/context.js +29 -4
- package/packages/host/dist/context.js.map +1 -1
- package/packages/host/dist/convlog.d.ts +1 -1
- package/packages/host/dist/convlog.js +1 -1
- package/packages/host/dist/costwindow.d.ts +25 -0
- package/packages/host/dist/costwindow.js +63 -1
- package/packages/host/dist/costwindow.js.map +1 -1
- package/packages/host/dist/ctxlog/ctxagents.js +16 -25
- package/packages/host/dist/ctxlog/ctxagents.js.map +1 -1
- package/packages/host/dist/ctxlog/ctxcursor.d.ts +36 -1
- package/packages/host/dist/ctxlog/ctxcursor.js +96 -2
- package/packages/host/dist/ctxlog/ctxcursor.js.map +1 -1
- package/packages/host/dist/ctxlog/ctxproject.js +2 -1
- package/packages/host/dist/ctxlog/ctxproject.js.map +1 -1
- package/packages/host/dist/ctxlog/ctxupdate.js +30 -24
- package/packages/host/dist/ctxlog/ctxupdate.js.map +1 -1
- package/packages/host/dist/ctxlog/usagerecord.d.ts +28 -0
- package/packages/host/dist/ctxlog/usagerecord.js +81 -0
- package/packages/host/dist/ctxlog/usagerecord.js.map +1 -0
- package/packages/host/dist/diskwatch.d.ts +4 -6
- package/packages/host/dist/diskwatch.js +3 -1
- package/packages/host/dist/diskwatch.js.map +1 -1
- package/packages/host/dist/eraseen.d.ts +6 -0
- package/packages/host/dist/eraseen.js +100 -0
- package/packages/host/dist/eraseen.js.map +1 -0
- package/packages/host/dist/explainjob.d.ts +24 -0
- package/packages/host/dist/explainjob.js +80 -0
- package/packages/host/dist/explainjob.js.map +1 -0
- package/packages/host/dist/exposure.d.ts +56 -0
- package/packages/host/dist/exposure.js +371 -0
- package/packages/host/dist/exposure.js.map +1 -0
- package/packages/host/dist/exposurepush.d.ts +28 -0
- package/packages/host/dist/exposurepush.js +136 -0
- package/packages/host/dist/exposurepush.js.map +1 -0
- package/packages/host/dist/exposurerun.d.ts +18 -0
- package/packages/host/dist/exposurerun.js +126 -0
- package/packages/host/dist/exposurerun.js.map +1 -0
- package/packages/host/dist/exposurewatch.d.ts +29 -0
- package/packages/host/dist/exposurewatch.js +127 -0
- package/packages/host/dist/exposurewatch.js.map +1 -0
- package/packages/host/dist/extensions/scorecard/host/engine.d.mts +54 -0
- package/packages/host/dist/extensions/scorecard/host/engine.mjs +303 -0
- package/packages/host/dist/extensions/scorecard/host/engine.mjs.map +1 -0
- package/packages/host/dist/extensions/scorecard/host/gitslug.d.mts +5 -0
- package/packages/host/dist/extensions/scorecard/host/gitslug.mjs +45 -0
- package/packages/host/dist/extensions/scorecard/host/gitslug.mjs.map +1 -0
- package/packages/host/dist/extensions/scorecard/host/index.d.mts +15 -0
- package/packages/host/dist/extensions/scorecard/host/index.mjs +47 -0
- package/packages/host/dist/extensions/scorecard/host/index.mjs.map +1 -0
- package/packages/host/dist/extensions/scorecard/host/store.d.mts +12 -0
- package/packages/host/dist/extensions/scorecard/host/store.mjs +91 -0
- package/packages/host/dist/extensions/scorecard/host/store.mjs.map +1 -0
- package/packages/host/dist/extensions/scorecard/shared/logic.d.mts +42 -0
- package/packages/host/dist/extensions/scorecard/shared/logic.mjs +170 -0
- package/packages/host/dist/extensions/scorecard/shared/logic.mjs.map +1 -0
- package/packages/host/dist/extensions/scorecard/shared/wire.d.mts +140 -0
- package/packages/host/dist/extensions/scorecard/shared/wire.mjs +29 -0
- package/packages/host/dist/extensions/scorecard/shared/wire.mjs.map +1 -0
- package/packages/host/dist/files.d.ts +14 -12
- package/packages/host/dist/files.js +64 -94
- package/packages/host/dist/files.js.map +1 -1
- package/packages/host/dist/forge/github.d.ts +3 -0
- package/packages/host/dist/forge/github.js +96 -0
- package/packages/host/dist/forge/github.js.map +1 -0
- package/packages/host/dist/forge/index.d.ts +14 -0
- package/packages/host/dist/forge/index.js +32 -0
- package/packages/host/dist/forge/index.js.map +1 -0
- package/packages/host/dist/forge/types.d.ts +58 -0
- package/packages/host/dist/forge/types.js +2 -0
- package/packages/host/dist/forge/types.js.map +1 -0
- package/packages/host/dist/git.d.ts +41 -16
- package/packages/host/dist/git.js +162 -101
- package/packages/host/dist/git.js.map +1 -1
- package/packages/host/dist/gitnotify.d.ts +54 -0
- package/packages/host/dist/gitnotify.js +167 -0
- package/packages/host/dist/gitnotify.js.map +1 -0
- package/packages/host/dist/healthwatch.d.ts +2 -1
- package/packages/host/dist/healthwatch.js +4 -2
- package/packages/host/dist/healthwatch.js.map +1 -1
- package/packages/host/dist/hoststore.js +2 -2
- package/packages/host/dist/hoststore.js.map +1 -1
- package/packages/host/dist/intents/adapters.js +68 -19
- package/packages/host/dist/intents/adapters.js.map +1 -1
- package/packages/host/dist/intents/clock.d.ts +6 -3
- package/packages/host/dist/intents/clock.js +19 -5
- package/packages/host/dist/intents/clock.js.map +1 -1
- package/packages/host/dist/intents/contract.d.ts +15 -5
- package/packages/host/dist/intents/contract.js.map +1 -1
- package/packages/host/dist/intents/disk.d.ts +16 -0
- package/packages/host/dist/intents/disk.js +26 -1
- package/packages/host/dist/intents/disk.js.map +1 -1
- package/packages/host/dist/intents/fire.js +7 -1
- package/packages/host/dist/intents/fire.js.map +1 -1
- package/packages/host/dist/intents/ladder.js +3 -1
- package/packages/host/dist/intents/ladder.js.map +1 -1
- package/packages/host/dist/intents/manager.d.ts +3 -3
- package/packages/host/dist/intents/manager.js +2 -2
- package/packages/host/dist/intents/manager.js.map +1 -1
- package/packages/host/dist/intents/watch.d.ts +27 -3
- package/packages/host/dist/intents/watch.js +70 -9
- package/packages/host/dist/intents/watch.js.map +1 -1
- package/packages/host/dist/intents/write.d.ts +28 -1
- package/packages/host/dist/intents/write.js +87 -2
- package/packages/host/dist/intents/write.js.map +1 -1
- package/packages/host/dist/localcistatus.d.ts +22 -0
- package/packages/host/dist/localcistatus.js +105 -0
- package/packages/host/dist/localcistatus.js.map +1 -0
- package/packages/host/dist/main.js +45 -12
- package/packages/host/dist/main.js.map +1 -1
- package/packages/host/dist/net.d.ts +2 -0
- package/packages/host/dist/net.js +11 -2
- package/packages/host/dist/net.js.map +1 -1
- package/packages/host/dist/netlog.d.ts +40 -0
- package/packages/host/dist/netlog.js +165 -0
- package/packages/host/dist/netlog.js.map +1 -0
- package/packages/host/dist/netretrycfg.d.ts +7 -0
- package/packages/host/dist/netretrycfg.js +51 -0
- package/packages/host/dist/netretrycfg.js.map +1 -0
- package/packages/host/dist/notifyprefs.d.ts +6 -2
- package/packages/host/dist/notifyprefs.js +20 -5
- package/packages/host/dist/notifyprefs.js.map +1 -1
- package/packages/host/dist/notifytypes.d.ts +63 -0
- package/packages/host/dist/notifytypes.js +2 -0
- package/packages/host/dist/notifytypes.js.map +1 -0
- package/packages/host/dist/opendeliveries.js +24 -0
- package/packages/host/dist/opendeliveries.js.map +1 -1
- package/packages/host/dist/optins.d.ts +28 -1
- package/packages/host/dist/optins.js +96 -4
- package/packages/host/dist/optins.js.map +1 -1
- package/packages/host/dist/peers/agentpeer.js +1 -1
- package/packages/host/dist/peers/agentpeer.js.map +1 -1
- package/packages/host/dist/peers/jobs.d.ts +2 -4
- package/packages/host/dist/peers/jobs.js +6 -1
- package/packages/host/dist/peers/jobs.js.map +1 -1
- package/packages/host/dist/periodspend.d.ts +22 -3
- package/packages/host/dist/periodspend.js +44 -4
- package/packages/host/dist/periodspend.js.map +1 -1
- package/packages/host/dist/plugins/pluginapi.js +40 -10
- package/packages/host/dist/plugins/pluginapi.js.map +1 -1
- package/packages/host/dist/plugins/pluginregistry.d.ts +3 -8
- package/packages/host/dist/plugins/pluginregistry.js +1 -1
- package/packages/host/dist/plugins/pluginregistry.js.map +1 -1
- package/packages/host/dist/plugins/plugintoolkit/sessionof.d.ts +47 -0
- package/packages/host/dist/plugins/plugintoolkit/sessionof.js +136 -0
- package/packages/host/dist/plugins/plugintoolkit/sessionof.js.map +1 -0
- package/packages/host/dist/prmergestore.d.ts +31 -0
- package/packages/host/dist/prmergestore.js +106 -0
- package/packages/host/dist/prmergestore.js.map +1 -0
- package/packages/host/dist/protectmain.d.ts +35 -0
- package/packages/host/dist/protectmain.js +73 -0
- package/packages/host/dist/protectmain.js.map +1 -0
- package/packages/host/dist/prpush.d.ts +38 -0
- package/packages/host/dist/prpush.js +351 -0
- package/packages/host/dist/prpush.js.map +1 -0
- package/packages/host/dist/prs.d.ts +118 -0
- package/packages/host/dist/prs.js +681 -0
- package/packages/host/dist/prs.js.map +1 -0
- package/packages/host/dist/push.d.ts +85 -1
- package/packages/host/dist/push.js +238 -8
- package/packages/host/dist/push.js.map +1 -1
- package/packages/host/dist/pushlanded.d.ts +29 -0
- package/packages/host/dist/pushlanded.js +61 -0
- package/packages/host/dist/pushlanded.js.map +1 -0
- package/packages/host/dist/pushreach.d.ts +9 -0
- package/packages/host/dist/pushreach.js +102 -0
- package/packages/host/dist/pushreach.js.map +1 -0
- package/packages/host/dist/pushverdict.d.ts +42 -0
- package/packages/host/dist/pushverdict.js +110 -0
- package/packages/host/dist/pushverdict.js.map +1 -0
- package/packages/host/dist/render.d.ts +57 -0
- package/packages/host/dist/render.js +57 -39
- package/packages/host/dist/render.js.map +1 -1
- package/packages/host/dist/repohealth.js +5 -2
- package/packages/host/dist/repohealth.js.map +1 -1
- package/packages/host/dist/repohealthapproval.d.ts +3 -0
- package/packages/host/dist/repohealthapproval.js +92 -2
- package/packages/host/dist/repohealthapproval.js.map +1 -1
- package/packages/host/dist/repos.d.ts +7 -1
- package/packages/host/dist/repos.js +30 -3
- package/packages/host/dist/repos.js.map +1 -1
- package/packages/host/dist/reposkill.d.ts +8 -5
- package/packages/host/dist/reposkill.js +16 -11
- package/packages/host/dist/reposkill.js.map +1 -1
- package/packages/host/dist/reposkilltext.d.ts +8 -1
- package/packages/host/dist/reposkilltext.js +85 -12
- package/packages/host/dist/reposkilltext.js.map +1 -1
- package/packages/host/dist/routes/apigitspend.d.ts +2 -0
- package/packages/host/dist/routes/apigitspend.js +40 -0
- package/packages/host/dist/routes/apigitspend.js.map +1 -0
- package/packages/host/dist/routes/apihost.js +17 -0
- package/packages/host/dist/routes/apihost.js.map +1 -1
- package/packages/host/dist/routes/apiprs.d.ts +2 -0
- package/packages/host/dist/routes/apiprs.js +47 -0
- package/packages/host/dist/routes/apiprs.js.map +1 -0
- package/packages/host/dist/routes/apirepofiles.js +13 -1
- package/packages/host/dist/routes/apirepofiles.js.map +1 -1
- package/packages/host/dist/routes/apirepowork.d.ts +6 -0
- package/packages/host/dist/routes/apirepowork.js +42 -33
- package/packages/host/dist/routes/apirepowork.js.map +1 -1
- package/packages/host/dist/routes/apiroutes.js +2 -1
- package/packages/host/dist/routes/apiroutes.js.map +1 -1
- package/packages/host/dist/routes/apisession.js +24 -0
- package/packages/host/dist/routes/apisession.js.map +1 -1
- package/packages/host/dist/routes/apistats.js +12 -7
- package/packages/host/dist/routes/apistats.js.map +1 -1
- package/packages/host/dist/routes/apisystem.js +23 -1
- package/packages/host/dist/routes/apisystem.js.map +1 -1
- package/packages/host/dist/routes/apitable.d.ts +10 -0
- package/packages/host/dist/routes/apitable.js.map +1 -1
- package/packages/host/dist/routes/apiweekburn.d.ts +2 -0
- package/packages/host/dist/routes/apiweekburn.js +30 -0
- package/packages/host/dist/routes/apiweekburn.js.map +1 -0
- package/packages/host/dist/routes/session.js +10 -0
- package/packages/host/dist/routes/session.js.map +1 -1
- package/packages/host/dist/routes/system.js +34 -6
- package/packages/host/dist/routes/system.js.map +1 -1
- package/packages/host/dist/routes/types.d.ts +29 -21
- package/packages/host/dist/routes/work/workbuild.js +3 -2
- package/packages/host/dist/routes/work/workbuild.js.map +1 -1
- package/packages/host/dist/routes/work/workintent.js +6 -2
- package/packages/host/dist/routes/work/workintent.js.map +1 -1
- package/packages/host/dist/routes/work/workschedule.js +33 -3
- package/packages/host/dist/routes/work/workschedule.js.map +1 -1
- package/packages/host/dist/screenlog.d.ts +20 -0
- package/packages/host/dist/screenlog.js +40 -0
- package/packages/host/dist/screenlog.js.map +1 -1
- package/packages/host/dist/server/billingwire.d.ts +3 -1
- package/packages/host/dist/server/billingwire.js +4 -2
- package/packages/host/dist/server/billingwire.js.map +1 -1
- package/packages/host/dist/server/clients.d.ts +14 -24
- package/packages/host/dist/server/clients.js +81 -11
- package/packages/host/dist/server/clients.js.map +1 -1
- package/packages/host/dist/server/ctx.d.ts +2 -0
- package/packages/host/dist/server/ctxseal.d.ts +1 -1
- package/packages/host/dist/server/ctxseal.js +6 -6
- package/packages/host/dist/server/ctxseal.js.map +1 -1
- package/packages/host/dist/server/deliveries.js +4 -2
- package/packages/host/dist/server/deliveries.js.map +1 -1
- package/packages/host/dist/server/http.js +2 -2
- package/packages/host/dist/server/http.js.map +1 -1
- package/packages/host/dist/server/intentDeps.js +13 -6
- package/packages/host/dist/server/intentDeps.js.map +1 -1
- package/packages/host/dist/server/intentEvents.js +9 -4
- package/packages/host/dist/server/intentEvents.js.map +1 -1
- package/packages/host/dist/server/scan.js +23 -1
- package/packages/host/dist/server/scan.js.map +1 -1
- package/packages/host/dist/server/sessionEvents.js +40 -15
- package/packages/host/dist/server/sessionEvents.js.map +1 -1
- package/packages/host/dist/server/shutdown.d.ts +3 -1
- package/packages/host/dist/server/shutdown.js +9 -1
- package/packages/host/dist/server/shutdown.js.map +1 -1
- package/packages/host/dist/sessionbudget.d.ts +2 -0
- package/packages/host/dist/sessionbudget.js +17 -6
- package/packages/host/dist/sessionbudget.js.map +1 -1
- package/packages/host/dist/sessions/agentpoll.d.ts +42 -0
- package/packages/host/dist/sessions/agentpoll.js +193 -0
- package/packages/host/dist/sessions/agentpoll.js.map +1 -0
- package/packages/host/dist/sessions/apiretry.d.ts +106 -0
- package/packages/host/dist/sessions/apiretry.js +387 -0
- package/packages/host/dist/sessions/apiretry.js.map +1 -0
- package/packages/host/dist/sessions/askwatch.d.ts +62 -0
- package/packages/host/dist/sessions/askwatch.js +169 -0
- package/packages/host/dist/sessions/askwatch.js.map +1 -0
- package/packages/host/dist/sessions/boxes.d.ts +2 -23
- package/packages/host/dist/sessions/boxes.js +10 -664
- package/packages/host/dist/sessions/boxes.js.map +1 -1
- package/packages/host/dist/sessions/boxread.d.ts +47 -0
- package/packages/host/dist/sessions/boxread.js +628 -0
- package/packages/host/dist/sessions/boxread.js.map +1 -0
- package/packages/host/dist/sessions/core.d.ts +22 -1
- package/packages/host/dist/sessions/ctxseries.js +3 -0
- package/packages/host/dist/sessions/ctxseries.js.map +1 -1
- package/packages/host/dist/sessions/drive.d.ts +20 -6
- package/packages/host/dist/sessions/drive.js +45 -12
- package/packages/host/dist/sessions/drive.js.map +1 -1
- package/packages/host/dist/sessions/endsession.d.ts +11 -0
- package/packages/host/dist/sessions/endsession.js +71 -0
- package/packages/host/dist/sessions/endsession.js.map +1 -0
- package/packages/host/dist/sessions/haltall.d.ts +14 -0
- package/packages/host/dist/sessions/haltall.js +32 -1
- package/packages/host/dist/sessions/haltall.js.map +1 -1
- package/packages/host/dist/sessions/knobs.d.ts +11 -0
- package/packages/host/dist/sessions/knobs.js +12 -0
- package/packages/host/dist/sessions/knobs.js.map +1 -1
- package/packages/host/dist/sessions/record.js +7 -2
- package/packages/host/dist/sessions/record.js.map +1 -1
- package/packages/host/dist/sessions/resume.d.ts +17 -0
- package/packages/host/dist/sessions/resume.js +65 -11
- package/packages/host/dist/sessions/resume.js.map +1 -1
- package/packages/host/dist/sessions/roster.js +3 -0
- package/packages/host/dist/sessions/roster.js.map +1 -1
- package/packages/host/dist/sessions/sidechannel.d.ts +1 -1
- package/packages/host/dist/sessions/sidechannel.js +2 -2
- package/packages/host/dist/sessions/tmux.js +21 -2
- package/packages/host/dist/sessions/tmux.js.map +1 -1
- package/packages/host/dist/sessions/turn.d.ts +15 -58
- package/packages/host/dist/sessions/turn.js +19 -358
- package/packages/host/dist/sessions/turn.js.map +1 -1
- package/packages/host/dist/sessions.d.ts +10 -7
- package/packages/host/dist/sessions.js +31 -79
- package/packages/host/dist/sessions.js.map +1 -1
- package/packages/host/dist/settle.d.ts +30 -2
- package/packages/host/dist/settle.js +94 -49
- package/packages/host/dist/settle.js.map +1 -1
- package/packages/host/dist/setupprefs.d.ts +26 -1
- package/packages/host/dist/setupprefs.js +49 -1
- package/packages/host/dist/setupprefs.js.map +1 -1
- package/packages/host/dist/setupwatch.d.ts +10 -8
- package/packages/host/dist/setupwatch.js +19 -16
- package/packages/host/dist/setupwatch.js.map +1 -1
- package/packages/host/dist/sidecar/sidecarname.d.ts +2 -0
- package/packages/host/dist/sidecar/sidecarname.js +5 -1
- package/packages/host/dist/sidecar/sidecarname.js.map +1 -1
- package/packages/host/dist/sidecar/sidecarroute.d.ts +1 -1
- package/packages/host/dist/sidecar/sidecarroute.js +5 -0
- package/packages/host/dist/sidecar/sidecarroute.js.map +1 -1
- package/packages/host/dist/sidecar.d.ts +1 -1
- package/packages/host/dist/sidecar.js +1 -1
- package/packages/host/dist/sidecar.js.map +1 -1
- package/packages/host/dist/tokenscan.d.ts +4 -4
- package/packages/host/dist/tokenscan.js +18 -37
- package/packages/host/dist/tokenscan.js.map +1 -1
- package/packages/host/dist/tokenstats.js +16 -18
- package/packages/host/dist/tokenstats.js.map +1 -1
- package/packages/host/dist/transcript/transcriptparse.js +17 -26
- package/packages/host/dist/transcript/transcriptparse.js.map +1 -1
- package/packages/host/dist/transcript/transcriptturns.d.ts +29 -0
- package/packages/host/dist/transcript/transcriptturns.js +27 -0
- package/packages/host/dist/transcript/transcriptturns.js.map +1 -1
- package/packages/host/dist/transcript.d.ts +1 -1
- package/packages/host/dist/transcript.js +1 -1
- package/packages/host/dist/transcript.js.map +1 -1
- package/packages/host/dist/usagesources.d.ts +1 -1
- package/packages/host/dist/usagesources.js +7 -2
- package/packages/host/dist/usagesources.js.map +1 -1
- package/packages/host/dist/visualskill.js +2 -2
- package/packages/host/dist/weekburn.d.ts +79 -0
- package/packages/host/dist/weekburn.js +276 -0
- package/packages/host/dist/weekburn.js.map +1 -0
- package/packages/host/dist/worktreeleftover.d.ts +9 -0
- package/packages/host/dist/worktreeleftover.js +17 -1
- package/packages/host/dist/worktreeleftover.js.map +1 -1
- package/packages/web/dist/assets/demo-DsZGy-MC.js +24 -0
- package/packages/web/dist/assets/icons-eqlvjswV.js +1 -0
- package/packages/web/dist/assets/index-GHwJuQb3.js +169 -0
- package/packages/web/dist/assets/index-VzDSZwwH.css +1 -0
- package/packages/web/dist/assets/shared-BWk5jXWb.js +49 -0
- package/packages/web/dist/assets/sheets-Dj-0m0DB.js +232 -0
- package/packages/web/dist/assets/{sheets-Bjv2L-cG.css → sheets-DoUhPGK0.css} +1 -1
- package/packages/web/dist/build-id.txt +1 -1
- package/packages/web/dist/buildstamp.json +1 -0
- package/packages/web/dist/index.html +7 -7
- package/packages/web/dist/sw.js +18 -3
- package/release.json +7 -4
- package/scripts/windows/wsl-setup.sh +10 -1
- package/tools/repohealth/constants.mjs +21 -1
- package/tools/repohealth/fixture.json +493 -30
- package/tools/repohealth/lang/typescript-resolve.mjs +354 -0
- package/tools/repohealth/metrics/graph.mjs +258 -0
- package/tools/repohealth/metrics/size.mjs +1 -1
- package/tools/repohealth/own.mjs +4 -4
- package/tools/repohealth/packs/c.mjs +4 -0
- package/tools/repohealth/packs/common.mjs +4 -0
- package/tools/repohealth/packs/dart.mjs +4 -0
- package/tools/repohealth/packs/kotlin.mjs +8 -0
- package/tools/repohealth/packs/python.mjs +8 -0
- package/tools/repohealth/packs/shell.mjs +4 -0
- package/tools/repohealth/packs/typescript.mjs +278 -7
- package/tools/repohealth/readings.mjs +39 -0
- package/tools/repohealth/series.mjs +1 -0
- package/tools/repohealth/snapshot.mjs +14 -0
- package/tools/repohealth/types.mjs +12 -0
- package/tools/repohealth.mjs +2 -0
- package/packages/web/dist/assets/demo-CXlqlYE4.js +0 -23
- package/packages/web/dist/assets/icons-BbqDBVjw.js +0 -1
- package/packages/web/dist/assets/index-CgPoyb3Y.css +0 -1
- package/packages/web/dist/assets/index-D5JKj8DK.js +0 -169
- package/packages/web/dist/assets/shared-eyaskl5l.js +0 -47
- package/packages/web/dist/assets/sheets-BzzL2re1.js +0 -204
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import{$i as e,A as t,As as n,At as r,Bc as i,C as a,Ds as o,E as s,Ec as c,Go as l,Gr as u,Io as d,Jo as f,Ko as p,Lo as m,M as h,Ni as g,O as _,Oa as v,Pi as y,Pn as b,Qo as x,Rn as S,So as C,St as w,Tc as T,Tn as E,To as D,U as O,Uc as k,Xc as A,Xo as j,Yo as M,Zc as ee,Zo as N,_s as P,_t as F,aa as I,ao as te,as as L,bc as R,bi as z,bs as ne,cc as re,cl as B,co as V,cs as H,dc as ie,di as ae,ds as oe,ea as U,et as se,fa as ce,fs as le,gt as ue,ha as de,hs as fe,ht as pe,i as me,ia as he,is as ge,j as _e,jt as ve,k as ye,ls as be,lt as xe,mt as Se,na as Ce,ns as we,oo as Te,os as Ee,ps as De,qo as Oe,ra as ke,ro as Ae,rs as je,s as Me,si as Ne,so as Pe,ss as Fe,st as Ie,ta as Le,to as Re,ts as ze,tt as Be,us as Ve,ut as He,vi as Ue,vs as We,vt as Ge,w as Ke,wc as qe,wn as Je,wo as Ye,xc as Xe,xi as Ze,xs as Qe,xt as $e,zr as et}from"./shared-eyaskl5l.js";import{C as tt,S as nt,_ as rt,b as it,c as at,d as ot,f as st,i as ct,l as lt,n as ut,p as W,t as dt,v as ft,w as pt,x as mt,y as ht}from"./demo-CXlqlYE4.js";import{$ as gt,$a as _t,$c as vt,$i as yt,$l as bt,$n as xt,$o as St,$r as Ct,$s as wt,$t as Tt,$u as Et,A as Dt,Aa as Ot,Ac as kt,Ai as At,Al as jt,An as Mt,Ao as Nt,Ar as Pt,As as Ft,At as It,Au as Lt,B as Rt,Ba as zt,Bc as Bt,Bi as Vt,Bl as Ht,Bn as Ut,Bo as Wt,Br as Gt,Bs as Kt,Bt as qt,Bu as Jt,C as Yt,Ca as Xt,Cc as Zt,Ci as Qt,Cl as $t,Cn as en,Co as tn,Cr as nn,Cs as rn,Ct as an,Cu as on,D as sn,Da as cn,Dc as ln,Di as un,Dl as dn,Dn as fn,Do as pn,Dr as mn,Ds as hn,Dt as gn,Du as _n,E as vn,Ea as yn,Ec as bn,Ei as xn,El as Sn,En as Cn,Eo as wn,Er as Tn,Es as En,Et as Dn,Eu as On,F as kn,Fa as An,Fc as jn,Fi as Mn,Fl as Nn,Fn as Pn,Fo as Fn,Fr as In,Fs as Ln,Ft as Rn,Fu as zn,G as Bn,Ga as Vn,Gc as G,Gi as Hn,Gl as Un,Gn as Wn,Go as Gn,Gr as Kn,Gs as qn,Gt as Jn,Gu as Yn,H as Xn,Ha as Zn,Hc as Qn,Hi as $n,Hl as er,Hn as tr,Ho as nr,Hr as rr,Hs as ir,Ht as ar,Hu as or,I as sr,Ia as cr,Ic as lr,Ii as ur,Il as dr,In as fr,Io as pr,Ir as mr,Is as hr,It as gr,Iu as _r,J as vr,Ja as yr,Jc as br,Ji as xr,Jl as Sr,Jn as Cr,Jo as wr,Jr as Tr,Js as Er,Jt as Dr,Ju as Or,K as kr,Ka as Ar,Kc as jr,Kl as Mr,Kn as Nr,Ko as Pr,Kr as Fr,Ks as Ir,Kt as Lr,Ku as Rr,L as zr,La as Br,Lc as Vr,Li as Hr,Ll as Ur,Ln as Wr,Lo as Gr,Lr as Kr,Ls as qr,Lt as Jr,Lu as Yr,M as Xr,Ma as Zr,Mc as Qr,Mi as $r,Ml as ei,Mn as ti,Mo as ni,Mr as ri,Ms as ii,Mt as ai,Mu as oi,N as si,Na as ci,Nc as li,Ni as ui,Nl as di,Nn as fi,No as pi,Nr as mi,Ns as hi,Nt as gi,Nu as _i,O as vi,Oa as yi,Oc as bi,Oi as xi,Ol as Si,On as Ci,Or as wi,Os as K,Ot as Ti,Ou as Ei,P as Di,Pa as Oi,Pc as ki,Pi as Ai,Pl as ji,Pn as Mi,Po as Ni,Pr as Pi,Ps as Fi,Pt as Ii,Pu as Li,Q as Ri,Qa as zi,Qc as Bi,Qi as Vi,Ql as Hi,Qn as Ui,Qo as Wi,Qr as Gi,Qs as Ki,Qt as qi,Qu as Ji,R as Yi,Ra as Xi,Rc as Zi,Ri as Qi,Rl as $i,Rn as ea,Ro as ta,Rr as na,Rs as ra,Rt as ia,Ru as aa,S as oa,Sa as sa,Sc as ca,Si as la,Sl as ua,Sn as da,So as fa,Sr as pa,Ss as ma,St as ha,Su as ga,T as _a,Ta as va,Tc as ya,Ti as ba,Tl as xa,Tn as Sa,To as Ca,Tr as wa,Ts as Ta,Tt as Ea,Tu as Da,U as Oa,Ua as ka,Uc as Aa,Ui as ja,Ul as Ma,Un as Na,Uo as Pa,Ur as Fa,Us as Ia,Ut as La,Uu as Ra,V as za,Va as Ba,Vc as Va,Vi as Ha,Vl as Ua,Vn as Wa,Vo as Ga,Vr as Ka,Vs as qa,Vt as Ja,Vu as Ya,W as Xa,Wa as Za,Wc as Qa,Wi as $a,Wl as eo,Wn as to,Wo as no,Wr as ro,Ws as io,Wt as ao,Wu as oo,X as so,Xa as co,Xc as lo,Xi as uo,Xl as fo,Xn as po,Xo as mo,Xr as ho,Xs as go,Xt as _o,Xu as vo,Y as yo,Ya as bo,Yc as xo,Yi as So,Yl as Co,Yn as wo,Yo as To,Yr as Eo,Ys as Do,Yt as Oo,Yu as ko,Z as Ao,Za as jo,Zc as Mo,Zi as No,Zl as Po,Zn as Fo,Zo as Io,Zr as Lo,Zs as Ro,Zt as zo,Zu as Bo,_ as Vo,_a as Ho,_c as Uo,_i as Wo,_l as Go,_n as Ko,_o as qo,_r as Jo,_s as Yo,_t as Xo,_u as Zo,a as Qo,aa as $o,ac as es,ad as ts,ai as ns,al as rs,an as is,ao as as,ar as os,as as ss,at as cs,au as ls,b as us,ba as ds,bc as fs,bi as ps,bl as ms,bn as hs,bo as gs,br as _s,bs as vs,bt as ys,bu as bs,c as xs,ca as Ss,cc as Cs,cd as ws,ci as Ts,cl as Es,cn as Ds,co as Os,cr as ks,cs as As,ct as js,cu as Ms,d as Ns,da as Ps,dc as Fs,dd as Is,di as Ls,dl as Rs,dn as zs,do as Bs,dr as Vs,ds as Hs,dt as Us,du as Ws,ea as Gs,ec as Ks,ed as qs,ei as Js,el as Ys,en as Xs,eo as Zs,er as Qs,es as $s,et as ec,eu as tc,f as nc,fa as rc,fc as ic,fd as ac,fi as oc,fl as sc,fn as cc,fo as lc,fr as uc,fs as dc,ft as fc,fu as pc,g as mc,ga as hc,gc,gi as _c,gl as vc,gn as yc,go as bc,gr as xc,gs as Sc,gt as Cc,gu as wc,h as Tc,ha as Ec,hc as Dc,hd as Oc,hi as kc,hl as Ac,hn as jc,ho as Mc,hr as Nc,hs as Pc,ht as Fc,hu as Ic,i as Lc,ia as Rc,ic as zc,id as Bc,il as Vc,in as Hc,io as Uc,ir as Wc,is as Gc,it as Kc,iu as qc,j as Jc,ja as Yc,jc as Xc,ji as Zc,jl as Qc,jn as $c,jo as el,jr as tl,js as nl,jt as rl,ju as il,k as al,ka as ol,kc as sl,ki as cl,kl as ll,kn as ul,ko as dl,kr as fl,ks as pl,kt as ml,ku as hl,l as gl,la as _l,lc as vl,ld as yl,li as bl,ll as xl,ln as Sl,lo as Cl,lr as wl,ls as Tl,lt as El,lu as Dl,m as Ol,ma as kl,mc as q,md as Al,mi as jl,ml as Ml,mn as Nl,mo as Pl,mr as Fl,ms as Il,mt as Ll,mu as Rl,n as zl,na as Bl,nc as Vl,nd as Hl,ni as Ul,nl as Wl,nn as Gl,no as Kl,nr as ql,ns as Jl,nt as Yl,nu as Xl,o as Zl,oa as Ql,oc as $l,od as eu,oi as tu,ol as nu,on as ru,oo as iu,or as au,os as ou,ot as su,ou as cu,p as lu,pa as uu,pc as J,pd as du,pi as fu,pl as pu,pn as mu,po as hu,pr as gu,ps as _u,pt as vu,pu as yu,q as bu,qa as xu,qc as Su,qi as Cu,ql as wu,qn as Tu,qo as Eu,qr as Du,qs as Ou,qt as ku,qu as Au,r as ju,ra as Mu,rc as Nu,rd as Pu,ri as Fu,rl as Iu,rn as Lu,ro as Ru,rr as zu,rs as Bu,rt as Vu,ru as Hu,s as Uu,sa as Wu,sc as Gu,sd as Ku,si as qu,sl as Ju,sn as Yu,so as Xu,sr as Zu,ss as Qu,st as $u,su as ed,t as td,ta as nd,tc as rd,td as id,tl as ad,tn as od,to as sd,tr as cd,ts as ld,tt as ud,tu as dd,u as fd,ua as pd,uc as md,ud as hd,ui as gd,ul as _d,un as vd,uo as yd,ur as bd,us as xd,ut as Sd,uu as Cd,v as wd,va as Td,vc as Ed,vi as Dd,vl as Od,vn as kd,vo as Ad,vr as jd,vs as Md,vt as Nd,vu as Pd,w as Fd,wa as Id,wc as Ld,wi as Rd,wl as zd,wn as Bd,wo as Vd,wr as Hd,ws as Ud,wt as Wd,wu as Gd,x as Kd,xa as qd,xc as Y,xi as Jd,xl as Yd,xn as Xd,xo as Zd,xr as Qd,xs as $d,xt as ef,xu as tf,y as nf,ya as rf,yc as af,yi as of,yl as sf,yn as cf,yo as lf,yr as uf,ys as df,yt as ff,yu as pf,z as mf,za as hf,zc as gf,zi as _f,zl as vf,zn as yf,zo as bf,zr as xf,zs as Sf,zt as Cf,zu as wf}from"./sheets-BzzL2re1.js";import{i as Tf,n as Ef,r as Df,t as Of}from"./react-CoSyT_xY.js";import{$ as kf,A as Af,Ai as jf,An as Mf,B as Nf,Bn as Pf,Br as Ff,Cr as If,Ct as Lf,D as Rf,Di as zf,Dr as Bf,En as Vf,Er as Hf,Fi as Uf,Fr as Wf,Ft as Gf,G as Kf,Gi as qf,Hi as Jf,Hn as Yf,Hr as Xf,In as Zf,Ir as Qf,It as $f,J as ep,Jr as tp,Jt as np,Kr as rp,L as ip,Lt as ap,M as op,Mi as sp,Nn as cp,Nt as lp,O as up,On as dp,Or as fp,Ot as pp,P as mp,R as hp,Ri as gp,Rn as _p,Rr as vp,Rt as yp,Si as bp,Sn as xp,Sr as Sp,St as Cp,Ti as wp,Tr as Tp,Ui as Ep,Un as Dp,Ut as Op,Vi as kp,Vn as Ap,Vr as jp,Vt as Mp,W as Np,Wi as Pp,Wr as Fp,X as Ip,Xr as Lp,Xt as Rp,Y as zp,Yi as Bp,Yn as Vp,Yr as Hp,Z as Up,Zn as Wp,Zt as Gp,_ as Kp,_i as qp,_n as Jp,b as Yp,c as Xp,ci as Zp,di as Qp,dn as $p,ei as em,en as tm,fi as nm,fn as rm,g as im,gi as am,gn as om,gr as sm,gt as cm,h as lm,hn as um,i as X,ii as dm,in as fm,ir as pm,it as mm,jr as hm,k as gm,kn as _m,kt as vm,m as ym,mi as bm,mt as xm,or as Sm,ot as Cm,pi as wm,pn as Tm,qt as Em,r as Dm,ri as Om,rn as km,rt as Am,si as jm,sn as Mm,tr as Nm,u as Pm,ui as Fm,un as Im,ut as Lm,vi as Rm,vn as zm,wr as Bm,xi as Vm,xn as Hm,xr as Um,xt as Wm,yn as Gm,yt as Km,z as qm,zi as Jm}from"./icons-BbqDBVjw.js";import{n as Ym,t as Xm}from"./xterm-C8zLTNGk.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),ct(ws())||Oc(),ws()&&ac(du());var Z=Tf(),Zm=Ef();async function Qm(e,t){let[n,r]=await Promise.all([Gd.artifacts(e,`outbox`,void 0,{signal:t}).then(e=>e.files).catch(()=>[]),Gd.inbox(e,t).catch(()=>[])]);return[...n,...r].map(e=>e.relPath).filter(Boolean)}function $m(e,t){return Si(e??``,t=>Qm(e,t),{enabled:t&&!!e}).data??void 0}var eh={fresh:0,warm:1,heavy:2,steep:3},th=60;function nh(e,t,n){if((eh[n[e]]??0)>=eh[t])return{notice:!1,next:n};let r={...n,[e]:t},i=Object.keys(r);if(i.length>th)for(let e of i.slice(0,i.length-th))delete r[e];return{notice:!0,next:r}}function rh(e,t,n){if(t==null){if(!(e in n))return{notice:!1,next:n};let t={...n};return delete t[e],{notice:!1,next:t}}if(n[e]===t)return{notice:!1,next:n};let r={...n,[e]:t},i=Object.keys(r);if(i.length>th)for(let e of i.slice(0,i.length-th))delete r[e];return{notice:!0,next:r}}var ih={warn:1,high:2};function ah(e,t,n){if(!t||(ih[n[e]]??0)>=ih[t])return{notice:!1,next:n};let r={...n,[e]:t},i=Object.keys(r);if(i.length>th)for(let e of i.slice(0,i.length-th))delete r[e];return{notice:!0,next:r}}function oh(){let e=q(`spendWarn`),t=Kt();return n=>n?ke(n.contextSpark?.costUsd,t,e):null}function sh(e){let t=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!e||!e.running)return;let n=re(e.contextSpark,{lastTurnAt:e.lastTurnAt,turnActive:e.turnActive,now:Date.now()});if(!n||n.level===`fresh`)return;let r=t.current??=it(W.costNoticed,{}),{notice:i,next:a}=nh(e.id,n.level,r);i&&(t.current=a,pt(W.costNoticed,a),G(n.advice?`${n.note} ${n.advice}`:n.note))},[e]);let n=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!e)return;let t=e.contextSpark,r=e.running?ie(t?.liveAgentTok,t?.liveAgentAt,Date.now(),Cs()):null,i=n.current??=it(W.agentNoticed,{}),{notice:a,next:o}=rh(e.id,r?t?.liveAgentId??`agent`:null,i);o!==i&&(n.current=o,pt(W.agentNoticed,o)),a&&r&&G(r)},[e]);let r=(0,Z.useRef)(null),i=oh()(e);(0,Z.useEffect)(()=>{if(!e||!i)return;let t=r.current??=it(W.spendNoticed,{}),{notice:n,next:a}=ah(e.id,i.level,t);n&&(r.current=a,pt(W.spendNoticed,a),G(`${i.text} Marks are set in Settings › Sessions › spend marks. Nothing was stopped.`))},[e,i]);let a=(0,Z.useRef)(new Set);(0,Z.useEffect)(()=>{if(!e)return;let t=e.budget,{notice:n,next:r}=ka(e.id,t?.verdict.state===`over`,a.current);a.current=r,n&&t&&G(Zn(e.title,t))},[e])}function ch(e,t){let[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(e){i.current=!0,r(!1);return}if(!i.current)return;i.current=!1,r(!0);let n=window.setTimeout(()=>r(!1),t);return()=>window.clearTimeout(n)},[e,t]),n}var lh=6e3,uh=2e4,dh=9e4,fh=1500,ph=5e3,mh=45e3,hh=`pending:`,gh=e=>!!e?.startsWith(hh),_h=e=>`${hh}${e}`,vh=`${hh}later:`,yh=e=>!!e?.startsWith(vh),bh=e=>`${vh}${e}`,xh=(e,t)=>gh(e)&&t?`create:${t}`:e;function Sh(e,t){let n=e.attempts??0,r=1+Math.min(3,n);return e.mode===`op`?(t==null?uh:Math.max(uh,Math.min(12e4,t*6)))*r:e.mode===`backlog`||e.mode===`upload`?lh*r:dh}function Ch(e,t,n=Date.now()){let r=(e.tries??0)+1;return{...e,status:`queued`,attempts:t?Math.max(0,(e.attempts??1)-1):e.attempts,tries:r,retryAt:n+oe(r)}}function wh(e){return e.pendingCreate&&e.holdUntilIdle?!0:void 0}function Th(e,t,n){let r=new Set;for(let i of e)i.status!==`queued`||i.pendingCreate||(i.mode??`input`)===`input`&&(!t.has(i.sessionId)||n.has(i.sessionId))&&r.add(i.sessionId);return[...r]}function Eh(e,t){if(e.mode===`op`){let t=e.cwd.split(`/`).filter(Boolean).pop()??``;return e.op?.t===`schedule.run`?`Scheduled run, by hand`:e.sessionId===`fanout`?`Fan-out`:e.sessionId.startsWith(`fu:`)?`Fan-out follow-up`:e.sessionId.startsWith(`build:`)?`${t||`repo`} · builds`:`${t||`repo`} · new session`}let n=t.find(t=>t.id===e.sessionId);return n?`${n.title}${e.mode===`backlog`?` · backlog`:``}`:`${e.cwd.split(`/`).filter(Boolean).pop()??e.cwd}${e.mode===`backlog`?` · backlog`:` · session gone`}`}function Dh(e,t=Date.now()){let n=e.map(e=>e.sentAt??e.ts),r=n.length?Math.min(...n):t,i=Math.max(0,Math.round((t-r)/1e3)),a=e.length>1?` (${e.length})`:``,o=e.some(e=>e.mode===`upload`)?`Uploading`:`Sending`,s=e.filter(e=>e.status===`queued`&&e.retryAt!=null).map(e=>e.retryAt);if(s.length===e.length&&s.length){let n=Math.max(1e3,Math.min(...s)-t),r=n<6e4?`${Math.round(n/1e3)}s`:`${Math.round(n/6e4)} min`,i=e.length===1&&e[0].waitReason?` — ${e[0].waitReason}`:``;return`${o}${a}…${i?`${i};`:``} retrying in ${r}`}return`${o}${a}… ${i}s${i>=20?` — no receipt yet, will retry`:``}`}function Oh(e){let t=Ai(e).trim().replace(/\s+/g,` `);return t?t.length>64?`${t.slice(0,64)}…`:t:e.mode===`upload`?`a file`:`an action`}function kh(e){return new Set(e.filter(o).map(e=>e.id))}function Ah(e,t){for(let n of e)if(!t.has(n))return!0;return!1}function jh(e,t){return{...e,status:`pending`,attempts:(e.attempts??0)+1,sentAt:t,firstTryAt:e.firstTryAt??t,waitReason:void 0}}function Mh(t){let n=t.firstTryAt;return t.mode===`upload`?null:t.mode===`op`?t.op?n==null?t.op:e(t.op,n):null:t.mode===`backlog`?{t:`backlog.add`,text:t.text,repoDir:t.cwd,label:t.label??t.text.slice(0,40),fire:t.fire,targetSessionId:t.targetSessionId,autoFire:t.autoFire,ackId:t.ackId,firstSentAt:n,steps:t.steps,resume:t.resume,...typeof t.closeWhenDone==`boolean`?{closeWhenDone:t.closeWhenDone}:{},...t.flagWhenDone?{flagWhenDone:!0}:{},...t.budget?{budget:t.budget}:{},...t.launch?{launch:t.launch}:{},...t.pastBudget?{pastBudget:!0}:{}}:t.answer?{t:`session.input`,id:t.sessionId,data:t.text,ackId:t.ackId,firstSentAt:n,expectPrompt:t.answer.fingerprint,promptSubmit:t.answer.submitBox,promptChoice:t.answer.choice,...t.answer.text===void 0?{}:{promptText:t.answer.text}}:{t:`session.input`,id:t.sessionId,data:t.text,ackId:t.ackId,firstSentAt:n,submit:!0,cwd:t.cwd,view:t.view}}function Nh(e){return`sending “${e}”…`}var Ph=`pending:`;function Fh(e){let t=e.remembered;if(t?.startsWith(Ph)){let n=t.slice(8);if(e.pendingAlive(n))return{do:`enter`,ack:n}}else if(t){let n=e.sessions.find(e=>e.id===t);if(n&&n.running)return{do:`attach`,id:n.id}}let n=e.sessions.find(t=>t.running&&!t.companionOf&&t.cwd===e.cwd&&e.isShell(t.backend));return n?{do:`attach`,id:n.id}:{do:`open`}}function Ih(e,t,n){return e===`${Ph}${t}`?n:e}function Lh(e,t,n){let r=!1,i={};for(let[a,o]of Object.entries(e)){let e=Ih(o,t,n);e!==o&&(r=!0),i[a]=e}return r?i:e}function Rh(e){return`back to ${e}`}function zh(e,t){return!!e&&!!t&&e.sessionId===t}var Bh=ms({}),Vh=ms(null);function Hh(e,t,n){Bh.set(n=>n[e]===t?n:{...n,[e]:t}),n&&Vh.set(()=>({sessionId:t,to:n}))}function Uh(e,t){Bh.set(n=>Lh(n,e,t)),Vh.set(n=>{if(!n)return n;let r=Ih(n.sessionId,e,t);return r===n.sessionId?n:{...n,sessionId:r}})}function Wh(){Vh.set(null)}var Gh=3e4;function Kh(e){return e?.adoptedAt&&Date.now()-e.adoptedAt>Gh?void 0:e}function qh(e,t,n){let r=(0,Z.useRef)(new Map),i=(0,Z.useMemo)(()=>{if(!gh(e))return null;let n=e.slice(hh.length);return t.find(e=>e.ackId===n&&dr(e))??null},[t,e]);return{pendingKept:r,pendingEntry:i,pendingSession:(0,Z.useMemo)(()=>{if(e&&!gh(e)){if(n.some(t=>t.id===e))return null;let t=Kh(r.current.get(e));return t?.adoptedAt?{id:e,cwd:t.cwd,title:t.title,remoteControl:!1,running:!0,createdAt:t.ts}:null}if(!gh(e))return null;if(yh(e)){let t=e.slice(vh.length);return{id:e,cwd:t,title:Ws(t)||`new session`,remoteControl:!1,running:!0,createdAt:Date.now()}}let t=i,a=Kh(r.current.get(e.slice(hh.length)));if(!t&&!a)return null;let o=t?.op,s=t?.cwd||a?.cwd||``;return{id:e,cwd:s,title:o?.title||a?.title||Ws(s)||`new session`,remoteControl:!1,running:!0,createdAt:t?.ts??a?.ts??Date.now(),model:o?.launch?.model,effort:o?.launch?.effort,permissionMode:o?.launch?.permissionMode,remoteControlled:o?.launch?.remoteControlled}},[i,e,n])}}function Jh(e){let{outboxRef:t,pendingKept:n,activeIdRef:r,connRef:i,wantNavRef:a,buffers:o,pendingEntry:s}=e,c=t=>e.writeOutbox(t),l=(t,n)=>e.addOutbox(t,n),u=(t,n,r,i)=>e.queueOp(t,n,r,i),d=e.setOverlay,f=e.setActiveId,p=e.setLastVisitedId;function m(e){let n=t.current.find(t=>dr(t)&&t.cwd===e&&t.status!==`failed`);n&&g(n.ackId)}function h(e){a.current=!1,d(null),f(bh(e))}function g(e){let r=t.current.find(t=>t.ackId===e),i=r?.op;for(r&&n.current.set(e,{cwd:r.cwd,title:i?.title||Ws(r.cwd),ts:r.ts});n.current.size>8;)n.current.delete(n.current.keys().next().value);a.current=!1,d(null),f(_h(e))}function _(){let e=s,n=e?.op;if(!e||e.status!==`failed`||n?.t!==`session.create`)return;Y(`action:session.pending.retry`);let r=t.current.filter(t=>t.mode===`input`&&t.createAck===e.ackId&&t.status===`failed`).sort((e,t)=>e.ts-t.ts),a=new Set([e.ackId,...r.map(e=>e.ackId)]);c(t.current.filter(e=>!a.has(e.ackId)));let o=eo(),{ackId:l,...d}=n;u(d,e.sessionId,e.text,{cwd:e.cwd,focus:!0,ackId:o});for(let e of r)y(e.cwd,e.text,o,e.kind===`command`?`command`:`prompt`);g(o),G(i.current.status===`open`?`trying again…`:`queued — it opens when the link is back`)}function v(e,t){let i=_h(e),a=n.current.get(e);if(a){let r={...a,adoptedAt:Date.now()};n.current.set(e,r),n.current.set(t,r)}if(Uh(e,t),r.current!==i)return;let s=vf(i);s&&Co(t,s),Co(i,``),o.current.has(t)||o.current.set(t,[]),f(t),p(t)}function y(e,t,n,r=`prompt`){l({ackId:eo(),sessionId:`create:${e}`,cwd:e,text:t,ts:Date.now(),status:`queued`,attempts:0,kind:r,mode:`input`,pendingCreate:!0,holdUntilIdle:!0,createAck:n,armed:!0})}function b(e,n){let r=new Set(je(t.current,e,n).map(e=>e.ackId));c(t.current.map(e=>r.has(e.ackId)?{...e,noTtl:!0}:e))}function x(e,n,r){let i=new Set(je(t.current,e,r).map(e=>e.ackId));c(t.current.map(e=>i.has(e.ackId)?(Li(),{...e,status:`failed`,reason:n,failedAt:Date.now()}):e))}function S(e,n){let r=e.upload?.relPath;if(!r)return;let i=e=>e.text.includes(r)||e.mode===`op`&&JSON.stringify(e.op??``).includes(r);c(t.current.map(t=>t.ackId!==e.ackId&&t.status===`queued`&&t.sessionId===e.sessionId&&i(t)?(Li(),{...t,status:`failed`,reason:n,failedAt:Date.now()}):t))}return{enterPending:g,enterOldestPending:m,enterLater:h,retryPendingCreate:_,adoptPendingSession:v,queueSessionPrompt:y,holdForLaunch:b,failPendingCreates:x,failDependentUploads:S}}function Yh(e){let{connRef:t,sessionsRef:n,exitedRef:r,outboxRef:i,ackTimers:a,uploadsInFlight:o,uploadAborts:s,busyLanesRef:c,budgetHeldLanesRef:l,busySerialRef:d,serialWatchRef:f,budgetRef:p,autoSendRef:m,holdQueueRef:h,flushIdleReason:g,queueBlockedRef:_,readModeRef:v,serialSessionsRef:y,sessions:b}=e,{inflightRef:S,upBytesRef:C}=e.up,w=()=>e.up.refreshUploadLabel(),T=t=>e.writeOutbox(t),E=(t,n)=>e.addOutbox(t,n),D=t=>e.addOutboxFirstInLane(t),O=(t,n,r)=>e.failOutbox(t,n,r),k=t=>e.holdWall(t),A=(t,n,r,i)=>e.queueSessionPrompt(t,n,r,i);async function ee(e,t=!0){if(e.mode!==`upload`)return;let n=e.upload?await Vl(`uploads`,e.ackId):null;n&&e.upload&&await Fa(e.upload.relPath,n),t&&await rd(`uploads`,e.ackId)}function P(e){return Sh(e,_r())}function F(e){let t=Date.now();T(i.current.map(n=>{if(n.ackId!==e||n.status===`failed`)return n;let r=(n.round??0)+1,i=le(r);return{...n,status:`queued`,attempts:0,round:r,retryAt:t+i,waitReason:`the desktop hasn't answered yet`}}));let n=i.current.find(t=>t.ackId===e);n&&(n.round??0)===1&&G(`still sending — the desktop hasn't confirmed yet. Retrying in ${Math.round(le(1)/6e4)} min; your text is safe.`)}function I(e,n=lh){let r=window.setTimeout(()=>{a.current.delete(e);let n=i.current,r=t.current.status!==`open`;n.some(t=>t.ackId===e&&t.status===`pending`)&&(Ei(),T(n.map(t=>t.ackId===e?Ch(t,r):t))),L()},n);a.current.set(e,r)}function te(){if(t.current.status!==`open`||Ms().pending.includes(`sessions`))return[];let e=new Set(n.current.filter(e=>e.running).map(e=>e.id));return Th(i.current,e,r.current)}function L(r=!1){if(r&&(h.current=!1,T(i.current.map(e=>e.status===`queued`?{...e,armed:!0,retryAt:void 0,waitReason:void 0,holdUntilIdle:e.holdUntilIdle&&(e.pendingCreate||k(e.sessionId))?!0:void 0}:e))),t.current.status!==`open`)return g.current=M([],{online:!1,queued:1}),0;let s=te(),u=ge(i.current,{now:Date.now(),inflight:[...a.current.keys(),...o.current],maxAttempts:8,minTryMs:Ve,busyLanes:c.current,busySerial:(()=>{let e=j(At(n.current),f.current,Date.now());return d.current=e.busy,f.current=e.watches,e.busy})(),budgetBlocked:p.current?.verdict.blocked??!1,goneLanes:s,budgetHeldLanes:l.current});u.release.length&&T(ze(i.current,u.release));for(let e of u.expire)_i(),F(e.ackId);let v={autoSend:m.current,hold:h.current},y=0,b=[...u.blocked];for(let e of u.send){if(!N(e,v)){b.push({ackId:e.ackId,sessionId:e.sessionId,reason:`gate`});continue}let n=Date.now(),r=jh(e,n);if(T(i.current.map(t=>t.ackId===e.ackId?jh(t,n):t)),e.mode===`upload`){oe(e),y++;continue}let a=Mh(r);a&&t.current.send(a),I(e.ackId,P(e)),y++}let x=new Map(b.map(e=>[e.ackId,e.reason]));return _.current=x,e.setQueueBlocked(x),g.current=y?null:M(b,{online:!0,queued:i.current.filter(e=>e.status===`queued`).length,serialText:(()=>{let e=b.find(e=>e.reason===`serial`),t=e&&i.current.find(t=>t.ackId===e.ackId);return t?.serial?Zc(t.serial,n.current):void 0})()}),y}function R(e=`nothing queued`){return g.current??e}function z(){window.setTimeout(()=>{L()},450)}function ne(e){let t=be(i.current,e)[0],n=t?{relPath:t,reason:`it never uploaded`}:ji(e);return n?`${n.relPath.split(`/`).pop()} — ${n.reason}. Re-attach it before sending.`:null}function re(e,t){let n=ne(e);if(n)return G(n),!1;let r=Fe(i.current,e,t);return r.some((e,t)=>e!==i.current[t])&&T(r),!0}function B(e){let t=ne(e.join(`
|
|
2
|
-
`));return!t||(G(t),!1)}function V(e,n,r,i,a=!1){if(!a&&ve(r)){let t=b.find(t=>t.id===e);t&&(t.hooked?t.turnActive:t.running&&!t.idle)&&(a=!0,G(`${r.trim().split(/\s+/)[0]} opens a view — held until this turn ends`))}if(!re(r,xh(e,n)))return!1;if(yh(e))return G(`this session starts only when its backlog item runs — write it in the box and Send`),!1;if(gh(e))return A(n,r,e.slice(hh.length),i),L(),!0;let o=eo(),s=t.current.status!==`open`;return E({ackId:o,sessionId:e,cwd:n,text:r,ts:Date.now(),status:`queued`,attempts:0,kind:i,mode:`input`,offline:s,armed:!s,holdUntilIdle:a||void 0,view:v.current?`read`:`term`}),s||se(e),L(),!0}function H(e,n,r,i){let a=i?.ackId??eo(),o=t.current.status!==`open`,s=i?.cwd??``,c=(i?.serial??y.current)&&e.t===`session.create`&&e.prompt&&s?x(s):void 0;return E({ackId:a,sessionId:n,cwd:s,text:r,ts:Date.now(),status:`queued`,attempts:0,mode:`op`,serial:c,op:{...e,ackId:a},focus:i?.focus&&!o?!0:void 0,offline:o,armed:!o},i?.frontOfLane),o||se(n),L(),o}async function ie(e,t,n,r,i){r=xh(r,i);let a=eo(),{name:o,relPath:s}=wu(n);return await zc(`uploads`,a,t),await Vl(`uploads`,a)?(E({ackId:a,sessionId:r,cwd:i,text:`file · ${o}`,ts:Date.now(),status:`queued`,attempts:0,mode:`upload`,upload:{repoId:e,name:o,relPath:s,size:t.size,type:t.type||`application/octet-stream`},armed:!0}),L(),{relPath:s,ackId:a}):null}async function oe(e){let n=e.upload;if(!n){O(e.ackId,`not an image`),z();return}o.current.add(e.ackId);let r=new AbortController;s.current.set(e.ackId,r),S.current++,C.current.startedAt||(C.current.startedAt=Date.now()),C.current.total+=n.size,w();let a=0,c=Date.now(),l=!1,d=0,f=()=>{window.clearTimeout(d),d=window.setTimeout(()=>{l=!0,r.abort(new u(`upload`,mh))},mh)};f();try{let t=await Vl(`uploads`,e.ackId);if(!t){O(e.ackId,`the file's bytes are no longer on this device`);return}let o=await Gd.uploadInbox(n.repoId,t,n.name,r.signal,e=>{C.current.sent+=Math.max(0,e-a),a=e,f(),w()},!0),s=o.saved?.[0]?.relPath;if(!s){O(e.ackId,o.skipped?.[0]?.error||`the host refused the file`);return}Js(n.repoId,s,o.saved[0].mtime),Bl(n.size,Date.now()-c),rd(`uploads`,e.ackId),s!==n.relPath&&U(n.relPath,s),T(i.current.filter(t=>t.ackId!==e.ackId))}catch(n){if(n?.permanent){O(e.ackId,n.message);return}let r=De({responded:n?.responded,stalled:l,socketOpen:t.current.status===`open`});T(i.current.map(t=>t.ackId===e.ackId&&t.status===`pending`?Ch(t,r):t))}finally{window.clearTimeout(d),C.current.sent+=Math.max(0,n.size-a),S.current=Math.max(0,S.current-1),w(),s.current.delete(e.ackId),o.current.delete(e.ackId),z()}}function U(t,n){T(i.current.map(e=>{if(!e.text.includes(t))return e;let r=e.text.split(t).join(n);if(e.mode===`op`&&e.op){let i={...e.op};return typeof i.text==`string`&&(i.text=i.text.split(t).join(n)),typeof i.prompt==`string`&&(i.prompt=i.prompt.split(t).join(n)),{...e,text:r,op:i}}return{...e,text:r,label:e.mode===`backlog`?r.slice(0,40):e.label}})),e.setCompose(e=>e.includes(t)?e.split(t).join(n):e)}function se(e){let t=i.current.filter(t=>t.sessionId===e&&t.status===`queued`&&!t.armed);t.length&&(T(i.current.map(t=>t.sessionId===e&&t.status===`queued`?{...t,armed:!0}:t)),G(`sending ${t.length} earlier queued message${t.length>1?`s`:``} first`))}function ce(e){if(!re(e.text,e.targetSessionId??e.repoDir))return null;let n=eo(),r=t.current.status!==`open`;return E({ackId:n,sessionId:e.targetSessionId??e.repoDir,cwd:e.repoDir,text:e.text,ts:Date.now(),status:`queued`,attempts:0,mode:`backlog`,label:e.label,fire:e.fire,autoFire:e.autoFire,targetSessionId:e.targetSessionId,steps:e.steps&&e.steps.length>1?e.steps:void 0,resume:e.resume||void 0,closeWhenDone:typeof e.closeWhenDone==`boolean`?e.closeWhenDone:void 0,flagWhenDone:e.flagWhenDone===!0||void 0,budget:e.budget,launch:e.launch,pastBudget:e.pastBudget||void 0,offline:r,armed:!r}),r||se(e.targetSessionId??e.repoDir),L(),r}function ue(e,n,r,i,a,o){let s=e.prompt;if(!s)return;let c=t.current.status!==`open`;D({ackId:eo(),sessionId:e.id,cwd:e.cwd,text:n,ts:Date.now(),status:`queued`,attempts:0,mode:`input`,answer:{fingerprint:ae(s),question:s.question,label:r,...i?{submitBox:!0}:{},...a==null?{}:{choice:a},...o===void 0?{}:{text:o}},offline:c,armed:!0}),G(c?`answer saved — “${r}” goes out when the link is back`:Nh(r)),L()}return{retainUploadBytes:ee,ackWindowFor:P,nextRound:F,armAckTimeout:I,goneLanes:te,flushOutbox:L,idleReason:R,releaseLane:z,uploadRefusal:ne,guardUploadRefs:re,guardChain:B,submitInput:V,queueOp:H,queueImageUpload:ie,runUpload:oe,rewriteQueuedPath:U,armLane:se,queueBacklog:ce,answerPrompt:ue}}function Xh(e){let{outboxRef:t,outbox:n,pendingKept:r,activeIdRef:i,connRef:a,sessions:o,activeId:s}=e,c=t=>e.writeOutbox(t),u=t=>e.flushOutbox(t),d=t=>e.idleReason(t),f=t=>e.holdWall(t),m=(t,n)=>e.retainUploadBytes(t,n),h=(t,n,r)=>e.failPendingCreates(t,n,r),g=(t,n,r)=>e.queueSessionPrompt(t,n,r),_=e.openSend,v=e.sendTargetFor,y=e.setActiveId,b=e.setCompose;function S(){let e=Qi(n);if(!e){G(ur(n)?`those are files, not text — open the message that names one and re-attach it there`:`nothing to put back — the failed items are actions, not text`);return}let t=n.filter(e=>e.status===`failed`&&e.mode!==`op`).length-1;_({prompts:[Ai(e)],target:v(e.sessionId,e.cwd),cwdHint:e.cwd,repoId:I(e),ackId:e.ackId,repair:!0,openAfter:!0,origin:t>0?`This one never went — ${t} more under Manage`:`This one never went`})}function C(){for(let e of t.current)e.status===`failed`&&e.mode===`upload`&&m(e);c(t.current.filter(e=>e.status!==`failed`))}function w(e,n){c(t.current.map(t=>{if(t.ackId!==e||t.status!==`queued`)return t;if(t.mode===`op`){let e=t.op;return e?.t===`session.create`?{...t,text:n,op:{...e,prompt:n}}:!e||e.t!==`fanout.run`&&e.t!==`fanout.followup`?t:{...t,text:n,op:{...e,text:n}}}return{...t,text:n,label:t.mode===`backlog`?n.slice(0,40):t.label}}))}function T(e,n){let r=t.current,i=r.find(t=>t.ackId===e);i&&(l(i)?(Y(`action:queue.retarget`),c(Oe(r,e,{...n,ackId:eo()})),G(n.mode===`backlog`?`moved to that repo's backlog`:`moved to that session`)):G(i.mode===`op`?`an action can't be re-aimed`:`already on its way`))}function E(e){let n=t.current,r=n.find(t=>t.ackId===e);if(!r)return;if(!l(r)){G(`already on its way`);return}if(ve(r.text??``)){r.holdUntilIdle||D(e),G(kc(`idle`,{online:a.current.status===`open`,holder:`phone`,phoneHold:`opens-a-view`}));return}Y(`action:queue.handtodesktop`);let i=eo();c(Oe(n,e,{sessionId:r.sessionId,cwd:r.cwd,ackId:i,mode:`backlog`,targetSessionId:r.sessionId}).map(e=>e.ackId===i?{...e,autoFire:!0,holdUntilIdle:void 0,kind:void 0}:e)),u(),G(kc(`idle`,{online:a.current.status===`open`,holder:`desktop`}))}function D(e){Y(`action:queue.hold`),c(t.current.map(t=>t.ackId===e&&t.status===`queued`?{...t,holdUntilIdle:!t.holdUntilIdle||void 0}:t)),u()}function O(e){Y(`action:queue.serial`),c(t.current.map(t=>t.ackId===e&&t.status===`queued`&&$i(t)?{...t,serial:t.serial?void 0:x(t.cwd)}:t)),u()}function k(e){return t.current.filter(t=>t.mode!==`op`||t.status===`pending`?!1:t.op?.t===`schedule.run`?t.op.id===e:t.op?.t===`schedule.save`&&t.op.entry?.id===e)}function A(e){if(!e.length)return;let n=new Set(e.map(e=>e.ackId));c(t.current.filter(e=>!n.has(e.ackId)))}function j(e){let n=t.current.find(t=>t.ackId===e);r.current.delete(e),i.current===_h(e)&&y(null),n?m(n):rd(`uploads`,e),n?.mode===`upload`&&n.upload&&Un(n.upload.relPath,`the upload was canceled`),c(t.current.filter(t=>t.ackId!==e)),n&&dr(n)&&h(n.sessionId,`the session it was queued for was discarded`,n.ackId)}function M(e,n){let r=t.current.find(t=>t.ackId===e);!r||!dr(r)||r.status!==`queued`?G(`that session is already on its way`):(Y(`action:queue.addprompt`),g(r.cwd,n,r.ackId),G(`queued — it runs after the one before it finishes`))}function ee(e,n){c(p(t.current,e,n))}function N(e){let n=t.current,r=n.find(t=>t.ackId===e);if(!r)return;if(r.status===`failed`){if(r.failState&&r.failState!==`other`){G(r.failState===`unconfirmed`||r.failState===`unsubmitted`?`it may already be in that session — open it and look, or rewrite it to send a fresh copy`:`the desktop remembers refusing this exact message — rewrite it to send it as a new one`);return}r.mode===`upload`&&r.upload&&(ei(r.upload.relPath),rr(r.upload.relPath)),n=c(n.map(t=>t.ackId===e?{...t,status:`queued`,attempts:0,tries:0,round:void 0,retryAt:void 0,waitReason:void 0,ts:Date.now(),reason:void 0,armed:!0}:t))}let i=n.find(t=>t.ackId===e);if(!i)return;let a=n.indexOf(i),o=n.filter((e,t)=>t<a&&e.sessionId===i.sessionId&&e.status===`queued`&&!e.armed),s=i.holdUntilIdle&&!i.pendingCreate?f(i.sessionId):null;s?G(s):(c(n.map((t,n)=>t.ackId===e?{...t,armed:!0,retryAt:void 0,waitReason:void 0,serial:void 0,holdUntilIdle:wh(t)}:n<a&&t.sessionId===i.sessionId&&t.status===`queued`?{...t,armed:!0,retryAt:void 0,waitReason:void 0,holdUntilIdle:wh(t)}:t)),u()?o.length&&G(`${o.length} earlier message${o.length>1?`s`:``} in this session go first`):G(d(`nothing left to send`)))}function P(){let e=t.current.filter(e=>e.status===`failed`&&(!e.failState||e.failState===`other`));if(!e.length){G(`nothing to try again`);return}for(let t of e)t.mode===`upload`&&t.upload&&(ei(t.upload.relPath),rr(t.upload.relPath));let n=new Set(e.map(e=>e.ackId));c(t.current.map(e=>n.has(e.ackId)?{...e,status:`queued`,attempts:0,tries:0,round:void 0,retryAt:void 0,waitReason:void 0,ts:Date.now(),reason:void 0,failState:void 0,failedAt:void 0,armed:!0}:e));let r=u();G(r?`${e.length} back in the queue — sending…`:`${e.length} back in the queue — ${d(`waiting`)}`)}function F(e){let n=t.current.find(t=>t.ackId===e);if(!n)return;if(n.mode===`op`){G(`that's an action — discard it instead`);return}if(n.pendingCreate){j(e),b(e=>e?`${e}\n${n.text}`:n.text),G(`moved into the message box`);return}j(e);let r=o.find(e=>e.id===n.sessionId);if(!r){b(e=>e?`${e}\n${n.text}`:n.text),G(`moved into the message box`);return}let i=vf(r.id),a=i?`${i}\n${n.text}`:n.text;Co(r.id,a),s===r.id&&b(a),G(`moved into ${r.title}'s message box`)}function I(t){return e.repoForCwd(t.cwd)?.id??null}return{restoreOutbox:S,dismissOutbox:C,editQueued:w,retargetQueued:T,handToDesktop:E,toggleHoldQueued:D,toggleSerialQueued:O,scheduleQueueRows:k,dropScheduleQueue:A,removeQueued:j,addPromptToQueuedCreate:M,moveQueued:ee,sendQueuedNow:N,retryFailedQueued:P,restoreQueued:F,repoIdOfEntry:I}}function Zh(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(0),[i,a]=(0,Z.useState)(null),o=(0,Z.useRef)(0),s=(0,Z.useRef)(0),c=(0,Z.useRef)({sent:0,total:0,startedAt:0,fullAt:0}),l=(0,Z.useRef)(new Set),u=(0,Z.useRef)(null);function d(){let e=o.current;if(r(s.current),e<=0){c.current={sent:0,total:0,startedAt:0,fullAt:0},t(null),a(null);return}let n=Date.now(),{sent:i,total:l,startedAt:u}=c.current,d=u?n-u:0,f=d>700&&i>4e4?i/1024/(d/1e3):null,p=l>0&&i>=l;p?c.current.fullAt||(c.current.fullAt=n):c.current.fullAt=0;let m=c.current.fullAt?Math.round((n-c.current.fullAt)/1e3):0,h=l>0?p?100:Math.min(99,Math.round(i/l*100)):0,g=l>i?nd(l-i,f):null;t(l<=0?`Uploading ${e}…`:p?`Sent ${Rl(l)} · waiting for the host${m>2?` · ${m}s`:``}`:`Uploading ${e} · ${h}% · ${Rl(i)}/${Rl(l)}${f?` · ${Math.round(f)} kB/s`:``}${g?` · ${g}`:``}`),a({sent:i,total:l,pct:h,kbps:f,waiting:p})}let f=e!=null,p=ch(f,900);return(0,Z.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>d(),1e3);return()=>window.clearInterval(e)},[f]),{uploading:e,parking:n,upProg:i,setUploading:t,setUpProg:a,inflightRef:o,parkingRef:s,upBytesRef:c,allBufsRef:l,uploadBufRef:u,refreshUploadLabel:d,uploadPending:f,uploadRowLinger:p}}function Qh(e){let{inflightRef:t,parkingRef:n,upBytesRef:r,allBufsRef:i,uploadBufRef:a,setUploading:o,setUpProg:s}=e.up,c=()=>e.up.refreshUploadLabel(),{uploadsInFlight:l,uploadAborts:u,sessionsRef:d,activeIdRef:f,composeTextRef:p,connRef:m,repos:h}=e,g=e.getActive,_=(t,n,r,i,a)=>e.queueImageUpload(t,n,r,i,a),v=t=>e.removeQueued(t),y=t=>e.queueBacklog(t),b=(t,n,r,i,a)=>e.submitInput(t,n,r,i,a),x=t=>e.pushHistory(t),S=e.setCompose;function C(e){let t=a.current;if(t&&!t.closed&&t.repoId===e)return t;let n=g(),r=n?{id:n.id,cwd:n.cwd}:void 0,o={repoId:e,slots:[],started:0,done:0,closed:!1,submit:!1,queue:!1,ctrl:new AbortController,ackIds:[],target:r};return i.current.add(o),a.current=o}function w(e,r,i,a,o){let s=e.started++;e.slots[s]=null,t.current++,n.current++,c(),(async()=>{let l=null,u=h.find(t=>t.id===e.repoId)?.worktreePath??e.repoId,d=e.target?.id??`create:${u}`;try{let t=r instanceof Blob?r:await r,{width:n}=Gs(),s=await Mu(t,i,n),c=await _(e.repoId,s.blob,s.name,d,e.target?.cwd??u);if(!c)e.fail??=`this browser can't hold files offline — reconnect and re-attach`,G(e.fail);else{e.ackIds.push(c.ackId);let t=await Promise.resolve(a),n=s.width&&s.height?{w:s.width,h:s.height}:o??null,r=t?Zu(t,n):``;l=r?`${c.relPath} (marked: ${r})`:c.relPath}}catch{e.fail??=`couldn't read that image`}t.current=Math.max(0,t.current-1),n.current=Math.max(0,n.current-1),e.ctrl.signal.aborted?c():(e.slots[s]=l,e.done++,c(),E(e))})()}function T(){let e=new Set(l.current);for(let t of i.current){t.ctrl.abort();for(let n of t.ackIds)e.add(n)}if(a.current){a.current.ctrl.abort();for(let t of a.current.ackIds)e.add(t)}if(i.current.clear(),a.current=null,e.size||t.current){for(let t of e)u.current.get(t)?.abort(),v(t);t.current=0,n.current=0,r.current={sent:0,total:0,startedAt:0,fullAt:0},o(null),s(null),G(`Uploads canceled`)}}function E(t){if(t.finalized||t.done<t.started||!t.closed)return;t.finalized=!0,i.current.delete(t),a.current===t&&(a.current=null);let n=t.slots.filter(e=>!!e);if(!n.length){G(t.fail??`Upload failed`);return}let r=n.join(` `);Da(r);let o=t.target?d.current.find(e=>e.id===t.target.id&&e.running):null,s=!t.target||f.current===t.target.id,c=p.current,l=c?`${c}${c.endsWith(` `)?``:` `}${r}`:r;if(t.queue&&t.target){let i=(s?l:r).trim();if(y({text:i,repoDir:t.target.cwd,label:i.slice(0,40),targetSessionId:o?t.target.id:void 0,autoFire:!0})===null)return;x(i),s&&S(``),s&&yh(t.target.id)&&e.setActiveId(null),G(o?`Attached ${n.length} · ${kc(`idle`,{online:m.current.status===`open`,holder:`desktop`})}`:`Attached ${n.length} · waiting in this repo's backlog — it opens a session of its own when it runs`)}else if(t.submit&&o){let e=s?l:r;if(!b(o.id,o.cwd,e,e.trimStart().startsWith(`/`)?`command`:`prompt`))return;x(e),s&&S(``),G(`Attached ${n.length} · submitted`)}else s?(S(l),G(t.submit&&!yh(t.target?.id)?`Attached ${n.length} · session gone, in box`:`Attached ${n.length} · ready`)):G(`Attached ${n.length} · copied (switched away)`)}return{ensureUploadBuf:C,queueUpload:w,cancelUploads:T,settleUploads:E}}function $h(e){let{ackTimers:t,outboxRef:n,serialWatchRef:r}=e,i=e,a=t=>e.writeOutbox(t),o=t=>e.flushOutbox(t),s=(t,n,r)=>e.failOutbox(t,n,r),c=()=>e.releaseLane(),l=e.applyDeliverySettled,u=(t,n,r)=>e.failPendingCreates(t,n,r),d=(t,n)=>e.adoptPendingSession(t,n),f=(t,n)=>e.holdForLaunch(t,n);function p(e){let r=t.current.get(e.ackId);r!=null&&(clearTimeout(r),t.current.delete(e.ackId)),e.ok?a(n.current.filter(t=>t.ackId!==e.ackId)):s(e.ackId,e.reason||`could not queue`),c()}function m(e){let o=t.current.get(e.ackId);o!=null&&(clearTimeout(o),t.current.delete(e.ackId));let l=n.current.find(t=>t.ackId===e.ackId);e.ok?(a(n.current.filter(t=>t.ackId!==e.ackId)),l&&dr(l)&&(l.serial&&e.sessionId&&(r.current=[...r.current.filter(e=>e.group!==l.serial),{group:l.serial,sessionId:e.sessionId,at:Date.now()}]),e.sessionId?(a(we(n.current,l.sessionId,e.sessionId,Date.now(),l.ackId)),d(l.ackId,e.sessionId)):e.launchId?f(l.sessionId,l.ackId):u(l.sessionId,`the session was never named — re-aim these or discard them`,l.ackId)),l?.focus&&e.sessionId&&i.focusSession(e.sessionId)):(s(e.ackId,e.reason||`could not start`,`refused`),l?.op?.t===`intent.requeue`&&G(e.reason||`it was not put back — the desktop refused it`)),c()}function h(e){let r=t.current.get(e.ackId);r!=null&&(clearTimeout(r),t.current.delete(e.ackId));let i=n.current.find(t=>t.ackId===e.ackId);if(e.ok)e.state===`forked`?G(e.reason||`forked into a new session`):i&&oi(Date.now()-i.ts),i?.answer&&Qa(Nh(i.answer.label)),a(n.current.filter(t=>t.ackId!==e.ackId)),c();else if(e.retryable)a(n.current.map(t=>t.ackId===e.ackId&&t.status===`pending`?{...Ch(t,!1),waitReason:e.reason||void 0}:t)),c();else if(e.state===`rescued`)a(n.current.filter(t=>t.ackId!==e.ackId)),G(e.reason||`that session is gone — the words are a backlog item now`),c();else{if(s(e.ackId,e.reason||`session gone`,e.state===`unconfirmed`||e.state===`unsubmitted`||e.state===`stale`?e.state:`other`),e.state===`stale`){let e=i?.answer;G(e?`“${e.label}” wasn't sent — that question is gone: ${e.question.slice(0,60)}`:`answer not sent — that question is gone`)}else e.state===`unsubmitted`&&G(`prompt is in the composer but Return didn't take — open the session and press Return`);c()}}function g(e){for(let t of e.items)l(t)}function _(e){l(e.item)}function v(e){i.setLaunches(e.launches);for(let t of e.launches)(t.state===`failed`||t.state===`canceled`)&&u(`create:${t.cwd}`,t.reason||`the session never opened`,t.id)}function y(e){a(we(n.current,`create:${e.cwd}`,e.sessionId,Date.now(),e.id)),d(e.id,e.sessionId),o()}function b(e){let t={budget:e.budget,verdict:e.verdict,...e.periods?{periods:e.periods}:{}};i.setBudget(t),i.budgetRef.current=t,e.verdict.blocked||o()}return{onBacklogAck:p,onOpAck:m,onInputAck:h,onDeliveryList:g,onDeliverySettled:_,onLaunchList:v,onLaunchOpened:y,onBudget:b}}function eg(e,t,n){if(!Array.isArray(e)||!e.length)return{doc:t,n:0};let r=new Set(t.notes.map(e=>e.id)),i=new Map(t.tombs.map(e=>[e.id,e.gone])),a=new Map,o=t;for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;if(typeof e.id!=`string`||!e.id||typeof e.text!=`string`||!e.text.trim()||r.has(e.id))continue;let s=typeof e.ts==`number`&&Number.isFinite(e.ts)?e.ts:n,c=i.get(e.id);if(c!==void 0&&c>=s)continue;let l=a.get(e.id);if(l!==void 0&&l>=s)continue;let u={id:e.id,text:e.text,ts:s},d=Array.isArray(e.steps)?e.steps.filter(e=>typeof e==`string`&&!!e.trim()):[];d.length&&(u.steps=d),typeof e.cwd==`string`&&e.cwd&&(u.cwd=e.cwd),o=S(o,u),a.set(e.id,s)}return{doc:o,n:a.size}}function tg(){if(ht(W.padRescueMigrated))return 0;let e=()=>nt(W.padRescueMigrated,String(Date.now())),{doc:t,n}=eg(it(W.padRescue,[]),er(),Date.now());return n?Hi(t)?(e(),n):0:(e(),0)}function ng(e){if(ht(W.giveupsMigrated))return e;let t=it(W.giveups,[]);if(nt(W.giveupsMigrated,String(Date.now())),!Array.isArray(t)||!t.length)return e;let n=new Set(e.map(e=>e.ackId)),r=new Map(Ua().map(e=>[e.id,e])),i=[];for(let e of t){if(!e||e.retriedAt||e.ackId&&n.has(e.ackId)||e.bytes||e.kind===`file`||e.kind===`answer`)continue;let t=e.padId?r.get(e.padId):void 0,a=(t?[t.text,...t.steps??[]].join(`
|
|
3
|
-
|
|
4
|
-
`):e.text??``).trim();if(!a)continue;let o=e.cwd??``;i.push({ackId:eo(),sessionId:o||`unknown`,cwd:o,text:a,ts:e.ts??Date.now(),status:`failed`,mode:`backlog`,label:a.slice(0,40),failedAt:e.ts??Date.now(),failState:e.failState,reason:e.reason?`${e.reason}${t?``:e.clipped?` (only the shortened copy was kept)`:``}`:`this one never reached a session`})}return i.length?[...e,...i.sort((e,t)=>e.ts-t.ts)]:e}function rg(e){sf(Ht);let t=Yd(Od),n=Yd(Go),{conn:r,...i}=e,{status:a,connRef:o,reconnectAsk:s,setReconnectAsk:c}=r,{sessions:l}=i,u=vc(l),d=vc(i.activeId),f=Fs(`confirmQueue`),[p,m]=(0,Z.useState)(null),h=(0,Z.useRef)(null),[g,_]=(0,Z.useState)([]),v=vc(g),[,y]=(0,Z.useState)(0),x=t.some(e=>e.status===`pending`||e.status===`queued`&&e.retryAt!=null);(0,Z.useEffect)(()=>{if(!x)return;let e=window.setInterval(()=>y(e=>e+1),1e3);return()=>window.clearInterval(e)},[x]);let S=ch(t.some(e=>e.status!==`failed`),fh),w=(0,Z.useRef)(t),T=(0,Z.useRef)(new Map),E=(0,Z.useRef)(new Set),D=(0,Z.useRef)(new Map),O=(0,Z.useRef)(new Set),k=(0,Z.useRef)(new Set),A=(0,Z.useRef)(new Set),M=(0,Z.useRef)([]),ee=(0,Z.useRef)(new Map),N=(0,Z.useRef)(!1),P=(0,Z.useRef)(null),F=(0,Z.useRef)(new Map),{pendingKept:I,pendingEntry:te,pendingSession:R}=qh(i.activeId,t,l),z=Zh(),ne={...i,connRef:o,status:a,reconnectAsk:s,setReconnectAsk:c,sessionsRef:u,activeIdRef:d,getActive:()=>l.find(e=>e.id===i.activeId)??R,budgetRef:h,setBudget:m,launchesRef:v,setLaunches:_,serialSessionsRef:Fs(`serialSessions`),confirmQueueRef:f,autoSendRef:Fs(`autoSend`)},re=ne,B={...ne,outbox:t,outboxRef:w,ackTimers:T,uploadsInFlight:E,uploadAborts:D,busyLanesRef:O,budgetHeldLanesRef:k,busySerialRef:A,serialWatchRef:M,holdQueueRef:N,flushIdleReason:P,queueBlockedRef:F,setQueueBlocked:e=>Go.set(e),pendingKept:I,pendingEntry:te,up:z},V=e=>B.writeOutbox(e),ie=e=>B.flushOutbox(e),ae=(e,t)=>B.retainUploadBytes(e,t),oe=(e,t,n)=>B.failPendingCreates(e,t,n),U=(e,t)=>B.failDependentUploads(e,t);function se(e){let t=u.current.find(t=>t.id===e);if(!t)return null;let n=Ee({limitBlocked:t.limit?.blocked,awaitingInput:t.awaitingInput,promptKind:t.prompt?.kind});return n===`limit`?`blocked on a usage limit — it goes out at the reset`:n===`awaitingAnswer`?t.awaitingInput?`a dialog is open in that session — answer it first`:`a question is on screen in that session — answer it first`:null}function ce(e){return fo(e),w.current=e,Od.set(e),zu(e.filter(e=>e.status!==`failed`).length),e}function le(e,t=!1){let n=w.current,r=t?H(n,e.sessionId):n.length,i=[...n.slice(0,r),e,...n.slice(r)];if(i.length>500){let e=i.length-500,t=new Set(i.filter(e=>e.status!==`failed`).slice(0,e).map(e=>e.ackId));t.size&&(i=i.map(e=>t.has(e.ackId)?(Li(),{...e,status:`failed`,reason:`queue full — older messages were pushed out`,failedAt:Date.now()}):e),G(`queue full — ${t.size} older message${t.size>1?`s`:``} stopped; their words are in Activity`))}if(i.length>1e3){let e=i.filter(e=>e.status===`failed`),t=new Set(e.slice(0,i.length-ll).map(e=>e.ackId));t.size&&(i=i.filter(e=>!t.has(e.ackId)),G(`${t.size} of the oldest failed sends had to be dropped — this device is out of room for them`))}V(i)}function ue(e){le(e,!0)}function de(e,t,n){let r=w.current,i=r.find(t=>t.ackId===e&&t.status!==`failed`);if(i&&(Li(),G(n===`unconfirmed`||n===`unsubmitted`?`Typed — the desktop is confirming it ran. It re-sends it itself if it never landed.`:re.overlayRef.current===`queue`?`Not sent — ${t}. Your words are kept; the row is below.`:`Not sent — ${t}. Your words are kept below — restore or re-aim them.`),V(r.map(r=>r.ackId===e?{...r,status:`failed`,reason:t,failState:n??`other`,failedAt:Date.now()}:r)),dr(i)&&oe(i.sessionId,`the session never opened — ${t}`,i.ackId),i.mode===`upload`&&i.upload)){Un(i.upload.relPath,`it never uploaded — ${t}`),ae(i,!1),U(i,`the image it refers to never uploaded — ${t}`);for(let e of re.launchesRef.current)e.state===`waiting`&&e.needs.includes(i.upload.relPath)&&o.current.send({t:`launch.cancel`,id:e.id})}}function fe(e){if(!e.ackId||e.verdict===`open`)return;let t=w.current.find(t=>t.ackId===e.ackId&&t.status===`failed`);if(!t)return;if(e.verdict===`landed`){V(w.current.filter(e=>e.ackId!==t.ackId)),G(`“${t.text.slice(0,40)}${t.text.length>40?`…`:``}” did run after all — cleared from the queue`);return}let n=e.verdict===`composer`?`still in that session's composer — open it and press Return`:e.reason??(e.verdict===`absent`?`checked — it never landed`:`still unreadable — the desktop could not tell`);V(w.current.map(e=>e.ackId===t.ackId?{...e,reason:n,hostSettled:!0}:e))}Object.assign(B,{writeOutbox:ce,addOutbox:le,addOutboxFirstInLane:ue,failOutbox:de,applyDeliverySettled:fe,holdWall:se}),Object.assign(B,Yh(B)),Object.assign(B,Jh(B)),Object.assign(B,Xh(B)),Object.assign(B,Qh(B));let pe=$h(B);(0,Z.useEffect)(()=>{if(a!==`open`)return;let e=w.current.filter(e=>e.status===`queued`&&e.offline&&!e.armed);if(f.current&&e.length>0){N.current=!0,c(!0),ie();return}N.current=!1;let t=ie();if(t>0){let e=w.current.filter(e=>e.status!==`failed`).length;G(e>t?`sending ${e} queued messages…`:`sent ${t} queued message${t>1?`s`:``}`)}},[a]);let me=t.filter(e=>e.status===`queued`&&e.offline&&!e.armed);(0,Z.useEffect)(()=>{s&&!me.length&&(N.current=!1,c(!1))},[s,me.length]),(0,Z.useEffect)(()=>{if(a===`open`)return;let e=w.current.filter(e=>e.status===`pending`&&e.mode!==`upload`);if(!e.length)return;for(let t of e){let e=T.current.get(t.ackId);e!=null&&(clearTimeout(e),T.current.delete(t.ackId))}let t=new Set(e.map(e=>e.ackId));V(w.current.map(e=>t.has(e.ackId)?{...e,status:`queued`,attempts:Math.max(0,(e.attempts??1)-1),retryAt:void 0,waitReason:void 0}:e))},[a]),(0,Z.useEffect)(()=>{let e=window.setInterval(()=>{ie()},ph);return()=>window.clearInterval(e)},[]);let he=t.filter(e=>e.status===`queued`).length,ge=(0,Z.useRef)(he);ge.current=he,(0,Z.useEffect)(()=>{let e=`queue`,t=()=>navigator.serviceWorker?.getRegistration?.(),n=()=>{try{t()?.then(t=>t?.getNotifications({tag:e}).then(e=>e.forEach(e=>e.close())).catch(()=>{})).catch(()=>{})}catch{}},r=()=>{let r=ge.current;if(r<=0)n();else if(`Notification`in window&&Notification.permission===`granted`)try{t()?.then(t=>t?.showNotification(`Messages still queued`,{body:`${r} message${r>1?`s`:``} waiting to go out. Open ${C.name} to send ${r>1?`them`:`it`}.`,tag:e,silent:!0})).catch(()=>{})}catch{}},i=()=>{document.visibilityState===`hidden`?r():n()};return window.addEventListener(`pagehide`,r),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`pagehide`,r),document.removeEventListener(`visibilitychange`,i)}},[]),(0,Z.useEffect)(()=>{if(!(he>0))try{navigator.serviceWorker?.getRegistration?.()?.then(e=>e?.getNotifications({tag:`queue`}).then(e=>e.forEach(e=>e.close())).catch(()=>{})).catch(()=>{})}catch{}},[he]),(0,Z.useEffect)(()=>{let e=e=>L({turnActive:e.turnActive,limitBlocked:e.limit?.blocked,promptKind:e.prompt?.kind,awaitingInput:e.awaitingInput});O.current=new Set(l.filter(e).map(e=>e.id));let t=kh(l),n=Ah(k.current,t);k.current=t;{let e=j(At(l),M.current,Date.now());A.current=e.busy,M.current=e.watches}let r=!1,i=ee.current;for(let t of l){let n=e(t);i.get(t.id)&&!n&&(r=!0),i.set(t.id,n)}let a=new Set(l.map(e=>e.id));for(let e of i.keys())a.has(e)||i.delete(e);(r||n)&&ie()},[l]);let[_e,ve]=(0,Z.useState)(0);(0,Z.useEffect)(()=>Yn(()=>ve(e=>e+1)),[]),(0,Z.useEffect)(()=>{let e=t.filter(e=>e.status===`queued`||e.status===`pending`).length;hl(e+oo(Ne))},[t,_e]),(0,Z.useEffect)(()=>{let e=w.current.map(e=>e.status===`pending`?{...e,status:`queued`,retryAt:void 0,waitReason:void 0}:e),t=new Set(e.filter(dr).map(e=>e.sessionId)),n=new Set(e.filter(dr).map(e=>e.ackId)),r=e=>e.pendingCreate&&(e.createAck?!n.has(e.createAck):!t.has(e.sessionId));e=e.map(e=>r(e)?(Li(),{...e,pendingCreate:void 0,status:`failed`,reason:`the session it was queued for is gone`,failedAt:Date.now()}):e),V(ng(e));let i=tg();i&&G(b(i))},[]);let ye=B,be=(...e)=>Object.fromEntries(e.map(e=>[e,ye[e]]));return{...be(`writeOutbox`,`addOutbox`,`addOutboxFirstInLane`,`failOutbox`,`applyDeliverySettled`,`holdWall`),...be(`retainUploadBytes`,`ackWindowFor`,`nextRound`,`armAckTimeout`,`goneLanes`,`flushOutbox`,`idleReason`,`releaseLane`,`uploadRefusal`,`guardUploadRefs`,`guardChain`,`submitInput`,`queueOp`,`queueImageUpload`,`runUpload`,`rewriteQueuedPath`,`armLane`,`queueBacklog`,`answerPrompt`),...be(`enterPending`,`enterOldestPending`,`enterLater`,`retryPendingCreate`,`adoptPendingSession`,`queueSessionPrompt`,`holdForLaunch`,`failPendingCreates`,`failDependentUploads`),...be(`restoreOutbox`,`dismissOutbox`,`editQueued`,`retargetQueued`,`handToDesktop`,`toggleHoldQueued`,`toggleSerialQueued`,`scheduleQueueRows`,`dropScheduleQueue`,`removeQueued`,`addPromptToQueuedCreate`,`moveQueued`,`sendQueuedNow`,`retryFailedQueued`,`restoreQueued`,`repoIdOfEntry`),...pe,entries:t,outboxRef:w,blocked:n,holdQueueRef:N,flushIdleReason:P,parkedSends:me,sendSettled:S,budget:p,launches:g,laneLabel:e=>Eh(e,l),PENDING_PREFIX:hh,isPendingId:gh,pendingLaneId:_h,laneFor:xh,pendingEntry:te,pendingSession:R,uploads:{uploading:z.uploading,parking:z.parking,upProg:z.upProg,current:()=>z.uploadBufRef.current,ensureUploadBuf:ye.ensureUploadBuf,queueUpload:ye.queueUpload,settleUploads:ye.settleUploads,cancelUploads:ye.cancelUploads,parkingRef:z.parkingRef,uploadBufRef:z.uploadBufRef,allBufsRef:z.allBufsRef,uploadPending:z.uploadPending,uploadRowLinger:z.uploadRowLinger}}}function ig(e,t,n){if(n?.v===1)return!1;let r=t?.model;if(!r)return!1;let i=pi(e,t?.backend)?.models.where;return i?i[r]===`hosted`:!1}function ag(){let e=it(W.hostedAck,null);return e&&typeof e.v==`number`?e:null}function og(e=Date.now()){let t={at:e,v:1};return pt(W.hostedAck,t),t}function sg(){ft(W.hostedAck)}var Q=Of();function cg({primary:e,targets:t,onOpen:n,onClose:r}){let[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(``),u=Si(e.id,()=>Gd.gitBranches(e.id)),d=u.data;function f(n){if(e.branch===n)return e.worktreePath;let r=t.find(t=>t.repoName===e.repoName&&t.branch===n);return r?r.worktreePath:null}async function p(t){s(null);let r=f(t);if(r){n(r,`${e.repoName} · ${t}`);return}a(t);let i=await Gd.newWorktree(e.id,t);a(null),i.path?n(i.path,`${e.repoName} · ${i.branch??t}`):s(i.error||`could not create worktree`)}return(0,Q.jsxs)(`div`,{className:`sheet`,children:[(0,Q.jsx)(fa,{title:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Vp,{size:16}),` `,e.repoName,` · branch`]}),onClose:r}),(0,Q.jsxs)(`div`,{className:`form`,children:[(0,Q.jsx)(`input`,{className:`search`,placeholder:`Filter, or type a new branch name…`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c.trim()&&p(c.trim())}}),c.trim()&&!d?.some(e=>e.name===c.trim())&&(0,Q.jsxs)(`button`,{className:`send`,disabled:!!i,onClick:()=>p(c.trim()),children:[(0,Q.jsx)(pp,{size:16}),` Create & open “`,c.trim(),`”`]})]}),o&&(0,Q.jsx)(`div`,{className:`err`,children:o}),(0,Q.jsxs)(`div`,{className:`list`,children:[(0,Q.jsx)(Mc,{res:u,empty:!d?.length,thing:`branches`,noun:`branch list`,children:`No local branches.`}),d?.filter(e=>e.name.toLowerCase().includes(c.trim().toLowerCase())).map(e=>{let t=!!f(e.name);return(0,Q.jsxs)(bc,{as:`button`,disabled:i===e.name,onClick:()=>p(e.name),children:[(0,Q.jsx)(`span`,{className:`gstat ${e.current?`g-added`:``}`,children:e.current?`●`:`○`}),(0,Q.jsx)(Ad,{className:`mono`,children:e.name}),(0,Q.jsx)(qo,{children:i===e.name?`creating…`:e.current?`primary`:t?`worktree`:`new worktree`})]},e.name)})]})]})}function lg({cur:e,backends:t,modelInput:n,setModelInput:r,submitInput:i,relaunch:a,sessionCan:o,sessionCant:s,onClose:c}){let l=mo(t,e.backend),u=o(e,`slash`),d=Wt(t,e.backend),f=t=>{i(e.id,e.cwd,`/model ${t}`,`command`),c(),G(`/model ${t}`)},p=t=>a(e,t),m=e=>u?f(e):p({model:e}),h=wr(t,e.backend,u),g=t=>{h?(i(e.id,e.cwd,`/effort ${t}`,`command`),c(),G(`/effort ${t}`)):p({effort:t})};return(0,Q.jsxs)(`div`,{className:`sheet`,children:[(0,Q.jsx)(fa,{title:`Switch model`,onClose:c}),(0,Q.jsxs)(gs,{children:[`Current: `,Na(e.model)||`default`,e.effort?` · ${e.effort}`:``,`.`,` `,u?(0,Q.jsxs)(Q.Fragment,{children:[`Picking a model sends `,(0,Q.jsx)(`span`,{className:`mono`,children:`/model`}),` to this session.`]}):`Picking a model is a launch flag here — it kills and relaunches this session.`]}),(0,Q.jsxs)(`div`,{className:`list`,children:[l.aliases.length>0&&(0,Q.jsx)(`div`,{className:`section`,children:`Aliases`}),l.aliases.map(t=>(0,Q.jsxs)(bc,{as:`button`,onClick:()=>m(t),children:[(0,Q.jsx)(Ad,{className:`mono`,children:t}),e.model===t&&(0,Q.jsx)(lf,{tone:`ok`,children:`current`})]},t)),l.ids.length>0&&(0,Q.jsx)(`div`,{className:`section`,children:`Versions`}),l.ids.map(t=>(0,Q.jsxs)(bc,{as:`button`,onClick:()=>m(t),children:[(0,Q.jsx)(Ad,{className:`mono`,children:t}),e.model===t&&(0,Q.jsx)(lf,{tone:`ok`,children:`current`})]},t)),(0,Q.jsx)(`div`,{className:`section`,children:`Custom`}),l.freeText&&(0,Q.jsx)(gs,{children:Ga(t,e.backend)}),(0,Q.jsxs)(`div`,{className:`form`,children:[(0,Q.jsx)(`input`,{className:`search mono`,placeholder:l.ids[0]?`e.g. ${l.ids[0]}`:`model id`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n.trim()&&(m(n.trim()),r(``))}}),(0,Q.jsx)(`button`,{className:`send`,onClick:()=>{n.trim()?(m(n.trim()),r(``)):G(`type a model id first`)},children:u?`Send /model`:`Relaunch on it`})]}),u?(0,Q.jsx)(bc,{as:`button`,onClick:()=>{i(e.id,e.cwd,`/model`,`command`),c()},children:(0,Q.jsx)(Ad,{children:`Open the model picker…`})}):(0,Q.jsx)(hu,{cants:[{label:`the CLI’s own model picker`,reason:s(e,`slash`)}]})]}),d.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(gs,{children:h?(0,Q.jsxs)(Q.Fragment,{children:[`Picking an effort sends `,(0,Q.jsx)(`span`,{className:`mono`,children:`/effort`}),` to this session.`]}):`Effort is a launch flag here — picking it kills + relaunches this session.`}),(0,Q.jsx)(`div`,{className:`form`,children:(0,Q.jsx)(`div`,{className:`annot-tools`,children:d.map(t=>(0,Q.jsx)(K,{className:e.effort===t?`active`:``,onClick:()=>g(t),children:t},t))})})]}):(0,Q.jsx)(hu,{cants:[{label:`effort`,reason:s(e,`effort`)??`this session has no effort setting`}]})]})}function ug(e){let{backends:t,launch:n,setOverlay:r}=e;return{branches:()=>e.branchPick?(0,Q.jsx)(cg,{primary:e.branchPick,targets:e.repos,onClose:()=>{r(null),e.setBranchPick(null)},onOpen:(t,n)=>{r(null),e.setBranchPick(null),e.openCwd(t,n)}}):null,new:()=>(0,Q.jsx)(ti,{root:e.root,repos:e.repos,onClose:()=>r(null),onChanged:e.refreshRepos,onOpen:e.openCwd,backends:ss(t)?[...dl(t)]:void 0,backend:n.backend,onBackend:e.pickBackend,onBuildApp:Xd}),launchask:()=>{if(!e.launchAskFor)return null;let i=e.launchAskFor;return(0,Q.jsx)(en,{title:i.title,backends:t,defaults:n,budget:i.budget,onRecheck:e.recheckBackends,onStart:(t,n)=>{e.setLaunchAskFor(null),r(null),i.run(t,n)},onClose:()=>{e.setLaunchAskFor(null),r(null),i.onCancel?.()}})},hostedack:()=>{if(!e.hostedAskFor)return null;let n=e.hostedAskFor;return(0,Q.jsx)(da,{title:n.title,backends:t,launch:n.launch,onAccept:()=>{og(),e.setHostedAskFor(null),r(null),n.run(n.launch,n.budget)},onClose:()=>{e.setHostedAskFor(null),r(null),n.onCancel?.()}})},model:()=>e.active?(0,Q.jsx)(lg,{cur:e.active,backends:t,modelInput:e.modelInput,setModelInput:e.setModelInput,submitInput:e.submitInput,relaunch:e.relaunch,sessionCan:e.sessionCan,sessionCant:e.sessionCant,onClose:()=>r(null)}):null}}var dg=`This desktop can’t open a shell — it needs an update.`,fg=1200;function pg(e){let{backends:t,setOverlay:n,geomRef:r,setRepos:i,setReposAt:a,setReposFailAt:o}=e,s=Fs(`launchAsk`),{queueOp:c,enterPending:l,queueSessionPrompt:u}=e.queue,d=e.repoForCwd,[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(Kl),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(``),S=(0,Z.useRef)(t);S.current=t;function C(){Gd.repos().then(e=>{i(e),Os(e),a(Date.now()),ed(`repos`)}).catch(()=>{o(Date.now())})}function w(e){_(t=>{let n={...t,...e};return Object.keys(n).forEach(e=>{n[e]||delete n[e]}),pt(W.launch,n),n})}let T=e=>Gn(e,S.current);function E(e){let{launch:t,...n}=e,i=t?Eu(t,S.current):null;return i&&G(i),{t:`session.create`,...n,cols:r.current.cols,rows:r.current.rows,...t?{launch:T(t)}:null}}function D(e,t,r){let i=pr(S.current,t.launch?.backend);return i&&!Gc(s.current,!!t.resume,!!t.override)?(G(`Not started — ${i}`),t.onCancel?.(),!0):Gc(s.current,!!t.resume,!!t.override)?(p({title:e,run:(n,i)=>{O(e,n,r,t.onCancel,i)||r(n,i)},onCancel:t.onCancel,budget:t.budget}),n(`launchask`),!0):!t.resume&&O(e,t.launch,r,t.onCancel,void 0)}function O(e,t,r,i,a){return!t||!ig(S.current,t,ag())?!1:(Y(`overlay:hostedack`),h({title:e,launch:t,run:r,onCancel:i,budget:a}),n(`hostedack`),!0)}let k=(e,n)=>nr(t,e?ni(e):void 0,n),A=(e,n)=>Gr(t,e?ni(e):void 0,n),j=e=>{if(e.unadopted)return(0,Z.createElement)(lc,null,e.unadopted);if(no(t,e.launch?.backend)||Ut(e))return null;let n=Gr(t,e.launch?.backend,`resumePick`);return n?(0,Z.createElement)(lc,null,n):null},M=e=>w({backend:e,model:void 0,effort:void 0});function ee(t){let n=e.openingCwds().get(t.worktreePath);n&&G(n.status===`pending`?`${n.n>1?`${n.n} already opening`:`one already opening`} in ${t.repoName} — this is another`:`${n.n>1?`${n.n} already queued`:`one already queued`} in ${t.repoName} — this is another`),!D(te(t),{launch:g},(e,n)=>N(t,e,n??void 0))&&N(t,g)}function N(e,t,n){let r=eo();c(E({cwd:e.worktreePath,title:te(e),launch:t,...n?{budget:n}:{}}),`create:${e.worktreePath}`,`open ${te(e)}`,{cwd:e.worktreePath,focus:!0,ackId:r})&&Y(`action:repo.new.offline`),l(r)}function P(e){let t=Jl(S.current);return t?(Y(`action:shell.new`),R(e.worktreePath,`shell · ${te(e)}`,!1,void 0,{backend:t.id})):(G(dg),null)}function F(e){let t=Jl(S.current);return t?(Y(`action:shell.companion`),R(e.cwd,`shell · ${e.title}`,!1,void 0,{backend:t.id},void 0,void 0,e.id)):(G(dg),null)}function I(){return Jl(S.current)?null:dg}function L(t,n={}){let r=Jl(S.current);if(!r)return G(dg),null;let i=$t(),a=n.cwd||e.root,o=Fh({remembered:Bh.get()[t]??null,sessions:i.world.sessions,cwd:a,isShell:e=>no(S.current,e),pendingAlive:e=>i.queue.entries.some(t=>t.ackId===e&&t.status!==`failed`)}),s=null;if(o.do===`attach`){let e=i.world.sessions.find(e=>e.id===o.id);Y(`action:shell.focus`),i.nav.attach(e),s=e.id}else o.do===`enter`?(l(o.ack),s=_h(o.ack)):(Y(`action:shell.new`),s=R(a,n.title||`shell · ${Ws(a)}`,!1,void 0,{backend:r.id}));return s?(Hh(t,s,n.back),s):null}function R(e,t,n=!1,r,i,a,o,s){if(n&&no(S.current,i?.backend)&&(n=!1,r=void 0,a=void 0),D(t,{resume:n,override:!!i,launch:i??g},(i,c)=>{R(e,t,n,r,i,a,c===void 0?o:c??void 0,s)}))return null;Y(n?`action:session.resume`:`action:session.new`);let u=eo();return c(E({cwd:e,title:t,resume:n,resumeMode:r,resumeSessionId:a,launch:i??g,...o?{budget:o}:{},...s?{companionOf:s}:{}}),`create:${e}`,`${n?`resume`:`open`} ${t}`,{cwd:e,focus:!0,ackId:u}),l(u),_h(u)}async function z(e){let t=d(e)?.id;if(!t)return null;try{let e=await Promise.race([Gd.gitStatus(t),new Promise(e=>setTimeout(()=>e(null),fg))]),n=e?.files.length??0;return!e||e.clean||n===0?null:`The worktree has ${n} uncommitted change${n===1?``:`s`} — those edits stay exactly as they are, but the reopened session won't remember making them.`}catch{return null}}async function ne(e,t){let n=t.sourceId||Ut(e);if(!n){G(`This session's conversation is not identified yet, so it cannot be cut here.`);return}let r={...t,sourceId:n};if(r.mode===`reset`){let t=await z(e.cwd),n=[`This session reopens holding the conversation up to just before turn #${r.n}. #${r.n} and everything after it are left behind.`,...e.turnActive?[`A turn is running right now — it will be interrupted.`]:[],`Nothing is deleted: the later turns stay on disk under this conversation and stay listed in the archive. Deleting one is a separate act.`,`No file in the repo is touched — only the conversation is rewound.`,...t?[t]:[]];if(!await Hs({title:`Reset to before #${r.n}?`,lines:n,confirmLabel:`Reset`}))return}let i=r.mode===`fork`?`${e.title} (before #${r.n})`:e.title,a={model:e.model,effort:e.effort,permissionMode:e.permissionMode,remoteControlled:e.remoteControlled,backend:e.backend},o=c(E({cwd:e.cwd,title:i,launch:a,resumeMode:`fork`,resumeSessionId:r.sourceId,forkAtTurn:r.turnId,...r.mode===`reset`?{replaceSessionId:e.id}:null}),`create:${e.cwd}`,r.mode===`fork`?`fork ${e.title} before #${r.n}`:`reset ${e.title} to before #${r.n}`,{cwd:e.cwd,focus:!0});G(o?`queued — the link dropped; it runs when it is back`:r.mode===`fork`?`forking before #${r.n} — a new session opens here`:`resetting to before #${r.n}…`)}function re(r,i,a){let o={model:r.model,effort:r.effort,permissionMode:r.permissionMode,remoteControlled:r.remoteControlled,backend:r.backend},s=T({...o,...i}),l=Ut(r),u=a?.prompt?.trim()||void 0,d=u?mg(u):[];c(E({cwd:r.cwd,title:r.title,launch:s,replaceSessionId:r.id,...u?{prompt:u}:{},...d.length?{needs:d}:{},...l?{resumeMode:`continue`,resumeSessionId:l}:{}}),`create:${r.cwd}`,`relaunch ${r.title} · ${Wr(s,Ni(t,s.backend),t)}`,{cwd:r.cwd,focus:!a?.quiet||e.active?.id===r.id,frontOfLane:d.length>0}),!a?.quiet&&(n(null),G(`relaunch · ${Wr(s,Ni(t,s.backend),t)}`))}function B(e,t,n,r,i,a,o,s){if(D(t,{override:!!i,launch:i??g,onCancel:o,budget:s},(i,c)=>B(e,t,n,r,i,a,o,c===void 0?s:c??void 0)))return;let d=i??g;Y(`action:session.newprompt`);let f=n.map(e=>e.trim()).filter(Boolean),[p,...m]=f,h=mg(p??``),_=eo(),v=c(E({cwd:e,title:t,prompt:p,launch:d,needs:h.length?h:void 0,...s?{budget:s}:{},...a?{resume:!0,resumeMode:`continue`}:{}}),`create:${e}`,p??`open ${t}`,{cwd:e,focus:!0,frontOfLane:h.length>0,ackId:_,serial:r});for(let t of m)u(e,t,_);l(_);let y=m.length>0;G(v?y?`queued — the session opens and runs ${f.length} prompts when the link is back`:`queued — the session opens and runs this when the link is back`:y?`starting… ${m.length} more queued behind it`:`starting…`)}return{launch:g,setLaunch:_,setLaunchOpt:w,pickBackend:M,wireLaunch:T,sessionCan:k,sessionCant:A,reopenCant:j,refreshRepos:C,openRepo:ee,openShell:P,openCompanionShell:F,focusShell:L,shellCant:I,openCwd:R,runForkRequest:ne,startSessionWithPrompt:B,relaunch:re,setBranchPick:y,sheets:ug({backends:t,launch:g,root:e.root,repos:e.repos,active:e.active,launchAskFor:f,setLaunchAskFor:p,hostedAskFor:m,setHostedAskFor:h,branchPick:v,setBranchPick:y,modelInput:b,setModelInput:x,setOverlay:n,submitInput:e.queue.submitInput,refreshRepos:C,openCwd:R,pickBackend:M,relaunch:re,sessionCan:k,sessionCant:A,recheckBackends:()=>{$t().conn.send({t:`backends.recheck`})}})}}function mg(e){let t=new Set;for(let n of e.matchAll(/\.claude\/inbox\/[A-Za-z0-9._-]+/g))t.add(n[0]);return[...t]}var hg=e=>e.preventDefault();function gg(e){let{q:t,status:n,reconnectAsk:r,setReconnectAsk:i,autoSend:a,confirmQueue:o,pullRecords:s,setOverlay:c,stripSessionId:l}=e,{entries:u,parkedSends:d,sendSettled:f,holdQueueRef:p,flushIdleReason:m,flushOutbox:h,idleReason:g,restoreOutbox:_,dismissOutbox:v,laneLabel:y}=t,b=Date.now(),x=u.filter(e=>ui(e,b)),S=u.filter(e=>e.status===`failed`&&!ui(e,b)),C=e=>e.status===`queued`&&e.retryAt!=null&&e.retryAt>b,w=u.filter(e=>e.status===`queued`&&!C(e)),T=l&&n===`open`&&!p.current&&w.length>0&&w.every(e=>e.sessionId===l)?[]:w,E=u.filter(e=>e.status===`pending`||C(e)),D=E.length>0,O=r&&d.length>0,k=(0,Q.jsx)(Ql,{records:s,onRemove:e=>{Y(`action:pull.strip.remove`);for(let t of e)ci.remove(t.item.id);let t=e.filter(e=>!e.local).map(e=>({t:`pull.dismiss`,id:e.item.id})),n=`removed ${e.length===1?e[0].item.name:`${e.length} stopped downloads`}`;t.length?$t().conn.liveSendAll(t,n,`${n} here — the desktop's queue still lists ${t.length===1?`it`:`them`} until the link is back`):G(n)},onOpen:()=>{Y(`overlay:pull`),c(`pull`)}}),A=Oi(s,An()).length>0;return!O&&!S.length&&!x.length&&!T.length&&!D&&!A&&!f?null:(0,Q.jsxs)(Q.Fragment,{children:[k,(0,Q.jsx)(Wu,{records:s}),r&&d.length>0&&(0,Q.jsxs)(`div`,{className:`outbox-recover ask`,children:[(0,Q.jsx)(Wm,{size:14}),(0,Q.jsxs)(`span`,{children:[`Back online — send `,d.length,` message`,d.length>1?`s`:``,` you queued while offline?`]}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:()=>{Y(`action:queue.confirm.send`);let e=h(!0);i(!1),G(e?`sending queued messages…`:g(`nothing left to send`))},children:[(0,Q.jsx)(Am,{size:14}),` Send`]}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:()=>{Y(`action:queue.confirm.review`),c(`queue`)},children:[(0,Q.jsx)(Hm,{size:14}),` Review`]}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:()=>{Y(`action:queue.confirm.hold`),i(!1)},title:`keep them queued — nothing is sent until you release it`,children:[(0,Q.jsx)(X,{size:14}),` Hold`]})]}),S.length===0&&x.length===0&&w.length===0&&!D&&f&&(0,Q.jsxs)(`div`,{className:`outbox-recover sending`,children:[(0,Q.jsx)(bm,{size:14}),(0,Q.jsx)(`span`,{children:`sent`})]}),(S.length>0||x.length>0||T.length>0||D)&&(0,Q.jsx)(`div`,{className:`outbox-recover ${S.length?`failed`:x.length?`confirming`:T.length?`queued`:`sending`}`,children:S.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kp,{size:14}),(0,Q.jsxs)(`span`,{children:[S.length,` message`,S.length>1?`s`:``,` not delivered`,S.length===1&&S[0].reason?` — ${S[0].reason}`:``]}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:_,children:[(0,Q.jsx)(xm,{size:14}),` Restore`]}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:()=>{Y(`action:queue.manage`),Kr(S,`the messages that were not delivered`)},children:[(0,Q.jsx)(Hm,{size:14}),` Manage`]}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:v,children:[(0,Q.jsx)(X,{size:14}),` Dismiss`]}),S.length>1?(0,Q.jsxs)(`div`,{className:`outbox-which`,children:[S.slice(0,3).map(e=>(0,Q.jsxs)(`button`,{className:`outbox-which-row`,onPointerDown:hg,title:`open this one in Activity`,onClick:()=>{Y(`action:queue.which`),Kr([e],`the message you tapped`)},children:[(0,Q.jsx)(`span`,{className:`outbox-which-where`,children:y(e)}),(0,Q.jsx)(`span`,{className:`outbox-which-text`,children:Oh(e)})]},e.ackId)),S.length>3?(0,Q.jsxs)(`button`,{className:`outbox-which-row more`,onPointerDown:hg,onClick:()=>{Y(`action:queue.which.more`),Kr(S,`the messages that were not delivered`)},children:[S.length-3,` more — open the list`]}):null]}):null]}):x.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Zf,{size:14}),(0,Q.jsx)(`span`,{children:$r(x.length)}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:()=>{Y(`action:queue.confirming`),Kr(x,`the messages the desktop is still confirming`)},children:[(0,Q.jsx)(Hm,{size:14}),` Which`]})]}):T.length>0?(0,Q.jsxs)(Q.Fragment,{children:[n===`open`?p.current?(0,Q.jsx)(Gf,{size:14}):(0,Q.jsx)(Zf,{size:14}):(0,Q.jsx)(Xf,{size:14}),(0,Q.jsxs)(`span`,{children:[T.length,` queued`,p.current?` — held until you send them`:n===`open`?D?` — going out one per session`:m.current?` — ${m.current}`:` — going out one per session`:` — will send when the connection is back`]}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:()=>{Y(`action:outbox.retry`),h(!0)||G(g(`nothing left to send`))},children:[(0,Q.jsx)(xm,{size:14}),` Send now`]}),(n!==`open`||p.current||!(a&&!o))&&(0,Q.jsxs)(K,{className:a&&!o?`active`:``,onPointerDown:hg,title:a&&!o?`queued messages go out by themselves as soon as the connection is back — tap to hold them instead`:`send everything queued the moment the connection is back, without asking`,onClick:()=>{let e=!(a&&!o);Y(`action:outbox.auto`),J(`autoSend`,e),J(`confirmQueue`,!e),e&&(p.current=!1,i(!1),h()),G(e?`auto-send on — the queue goes out as soon as the link is back`:`auto-send off — the queue waits for “Send now”`)},children:[(0,Q.jsx)(Dm,{size:14}),` auto `,a&&!o?`on`:`off`]}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:()=>{Y(`action:queue.manage`),Kr(T,`the messages still waiting to go out`)},children:[(0,Q.jsx)(Hm,{size:14}),` Manage`]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(um,{size:14,className:`spin`}),(0,Q.jsx)(`span`,{children:Dh(E)}),(0,Q.jsxs)(K,{onPointerDown:hg,onClick:()=>{Y(`action:queue.manage`),Kr(E,`the messages going out now`)},children:[(0,Q.jsx)(Hm,{size:14}),` Manage`]})]})})]})}function _g(e,t){if(!e||e.kind===`after`)return null;if(e.kind===`at`){if(e.rule.kind===`once`&&!(typeof e.rule.at==`number`&&e.rule.at>t))return null;let{name:n,...r}=e;return r}return e}function vg(e){return e===`now`||e===`idle`?e:null}function yg(e){return e===`this`||e===`new`?e:null}function bg(e,t,n,r,i=40){if(!t)return e;let a={...e[t],at:r};if(n.mode!==void 0){let e=vg(n.mode);e?a.mode=e:delete a.mode}if(n.when!==void 0){let e=_g(n.when,r);e?a.when=e:delete a.when}if(n.where!==void 0){let e=yg(n.where);e?a.where=e:delete a.where}let o={...e,[t]:a},s=Object.keys(o);if(s.length<=i)return o;s.sort((e,t)=>(o[e].at??0)-(o[t].at??0));for(let e of s.slice(0,s.length-i))delete o[e];return o}function xg(e,t){return t?vg(e[t]?.mode)??`now`:`now`}function Sg(e,t){return t?yg(e[t]?.where)??`this`:`this`}function Cg(e,t,n){return t?_g(e[t]?.when,n):null}function wg(e){return`When is set the way you last sent to ${e} — open When to change it`}function Tg(e){let{connRef:t,liveSend:n,liveSendAll:r,queue:i,sessions:a,getVisibleRepos:o,intents:s,usage:c,launch:l,wireLaunch:u,geomRef:d,repoForCwd:f,startSessionWithPrompt:p,setOverlay:m,attach:h}=e,{pendingSession:g,budget:_}=i,{guardChain:v,guardUploadRefs:y,queueOp:b,submitInput:x,queueBacklog:S,writeOutbox:C,outboxRef:w,addOutbox:T,flushOutbox:D,queueImageUpload:O}=i,j=i.entries,M=Nl(),[N,F]=(0,Z.useState)(null),I=(0,Z.useRef)(null);I.current=N;let L=(0,Z.useRef)(null),R=(0,Z.useRef)(it(W.sendMemory,{}));function z(e,t){let n=bg(R.current,e,t,Date.now());n!==R.current&&(R.current=n,pt(W.sendMemory,n))}function ne(e,t){let n=t.kind===`at`?{kind:`at`,rule:t.rule,graceMin:t.graceMin}:t.kind===`after`?{kind:`after`,id:t.id,onlyIfOk:t.onlyIfOk,title:t.title}:{kind:t.kind},i=t.kind===`at`?A(t.rule):t.kind===`now`?_f:P(t,Hn(t,c??void 0)),a=[...new Set(e.flatMap(e=>{let t=s.find(t=>t.id===e)?.cwd,n=t?f(t)?.repoName??Ws(t):``;return n?[n]:[]}))],o=_?.verdict.blocked&&Vt(e,s).length>0?_.verdict.resumeAt?fe(_.verdict.resumeAt):`it clears`:null,l=t.kind===`at`?ba(e.length,i):Rd(e.length,i,a,o),u=t.kind===`at`?s.find(t=>t.id===e[0])?.cwd:void 0;return u&&Dd(e[0],u),r(e.map(e=>({t:`intent.update`,id:e,patch:{trigger:n,...t.kind===`at`?{holdForHost:!!t.waitUntilFree}:{}}})),l,xn)}let re=(e,n)=>{let i=s.find(t=>t.id===e[0]),l=i?.trigger.kind===`at`?{kind:`at`,rule:i.trigger.rule,graceMin:i.trigger.graceMin,...i.holdForHost?{waitUntilFree:!0}:{}}:uo(36e5),u=!1;return(0,Q.jsx)(cf,{seed:{retime:{ids:e},when:l,draftKey:`send.retime`},sessions:a,repos:o(),outbox:j,online:t.current.status===`open`,usage:c,intents:s,buildName:M,onAttach:async()=>[],onAnnotate:()=>{},onSend:t=>(u=ne(e,t.when),u),onClose:()=>u?n.onSent():n.onCancel(),budgetHeld:_?.verdict.blocked?{note:k(_.verdict),resumeAt:_.verdict.resumeAt,ids:Vt(e,s)}:null,onPastBudget:e=>{r(e.map(e=>({t:`intent.waive`,id:e,rung:`budget`,on:!0})),ja(e.length),`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`)&&n.onSent()}})};function V(e,t){let n=e?a.find(t=>t.id===e&&t.running):void 0;return n?{kind:`session`,sessionId:n.id,cwd:n.cwd}:t?{kind:`repo`,cwd:t}:void 0}function H(e){let t=e.target.kind===`repos`,n=e.payload.kind===`prompt`?e.payload.steps:[],r=n[0]??``;return{prompts:n.length?[...n]:[r],target:t&&e.target.kind===`repos`?{kind:`repos`,dirs:e.target.dirs,...e.budget?{budget:e.budget}:{},...e.launch?{launch:e.launch}:{},...e.flagWhenDone?{flagWhenDone:!0}:{}}:{kind:`repo`,cwd:e.cwd,...typeof e.closeWhenDone==`boolean`?{closeWhenDone:e.closeWhenDone}:{},...e.flagWhenDone?{flagWhenDone:!0}:{},...e.budget?{budget:e.budget}:{},...e.launch?{launch:e.launch}:{}},when:e.trigger.kind===`at`?{kind:`at`,rule:e.trigger.rule,graceMin:e.trigger.graceMin??120,name:e.label||ee(e.title,r)||void 0,waitUntilFree:e.serial===!0&&e.holdForHost===!0||void 0}:void 0,cwdHint:e.cwd||null,scheduleId:e.id,origin:`Editing a schedule`}}function ie(e){let t=e.action;return{prompts:t.kind===`backlog`&&t.steps?.length?[...t.steps]:[t.text],target:t.kind===`fanout`?{kind:`repos`,dirs:t.dirs,...t.budget?{budget:t.budget}:{},...t.launch?{launch:t.launch}:{}}:{kind:`repo`,cwd:t.repoDir,...typeof t.closeWhenDone==`boolean`?{closeWhenDone:t.closeWhenDone}:{},...t.kind===`backlog`&&t.flagWhenDone?{flagWhenDone:!0}:{},...t.budget?{budget:t.budget}:{},...t.kind===`backlog`&&t.launch?{launch:t.launch}:{}},when:{kind:`at`,rule:e.rule,graceMin:e.graceMin??120,name:ee(e.name,t.text)||void 0,waitUntilFree:e.waitUntilFree},cwdHint:t.kind===`fanout`?t.dirs[0]??null:t.repoDir,scheduleId:e.id,origin:`Editing a schedule`}}function ae(e){let t=(g?[...a,g]:a).find(t=>t.id===e);t&&h(t)}function oe(e){let t=Po(No,(e.prompts?.length?e.prompts:[``]).join(`\f`),e.cwdHint);t===`kept`?G(Je):t===`refused`&&G(E),L.current=null,F(Vi(e,t)),m(`send`)}function U(e,r){let i=e.prompts.map(e=>e.trim()).filter(Boolean),a=i[0]??``,o=a.slice(0,40),m=e=>e.trimStart().startsWith(`/`)?`command`:`prompt`;if(e.target.kind!==`shell`&&!v(i))return!1;let h=r.scheduleId?s.find(e=>e.id===r.scheduleId)??null:null,g=xr(e,h);if(g.kind===`refuse`)return G(g.why),!1;if(g.kind===`patch`&&h){let t=e.target.kind===`repo`||e.target.kind===`repos`?e.target.budget:void 0;if(JSON.stringify(t??null)!==JSON.stringify(h.budget??null))return G(`a budget can't be changed on a row that is already waiting — remove the budget change, or post this as a new row`),!1;let r={payload:{kind:`prompt`,steps:i},trigger:e.when.kind===`after`?{kind:`after`,id:e.when.id,onlyIfOk:e.when.onlyIfOk,title:e.when.title}:e.when.kind===`at`?{kind:`at`,rule:e.when.rule,graceMin:e.when.graceMin}:{kind:e.when.kind===`idle`?`idle`:`now`},target:e.target.kind===`session`?{kind:`session`,sessionId:e.target.sessionId}:{kind:`repo`},cwd:e.target.kind===`session`||e.target.kind===`repo`?e.target.cwd:void 0,resume:e.target.kind===`repo`?!!e.target.resume:void 0,closeWhenDone:e.target.kind===`repo`?e.target.closeWhenDone??null:void 0,flagWhenDone:e.target.kind===`repo`?So(e.target,e.when)??null:void 0,launch:e.target.kind===`repo`?e.target.launch?u(e.target.launch):null:void 0,holdForHost:e.when.kind===`at`?!!e.when.waitUntilFree:void 0,label:o};return Y(`action:send.retime`),n({t:`intent.update`,id:h.id,patch:r},Cu(e.when),`no connection — this row's clock lives on the desktop and nothing here changed. Its words are still in the box.`)?(e.when.kind===`at`&&h.cwd&&Dd(h.id,h.cwd),!0):!1}if(e.when.kind===`at`&&e.target.kind===`session`){let t=e.when,n=e.target,s={id:r.scheduleId??`i_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,cwd:n.cwd,payload:{kind:`prompt`,steps:i},target:{kind:`session`,sessionId:n.sessionId},trigger:{kind:`at`,rule:t.rule,graceMin:t.graceMin},holdForHost:t.waitUntilFree||void 0,auto:!0,pinned:!0,label:o};if(Y(`action:send.clockSession`),!y(i.join(`
|
|
5
|
-
`),n.sessionId))return!1;let l=b({t:`intent.post`,intent:s},n.sessionId,a,{cwd:n.cwd});Dd(s.id,n.cwd);let u=i.length>1?` · ${i.length} turns`:``,d=Hn(e.when,c??void 0),f=d==null?`when its window opens`:fe(d);return G(l?`Queued offline${u} — it reaches the desktop when the link is back, then waits for ${f}`:`Queued${u} for ${f} — it goes to that session, or to its conversation reopened if the session has gone`),!0}if(e.when.kind===`at`){let t=h?.budget&&(e.target.kind!==`repo`&&e.target.kind!==`repos`||!e.target.budget)?{budget:null}:{},n=e.target.kind===`repos`?{kind:`fanout`,dirs:e.target.dirs,text:a,...e.target.kind===`repos`&&e.target.budget?{budget:e.target.budget}:t,...e.target.launch?{launch:u(e.target.launch)}:{}}:{kind:`backlog`,repoDir:e.target.cwd,text:a,autoFire:!0,...i.length>1?{steps:i}:{},...e.target.kind===`repo`&&typeof e.target.closeWhenDone==`boolean`?{closeWhenDone:e.target.closeWhenDone}:{},...So(e.target,e.when)?{flagWhenDone:!0}:{},...e.target.kind===`repo`&&e.target.budget?{budget:e.target.budget}:t,...e.target.kind===`repo`&&e.target.launch?{launch:u(e.target.launch)}:{}},o={id:r.scheduleId??`s_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,name:(e.when.name??``).trim()||a.split(`
|
|
6
|
-
`)[0].slice(0,60),enabled:!0,rule:e.when.rule,action:n,createdAt:Date.now(),nextAt:Hn(e.when,c??void 0),graceMin:e.when.graceMin,waitUntilFree:e.when.waitUntilFree};Y(`action:schedule.save`);let s=b({t:`schedule.save`,entry:o},`sched:${o.id}`,o.name),l=i.length>1?` · ${i.length} turns`:``,d=e.target.kind===`repo`&&!B(e.when.rule),p=d?` in ${f(e.target.kind===`repo`?e.target.cwd:``)?.repoName??`that repo`}`:``;return d&&e.target.kind===`repo`&&Dd(o.id,e.target.cwd),e.target.kind===`repos`&&i.length>1?G(`scheduled the first step — a sweep is ONE prompt, so the other ${i.length-1} were dropped`):G(d?s?`queued${l} — it is saved to the backlog when the link is back`:`queued${p}${l} for ${o.nextAt==null?`when its window opens`:fe(o.nextAt)} — it is in the backlog`:s?`queued${l} — the schedule is saved when the link is back`:`schedule saved${l}`),!0}if(e.when.kind===`after`){let t=e.when;if(e.target.kind===`repos`&&i.length>1)return G(`a sweep is ONE prompt — the other ${i.length-1} step${i.length===2?``:`s`} would be dropped, so nothing was sent`),!1;let n=e.target.kind===`repos`?e.target.dirs[0]??``:e.target.cwd,r=e.target.kind===`session`?{kind:`session`,sessionId:e.target.sessionId}:e.target.kind===`repos`?{kind:`repos`,dirs:e.target.dirs}:{kind:`repo`},s={id:`i_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,cwd:n,payload:{kind:`prompt`,steps:i},target:r,trigger:{kind:`after`,id:t.id,onlyIfOk:t.onlyIfOk,title:t.title},serial:e.target.kind!==`session`||void 0,auto:!0,pinned:e.target.kind===`session`||void 0,resume:e.target.kind===`repo`?e.target.resume:void 0,closeWhenDone:e.target.kind===`repo`?e.target.closeWhenDone:void 0,flagWhenDone:So(e.target,e.when),budget:e.target.kind===`repo`||e.target.kind===`repos`?e.target.budget:void 0,...(e.target.kind===`repos`||e.target.kind===`repo`)&&e.target.launch?{launch:u(e.target.launch)}:{},label:o};Y(`action:send.after`);let c=e.target.kind===`session`?e.target.sessionId:n;if(!y(i.join(`
|
|
7
|
-
`),c))return!1;let l=b({t:`intent.post`,intent:s},c,a,{cwd:n}),d=i.length>1?` · ${i.length} turns`:``,f=t.title?`“${t.title}”`:`the item before it`;return G(l?`Queued offline${d} — it reaches the desktop when the link is back, then waits for ${f}`:`Queued${d} — it goes in after ${f} finishes`),!0}let _=e.when.kind===`idle`;switch(e.target.kind){case`session`:{let n=e.target.sessionId,r=e.target.cwd,a=0,o=!1;for(let[e,t]of i.entries()){if(e===0&&!_){if(!x(n,r,t,m(t)))return!1;a++;continue}let i=S({text:t,repoDir:r,label:t.slice(0,40),targetSessionId:n,autoFire:!0});if(i===null)return G(`part of that chain could not be queued — its words are still in the box`),!1;o||=i,a++}if(!a)return!1;let s=i.length>1?` · ${i.length-1} more behind it`:``;return G(o||t.current.status!==`open`?`queued — it reaches the desktop when the link is back${s}`:_?`queued on the desktop — it goes in when this session is free${s}`:`sent${s}`),!0}case`repo`:{let t=e.target.cwd;if(!_){let n=f(t),a=e.target.launch??(e.launchChosen?l:void 0);return p(t,n?te(n):Ws(t),i,e.sequential,a,e.target.resume,()=>{oe({prompts:i,target:e.target,cwdHint:t,repoId:r.repoId,origin:r.origin}),G(`nothing was started — your words are back in the send sheet`)},e.target.budget),!0}let n=S({text:a,steps:i,repoDir:t,label:o,autoFire:!0,resume:e.target.resume,closeWhenDone:e.target.closeWhenDone,budget:e.target.budget,flagWhenDone:So(e.target,e.when),...e.target.launch?{launch:u(e.target.launch)}:{}});if(n===null)return!1;let s=i.length>1?` · ${i.length} turns`:``;return G(n?`Queued offline${s} · it reaches the desktop when the link is back`:`Queued${s} · a new session when this repo is free`),!0}case`repos`:{if(!e.sequential){let t=b({t:`fanout.run`,dirs:e.target.dirs,text:a,launch:u(e.target.launch??l),...e.target.budget?{budget:e.target.budget}:{},...So(e.target,e.when)?{flagWhenDone:!0}:{},cols:d.current.cols,rows:d.current.rows},`fanout`,a);return i.length>1?G(`a sweep is ONE prompt — the other ${i.length-1} steps were dropped`):G(t?`queued — the sweep runs when the link is back`:`fanning out to ${e.target.dirs.length} repo${e.target.dirs.length===1?``:`s`}`),!0}let t=0,n=!1;for(let r of e.target.dirs){let s=S({text:a,steps:i,repoDir:r,label:o,autoFire:!0,budget:e.target.budget,flagWhenDone:So(e.target,e.when),...e.target.launch?{launch:u(e.target.launch)}:{}});if(s===null)return G(`part of that sweep could not be queued — its words are still in the box`),!1;n||=s,t++}if(!t)return!1;let r=i.length>1?` · ${i.length} turns each`:``;return G(n?`Queued offline · ${t} repo${t===1?``:`s`}${r} when the link is back`:`Queued for ${t} repo${t===1?``:`s`}${r} — one at a time in each`),!0}case`shell`:{let t=cc(e.target.cwd,e.target.buildId),n=b({t:`build.run`,repoDir:e.target.cwd,buildId:e.target.buildId},jc(e.target.cwd),yc(t),{cwd:e.target.cwd});return G(Ko(n,t)),!0}}}function se(e){e.ackId&&C(w.current.filter(t=>t.ackId!==e.ackId)),e.padId&&Sr([e.padId])}async function ce(e,n,r){Y(`action:resend.reattach`);let i=await ro(e);if(!i){G(`those bytes are no longer on this phone`);return}let a=eo(),o=e.split(`/`).pop()||`file`;await zc(`uploads`,a,i),await Vl(`uploads`,a)?(T({ackId:a,sessionId:r,cwd:r,text:`file · ${o}`,ts:Date.now(),status:`queued`,attempts:0,mode:`upload`,upload:{repoId:n,name:o,relPath:e,size:i.size,type:i.type||`application/octet-stream`},armed:!0}),ei(e),await rr(e),D(),G(t.current.status===`open`?`re-attached — uploading`:`re-attached — uploads when the link is back`)):G(`couldn't park the file on this device`)}let le=(0,Z.useRef)(null),ue=(0,Z.useRef)(null);function de(e,t,n){return Y(`action:resend.replace`),ue.current?.(null),new Promise(e=>{ue.current=async t=>{ue.current=null,e(t)};let r=le.current;r?(r.value=``,r.dataset.repoId=t,r.dataset.cwd=n,r.click()):(ue.current=null,e(null))})}async function pe(e){let t=e.target,n=t.files?.[0]??null,r=t.dataset.repoId??``,i=t.dataset.cwd??``,a=ue.current;if(!n||!r||!a)a?.(null);else try{let{width:e}=Gs(),t=await Mu(n,n.name,e),o=await O(r,t.blob,t.name,i,i);a(o?.relPath??null),G(o?`attached — it uploads before the message`:`couldn't park that file`)}catch{a(null),G(`couldn't read that file`)}}return{sendSeed:N,setSendSeed:F,sendSeedRef:I,sendResumeRef:L,sendMemRef:R,noteSendAim:z,openSend:oe,openSent:ae,dispatchIntent:U,retireSendSource:se,seedFromIntent:H,seedFromSchedule:ie,sendTargetFor:V,retimeMany:ne,renderRetime:re,reattachKept:ce,pickReplacement:de,onPickReplacement:pe,replacePick:le,buildNames:M}}var Eg=3e4;function Dg(e,t,n){if(!e)return{show:!1,sig:``,recentResult:!1,canApply:!1,staleAt:null};let r=!!e.lastResult&&n-e.lastResult.at<3e4,i=!!e.available,a=r?e.lastResult.at+Eg:null,o=[e.current??``,e.latest??``,e.lastResult?.at??0,e.lastError??``].join(`|`);return!e.available&&!e.running&&!r&&!e.lastError||!e.running&&t===o?{show:!1,sig:o,recentResult:r,canApply:i,staleAt:a}:{show:!0,sig:o,recentResult:r,canApply:i,staleAt:a}}var Og=16,kg=6048e5;function Ag(){let e=ht(W.dismissInsecure);return e===`1`?Date.now()+kg:Number(e)||0}var jg=ms(typeof window>`u`?0:Ag());function Mg(){let e=Yu();return e.on?(0,Q.jsxs)(`div`,{className:`staged-bar halt-bar`,role:`alert`,children:[(0,Q.jsx)(Mp,{size:16}),(0,Q.jsx)(`span`,{className:`staged-bar-text`,children:Ds(e)}),(0,Q.jsx)(K,{className:`staged-bar-go`,type:`button`,onClick:ru,children:`Lift halt`})]}):null}function Ng({httpsUrl:e}){let t=Yd(jg);return typeof window>`u`||window.isSecureContext||!e||Date.now()<t?null:(0,Q.jsx)(`div`,{className:`update-bar-wrap`,children:(0,Q.jsxs)(`div`,{className:`update-bar`,children:[(0,Q.jsx)(Up,{size:Og}),(0,Q.jsx)(`span`,{className:`update-text`,children:`Plain HTTP: no offline shell, so a dropped tunnel replaces the app with the browser's timeout page. No push and no background downloads either. Switch to the HTTPS address.`}),(0,Q.jsx)(K,{onClick:()=>{Y(`action:https.switch`),location.href=e+location.pathname+location.hash},children:`switch`}),(0,Q.jsx)(K,{title:`hide for a week — this comes back, because the problem does`,onClick:()=>{let e=Date.now()+kg;jg.set(e),nt(W.dismissInsecure,String(e))},children:(0,Q.jsx)(X,{size:Og})})]})})}var Pg=6048e5,Fg=ms(typeof window>`u`?0:Number(ht(W.dismissPhoneSetup))||0);function Ig({onOpen:e}){let t=Yd(Fg),{steps:n}=Sl(),r=n?vd(n):null;return!r||Date.now()<t?null:(0,Q.jsx)(`div`,{className:`update-bar-wrap`,children:(0,Q.jsxs)(`div`,{className:`update-bar`,children:[(0,Q.jsx)(Nf,{size:Og}),(0,Q.jsxs)(`span`,{className:`update-text`,children:[r,` Downloads, alerts and installs wait for the app to be opened until then.`]}),(0,Q.jsx)(K,{onClick:()=>{Y(`action:phoneSetup.open`),e()},children:`set up`}),(0,Q.jsx)(K,{title:`hide for a week — this comes back while something is still missing`,onClick:()=>{let e=Date.now()+Pg;Fg.set(e),nt(W.dismissPhoneSetup,String(e))},children:(0,Q.jsx)(X,{size:Og})})]})})}function Lg(){let e=q(`dismissedSelfUpdate`),t=is(Hc(),e);return t.show?(0,Q.jsx)(`div`,{className:`update-bar-wrap`,children:(0,Q.jsxs)(`div`,{className:`update-bar`,children:[(0,Q.jsx)(Hf,{size:Og}),(0,Q.jsx)(`span`,{className:`update-text`,children:t.text}),(0,Q.jsx)(K,{title:`see what changed and update the desktop`,onClick:od,children:`review`}),(0,Q.jsxs)(K,{title:`dismiss this — it comes back for a newer version`,onClick:()=>J(`dismissedSelfUpdate`,t.sig),children:[(0,Q.jsx)(X,{size:Og}),` dismiss`]})]})}):null}function Rg({update:e,liveAsk:t,liveSend:n}){let r=q(`dismissedUpdate`),[,i]=(0,Z.useState)(0),{show:a,sig:o,recentResult:s,canApply:c,staleAt:l}=Dg(e,r,Date.now());if((0,Z.useEffect)(()=>{if(l==null)return;let e=setTimeout(()=>i(e=>e+1),Math.max(0,l-Date.now())+50);return()=>clearTimeout(e)},[l]),!e||!a)return null;let u=e.lastResult,d=e.running?`Updating Claude…`:u&&s?u.ok?`Updated: ${u.message}`:`Update failed: ${u.message}`:e.available?`Claude ${e.current??``} → ${e.latest??`new`} available${e.source===`cli`?e.route===`brew`?` (cask lags npm)`:` (the CLI says so)`:``}`:`Claude ${e.current??`(unknown)`} · up to date`,f=e.running?`running`:e.available?``:`idle`,p=(e.running||s)&&e.log&&e.log.length>0;return(0,Q.jsxs)(`div`,{className:`update-bar-wrap ${f}`,children:[(0,Q.jsxs)(`div`,{className:`update-bar ${f}`,children:[(0,Q.jsx)(Hf,{size:Og}),(0,Q.jsx)(`span`,{className:`update-text`,children:d}),e.running?(0,Q.jsxs)(`span`,{className:`act-cant act-cant-inline`,children:[(0,Q.jsx)(um,{size:Og,className:`spin`}),` running — the buttons come back when it finishes`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(K,{onClick:()=>t({t:`update.check`},`no connection — the update lives on the desktop and can't be checked from here`),children:(0,Q.jsx)(xm,{size:Og})}),c&&(0,Q.jsx)(K,{onClick:()=>n({t:`update.apply`},`updating — the host restarts itself when it is done`),children:e.applyLabel??`update`}),(0,Q.jsx)(K,{title:`dismiss this — it comes back for a newer version, a new upgrade result or a new error`,onClick:()=>J(`dismissedUpdate`,o),children:(0,Q.jsx)(X,{size:Og})})]})]}),p&&(0,Q.jsx)(`pre`,{className:`update-log`,ref:e=>{e&&(e.scrollTop=e.scrollHeight)},children:e.log.slice(-50).join(`
|
|
8
|
-
`)})]})}var zg=new Set;function Bg(e,t){let n=`${e}|${t}`;return zg.has(n)||Vg.has(n)}var Vg=new Set;function Hg({active:e,update:n,relaunch:r}){let[,i]=(0,Z.useState)(0),a=Tt(e.id),o=t(e.cliVersion,n?.current);if(!o)return null;let s=`${e.id}|${o.installed}`;if(zg.has(s))return null;let c=h(o,{turnActive:e.turnActive,agents:e.agents?.length,shells:e.shells,resumeId:Ut(e)}),l=async()=>{(!c.loses||await Hs({title:`Restart this session now?`,lines:[`Restarting stops ${c.loses}; their work so far stays in the conversation, but what they were still doing is not finished.`,`The conversation itself reopens on the new version.`],confirmLabel:`Restart now`}))&&(Vg.has(s)||(Vg.add(s),i(e=>e+1),Y(`action:session.cliRestart`),r(e,{})))};return(0,Q.jsx)(`div`,{className:`update-bar-wrap`,children:(0,Q.jsxs)(`div`,{className:`update-bar`,children:[(0,Q.jsx)(Km,{size:Og}),(0,Q.jsxs)(`span`,{className:`update-text`,children:[c.text,c.loses?` Running now: ${c.loses}.`:``]}),Vg.has(s)?(0,Q.jsx)(`span`,{className:`update-text`,children:`restarting — the new session opens here`}):c.cant?(0,Q.jsxs)(lc,{children:[`can't restart here — `,c.cant]}):a===o.installed?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`update-text`,children:`restarts by itself once nothing is running`}),(0,Q.jsx)(K,{onClick:()=>qi(e.id),children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(K,{onClick:()=>void l(),children:`Restart, same conversation`}),(0,Q.jsx)(K,{onClick:()=>zo(e.id,o.installed),children:`When idle`})]}),(0,Q.jsx)(K,{title:`hide this for this version (and cancel a restart waiting for idle) — a newer install asks again`,onClick:()=>{zg.add(s),qi(e.id),i(e=>e+1)},children:(0,Q.jsx)(X,{size:Og})})]})})}var Ug=` `;function Wg(e){return e.replace(/\r?\n/g,`\r`)}function Gg(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length-n;return``.repeat(r)+Wg(t.slice(n))}var Kg={Enter:`\r`,Tab:` `,Escape:`\x1B`,ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Home:`\x1B[H`,End:`\x1B[F`,PageUp:`\x1B[5~`,PageDown:`\x1B[6~`,Delete:`\x1B[3~`};function qg(e){if(e.metaKey)return null;if(e.ctrlKey&&!e.altKey&&/^[a-zA-Z]$/.test(e.key))return String.fromCharCode(e.key.toUpperCase().charCodeAt(0)-64);let t=Kg[e.key];return t?e.key===`Enter`&&e.altKey?`\x1B\r`:t:null}var Jg={ctrl:`off`,alt:`off`,shift:`off`},Yg=e=>({ctrl:e.ctrl!==`off`,alt:e.alt!==`off`,shift:e.shift!==`off`});function Xg(e){return e===`off`?`once`:e===`once`?`lock`:`off`}function Zg(e){return{ctrl:e.ctrl===`lock`?`lock`:`off`,alt:e.alt===`lock`?`lock`:`off`,shift:e.shift===`lock`?`lock`:`off`}}function Qg(e){return e===``?`backspace`:e===`\r`?`enter`:e===` `?`tab`:e===` `?`space`:e}var $g={Enter:`enter`,Tab:`tab`,Escape:`esc`,ArrowUp:`up`,ArrowDown:`down`,ArrowLeft:`left`,ArrowRight:`right`,Home:`home`,End:`end`,PageUp:`pgup`,PageDown:`pgdn`,Delete:`delete`,Backspace:`backspace`};function e_(e){let[t,n]=(0,Z.useState)(Jg),r=(0,Z.useRef)(Jg),i=e=>{r.current=e,n(e)};function a(t,n){let a=Yg(r.current);if(!ue(a)){e(n);return}let o=Se(a,t);`refused`in o?G(`${o.refused}. Nothing was sent.`):(Y(`action:chord.send`),e(o.bytes)),i(Zg(r.current))}let o=pe(Yg(t),``).replace(/\+$/,``);return{mods:t,armed:ue(Yg(t)),heldName:o,tapMod(e){i({...r.current,[e]:Xg(r.current[e])})},clear(){i(Jg)},sendKey:a,sendTyped(t){if(!t)return;if(!ue(Yg(r.current))){e(t);return}let n=Array.from(t),i=0;for(;i<n.length&&ue(Yg(r.current));)a(Qg(n[i]),n[i]),i++;i<n.length&&e(n.slice(i).join(``))}}}var t_=/(?:^|[\s[(])(?:password|passphrase|passcode|pin)\b(?:'[^']*'|"[^"]*"|[^:'"\n]){0,160}:$/i;function n_(e){let t=e.replace(/\s+$/,``);return!t||t.length>200||!t_.test(t)?null:t.trim()}var r_=200,i_=new Set;function a_(){let[e,t]=(0,Z.useState)(``),n=(0,Z.useRef)(``);n.current=e;let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(_t),[o,s]=(0,Z.useState)(-1),c=(0,Z.useRef)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1);function h(){let e=r.current;if(!e)return;e.style.height=`auto`;let t=e.offsetHeight-e.clientHeight;e.style.height=`${Math.min(e.scrollHeight+t,r_)}px`}(0,Z.useLayoutEffect)(h,[e]);function g(e){let t=e.trim();t&&(a(e=>{let n=[...e.filter(e=>e!==t),t].slice(-50);return pt(W.cmdHistory,n),n}),s(-1),u(!1))}function _(e){t(t=>t?`${t}${t.endsWith(` `)?``:` `}${e}`:e)}return{compose:e,setCompose:t,composeNow:n,composeRef:r,cmdHistory:i,histIdx:o,setHistIdx:s,histStash:c,clearArmed:l,setClearArmed:u,composeFocused:d,setComposeFocused:f,snippetOpen:p,setSnippetOpen:m,pushHistory:g,insertCompose:_,growCompose:h}}function o_(e,i){let{compose:a,setCompose:s,composeNow:c,composeRef:l,cmdHistory:u,histIdx:d,setHistIdx:f,histStash:p,clearArmed:m,setClearArmed:g,setSnippetOpen:_,pushHistory:v}=e,{active:y,pending:b,activeId:x,sessions:S,readerShown:C,enterSends:w,cliModeOn:T,setCliModeOn:E,repoForCwd:D}=i,{connRef:O,send:A}=i.conn,j=vc(x),{submitInput:M,queueBacklog:ee}=i.queue,{parkingRef:N}=i.queue.uploads,{dispatchIntent:P,openSend:F,noteSendAim:I,sendMemRef:te}=i.sender,L=Fs(`closeKbOnSend`),R=Fs(`btwToCli`),z=Fs(`busySend`);function ne(){let e=()=>{i.showCli(),G(`switched to the CLI for the /btw answer — the book button above brings the reader back`)};R.current===`switch`?e():R.current!==`stay`&&dc({title:`Switch to the CLI to read the answer?`,lines:[`The CLI answers /btw in an overlay of its own and keeps no record of it, so the reader cannot show it.`,`It stays readable in the CLI until the overlay is closed (Esc).`],confirmLabel:`switch`,cancelLabel:`stay`,tone:`info`,rememberLabel:`don't ask again`}).then(({ok:t,remember:n})=>{n&&(J(`btwToCli`,t?`switch`:`stay`),t||G(`won't ask again — Settings › Writing & reading › /btw from the reader changes it`)),t&&(Y(`action:compose.btwToCli`),e())})}let[re,B]=(0,Z.useState)(`now`),[V,H]=(0,Z.useState)(`this`),[ie,ae]=(0,Z.useState)(null),[oe,U]=(0,Z.useState)(!1),se=(0,Z.useRef)(Ug),ce=(0,Z.useRef)(null),le=e_(Pe),ue=(T||le.armed)&&!b&&!C,de=(0,Z.useRef)(!1);function fe(e){!le.armed&&!T?(de.current=document.activeElement===l.current,se.current=Ug,le.tapMod(e),Re()):le.tapMod(e)}let pe=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{le.armed?(pe.current=!0,se.current=Ug):pe.current&&(pe.current=!1,!T&&!de.current&&l.current?.blur())},[le.armed]),(0,Z.useEffect)(()=>{le.clear()},[x,b,C]);let me=yh(x);(0,Z.useEffect)(()=>{let e=ce.current;e&&e===x&&Co(e,a)},[a,x]),(0,Z.useEffect)(()=>{x?(ce.current=x,s(vf(x)),U(!1)):ce.current=null},[x]),(0,Z.useEffect)(()=>{me?(B(`idle`),H(`new`),ae(null)):(B(xg(te.current,y?.cwd)),H(Sg(te.current,y?.cwd)),ae(null))},[y?.cwd,me]);let he=xu({read:()=>c.current,write:e=>s(e),key:()=>j.current??``});function ge(t,n){let r=T;T&&(E(!1),se.current=Ug),le.clear();let i=j.current===t,a=i?e.composeNow.current:vf(t)??``,o=n.trim()!==``&&a.includes(n.trim());return o||(i?e.insertCompose(n):Co(t,a?`${a}${a.endsWith(` `)?``:` `}${n}`:n)),{leftCli:r,already:o}}function ye(t,n){return e.composeNow.current===t&&(e.composeNow.current=n,e.setCompose(n),!0)}let[be,xe]=(0,Z.useState)(null),[Se,Ce]=(0,Z.useState)(null),[we,Te]=(0,Z.useState)(``),[Ee,De]=(0,Z.useState)(!1);function Oe(e){let t=n_(e);xe(t),t||(Te(``),De(!1),Ce(null))}(0,Z.useEffect)(()=>{xe(null),Te(``),De(!1),Ce(null)},[x]);let ke=be&&be!==Se&&!b&&!ue&&no(null,y?.backend)?be:null;function Ae(){be&&Ce(be),Te(``),De(!1)}let je=vc(ke);function Me(){let e=j.current,t=je.current;return!e||!t?null:{sessionId:e,askLine:t,fill(n){return!n||j.current!==e||je.current!==t?!1:(Te(n),De(!1),!0)}}}function Ne(){y&&(we?O.current.status===`open`?(Y(`action:compose.secret.send`),Pe(`${we}\r`),Te(``),De(!1)):G(`link is down — a password is never queued; send it once the link is back`):G(`type the password first — Send types it into the prompt`))}function Pe(e){y&&(b?G(`no terminal yet — keys reach the CLI once the session opens`):A({t:`session.input`,id:y.id,data:e}))}function Fe(e){if(u.length===0)return;if(g(!1),d===-1){if(e>0)return;p.current=a;let t=u.length-1;f(t),s(u[t]);return}let t=d+e;t<0?(f(0),s(u[0])):t>=u.length?(f(-1),s(p.current)):(f(t),s(u[t]))}function Ie(){m?(s(``),f(-1),p.current=``,g(!1)):(g(!0),G(`Tap clear again to wipe the message box`))}function Le(e){s(t=>(t&&!/\s$/.test(t)?t+`
|
|
9
|
-
`:t)+e.text),f(-1),g(!1),_(!1),l.current?.focus()}function Re(){let e=l.current;if(e){e.focus();try{e.setSelectionRange(e.value.length,e.value.length)}catch{}}}function ze(){let e=!T;Y(e?`action:cli.on`:`action:cli.off`),le.clear(),E(e),se.current=Ug,e&&(Re(),G(O.current.status===`open`?`CLI mode — keys go straight to the session; full screen while the keyboard is up (corner button brings the header back)`:`CLI mode — link is down, so keystrokes are NOT queued`))}function Be(e){e.nativeEvent.isComposing||Ve(e.target)}function Ve(e){let t=Gg(se.current,e.value);se.current=Ug,e.value=Ug,t&&le.sendTyped(t)}function He(e){if(e.nativeEvent.isComposing||e.keyCode===229)return;let t=qg(e);if(!t)return;e.preventDefault();let n=$g[e.key];le.armed&&n?le.sendKey(n,t):Pe(t)}function Ue(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&!e.nativeEvent.isComposing?(e.preventDefault(),(a.trim()||wl())&&qe()):e.key===`Enter`&&w&&(e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||e.nativeEvent.isComposing||e.keyCode===229||(e.preventDefault(),(a.trim()||wl())&&qe()))}function We(){if(!y)return{refuse:``};if(V===`new`)return{target:{kind:`repo`,cwd:y.cwd}};if(V===`other`){if(!ie)return{refuse:ns};let e=S.find(e=>e.id===ie&&e.running);return e?{target:{kind:`session`,sessionId:e.id,cwd:e.cwd}}:{refuse:Wo(S.find(e=>e.id===ie)?.title??null)}}return{target:{kind:`session`,sessionId:y.id,cwd:y.cwd}}}function Ge(){me||(H(`this`),ae(null),I(y?.cwd,{where:`this`}))}let Ke=V===`other`&&ie?S.find(e=>e.id===ie&&e.running)??null:null;function qe(e,c=!1,l,u=!1,d=!1,f=!1){let p=!c&&y&&V===`this`?wl():null;if(p){let t=e??re;Hs({title:`Send the picture too?`,lines:[`With the picture: the marked picture goes up and this message is sent with its path, once it lands.`,a?`Text only: just the words — the picture stays open to finish.`:`The message box is empty, so without it there is nothing to send.`],confirmLabel:`With the picture`,cancelLabel:`Text only`,tone:`info`}).then(n=>{n?(Y(`action:compose.send.picture`),p(t===`idle`?`queue`:`run`)):qe(e,!0)});return}if(!y||!a)return;if(N.current>0){G(`still reading that picture — Send goes the moment it is readable`);return}let m=bl({how:l??e??re,explicit:e!==void 0||l!==void 0,aimedHere:V===`this`,turnActive:!!y.turnActive,pending:b,localCmd:ve(a),pref:z.current});if(m===`ask`){let e=i.queue.budget;xd(qu(e?.verdict.blocked?k(e.verdict):null)).then(e=>{if(!e)return;let t=e.ok?`now`:`idle`;Y(e.alt?`action:compose.busy.pastbudget`:`action:compose.busy.${t}`),e.remember&&(J(`busySend`,t),G(Ts(t))),qe(void 0,!0,t,!!e.alt)});return}let g=e??m,_=y.budget;if(!d&&g===`now`&&V===`this`&&_?.cfg.hard&&o(y)&&!ve(a)){Hs(pn(n(_.verdict))).then(t=>{Y(t?`action:compose.hardbudget.send`:`action:compose.hardbudget.keep`),t&&qe(e,!0,g,u,!0)});return}let x=!f&&g===`now`&&V===`this`&&!b&&!ve(a)?t(y.cliVersion,i.cliInstalled):null,S=x?`${y.id}|${x.installed}`:``;if(x&&!Bg(y.id,x.installed)&&!i_.has(S)){let t=h(x,{turnActive:y.turnActive,agents:y.agents?.length,shells:y.shells,resumeId:Ut(y)});if(!t.cant&&!t.loses){let t=y;xd({..._e(x),tone:`info`}).then(n=>{if(!n)return;if(!n.ok){Y(`action:compose.restart.sendOld`),i_.add(S),qe(e,!0,g,u,!0,!0);return}Y(`action:compose.restart.thenSend`);let r=a;i.relaunch(t,{},{prompt:r}),v(r),s(``),Je()});return}}let w=e??re;Y(`action:compose.send.${g}`);let T=a,E=O.current.status===`open`;if(V!==`this`){let e=We();if(`refuse`in e){e.refuse&&G(e.refuse),V===`other`&&ie&&Ge();return}let t=e.target.cwd;if(!P({prompts:[T],target:e.target,when:g===`idle`?{kind:`idle`}:{kind:`now`},sequential:!1},{prompts:[T],target:e.target,cwdHint:t,repoId:D(t)?.id??null,origin:y.title}))return;if(v(T),s(``),me){Je(),i.leave();return}I(y.cwd,{mode:w,where:V}),B(w),Je();return}let A=ve(T),j=g===`idle`&&!b&&!A?`desktop`:`phone`;if(g===`idle`&&j===`desktop`){let e=ee({text:T.trim(),repoDir:y.cwd,label:T.trim().slice(0,40),targetSessionId:y.id,autoFire:!0,...u?{pastBudget:!0}:{}});if(e===null)return;v(T),s(``);let t=u?tu(!e):kc(`idle`,{online:!e,holder:j});t&&G(t),I(y.cwd,{mode:w}),B(w),Je();return}if(!M(y.id,y.cwd,T,T.trimStart().startsWith(`/`)?`command`:`prompt`,g===`idle`))return;v(T),s(``);let F=kc(g,{online:E,holder:j,phoneHold:A?`opens-a-view`:`session-not-open`});F&&G(F),C&&g!==`idle`&&r(T)&&ne(),I(y.cwd,{mode:w}),B(w),Je()}function Je(){L.current&&l.current?.blur()}function Ye(){if(!y)return;Y(`action:compose.options`);let e=Cg(te.current,y.cwd,Date.now()),t=We(),n=y.id,r=a;F({prompts:a?[a]:[``],target:`target`in t?t.target:{kind:`session`,sessionId:y.id,cwd:y.cwd},cwdHint:y.cwd,repoId:D(y.cwd)?.id??null,...e?{when:e}:{},origin:e&&e.kind!==`now`?`${y.title} · ${wg(D(y.cwd)?.repoName??Ws(y.cwd))}`:y.title,onPosted:()=>{j.current===n?(s(``),yh(n)&&i.leave()):vf(n)===r&&Co(n,``)}})}function Xe(){let e=a.trim();if(!e){G(Ul);return}Y(`action:compose.pad`);let t=We(),n=`target`in t?t.target.cwd:y?.cwd,r=jt({id:Mr(),text:e,ts:Date.now(),...n?{cwd:n}:{}});r?G(r):(v(a),s(``),G(Fu))}function Ze(e){if(!y)return;Y(`action:hdrcmd.send`);let t=e.text;M(y.id,y.cwd,t,t.trimStart().startsWith(`/`)?`command`:`prompt`)&&(v(t),G(O.current.status===`open`?`sent ${e.title}`:`queued ${e.title} — sends when the link is back`))}return{...e,sendMode:re,setSendMode:B,sendWhere:V,setSendWhere:H,sendWhereSid:ie,setSendWhereSid:ae,sendMenu:oe,setSendMenu:U,cliMode:ue,enterSends:w,voice:he,aimedSession:Ke,noteSendAim:I,chord:le,tapChordMod:fe,sendInput:Pe,stepHistory:Fe,clearCompose:Ie,appendSnippet:Le,focusPipe:Re,toggleCliMode:ze,onPipeInput:Be,flushPipe:Ve,onPipeKey:He,onComposeKey:Ue,aimHere:Ge,sendCompose:qe,openComposeSend:Ye,keepOnPad:Xe,runHeaderCmd:Ze,seedDraft:ge,typeOn:ye,sendNow:()=>qe(`now`),secretAskLine:ke,secret:we,setSecret:Te,secretShown:Ee,setSecretShown:De,noteCursorLine:Oe,dismissSecret:Ae,sendSecret:Ne,secretFillContext:Me}}function s_(e=!1){let t=new Set;return(n,r,i,a)=>{console.error(`${D} feature ${n} failed on ${r}`,i);let o=`${n}\u0000${r}`;if(t.has(o)||!a)return;t.add(o);let s=()=>{try{a.say.toast(`${n} stopped handling ${r}`),a.say.track(`feature-fail:${n}`)}catch(e){console.error(`${D} could not report a feature failure`,e)}};e?queueMicrotask(s):s()}}function c_(e,t){let n=new Map;for(let t of e)for(let[e,r]of Object.entries(t.messages??{})){if(!r)continue;let i=n.get(e)??[];i.push({id:t.id,fn:r}),n.set(e,i)}let r=new Map;for(let t of e)for(let[e,n]of Object.entries(t.pushes??{}))r.set(`${t.id}\u0000${e}`,{id:t.id,fn:n});let i=new Map(e.flatMap(e=>(e.commands??[]).map(t=>[t.id,{feature:e.id,run:t.run}]))),a=s_();return{dispatch(e){if(e.t===`plugin.push`){let n=r.get(`${e.plugin}\u0000${e.event}`);if(n){let r=t();try{n.fn(e.data,r)}catch(t){a(n.id,`push ${e.event}`,t,r)}}}let i=n.get(e.t);if(!i)return;let o=t();for(let t of i)try{t.fn(e,o)}catch(n){a(t.id,e.t,n,o)}},runCommand(e){let n=i.get(e);if(!n)return!1;let r=t();try{n.run(r)}catch(t){a(n.feature,e,t,r)}return!0},boot(){let n=t(),r=[];for(let t of e)try{let e=t.boot?.(n);typeof e==`function`&&r.push(e)}catch(e){a(t.id,`boot`,e,n)}return()=>{for(let e of r.reverse())e()}}}}function l_(e){let t=(e,t)=>!String(t.id).startsWith(`feature:`)||String(t.id).startsWith(`feature:${e.id}/`)?!0:(console.error(`${D} feature ${e.id} declares sheet ${t.id}, which is not under feature:${e.id}/ — dropped`),!1),n=new Map(e.flatMap(e=>(e.sheets??[]).filter(n=>t(e,n)).map(e=>[e.id,e])));return{sheets:n,leave(e,t){e&&e!==t&&n.get(e)?.onLeave?.()}}}function u_(e,t){let n=e.flatMap(e=>(e.settings??[]).map((t,n)=>({feature:e.id,key:`${e.id}:${n}`,d:t})));pl(n.flatMap(e=>(e.d.rows??[]).map(t=>({...t,group:e.d.group}))));let r=s_(!0);return{rows(e,i){let a=i?.from??-1/0,o=i?.to??1/0,s=n.filter(t=>t.d.group===e&&t.d.order>=a&&t.d.order<o);if(!s.length)return[];let c=t(),l=[];for(let t of[...s].sort((e,t)=>e.d.order-t.d.order))try{l.push({key:t.key,node:t.d.render(c)})}catch(n){r(t.feature,`settings:${e}`,n,c)}return l}}}function d_(e,t){let n=new Map(e.flatMap(e=>(e.toolbarItems??[]).map(t=>[t.id,{feature:e.id,d:t}]))),r=s_(!0);return{item(e,i){let a=n.get(e);if(!a)return;let o=t();try{return a.d.render(o,i)}catch(t){return r(a.feature,`toolbar:${e}`,t,o),null}}}}function f_(e,t){let n=e.flatMap(e=>(e.repoActions??[]).map(t=>({feature:e.id,d:t}))),r=s_(!0);return{actions(e){if(!n.length)return[];let i=t(),a=[];for(let{feature:o,d:s}of n)try{let n=s.label(e,i);if(n==null)continue;let c=s.title?.(e);a.push({key:`${o}:${s.id}`,feature:o,id:s.id,icon:s.icon,label:n,...c?{title:c}:{},run:()=>{let n=t();try{s.run(e,n)}catch(e){r(o,`repo action ${s.id}`,e,n)}}})}catch(e){r(o,`repo action ${s.id}`,e,i)}return a}}}function p_(e){return e.flatMap(e=>(e.repoChips??[]).map(t=>({key:`${e.id}:${t.id}`,feature:e.id,def:t})))}function m_(e){return e.flatMap(e=>[...e.setupRows??[]])}function h_(e){return e&&Number.isFinite(e.n)&&e.n>0?Math.floor(e.n):0}function g_(e,t){return Math.max(0,e)+t.reduce((e,t)=>e+h_(t),0)}function __(e,t){return e===!0?null:typeof e==`string`&&e.trim()?e.trim():`${t} is not available here`}function v_(e,t,n,r,i){let a=e.flatMap(e=>(t(e)??[]).map(t=>({feature:e.id,d:t}))).sort((e,t)=>(e.d.order??0)-(t.d.order??0)),o=s_(!0);return{entries(...e){if(!a.length)return[];let t=r(),s=[];for(let{feature:c,d:l}of a)try{let a=l.available?__(l.available(t),l.label):null;s.push({key:`${c}:${l.id}`,feature:c,id:l.id,label:l.label,icon:l.icon,unavailable:a,open:()=>{let t=r();try{i(l,t,...e)}catch(e){o(c,`${n} ${l.id}`,e,t)}}})}catch(e){o(c,`${n} ${l.id}`,e,t)}return s}}}function y_(e,t){let n=v_(e,e=>e.sessionViews,`session view`,t,(e,t,n)=>e.open(t,{sessionId:n}));return{views:e=>n.entries(e)}}function b_(e,t){let n=v_(e,e=>e.launcherItems,`launcher item`,t,(e,t)=>e.open(t)),r=new Map;for(let t of e)for(let e of t.launcherItems??[])typeof e.useCount==`function`&&r.set(`${t.id}:${e.id}`,e);let i=s_(!0),a=(e,n)=>({...e,useCount:n.useCount,...typeof n.openCount==`function`?{openCount:()=>{let r=t();try{n.openCount(r)}catch(t){i(e.feature,`launcher item ${n.id}`,t,r)}}}:{}});return{items:()=>n.entries().map(e=>{let t=r.get(e.key);return t?a(e,t):e})}}var x_=(e,t)=>`${e}:${t}`;function S_(e){return e.flatMap(e=>(e.menuItems??[]).map(t=>({feature:e.id,d:t}))).sort((e,t)=>(e.d.order??0)-(t.d.order??0)).map(({feature:e,d:t})=>({id:x_(e,t.id),name:t.label,Icon:t.icon}))}function C_(e,t){let n=v_(e,e=>e.menuItems,`menu item`,t,(e,t,n)=>e.open(t,{active:n}));return{items:e=>n.entries(e)}}function w_(e,t){let n=v_(e,e=>e.secretFillers,`secret filler`,t,(e,t,n)=>e.open(t,n)),r=new Map;for(let t of e)for(let e of t.secretFillers??[])r.set(`${t.id}:${e.id}`,e);let i=s_(!0);return{items:e=>n.entries(e).flatMap(n=>{let a=r.get(n.key);if(!a?.labelFor)return[n];try{let t=a.labelFor(e);return t?[{...n,label:t}]:[]}catch(e){return i(n.feature,`secret filler ${a.id}`,e,t()),[]}})}}var T_=null,E_=null,D_=null,O_=null,k_=null,A_=null,j_=null,M_=null,N_=null,P_=e=>(T_??=f_(Vo,$t)).actions(e),F_=e=>(k_??=y_(Vo,$t)).views(e),I_=()=>(A_??=b_(Vo,$t)).items();function L_(e){let t=I_().find(t=>t.feature===e&&!t.unavailable);return t?(t.open(),!0):!1}var R_=e=>(j_??=C_(Vo,$t)).items(e);Id(()=>N_??=S_(Vo));var z_=e=>(M_??=w_(Vo,$t)).items(e);Do(z_);var B_=()=>E_??=p_(Vo);Us(()=>(D_||(D_=fc(m_(Vo)),D_.refused.length&&console.error(`${D} setup rows refused (they name a core guidance key or fix): ${D_.refused.join(`, `)}`)),D_));function V_(e){let t=[],n=[];for(let r of e)for(let e of r.ledgerViews??[])e.id===`claude`||t.some(t=>t.id===e.id)?n.push(`${r.id}:${e.id}`):t.push(e);return{views:t,refused:n}}go(()=>{if(!O_){let e=V_(Vo);e.refused.length&&console.error(`${D} ledger views refused (claude, or an id already taken): ${e.refused.join(`, `)}`),O_=e.views}return O_}),$l(Lu),es(()=>Vo);var H_=c_(Vo,$t);function U_(e){Gu().onFrame(e),Ks().onText(e),H_.dispatch(e)}function W_(e){return H_.runCommand(e)}function G_(){return H_.boot()}var K_=s_(!0),q_=class extends Z.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){let n=null;try{n=$t()}catch{}K_(this.props.feature,`drawing ${this.props.what}`,e,n)}render(){return this.state.failed?(0,Q.jsxs)(lc,{children:[this.props.feature,` could not draw `,this.props.what]}):this.props.children}},J_=l_(Vo),Y_=new Map;for(let[e,t]of J_.sheets){let n=/^feature:([^/]+)\//.exec(e);if(!n)continue;let r=()=>t.render($t());Y_.set(e,()=>(0,Z.createElement)(q_,{feature:n[1],what:`its sheet`,children:(0,Z.createElement)(r)}))}function X_(){let e={};for(let[t,n]of J_.sheets)e[t]=Y_.get(t)??(()=>n.render($t()));return e}function Z_(e,t){J_.leave(e,t)}var Q_=class{held=[];flushing=!1;keep(e,t){return!this.held||t>0&&!this.flushing?!1:(this.held.length<1e3&&this.held.push(e),!0)}subscribed(e,t){this.held&&!this.flushing&&(this.flushing=!0,e(()=>{let e=this.held??[];this.held=null,this.flushing=!1;for(let n of e)t(n)}))}};function $_(e){let t=I(U(e,Date.now()));return aa(`up`,t.length),t}function ev(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof Blob<`u`&&e instanceof Blob?e.size:0}var tv=12e3,nv=1200,rv=2,iv=8e3,av=3e4,ov=4e3,sv=null;function cv(e){sv=e}var lv=class{url;dial;ws=null;listeners=new Set;binaryListeners=new Set;early=new Q_;queue=[];reconnectTimer=null;heartbeatTimer=null;awaitingPong=!1;pingAt=0;probeResolve=null;probeTimer=null;probeAt=0;verifyTimer=null;verifyPending=!1;verifyPings=0;watchdogTimer=null;authPaused=!1;redialing=!1;dialGuard=null;status=`connecting`;constructor(e,t=null){this.url=e,this.dial=t,this.connect();let n=()=>{(typeof document>`u`||document.visibilityState===`visible`)&&this.verifyAlive()};typeof document<`u`&&(document.addEventListener(`visibilitychange`,n),document.addEventListener(`resume`,n),document.addEventListener(`freeze`,()=>this.dropSocketForSleep())),typeof window<`u`&&(window.addEventListener(`online`,n),window.addEventListener(`focus`,n),window.addEventListener(`pageshow`,n),window.addEventListener(`pagehide`,()=>this.dropSocketForSleep()),window.addEventListener(Ui,()=>this.verifyAlive()))}dropSocketForSleep(){this.stopHeartbeat();try{this.ws?.close()}catch{}}verifyAlive(){if(!this.authPaused){if(this.armWatchdog(),!this.ws||this.ws.readyState!==WebSocket.OPEN){if(this.ws&&this.ws.readyState===WebSocket.CONNECTING)return;this.forceReconnect()}else this.verifyTimer??(this.verifyPings=0,this.sendVerifyPing())}}sendVerifyPing(){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)this.forceReconnect();else{this.verifyPending=!0,this.verifyPings++,this.pingAt=Date.now();try{this.ws.send($_({t:`ping`}))}catch{this.forceReconnect();return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.verifyPending&&(this.verifyPending=!1,this.verifyPings<rv?this.sendVerifyPing():this.forceReconnect())},nv)}}probe(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN||this.probeResolve)return Promise.resolve(null);try{this.ws.send($_({t:`ping`}))}catch{return Promise.resolve(null)}let t=Date.now();return new Promise(n=>{this.probeResolve=e=>n(e),this.probeTimer=window.setTimeout(()=>this.settleProbe(null),e),this.probeAt=t})}settleProbe(e){this.probeTimer!=null&&(window.clearTimeout(this.probeTimer),this.probeTimer=null);let t=this.probeResolve;this.probeResolve=null,t&&t(e)}armWatchdog(){this.clearWatchdog(),this.watchdogTimer=window.setTimeout(()=>{this.watchdogTimer=null,this.maybeForceReload()},iv)}async maybeForceReload(){if(this.status!==`open`){if(sv?.())this.armWatchdog();else if((typeof document>`u`||document.visibilityState===`visible`)&&(typeof navigator>`u`||navigator.onLine!==!1)&&await this.hostReachable()&&(this.hasShellCache()||await this.hostReachable())&&this.ws?.readyState!==WebSocket.OPEN&&(typeof navigator<`u`&&navigator.serviceWorker?.controller||await this.hostReachable()&&this.ws?.readyState!==WebSocket.OPEN)){try{let e=Number(sessionStorage.getItem(W.lastForcedReload)||0);if(Date.now()-e<av)return;sessionStorage.setItem(W.lastForcedReload,String(Date.now()))}catch{}Lt(),location.reload()}}}hasShellCache(){try{return!!navigator.serviceWorker?.controller}catch{return!1}}async hostReachable(){try{let e=new AbortController,t=window.setTimeout(()=>e.abort(),ov);try{return(await fetch(`/api/health`,{cache:`no-store`,signal:e.signal,credentials:`same-origin`})).ok}finally{window.clearTimeout(t)}}catch{return!1}}clearWatchdog(){this.watchdogTimer!=null&&(window.clearTimeout(this.watchdogTimer),this.watchdogTimer=null)}reconnect(){this.authPaused=!1,this.armWatchdog(),this.forceReconnect()}get dialUrl(){return this.url}setDialGuard(e){this.dialGuard=e}redial(e){e===this.url&&this.ws&&this.ws.readyState<=WebSocket.OPEN||(this.url=e,this.authPaused=!1,this.redialing=!0,this.forceReconnect())}startHeartbeat(){this.stopHeartbeat(),this.awaitingPong=!1,this.heartbeatTimer=window.setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&(document.visibilityState===`hidden`&&Ys(lo())?this.awaitingPong=!1:this.awaitingPong?(this.awaitingPong=!1,this.forceReconnect()):(this.awaitingPong=!0,this.pingAt=Date.now(),this.ws.send($_({t:`ping`}))))},tv)}stopHeartbeat(){this.heartbeatTimer!=null&&(window.clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}forceReconnect(){this.reconnectTimer!=null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null);let e=this.ws;if(e){e.onopen=e.onmessage=e.onclose=e.onerror=null;try{e.close()}catch{}this.ws=null}this.connect()}connect(){if(this.redialing)this.redialing=!1;else if(this.dialGuard)try{this.url=this.dialGuard(this.url)||this.url}catch{}this.status=`connecting`,this.emitStatus();let e;try{let t=Is(hd());e=this.dial?this.dial(this.url,t):t?new WebSocket(this.url,t):new WebSocket(this.url)}catch{this.status=`closed`,this.emitStatus(),this.scheduleReconnect();return}this.ws=e;try{e.binaryType=`arraybuffer`}catch{}e.onopen=()=>{this.status=`open`,this.clearWatchdog(),this.verifyPending=!1,this.emitStatus(),this.send({t:`hello`,protocol:2});let e=this.queue;this.queue=[];for(let t of e)this.send(t);this.startHeartbeat()},e.onmessage=e=>{let t=typeof e.data!=`string`;if(t?aa(`down`,ev(e.data)):aa(`down`,e.data.length),cu(),this.awaitingPong=!1,this.verifyPending=!1,this.verifyTimer!=null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null),this.clearWatchdog(),t){e.data instanceof ArrayBuffer&&this.deliverBinary(e.data);return}let n;try{n=he(e.data)}catch{return}n.t===`pong`?(this.pingAt&&=(il(Date.now()-this.pingAt),0),this.probeResolve&&this.settleProbe(Date.now()-this.probeAt)):(n.t===`authRequired`&&(this.authPaused=!0,this.clearWatchdog()),this.deliver(n))},e.onclose=()=>{this.status=`closed`,this.settleProbe(null),this.stopHeartbeat(),this.emitStatus(),this.scheduleReconnect()},e.onerror=()=>e.close()}scheduleReconnect(){this.authPaused||(this.reconnectTimer??=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},1e3))}emitStatus(){wf(this.status),this.deliver({t:`error`,message:this.status,context:`__status`})}deliver(e){this.early.keep(e,this.listeners.size)||this.fanOut(e)}fanOut(e){for(let t of this.listeners)try{t(e)}catch(t){console.error(`${D} socket listener failed on ${e.t}`,t)}}deliverBinary(e){for(let t of this.binaryListeners)try{t(e)}catch(e){console.error(`${D} binary listener failed`,e)}}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send($_(e)):this.queue.push(e)}trySend(e){return!this.ws||this.ws.readyState!==WebSocket.OPEN?!1:(this.ws.send($_(e)),!0)}on(e){return this.listeners.add(e),this.early.subscribed(queueMicrotask,e=>this.fanOut(e)),()=>this.listeners.delete(e)}onBinary(e){return this.binaryListeners.add(e),()=>this.binaryListeners.delete(e)}},uv=null;function dv(){if(!uv){let e=yl();if(!e)throw Error(`no host paired — open the host setup screen`);let t=dt();uv=t?new lv(e,t.dial):new lv(e)}return uv}var fv=1800,pv={enabled:!1,gateTailscale:!1,canManage:!1};function mv(){let e=(0,Z.useRef)(dv()),[t,n]=(0,Z.useState)(()=>e.current.status);(0,Z.useEffect)(()=>{n(e.current.status)},[]);let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)({tailscaleIp:null,tailscaleBin:null,httpsUrl:null,lanIps:[],hostPort:8770,root:``,auth:pv}),s=e=>o(t=>({...t,...e})),c=e=>s({tailscaleIp:e.tailscaleIp,tailscaleBin:e.tailscaleBin,root:e.root,httpsUrl:e.httpsUrl??null,lanIps:e.lanIps,hostPort:e.port,auth:e.auth}),[l,u]=(0,Z.useState)(!1),d=e.current.send.bind(e.current);function f(t,n,r){return e.current.status===`open`?(d(t),G(n),!0):(G(r??`no connection — the desktop didn't get that. Try again when the link is back.`),!1)}function p(t,n,r){if(!t.length)return!1;if(e.current.status!==`open`)return G(r??`no connection — the desktop didn't get that. Try again when the link is back.`),!1;for(let e of t)d(e);return G(n),!0}function m(t,n=`no connection — the host can't be asked from here`){return e.current.status===`open`?(d(t),!0):(G(n),!1)}let h=(0,Z.useRef)(Date.now());return(0,Z.useEffect)(()=>{if(t===`open`){h.current=Date.now(),i(!1);return}let e=Math.max(0,fv-(Date.now()-h.current)),n=window.setTimeout(()=>i(!0),e);return()=>window.clearTimeout(n)},[t]),{connRef:e,status:t,setStatus:n,connVisible:r,info:a,setInfo:s,noteWelcome:c,send:d,liveSend:f,liveSendAll:p,liveAsk:m,reconnectAsk:l,setReconnectAsk:u}}function hv(e,t,n){let r=[[null,null,null]];n&&r.push([null,null,n]),e&&r.push([e,null,n]),t&&r.push([e,t,n]),r.forEach(([e,t,n],r)=>{let i=sc(e,t,n),a={navRoute:i,navDepth:r},o=Ml(e,t,n);r===0?history.replaceState(a,``,o):history.pushState(a,``,o),nu.keys[r]=i}),nu.depth=r.length-1,nu.keys.length=r.length,rs()}function gv(){let e=(0,Z.useRef)(_d()).current,t=(0,Z.useRef)(!1),[n,r]=(0,Z.useState)(e.activeId),[i,a]=(0,Z.useState)(e.image?`swipe`:e.file&&Xi(e.file.relPath)?`gallery`:e.overlay),o=e=>a(t=>t===e?null:t),s=vc(i),[c,l]=(0,Z.useState)(()=>xl());return(0,Z.useEffect)(()=>{so(Ml(n,i,c),Date.now())},[n,i,c]),(0,Z.useEffect)(()=>{let e=sc(n,i,c),r=!t.current;t.current=!0;let a=history.state,o=a?.navRoute===e?a.navDepth||0:-1;if(r&&o<=0){hv(n,i,c);return}if(o>=0){nu.depth=o,nu.keys[o]=e,rs();return}let s=pu(nu.keys,nu.depth,e);if(s.kind===`stay`)return;if(s.kind===`go`){nu.depth+=s.delta,history.go(s.delta);return}let l=Ml(n,i,c),u=nu.depth+1,d={navRoute:e,navDepth:u};history.pushState(d,``,l),nu.depth=u,nu.keys[u]=e,nu.keys.length=u+1,rs()},[n,i,c]),(0,Z.useEffect)(()=>{let e=()=>{let e=history.state,t=Rs(e,{..._d(),focusRepo:xl()},nu.keys,nu.depth);!t.adopt&&Vc(t.depth)&&t.depth>0?(nu.depth=t.depth,history.back()):(nu.depth=t.depth,t.key&&(nu.keys[t.depth]=t.key),t.adopt&&t.key&&(history.replaceState({navRoute:t.key,navDepth:t.depth},``),nu.keys.length=t.depth+1),rs(),r(t.activeId),a(t.overlay),l(xl()))};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[]),(0,Z.useEffect)(()=>Ac(`Back`,()=>nu.depth<=0?!1:(history.back(),!0),``),[]),{initRoute:e,activeId:n,setActiveId:r,overlay:i,setOverlay:a,closeSheet:o,overlayRef:s,focusRepo:c,setFocusRepo:l}}var _v=4e3,vv=`pty`,yv=3e4,bv=3e5,xv=12;function Sv(e){let t=e.indexOf(`\x1B`);return t>0&&t<=1024?e.slice(t):e}async function Cv(e,t,n,r){if(!t||n==null)return;let i={sessionId:e,tail:Sv(t.slice(-65536)),seq:n,savedAt:Date.now(),boot:r};await zc(vv,e,i);let a=await Nu(vv);if(!(a.length<=xv))for(let e of[...a].sort((e,t)=>t.savedAt-e.savedAt).slice(xv))await rd(vv,e.sessionId)}async function wv(){return(await Nu(vv)).filter(e=>e&&e.sessionId&&typeof e.tail==`string`)}function Tv(e,t,n,r){if(r)return e.set(t,n?[n]:[]),!0;let i=e.get(t)??[];return i.push(n),e.set(t,i),!1}function Ev(e,t,n){return((e??``)+t).slice(-n)}function Dv(e,t){let n=new Map;for(let r of e)(t.buffers.get(r.sessionId)?.length??0)>0||(t.buffers.set(r.sessionId,[r.tail]),n.set(r.sessionId,r.savedAt),r.boot&&(t.lastSeqById.set(r.sessionId,r.seq),t.restore.set(r.sessionId,r.seq),t.resumeBoot.set(r.sessionId,r.boot)));return n}function Ov(e,t){return[...e].sort((e,n)=>+(n.id===t)-(e.id===t)||n.createdAt-e.createdAt).map(e=>e.id)}function kv(e){let{activeId:t,setActiveId:n,setOverlay:r,sessions:i}=e,{connRef:a,send:o,status:s}=e.conn,c=(0,Z.useRef)(null),l=(0,Z.useRef)(new Map),u=(0,Z.useRef)(new Map),d=(0,Z.useRef)(new Map),f=(0,Z.useRef)(new Map),[p,m]=(0,Z.useState)(new Map),h=(0,Z.useRef)(new Map),g=(0,Z.useRef)(new Map),_=(0,Z.useRef)(void 0),v=(0,Z.useRef)(new Set),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[C,w]=(0,Z.useState)(0),[T,E]=(0,Z.useState)(()=>rt(W.readMode)),D=(0,Z.useRef)(T);D.current=T;let[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(0),[M,ee]=(0,Z.useState)(null);function N(e){ee(t=>({kind:e,key:(t?.key??0)+1}))}let P=(0,Z.useRef)({cols:80,rows:30}),F=(0,Z.useRef)(null),I=(0,Z.useRef)(s),te=vc(i),L=(0,Z.useRef)(!1),R=(0,Z.useRef)(null),z=(0,Z.useRef)(void 0),[ne,re]=(0,Z.useState)(0),B=vc(s);function V(e){R.current===e&&_e(e),h.current.delete(e),g.current.delete(e),m(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}function H(t){if(Y(`action:session.attach`),e.noteVisited(t.id),r(null),ee(null),!y){n(t.id);return}let i=h.current.get(t.id);i==null&&!p.has(t.id)&&l.current.set(t.id,[]),F.current=t.id,n(t.id),o({t:`session.attach`,id:t.id,resumeSeq:i,resumeBoot:g.current.get(t.id)??_.current}),D.current||Ki(t.id)}function ie(){ae(!0)}function ae(t){let n=e.getActive();if(!n)return;let r=n.id;l.current.set(r,[]),w(e=>e+1),t&&a.current.reconnect(),o({t:`session.detach`,id:r}),o({t:`session.attach`,id:r}),setTimeout(()=>{let{cols:e,rows:t}=P.current;o({t:`session.resize`,id:r,cols:e,rows:Math.max(12,t-1)}),setTimeout(()=>o({t:`session.resize`,id:r,cols:e,rows:t}),120)},280)}function oe(e){E(e),tt(W.readMode,e),e?j(e=>e+1):setTimeout(()=>ae(!1),0)}function U(e,t=!0){Y(`action:session.read`),D.current=!0,oe(!0),H(e),t&&N(`outline`)}function se(){j(e=>e+1)}function ce(t){l.current.has(t)||l.current.set(t,[]),F.current=t,n(t),e.noteVisited(t),r(null),o({t:`session.attach`,id:t})}function le(e){_.current=e,F.current&&!D.current&&Ki(F.current),he.current()}function ue(e){e.id===F.current&&e.idle&&se(),e.idle&&!(D.current&&e.id===F.current)&&Ki(e.id)}function de(e){let t=Cd(e.dataB64);Tv(l.current,e.id,t,e.full)&&F.current===e.id&&w(e=>e+1),e.seq!=null&&u.current.set(e.id,e.seq),V(e.id),!e.full&&t&&(d.current.set(e.id,Date.now()),f.current.set(e.id,Ev(f.current.get(e.id),t,_v))),S(e=>e+1)}function fe(t){v.current.add(t.id),S(e=>e+1),e.onExit()}let pe=()=>c.current?.snapshot()??[];(0,Z.useEffect)(()=>{s===`open`&&I.current!==`open`&&(F.current=null),I.current=s},[s]),(0,Z.useEffect)(()=>{t?L.current||F.current!==t&&i.some(e=>e.id===t)&&y&&(F.current=t,o({t:`session.attach`,id:t,resumeSeq:u.current.get(t),resumeBoot:g.current.get(t)??_.current}),D.current||Ki(t)):F.current=null},[t,i,y,ne]);let me=vc(s),he=(0,Z.useRef)(()=>{});he.current=()=>{if(me.current!==`open`)return;let e=Ov(te.current,F.current);e.length&&wt(e)},(0,Z.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&he.current()},t=setInterval(e,bv);return document.addEventListener(`visibilitychange`,e),e(),()=>{clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[]),(0,Z.useEffect)(()=>{let e=!1;return wv().then(t=>{if(e)return;let n=Dv(t,{buffers:l.current,lastSeqById:u.current,restore:h.current,resumeBoot:g.current});n.size&&m(n)}).finally(()=>{e||b(!0)}),Ii(),()=>{e=!0}},[]),(0,Z.useEffect)(()=>{let e=t;if(!e)return;let n=()=>{Rn(e),!h.current.has(e)&&Cv(e,(l.current.get(e)??[]).join(``),u.current.get(e),_.current)},r=window.setInterval(()=>{L.current||n()},yv);return window.addEventListener(`pagehide`,n),window.addEventListener(`freeze`,n),()=>{window.clearInterval(r),window.removeEventListener(`pagehide`,n),window.removeEventListener(`freeze`,n),n()}},[t]);function ge(e){Rn(e),!h.current.has(e)&&Cv(e,(l.current.get(e)??[]).join(``),u.current.get(e),_.current)}function _e(e){R.current=null,window.clearTimeout(z.current),L.current&&(ge(e),o({t:`session.detach`,id:e}))}return(0,Z.useEffect)(()=>{let e=t;if(!e||gh(e))return;let n,r=()=>{let t=lo();if(!Ys(t)||L.current)return;L.current=!0,ge(e),o({t:`session.detach`,id:e});let r=vt(t);r!=null&&(n=window.setInterval(i,r))},i=()=>{L.current&&!R.current&&B.current===`open`&&(R.current=e,o({t:`session.attach`,id:e,resumeSeq:u.current.get(e),resumeBoot:g.current.get(e)??_.current}),z.current=window.setTimeout(()=>_e(e),2e4),he.current())},a=()=>{window.clearInterval(n),n=void 0,L.current&&(L.current=!1,R.current=null,window.clearTimeout(z.current),F.current=null,re(e=>e+1))},s=()=>{document.visibilityState===`hidden`?r():a()};return document.addEventListener(`visibilitychange`,s),document.visibilityState===`hidden`&&r(),()=>{document.removeEventListener(`visibilitychange`,s),window.clearInterval(n),L.current&&(L.current=!1,R.current=null,window.clearTimeout(z.current))}},[t]),(0,Z.useEffect)(()=>{if(t&&!gh(t))return()=>o({t:`session.detach`,id:t})},[t]),{termRef:c,geomRef:P,buffers:l,lastPtyAt:d,ptyTail:f,exitedRef:v,staleAt:p,writeSeq:x,termNonce:C,readMode:T,readModeRef:D,setView:oe,openReader:U,readerCmd:M,fireReader:N,outlineJump:O,setOutlineJump:k,transcriptNonce:A,attach:H,focus:ce,refreshTerminal:ie,hostAnsweredFor:V,onWelcome:le,onSessionUpdated:ue,onPty:de,onSessionExit:fe,snapshot:pe}}function Av(e,t=1){return`${t>1?`archived ${t} sessions`:`archived ${e}`} — the conversation is kept: reopen it under “Recently closed”, or in Archive`}function jv(e,t){let{connRef:n,send:r,liveSend:i,liveAsk:a}=e,o=Mv(e,jo,xa,(e,t)=>({t:`session.star`,id:e,starred:t})),c=Mv(e,co,zd,(e,t)=>({t:`session.followup`,id:e,on:t}));function l(e){Y(`action:session.close`),e.running?a({t:`session.closecheck`,id:e.id},`no connection — the desktop didn't get that, the session is still open`):(si(e.id),i({t:`session.remove`,id:e.id},Av(e.title),`no connection — the desktop didn't get that, the session is still listed`))}function u(){let e=t().filter(e=>!e.running);if(e.length){if(n.current.status!==`open`)G(`no connection — the desktop didn't get that, the sessions are still listed`);else{for(let t of e)r({t:`session.remove`,id:t.id});G(Av(e[0].title,e.length))}}}function d(e){let n=[];if(e.isRepo&&(e.dirty&&n.push(`• uncommitted changes (no commit done)`),!e.isMain&&e.unmerged>0&&n.push(`• ${e.unmerged} commit(s) not merged to ${e.mainBranch||`main`}`)),e.shells?.length){let t=s(ye(e.shells,Date.now()),e.shells);t&&n.push(`• ${t}`)}let i=t().find(t=>t.id===e.id)?.title??e.branch??`session`;if(n.length===0){si(e.id),r({t:`session.remove`,id:e.id}),G(Av(i));return}let a=e.branch||`this session`,o=n.map(e=>e.replace(/^• /,``)),c=t=>{si(e.id),r({t:`session.remove`,id:e.id}),G(t)};Fs(`confirmClose`).current?(async()=>{let{ok:e,remember:t}=await dc({title:`Close ${a}?`,lines:o,confirmLabel:`Close anyway`,tone:`warn`});e&&(t?(J(`confirmClose`,!1),c(`won't ask again — Settings › Sessions › ask before closing a session turns it back on`)):c(Av(i)))})():c(`${Av(i)} — left: ${o.join(`; `)}`)}function f(e,t){Y(`action:session.star`),o.press(e,t)}function p(e,t){Y(`action:session.followup`),c.press(e,t)}function m(e,t){o.settle(e,t),c.settle(e,t)}return{pendingStars:o.pending,toggleStar:f,pendingFollowUps:c.pending,toggleFollowUp:p,settleStars:m,closeSession:l,archivedToast:Av,clearExited:u,onCloseCheck:d}}function Mv(e,t,n,r){let{connRef:i,status:a,send:o}=e,[s,c]=(0,Z.useState)(()=>Ru(t)),l=(0,Z.useRef)(s);l.current=s,(0,Z.useEffect)(()=>{if(a===`open`)for(let[e,t]of Object.entries(l.current))i.current.send(r(e,t))},[a]);function u(e){l.current=e,c(e),Xu(t,e)}return{pending:s,press(e,t){u({...l.current,[e]:t}),o(r(e,t))},settle(e,t){let r=dn(l.current,e,t,n);r&&u(r)}}}var Nv=[`default`,`acceptEdits`,`plan`,`auto`],Pv=[`bypassPermissions`,`dontAsk`],Fv={default:{mode:`default`,title:`Manual`,desc:`Asks for approval before each edit and command`,icon:`hand`},acceptEdits:{mode:`acceptEdits`,title:`Edit automatically`,desc:`Edits files without asking; still asks before other commands`,icon:`code`},plan:{mode:`plan`,title:`Plan`,desc:`Explores the code and presents a plan before editing`,icon:`scroll`},auto:{mode:`auto`,title:`Auto`,desc:`Approves actions that pass a safety check, pauses for anything risky`,icon:`zap`},bypassPermissions:{mode:`bypassPermissions`,title:`Bypass permissions`,desc:`Runs every tool call without asking — nothing is checked`,icon:`shieldOff`},dontAsk:{mode:`dontAsk`,title:`Don’t ask`,desc:`Never shows an approval prompt — the permission rules decide alone`,icon:`lock`}};function Iv(e){return Fv[e]?.title??e}function Lv(e){return e.liveMode?{mode:e.liveMode,source:`live`}:e.permissionMode?{mode:e.permissionMode,source:`launch`}:{mode:null,source:`unknown`}}function Rv(e,t=`the CLI’s footer`){let n=t===`the CLI’s footer`;return e.source===`live`?`Now: ${Iv(e.mode)}, read ${n?`off`:`from`} ${t}.`:e.source===`launch`?`Launched in ${Iv(e.mode)}. ${n?`The footer`:`Its mode`} can’t be read right now, so it may have changed since.`:`${n?`The footer`:`Its mode`} can’t be read right now and this session launched with no mode flag, so its mode is not known here.`}function zv(e,t,n=!0){let r=Nv.filter(t=>e.includes(t));for(let i of Pv)e.includes(i)&&(!n||t.liveMode===i||t.permissionMode===i)&&r.push(i);return r.map(e=>Fv[e])}function Bv(e,t){return t.source===`live`&&t.mode===e?{kind:`none`,say:`already in ${Iv(e)}`}:Pv.includes(e)?{kind:`confirm`}:{kind:`send`}}function Vv(e){return e.reason?e.reason:e.mode?`now in ${Iv(e.mode)}`:`the desktop switched, but could not read the footer afterwards`}var Hv=12e3;function Uv(e){return`the desktop did not answer the switch to ${Iv(e)} — check the footer in the terminal`}function Wv(e){return e.liveMode&&e.liveMode!=="default"?e.liveMode:null}function Gv(e){return e===!0?`on`:e===!1?`off`:`unknown`}function Kv(e){let t=Gv(e);return t===`on`?`on for this session — the CLI confirmed it`:t===`off`?`off — the CLI confirmed it`:`not known — the CLI hasn’t confirmed it yet`}function qv(e){return`/effort ultracode ${e?`on`:`off`}`}var Jv=new Map,Yv=new Set,Xv=()=>{for(let e of Yv)e()};function Zv(e,t){let n=Jv.get(e);n&&window.clearTimeout(n.timer);let r=window.setTimeout(()=>{Jv.get(e)?.timer===r&&(Jv.delete(e),Xv(),G(Uv(t)))},Hv);Jv.set(e,{mode:t,timer:r}),Xv()}function Qv(e){let t=Jv.get(e.id);t&&(window.clearTimeout(t.timer),Jv.delete(e.id),Xv()),G(Vv(e))}function $v(e){return(0,Z.useSyncExternalStore)(e=>(Yv.add(e),()=>{Yv.delete(e)}),()=>Jv.get(e)?.mode??null)}function ey(e,t){let n=vc(e);(0,Z.useEffect)(()=>{let{connRef:e,setBackends:r,setSessions:i,setRecent:a,setClosed:o,setUpdate:s,setMeter:c,setIntents:l,updateResultSeenRef:u,wantNavRef:d}=t,f=e.current.on(e=>{let{conn:t,term:f,verbs:p,q:m,focusSession:h}=n.current;switch(e.t){case`welcome`:e.protocol!==2&&G(e.protocol>2?`the desktop is newer than this app — reload to update`:"the desktop is older than this app — run `npm run restart` there"),r(null),t.noteWelcome(e);{let t=or(e);t&&G(t.announced?`desktop restarted — back${t.downMs==null?``:` after ${Jt(t.downMs)}`}`:`desktop restarted without warning (crash?)${t.downMs==null?``:` — back after ${Jt(t.downMs)}`}`)}ci.pump(),f.onWelcome(e.bootId);break;case`backends`:r(e.list);break;case`host.restarting`:{Ya(Date.now(),e.reason);let t=Ra().usualMs;G(`desktop is restarting${e.reason?` (${e.reason})`:``}${t==null?` — the app cannot reach it until it is back`:` — usually back in ~${Jt(t)}`}`);break}case`auth.state`:t.setInfo({auth:e.auth});break;case`backlog.ack`:m.onBacklogAck(e);break;case`op.ack`:Tr(e.ackId,e.ok,e.filed,Sr),m.onOpAck(e);break;case`session.list`:i(e.sessions),p.settleStars(e.sessions,!0),Cl(e.sessions),ed(`sessions`);break;case`recent.list`:a(e.recent),yd(W.snapRecent,e.recent);break;case`closed.list`:o(e.closed),yd(W.snapClosed,e.closed);break;case`input.ack`:m.onInputAck(e);break;case`delivery.list`:m.onDeliveryList(e);break;case`delivery.settled`:m.onDeliverySettled(e);break;case`session.created`:i(t=>[...t.filter(t=>t.id!==e.session.id),e.session]),f.buffers.current.set(e.session.id,[]),d.current&&h(e.session.id);break;case`session.focus`:h(e.id);break;case`session.updated`:p.settleStars([e.session],!1),i(t=>{let n=t.map(t=>t.id===e.session.id?e.session:t);return Cl(n),n}),f.onSessionUpdated(e.session);break;case`pty`:f.onPty(e);break;case`session.exit`:f.onSessionExit(e);break;case`session.closecheck`:p.onCloseCheck(e);break;case`session.history`:f.hostAnsweredFor(e.id),gr(e.id,e.entries);break;case`session.named`:G(e.name?`named “${e.name}”`:e.reason??`no name was written`);break;case`session.moded`:Qv(e);break;case`update.status`:s(e.info),e.info.lastResult&&e.info.lastResult.at>u.current&&(u.current=e.info.lastResult.at,G(e.info.lastResult.ok?`Claude updated`:`Update failed: ${e.info.lastResult.message}`));break;case`budget.state`:m.onBudget(e);break;case`settings.all`:dd(e.doc);break;case`settings.update`:bt(e.key,e.value,e.ts);break;case`toast`:G(e.text);break;case`meter.status`:c(e.summary);break;case`intent.list`:l(e.intents);break;case`intent.changed`:l(t=>{let n=t.findIndex(t=>t.id===e.intent.id);if(n<0)return[e.intent,...t];let r=t.slice();return r[n]=e.intent,r});break;case`launch.list`:m.onLaunchList(e);break;case`launch.opened`:m.onLaunchOpened(e);break;case`error`:e.context===`__status`&&t.setStatus(e.message)}}),p=e.current.on(U_),m=e.current.onBinary(e=>Ks().onBinary(e));return()=>{f(),p(),m()}},[])}var ty=`theme.textScale.iconScale.termZoom.readerZoom.scrollZoom.gitZoom.textDumpWrap.sessionTabs.sessionTabsCount.sessionTabsOrder.sessionTabsLimit.sessionTabsSync.netPulse.localRtBar.unfoldToEnd.typingRoom.closeKbOnSend.shortcutCard.busySend.btwToCli.toolbarOpen.readMode.cliMode.termCostOpen.termCornerPos.hintChip.annHintHidden`.split(`.`),ny=[W.outbox,W.pad,W.compose,W.fileRemarks,W.padRescue,W.padRescueMigrated,W.giveups,W.giveupsMigrated,W.syncTs,W.hosts,W.hostActive,W.hostSwitch,W.hostsGone,g,...y,W.brandMigrated,W.brandStores];async function ry(){try{for(let e of Object.keys(localStorage))ny.some(t=>e.startsWith(t))||localStorage.removeItem(e)}catch{}try{let e=await caches.keys();await Promise.all(e.filter(e=>!Al.some(t=>e.startsWith(t))).map(e=>caches.delete(e)))}catch{}try{let e=await navigator.serviceWorker.getRegistrations();await Promise.all(e.map(e=>e.unregister()))}catch{}location.reload()}function iy({err:e}){let t=e instanceof Error?`${e.name}: ${e.message}`:String(e);return(0,Q.jsxs)(`div`,{className:`boot-fail`,children:[(0,Q.jsxs)(`h2`,{children:[Rr(),` couldn't start`]}),(0,Q.jsx)(`pre`,{children:t}),(0,Q.jsxs)(`div`,{className:`boot-fail-acts`,children:[(0,Q.jsx)(`button`,{onClick:()=>location.reload(),children:`Reload`}),(0,Q.jsx)(`button`,{onClick:()=>{ry()},children:`Reset caches & reload`})]}),(0,Q.jsx)(`p`,{children:`Queued text and prompt-pad drafts are kept by the reset.`})]})}var ay=class extends Z.Component{state={err:null};static getDerivedStateFromError(e){return{err:e}}componentDidCatch(e,t){console.error(`${D} render failed`,e,t.componentStack)}render(){return this.state.err?(0,Q.jsx)(iy,{err:this.state.err}):this.props.children}};function oy(){let e=null,t=t=>{e||=t};window.addEventListener(`error`,e=>t(e.error||e.message)),window.addEventListener(`unhandledrejection`,e=>t(e.reason)),setTimeout(()=>{let t=document.getElementById(`root`);if(!t||t.childElementCount>0)return;t.innerHTML=``;let n=document.createElement(`div`);n.className=`boot-fail`;let r=e?e instanceof Error?`${e.name}: ${e.message}`:String(e):`The app scripts loaded but nothing rendered.`;n.innerHTML=`<h2></h2><pre></pre>`,n.querySelector(`h2`).textContent=`${Rr()} couldn't start`,n.querySelector(`pre`).textContent=r;let i=document.createElement(`div`);i.className=`boot-fail-acts`;let a=document.createElement(`button`);a.textContent=`Reload`,a.onclick=()=>location.reload();let o=document.createElement(`button`);o.textContent=`Reset caches & reload`,o.onclick=()=>{ry()},i.append(a,o),n.append(i),t.append(n)},4e3)}var sy=class extends Z.Component{state={err:!1};static getDerivedStateFromError(){return{err:!0}}componentDidCatch(e,t){console.error(`${D} sheet "${this.props.name}" failed`,e,t.componentStack);let n=e instanceof Error?`${e.name}: ${e.message}`:String(e);try{this.props.onFail(this.props.name,n)}catch{}}render(){return this.state.err?null:this.props.children}},cy=u_(Vo,$t);function ly(e,t){return cy.rows(e,t).map(e=>(0,Z.createElement)(Z.Fragment,{key:e.key},e.node))}var uy=new Set([`dontAsk`,`bypassPermissions`]),dy=[`The agent will edit files, run shell commands, and push — with no approval prompt and no chance to say no.`,`Use it only in a repo whose contents you could afford to lose.`,`Sessions you start from any of your clients will use this until you change it back.`],fy=[{key:`warnPct`,label:`orange at`,suffix:`% of week`},{key:`highPct`,label:`red at`,suffix:`% of week`},{key:`warnUsd`,label:`orange at`,prefix:`$`,suffix:`without a week reading`},{key:`highUsd`,label:`red at`,prefix:`$`,suffix:`without a week reading`}];function py(){let e=q(`spendWarn`),[t,n]=(0,Z.useState)({}),[r,i]=(0,Z.useState)(null),a=r=>{let a=t[r];if(a==null)return;let o=Number(a.trim().replace(`,`,`.`).replace(/^\$|%$/g,``));if(n(e=>{let{[r]:t,...n}=e;return n}),!(o>0)||!Number.isFinite(o)){i(`“${a}” is not a number above zero — kept ${String(e[r])}.`);return}let s={...e,[r]:o},c=r.endsWith(`Pct`)?[`warnPct`,`highPct`]:[`warnUsd`,`highUsd`];s[c[1]]>s[c[0]]?r.endsWith(`Pct`)&&o>100?i(`A share of the week cannot be more than 100%.`):(i(null),Y(`action:spendWarn.set`),J(`spendWarn`,Ce(s))):i(`Red has to be above orange — kept what was there.`)},o=[`warnPct`,`highPct`,`warnUsd`,`highUsd`].every(t=>e[t]===Le[t]);return(0,Q.jsxs)(Ud,{id:`spend-warn`,label:`spend marks`,icon:Kp,on:e.on,onChange:()=>{Y(`action:spendWarn.toggle`),J(`spendWarn`,{...e,on:!e.on})},note:e.on?(0,Q.jsxs)(Q.Fragment,{children:[`A session's Σ figure gets an orange triangle at `,e.warnPct,`% of the week and a red one at `,e.highPct,`% — $`,e.warnUsd,` and $`,e.highUsd,` where there is no weekly limit reading.`]}):(0,Q.jsx)(Q.Fragment,{children:`Off: no session's spend is marked, whatever it reaches.`}),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Which scale.`}),` With a subscription, the desktop measures what one percent of your week is in list-price dollars from its own `,(0,Q.jsx)(`code`,{children:`/usage`}),` readings, and the marks are a share of that. With an API key there is no weekly limit, so the dollar pair applies — and also on a subscription until the week has been measured.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Where the dollar defaults come from.`}),` On a Max plan one percent of a week measured at about $15 of list price, so 2% ≈ $30 and 5% ≈ $75. Another plan moves that rate; the percent pair follows it on its own.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What a mark does.`}),` It is a readout: one toast the first time a session passes each mark, and the triangle beside its spend. Nothing is paused or refused — for that, give a session its own budget.`]}),!o&&(0,Q.jsxs)(`p`,{children:[`Defaults: `,Le.warnPct,`% / `,Le.highPct,`% of week, $`,Le.warnUsd,` / $`,Le.highUsd,`.`]})]}),children:[e.on&&fy.map(r=>(0,Q.jsxs)(`div`,{className:`set-item`,children:[(0,Q.jsx)(`label`,{className:`set-lead`,htmlFor:`spend-warn-${r.key}`,children:(0,Q.jsx)(`span`,{className:`set-lbl`,style:{color:r.key.startsWith(`warn`)?`var(--warn)`:`var(--dead)`},children:r.label})}),(0,Q.jsxs)(`div`,{className:`budget-input`,children:[r.prefix&&(0,Q.jsx)(`span`,{className:`budget-affix`,children:r.prefix}),(0,Q.jsx)(`input`,{id:`spend-warn-${r.key}`,inputMode:`decimal`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:t[r.key]??String(e[r.key]),onChange:e=>n(t=>({...t,[r.key]:e.target.value})),onBlur:()=>a(r.key),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}}),r.suffix&&(0,Q.jsx)(`span`,{className:`budget-affix`,children:r.suffix})]})]},r.key)),r&&(0,Q.jsx)(`div`,{className:`set-warn`,children:r})]})}var my=(e,t)=>{let n=e.find(e=>e.worktreePath===t);if(n)return n;let r=null;for(let n of e){let e=n.worktreePath.replace(/\/+$/,``);e&&t.startsWith(e+`/`)&&(!r||e.length>r.worktreePath.replace(/\/+$/,``).length)&&(r=n)}return r},hy=(e,t)=>my(e,t.cwd)?.repoName??Ws(t.cwd),gy=(e,t)=>{let n=my(e,t.cwd);return n?`${n.repoName} · ${n.branch}`:Ws(t.cwd)},_y=(e,t)=>{let n=my(e,t.cwd);return n?Re(n):Ws(t.cwd)},vy=(e,t)=>_y(e,t)||(t.tabTitle??``).trim()||hy(e,t),yy=e=>`${e.status===`pending`?`opening…`:`queued`} ${e.n}`,by=e=>`${e.n>1?`${e.n} sessions `:``}${e.status===`pending`?`opening — waiting for the desktop to confirm`:`queued — opens when the link is back`}`,xy=e=>`repo setup: ${e.issues} ${e.ok?`thing to look at`:`issue`}${e.issues>1?`s`:``}${e.fixable?`, ${e.fixable} one-tap fixable`:``} — open the checklist`,Sy=e=>e&&e.issues>0?`repo readings · ${e.issues}`:`repo readings`,Cy=e=>e&&e.issues>0?xy(e):`open this repo's readings`;function wy(e,t,n){let r=[...e].sort((e,t)=>(e.createdAt??0)-(t.createdAt??0)),i=r;if(t.length){let e=new Map(r.map(e=>[e.id,e]));i=[];for(let n of t){let t=e.get(n);t&&(i.push(t),e.delete(n))}for(let t of r)e.has(t.id)&&i.push(t)}let a=new Map;for(let e of i){let t=n(e),r=a.get(t);r?r.push(e):a.set(t,[e])}return Ke([...a.values()].flat())}function Ty(e,t,n){let r=new Set(t),i=e.filter(e=>n.has(e)&&!r.has(e));return[...t,...i]}function Ey(e,t,n,r){if(!n||n===t)return null;let i=e.find(e=>e.id===t),a=e.find(e=>e.id===n);if(!i||!a||r(i)!==r(a))return null;let o=e.map(e=>e.id),s=o.indexOf(t),c=o.indexOf(n);return s===-1||c===-1?null:(o.splice(s,1),o.splice(c,0,t),o)}function Dy(e,t,n,r){return t?e.filter(e=>n(e,t.status)&&(!t.repo||r(e)===t.repo)):e}function Oy(e,t,n){let r=new Map;for(let i of e){let e=n(i),a=r.get(e)??{wait:0,limit:0,coding:0,done:0,exited:0};a[t(i)]++,r.set(e,a)}return r}var ky=(e,t)=>[...e.values()].reduce((e,n)=>e+n[t],0);function Ay(e,t){let n=new Map;for(let r of e)if(r.starred){let e=t(r);n.set(e,(n.get(e)??0)+1)}return n}function jy(e,t){let n=new Map,r=new Map;for(let i of e){if(!i.running)continue;let e=t(i),a=n.get(e)??0;r.set(i.id,a),n.set(e,a+1)}return r}var My=[`name`,`sessions`],Ny={name:`alphabetical`,sessions:`most open sessions first`};function Py(e,t){let n=new Map;for(let r of e)if(r.running){let e=t(r);n.set(e,(n.get(e)??0)+1)}return n}function Fy(e,t,n,r,i=[],a){let o=new Map,s=[];for(let t of e){let e=r(t),n=o.get(e);n||(n=[],o.set(e,n),s.push(e)),n.push(t)}for(let e of t)(!n||i.includes(e.repoName))&&!o.has(e.repoName)&&(o.set(e.repoName,[]),s.push(e.repoName));return s.sort((e,t)=>(a?(a.get(t)??0)-(a.get(e)??0):0)||e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0})),s.map(e=>({repoName:e,sessions:o.get(e)??[]}))}function Iy(e,t,n,r){let i=new Map,a=(e,t)=>{if(n.has(t))return;let a=r(e);if(!a)return;let o=i.get(a);o?o.push(t):i.set(a,[t])};for(let t of e)t.status!==`failed`&&t.cwd&&a(t.cwd,Hr(t.ackId));for(let e of t)e.archived||(e.state===`queued`||e.state===`blocked`)&&(m(e)||e.cwd&&a(e.cwd,Mn(e.id)));return i}function Ly(e,t){let n=new Set(e),r=t.filter(e=>n.has(Mn(e.id))),i=new Set(r.map(e=>e.cwd));return r.length===e.length&&i.size===1&&r[0].cwd&&r.every(d)?{kind:`backlog`,cwd:r[0].cwd,ids:r.map(e=>e.id)}:{kind:`activity`}}var Ry=e=>!!e.starred||wo(e);function zy(e,t,n,r){let i=t?e.filter(e=>r(e)===t):[...e];return n?i.filter(e=>!Ry(e)):i}function By(e,t,n){let r=(t?e.filter(e=>n(e)===t):e).filter(Ry);return{n:r.length,starred:r.filter(e=>e.starred).length,flagged:r.filter(wo).length}}function Vy(e,t,n,r){return n?By(e,t,r).n:0}function Hy(e){let t=e.starred&&e.flagged?`starred & flagged`:e.flagged?`flagged`:`starred`;return`${e.n} ${t}`}function Uy(e,t){let n=e.toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return!0;let r=t.filter(Boolean).join(`
|
|
10
|
-
`).toLowerCase();return n.every(e=>r.includes(e))}function Wy(){try{return window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0}catch{return!1}}function Gy(){let e=navigator.userAgent;return(/iPad|iPhone|iPod/.test(e)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1)&&!/CriOS|FxiOS|EdgiOS/.test(e)}var Ky={phase:`idle`};function qy(e){return e===`Control`?`ctrl`:e===`Meta`||e===`OS`?`meta`:e===`Alt`?`alt`:null}function Jy(e,t){return e.shiftKey||t!==`ctrl`&&e.ctrlKey||t!==`meta`&&e.metaKey||t!==`alt`&&e.altKey}function Yy(e,t){switch(t.type){case`blur`:return e.phase===`idle`?e:Ky;case`timer`:return e.phase===`armed`&&e.mod===t.mod?{phase:`shown`,mod:t.mod}:e;case`up`:return qy(t.e.key)?e.phase===`idle`?e:Ky:e.phase===`spent`&&!t.e.ctrlKey&&!t.e.metaKey&&!t.e.altKey?Ky:e;case`down`:{let n=qy(t.e.key);return t.e.isComposing||!n?e.phase===`idle`?e:{phase:`spent`}:(e.phase===`armed`||e.phase===`shown`)&&e.mod===n?e:e.phase===`idle`&&!t.e.repeat&&!Jy(t.e,n)?{phase:`armed`,mod:n}:e.phase===`idle`?e:{phase:`spent`}}}}function Xy(e){return e.isComposing||e.keyCode===229?!1:e.key.length===1||qy(e.key)!=null}function Zy(e,t){return e||t}var Qy=ms(null),$y=ms(!1),eb=()=>Yd($y),tb=()=>ht(W.shortcutCard)!==`0`;function nb(){return{mac:Fd(navigator),tab:!Wy()&&!ws()}}function rb(e){if($y.set(!0),!e||ht(W.shortcutCard)!=null)return;nt(W.shortcutCard,`1`);let t=Fd(navigator);G(`Hold ${_a(t?`meta`:`ctrl`,{mac:t})} to see what each key does with it. Settings › Writing & reading turns the card off.`)}function ib(e=window){let t=Ky,n=null,r=e=>{let i=Yy(t,e);if(i!==t){if(t=i,n&&=(clearTimeout(n),null),t.phase===`armed`){let e=t.mod;n=setTimeout(()=>{n=null,r({type:`timer`,mod:e})},500)}if(t.phase===`shown`&&tb()){let e=nb(),n=vi(sn(),t.mod,e);Qy.set(n.length?{mod:t.mod,env:e,rows:n}:null)}else Qy.get()&&Qy.set(null)}},i=!1,a=e=>{!i&&Xy(e)&&(i=!0,rb(!0)),r({type:`down`,e})},o=e=>r({type:`up`,e}),s=()=>r({type:`blur`}),c=()=>{e.document.visibilityState!==`visible`&&r({type:`blur`})},l=!1;try{l=e.matchMedia?.(`(pointer: fine)`).matches??!1}catch{}return Zy(l,!1)&&rb(!1),e.addEventListener(`keydown`,a,{capture:!0,passive:!0}),e.addEventListener(`keyup`,o,{capture:!0,passive:!0}),e.addEventListener(`blur`,s),e.document.addEventListener(`visibilitychange`,c),()=>{n&&clearTimeout(n),e.removeEventListener(`keydown`,a,{capture:!0}),e.removeEventListener(`keyup`,o,{capture:!0}),e.removeEventListener(`blur`,s),e.document.removeEventListener(`visibilitychange`,c),Qy.set(null)}}function ab(){let e=Yd(Qy);if(!e)return null;let t=_a(e.mod,e.env);return(0,Q.jsxs)(`div`,{className:`shortcut-card`,"aria-live":`polite`,role:`status`,children:[(0,Q.jsxs)(`div`,{className:`shortcut-card-head`,children:[t,` +`]}),(0,Q.jsx)(`ul`,{className:`shortcut-card-rows`,children:e.rows.map(e=>(0,Q.jsxs)(`li`,{className:`shortcut-card-row`,children:[(0,Q.jsx)(`kbd`,{className:`kbd`,children:e.key}),(0,Q.jsxs)(`span`,{className:`shortcut-card-what`,children:[e.what,e.note&&(0,Q.jsx)(`span`,{className:`shortcut-card-note`,children:e.note})]})]},e.id))})]})}async function ob(e){if(!Bt())return;nt(W.tabsSaverAsked,`1`);let t=await xd({title:`Stop sharing tab order while ${bi[e]} is on?`,lines:[`Shared, every tab you open sends a small update to the desktop so your other devices order their tabs the same way.`,`Stopped, this device keeps its own order. Settings › Appearance › same tab order on every device turns it back on.`],confirmLabel:`stop sharing`,cancelLabel:`keep sharing`});t&&(t.ok?(J(`tabsSync`,!1),ic.reload(`tabsSort`),G(`tab order kept on this device — Settings › Appearance shares it again`)):G(`tab order still shared`))}var sb=()=>navigator.connection;async function cb(){let e=Zi({app:ad(),phoneData:!!sb()?.saveData,battery:await ql()});e?lr(e,Bt(),ht(W.tabsSaverAsked)===`1`)&&ob(e):ft(W.tabsSaverAsked)}var lb=!1;function ub(){if(!(lb||typeof document>`u`)){lb=!0,setTimeout(()=>{cb()},4e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&cb()});try{sb()?.addEventListener(`change`,()=>{cb()})}catch{}}}var db=16;function fb(){let e=q(`theme`),t=q(`txtScale`),n=q(`icScale`),r=q(`tZoom`),i=q(`tabsOn`),a=q(`tabsN`),o=q(`tabsSort`),s=q(`tabsMax`),c=q(`tabsSync`),l=q(`netPulse`),u=q(`unfoldToEnd`),d=q(`repoSort`),f=q(`localRtBar`),p=q(`agentWarn`),m=Pu(r,-1,t),h=Pu(r,1,t),g=e=>{J(`tabsN`,e),G(`${e} tabs across the strip`)},_=e=>{J(`tabsMax`,e),G(`at most ${e} session tabs`)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Il,{id:`theme`,radio:!0,label:`theme`,icon:gm,value:e,options:[[`system`,`follow device`,gm],[`light`,`light`,up],[`dark`,`dark`,Em]].map(([e,t,n])=>({value:e,label:t,icon:n})),onChange:e=>{J(`theme`,e),G(`theme: ${e===`system`?`following this device (${br()})`:e}`)},note:e===`system`?`Following this device — it is ${br()} right now, and switches with it.`:`Always ${e} on this device, whatever its OS says.`,more:(0,Q.jsx)(`p`,{children:`Per device, not per account: the phone in a dark room and the desktop under a window want different answers, and “follow device” is how each one gets its own.`})}),(0,Q.jsx)(Il,{id:`text-size`,label:`text size`,icon:im,value:t,options:id.map(e=>({value:e.value,label:e.label,icon:im,style:{fontSize:`${Math.round(14*e.value)}px`}})),onChange:e=>{Y(`action:uiscale.text`),J(`txtScale`,e)},note:`Everywhere — the lists, the sheets and the terminal.`,more:(0,Q.jsx)(`p`,{children:`The buttons are drawn at the size they set, so the one you can read comfortably is the one to press.`})}),(0,Q.jsx)(Il,{id:`icon-size`,label:`icon size`,icon:cp,value:n,options:qs.map(e=>({value:e.value,label:e.label})),onChange:e=>{Y(`action:uiscale.icon`),J(`icScale`,e)},note:`Separately from the text — an icon too small to hit is not the same complaint as text too small to read.`,more:(0,Q.jsx)(`p`,{children:`Wanting big text with compact chrome is not a contradiction. Charts and graphs are left alone — scaling those would move the data rather than enlarge it.`})}),(0,Q.jsx)(rn,{id:`terminal-zoom`,label:`terminal size`,icon:Rf,readout:(0,Q.jsxs)(Q.Fragment,{children:[ts(t,r),`px`,m==null?` · smallest`:h==null?` · biggest`:``]}),onLess:m==null?null:()=>md(m),onMore:h==null?null:()=>md(h),lessLabel:`smaller`,moreLabel:`bigger`,extra:r!==1&&(0,Q.jsxs)(K,{onClick:()=>md(1),title:`back to the text size on its own — ${ts(t,1)}px`,children:[(0,Q.jsx)(xm,{size:db}),` default`]}),note:`Terminal only, on top of the text size above — a smaller console font is a BIGGER grid.`,more:(0,Q.jsx)(`p`,{children:`So the CLI gets more columns and rows to draw in and a wide diff stops wrapping. The desktop is told the new size the moment you tap. The same two buttons float in the terminal's top-right corner, which is where they are worth using: you can see what you are changing while you change it.`})}),(0,Q.jsx)(_u,{id:`repo-colours`,label:`repo colours`,icon:ap,opens:!0,onClick:()=>{Y(`action:repocolor.open`),$t().nav.open(`repocolor`)},note:`Every repo gets a colour of its own — the group header, the row stripes and the session tab all wear it.`,more:(0,Q.jsxs)(`p`,{children:[`Pick the `,(0,Q.jsx)(`b`,{children:`ring`}),` the colours come from (including one that survives colour blindness), `,(0,Q.jsx)(`b`,{children:`pin a colour`}),` to a repo by hand, and see which repos ended up sharing one. Synced: a repo recognised by one colour on the phone and another on the desktop is not recognised at all.`]})}),(0,Q.jsx)(Ud,{id:`tabs`,label:`session tabs`,icon:Vf,on:i,onChange:()=>{let e=!i;J(`tabsOn`,e),Y(`action:sessiontabs.${e?`on`:`off`}`),G(e?`session tabs on — ${a} fit this screen, the rest scroll sideways`:`session tabs off`)},note:`A row of the sessions you have open, above every screen, each one coloured by its repo.`,more:(0,Q.jsx)(`p`,{children:`It answers the question the launcher makes you work for: what else is open, and can I get back to it without leaving this screen. Each tab is named in four words or fewer by the desktop, once, off the summary it already writes — until then it wears the repo and branch it has everywhere else. The × closes that session and asks first; the conversation is kept either way.`})}),i&&(0,Q.jsx)(rn,{id:`tabs-count`,label:`tabs that fit`,icon:Vf,readout:(0,Q.jsxs)(Q.Fragment,{children:[a,` tabs`,a===2?` · widest`:a===8?` · narrowest`:``]}),onLess:a>2?()=>g(a-1):null,onMore:a<8?()=>g(a+1):null,lessLabel:`wider`,moreLabel:`narrower`,note:`The narrowest a tab gets, between 2 and 8 across. Fewer open, each is as wide as its name. It hides nothing.`,more:(0,Q.jsx)(`p`,{children:`Up to the limit below, every open session is on the strip and the rest scroll sideways; what this decides is the narrowest a tab gets once the strip fills, and therefore how much of its name you can read then. With fewer open, each tab is as wide as its name.`})}),i&&(0,Q.jsx)(rn,{id:`tabs-limit`,label:`most tabs shown`,icon:Vf,readout:(0,Q.jsxs)(Q.Fragment,{children:[s,` tabs`,s===50?` · most`:s===2?` · fewest`:``]}),onLess:s>2?()=>_(s-1):null,onMore:s<50?()=>_(s+1):null,lessLabel:`fewer`,moreLabel:`more`,note:`How many sessions the strip draws, in the order below. The rest are counted at its end.`,more:(0,Q.jsx)(`p`,{children:`Past this number the strip stops and says how many it left off — every session is still in the launcher. The one you are in is always drawn, even when the order would put it past the cut.`})}),i&&(0,Q.jsx)(Il,{id:`tabs-order`,radio:!0,label:`tab order`,icon:Vf,value:o,options:Xc.map(e=>({value:e,label:Qr[e]})),onChange:e=>{J(`tabsSort`,e),Y(`action:sessiontabs.order.${e}`),G(`session tabs: ${Qr[e]}`)},note:`Three orders, three different things to want.`,more:(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`In the order opened`}),` never moves, so a tab's position is something you learn and reach without reading it. `,(0,Q.jsx)(`b`,{children:`Most opened first`}),` keeps the ones you actually go back to under your thumb. `,(0,Q.jsx)(`b`,{children:`Last opened first`}),` answers “where was I” instead — the one order that moves under you. Tabs that tie keep the order they were started in, so nothing shuffles on its own.`]})}),i&&(0,Q.jsx)(Ud,{id:`tabs-sync`,label:`same tab order on every device`,icon:Vf,on:c,onChange:()=>{let e=!c;J(`tabsSync`,e),ic.reload(`tabsSort`),Y(`action:sessiontabs.sync.${e?`on`:`off`}`),G(e?`tab order shared with your other devices`:`tab order kept on this device only`)},note:c?`The order above, and which session you opened last or most, follow you between devices.`:`This device keeps its own order and its own record of what you opened.`,more:(0,Q.jsxs)(`p`,{children:[`On, a session you open on the desktop moves to the front here too under `,(0,Q.jsx)(`b`,{children:`last opened first`}),`, and picking an order on one device picks it on all of them that have this on. How many tabs fit and how many are shown stay per device — they are about the screen. Off, this device goes back to the order and record it kept for itself; pinned files are always this device's. When data saver or the phone's battery saver comes on, you are asked once whether to stop sharing.`]})}),(0,Q.jsx)(Il,{id:`repo-order`,radio:!0,label:`repo order`,icon:Jf,value:d,options:My.map(e=>({value:e,label:Ny[e]})),onChange:e=>{J(`repoSort`,e),Y(`action:reposort.${e}`),G(`repos: ${Ny[e]}`)},note:`The launcher's repo list. Most open sessions first breaks ties alphabetically. Per device.`,more:(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Alphabetical`}),` never moves, so a repo's place is something you learn. `,(0,Q.jsx)(`b`,{children:`Most open sessions first`}),` keeps the repos you are working in on top — and moves a repo when a session in it starts or ends.`]})}),(0,Q.jsx)(Ud,{id:`unfold-to-end`,label:`unfolding a repo shows its last row`,icon:Ep,on:u,onChange:()=>{let e=!u;J(`unfoldToEnd`,e),Y(`action:unfoldtoend.${e?`on`:`off`}`),G(e?`unfolding a repo scrolls to its last row`:`unfolding a repo scrolls to its header`)},note:`On the launcher, tapping a repo's chevron scrolls down until the last revealed row is on screen. Off, it scrolls to the repo's header instead. Per device.`}),(0,Q.jsx)(Ud,{id:`net-pulse`,label:`connection strip`,icon:Bp,on:l,onChange:()=>{let e=!l;J(`netPulse`,e),Y(`action:netpulse.${e?`on`:`off`}`),G(e?`connection strip on — pings every 3s while the app is open`:`connection strip off`)},note:`A permanent bar: a state dot, the last ~90 seconds of round-trip times as a graph, and the current number.`,more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`It exists because every other connection readout here is retrospective — the banner appears once the socket is already gone, the activity strip once a request is already slow, and connection health only when you go and open it. None of them answers “is it bad right now, or is the app just being slow?”, which is the question you have while looking at a screen that has not changed.`}),(0,Q.jsx)(`p`,{children:`A graph rather than a number because an average cannot tell a steady 250 ms apart from 30 ms with every fourth ping lost, and only one of those is the link that eats prompts — unanswered pings are drawn as their own red marks, never averaged away.`}),(0,Q.jsx)(`p`,{children:`Costs one extra ping every 3 seconds, only while the app is in the foreground, and it only ever watches: a missed probe is drawn and nothing else, never a reconnect. Tap the bar for the full history.`})]})}),(0,Q.jsx)(Il,{id:`local-rt`,radio:!0,label:`desktop strip`,icon:hm,value:f,options:Va.map(e=>({value:e,label:Qn[e]})),onChange:e=>{J(`localRtBar`,e),Y(`action:localrt.${e}`),G(e===`off`?`desktop strip off`:`desktop strip: ${Qn[e]}`)},note:`A line for the desktop: how busy its CPU and GPU are and how much memory is left — and, while a local model is loaded, that model up front.`,more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`“While a model is loaded” still polls`}),` — it cannot know whether to draw itself without asking — so what it saves is a line of screen, not battery and not the desktop's work. Pick “always on” to keep it pinned, which is the only way to watch a model `,(0,Q.jsx)(`i`,{children:`not`}),` be there.`]}),(0,Q.jsx)(`p`,{children:`It exists for the one question a hosted model never raises and a local one raises constantly — “is the thing I am talking to still resident, or is the desktop swapping?” With no model loaded it is the machine itself — CPU, GPU, memory available, amber when memory is tight. Tap it for the full readout.`})]})}),(0,Q.jsx)(hb,{id:`agent-warn`,label:`warn above this many agents`,icon:bp,cfg:p,k:`warn`,note:(0,Q.jsx)(Q.Fragment,{children:`The desktop strip's agent count turns amber, and says so once, when more than this many agents run at once — sessions mid-turn plus their subagents.`})}),(0,Q.jsx)(hb,{id:`agent-alarm`,label:`alarm above this many agents`,icon:Np,cfg:p,k:`alarm`,note:(0,Q.jsx)(Q.Fragment,{children:`…and red, with a second notice, above this many. Nothing is stopped or refused at either mark.`}),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What counts.`}),` Every session on this desktop whose turn is running, plus every subagent (the Agent/Task tool) running under any session, background ones included. A session that is idle while its subagents work counts once per subagent, never also for itself.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Where it shows.`}),` On the desktop strip, between the CPU and the GPU. Past a mark the strip shows itself even when it is switched off above; its × hides it until the count passes your next mark. Tap the number for the count over time and which sessions hold the agents.`]})]})}),(0,Q.jsx)(_u,{id:`ui-reset`,label:`reset UI settings to default`,icon:xm,onClick:()=>{(async()=>{if(await Hs({title:`Reset UI settings?`,lines:[`Theme, text and icon size, zooms, the strips, session tabs, layout switches and the ? button go back to their defaults on this phone.`,`Drafts, queued prompts, header commands, pins and everything synced stay as they are.`],confirmLabel:`Reset and reload`})){Y(`action:settings.uiReset`);for(let e of ty)ft(W[e]);location.reload()}})()},note:`Everything about how this phone draws the app, back to how it shipped. Your words and synced choices are kept.`})]})}function pb({voice:e}){let t=q(`enterSends`),n=q(`dictLang`),r=q(`dictLangCodes`),i=q(`dictTerms`),a=q(`typingRoom`),o=q(`closeKbOnSend`),s=q(`shortcutCard`),c=eb(),l=q(`btwToCli`),u=q(`busySend`),d=q(`toolsMode`),f=q(`hints`),p=q(`hintChip`),m=xe(r,n,ca()),h=Be(i),g=se(i);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Il,{id:`enter-sends`,radio:!0,label:`the Return key`,icon:Wf,value:t?`send`:`newline`,options:[{value:`send`,label:`sends`},{value:`newline`,label:`inserts a newline`}],onChange:e=>J(`enterSends`,e===`send`),note:t?`Return sends the message (the key is labelled “send”). Shift/Ctrl/⌘+Return inserts a newline.`:`Return inserts a newline; only the Send button sends.`}),e.supported&&(0,Q.jsx)(Il,{id:`dictate-lang`,radio:!0,label:`dictation is read as`,icon:dp,value:n,options:m.map(e=>({value:e.code,label:e.code===`auto`?`auto`:e.label,title:He(e.code)})),onChange:e=>{Y(`action:voice.lang`),J(`dictLang`,e)},note:He(n),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`The phone used to send its own system language, and whisper `,(0,Q.jsx)(`b`,{children:`told`}),` a language does not transcribe another one — it translates into it. English spoken into a German phone came back as fluent German prose.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`auto`}),` is the answer for anybody who works in two languages: the transcriber detects what was said. Pin one where a short clip or a sentence full of English identifiers gets detected wrong.`]}),e.engine===`browser`&&(0,Q.jsxs)(`p`,{children:[`This phone is using the `,(0,Q.jsx)(`b`,{children:`browser's`}),` recogniser, which has no auto-detect and is given its language when the recording starts — so `,(0,Q.jsx)(`b`,{children:`auto`}),` here means this device's own language, and a change applies to the next recording.`]})]})}),e.supported&&(0,Q.jsx)(Md,{id:`dictate-langs`,label:`languages on the microphone`,icon:dp,value:m.map(e=>e.code),options:Ie(ca()).map(e=>({value:e.code,label:e.code===`auto`?`auto`:e.label})),onChange:e=>{Y(`action:voice.langs`),J(`dictLangCodes`,e)},note:`The picker beside the microphone lists these — ${m.length} of ${Ie(ca()).length}.`,more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`Turn them all off and it goes back to `,(0,Q.jsx)(`b`,{children:`auto`}),`, English and German: a picker with nothing in it is a dead tap. The language in use is always listed, whether or not it is lit here.`]}),(0,Q.jsx)(`p`,{children:`Every language here is one the desktop's transcriber knows. Your phone's own language is in the list even when this app does not otherwise name it.`})]})}),e.supported&&(0,Q.jsx)(Pc,{id:`dictate-terms`,label:`words dictation should know`,icon:hp,note:h.length?`${h.length} term${h.length===1?``:`s`}: ${h.slice(0,6).map(e=>e.term).join(`, `)}${h.length>6?`, …`:``}${g?` — ${g} more past the limit of 60 are not used`:``}`:`None yet. One per line, e.g. BA3 — optionally followed by what it comes out as: BA3: bee a three, be a 3`,more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`One term per line. After a colon, what it keeps coming back as, comma-separated: `,(0,Q.jsx)(`b`,{children:`BA3: bee a three, be a 3`}),`. A line starting with # is a comment.`]}),e.engine===`host`?(0,Q.jsxs)(`p`,{children:[`The desktop's transcriber is `,(0,Q.jsx)(`b`,{children:`told`}),` these words before it listens, which is what makes it spell them your way. Whatever still comes out wrong is corrected afterwards from the list after the colon.`]}):(0,Q.jsxs)(`p`,{children:[`This phone is using the `,(0,Q.jsx)(`b`,{children:`browser's`}),` recogniser, which cannot be told words in advance — here the list only corrects what comes out, so the part after the colon does the work.`]}),(0,Q.jsxs)(`p`,{children:[`A term that arrives split (`,(0,Q.jsx)(`b`,{children:`BA 3`}),`, `,(0,Q.jsx)(`b`,{children:`B.A.3`}),`) is joined back without being listed, and one with a digit or an inner capital is re-cased (`,(0,Q.jsx)(`b`,{children:`ba3`}),` → `,(0,Q.jsx)(`b`,{children:`BA3`}),`). An ordinary word is never re-cased, so `,(0,Q.jsx)(`b`,{children:`Go`}),` leaves "go" alone.`]})]}),children:(0,Q.jsx)(`textarea`,{className:`guardrail-text`,rows:4,value:i,placeholder:`BA3: bee a three, be a 3
|
|
11
|
-
Tiptoi`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>J(`dictTerms`,e.target.value)})}),(0,Q.jsx)(Ud,{id:`close-kb-on-send`,label:`close the keyboard after Send`,icon:_m,on:o,onChange:()=>J(`closeKbOnSend`,!o),note:o?`Once a message goes, the keyboard drops so the answer gets the whole screen. Tap the box to type again.`:`The keyboard stays up after a send, ready for the next message.`}),c&&(0,Q.jsx)(Ud,{id:`shortcut-card`,label:`hold Ctrl to see shortcuts`,icon:vp,on:s,onChange:()=>J(`shortcutCard`,!s),note:s?`Hold Ctrl, ⌘ or Alt alone for half a second and a card lists what each key does with it right now. Letting go hides it.`:`Holding a modifier shows nothing. The shortcuts themselves still work.`}),(0,Q.jsx)(Il,{id:`busy-send`,radio:!0,label:`Send while it works`,icon:Zf,value:u,options:[{value:``,label:`ask`},{value:`now`,label:`send now`},{value:`idle`,label:`when it's free`}],onChange:e=>J(`busySend`,e),note:u===`now`?`Send on a session that is still working types the words into the running turn straight away.`:u===`idle`?`Send on a session that is still working hands the words to the desktop, which sends them when the turn ends.`:`Send on a session that is still working asks: send now, or when it's free.`}),(0,Q.jsx)(Il,{id:`btw-to-cli`,radio:!0,label:`/btw from the reader`,icon:Rf,value:l,options:[{value:``,label:`ask`},{value:`switch`,label:`switch to the CLI`},{value:`stay`,label:`stay`}],onChange:e=>J(`btwToCli`,e),note:l===`switch`?`A /btw sent from the reader switches to the CLI, where its answer is — the reader cannot show it.`:l===`stay`?`A /btw sent from the reader stays in the reader; its row has an open the CLI button for the answer.`:`After a /btw sent from the reader, asks whether to switch to the CLI, where its answer is.`}),(0,Q.jsx)(Ud,{id:`typing-room`,label:`typing room`,icon:Fm,on:a,onChange:()=>J(`typingRoom`,!a),note:a?`While the caret is in the box, everything above it is hidden except the output and the outline button.`:`The header, status line, key row and file strips stay up while you type.`,more:(0,Q.jsx)(`p`,{children:`On, the keyboard costs the terminal nothing — tap the terminal to get the header back. Measured: with all the chrome up, a phone keyboard left two lines of output.`})}),(0,Q.jsx)(Il,{id:`reader-tools`,radio:!0,label:`tool calls in the reader`,icon:wp,value:d,options:[[`fold`,`fold runs`],[`list`,`one row each`],[`full`,`download details`]].map(([e,t])=>({value:e,label:t})),onChange:e=>J(`toolsMode`,e),note:d===`fold`?`A run of tool calls collapses into one “N tool calls” line, so the conversation stays on screen.`:d===`list`?`Every tool call gets its own row.`:`Tool inputs and results come down with the transcript — everything is there offline.`,more:d===`full`?(0,Q.jsx)(`p`,{children:`At the cost of a much bigger download and a much bigger offline cache, which is what makes a long conversation slow to load on a phone.`}):(0,Q.jsx)(`p`,{children:`What a call ran and what came back stays on the host until you open one. Tap a folded run to see the calls, tap one to load it.`})}),(0,Q.jsx)(Il,{id:`hints-mode`,radio:!0,label:`button hints`,icon:Lp,value:f.mode,options:[[`first`,`explain once`],[`press`,`long-press only`],[`off`,`off`]].map(([e,t])=>({value:e,label:t})),onChange:e=>J(`hints`,{mode:e,seen:Ld()}),note:f.mode===`first`?`The handful of actions whose icon can't be guessed explain themselves the first time you tap them, then never again.`:f.mode===`press`?`Nothing interrupts a tap. Long-press any button to read what it does.`:`No hints at all — not even on long-press.`,more:(0,Q.jsx)(`p`,{children:`Hold, re-aim, fork, fan out and keep-newest are the ones that cannot be guessed from an icon. A long press never fires the button it explains.`})}),(0,Q.jsx)(_u,{id:`hints-explain`,label:`explain mode`,icon:Lp,onClick:()=>{ln(!0),$t().nav.close(`settings`)},note:`Turns every tap into an explanation until you leave it — the way back after everything has been dismissed.`,more:(0,Q.jsx)(`p`,{children:`Also on the “?” chip in the launcher and session headers.`})}),(0,Q.jsx)(Ud,{id:`hints-chip`,label:`? button in the headers`,icon:Lp,on:p!==`hidden`,onChange:()=>J(`hintChip`,p===`hidden`?`asked`:`hidden`),note:p===`hidden`?`Removed from the launcher and session headers. Long-press any button, or explain mode above, still explains it.`:`The ? in the launcher and session headers turns on explain mode. Leaving it the first time asks whether it can go.`}),(0,Q.jsx)(_u,{id:`hints-reset`,label:`explain them again`,icon:xm,cant:f.seen===0?`nothing has been dismissed yet`:void 0,onClick:()=>{bn(),ic.reload(`hints`),G(`hints reset`)},note:f.seen===0?`Dismissals follow you to your other devices.`:`${f.seen} dismissed. This makes them all first-time again, on every device.`})]})}function mb({install:e,reconnect:t}){let n=ud(),r=q(`autoSend`),i=q(`serialSessions`),a=q(`confirmQueue`),o=q(`saver`),s=q(`bgFresh`),c=$t().queue.entries.filter(e=>e.status===`queued`);return(0,Q.jsxs)(Q.Fragment,{children:[e.installed?(0,Q.jsx)(Pc,{id:`install`,label:`install this app`,icon:bm,note:`Running as an installed app.`}):n===`insecure`?(0,Q.jsx)(Pc,{id:`install`,label:`install this app`,icon:Nf,children:(0,Q.jsxs)(Ta,{children:[`Installing needs a secure context — you're on `,location.protocol,`//`,location.host,`, and a service worker can't register over plain HTTP. Front the host with TLS (the command under Notifications), reopen on the HTTPS name, then install from here.`]})}):e.canInstall?(0,Q.jsx)(_u,{id:`install`,label:`install this app`,icon:Nf,onClick:async()=>{Y(`action:install.app`);let t=e.evt.current;if(!t)G(`install offer expired — reload and try again`);else{e.evt.current=null,e.taken();try{t.prompt(),await t.userChoice}catch{G(`install cancelled`)}}},note:`Adds it to your home screen and runs it full-screen, without browser chrome.`}):Gy()?(0,Q.jsx)(Pc,{id:`install`,label:`install this app`,icon:Nf,note:(0,Q.jsxs)(Q.Fragment,{children:[`To install: tap Share, then `,(0,Q.jsx)(`b`,{children:`Add to Home Screen`}),`. iOS has no in-app install button.`]})}):(0,Q.jsx)(Pc,{id:`install`,label:`install this app`,icon:Nf,note:`No install offer from this browser right now — it may already be installed, or the browser needs another visit first.`}),(0,Q.jsx)(Ud,{id:`auto-send`,label:`auto-send the queue`,icon:Am,on:r,onChange:()=>{J(`autoSend`,!r),G(r?`queued messages wait for “Send now”`:`queued messages will send themselves`)},note:(0,Q.jsxs)(Q.Fragment,{children:[`Messages sent while the link is down go out the moment the host is reachable again.`,c.length>0?` ${c.length} waiting now.`:``]}),more:(0,Q.jsx)(`p`,{children:`They are kept in this browser, so a reload or the phone killing the tab doesn't lose them — Return included. Several messages for the SAME session go out one at a time, in order, each waiting for the one before it to be submitted. The host de-duplicates delivery receipts, so a re-send can never type the same prompt twice. Off holds them until you tap “Send now”.`})}),(0,Q.jsx)(Ud,{id:`serial-sessions`,label:`one session at a time per repo`,icon:Hm,on:i,onChange:()=>{J(`serialSessions`,!i),G(i?`queued work all starts at once`:`queued work runs one session at a time per repo`)},note:`On, a queued open waits until every session in that directory has finished its turn.`,more:(0,Q.jsx)(`p`,{children:`Queue five prompts for one repo on a train and, with this off, all five open their own agent the second the link is back: one account's usage limit spent five ways in parallel, five half-finished turns when it runs out, and five agents editing the same working tree. A worktree counts as its own directory — that is what makes running work in parallel safe in the first place. Only opens that carry a prompt are held (a bare terminal runs nothing), and “Send this one now” always overrides it.`})}),(0,Q.jsx)(Ud,{id:`confirm-queue`,label:`ask on reconnect`,icon:Wm,on:a,onChange:()=>{a&&(t.holdRef.current=!1,t.setReconnectAsk(!1),t.flush()),J(`confirmQueue`,!a),G(a?`the queue drains without asking`:`you'll be asked before the queue goes out`)},note:`Text typed offline was written against what the session looked like THEN — ask before it goes out.`,more:(0,Q.jsx)(`p`,{children:`Send it, review and edit it first, or hold it. Off = it just goes (subject to auto-send above). A message you send with the link UP is never held by this.`})}),c.length>0&&(0,Q.jsx)(_u,{id:`queue-manage`,label:`manage ${c.length} queued`,icon:Hm,opens:!0,onClick:()=>{Y(`action:queue.manage`),$t().nav.open(`queue`)}}),(0,Q.jsx)(Ud,{id:`data-saver`,label:`data saver`,icon:Wm,on:o,onChange:()=>{let e=!o;J(`saver`,e),Y(`action:datasaver`),G(e?`data saver on — smaller images, slower polling`:`data saver off`),e&&ob(`app`)},note:`For a roaming or hotel link: smaller image copies, slower background polling. Per device.`,more:(0,Q.jsx)(`p`,{children:`Asks the host for smaller images in the grids and the full-screen viewer — “full res” is always one tap away — and slows the reader view's background polling.`})}),(0,Q.jsx)(ma,{id:`bg-fresh`,label:`in the background`,icon:jf,min:0,max:xo.length-1,step:1,value:Math.max(0,xo.indexOf(s)),readout:Mo(s),onInput:e=>J(`bgFresh`,xo[e]??s),onCommit:()=>Y(`action:bgfresh`),note:Bi(s),more:(0,Q.jsx)(`p`,{children:`Battery against how recent the screen is that you can read with no signal. Left is fresher, right saves more. Takes effect the next time the app goes to the background. Per device.`})})]})}function hb({id:e,label:t,icon:n,cfg:r,k:i,note:a,more:o}){let s=[...Dc,0],c=r[i],l=s.indexOf(c);l<0&&(l=s.findIndex(e=>e>c)),l<0&&(l=s.length-2);let u=e=>{Y(`action:agentWarn.${i}`),J(`agentWarn`,{...r,[i]:e})};return(0,Q.jsx)(rn,{id:e,label:t,icon:n,readout:c===0?`off`:String(c),onLess:l>0?()=>u(s[l-1]):null,onMore:l>=0&&l<s.length-1?()=>u(s[l+1]):null,lessLabel:`fewer`,moreLabel:s[l+1]===0?`off`:`more`,note:a,more:o})}var gb=ms(``),_b=0,vb=ms(``);function yb(e){let t=Yd(gb),n=Du();(0,Z.useEffect)(()=>(_b++,()=>{_b--,queueMicrotask(()=>{_b===0&&Fr.set(null)})}),[]);let r=$t(),{status:i}=r.conn,{tailscaleIp:a}=r.conn.info,o=hn(t,n);return(0,Q.jsxs)(`div`,{className:`sheet`,children:[(0,Q.jsx)(fa,{title:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(kf,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),` Settings`]}),onClose:()=>r.nav.close(`settings`),children:(0,Q.jsxs)(`div`,{className:`conn conn-${i}`,children:[i,a?` · ${a}`:``]})}),(0,Q.jsx)(cn,{keys:Ne,thing:`your settings`}),(0,Q.jsx)($d,{value:t,onChange:e=>{Fr.set(null),gb.set(e)}}),(0,Q.jsx)(En,{value:o,children:(0,Q.jsxs)(`div`,{className:`settings`,children:[(0,Q.jsxs)(Yo,{id:`sessions`,title:`Sessions`,icon:bp,children:[ly(`sessions`,{to:0}),(0,Q.jsx)(bb,{pickBackend:e.pickBackend}),ly(`sessions`,{from:0})]}),(0,Q.jsx)(Yo,{id:`notifications`,title:`Notifications`,icon:zf,children:ly(`notifications`)}),(0,Q.jsxs)(Yo,{id:`appearance`,title:`Appearance`,icon:gm,children:[ly(`appearance`,{to:0}),(0,Q.jsx)(fb,{}),ly(`appearance`,{from:0})]}),(0,Q.jsxs)(Yo,{id:`writing`,title:`Writing & reading`,icon:Wf,children:[ly(`writing`,{to:0}),(0,Q.jsx)(pb,{voice:e.voice}),ly(`writing`,{from:0})]}),(0,Q.jsxs)(Yo,{id:`offline`,title:`Offline & data`,icon:Nf,children:[ly(`offline`,{to:0}),(0,Q.jsx)(mb,{install:e.install,reconnect:e.reconnect}),ly(`offline`,{from:0})]}),(0,Q.jsxs)(Yo,{id:`connection`,title:`Connection`,icon:If,children:[ly(`connection`,{to:0}),(0,Q.jsx)(xb,{redial:e.redial}),ly(`connection`,{from:0})]}),(0,Q.jsxs)(Yo,{id:`tools`,title:`Tools & diagnostics`,icon:Xp,children:[ly(`tools`,{to:-10}),(0,Q.jsxs)(`div`,{className:`set-doors`,children:[ly(`tools`,{from:-10,to:0}),(0,Q.jsx)(Sb,{pickShotRepo:e.pickShotRepo})]}),ly(`tools`,{from:0})]}),(0,Q.jsx)(Sc,{tally:o,onClear:()=>{Fr.set(null),gb.set(``)}})]})})]})}function bb({pickBackend:e}){let t=$t(),n=t.world.backends,r=t.world.launch,i=t.launch.setOpt,a=q(`launchAsk`),o=q(`closeWhenDone`),s=q(`confirmClose`),c=q(`localSessions`);return(0,Q.jsxs)(Q.Fragment,{children:[ss(n)&&(0,Q.jsxs)(vs,{id:`launch-backend`,label:`backend`,control:(0,Q.jsx)(`select`,{value:r.backend??`claude`,onChange:t=>e(t.target.value===`claude`?void 0:t.target.value),children:dl(n).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:Fn(e)},e.id))}),note:(0,Q.jsxs)(Q.Fragment,{children:[`What a new session runs.`,Qu(n,r.backend)?` ${Qu(n,r.backend)}.`:``,el(n,r.backend)?` ${el(n,r.backend)}`:``]}),more:(0,Q.jsx)(`p`,{children:`Sessions already open keep the binary they started with. The window size is said only when it is known — never a 0k, and never claude's window borrowed for a local model.`}),children:[pr(n,r.backend)&&(0,Q.jsx)(df,{className:`act-cants`,children:(0,Q.jsx)(lc,{children:pr(n,r.backend)})}),(0,Q.jsx)(hu,{className:`set-note`,cants:[[`context meter`,`contextMeter`],[`transcript`,`transcript`],[`slash commands`,`slash`],[`effort`,`effort`],[`remote control`,`remoteControl`]].flatMap(([e,t])=>{let i=Gr(n,r.backend,t);return i?[{label:e,reason:i}]:[]})})]}),(0,Q.jsx)(vs,{id:`launch-model`,label:`model`,control:(0,Q.jsx)($c,{backends:n,backend:r.backend,value:r.model,onChange:e=>i({model:e})})}),Wt(n,r.backend).length===0&&Gr(n,r.backend,`effort`)&&(0,Q.jsx)(df,{children:Gr(n,r.backend,`effort`)}),Wt(n,r.backend).length>0&&(0,Q.jsx)(vs,{id:`launch-effort`,label:`effort`,control:(0,Q.jsxs)(`select`,{value:r.effort??``,onChange:e=>i({effort:e.target.value||void 0}),children:[(0,Q.jsx)(`option`,{value:``,children:`default`}),Wt(n,r.backend).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})}),Pr(n,r.backend).length>0&&(0,Q.jsxs)(vs,{id:`launch-permission`,label:`permission`,control:(0,Q.jsxs)(`select`,{className:r.permissionMode&&uy.has(r.permissionMode)?`danger`:``,value:r.permissionMode??``,onChange:e=>{let t=e.target.value||void 0;!t||!uy.has(t)?i({permissionMode:t}):(e.target.value=r.permissionMode??``,(async()=>{await Hs({title:t,lines:dy,confirmLabel:`Run without asking`})&&i({permissionMode:t})})())},children:[(0,Q.jsx)(`option`,{value:``,children:`default`}),Pr(n,r.backend).map(e=>(0,Q.jsxs)(`option`,{value:e,children:[e,uy.has(e)?` — no approvals`:``]},e))]}),children:[r.permissionMode&&uy.has(r.permissionMode)&&(0,Q.jsxs)(df,{className:`danger-note`,children:[(0,Q.jsx)(Up,{size:13,style:{verticalAlign:`-2px`}}),` New sessions run every tool call without asking. Nothing will stop a destructive command.`,` `,(0,Q.jsx)(`button`,{className:`link-btn`,onClick:()=>i({permissionMode:void 0}),children:`back to default`})]}),Eu(r,n)&&(0,Q.jsx)(Ta,{tone:`plain`,children:Eu(r,n)})]}),nr(n,r.backend,`remoteControl`)&&(0,Q.jsx)(Ud,{id:`launch-remote`,label:`remote control`,icon:Wm,on:!!r.remoteControlled,onChange:()=>i({remoteControlled:!r.remoteControlled}),note:`Starts new sessions with --remote-control, so they are steerable from claude.ai.`,more:(0,Q.jsx)(`p`,{children:`Applies to sessions you start from here. Sessions already open keep the flags they were started with.`})}),(0,Q.jsx)(Ud,{id:`launch-ask`,label:`ask before each launch`,icon:Lp,on:a,onChange:()=>{Y(`action:launchAsk.toggle`),J(`launchAsk`,!a)},note:(0,Q.jsxs)(Q.Fragment,{children:[`On, starting a new session asks `,ss(n)?`which backend and model`:`which model`,` first, starting from the values above.`]}),more:(0,Q.jsx)(`p`,{children:`The answer applies to that session only — these defaults stay as they are. Resuming a conversation never asks: it keeps the launch it was recorded with.`})}),(0,Q.jsx)(py,{}),(0,Q.jsx)(Ud,{id:`confirm-close`,label:`ask before closing a session`,icon:Bf,on:s,onChange:()=>{Y(`action:confirmClose.toggle`),J(`confirmClose`,!s),G(s?`sessions close without asking`:`you'll be asked before a close loses work`)},note:`On, closing a session with uncommitted changes, commits not merged or shells still running asks first.`,more:(0,Q.jsx)(`p`,{children:`Off, the close goes straight through and the toast still names what was left behind. Its conversation stays under “Recently closed” either way; uncommitted changes stay in the working tree.`})}),(0,Q.jsx)(Ud,{id:`close-when-done`,label:`close automatic sessions when done`,icon:fp,on:o,onChange:()=>{Y(`action:closeWhenDone.toggle`),J(`closeWhenDone`,!o)},note:o?(0,Q.jsx)(Q.Fragment,{children:`On: a session that a backlog or scheduled item opened closes itself once its work is done and it has sat idle for 10 minutes (the desktop's default). Its conversation stays under “Recently closed” and reopens where it left off.`}):(0,Q.jsx)(Q.Fragment,{children:`Off: a session that a backlog or scheduled item opened stays open until you close it, so you can read it and carry on in it.`}),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Which sessions this covers.`}),` Only the ones `,C.name,` opens for work you queued: a backlog item (whether the backlog fired it or you tapped fire), each run of a scheduled item, a prompt an agent posted for later, and the session that continues one of these after a usage limit. Their titles start with “backlog ·”.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Never closed by this.`}),` Sessions you open yourself, the backlog's “open a session here”, one prompt sent to several repos, a launch you queued for later, and anything you reopened from “Recently closed”.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What “done” means.`}),` The turn has ended and the idle wait (10 minutes by default) has passed with nobody watching it on a phone, no background agent and no background shell still running under it. A session waiting on your answer is never closed.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`One item, its own answer.`}),` Open a row on the backlog (or use the choice under “To” when you schedule one) to say “keep open” or “close when done” for that item only; it wins over this switch.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What a slot is.`}),` The desktop runs at most 3 automatic sessions at the same time (the default; `,(0,Q.jsx)(`code`,{children:Ye(`BACKLOG_SESSIONS`)}),` on the desktop changes it). A “backlog ·” session holds one of those slots only while it is working (a turn running, a box waiting on you, a background shell or agent still going); finished and idle, it holds none, even left open. The backlog's “open a session here” counts the same way. Sessions you open yourself never do.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Why there is a limit.`}),` Every session is a real `,(0,Q.jsx)(`code`,{children:`claude`}),` process on your desktop, using its memory and your account's usage. Without a limit, a desktop that comes back after a few days with a pile of due items would start them all inside a minute.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Leaving sessions open does not stop queued work.`}),` With this switch off, finished sessions stay open for you to read, and the next backlog or scheduled item still starts as soon as fewer than 3 are working. When all 3 are working, it waits and says “waiting for a free slot”; a slot frees itself when one goes idle, and “close one to make room” lists the working ones if you want to stop one sooner.`]})]})}),(0,Q.jsx)(Il,{id:`local-sessions`,label:`local model sessions at once`,icon:hm,value:c,options:[{value:``,label:`desktop default`},{value:`1`,label:`1`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`0`,label:`no limit`}],onChange:e=>{Y(`action:localSessions.set`),J(`localSessions`,e)},note:c===`0`?(0,Q.jsx)(Q.Fragment,{children:`No limit: automatic work on a local model starts whenever it is due, even while another local session is working.`}):c?(0,Q.jsxs)(Q.Fragment,{children:[`At most `,c,` session`,c===`1`?``:`s`,` on a local model working at once. Queued work waits for the local model; one you start yourself still starts, and says so.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`The desktop's own setting — 1 unless `,(0,Q.jsx)(`code`,{children:Ye(`LOCAL_SESSIONS`)}),` says otherwise.`]}),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What counts.`}),` A session on a model that runs on this desktop (Claude Code on a local model, or another backend on a local model) while a turn is running. An open local session that is idle holds nothing.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What waits.`}),` Backlog items, scheduled work, prompts an agent posted for later, and each repo of a sweep. Their row says “waiting for the local model — 1 local session is working”.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`The model is loaded first.`}),` Before queued work opens on a local model, the desktop loads that model on Ollama and waits for it. If Ollama is not running or does not have the model, the row says so and tries again; it never switches to another model.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Background helpers.`}),` A summary or naming pass sent to the same local runner is skipped while a local coding session is working on a different model, so it cannot swap that model out mid-turn.`]})]})}),(0,Q.jsx)(_u,{id:`hosted-notice`,label:`show the hosted-model notice again`,icon:xm,onClick:()=>{Y(`action:hostedAck.reset`),sg(),G(`hosted-model notice reset — the next hosted launch will show it again`)},note:`The first session on a model that runs on somebody else's server stops once and says what that means.`,more:(0,Q.jsx)(`p`,{children:`After you accept, it stays out of the way. Local models and Claude Code never show it.`})})]})}function xb({redial:e}){let t=$t(),n=t.conn.info.auth,r=t.conn.status,i=Yd(vb);return(0,Q.jsxs)(Q.Fragment,{children:[n.canManage?(0,Q.jsx)(Pc,{id:`lan-password`,label:`LAN password`,icon:rm,note:n.enabled?`A password is set. Devices reaching this host over the local network (not Tailscale) must enter it.`:`No password set. While a LAN interface is bound (${Ye(`ALLOW_PUBLIC`)}=1), LAN devices are blocked until you set one here.`,more:(0,Q.jsx)(`p`,{children:`Changing or clearing the password logs out every gated device. Password management is only available on this trusted path — LAN devices can never set it.`}),children:(0,Q.jsxs)(`div`,{className:`set-chips`,children:[(0,Q.jsx)(`input`,{className:`auth-input`,type:`password`,placeholder:n.enabled?`new password`:`set a password`,value:i,onChange:e=>vb.set(e.target.value),style:{maxWidth:220}}),i.length>=4?(0,Q.jsx)(K,{variant:`primary`,onClick:()=>{t.conn.send({t:`auth.set`,password:i}),vb.set(``),G(n.enabled?`password changed`:`password set`)},children:n.enabled?`change`:`set password`}):(0,Q.jsx)(`span`,{className:`set-cant-why`,children:i.length===0?`type a password of at least four characters`:`at least four characters`}),n.enabled&&(0,Q.jsx)(K,{variant:`danger`,onClick:()=>{t.conn.send({t:`auth.clear`}),G(`password cleared — LAN blocked`)},children:`clear`})]})}):(0,Q.jsx)(_u,{id:`lan-logout`,label:`log out this device`,icon:rm,onClick:async()=>{await Gd.auth.logout(),e()},note:`Connected over the local network (authenticated). The password is managed from the desktop or a Tailscale connection.`}),n.canManage&&n.enabled&&(0,Q.jsx)(Ud,{id:`lan-gate-tailscale`,label:`gate Tailscale too`,icon:rm,on:n.gateTailscale,onChange:()=>t.conn.liveSend({t:`auth.gateTailscale`,enabled:!n.gateTailscale},n.gateTailscale?`Tailscale devices no longer need the password`:`Tailscale devices now need the password`),note:`Require the password from Tailscale peers as well. Off = Tailscale trusted; loopback stays exempt either way.`}),(0,Q.jsx)(_u,{id:`sync-push`,label:`use this device's copy`,icon:jp,cant:r===`open`?void 0:`no connection to the host right now`,onClick:()=>{let e=qc();G(e?`pushing ${e} setting${e===1?``:`s`} from this device`:`nothing to push`)},note:`Makes this device's copy the one every other client gets. The newest edit wins.`,more:(0,Q.jsx)(`p`,{children:`Prompt templates, fan-out presets, header commands, the prompt pad, the toolbar layout and your new-session defaults are kept on the host, so every client — this phone, a desktop tab, the Android app — has the same ones. The send queue, drafts and anything about this device's link stay here. If a client adopted the wrong list (the first one to connect after an update seeds the host), push from the device that has the good one.`})})]})}function Sb({pickShotRepo:e}){let t=$t(),n=t.nav.open;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_u,{id:`tool-net-health`,compact:!0,label:`connection health`,icon:Bp,title:`what the link has been doing to your prompts`,onClick:()=>{Y(`overlay:nethealth`),n(`nethealth`)}}),(0,Q.jsx)(_u,{id:`tool-storage`,compact:!0,label:`storage`,icon:Pf,title:`what this phone is holding, and what clearing any of it would cost`,onClick:()=>{Y(`overlay:storage`),n(`storage`)}}),(0,Q.jsx)(_u,{id:`tool-speedtest`,compact:!0,label:`speed test`,icon:Wp,title:`connection speed test + diagnostics`,onClick:()=>n(`speedtest`)}),(0,Q.jsx)(_u,{id:`tool-host-stat`,compact:!0,label:`host stat`,icon:hm,title:`host CPU / memory load`,onClick:()=>void gt()}),(0,Q.jsx)(_u,{id:`tool-repo-setup`,compact:!0,label:`repo setup`,icon:xp,title:`repo setup checklist`,onClick:()=>n(`setup`)}),(0,Q.jsx)(_u,{id:`tool-secret`,compact:!0,label:`secret`,icon:Mf,title:`set a secret (write-only)`,onClick:()=>n(`secret`)}),(0,Q.jsx)(_u,{id:`tool-features`,compact:!0,label:`feature usage`,icon:am,title:`which features you actually use (and which you never do)`,onClick:()=>n(`features`)}),(0,Q.jsx)(_u,{id:`tool-screenshot`,compact:!0,label:`screenshot`,icon:np,title:`screenshot the desktop`,onClick:()=>{let n=t.world.visibleRepos;n.length?n.length===1?ec(n[0].id):e():G(`no repo to store the shot`)}})]})}function Cb(e){let{send:t,sessions:n,pendingSession:r,removeQueued:i}=e,{sendSeed:a,setSendSeed:o,sendResumeRef:s,dispatchIntent:c,noteSendAim:l,retireSendSource:u,openSent:d}=t;return a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(cf,{seed:a,sessions:r&&!yh(r.id)?[...n,r]:n,repos:e.visibleRepos,outbox:e.outbox,online:e.online,usage:e.usage,intents:e.intents,backends:e.backends,launchDefaults:e.launch,buildName:t.buildNames,onAttach:e.onAttach,onAnnotate:e.onAnnotate,onBrowseRepoFiles:e.onBrowseRepoFiles,resume:s.current,onDecide:e=>{s.current=e},onReattach:t.reattachKept,onReplace:t.pickReplacement,onSend:e=>{if(!c(e,a))return!1;let t=e.target.kind===`session`||e.target.kind===`repo`?e.target.cwd:null;return t&&l(t,{when:e.when}),u(a),a.onPosted?.(),a.openAfter&&e.target.kind===`session`&&d(e.target.sessionId),!0},onDiscard:a.ackId||a.padId?()=>{Y(`action:send.discard`),a.ackId&&i(a.ackId),a.padId&&Sr([a.padId]),di(No),G(`discarded`)}:void 0,onClose:()=>{s.current=null,o(null),e.closeSheet(`send`)}}),(0,Q.jsx)(`input`,{ref:t.replacePick,type:`file`,hidden:!0,onChange:t.onPickReplacement})]}):null}var wb=`<?xml version="1.0" encoding="UTF-8"?>
|
|
12
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
13
|
-
<defs>
|
|
14
|
-
<clipPath id="aclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
15
|
-
<linearGradient id="asky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0A1B28"/><stop offset="1" stop-color="#10324A"/></linearGradient>
|
|
16
|
-
<linearGradient id="asea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0F5A66"/><stop offset="1" stop-color="#061219"/></linearGradient>
|
|
17
|
-
<linearGradient id="awarm" gradientUnits="userSpaceOnUse" x1="60" y1="140" x2="300" y2="320"><stop offset="0" stop-color="#F5A93F"/><stop offset="1" stop-color="#EC6F55"/></linearGradient>
|
|
18
|
-
<radialGradient id="aglow" cx=".74" cy=".62" r=".42">
|
|
19
|
-
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.34"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
20
|
-
<clipPath id="arip"><rect x="30" y="344" width="380" height="12"/><rect x="46" y="364" width="356" height="11"/><rect x="30" y="384" width="332" height="10"/><rect x="46" y="404" width="308" height="9"/><rect x="30" y="424" width="284" height="8"/><rect x="46" y="444" width="260" height="7"/><rect x="30" y="464" width="236" height="6"/><rect x="46" y="484" width="212" height="5"/></clipPath>
|
|
21
|
-
<linearGradient id="afade" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".9"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>
|
|
22
|
-
<mask id="arm"><rect y="330" width="512" height="182" fill="url(#afade)"/></mask>
|
|
23
|
-
</defs>
|
|
24
|
-
<g clip-path="url(#aclip)">
|
|
25
|
-
<rect width="512" height="512" fill="url(#asky)"/>
|
|
26
|
-
<circle cx="74" cy="70" r="2" fill="#E9F4F2" opacity=".5"/><circle cx="150" cy="104" r="1.4" fill="#E9F4F2" opacity=".5"/><circle cx="412" cy="76" r="2.2" fill="#E9F4F2" opacity=".5"/><circle cx="462" cy="146" r="1.3" fill="#E9F4F2" opacity=".5"/><circle cx="334" cy="56" r="1.5" fill="#E9F4F2" opacity=".5"/><circle cx="226" cy="48" r="1.1" fill="#E9F4F2" opacity=".5"/><circle cx="40" cy="150" r="1.2" fill="#E9F4F2" opacity=".5"/>
|
|
27
|
-
<rect width="512" height="512" fill="url(#aglow)"/>
|
|
28
|
-
<rect y="330" width="512" height="182" fill="url(#asea)"/>
|
|
29
|
-
<path d="M40,172 L4,168 M44,292 L10,296" stroke="#E9F4F2" stroke-width="4" stroke-linecap="round" opacity=".22"/>
|
|
30
|
-
|
|
31
|
-
<g transform="rotate(7 286 228)">
|
|
32
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#awarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
33
|
-
<path d="M272,228 L84,228" stroke="url(#awarm)" stroke-width="22" stroke-linecap="round"/>
|
|
34
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#awarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
35
|
-
<path d="M140,160 L270,228" stroke="#fff" stroke-opacity=".28" stroke-width="7" stroke-linecap="round"/>
|
|
36
|
-
<circle cx="250" cy="228" r="6.5" fill="#0A1B28" opacity=".5"/>
|
|
37
|
-
</g>
|
|
38
|
-
|
|
39
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
40
|
-
<animate attributeName="opacity" values="1;1;.12;.12" keyTimes="0;.5;.56;1" dur="1.1s" repeatCount="indefinite"/>
|
|
41
|
-
</rect>
|
|
42
|
-
<g mask="url(#arm)"><g clip-path="url(#arip)" opacity="0.4"><g transform="translate(0,660) scale(1,-1)">
|
|
43
|
-
|
|
44
|
-
<g transform="rotate(7 286 228)">
|
|
45
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="#F5A93F" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
46
|
-
<path d="M272,228 L84,228" stroke="#F5A93F" stroke-width="22" stroke-linecap="round"/>
|
|
47
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="#F5A93F" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
48
|
-
|
|
49
|
-
</g>
|
|
50
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
51
|
-
</rect></g></g></g>
|
|
52
|
-
<path d="M300,338 q11,-5 22,0 t22,0 t22,0 t22,0 t22,0 t22,0 t22,0" fill="none" stroke="#E9F4F2" stroke-width="3" opacity=".5"/>
|
|
53
|
-
</g></svg>
|
|
54
|
-
`,Tb=`<?xml version="1.0" encoding="UTF-8"?>
|
|
55
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
56
|
-
<defs>
|
|
57
|
-
<clipPath id="sclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
58
|
-
<linearGradient id="ssky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0A1B28"/><stop offset="1" stop-color="#10324A"/></linearGradient>
|
|
59
|
-
<linearGradient id="ssea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0F5A66"/><stop offset="1" stop-color="#061219"/></linearGradient>
|
|
60
|
-
<linearGradient id="swarm" gradientUnits="userSpaceOnUse" x1="60" y1="140" x2="300" y2="320"><stop offset="0" stop-color="#F5A93F"/><stop offset="1" stop-color="#EC6F55"/></linearGradient>
|
|
61
|
-
<radialGradient id="sglow" cx=".74" cy=".62" r=".42">
|
|
62
|
-
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.34"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
63
|
-
<clipPath id="srip"><rect x="30" y="344" width="380" height="12"/><rect x="46" y="364" width="356" height="11"/><rect x="30" y="384" width="332" height="10"/><rect x="46" y="404" width="308" height="9"/><rect x="30" y="424" width="284" height="8"/><rect x="46" y="444" width="260" height="7"/><rect x="30" y="464" width="236" height="6"/><rect x="46" y="484" width="212" height="5"/></clipPath>
|
|
64
|
-
<linearGradient id="sfade" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".9"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>
|
|
65
|
-
<mask id="srm"><rect y="330" width="512" height="182" fill="url(#sfade)"/></mask>
|
|
66
|
-
</defs>
|
|
67
|
-
<g clip-path="url(#sclip)">
|
|
68
|
-
<rect width="512" height="512" fill="url(#ssky)"/>
|
|
69
|
-
|
|
70
|
-
<rect width="512" height="512" fill="url(#sglow)"/>
|
|
71
|
-
<rect y="330" width="512" height="182" fill="url(#ssea)"/>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<g transform="rotate(7 286 228)">
|
|
75
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#swarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
76
|
-
<path d="M272,228 L84,228" stroke="url(#swarm)" stroke-width="22" stroke-linecap="round"/>
|
|
77
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#swarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
78
|
-
|
|
79
|
-
</g>
|
|
80
|
-
|
|
81
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
82
|
-
</rect>
|
|
83
|
-
|
|
84
|
-
</g></svg>
|
|
85
|
-
`,Eb=`<?xml version="1.0" encoding="UTF-8"?>
|
|
86
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
87
|
-
<defs>
|
|
88
|
-
<clipPath id="lclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
89
|
-
<linearGradient id="lsky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#F4F8F7"/><stop offset="1" stop-color="#E3EFEE"/></linearGradient>
|
|
90
|
-
<linearGradient id="lsea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#BFDDDB"/><stop offset="1" stop-color="#93C1BF"/></linearGradient>
|
|
91
|
-
<linearGradient id="lwarm" gradientUnits="userSpaceOnUse" x1="60" y1="140" x2="300" y2="320"><stop offset="0" stop-color="#F5A93F"/><stop offset="1" stop-color="#EC6F55"/></linearGradient>
|
|
92
|
-
<radialGradient id="lglow" cx=".74" cy=".62" r=".42">
|
|
93
|
-
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.22"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
94
|
-
<clipPath id="lrip"><rect x="30" y="344" width="380" height="12"/><rect x="46" y="364" width="356" height="11"/><rect x="30" y="384" width="332" height="10"/><rect x="46" y="404" width="308" height="9"/><rect x="30" y="424" width="284" height="8"/><rect x="46" y="444" width="260" height="7"/><rect x="30" y="464" width="236" height="6"/><rect x="46" y="484" width="212" height="5"/></clipPath>
|
|
95
|
-
<linearGradient id="lfade" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".9"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>
|
|
96
|
-
<mask id="lrm"><rect y="330" width="512" height="182" fill="url(#lfade)"/></mask>
|
|
97
|
-
</defs>
|
|
98
|
-
<g clip-path="url(#lclip)">
|
|
99
|
-
<rect width="512" height="512" fill="url(#lsky)"/>
|
|
100
|
-
|
|
101
|
-
<rect width="512" height="512" fill="url(#lglow)"/>
|
|
102
|
-
<rect y="330" width="512" height="182" fill="url(#lsea)"/>
|
|
103
|
-
<path d="M40,172 L4,168 M44,292 L10,296" stroke="#0A1620" stroke-width="4" stroke-linecap="round" opacity=".22"/>
|
|
104
|
-
|
|
105
|
-
<g transform="rotate(7 286 228)">
|
|
106
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#lwarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
107
|
-
<path d="M272,228 L84,228" stroke="url(#lwarm)" stroke-width="22" stroke-linecap="round"/>
|
|
108
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#lwarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
109
|
-
<path d="M140,160 L270,228" stroke="#fff" stroke-opacity=".28" stroke-width="7" stroke-linecap="round"/>
|
|
110
|
-
<circle cx="250" cy="228" r="6.5" fill="#0A1B28" opacity=".5"/>
|
|
111
|
-
</g>
|
|
112
|
-
|
|
113
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#EC6F55">
|
|
114
|
-
</rect>
|
|
115
|
-
<g mask="url(#lrm)"><g clip-path="url(#lrip)" opacity="0.45"><g transform="translate(0,660) scale(1,-1)">
|
|
116
|
-
|
|
117
|
-
<g transform="rotate(7 286 228)">
|
|
118
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="#F5A93F" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
119
|
-
<path d="M272,228 L84,228" stroke="#F5A93F" stroke-width="22" stroke-linecap="round"/>
|
|
120
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="#F5A93F" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
121
|
-
|
|
122
|
-
</g>
|
|
123
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
124
|
-
</rect></g></g></g>
|
|
125
|
-
<path d="M300,338 q11,-5 22,0 t22,0 t22,0 t22,0 t22,0 t22,0 t22,0" fill="none" stroke="#fff" stroke-width="3" opacity=".5"/>
|
|
126
|
-
</g></svg>
|
|
127
|
-
`,Db=`<?xml version="1.0" encoding="UTF-8"?>
|
|
128
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
129
|
-
<defs>
|
|
130
|
-
<clipPath id="slclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
131
|
-
<linearGradient id="slsky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#F4F8F7"/><stop offset="1" stop-color="#E3EFEE"/></linearGradient>
|
|
132
|
-
<linearGradient id="slsea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#BFDDDB"/><stop offset="1" stop-color="#93C1BF"/></linearGradient>
|
|
133
|
-
<linearGradient id="slwarm" gradientUnits="userSpaceOnUse" x1="60" y1="140" x2="300" y2="320"><stop offset="0" stop-color="#F5A93F"/><stop offset="1" stop-color="#EC6F55"/></linearGradient>
|
|
134
|
-
<radialGradient id="slglow" cx=".74" cy=".62" r=".42">
|
|
135
|
-
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.22"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
136
|
-
<clipPath id="slrip"><rect x="30" y="344" width="380" height="12"/><rect x="46" y="364" width="356" height="11"/><rect x="30" y="384" width="332" height="10"/><rect x="46" y="404" width="308" height="9"/><rect x="30" y="424" width="284" height="8"/><rect x="46" y="444" width="260" height="7"/><rect x="30" y="464" width="236" height="6"/><rect x="46" y="484" width="212" height="5"/></clipPath>
|
|
137
|
-
<linearGradient id="slfade" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".9"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>
|
|
138
|
-
<mask id="slrm"><rect y="330" width="512" height="182" fill="url(#slfade)"/></mask>
|
|
139
|
-
</defs>
|
|
140
|
-
<g clip-path="url(#slclip)">
|
|
141
|
-
<rect width="512" height="512" fill="url(#slsky)"/>
|
|
142
|
-
|
|
143
|
-
<rect width="512" height="512" fill="url(#slglow)"/>
|
|
144
|
-
<rect y="330" width="512" height="182" fill="url(#slsea)"/>
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
<g transform="rotate(7 286 228)">
|
|
148
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#slwarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
149
|
-
<path d="M272,228 L84,228" stroke="url(#slwarm)" stroke-width="22" stroke-linecap="round"/>
|
|
150
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#slwarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
151
|
-
|
|
152
|
-
</g>
|
|
153
|
-
|
|
154
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#EC6F55">
|
|
155
|
-
</rect>
|
|
156
|
-
|
|
157
|
-
</g>
|
|
158
|
-
<rect x="6" y="6" width="500" height="500" rx="108" fill="none" stroke="#0A1B28" stroke-opacity=".14" stroke-width="12"/></svg>
|
|
159
|
-
`;function Ob(e){return e<64}var kb=e=>e.replace(/<\?xml[^>]*\?>/,``).replace(/<animate\b[^>]*\/>/g,``).replace(/<(animate)\b[^>]*>[\s\S]*?<\/\1>/g,``),Ab=e=>`data:image/svg+xml;charset=utf-8,${encodeURIComponent(kb(e))}`,jb={dark:{full:Ab(wb),small:Ab(Tb)},light:{full:Ab(Eb),small:Ab(Db)}};function Mb(){let[e,t]=(0,Z.useState)(br);return(0,Z.useEffect)(()=>Su(e=>t(e)),[]),e}function Nb({size:e=32,label:t=Rr()}){let n=jb[Mb()];return(0,Q.jsx)(`img`,{className:`logo`,src:Ob(e)?n.small:n.full,alt:t,width:e,height:e,style:{display:`block`,width:e,height:e,flex:`0 0 auto`}})}var Pb=400,Fb=2e3,Ib=et,Lb=400;function Rb(){let e=ls(e=>e.ops),[,t]=(0,Z.useState)(0),n=(0,Z.useRef)(!1),r=(0,Z.useRef)(!1),[i,a]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!e.length)return;let n=window.setInterval(()=>t(e=>e+1),500);return()=>window.clearInterval(n)},[e.length]),(0,Z.useEffect)(()=>{if(e.length){a(!1);return}if(!n.current)return;a(!0);let t=window.setTimeout(()=>{n.current=!1,r.current=!1,a(!1)},Lb);return()=>window.clearTimeout(t)},[e.length]);let o=e.length?e.reduce((e,t)=>e.started<=t.started?e:t):null,s=o?Date.now()-o.started:0;if(o&&s>=Pb&&(n.current=!0),o&&s>=Fb&&(r.current=!0),!n.current||!o&&!i)return null;let c=Math.floor(s/1e3),l=!!o&&s>=Ib;return(0,Q.jsxs)(`div`,{className:`net-activity${l?` stalled`:``}`,role:`status`,"aria-live":`polite`,children:[(0,Q.jsx)(`div`,{className:`net-bar`,children:(0,Q.jsx)(`span`,{})}),r.current&&o&&(0,Q.jsxs)(`div`,{className:`net-chip`,children:[l?(0,Q.jsx)(Kp,{size:12}):(0,Q.jsx)(om,{size:12,className:`spin`}),(0,Q.jsxs)(`span`,{children:[o.label,e.length>1?` +${e.length-1}`:``,` · `,c,`s`,l?` — the connection may be down`:``]})]})]})}var zb=16,Bb=`
|
|
160
|
-
tap for both windows, their reset times and the token history`,Vb=`
|
|
161
|
-
tap for its quota windows and the readings kept`,Hb=e=>e.source===`claude`;function Ub({f:e,size:t,gauge:n=!0}){return(0,Q.jsxs)(Q.Fragment,{children:[n&&(0,Q.jsx)(Wp,{size:t}),(0,Q.jsx)(`span`,{className:(e.sess??0)>=80?`usage-hot`:``,children:e.sess==null?`?`:`${e.sess}%`}),e.sessResetAt!=null&&(0,Q.jsxs)(`span`,{className:`usage-unit usage-reset`,children:[(0,Q.jsx)(Fp,{size:11}),` `,wc(e.sessResetAt)]}),(0,Q.jsx)(`span`,{className:`usage-sep`,children:`/`}),(0,Q.jsx)(`span`,{className:(e.wk??0)>=80?`usage-hot`:``,children:e.wk==null?`?`:`${e.wk}%`}),(0,Q.jsx)(`span`,{className:`usage-unit`,children:`wk`})]})}function Wb({seg:e,size:t,gauge:n=!0}){return(0,Q.jsxs)(Q.Fragment,{children:[n&&(0,Q.jsx)(Wp,{size:t}),(0,Q.jsx)(`span`,{className:`usage-label`,children:e.label}),(0,Q.jsx)(`span`,{className:e.hot?`usage-hot`:``,children:e.text}),e.unit&&(0,Q.jsx)(`span`,{className:`usage-unit`,children:e.unit})]})}function Gb(e,t,n=Date.now()){return`${Hb(e)&&t?bs(t):de(e.reading,n)}${Hb(e)?Bb:Vb}${qn(e.hidden)}`}function Kb({sessions:e}){let t=hr(),n=Ou(ra(),e),{segments:r}=ce(n,3),i=e=>{Y(`overlay:tokens`),ii(Er(e.source))},a=()=>{let e=Ir(t);return(0,Q.jsx)(K,{className:`usage-key${Ia(e)?` danger`:``}`,title:`${bs(t)}${Bb}`,onClick:()=>{Y(`overlay:tokens`),ii(null)},children:(0,Q.jsx)(Ub,{f:e,size:zb})},`claude`)};if(!r.length)return a();let o=qa(r,t),s=o||r.length>1,c=r.map((e,n)=>{let r=Hb(e)?ir(e.reading,t):null,a=!s||!o&&n===0;return(0,Q.jsx)(K,{className:`usage-key${s?` usage-seg`:``}${(r?Ia(r):e.hot)?` danger`:``}`,title:Gb(e,t),onClick:()=>i(e),children:r?(0,Q.jsx)(Ub,{f:r,size:zb,gauge:a}):(0,Q.jsx)(Wb,{seg:e,size:zb,gauge:a})},e.source)});return s?(0,Q.jsxs)(`div`,{className:`usage-multi`,children:[o&&a(),c]}):(0,Q.jsx)(Q.Fragment,{children:c})}function qb({backend:e}){let t=hr(),n=ra(),{segments:r}=ce(io(n,e),3),i=e=>{Y(`overlay:tokens`),ii(e?Er(e.source):null)},a=(e,t,n)=>(0,Q.jsxs)(qo,{className:`usage-inline${(e.sess??0)>=80?` danger`:``}`,title:t,onClick:()=>i(n),children:[(0,Q.jsx)(Wp,{size:11}),` sess `,e.sess==null?`?`:`${e.sess}%`,e.sessResetAt!=null&&(0,Q.jsxs)(Q.Fragment,{children:[` resets `,wc(e.sessResetAt)]}),` · `,`wk `,e.wk==null?`?`:`${e.wk}%`]},n?.source??`claude`);return r.length?(0,Q.jsx)(Q.Fragment,{children:r.map(e=>Hb(e)?a(ir(e.reading,t),Gb(e,t),e):(0,Q.jsxs)(qo,{className:`usage-inline${e.hot?` danger`:``}`,title:Gb(e,t),onClick:()=>i(e),children:[(0,Q.jsx)(Wp,{size:11}),` `,e.label,` `,e.text,e.unit?` ${e.unit}`:``]},e.source))}):a(Ir(t),`${bs(t)}${Bb}`,null)}var Jb=[`queued`,`blocked`,`starting`,`running`];function Yb(e){return Jb.includes(e.state)&&!e.archived}function Xb(e){let t=new Map;for(let n of e){if(n.trigger.kind!==`at`||n.target.kind!==`session`||!Yb(n))continue;let e=t.get(n.target.sessionId)??{ids:[],nextAt:null};e.ids.push(n.id),n.nextAt!=null&&(e.nextAt=e.nextAt==null?n.nextAt:Math.min(e.nextAt,n.nextAt)),t.set(n.target.sessionId,e)}return t}function Zb(e,t){return e.some(e=>t.has(e))}var Qb=ms(null),$b=ms(``),ex=ms(Zs()),tx=ms(as()),nx=ms(`home`),rx=ms([]),ix=ms(null),ax=ms(!1),ox=ms(!1),sx=ms(!1),cx=ms(null);ft(W.closeCustomH),ft(W.closeBy);var lx=ms(rt(W.closeKeepStar,!0)),ux={top:0};function dx(){sx.set(!0)}function fx(e){return[Yd(e),e.set]}function px(e){let{sessions:t,recent:n,closed:r,repos:i,intents:a,outbox:o,nowTick:s}=e,{hiddenRepoPaths:c,cwdInFocus:l,visibleRepos:u,hiddenRepos:d}=e.view,{focusRepo:f,setFocusRepo:p}=e.route,[m,h]=fx(Qb),[g,_]=fx($b),v=g.trim()!==``,[y,b]=fx(ex),[x,S]=fx(tx),[C,w]=fx(nx),[T,E]=fx(rx),[D,O]=fx(ix),[k,A]=fx(ax),[j,M]=fx(ox),[ee,N]=fx(sx),[P,F]=fx(cx),[I,te]=fx(lx),[L,R]=(0,Z.useState)(null),z=e=>my(i,e),re=e=>z(e.cwd),B=e=>hy(i,e),V=e=>gy(i,e),H=e=>_y(i,e),ie=e=>vy(i,e),ae=(0,Z.useMemo)(()=>t.filter(e=>!c.has(e.cwd)&&l(e.cwd)),[t,c,f,i]),oe=(0,Z.useMemo)(()=>t.filter(e=>c.has(e.cwd)&&l(e.cwd)),[t,c,f,i]),U=(0,Z.useMemo)(()=>wy(ae,x,B),[ae,x,i]);function se(e,t){h(n=>n&&n.status===e&&n.repo===t?null:(Y(`action:session.filter.${e}`),{status:e,repo:t}))}let ce=(e,t)=>!!m&&m.status===e&&m.repo===t,le=(0,Z.useMemo)(()=>Dy(U,m,(t,n)=>n===`worktrees`?z(t.cwd)?.isPrimary===!1:ea(t,n,e.backends),B).filter(e=>!v||Uy(g,[e.tabTitle,e.title,e.firstPrompt,e.lastPrompt,e.pinnedPrompt,B(e),H(e)])),[U,m,i,g,e.backends]),ue=(0,Z.useMemo)(()=>Oy(U,t=>tr(t,e.backends),B),[U,i,e.backends]),de=(0,Z.useMemo)(()=>ky(ue,`wait`),[ue]),fe=(0,Z.useMemo)(()=>Xb(a),[a]),pe=(0,Z.useMemo)(()=>{let t=new Map;for(let n of U)tr(n,e.backends)===`wait`&&fe.has(n.id)&&t.set(B(n),!0);return t},[U,fe,i,e.backends]),me=(0,Z.useMemo)(()=>Zb(U.filter(t=>tr(t,e.backends)===`wait`).map(e=>e.id),fe),[U,fe,e.backends]),he=(0,Z.useMemo)(()=>ky(ue,`limit`),[ue]),ge=(0,Z.useMemo)(()=>ky(ue,`coding`),[ue]),_e=(0,Z.useMemo)(()=>Ay(U,B),[U,i]),ve=(0,Z.useMemo)(()=>jy(U,B),[U,i]),ye=(0,Z.useMemo)(()=>[..._e.values()].reduce((e,t)=>e+t,0),[_e]),be=(0,Z.useMemo)(()=>Nr(U,B),[U,i]),xe=(0,Z.useMemo)(()=>Cr(be),[be]),Se=(0,Z.useMemo)(()=>U.filter(e=>e.shellList?.length).length,[U]),Ce=xf(),we=na(),Te=(0,Z.useMemo)(()=>Iy(o,a,Ce,e=>z(e)?.repoName??Ws(e)),[o,a,i,Ce]),Ee=(0,Z.useMemo)(()=>new Map(a.map(e=>[e.id,e])),[a]);function De(e){b(e),pt(bo,[...e])}function Oe(e){Y(`action:repo.collapse`);let t=new Set(y);t.has(e)?t.delete(e):t.add(e),De(t)}let ke=e=>i.find(t=>t.repoName===e&&t.isPrimary)??null,Ae=e=>u.filter(t=>t.repoName===e&&!t.isPrimary),je=q(`repoSort`),Me=(0,Z.useMemo)(()=>je===`sessions`?Py(U,B):void 0,[je,U,i]),Ne=(0,Z.useMemo)(()=>Fy(le,u,!!m||v,B,m?.status===`worktrees`&&m.repo?[m.repo]:v&&!m?u.filter(e=>Uy(g,[e.repoName,e.branch])).map(e=>e.repoName):[],Me),[le,u,m,i,g,Me]),Pe=Ne.length>0&&Ne.every(e=>y.has(e.repoName)),Fe=Ne.every(e=>!y.has(e.repoName)),Ie=(0,Z.useRef)(!1);function Le(e){let n=Ty(tx.get(),e,new Set(t.map(e=>e.id)));S(n),pt(zi,n)}function Re(){S([]),ft(zi)}function ze(e,t){if(e.pointerType===`mouse`&&e.button!==0)return;Ie.current=!1;let n=e.clientX,r=e.clientY,i=window.setTimeout(()=>{i=void 0,s(),Ie.current=!0,R(t),navigator.vibrate?.(15),Y(`action:session.reorder`)},400),a=e=>{Math.hypot(e.clientX-n,e.clientY-r)>10&&o()},o=()=>{i&&clearTimeout(i),s()},s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),window.removeEventListener(`scroll`,o,!0)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),window.addEventListener(`scroll`,o,!0)}(0,Z.useEffect)(()=>{if(!L)return;let e=e=>{let t=(document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-sid]`))?.getAttribute(`data-sid`),n=t?Ey(U,L,t,B):null;n&&Le(n)},t=e=>e.preventDefault(),n=()=>R(null);return window.addEventListener(`pointermove`,e),window.addEventListener(`touchmove`,t,{passive:!1}),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`touchmove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n)}},[L,U]),(0,Z.useEffect)(()=>{C===`external`&&Gd.external().then(E).catch(()=>E([]))},[C,e.conn.status]);let Be=(0,Z.useMemo)(()=>T.filter(e=>l(e.cwd)),[T,f,i]);function Ve(e){ws()?p(e):window.open(`${location.pathname}?repo=${encodeURIComponent(e)}`,`_blank`)}function He(){p(null)}let Ue=Jd(a,o,s),Ge=Ue.horizon,Ke=Qe(Ge),qe=(0,Z.useMemo)(()=>xi({cuts:Ue,repoOf:e=>z(e)?.repoName??(Ws(e)||null),now:Date.now()}),[Ue,i,s]),Je=ne(Ge),Ye=Ge.unarmed>0&&Ge.unarmed===Ge.total,Xe=Ue.kinds,Ze=[Xe.rules?`${Xe.rules} rule${Xe.rules===1?``:`s`}`:``,Xe.timed?`${Xe.timed} on a clock in a backlog`:``].filter(Boolean).join(` · `),$e=Ke?`schedules · ${Ze} — ${Ke}${Ge.unarmed&&!Ye?` · ${Ge.unarmed} not armed`:``} — tap to see the ${Je?We[Je]:``} ones`:`schedules — run a prompt on its own at a time you pick (once, every week, or around a usage window)`,et=o.filter(e=>(e.status===`queued`||e.status===`failed`)&&!Ce.has(`queue:${e.ackId}`)&&!we.has(`queue:${e.ackId}`)).length,tt=$o(),nt=yt(Oi(tt,An())),rt=Ec(uu(kl(tt),[],rc)).length,it=new Set(t.map(e=>e.cwd)),at=new Set(t.map(Ut).filter(Boolean)),ot=e=>{let t=Ut(e);return t?at.has(t):it.has(e.cwd)},st=n.filter(e=>!ot(e)&&c.has(e.cwd)&&l(e.cwd));return{statusFilter:m,setStatusFilter:h,toggleStatusFilter:se,statusFilterActive:ce,textQuery:g,setTextQuery:_,textOn:v,collapsedRepos:y,persistCollapsedRepos:De,toggleRepoCollapsed:Oe,sessionOrder:x,saveSessionOrder:Le,resetSessionOrder:Re,dragSid:L,dragRef:Ie,armRowDrag:ze,tab:C,setTab:w,repoMenu:D,setRepoMenu:O,navMenu:k,setNavMenu:A,showHidden:j,setShowHidden:M,shotPick:ee,setShotPick:N,closeAllPick:P,setCloseAllPick:F,closeKeepStar:I,setCloseKeepStar:te,repoForCwd:z,sessionRepo:re,sessionRepoName:B,sessionRepoLabel:V,sessionRowBranch:H,sessionRowTitle:ie,visibleSessions:ae,hiddenSessions:oe,sortedSessions:U,shownSessions:le,repoGroups:Ne,allReposCollapsed:Pe,noRepoCollapsed:Fe,primaryRepo:ke,worktreesOf:Ae,attentionByRepo:ue,waitingTotal:de,repliesBySession:fe,waitingRepliesByRepo:pe,waitingRepliesTotal:me,limitTotal:he,codingTotal:ge,starredByRepo:_e,starredTotal:ye,flaggedByRepo:be,flaggedTotal:xe,sessionNumbers:ve,shellsTotal:Se,queuedByRepo:Te,intentById:Ee,visibleExternal:Be,openFocusWindow:Ve,clearFocus:He,scheduleWords:Ke,scheduleLead:Je,scheduleTitle:$e,clocksPerRepo:qe,activityBadge:et,dl:nt,appsReady:rt,visibleRecent:n.filter(e=>!ot(e)&&!c.has(e.cwd)&&l(e.cwd)),hiddenRecent:st,reopenable:r.filter(e=>!ot(e)&&l(e.cwd)),hiddenCount:d.length+oe.length+st.length}}function mx(e,t,n,r=null){let i=tr(e,r),a=(e,r,a)=>{let o=n?`${e} tag-fresh`:e,s=n?`something new since you last looked${r?` · `:``}${r}`:r,c=n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Af,{size:11,fill:`currentColor`}),` `,a]}):a;if(!t)return(0,Q.jsx)(lf,{className:o,title:s,children:c});let l=t.isOn(i);return(0,Q.jsx)(lf,{className:`${o} tag-filter${l?` on`:``}`,role:`button`,tabIndex:0,title:`${s}${s?` · `:``}${l?`showing only these — tap to clear the filter`:`tap to show only the ${fi[i]} sessions`}`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t.toggle(i))},onClick:e=>{e.stopPropagation(),t.toggle(i)},children:c})},o=to(e,r);return a(o.cls,o.title,o.body)}function hx(e,t){let n=e.limit;return!n||n.blocked||!e.running||n.autoContinue===t?null:n.autoContinue?(0,Q.jsxs)(lf,{className:`limit-on`,title:`set for this session: auto-continue after a usage-limit reset is ON here — the global setting is off`,children:[(0,Q.jsx)(Zf,{size:12}),` auto`]}):(0,Q.jsxs)(lf,{className:`limit-off`,title:`set for this session: auto-continue after a usage-limit reset is OFF here — the global setting is on, so a hit limit waits for you in this session only`,children:[(0,Q.jsx)(Zf,{size:12}),` no auto`]})}function gx(e){let t=Pn(e);return t&&(0,Q.jsx)(lf,{className:t.cls,title:t.title,children:t.body})}function _x(e){let t=Wa(e);return t&&(0,Q.jsx)(lf,{className:t.cls,title:t.title,children:t.body})}function vx(e){let t=e.contextSpark,n=e.running?ie(t?.liveAgentTok,t?.liveAgentAt,Date.now(),Cs()):null;return!n||t?.liveAgentTok==null?null:(0,Q.jsxs)(lf,{className:`cost-heavy`,title:`${n}\n\nTap the context readout for the whole picture. Nothing here stops it.`,children:[(0,Q.jsx)(bp,{size:12}),` `,t.liveAgentType?`${t.liveAgentType} `:`agent `,`re-reads `,R(t.liveAgentTok)]})}function yx(e,t){let n=e.shellList;if(!n?.length)return null;let r=ye(n,Date.now()),i=r.working>0?`coding`:`idle`;return(0,Q.jsxs)(lf,{className:`${i} tag-filter`,role:`button`,tabIndex:0,title:`tap to see what each background shell is doing`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())},onClick:e=>{e.stopPropagation(),t()},children:[(0,Q.jsx)(op,{size:12}),` `,_(r)]})}var bx=e=>e?.contextSpark?.turns||null,xx=e=>e==null?``:` · ${e} turn${e===1?``:`s`} logged so far`;function Sx(e,t){let n=Ba(e,Date.now());return n?(0,Q.jsxs)(lf,{className:`${n.cls} tag-filter`,role:`button`,tabIndex:0,title:n.title,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())},onClick:e=>{e.stopPropagation(),t()},children:[(0,Q.jsx)(Pm,{size:12}),` `,n.text]}):null}async function Cx(e,t){let n=await Xa({title:`Name this session`,initial:Te(e),placeholder:`what this session is about`,note:`Shown on the tab, the row and the header — up to 4 words, 30 characters.`});if(!n)return;let r=Ae(n);if(!r){G(`that name was not kept — one word longer than the tab, or an ellipsis in it`);return}Y(`action:session.rename`);let i=r===n.trim()?``:` (shortened to fit the tab)`;t({t:`session.rename`,id:e.id,title:r},`named “${r}”${i}`,`no connection — the name lives on the desktop and was not changed`)}var wx=`Flag for follow up`,Tx=`Done — clear flag`,Ex=e=>e?` fu-${e.by}`:``;function Dx(e,t,n){if(t){let t=e.followUp?`flagged here`:`flag cleared here`;return n?`${t} — the desktop has not confirmed it yet`:`${t} — offline, so it is only on this phone until the link is back`}return e.followUp?`${Tx} — ${v(e.followUp)}`:`${wx} — a one-shot mark; opening the session does not clear it`}var Ox=({on:e,size:t})=>(0,Q.jsx)(Sm,{size:t,fill:e?`currentColor`:`none`});function kx({f:e}){return(0,Q.jsxs)(`span`,{className:`fu-line${Ex(e)}`,children:[(0,Q.jsx)(Sm,{size:12,fill:`currentColor`}),` `,v(e)]})}var Ax=16,jx=(e,t)=>e?(0,Q.jsxs)(Q.Fragment,{children:[e.outboxCount>0&&(0,Q.jsxs)(`button`,{className:`row-act count`,title:`${e.outboxCount} new outbox file${e.outboxCount>1?`s`:``} since last opened — open gallery`,onClick:()=>wi(e.id),children:[(0,Q.jsx)(cp,{size:14}),e.outboxCount]}),wd(e)&&(0,Q.jsxs)(`button`,{className:`row-act count`,title:us(e),onClick:()=>t(e.id),children:[(0,Q.jsx)(sm,{size:14}),e.changedCount>0&&e.changedCount,nf(e)&&(0,Q.jsx)(`span`,{className:`git-ab`,children:nf(e)})]})]}):null;function Mx({p:e,m:t,s:n,repoName:r}){let i=oh()(n),{backends:a,openGitFor:o}=e,{status:s,liveSend:c}=e.conn,{lastVisitedId:l}=e.route,{attach:u,openReader:d}=e.term,{sessionCan:f}=e.launchCore,{pendingStars:p,toggleStar:m,pendingFollowUps:h,toggleFollowUp:g,closeSession:_}=e.verbs,{dragSid:v,dragRef:y,armRowDrag:b,sessionRowBranch:x,sessionRepoName:S,sessionRepoLabel:C,sessionRowTitle:w,sessionRepo:T,repliesBySession:E,sessionNumbers:D}=t,O=qt(),k={isOn:e=>t.statusFilterActive(e),toggle:e=>t.toggleStatusFilter(e)},A=C(n),j=(()=>{let e=Fo(n);return!!(e.first||e.now)})(),M=j?``:n.title&&n.title!==A&&n.title!==r?n.title:``;return(0,Q.jsxs)(`div`,{className:`row-wrap${n.id===l?` row-recent`:``}${n.id===v?` row-dragging`:``}`,style:pf(r),"data-sid":n.id,children:[(0,Q.jsxs)(`button`,{className:`row grow${n.id===v?` dragging`:``}`,"data-nohint":!0,title:`tap to open · press and hold to drag into a new position`,onPointerDown:e=>b(e,n.id),onContextMenu:e=>e.preventDefault(),onClick:()=>{y.current||u(n)},children:[(0,Q.jsxs)(`span`,{className:`row-head`,children:[D.has(n.id)&&(0,Q.jsx)(`span`,{className:`row-num`,title:`open session ${D.get(n.id)} in ${r}`,children:D.get(n.id)}),x(n)&&(0,Q.jsx)(Ad,{children:x(n)}),Te(n)?(0,Q.jsx)(Gt,{s:n}):!x(n)&&(0,Q.jsx)(Ad,{children:S(n)}),(0,Q.jsxs)(`span`,{className:`row-meta`,children:[(0,Q.jsx)(qo,{className:`row-launch${Ni(a,n.backend)?` row-foreign`:``}`,children:Wr(Wn(n),Ni(a,n.backend),a)}),n.createdAt&&n.running&&(0,Q.jsxs)(qo,{title:`session open for ${yu(n.createdAt)}`,children:[(0,Q.jsx)(Fp,{size:11}),` `,yu(n.createdAt)]})]})]}),(0,Q.jsxs)(`span`,{className:`row-gist`,children:[j?(0,Q.jsx)(po,{firstPrompt:n.firstPrompt,lastPrompt:n.lastPrompt,pinnedPrompt:n.pinnedPrompt}):M&&(0,Q.jsx)(`span`,{className:`row-summary`,children:M}),n.followUp&&(0,Q.jsx)(kx,{f:n.followUp})]})]}),(0,Q.jsxs)(`div`,{className:`row-acts`,children:[(0,Q.jsx)(`span`,{className:`row-stat`,children:mx(n,k,n.starred&&n.newActivity,a)}),(0,Q.jsxs)(`span`,{className:`row-tags`,children:[n.remoteControlled&&(0,Q.jsxs)(lf,{className:`rc-tag`,title:`a desktop is driving this session`,children:[(0,Q.jsx)(Wm,{size:12}),` RC`]}),(()=>{let e=E.get(n.id);if(!e)return null;let t=e.ids.length,r=e.nextAt==null?`when its window opens`:fe(e.nextAt),i=()=>{Y(`action:session.scheduled.open`),ho(n.cwd,e.ids,`scheduled for ${n.title}`)};return(0,Q.jsxs)(lf,{className:`sched tag-filter`,role:`button`,tabIndex:0,title:`${t} prompt${t>1?`s`:``} on a clock for this session — next ${r}; tap to open ${t>1?`them`:`it`}`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),i())},onClick:e=>{e.stopPropagation(),i()},children:[(0,Q.jsx)(Rm,{size:12}),` `,t>1?`${t} · `:``,r]})})(),(0,Q.jsx)(Yi,{s:n}),(0,Q.jsx)(sr,{s:n}),yx(n,()=>Di(n)),hx(n,O),(0,Q.jsx)(Xs,{s:n}),(0,Q.jsx)(os,{sessionId:n.id}),jx(T(n),o)]}),(()=>{let e=Sx(n,()=>Za(n.id)),t=gx(n),r=f(n,`transcript`);return(e||t||r||n.contextSpark)&&(0,Q.jsxs)(`span`,{className:`row-side`,children:[r&&(()=>{let e=bx(n);return(0,Q.jsxs)(`button`,{className:`row-act${e==null?``:` tally`}`,title:`outline — where this session got to, without opening the terminal${xx(e)}`,onClick:()=>d(n),children:[(0,Q.jsx)(Jp,{size:Ax}),e??null]})})(),(e||t)&&(0,Q.jsxs)(`span`,{className:`row-side-top`,children:[t,e]}),n.contextSpark&&(0,Q.jsxs)(`span`,{className:`row-spark tappable`,role:`button`,tabIndex:0,"aria-label":`what this session has cost — open the context graph for ${w(n)}`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Cc(n))},onClick:e=>{e.stopPropagation(),Cc(n)},children:[_x(n),vx(n),(0,Q.jsx)(Xo,{spark:n.contextSpark,value:!0}),(0,Q.jsx)(Nd,{spark:n.contextSpark,warn:i})]})]})})(),(0,Q.jsxs)(`span`,{className:`row-ctl`,children:[(0,Q.jsx)(`button`,{className:`row-act${n.starred?` starred`:``}${n.id in p?` star-pending`:``}`,"data-hint":`session.star`,title:n.id in p?s===`open`?`starred here — the desktop has not confirmed it yet`:`starred here — offline, so it is only on this phone until the link is back`:n.starred?`unstar (prima interest)`:`star — mark as prima interest to come back to`,onClick:()=>m(n.id,!n.starred),children:(0,Q.jsx)(Af,{size:Ax,fill:n.starred?`currentColor`:`none`})}),(0,Q.jsx)(`button`,{className:`row-act fu-btn${Ex(n.followUp)}${n.id in h?` star-pending`:``}`,"data-hint":`session.followup`,"aria-pressed":!!n.followUp,title:Dx(n,n.id in h,s===`open`),onClick:()=>g(n.id,!n.followUp),children:(0,Q.jsx)(Ox,{on:!!n.followUp,size:Ax})}),(0,Q.jsx)(`button`,{className:`row-act`,title:`name this session`,onClick:()=>{Cx(n,c)},children:(0,Q.jsx)(lp,{size:Ax})}),(0,Q.jsx)(`button`,{className:`row-act danger`,title:n.running?`close`:`remove`,onClick:()=>_(n),children:(0,Q.jsx)(X,{size:Ax})})]})]})]})}function Nx({def:e,repo:t}){let n=e.useCount(t);if(!n||!(n.n>0))return null;let r=e.icon;return(0,Q.jsxs)(`button`,{className:`repo-group-stat`,title:n.title,onClick:()=>{Y(`action:repo.chip.${e.id}`),e.open(t,n.filter,$t())},children:[(0,Q.jsx)(r,{size:12}),n.label?`${n.label} `:``,n.n]})}function Px(e){let[t,n]=(0,Z.useState)(new Map),[r,i]=(0,Z.useState)(0),a=e.join(`,`);return(0,Z.useEffect)(()=>{if(!e.length)return;let t=!0;n(new Map(e.map(e=>[e,{state:`loading`}])));for(let r of e)Gd.worktreeLeftover(r).then(e=>{t&&n(t=>new Map(t).set(r,{state:`ok`,v:e}))},e=>{t&&n(t=>new Map(t).set(r,{state:`error`,error:e instanceof Error?e.message:String(e)}))});return()=>{t=!1}},[a,r]),{readings:t,recheck:(0,Z.useCallback)(()=>i(e=>e+1),[])}}var Fx=e=>e?.state===`ok`&&e.v.blockers.length===0;async function Ix(e,t){let n=0,r=[],i=[];for(let t of e)try{let e=await Gd.removeWorktree(t.id);e.ok?(n++,e.note&&i.push(e.note)):r.push(`${t.branch}: ${e.error??`refused`}`)}catch(e){r.push(`${t.branch}: ${e instanceof Error?e.message:String(e)}`)}let a=n?`Removed ${n} worktree${n===1?``:`s`} and ${n===1?`its branch`:`their branches`}.`:`Nothing removed.`;G([a,...i,...r.length?[`Kept ${r.join(`; `)}`]:[]].join(` `)),t()}function Lx({wts:e,readings:t,onChanged:n}){let[r,i]=(0,Z.useState)(!1);if(!e.length)return null;let a=e.length,o=e.filter(e=>Fx(t.get(e.id))),s=e.some(e=>t.get(e.id)?.state===`loading`),c=a-o.length;return(0,Q.jsxs)(`div`,{className:`wt-leftover-head`,children:[(0,Q.jsxs)(qo,{as:`div`,children:[`No session is using `,a===1?`this worktree`:`these ${a} worktrees`,`. A worktree is a second checkout of the repo, usually made for an agent; `,a===1?`it`:`they`,` outlived the session that made `,a===1?`it`:`them`,`.`,s?` Checking what is in them…`:o.length===a?` Every commit in ${a===1?`it`:`them`} is already on ${Rx(o,t)}, and nothing is uncommitted — removing loses nothing.`:o.length?` ${o.length} hold nothing that is not on ${Rx(o,t)}; ${c} hold work, said on ${c===1?`its`:`their`} row.`:` ${a===1?`It holds`:`Each holds`} work that is not anywhere else, said on the row — open it to commit or keep it.`]}),o.length>0&&(r?(0,Q.jsx)(qo,{children:`removing…`}):(0,Q.jsxs)(As,{className:`key wt-leftover-go`,confirm:`remove ${o.length} for good?`,onConfirm:()=>{Y(`action:repo.worktree.removeLeftovers`),i(!0),Ix(o,()=>{i(!1),n()})},children:[(0,Q.jsx)(Yp,{size:14}),`remove `,o.length===a?a===1?`it`:`all ${a}`:`the ${o.length} safe`]}))]})}function Rx(e,t){for(let n of e){let e=t.get(n.id);if(e?.state===`ok`&&e.v.base)return e.v.base}return`the main branch`}function zx({r:e}){return!e||e.state===`loading`?(0,Q.jsx)(qo,{className:`wt-leftover`,children:`checking what is in it…`}):e.state===`error`?(0,Q.jsxs)(qo,{className:`wt-leftover warn`,children:[(0,Q.jsx)(Kp,{size:12}),`could not check it: `,e.error]}):e.v.blockers.length?(0,Q.jsxs)(qo,{className:`wt-leftover warn`,children:[(0,Q.jsx)(Kp,{size:12}),`keep: `,e.v.blockers.join(` `)]}):(0,Q.jsxs)(qo,{className:`wt-leftover ok`,children:[(0,Q.jsx)(Om,{size:12}),`nothing only here — `,e.v.ahead?`its ${e.v.ahead} commit${e.v.ahead===1?` is`:`s are`} on ${e.v.base} as cherry-picks`:`all on ${e.v.base}`]})}function Bx({t:e,r:t,onChanged:n}){return Fx(t)?(0,Q.jsxs)(As,{className:`more-act`,confirm:`remove for good?`,onConfirm:()=>{Y(`action:repo.worktree.remove`),Ix([e],n)},children:[(0,Q.jsx)(Yp,{size:16}),`remove worktree`]}):null}var Vx=16;function Hx({p:e,m:t,repoName:n,sessions:r}){let{intents:i,openGitFor:a}=e,{focusRepo:o,setOverlay:s}=e.route,{toggleHideRepo:c,openingCwds:l}=e.view,{openRepo:u,openShell:d,setBranchPick:f,refreshRepos:p}=e.launchCore,m=!!Jl(e.backends),{enterOldestPending:h,enterLater:g}=e.queue,{primaryRepo:_,worktreesOf:v,attentionByRepo:y,statusFilter:b,textOn:x,collapsedRepos:S,toggleRepoCollapsed:C,openFocusWindow:w,statusFilterActive:T,toggleStatusFilter:E,waitingRepliesByRepo:D,queuedByRepo:k,intentById:A,clocksPerRepo:j,starredByRepo:M,flaggedByRepo:ee,repoMenu:N,setRepoMenu:P,setCloseAllPick:F}=t,I=r.length,L=_(n),R=v(n),z=R.length,ne=R.filter(e=>!e.ownerSessionId),{readings:re,recheck:B}=Px(ne.map(e=>e.id)),V=()=>{p(),B()},H=y.get(n)??{wait:0,limit:0,coding:0,done:0,exited:0},ie=I+z===0,[ae,oe]=(0,Z.useState)(!1),U=ie?!ae:!b&&!x&&S.has(n),se=(0,Z.useRef)(null),ce=(0,Z.useRef)(null),le=(0,Z.useRef)(!1);(0,Z.useLayoutEffect)(()=>{if(!le.current)return;le.current=!1;let e=se.current,t=e?.closest(`.list`);if(!e||!t)return;let n=t.getBoundingClientRect().top,r=ce.current;if(!U&&r&&Fs(`unfoldToEnd`).current){let e=r.getBoundingClientRect().top-n;e>t.clientHeight&&t.scrollTo({top:t.scrollTop+e-t.clientHeight,behavior:`smooth`});return}let i=e.getBoundingClientRect().top-n+t.scrollTop;t.scrollTo({top:i,behavior:`smooth`})},[U]);let ue=(0,Q.jsxs)(`div`,{className:`section repo-group${ie?` idle`:``}`,style:pf(n),children:[(0,Q.jsxs)(`div`,{className:`repo-group-line`,children:[(0,Q.jsxs)(`button`,{className:`repo-group-toggle`,title:ie?`${U?`show`:`hide`} — no session open in ${n}`:U?`show ${I} session${I===1?``:`s`}${z>0?` and ${z} worktree${z===1?``:`s`}`:``}`:`hide ${I} session${I===1?``:`s`}${z>0?` and ${z} worktree${z===1?``:`s`}`:``}`,onClick:()=>{le.current=!0,ie?(Y(`action:repo.collapse`),oe(e=>!e)):C(n)},children:[U?(0,Q.jsx)(nm,{size:17}):(0,Q.jsx)(wm,{size:17}),(0,Q.jsx)(`span`,{children:n})]}),(0,Q.jsxs)(`span`,{className:`repo-group-acts`,children:[L&&(0,Q.jsxs)(`button`,{className:`focus-btn${L.outboxCount>0?` count`:``}`,title:L.outboxCount>0?`${L.outboxCount} new outbox file${L.outboxCount>1?`s`:``} since last opened — open files`:`files in ${n}`,onClick:()=>{Y(`action:repo.files.header`),L.outboxCount>0?wi(L.id):Tn(L.id)},children:[(0,Q.jsx)(cp,{size:15}),L.outboxCount>0&&L.outboxCount]}),L&&(0,Q.jsxs)(`button`,{className:`focus-btn${wd(L)?` count`:``}`,title:L.gitRunning?`${L.gitRunning===`push`?`a push`:`a pull`} is running on the desktop — open git to follow it`:us(L),onClick:()=>a(L.id),children:[L.gitRunning?(0,Q.jsx)(um,{size:13,className:`spin`}):(0,Q.jsx)(sm,{size:13}),L.changedCount>0&&L.changedCount,nf(L)&&(0,Q.jsx)(`span`,{className:`git-ab`,children:nf(L)}),Kd(L)&&(0,Q.jsxs)(`span`,{className:`git-ab no-origin`,children:[(0,Q.jsx)(Xf,{size:12}),`no remote`]})]}),L&&(0,Q.jsx)(Ux,{repo:L,repoName:n})]})]}),(0,Q.jsxs)(`span`,{className:`repo-group-pin`,children:[(0,Q.jsx)(`button`,{className:`focus-btn${N===n?` on`:``}`,"aria-label":`more actions`,"aria-expanded":N===n,title:`more actions`,onClick:()=>{Y(`action:repo.more`),P(e=>e===n?null:n)},children:(0,Q.jsx)(Tp,{size:17})}),I>0&&(0,Q.jsx)(`button`,{className:`focus-btn danger`,title:`close sessions in ${n} — review the ${I} here, cut by state, idle time, or what is still running underneath`,onClick:()=>F(n),children:(0,Q.jsx)(X,{size:18})})]}),(0,Q.jsxs)(`span`,{className:`repo-group-stats`,children:[L&&(()=>{let e=l.get(L.worktreePath);return(0,Q.jsxs)(`span`,{className:`repo-start`,children:[(0,Q.jsxs)(`button`,{className:`repo-start-btn${ie&&!U?` lead`:``}`,title:e?`new session in ${n} · ${L.branch}, another one now — ${by(e)}`:`new session in ${n} · ${L.branch}, opened now`,onClick:()=>{Y(`action:repo.new.header`),u(L)},children:[(0,Q.jsx)(pp,{size:15}),`now`]}),(0,Q.jsxs)(`button`,{className:`repo-start-btn`,title:`words for a new session in ${n} — held until the repo is free, or on a clock you pick`,onClick:()=>{Y(`action:repo.send`),g(L.worktreePath)},children:[(0,Q.jsx)(pp,{size:15}),`later`]})]})})(),I===0&&L&&Re(L)&&(0,Q.jsx)(`span`,{className:`repo-group-branch`,title:`${te(L)} — nothing running`,children:Re(L)}),z>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat wt${T(`worktrees`,n)?` on`:``}`,title:`${z} open worktree${z>1?`s`:``} in ${n} — tap to show only those`,onClick:()=>E(`worktrees`,n),children:[(0,Q.jsx)(Vp,{size:13}),z]}),(()=>{let e=L?vu(L.healthIndex,n,O(new Date().toISOString().slice(0,10))):null;if(!L||!e)return null;let t=e.arrow===`down`?kp:e.arrow===`up`?Uf:e.arrow===`flat`?Rp:null;return(0,Q.jsxs)(`button`,{className:`repo-group-stat health${e.tone?` ${e.tone}`:``}`,title:e.title,onClick:()=>{Y(`action:repo.healthindex`),Yl(L)},children:[(0,Q.jsx)(_p,{size:13}),e.label,t?(0,Q.jsx)(t,{size:12}):null,e.delta]})})(),L?.setup&&L.setup.issues>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat ${L.setup.ok?`warn`:`bad`}`,title:xy(L.setup),onClick:()=>{Y(`action:repo.setup`),Vu(L.id,{focus:`findings`})},children:[(0,Q.jsx)(xp,{size:13}),L.setup.issues]}),(()=>{let e=L&&l.get(L.worktreePath);return e?(0,Q.jsxs)(`button`,{className:`repo-group-stat`,title:`${by(e)} — open its screen`,onClick:()=>{Y(`action:repo.pending.open`),h(L.worktreePath)},children:[(0,Q.jsx)(um,{size:12,className:`spin`}),yy(e)]}):null})(),H.limit>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat limit${T(`limit`,n)?` on`:``}`,title:`${H.limit} session${H.limit>1?`s`:``} in ${n} blocked on a usage limit — tap to show only those`,onClick:()=>E(`limit`,n),children:[(0,Q.jsx)(Zf,{size:13}),H.limit]}),H.wait>0&&(0,Q.jsxs)(`button`,{className:`repo-group-wait${T(`wait`,n)?` on`:``}`,title:`${H.wait} session${H.wait>1?`s`:``} in ${n} waiting for your answer${D.get(n)?` — some already have a reply on a clock`:``} — tap to show only those`,onClick:()=>E(`wait`,n),children:[(0,Q.jsx)(em,{size:13}),H.wait,` waiting`,D.get(n)&&(0,Q.jsx)(Rm,{size:11,className:`wait-sched`})]}),H.coding>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat coding${T(`coding`,n)?` on`:``}`,title:`${H.coding} session${H.coding>1?`s`:``} in ${n} working — tap to show only those`,onClick:()=>E(`coding`,n),children:[(0,Q.jsx)(um,{size:13,className:`spin`}),H.coding]}),H.done>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat done${T(`done`,n)?` on`:``}`,title:`${H.done} session${H.done>1?`s`:``} in ${n} idle — turn finished; tap to show only those`,onClick:()=>E(`done`,n),children:[(0,Q.jsx)(bm,{size:13}),H.done]}),H.exited>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat exited${T(`exited`,n)?` on`:``}`,title:`${H.exited} exited session${H.exited>1?`s`:``} in ${n} — tap to show only those`,onClick:()=>E(`exited`,n),children:[(0,Q.jsx)(Hp,{size:11}),H.exited]}),(k.get(n)?.length??0)>0&&(()=>{let e=k.get(n)??[],t=e.length,r=new Set(e),a=Date.now(),o=i.filter(e=>r.has(Mn(e.id))&&Ha(e,a,A)).length;return(0,Q.jsxs)(`button`,{className:`repo-group-stat queued`,title:`${t} command${t>1?`s`:``} waiting to run in ${n} — on this phone or held by the desktop${o?`; ${o} held by the usage budget`:``}. Tap to show only those.`,onClick:()=>{let r=Ly(e,i);r.kind===`backlog`?(Y(`action:repo.queued.backlog`),ho(r.cwd,r.ids,`the ${t} waiting in ${n}`)):(Y(`action:repo.queued.open`),mr({keys:e,label:`the ${t} waiting in ${n}`}))},children:[(0,Q.jsx)(Zf,{size:12}),t,Qt(t,o)]})})(),(j.get(n)?.ids.length??0)>0&&(()=>{let e=j.get(n),t=e.ids.length,r=Qe(e.horizon);return(0,Q.jsxs)(`button`,{className:`repo-group-stat`,title:`${t} thing${t>1?`s`:``} on a clock in ${n}${r?` — ${r}`:``}. Tap to show only those.`,onClick:()=>{Y(`action:repo.clocks.open`),of(e.ids,cl(n,t))},children:[(0,Q.jsx)(Rm,{size:12}),t]})})(),L&&B_().map(e=>(0,Q.jsx)(q_,{feature:e.feature,what:`its ${e.def.id} chip`,children:(0,Q.jsx)(Nx,{def:e.def,repo:L})},e.key)),(M.get(n)??0)>0&&(()=>{let e=M.get(n)??0;return(0,Q.jsxs)(`button`,{className:`repo-group-stat starred${T(`starred`,n)?` on`:``}`,title:`${e} starred session${e>1?`s`:``} in ${n} — tap to show only those`,onClick:()=>E(`starred`,n),children:[(0,Q.jsx)(Af,{size:12,fill:`currentColor`}),e]})})(),(()=>{let e=ee.get(n);return e?(0,Q.jsxs)(`button`,{className:`repo-group-stat fu-${e.tone}${T(`followup`,n)?` on`:``}`,"data-hint":`session.followup`,title:Tu(e.n,n),onClick:()=>E(`followup`,n),children:[(0,Q.jsx)(Sm,{size:12,fill:`currentColor`}),e.n]}):null})()]}),N===n&&(0,Q.jsxs)(`div`,{className:`row-more`,children:[L&&m&&(0,Q.jsxs)(`button`,{className:`more-act`,title:`a plain terminal on the desktop in this repo — no agent`,onClick:()=>{P(null),d(L)},children:[(0,Q.jsx)(Rf,{size:Vx}),`open a shell here`]}),!o&&(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`repo.focus`,onClick:()=>{Y(`action:repo.focus`),P(null),w(n)},children:[(0,Q.jsx)(If,{size:Vx}),ws()?`focus this repo`:`focus window`]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{Y(`action:repo.browse`),P(null),wa(L.id)},children:[(0,Q.jsx)(Nm,{size:Vx}),`browse files`]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{Y(`action:repo.backlog`),P(null),Lo(L)},children:[(0,Q.jsx)(zm,{size:Vx}),`backlog`]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{Y(`action:repo.assess`),P(null),Eo(L)},children:[(0,Q.jsx)(rp,{size:Vx}),`what is left`]}),L&&P_(L).map(e=>(0,Q.jsx)(q_,{feature:e.feature,what:`its ${e.id} action`,children:(0,Q.jsxs)(`button`,{className:`more-act`,title:e.title,onClick:()=>{Y(`action:repo.ext.${e.id}`),P(null),e.run()},children:[(0,Q.jsx)(e.icon,{size:Vx}),e.label]})},e.key)),L&&(0,Q.jsxs)(`button`,{className:`more-act`,title:Cy(L.setup),onClick:()=>{Y(`action:repo.setup`),P(null),Vu(L.id)},children:[(0,Q.jsx)(xp,{size:Vx}),Sy(L.setup)]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,title:`what this repo downloads to this phone by itself`,onClick:()=>{Y(`action:repo.pullrules`),P(null),Rc(L.worktreePath)},children:[(0,Q.jsx)(Hf,{size:Vx}),`download rules`]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{Y(`action:repo.branch`),P(null),f(L),s(`branches`)},children:[(0,Q.jsx)(Vp,{size:Vx}),`branch`]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`repo.hide`,onClick:()=>{Y(`action:repo.hide`),P(null),c(L.id)},children:[(0,Q.jsx)(Sp,{size:Vx}),`hide`]}),L&&(0,Q.jsx)(El,{repo:L,onOpen:()=>{P(null),Yl(L)}}),L&&(0,Q.jsx)(js,{onOpen:()=>{Y(`action:repo.optins`),P(null),Vu(L.id,{region:`optins`})}})]})]}),de=new Set(r.map(e=>e.id)),fe=e=>R.filter(t=>t.ownerSessionId===e),pe=R.filter(e=>!e.ownerSessionId||!de.has(e.ownerSessionId)),me=e=>(0,Q.jsxs)(`div`,{className:`row-wrap repo-row row-wt${e.ownerSessionId&&de.has(e.ownerSessionId)?` row-wt-owned`:``}`,style:pf(n),children:[(0,Q.jsxs)(`div`,{className:`row grow repo-main`,role:`button`,tabIndex:0,onClick:()=>u(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),u(e))},children:[(0,Q.jsx)(Ad,{children:(0,Q.jsx)(`span`,{className:`wt-branch`,children:e.branch.replace(/^worktree-/,``)})}),(0,Q.jsxs)(qo,{className:`repo-sub`,children:[(0,Q.jsxs)(`span`,{className:`repo-branch wt-of`,children:[(0,Q.jsx)(Vp,{size:12}),`worktree of `,(0,Q.jsx)(`b`,{children:n})]}),(()=>{let t=l.get(e.worktreePath);return t?(0,Q.jsxs)(`button`,{className:`row-chip`,title:`${by(t)} — open its screen`,onClick:t=>{t.stopPropagation(),Y(`action:repo.pending.open`),h(e.worktreePath)},children:[(0,Q.jsx)(um,{size:12,className:`spin`}),yy(t)]}):null})(),e.outboxCount>0&&(0,Q.jsxs)(`button`,{className:`row-chip`,title:`${e.outboxCount} new outbox file${e.outboxCount>1?`s`:``} since last opened — open gallery`,onClick:t=>{t.stopPropagation(),Y(`action:repo.inbox`),wi(e.id)},children:[(0,Q.jsx)(cp,{size:12}),e.outboxCount]}),wd(e)&&(0,Q.jsxs)(`button`,{className:`row-chip`,title:us(e),onClick:t=>{t.stopPropagation(),Y(`action:repo.git`),a(e.id)},children:[(0,Q.jsx)(sm,{size:12}),e.changedCount>0&&e.changedCount,nf(e)&&(0,Q.jsx)(`span`,{className:`git-ab`,children:nf(e)})]}),e.setup&&e.setup.issues>0&&(0,Q.jsxs)(`button`,{className:`row-chip ${e.setup.ok?`warn`:`bad`}`,title:xy(e.setup),onClick:t=>{t.stopPropagation(),Y(`action:repo.setup`),Vu(e.id,{focus:`findings`})},children:[(0,Q.jsx)(xp,{size:12}),e.setup.issues]})]}),!e.ownerSessionId&&(0,Q.jsx)(zx,{r:re.get(e.id)})]}),(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this worktree`,onClick:()=>uf(e.id),children:(0,Q.jsx)(qp,{size:Vx})}),(0,Q.jsx)(`button`,{className:`row-act`,title:`send words to a new session here — works offline`,onClick:()=>{Y(`action:repo.send`),g(e.worktreePath)},children:(0,Q.jsx)(Am,{size:Vx})}),(0,Q.jsx)(`button`,{className:`row-act${N===e.id?` on`:``}`,"aria-label":`more actions`,"aria-expanded":N===e.id,title:`more actions`,onClick:()=>{Y(`action:repo.more`),P(t=>t===e.id?null:e.id)},children:(0,Q.jsx)(Tp,{size:Vx})}),N===e.id&&(0,Q.jsxs)(`div`,{className:`row-more`,children:[m&&(0,Q.jsxs)(`button`,{className:`more-act`,title:`a plain terminal on the desktop in this worktree — no agent`,onClick:()=>{P(null),d(e)},children:[(0,Q.jsx)(Rf,{size:Vx}),`open a shell here`]}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{Y(`action:repo.build`),P(null),zs(e)},children:[(0,Q.jsx)(Yf,{size:Vx}),`build`]}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{Y(`action:repo.capture`),P(null),yi(e)},children:[(0,Q.jsx)(Lm,{size:Vx}),`capture`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:Cy(e.setup),onClick:()=>{Y(`action:repo.setup`),P(null),Vu(e.id)},children:[(0,Q.jsx)(xp,{size:Vx}),Sy(e.setup)]}),(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`repo.hide`,onClick:()=>{Y(`action:repo.hide`),P(null),c(e.id)},children:[(0,Q.jsx)(Sp,{size:Vx}),`hide`]}),!e.ownerSessionId&&(0,Q.jsx)(Bx,{t:e,r:re.get(e.id),onChanged:()=>{P(null),V()}})]})]},e.id);return(0,Q.jsxs)(`div`,{className:`repo-group-block`,children:[(0,Q.jsx)(`span`,{ref:se,className:`repo-group-anchor`,"aria-hidden":!0}),ue,ie&&!U&&(0,Q.jsx)(`div`,{className:`repo-group-empty`,style:pf(n),children:L?(0,Q.jsxs)(Q.Fragment,{children:[`No active session — start one with `,(0,Q.jsx)(pp,{size:15,"aria-label":`plus`}),`now under the name above.`]}):`No active session.`}),!U&&(0,Q.jsx)(Lx,{wts:ne,readings:re,onChanged:V}),!U&&pe.map(me),!U&&r.map(r=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(Mx,{p:e,m:t,s:r,repoName:n}),fe(r.id).map(me)]},r.id)),(0,Q.jsx)(`span`,{ref:ce,className:`repo-group-anchor`,"aria-hidden":!0})]})}function Ux({repo:e,repoName:t}){let n=mu(e);return(0,Q.jsx)(`button`,{className:`focus-btn`,title:n?`build “${n.name}” is running on the desktop — open build to follow it`:`build ${t} (run a build command, no tokens)`,onClick:()=>{Y(`action:repo.build.header`),zs(e)},children:n?(0,Q.jsx)(um,{size:17,className:`spin`}):(0,Q.jsx)(Yf,{size:17})})}function Wx(e){return e.itemLabel||e.tabTitle||V(e.title)||e.title}function Gx(e){let t=V(e.title)||e.title;return t&&t!==Wx(e)?t:void 0}var Kx={hand:`by hand`,fork:`fork`,backlog:`backlog`,schedule:`scheduled`,agent:`agent`,fanout:`fan-out`,resurrect:`reopened after limit`};function qx(e){return e.kind?Kx[e.kind]:void 0}function Jx(e){return e.closedBy===`auto-done`||e.closedBy===`auto-slot`}function Yx(e){switch(e.closedBy){case`you`:return{text:`closed by you`,tone:`quiet`};case`replaced`:return{text:`replaced by a relaunch`,tone:`quiet`};case`auto-done`:return{text:`closed automatically — work finished`,tone:`auto`};case`auto-slot`:return{text:`closed automatically to make room for a waiting item`,tone:`auto`};case`exited`:return typeof e.exitSignal==`number`&&e.exitSignal!==0?{text:`ended on its own (signal ${e.exitSignal})`,tone:`note`}:typeof e.exitCode==`number`&&e.exitCode!==0?{text:`ended on its own (exit ${e.exitCode})`,tone:`note`}:{text:`ended on its own`,tone:`quiet`};case`limit`:return{text:e.resumedAs?`stopped at usage limit — reopened`:`stopped at usage limit`,tone:`note`};default:return}}function Xx(e){if(!e.itemState)return;let t=e.itemDetail?`: ${e.itemDetail}`:``;return e.itemState===`canceled`?{text:`item canceled${t}`,tone:`muted`}:e.itemState===`failed`||e.itemOk===!1?{text:`item failed${t}`,tone:`bad`}:{text:`item done${t}`,tone:`ok`}}function Zx(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return n%60?`${r}h ${n%60}m`:`${r}h`;let i=Math.floor(r/24);return r%24?`${i}d ${r%24}h`:`${i}d`}function Qx(e,t){let n=[];return typeof e.openedAt==`number`&&e.closedAt>=e.openedAt&&n.push(`open ${Zx(e.closedAt-e.openedAt)}`),typeof e.lastActiveAt==`number`&&n.push(`last active ${Zx(t-e.lastActiveAt)} ago`),typeof e.turns==`number`&&e.turns>0&&n.push(`${e.turns} prompt${e.turns===1?``:`s`} sent from here`),e.model&&n.push(e.model),n}function $x(e,t){return t===`auto`?e.filter(Jx):[...e]}function eS(e,t){return`${e} of ${t} shown — closed automatically`}var tS=16;function nS({p:e,m:t}){let{backends:n,openGitFor:r}=e,{send:i,liveSend:a}=e.conn,{setOverlay:o}=e.route,{hiddenRepos:s,toggleHideRepo:c}=e.view,{openCwd:l,openRepo:u,reopenCant:d}=e.launchCore,{attach:f}=e.term,{closeSession:p}=e.verbs,{repoForCwd:m,sessionRepo:h,visibleRecent:g,hiddenRecent:_,hiddenSessions:v,hiddenCount:y,showHidden:b,setShowHidden:x}=t,S=e=>no(n,e.launch?.backend),C=e=>S(e)?`starts a new shell in this folder — a shell has no conversation to continue`:yf(!!Ut(e)),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(``),A=O.trim()!==``,j=t.reopenable,M=A?j.filter(e=>Uy(O,[e.title,Wx(e),Gx(e),e.cwd,e.firstPrompt,e.lastPrompt])):j,ee=A?g.filter(e=>Uy(O,[e.title,e.cwd])):g,N=j.length+g.length,P=M.length+ee.length;return(0,Q.jsxs)(Q.Fragment,{children:[N>0&&(0,Q.jsx)(`button`,{className:`section section-head closed-fold`,"aria-expanded":E,title:E?`fold away recently closed and recent sessions`:`show recently closed and recent sessions, with a search`,onClick:()=>D(e=>!e),children:(0,Q.jsxs)(`span`,{children:[E?(0,Q.jsx)(wm,{size:tS}):(0,Q.jsx)(nm,{size:tS}),` Closed & recent`,(0,Q.jsxs)(`span`,{className:`section-hint`,children:[` · `,j.length,` closed · `,g.length,` recent`]})]})}),E&&N>0&&(0,Q.jsxs)(`div`,{className:`section quick-filter`,children:[(0,Q.jsx)(mm,{size:14,className:`quick-filter-icon`}),(0,Q.jsx)(`input`,{type:`search`,value:O,placeholder:`search closed & recent`,"aria-label":`search recently closed and recent sessions by title, folder and prompts`,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Escape`&&O&&(e.preventDefault(),e.stopPropagation(),k(``))}}),A&&(0,Q.jsxs)(`span`,{className:`quick-filter-n`,children:[P,` of `,N]}),A&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`clear the search`,title:`clear the search — every row again`,onClick:()=>k(``),children:(0,Q.jsx)(X,{size:tS})})]}),E&&A&&P===0&&(0,Q.jsxs)(Mc,{children:[`No closed or recent session shows “`,O.trim(),`”.`]}),E&&(()=>{if(!M.length)return null;let e=M.filter(Jx).length,t=w===`auto`&&e>0?`auto`:null,s=$x(M,t),c=Date.now();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`section section-head`,children:[(0,Q.jsxs)(`span`,{children:[`Recently closed `,(0,Q.jsx)(`span`,{className:`section-hint`,children:`· tap to reopen (newest first)`})]}),(0,Q.jsxs)(`span`,{className:`head-acts tight`,children:[(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`open the archive`,title:`older conversations — the full archive on disk`,onClick:()=>{Y(`overlay:archive`),o(`archive`)},children:(0,Q.jsx)(qf,{size:tS})}),(0,Q.jsx)(As,{className:`head-act`,"aria-label":`clear recently-closed list`,title:`clear the recently-closed shortlist (the conversations stay, in the archive)`,confirmTitle:`tap again to clear the shortlist — the conversations stay on disk and remain resumable from the archive`,confirm:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Yp,{size:tS}),` clear?`]}),onConfirm:()=>{i({t:`closed.clear`}),G(`shortlist cleared — conversations kept`)},children:(0,Q.jsx)(Yp,{size:tS})})]})]}),e>0&&(0,Q.jsx)(tn,{className:`annot-tools closed-chips`,keys:[`auto`],bucket:()=>({count:e}),label:()=>`closed automatically`,active:t,onPick:e=>T(e)}),t&&(0,Q.jsx)(wn,{onClear:()=>T(null),clearLabel:`show all`,children:eS(s.length,M.length)}),s.map(e=>{let t=Gx(e),i=qx(e),o=Yx(e),s=Xx(e),u=Qx(e,c),f=e.contextSpark,p=()=>l(e.cwd,V(e.title)||e.title,!0,`continue`,e.launch,Ut(e));return(0,Q.jsxs)(`div`,{className:`row-wrap closed-card${Jx(e)?` closed-auto-row`:``}`,style:pf(m(e.cwd)?.repoName??Ws(e.cwd)),children:[(0,Q.jsxs)(bc,{as:`button`,kind:`grow`,title:`reopen ${V(e.title)} — ${C(e)}`,onClick:p,children:[(0,Q.jsxs)(`span`,{className:`row-head`,children:[(0,Q.jsxs)(Ad,{children:[e.bookmark&&!e.bookmark.note&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`bm-mark`,children:(0,Q.jsx)(ef,{on:!0,size:12})}),` `]}),Wx(e)]}),(0,Q.jsxs)(`span`,{className:`row-meta`,children:[t&&(0,Q.jsx)(qo,{className:`closed-folder`,children:t}),(0,Q.jsx)(qo,{className:`row-launch${Ni(n,e.launch?.backend)?` row-foreign`:``}`,children:Wr(e.launch??{},Ni(n,e.launch?.backend),n)}),i&&(0,Q.jsx)(lf,{className:`closed-kind`,children:i}),o&&o.tone!==`auto`&&(0,Q.jsx)(qo,{className:o.tone===`note`?`closed-note`:void 0,children:o.text}),S(e)&&(0,Q.jsx)(qo,{children:`new shell here`})]})]}),(0,Q.jsx)(`span`,{className:`row-stat`,children:(0,Q.jsxs)(lf,{className:`closed-stat`,title:`closed ${new Date(e.closedAt).toLocaleString()}`,children:[`closed `,Dl(e.closedAt)]})}),(0,Q.jsxs)(`span`,{className:`row-gist`,children:[o?.tone===`auto`&&(0,Q.jsx)(`span`,{className:`closed-line`,children:(0,Q.jsxs)(lf,{className:`closed-auto`,children:[(0,Q.jsx)(bp,{size:12}),` `,o.text]})}),s&&(0,Q.jsxs)(qo,{className:`closed-line closed-outcome ${s.tone}`,children:[s.tone===`ok`?(0,Q.jsx)(Om,{size:12}):s.tone===`bad`?(0,Q.jsx)(tp,{size:12}):(0,Q.jsx)(sp,{size:12}),` `,s.text]}),(0,Q.jsx)(po,{firstPrompt:e.firstPrompt,lastPrompt:e.lastPrompt,className:`closed-gist`}),u.length>0&&(0,Q.jsx)(qo,{className:`closed-line closed-meta`,children:u.join(` · `)}),e.followUp&&(0,Q.jsx)(`span`,{className:`closed-line`,children:(0,Q.jsx)(kx,{f:e.followUp})}),e.bookmark?.note&&(0,Q.jsxs)(`span`,{className:`closed-line bm-mark`,children:[(0,Q.jsx)(ef,{on:!0,size:12}),` `,e.bookmark.note]}),d(e)]}),f&&(0,Q.jsx)(`span`,{className:`row-side`,children:(0,Q.jsxs)(`span`,{className:`row-spark`,children:[(0,Q.jsx)(Xo,{spark:f,value:!0}),(0,Q.jsx)(Nd,{spark:f})]})})]}),(0,Q.jsxs)(`div`,{className:`row-acts`,children:[(0,Q.jsx)(`span`,{className:`row-tags`,children:jx(m(e.cwd),r)}),(0,Q.jsxs)(`span`,{className:`row-ctl`,children:[e.followUp&&(0,Q.jsx)(`button`,{className:`row-act fu-btn${Ex(e.followUp)}`,"data-hint":`session.followup`,"aria-pressed":!0,title:`Done — clear flag — the conversation stays where it is`,onClick:()=>{Y(`action:session.followup.closed`),a({t:`session.followup`,id:e.claudeSessionId??e.id,on:!1},`flag cleared`,`no connection — the desktop didn't get that, the flag is still set`)},children:(0,Q.jsx)(Ox,{on:!0,size:tS})}),nr(n,e.launch?.backend,`resumePick`)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`pick an older conversation in this folder — the binary's own list`,onClick:()=>l(e.cwd,e.title,!0,`pick`,e.launch),children:(0,Q.jsx)(cm,{size:tS})}),(0,Q.jsx)(`button`,{className:`row-act`,title:`${S(e)?`start a new shell in this folder`:`reopen`} — ${C(e)}`,onClick:p,children:(0,Q.jsx)(xm,{size:tS})})]})]})]},e.id)})]})})(),E&&ee.length>0&&(0,Q.jsxs)(`div`,{className:`section section-head`,children:[(0,Q.jsx)(`span`,{children:`Resume recent`}),(0,Q.jsx)(`span`,{className:`head-acts tight`,children:(0,Q.jsx)(As,{className:`head-act`,"aria-label":`clear recent list`,title:`clear the recent-sessions list`,confirmTitle:`tap again to clear the recent-sessions list`,confirm:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Yp,{size:tS}),` clear?`]}),onConfirm:()=>{i({t:`recent.clear`}),G(`recent cleared`)},children:(0,Q.jsx)(Yp,{size:tS})})})]}),E&&ee.map(e=>(0,Q.jsxs)(bc,{kind:`wrap`,style:pf(m(e.cwd)?.repoName??Ws(e.cwd)),children:[(0,Q.jsxs)(bc,{as:`button`,kind:`grow`,title:`${S(e)?`open a new shell in`:`resume`} ${e.title} — ${C(e)}`,onClick:()=>l(e.cwd,e.title,!0,`continue`,e.launch,Ut(e)),children:[(0,Q.jsx)(Ad,{children:e.title}),(0,Q.jsxs)(qo,{children:[(0,Q.jsx)(xm,{size:12}),` `,S(e)?`new shell here`:`resume`]}),d(e)]}),jx(m(e.cwd),r),m(e.cwd)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this repo`,onClick:()=>uf(m(e.cwd).id),children:(0,Q.jsx)(qp,{size:tS})})]},Ut(e)??e.cwd)),y>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{className:`section`,onClick:()=>x(e=>!e),style:{background:`none`,border:0,textAlign:`left`,cursor:`pointer`,width:`100%`},children:[`Hidden (`,y,`) `,b?`▾`:`▸`]}),b&&(0,Q.jsxs)(Q.Fragment,{children:[v.map(e=>(0,Q.jsxs)(bc,{kind:`wrap`,children:[(0,Q.jsxs)(bc,{as:`button`,kind:`grow`,onClick:()=>f(e),children:[(0,Q.jsxs)(Ad,{children:[e.title,(0,Q.jsxs)(qo,{className:Ni(n,e.backend)?`row-foreign`:void 0,children:[` `,Wr(e,Ni(n,e.backend),n)]})]}),(0,Q.jsx)(Gt,{s:e}),mx(e,void 0,void 0,n)]}),jx(h(e),r),h(e)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this session`,onClick:()=>uf(h(e).id),children:(0,Q.jsx)(qp,{size:tS})}),(0,Q.jsx)(`button`,{className:`row-act danger`,title:e.running?`close`:`remove`,onClick:()=>p(e),children:(0,Q.jsx)(X,{size:tS})})]},e.id)),_.map(e=>(0,Q.jsxs)(bc,{kind:`wrap`,children:[(0,Q.jsxs)(bc,{as:`button`,kind:`grow`,title:`${S(e)?`open a new shell in`:`resume`} ${e.title} — ${C(e)}`,onClick:()=>l(e.cwd,e.title,!0,`continue`,e.launch,Ut(e)),children:[(0,Q.jsx)(Ad,{children:e.title}),(0,Q.jsxs)(qo,{children:[(0,Q.jsx)(xm,{size:12}),` `,S(e)?`new shell here`:`resume`]})]}),jx(m(e.cwd),r),m(e.cwd)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this repo`,onClick:()=>uf(m(e.cwd).id),children:(0,Q.jsx)(qp,{size:tS})})]},Ut(e)??e.cwd)),s.map(e=>(0,Q.jsxs)(`div`,{className:`row-wrap ${e.isPrimary?``:`row-wt`}`,children:[(0,Q.jsxs)(bc,{as:`button`,kind:`grow`,onClick:()=>u(e),children:[(0,Q.jsx)(Ad,{children:e.isPrimary?e.repoName:(0,Q.jsx)(`span`,{className:`wt-branch`,children:e.branch})}),(e.isPrimary?Re(e):`worktree`)&&(0,Q.jsx)(qo,{children:e.isPrimary?Re(e):`worktree`})]}),(0,Q.jsx)(`button`,{className:`row-act`,title:`show repo`,onClick:()=>c(e.id),children:(0,Q.jsx)(Um,{size:tS})})]},e.id))]})]})]})}var rS=[`wait`,`limit`,`coding`,`done`,`exited`],iS={coding:`working`,wait:`waiting for your answer`,done:`idle`,limit:`at the usage limit`,exited:`exited`},aS=[`1h`,`6h`,`1d`,`3d`],oS={"1h":36e5,"6h":216e5,"1d":864e5,"3d":2592e5},sS={"1h":`> 1h`,"6h":`> 6h`,"1d":`> 1d`,"3d":`> 3d`},cS=[`agents`,`shellsLive`,`shellsQuiet`,`nothing`],lS={agents:`agents running`,shellsLive:`shells live`,shellsQuiet:`shells quiet`,nothing:`nothing running`};function uS(e,t,n){let r=!!e.agents?.length,i,a;if(e.shellList){let n=ye(e.shellList,t);i=n.working+n.waiting+n.unknown>0,a=!i&&n.quiet>0}else i=!!e.shells,a=!1;return n===`agents`?r:n===`shellsLive`?i:n===`shellsQuiet`?a:!r&&!i&&!a}var dS=[`draft`,`queued`,`none`],fS={draft:`unsent draft on this phone`,queued:`prompts queued for it`,none:`nothing waiting`};function pS(e,t,n){return t.has(e.id)?`draft`:n.some(t=>t.sessionId===e.id&&t.status!==`failed`)?`queued`:`none`}var mS=[`fresh`,`started`],hS={fresh:`never started`,started:`started`},gS={state:new Set,idleOver:new Set,openOver:new Set,under:new Set,stakes:new Set,convo:new Set,repo:new Set};function _S(e,t){return e.size===0||[...e].some(t)}function vS(e,t,n){return _S(t.state,t=>n.statusOf(e)===t)&&_S(t.idleOver,t=>Zo(e)>=oS[t])&&_S(t.openOver,t=>n.now-e.createdAt>=oS[t])&&_S(t.under,t=>uS(e,n.now,t))&&_S(t.stakes,t=>pS(e,n.draftIds,n.outbox)===t)&&_S(t.convo,t=>pc(e)===t)&&_S(t.repo,t=>n.repoName(e)===t)}function yS(e,t,n){return e.filter(e=>vS(e,t,n))}function bS(e,t){return{...e,[t]:gS[t]}}function xS(e,t,n,r,i,a){let o=bS(t,r),s=e.filter(e=>vS(e,o,n)),c={};for(let e of i)c[e]=s.filter(t=>a(t,e)).length;return c}function SS(e,t,n,r){let i=bS(t,`idleOver`);return{state:xS(e,t,n,`state`,rS,(e,t)=>n.statusOf(e)===t),idleOver:xS(e,t,n,`idleOver`,aS,(e,t)=>Zo(e)>=oS[t]),openOver:xS(e,t,n,`openOver`,aS,(e,t)=>n.now-e.createdAt>=oS[t]),under:xS(e,t,n,`under`,cS,(e,t)=>uS(e,n.now,t)),stakes:xS(e,t,n,`stakes`,dS,(e,t)=>pS(e,n.draftIds,n.outbox)===t),convo:xS(e,t,n,`convo`,mS,(e,t)=>pc(e)===t),repo:xS(e,t,n,`repo`,r,(e,t)=>n.repoName(e)===t),idleUnknown:e.filter(e=>vS(e,i,n)&&!Pd(e)).length}}function CS(e){return e?`${e} session${e===1?` has`:`s have`} no readable activity record — ${e===1?`its`:`their`} quiet time is measured only since the last desktop restart, so "idle for" may read shorter than it has been. "Open for" is unaffected.`:``}function wS(e){let t=[];return e.state.size&&t.push([...e.state].map(e=>iS[e]).join(` or `)),e.idleOver.size&&t.push(`idle ${[...e.idleOver].map(e=>sS[e]).join(` or `)}`),e.openOver.size&&t.push(`open ${[...e.openOver].map(e=>sS[e]).join(` or `)}`),e.under.size&&t.push([...e.under].map(e=>lS[e]).join(` or `)),e.stakes.size&&t.push([...e.stakes].map(e=>fS[e]).join(` or `)),e.convo.size&&t.push([...e.convo].map(e=>hS[e]).join(` or `)),e.repo.size&&t.push([...e.repo].join(` or `)),t.join(` · `)}function TS(e,t,n){let r=wS(n);return`${e} of ${t} in scope${r?` · ${r}`:``}`}var ES=e=>e.state.size+e.idleOver.size+e.openOver.size+e.under.size+e.stakes.size+e.convo.size+e.repo.size>0;function DS(e,t,n=new Set){return n.has(e)?!t.has(e):t.has(e)}function OS(e,t,n){return e.filter(e=>!DS(e.id,t,n))}function kS(e){return e?`${e} session${e===1?` is`:`s are`} kept open: a timed prompt is aimed at ${e===1?`it`:`each`}. Closed anyway, the desktop reopens that conversation when the prompt's time comes — the shield on the row puts ${e===1?`it`:`one`} back in this close.`:``}function AS(e){return e.reduce((e,t)=>e+(t.shellList?.length??0),0)}function jS(e,t){return e.filter(e=>t.statusOf(e)===`wait`).length}function MS(e,t){return e?t>0?`close ${e} · stops ${t} background shell${t===1?``:`s`}`:`close ${e}`:``}function NS(e,t,n,r){let i=`archived ${e} session${e===1?``:`s`}${r?` in ${r}`:``}`,a=[t>0?`stopping ${t} background shell${t===1?``:`s`}`:``,typeof n==`string`?n?`kept ${n}`:``:n>0?`kept ${n} starred`:``].filter(Boolean).join(`, `);return`${i}${a?`, ${a}`:``} — the conversation${e===1?` is`:`s are`} kept: reopen under "Recently closed" or Archive`}var PS=16;function FS({label:e,options:t,counts:n,active:r,labels:i,onToggle:a,hintId:o}){let s=t.filter(e=>n[e]>0||r.has(e)),c=t.filter(e=>!(n[e]>0||r.has(e)));return(0,Q.jsxs)(`div`,{className:`close-facet`,"data-hint":o,children:[(0,Q.jsx)(`span`,{className:`close-facet-label`,children:e}),(0,Q.jsxs)(`div`,{className:`close-facet-body`,children:[s.length>0&&(0,Q.jsx)(`div`,{className:`fchips wrap`,children:s.map(e=>(0,Q.jsx)(Vd,{on:r.has(e),title:`${i[e]} — ${n[e]} session${n[e]===1?``:`s`}`,onClick:()=>a(e),children:Ca(i[e],{count:n[e]})},e))}),c.length>0&&(0,Q.jsx)(`div`,{className:`close-facet-none`,children:`none: ${c.map(e=>i[e]).join(`, `)}`})]})]})}function IS(e){let t=e.indexOf(` — `);if(t<0)return[e.replace(/\.$/,``),``];let n=e.slice(t+3);return[e.slice(0,t),n.charAt(0).toUpperCase()+n.slice(1)]}function LS(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function RS({s:e,repoLabel:t,kept:n,onToggleKeep:r,statusOf:i,now:a,timedAt:o,backends:s}){let c=i(e)===`wait`;return(0,Q.jsxs)(bc,{kind:`wrap`,children:[(0,Q.jsxs)(bc,{kind:`grow`,style:{cursor:`default`},children:[(0,Q.jsx)(Mi,{s:e,repoLabel:t,backends:s}),e.shellList?.length?(0,Q.jsxs)(qo,{children:[(0,Q.jsx)(op,{size:11}),` `,_(ye(e.shellList,a)),` — will stop`]}):null,o&&(0,Q.jsxs)(qo,{children:[(0,Q.jsx)(Fp,{size:11}),` a prompt is timed into it · `,o,n?` — kept open`:` — its conversation is reopened then`]}),c&&(0,Q.jsxs)(qo,{className:`warn`,children:[(0,Q.jsx)(em,{size:11}),` waiting on a box — closing answers nothing, it just ends the process`]})]}),(0,Q.jsx)(`button`,{className:`row-act${n?` on`:``}`,title:n?`kept — tap to put it back in this close`:`keep — leave this one open`,onClick:r,children:(0,Q.jsx)(Ip,{size:PS})})]})}function zS({p:e,m:t}){let{send:n}=e.conn,{closeAllPick:r,setCloseAllPick:i,closeKeepStar:a,setCloseKeepStar:o,visibleSessions:s,sessionRepoName:c}=t,l=r!==null;Ju(l,()=>i(null));let[u,d]=(0,Z.useState)(gS),[f,p]=(0,Z.useState)(new Set),{items:m}=Ct();if((0,Z.useEffect)(()=>{l||(d(gS),p(new Set))},[l]),!l)return null;let h=r===`*`?void 0:r,g=Date.now(),_=zy(s,h,a,c),v=Vy(s,h,a,c),y=By(s,h,c),b=y.n,x=Hy(y),S={now:g,repoName:c,statusOf:t=>tr(t,e.backends),draftIds:Nn(),outbox:e.outbox},C=h?[]:[...new Set(_.map(c))].sort(),w=SS(_,u,S,C),T=yS(_,u,S),E=new Map;for(let e of m)e.status===`queued`&&e.at&&e.targetSessionId&&!E.has(e.targetSessionId)&&E.set(e.targetSessionId,e.at.nextAt==null?`when its rule comes round`:wc(e.at.nextAt));let D=new Set(E.keys()),O=OS(T,f,D),k=kS(T.filter(e=>D.has(e.id)&&DS(e.id,f,D)).length),A=AS(O),j=jS(O,S),M=MS(O.length,A),[ee,N]=IS(CS(w.idleUnknown));function P(e,t){d(n=>({...n,[e]:t}))}function F(){d(gS)}function I(e){p(t=>LS(t,e))}function te(){if(O.length){Y(`action:${h?`repo`:`session`}.close.facets`);for(let e of O)si(e.id),n({t:`session.remove`,id:e.id});i(null),G(NS(O.length,A,v>0?x:``,h))}}return(0,Q.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:30,background:`var(--bg)`,display:`flex`,flexDirection:`column`},children:(0,Q.jsx)(Zd,{title:h?`Close sessions in ${h}?`:`Close sessions?`,icon:(0,Q.jsx)(X,{size:PS}),onClose:()=>i(null),footer:(0,Q.jsxs)(Q.Fragment,{children:[M?(0,Q.jsxs)(As,{className:`key danger`,confirm:`tap again to ${M}`,title:M,confirmTitle:`tap again to ${M}`,onConfirm:te,children:[(0,Q.jsx)(X,{size:PS}),` `,M]}):(0,Q.jsx)(gs,{children:_.length===0?v>0?`Nothing left to close — every session here is starred or flagged. "Close them too" below puts ${v===1?`it`:`them`} back in reach.`:`Nothing here to close.`:`Nothing in the cut, or every matching row is kept — nothing to send.`}),(0,Q.jsx)(gs,{children:`Conversations are kept — reopen under "Recently closed" or Archive.`})]}),children:(0,Q.jsxs)(`div`,{className:`sheet-body`,children:[b>0&&(0,Q.jsx)(`div`,{className:`section`,children:(0,Q.jsx)(`div`,{style:{padding:`10px 12px 0`},children:(0,Q.jsx)(Ft,{label:`what happens to the starred and flagged sessions`,value:a?`keep`:`close`,options:[{key:`keep`,label:`keep ${x}`,title:`leave the ${x} session(s) alone — out of every count and cut below`},{key:`close`,label:`close them too`,title:`treat the ${x} session(s) like any other`}],onChange:e=>o(e===`keep`)})})}),ES(u)&&(0,Q.jsxs)(`div`,{className:`filter-bar`,children:[(0,Q.jsx)(`span`,{className:`filter-bar-txt`,children:TS(T.length,_.length,u)}),(0,Q.jsxs)(`button`,{className:`filter-bar-clear`,onClick:F,children:[(0,Q.jsx)(X,{size:13}),` clear`]})]}),(0,Q.jsxs)(`div`,{className:`close-facets`,children:[(0,Q.jsx)(FS,{label:`State`,options:rS,counts:w.state,active:u.state,labels:iS,onToggle:e=>P(`state`,LS(u.state,e))}),(0,Q.jsx)(FS,{label:`Idle for`,options:aS,counts:w.idleOver,active:u.idleOver,labels:sS,onToggle:e=>P(`idleOver`,LS(u.idleOver,e)),hintId:`session.close.stale`}),ee&&(0,Q.jsxs)(gs,{children:[ee,`.`,` `,N&&(0,Q.jsx)(Bs,{of:`the idle-for reading`,label:`what does that change?`,children:N})]}),(0,Q.jsx)(FS,{label:`Open for`,options:aS,counts:w.openOver,active:u.openOver,labels:sS,onToggle:e=>P(`openOver`,LS(u.openOver,e))}),(0,Q.jsx)(FS,{label:`Underneath`,options:cS,counts:w.under,active:u.under,labels:lS,onToggle:e=>P(`under`,LS(u.under,e))}),(0,Q.jsx)(FS,{label:`Words at stake`,options:dS,counts:w.stakes,active:u.stakes,labels:fS,onToggle:e=>P(`stakes`,LS(u.stakes,e))}),(0,Q.jsx)(FS,{label:`Conversation`,options:mS,counts:w.convo,active:u.convo,labels:hS,onToggle:e=>P(`convo`,LS(u.convo,e))}),!h&&C.length>1&&(0,Q.jsx)(FS,{label:`Repo`,options:C,counts:w.repo,active:u.repo,labels:Object.fromEntries(C.map(e=>[e,e])),onToggle:e=>P(`repo`,LS(u.repo,e))})]}),k&&(0,Q.jsx)(gs,{children:k}),(0,Q.jsx)(`div`,{className:`section section-head close-cut`,children:(0,Q.jsxs)(`span`,{children:[`The cut`,j>0?` · ${j} waiting on a box`:``]})}),T.length===0?(0,Q.jsx)(Mc,{children:`Nothing here matches every facet ticked above.`}):T.map(t=>(0,Q.jsx)(RS,{backends:e.backends,s:t,repoLabel:h?void 0:c(t),kept:DS(t.id,f,D),onToggleKeep:()=>I(t.id),statusOf:S.statusOf,now:g,timedAt:E.get(t.id)},t.id))]})})})}var BS=()=>null;function VS(e,t,n,r){Y(`action:launcher.${t}${e.key}`),r?.(),e.unavailable?G(e.unavailable):n>0&&e.openCount?e.openCount():e.open()}function HS({it:e,size:t,onOpen:n}){let r=(e.useCount??BS)(),i=h_(r),a=e.icon;return(0,Q.jsxs)(`button`,{className:`more-act${i?` notif-btn`:``}`,title:e.unavailable??(i?r.title:`open ${e.label}`),onClick:()=>VS(e,``,i,n),children:[(0,Q.jsx)(a,{size:t}),e.label,i>0&&(0,Q.jsx)(`span`,{className:`notif-badge`,children:La(i)})]})}function US({size:e,onOpen:t}){let n=I_();return n.length?(0,Q.jsx)(Q.Fragment,{children:n.map(n=>(0,Q.jsx)(q_,{feature:n.feature,what:`its ${n.label} menu line`,children:(0,Q.jsx)(HS,{it:n,size:e,onOpen:t})},n.key))}):null}function WS({it:e,size:t}){let n=e.useCount(),r=h_(n);if(!r)return null;let i=e.icon;return(0,Q.jsxs)(K,{className:`notif-btn`,"aria-label":n.title,title:n.title,onClick:()=>VS(e,`key.`,r),children:[(0,Q.jsx)(i,{size:t}),(0,Q.jsx)(`span`,{className:`notif-badge`,children:La(r)})]})}function GS({size:e}){let t=I_().filter(e=>e.useCount);return t.length?(0,Q.jsx)(Q.Fragment,{children:t.map(t=>(0,Q.jsx)(q_,{feature:t.feature,what:`its ${t.label} header key`,children:(0,Q.jsx)(WS,{it:t,size:e})},t.key))}):null}function KS({items:e,base:t}){let n=g_(t,e.map(e=>e.useCount()));return n>0?(0,Q.jsx)(`span`,{className:`mic-badge`,children:La(n)}):null}function qS({base:e}){let t=I_().filter(e=>e.useCount);return t.length?(0,Q.jsx)(q_,{feature:t.map(e=>e.feature).join(`, `),what:`the menu badge`,children:(0,Q.jsx)(KS,{items:t,base:e})}):e>0?(0,Q.jsx)(`span`,{className:`mic-badge`,children:La(e)}):null}var JS=16,YS=6e4;function XS(e){let t=px(e),{sessions:n,recent:r,repos:i,reposAt:a,reposFailAt:o,launch:s}=e,{status:c,connVisible:l}=e.conn,{tailscaleIp:u}=e.conn.info,{focusRepo:d,setOverlay:f,lastVisitedId:p}=e.route,{visibleRepos:m}=e.view,{openCwd:h,refreshRepos:g}=e.launchCore,{clearExited:_}=e.verbs,{tab:v,setTab:y,navMenu:b,setNavMenu:x,dl:S,appsReady:w,activityBadge:T,visibleSessions:E,visibleExternal:D,clearFocus:O,repoGroups:k,sessionOrder:A,resetSessionOrder:j,waitingTotal:M,waitingRepliesTotal:ee,limitTotal:N,codingTotal:P,starredTotal:F,flaggedTotal:I,shellsTotal:te,statusFilter:L,setStatusFilter:R,statusFilterActive:z,toggleStatusFilter:ne,shownSessions:re,sortedSessions:B,textQuery:V,setTextQuery:H,textOn:ie,noRepoCollapsed:ae,allReposCollapsed:oe,persistCollapsedRepos:U,scheduleWords:se,scheduleLead:ce,scheduleTitle:le,setCloseAllPick:ue,shotPick:de,setShotPick:fe,repoForCwd:pe}=t;Ju(de,()=>fe(!1));let me=qr(),he=ar(),ge=ud(),_e=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let e=_e.current;if(!e||(e.scrollTop=ux.top,!p))return;let t=e.querySelector(`[data-sid="${CSS.escape(p)}"]`);if(!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();(r.top<n.top||r.bottom>n.bottom)&&t.scrollIntoView({block:`center`})},[]),(0,Q.jsxs)(`div`,{className:`screen`,children:[(0,Q.jsxs)(`header`,{className:`topbar`,children:[d?(0,Q.jsxs)(`div`,{className:`brand brand-focus`,style:pf(d),children:[(0,Q.jsx)(Nb,{size:32,label:``}),(0,Q.jsx)(`span`,{children:d}),(0,Q.jsx)(`button`,{className:`focus-clear`,title:`exit repo focus — show all repos`,onClick:O,children:(0,Q.jsx)(X,{size:14})})]}):(0,Q.jsx)(`div`,{className:`brand`,children:(0,Q.jsx)(Nb,{size:40})}),s.permissionMode&&uy.has(s.permissionMode)&&(0,Q.jsxs)(K,{variant:`danger`,title:`New sessions launch with --permission-mode ${s.permissionMode}: every tool call runs without asking. Tap to change it.`,onClick:()=>f(`settings`),children:[(0,Q.jsx)(Up,{size:JS}),` no approvals`]}),(0,Q.jsx)(Ol,{compact:!0}),(0,Q.jsxs)(K,{className:`nav-key${b?` on`:``}`,"data-nohint":!0,"aria-label":`menu`,"aria-expanded":b,title:`menu — new, pad, activity, search, files, downloads, archive, logs, local/external${v===`external`?`
|
|
162
|
-
showing: external processes`:``}`,onClick:()=>{Y(`action:nav.menu`),x(e=>!e)},children:[(0,Q.jsx)(Mm,{size:JS}),v===`external`&&(0,Q.jsxs)(`span`,{className:`nav-tab`,children:[(0,Q.jsx)(Rf,{size:12}),` external`]}),S.active>0&&(0,Q.jsxs)(`span`,{className:`nav-dl${S.stuck?` warn`:``}`,children:[(0,Q.jsx)(Hf,{size:11}),` `,S.pct,`%`]}),(0,Q.jsx)(qS,{base:T+(pd()?w:0)})]}),b&&(0,Q.jsxs)(`div`,{className:`row-more nav-more`,children:[ws()&&(0,Q.jsx)(za,{size:JS,onOpen:()=>x(!1)}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{x(!1),f(`new`)},children:[(0,Q.jsx)(pp,{size:JS}),`new`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`prompt pad — write a thought now, decide where it goes later`,onClick:()=>{x(!1),f(`pad`)},children:[(0,Q.jsx)(Op,{size:JS}),`pad`]}),(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`activity.open`,title:`activity — every prompt, sweep, build, schedule and download you posted, with what became of it. Select rows here to deal with many at once.`,onClick:()=>{Y(`overlay:activity`),x(!1),mr(null)},children:[(0,Q.jsx)(Hm,{size:JS}),`activity`,T>0&&(0,Q.jsx)(`span`,{className:`mic-badge`,children:T})]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`search words across all sessions`,onClick:()=>{x(!1),Jr(null)},children:[(0,Q.jsx)(mm,{size:JS}),`search`]}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{x(!1),f(`gallery`)},children:[(0,Q.jsx)(cp,{size:JS}),`files`]}),(0,Q.jsxs)(`button`,{className:`more-act${S.active>0?` has-bar`:``}`,title:S.active>0?`downloads — ${S.active} in flight, ${S.pct}% of the bytes here${S.stuck?` (something is stopped)`:``}`:`downloads — files fetched to this phone, and what each repo fetches on its own`,onClick:()=>{Y(`overlay:pull`),x(!1),f(`pull`)},children:[(0,Q.jsx)(Hf,{size:JS}),`downloads`,S.active>0?` ${S.active} · ${S.pct}%`:S.onPhone>0?` ${S.onPhone}`:``,S.active>0&&(0,Q.jsx)(`span`,{className:`more-dl-bar${S.stuck?` warn`:``}`,style:{width:`${S.pct}%`}})]}),pd()&&(0,Q.jsxs)(`button`,{className:`more-act`,title:w>0?`apps — ${w} build${w===1?``:`s`} ready to install`:`apps — builds from your repos, and which install themselves`,onClick:()=>{Y(`overlay:apps`),w>0&&Ss(),x(!1),f(`apps`)},children:[(0,Q.jsx)(Vm,{size:JS}),`apps`,w>0?` · ${w} ready`:``]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`archive — every conversation this repo ever had, resumable`,onClick:()=>{Y(`overlay:archive`),x(!1),f(`archive`)},children:[(0,Q.jsx)(qf,{size:JS}),`archive`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`decision log — usage-limit auto-continues and what plugins suggested or answered`,onClick:()=>{x(!1),Gl(null)},children:[(0,Q.jsx)(Cm,{size:JS}),`decisions`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`sent commands — everything this app typed into a session, including what it decided by itself`,onClick:()=>{Y(`overlay:sentlog`),x(!1),_o(null)},children:[(0,Q.jsx)(tm,{size:JS}),`sent`]}),(0,Q.jsxs)(`button`,{className:`more-act${v===`home`?` on`:``}`,title:`sessions this app started`,onClick:()=>{x(!1),y(`home`)},children:[(0,Q.jsx)(zm,{size:JS}),`local `,E.length?`(${E.length})`:``]}),(0,Q.jsxs)(`button`,{className:`more-act${v===`external`?` on`:``}`,title:"`claude` processes running outside this app — resumable from here",onClick:()=>{x(!1),y(`external`)},children:[(0,Q.jsx)(Rf,{size:JS}),`external `,D.length?`(${D.length})`:``]}),(0,Q.jsx)(US,{size:JS,onOpen:()=>x(!1)})]}),me.kind===`windows`?(0,Q.jsx)(Kb,{sessions:n}):(0,Q.jsxs)(K,{className:`usage-key ${me.kind===`usd`&&me.chip.hot?`danger`:``}`,"aria-label":me.kind===`usd`?me.chip.text:`token statistics`,title:`${me.kind===`usd`?me.chip.title:`Spend on this desktop`}\ntap for the token history`,onClick:()=>{Y(`overlay:tokens`),f(`tokens`)},children:[(0,Q.jsx)(Wp,{size:JS}),me.kind===`usd`&&(0,Q.jsx)(`span`,{className:me.chip.hot?`usage-hot`:``,children:me.chip.text})]}),(0,Q.jsx)(Oo,{}),(0,Q.jsx)(GS,{size:JS}),(0,Q.jsxs)(K,{className:`notif-btn`,title:`notifications`,onClick:Ja,children:[(0,Q.jsx)(zf,{size:JS}),he>0&&(0,Q.jsx)(`span`,{className:`notif-badge`,children:La(he)})]}),(0,Q.jsx)(K,{className:ge===`insecure`?`danger`:``,"aria-label":`settings`,title:`settings — notifications, launch defaults, plugins, tools`,onClick:()=>f(`settings`),children:(0,Q.jsx)(kf,{size:JS})}),(0,Q.jsx)(mf,{})]}),e.banners,v===`home`&&(0,Q.jsxs)(`div`,{className:`list`,ref:_e,onScroll:e=>{ux.top=e.currentTarget.scrollTop},children:[n.length===0&&r.length===0&&i.length===0&&c!==`open`&&l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`offline-card`,children:[(0,Q.jsxs)(`div`,{className:`offline-card-head`,children:[(0,Q.jsx)(Xf,{size:18}),` Can’t reach the host and nothing is cached yet`]}),(0,Q.jsx)(`div`,{className:`offline-card-body`,children:`The launcher fills in when the tunnel is back — sessions, repos and recent conversations all come from the desktop.`}),(0,Q.jsxs)(`ul`,{className:`offline-card-hints`,children:[(0,Q.jsx)(`li`,{children:`Is Tailscale connected on this phone?`}),(0,Q.jsxs)(`li`,{children:[`Is the desktop awake, with the `,C.name,` daemon running?`]}),u&&(0,Q.jsxs)(`li`,{children:[`Last known host address: `,(0,Q.jsx)(`span`,{className:`mono`,children:u})]})]})]}),[0,1,2].map(e=>(0,Q.jsxs)(`div`,{className:`row-wrap skel-row`,"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{className:`skel-bar skel-title`}),(0,Q.jsx)(`span`,{className:`skel-bar skel-sub`})]},e))]}),(0,Q.jsx)(hs,{repos:i.length,demo:ot(),onDemo:()=>lt(`first-look`)}),k.length>0&&(0,Q.jsxs)(`div`,{className:`section section-head launcher-head`,children:[(0,Q.jsxs)(`span`,{children:[`Sessions & repos `,(0,Q.jsxs)(`span`,{className:`section-hint`,children:[`· `,E.length,` live in `,k.length,` repo`,k.length>1?`s`:``,A.length?` · custom order`:``,a&&o>a&&Date.now()-a>YS?(0,Q.jsxs)(Q.Fragment,{children:[` — repos as of `,Dl(a),`, the host hasn’t answered since`]}):(0,Q.jsx)(Q.Fragment,{children:` — hold a row to drag`})]})]}),(0,Q.jsxs)(`span`,{className:`head-acts tight`,children:[M>0&&(0,Q.jsxs)(`button`,{className:`head-wait`,title:`${M} session${M>1?`s`:``} waiting for your answer${ee?` — some already have a reply on a clock`:``} — tap to answer them here`,onClick:()=>{Y(`overlay:questions`),f(`questions`)},children:[(0,Q.jsx)(em,{size:13}),` `,M,` waiting`,ee&&(0,Q.jsx)(Rm,{size:11,className:`wait-sched`})]}),N>0&&(0,Q.jsxs)(`button`,{className:`head-wait limit`,"data-hint":`limit.open`,title:N>1?`${N} sessions at the usage limit — they resume one at a time; tap to set the order`:`a session is at the usage limit — tap to steer when it resumes`,onClick:()=>{Y(`overlay:limits`),f(`limits`)},children:[(0,Q.jsx)(Zf,{size:13}),` `,N,` at limit`]}),P>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat coding${z(`coding`)?` on`:``}`,title:`${P} session${P>1?`s`:``} working — tap to show only those`,onClick:()=>ne(`coding`),children:[(0,Q.jsx)(um,{size:13,className:`spin`}),P]}),F>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat starred${z(`starred`)?` on`:``}`,title:`${F} starred session${F>1?`s`:``} — tap to show only those`,onClick:()=>ne(`starred`),children:[(0,Q.jsx)(Af,{size:13,fill:`currentColor`}),F]}),I&&(0,Q.jsxs)(`button`,{className:`repo-group-stat fu-${I.tone}${z(`followup`)?` on`:``}`,"data-hint":`session.followup`,title:Tu(I.n),onClick:()=>ne(`followup`),children:[(0,Q.jsx)(Sm,{size:13,fill:`currentColor`}),I.n]}),te>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat coding${z(`shells`)?` on`:``}`,title:`${te} session${te>1?`s`:``} running background shells — tap to show only those`,onClick:()=>ne(`shells`),children:[(0,Q.jsx)(op,{size:13}),te]}),A.length>0&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`reset order`,title:`reset order — drop the custom order and go back to creation order`,onClick:()=>{Y(`action:session.order.reset`),j(),G(`order reset to oldest-first`)},children:(0,Q.jsx)(Gm,{size:JS})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`expand all repo groups`,title:ae?`expand all — every repo group is already open`:`expand all — every repo group opens`,onClick:()=>{Y(`action:repo.expand.all`),U(new Set)},children:(0,Q.jsx)(jm,{size:JS})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`collapse all repo groups`,title:oe?`collapse all — every repo group is already folded`:`collapse all — headers stay, session and worktree rows hide`,onClick:()=>{Y(`action:repo.collapse.all`),U(new Set(k.map(e=>e.repoName)))},children:(0,Q.jsx)(Fm,{size:JS})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`fan out`,title:`fan out — run one prompt in several repos at once (a fresh session each)`,onClick:()=>{Y(`overlay:fanout`),f(`fanout`)},children:(0,Q.jsx)(ip,{size:JS})}),(0,Q.jsxs)(`button`,{className:`head-act${se?` head-act-wide`:``}`,"aria-label":`schedules`,title:le,onClick:()=>{Y(`overlay:schedule`),ps(se?ce:null)},children:[(0,Q.jsx)(Rm,{size:JS}),se&&(0,Q.jsx)(`span`,{className:`head-act-n`,children:se})]}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`sync repos`,title:`sync repos — pull, push or sync every repo at once`,onClick:()=>{Y(`overlay:reposync`),f(`reposync`)},children:(0,Q.jsx)(Pp,{size:JS})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`rescan repos`,title:`rescan the host root for repos and worktrees`,onClick:()=>{g(),G(`repos rescanned`)},children:(0,Q.jsx)(xm,{size:JS})}),E.some(e=>!e.running)&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`clear exited sessions`,title:`clear exited — drop the sessions that have already ended`,onClick:_,children:(0,Q.jsx)(Bm,{size:JS})}),E.length>0&&(0,Q.jsx)(`button`,{className:`head-act danger`,"data-hint":`session.close.all`,"aria-label":`close sessions`,title:`close sessions — review the ${E.length} listed, cut by state, idle time, what is still running underneath, or a repo`,onClick:()=>ue(`*`),children:(0,Q.jsx)(X,{size:JS})})]})]}),(k.length>0||ie)&&(0,Q.jsxs)(`div`,{className:`section quick-filter`,children:[(0,Q.jsx)(mm,{size:14,className:`quick-filter-icon`}),(0,Q.jsx)(`input`,{type:`search`,value:V,placeholder:`filter sessions & repos`,"aria-label":`filter sessions and repos by the text on their rows`,onChange:e=>H(e.target.value),onKeyDown:e=>{e.key===`Escape`&&V&&(e.preventDefault(),e.stopPropagation(),H(``))}}),ie&&(0,Q.jsxs)(`span`,{className:`quick-filter-n`,children:[re.length,` of `,B.length]}),ie&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`clear the filter`,title:`clear the filter — every row again`,onClick:()=>H(``),children:(0,Q.jsx)(X,{size:JS})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`search what sessions said`,title:`search what the sessions SAID — every transcript, on the desktop`,onClick:()=>{Y(`action:launcher.search`),Jr(null)},children:(0,Q.jsx)(Cm,{size:JS})})]}),L&&(0,Q.jsxs)(`div`,{className:`section filter-bar`,children:[(0,Q.jsxs)(`span`,{className:`filter-bar-txt`,children:[`showing `,fi[L.status],L.repo?` in ${L.repo}`:``,L.status===`worktrees`&&L.repo?(0,Q.jsxs)(Q.Fragment,{children:[` · `,t.worktreesOf(L.repo).length,` worktree`,t.worktreesOf(L.repo).length===1?``:`s`,`, `,re.length,` of `,B.length,` sessions`]}):(0,Q.jsxs)(Q.Fragment,{children:[` · `,re.length,` of `,B.length]}),re.length===0&&L.status!==`worktrees`&&(L.status===`starred`?` — nothing is starred any more`:L.status===`followup`?` — nothing is flagged any more`:L.status===`shells`?` — no session is running one any more`:` — nothing is in that state any more`)]}),(0,Q.jsxs)(`button`,{className:`filter-bar-clear`,title:`clear the filter — show every live session again`,onClick:()=>R(null),children:[(0,Q.jsx)(X,{size:13}),` clear`]})]}),k.map(({repoName:n,sessions:r})=>(0,Q.jsx)(Hx,{p:e,m:t,repoName:n,sessions:r},`g:${n}`)),i.length===0&&(0,Q.jsx)(Mc,{children:`No repos under host root.`}),ie&&k.length===0&&(0,Q.jsxs)(Mc,{children:[`No session or repo shows “`,V.trim(),`”. The search at the end of the filter looks through what sessions said.`]}),(0,Q.jsx)(nS,{p:e,m:t})]}),v===`external`&&(0,Q.jsxs)(`div`,{className:`list`,children:[(0,Q.jsxs)(`div`,{className:`section section-head`,children:[(0,Q.jsx)(`span`,{children:`External claude processes`}),(0,Q.jsxs)(`button`,{className:`head-act`,title:`back to the sessions this app started`,onClick:()=>y(`home`),children:[(0,Q.jsx)(zm,{size:13}),` local`]})]}),D.length===0&&(0,Q.jsxs)(Mc,{children:["No `claude` running outside ",C.name,`. Started one in a terminal? It shows here.`]}),D.map(e=>(0,Q.jsxs)(bc,{kind:`wrap`,children:[(0,Q.jsxs)(bc,{as:`button`,kind:`grow`,onClick:()=>h(e.cwd,Ws(e.cwd),!0),children:[(0,Q.jsx)(Ad,{className:`mono`,children:Ws(e.cwd)}),(0,Q.jsxs)(qo,{children:[`pid `,e.pid,` · `,(0,Q.jsx)(Xp,{size:12}),` resume here`]})]}),pe(e.cwd)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this repo`,onClick:()=>uf(pe(e.cwd).id),children:(0,Q.jsx)(qp,{size:JS})})]},e.pid)),(0,Q.jsxs)(gs,{children:[`Can't attach to another terminal's TTY directly — "resume here" opens a session here in that directory with `,(0,Q.jsx)(`span`,{className:`mono`,children:`--continue`}),`.`]})]}),(0,Q.jsx)(zS,{p:e,m:t}),de&&(0,Q.jsx)(`div`,{className:`bl-modal-backdrop`,onClick:()=>fe(!1),children:(0,Q.jsxs)(`div`,{className:`bl-modal`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`div`,{className:`bl-modal-title`,children:`Screenshot → which repo?`}),(0,Q.jsx)(`div`,{className:`bl-modal-repo`,children:`The capture is saved into the chosen repo, then opens in the annotator.`}),(0,Q.jsx)(`div`,{className:`list`,children:m.map(e=>(0,Q.jsxs)(bc,{as:`button`,onClick:()=>{fe(!1),ec(e.id)},children:[(0,Q.jsx)(Ad,{children:e.repoName}),Re(e)&&(0,Q.jsx)(qo,{children:Re(e)})]},e.id))}),(0,Q.jsx)(`div`,{className:`bl-modal-actions`,children:(0,Q.jsx)(K,{onClick:()=>fe(!1),children:`Cancel`})})]})}),(0,Q.jsx)(Rb,{}),(0,Q.jsx)(Jc,{})]})}function ZS(e){let{overlay:t,setOverlay:n,closeSheet:r,connRef:i,status:a,setReconnectAsk:o,submitInput:s,holdQueueRef:c,flushOutbox:l,removeQueued:u,pendingSession:d,insertCompose:f,setOutlineJump:p,setView:m,active:h,sessions:g,visibleRepos:_,outbox:v,usage:y,intents:b,launchCore:x,sessionCant:S,pickBackend:C,refreshRepos:w,sendCore:T,sendSeed:E,voice:D,installed:O,canInstall:k,installEvt:A,setCanInstall:j,gitRepoId:M,setGitRepoId:ee,activeRepoId:N,repos:P,backends:F}=e,I=(e,t)=>{n(null),G(`${e} failed to open — ${t}`)},te={...X_(),...x.sheets,slash:()=>h?(0,Q.jsx)(mc,{cwd:h.cwd,backends:F,backend:Wi(F,ni(h))?ni(h):void 0,onClose:()=>n(null),unsupported:Wi(F,ni(h))?void 0:S(h,`slash`)??void 0,onPick:(e,t)=>{t?(n(null),s(h.id,h.cwd,e,`command`)&&G(i.current.status===`open`?`running ${e}`:`${e} queued — it runs when the link is back`)):(f(e),n(null))}}):null,settings:()=>(0,Q.jsx)(yb,{pickBackend:C,voice:D,install:{installed:O,canInstall:k,evt:A,taken:()=>j(!1)},reconnect:{holdRef:c,setReconnectAsk:o,flush:l},redial:()=>i.current.reconnect(),pickShotRepo:dx}),git:()=>{if(!(M??N))return null;let e=P.find(e=>e.id===(M??N));return(0,Q.jsx)(Tc,{repoId:M??N,onAskAgent:e?t=>T.openSend(kd(t,e)):void 0,onBrowse:()=>wa(M??N,`git`),onClose:()=>{ee(null),n(null),w()}})},outline:()=>h?(0,Q.jsx)(ml,{sessionId:h.id,title:h.title,onJump:e=>{Y(`action:outline.jump`),p({n:e,key:Date.now()}),m(!0),n(null)},onClose:()=>n(null)}):null,send:()=>E?(0,Q.jsx)(Cb,{send:T,sessions:g,pendingSession:d,visibleRepos:_,outbox:v,online:a===`open`,usage:y,intents:b,removeQueued:u,backends:F,launch:x.launch,closeSheet:r,onAttach:(e,t)=>xc(t,e),onAnnotate:(e,t)=>uc(t,e,`send`),onBrowseRepoFiles:mn}):null},L=t?te[t]?.()??null:null;return L?(0,Q.jsx)(sy,{name:t??``,onFail:I,children:L},t??``):null}function QS(e){let{connRef:t,setLaunch:n,setHiddenRepoIds:r}=e;(0,Z.useEffect)(()=>(tc(e=>t.current.send(e)),Hu(e=>{switch(e){case W.launch:n(Kl());break;case W.hiddenRepos:r(sd());break;case W.repoColors:cr()}})),[])}function $S(e){let{repos:t,focusRepo:n,outbox:r,bl:i}=e,[a,o]=(0,Z.useState)(sd),s=(0,Z.useMemo)(()=>fr(t.filter(e=>!a.has(e.id)&&(!n||e.repoName===n))),[t,a,n]),c=(0,Z.useMemo)(()=>fr(t.filter(e=>a.has(e.id)&&(!n||e.repoName===n))),[t,a,n]),l=(0,Z.useMemo)(()=>new Set(c.map(e=>e.worktreePath)),[c]),u=(0,Z.useMemo)(()=>{let e=new Map;for(let t of r){if(!dr(t)||!t.cwd||t.status===`failed`)continue;let n=e.get(t.cwd);e.set(t.cwd,{status:n?.status===`pending`?`pending`:t.status,n:(n?.n??0)+1})}return e},[r]),d=(0,Z.useMemo)(()=>n?new Set(t.filter(e=>e.repoName===n).map(e=>e.worktreePath)):null,[t,n]),f=e=>!d||d.has(e)||Ws(e)===n,p=(0,Z.useCallback)(e=>!l.has(e)&&(!d||d.has(e)||Ws(e)===n),[l,d,n]),m=(0,Z.useMemo)(()=>i.items.filter(e=>p(e.repoDir)),[i.items,p]);function h(e){o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),pt(W.hiddenRepos,[...n]),n})}return{hiddenRepoIds:a,setHiddenRepoIds:o,toggleHideRepo:h,visibleRepos:s,hiddenRepos:c,hiddenRepoPaths:l,openingCwds:u,focusPaths:d,cwdInFocus:f,cwdVisible:p,visibleBacklogItems:m}}function eC(e,t){let{setOverlay:n,activeRepoId:r,active:i,readMode:a,fireReader:o,send:s,geomRef:c}=t,l=e=>tC(e,t);switch(Y(`toolbar:${e}`),e){case`model`:n(`model`);break;case`cmd`:n(`slash`);break;case`diff`:r?n(`git`):G(`not a known repo`);break;case`ctx`:l(`/context`);break;case`usage`:l(`/usage`);break;case`teleport`:l(`/teleport`);break;case`remote`:l(`/remote-control`);break;case`tasks`:l(`/tasks`);break;case`backlog`:n(`backlog`);break;case`history`:n(`history`);break;case`outline`:if(!i){G(`no active session`);break}a?o(`outline`):n(`outline`);break;case`find`:if(!i){G(`no active session`);break}a?o(`find`):Jr(i.id);break;case`refresh`:if(!i){G(`no active session`);break}a?o(`refresh`):G(`refresh is the reader's — the terminal is live`);break;case`scrollback`:It();break;case`fork`:if(!i)break;s({t:`session.fork`,id:i.id,cols:c.current.cols,rows:c.current.rows}),G(`forking conversation into a new session…`);break;case`companion`:if(!i){G(`no active session`);break}t.openCompanionShell(i);break;default:W_(e)}}function tC(e,t){let{active:n,submitInput:r}=t;n&&(Y(`action:slash:${e.split(/\s/)[0].replace(/[^a-zA-Z0-9-]/g,``)||`other`}`),r(n.id,n.cwd,e,`command`))}var nC=1e4;function rC(e){let{refreshRepos:t,activeId:n,repos:r,overlay:i}=e,a=r.some(e=>e.gitRunning||e.buildRunning);(0,Z.useEffect)(()=>{if(n||!a)return;let e=setInterval(t,nC);return()=>clearInterval(e)},[n,a]);let o=(0,Z.useRef)(i);(0,Z.useEffect)(()=>{o.current===`git`&&i!==`git`&&t(),o.current=i},[i])}function iC(e){let{status:t,refreshRepos:n,activeId:r,active:i,wantNavRef:a,firedIdRef:o,bl:s,sessions:c,attach:l,repos:u,overlay:d}=e;(0,Z.useEffect)(()=>{n()},[t]),(0,Z.useEffect)(()=>{r&&n()},[r,i?.idle]),(0,Z.useEffect)(()=>{r||n()},[r]),rC({refreshRepos:n,activeId:r,repos:u,overlay:d}),(0,Z.useEffect)(()=>{if(r)return;let e=()=>{document.visibilityState===`visible`&&n()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[r]),(0,Z.useEffect)(()=>{if(!a.current||!o.current)return;let e=s.items.find(e=>e.id===o.current);if(e?.status===`running`&&e.sessionId){let t=c.find(t=>t.id===e.sessionId);t&&(a.current=!1,o.current=null,l(t))}},[s.items,c])}function aC(){let e=(0,Z.useRef)(null),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(()=>Wy());return(0,Z.useEffect)(()=>{let t=t=>{t.preventDefault(),e.current=t,n(!0)},r=()=>{e.current=null,n(!1),i(!0),G(`installed — open it from your home screen`)};return window.addEventListener(`beforeinstallprompt`,t),window.addEventListener(`appinstalled`,r),()=>{window.removeEventListener(`beforeinstallprompt`,t),window.removeEventListener(`appinstalled`,r)}},[]),{installEvt:e,canInstall:t,setCanInstall:n,installed:r}}function oC(e){let{sessions:t,backends:n,sessionRepoName:r}=e,i=q(`agentWarn`),a=(0,Z.useRef)(`ok`);(0,Z.useEffect)(()=>{let e=t.map(e=>{let t=r(e);return{id:e.id,label:gf(e,t),repo:t,working:!e.idle&&tr(e,n)===`coding`,agents:e.running?(e.agents??[]).map(e=>({what:e.what,model:e.model,startedAt:e.startedAt})):[]}}),o=Ed(e.map(e=>({working:e.working,agents:e.agents.length}))),s=gc(o.total,i);fs(o,e,s),af(a.current,s)&&G(Uo(o,s,i)),a.current=s},[t,n,i])}Xl(W.tabOpensShared,(e,t)=>li(e,t,Date.now())),Hu(Vr,[W.tabOrderShared,W.tabOpensShared]),ub();function sC(e){let{tabsOn:t,sessions:n,sessionRepoName:r,activeId:i,repos:a,attach:o,closeSession:s,backends:c}=e;(0,Z.useEffect)(()=>{t&&jn(n.map(e=>{let t=r(e);return{id:e.id,label:gf(e,t),repo:t,status:tr(e,c),createdAt:e.createdAt,...e.companionOf?{companionOf:e.companionOf}:{}}}),i)},[n,i,a,c,t]),(0,Z.useEffect)(()=>{let e=e=>e.detail?.id??``,t=t=>{let r=n.find(n=>n.id===e(t));r&&o(r)},r=t=>{let r=n.find(n=>n.id===e(t));r&&s(r)};return window.addEventListener(sl,t),window.addEventListener(kt,r),()=>{window.removeEventListener(sl,t),window.removeEventListener(kt,r)}}),oC({sessions:n,backends:c,sessionRepoName:r})}function cC(e){return e.startsWith(`plugin:`)&&e.length>7?{plugin:e.slice(7)}:{sessionId:e}}function lC(e){let{reposRef:t,initRoute:n,sessions:r,attach:i,setOverlay:a}=e;(0,Z.useEffect)(()=>{Ot(e=>{let n=t.current.find(t=>t.id===e);return n?{repoName:n.repoName,repoDir:n.worktreePath}:void 0})},[]),(0,Z.useEffect)(()=>{n.file&&!Xi(n.file.relPath)&&Yc(n.file),n.plugin&&L_(n.plugin)},[]),(0,Z.useEffect)(()=>{if(!(`serviceWorker`in navigator))return;let e=e=>{if(e.data?.type===`open-session`){let t=r.find(t=>t.id===e.data.sessionId);t&&i(t)}else if(!Zr(e.data)){if(e.data?.type===`open-pulls`)a(`pull`);else if(e.data?.type===`download-file`&&e.data.file){let t=e.data.file;Xi(t.relPath)?nn(t):Yc(t)}else if(e.data?.type===`open-image`&&e.data.image){let t=r.find(t=>t.id===e.data.sessionId);t&&i(t),ri(e.data.image,e.data.sessionId)}else e.data?.type===`open-plugin`&&typeof e.data.plugin==`string`&&L_(e.data.plugin)}};return navigator.serviceWorker.addEventListener(`message`,e),()=>navigator.serviceWorker.removeEventListener(`message`,e)},[r]);let o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(null);(0,Z.useEffect)(()=>Qs(e=>{let t=cC(e);`plugin`in t?L_(t.plugin):(o.current=e,c(e))}),[]),(0,Z.useEffect)(()=>{let e=o.current;if(!e)return;let t=r.find(t=>t.id===e);t&&(o.current=null,c(null),i(t))},[r,s])}function uC(e){let{outbox:t,activityFiled:n,activityConfirmedDone:r,allBufsRef:i}=e,a=t.filter(e=>e.status===`failed`&&!n.has(`queue:${e.ackId}`)&&!r.has(`queue:${e.ackId}`)).length;(0,Z.useEffect)(()=>{zn(a)},[a]),(0,Z.useEffect)(()=>(cv(()=>Fl()||i.current.size>0),()=>cv(null)),[])}function dC(){let[e,t]=(0,Z.useState)(()=>iu(W.snapSessions,[])),[n,r]=(0,Z.useState)(()=>iu(W.snapRecent,[])),[i,a]=(0,Z.useState)(()=>iu(W.snapClosed,[])),[o,s]=(0,Z.useState)(()=>iu(W.snapRepos,[])),[c,l]=(0,Z.useState)(Uc),[u,d]=(0,Z.useState)(0),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null);return{sessionsRaw:e,setSessions:t,recent:n,setRecent:r,closed:i,setClosed:a,repos:o,setRepos:s,reposAt:c,setReposAt:l,reposFailAt:u,setReposFailAt:d,intents:f,setIntents:p,backends:m,setBackends:h,update:g,setUpdate:_,meter:v,setMeter:y,updateResultSeenRef:(0,Z.useRef)(0)}}function fC(e,t,n){return t.trim()?e.filter(e=>!n(e)):[...e]}function pC(e){if(!e)return[];let t=[];for(let n of Array.from(e.items??[])){if(n.kind!==`file`)continue;let e=n.getAsFile();e&&t.push(e)}return t.length?t:Array.from(e.files??[])}var mC=e=>!!e&&Array.from(e.types??[]).includes(`Files`);function hC(e,t){let n=$t(),r=n.world.activeRepo?.id;r?Fl()?Vs(e).then(r=>{r?(n.say.track(`action:attach.${t}.repeat`),n.say.toast(`That picture is already open for marking — not added twice`)):gC(e,t)}):(n.say.track(`action:attach.${t}`),n.files.attachFiles(e,r)):n.say.toast(`No repo for this session — files have nowhere to go`)}function gC(e,t){let n=$t(),r=e.filter(Wl).length,i=r===e.length?r===1?`this picture`:`these ${r} pictures`:e.length===1?`this file`:`these ${e.length} files`;n.say.confirm({title:`Append ${i}?`,lines:[r?`Pictures are marked next, after the one on screen — its marks stay.`:`Uploaded into the inbox, its path added to the message.`],confirmLabel:`Append`,cancelLabel:`Leave it`,tone:`info`}).then(r=>{r&&(n.say.track(`action:attach.${t}.append`),Nc(e))})}function _C(){let[e,t]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let e=e=>{let t=fC(pC(e.clipboardData),e.clipboardData?.getData(`text/plain`)??``,Wl),n=e.target,r=$t();mi({files:t.length,editable:!!n&&(n.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(n.tagName)),inCompose:!!n?.closest?.(`.compose, .ann-prompt`),sheet:r.nav.overlay!=null,annotating:Fl(),repoId:r.world.activeRepo?.id??null,handled:e.defaultPrevented})!==`ignore`&&(e.preventDefault(),hC(t,`paste`))},t=e=>{mC(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`))};return document.addEventListener(`paste`,e),document.addEventListener(`dragover`,t),document.addEventListener(`drop`,t),()=>{document.removeEventListener(`paste`,e),document.removeEventListener(`dragover`,t),document.removeEventListener(`drop`,t)}},[]),{dragOver:e,dropProps:{onDragOver(e){mC(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,t(!0))},onDragLeave(e){e.currentTarget.contains(e.relatedTarget)||t(!1)},onDrop(e){if(!mC(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),t(!1);let n=pC(e.dataTransfer);n.length&&hC(n,`drop`)}}}}var vC=16,$=e=>e.preventDefault();function yC(){try{return window.matchMedia?.(`(pointer: coarse)`).matches??!1}catch{return!1}}function bC(e){let{api:t,active:n,sessions:r,outbox:i,online:a,repoForCwd:o,activeRepoId:s,pickImageFor:c,pickFileFor:l,visibleBacklogItems:u,setOverlay:d}=e,{uploading:f,parking:p,upProg:m,uploadPending:h,uploadRowLinger:g,cancelUploads:_}=e.uploads,{compose:v,setCompose:y,composeRef:b,cmdHistory:x,histIdx:S,setHistIdx:C,clearArmed:w,setClearArmed:T,setComposeFocused:E,snippetOpen:D,setSnippetOpen:O,sendMode:k,setSendMode:A,sendWhere:j,setSendWhere:M,sendWhereSid:ee,setSendWhereSid:N,sendMenu:P,setSendMenu:F,cliMode:I,enterSends:te,voice:L,aimedSession:R,stepHistory:z,clearCompose:ne,appendSnippet:re,chord:B,toggleCliMode:V,onPipeInput:H,flushPipe:ie,onPipeKey:ae,onComposeKey:oe,aimHere:U,sendCompose:se,openComposeSend:ce,keepOnPad:le,noteSendAim:ue,secretAskLine:de,secret:fe,setSecret:pe,secretShown:me,setSecretShown:he,dismissSecret:ge,sendSecret:_e,secretFillContext:ve}=t,ye=I||no(null,n.backend),be=Ll(),{dragOver:xe,dropProps:Se}=_C();(0,Z.useLayoutEffect)(()=>{t.growCompose()},[I]);let Ce=n?.id,we=yh(Ce);(0,Z.useEffect)(()=>{gh(Ce)&&!yC()&&b.current?.focus()},[Ce,b]);let Te=Pi();return(0,Z.useEffect)(()=>{if(!Te||!Qd()||yC()||I)return;let e=b.current;if(e){e.focus();try{e.setSelectionRange(e.value.length,e.value.length)}catch{}}},[Te,b,I]),(0,Q.jsxs)(Q.Fragment,{children:[n&&!we&&(()=>{let e=gd(j,{repoName:o(n.cwd)?.repoName??Ws(n.cwd),sessionName:R?Pe(R):null});return e?(0,Q.jsxs)(`div`,{className:`compose-aim`,children:[(0,Q.jsxs)(`span`,{className:`compose-aim-what`,children:[(0,Q.jsx)(Xp,{size:12}),` `,e]}),(0,Q.jsxs)(K,{onPointerDown:$,title:`send to ${_c(`this`)} instead — the conversation on screen`,onClick:()=>{Y(`action:compose.where.here`),U()},children:[(0,Q.jsx)(Am,{size:12}),` `,`aim it here`]})]}):null})(),(0,Q.jsxs)(`div`,{className:`compose${xe?` drop-over`:``}`,...Se,children:[(h||g)&&(0,Q.jsxs)(`div`,{className:`upload-progress`,title:`images upload in the background; a prompt naming one is delivered after it lands`,children:[(0,Q.jsxs)(`div`,{className:`upload-progress-line`,children:[h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(um,{size:12,className:`spin`}),` `,f,p>0?` · still reading it`:``]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bm,{size:12}),` uploads done`]}),h&&(0,Q.jsxs)(K,{className:`upload-cancel`,onPointerDown:$,onClick:_,title:`cancel uploads`,children:[(0,Q.jsx)(X,{size:12}),` cancel`]})]}),h&&v.trim()&&(0,Q.jsxs)(`div`,{className:`upload-acts`,children:[(0,Q.jsx)(`span`,{className:`upload-acts-what`,children:p>0?`Send goes as soon as the picture is readable`:`your prompt is ready to go — it is delivered after the picture lands`}),(0,Q.jsxs)(K,{onPointerDown:$,"data-hint":`queue.sendnow`,title:`post it now — if it names a picture still moving, the queue still delivers it after the bytes`,onClick:()=>{Y(`action:upload.sendnow`),se(`now`)},children:[(0,Q.jsx)(Dm,{size:14}),` send now`]}),(0,Q.jsxs)(K,{onPointerDown:$,"data-hint":`queue.hold`,title:`park it until this session is free, instead of typing it in mid-turn`,onClick:()=>{Y(`action:upload.hold`),se(`idle`)},children:[(0,Q.jsx)(Zf,{size:14}),` let it wait`]})]}),(0,Q.jsx)(`div`,{className:`upload-bar`,children:(0,Q.jsx)(`div`,{className:`upload-bar-fill${m?.waiting?` waiting`:``}`,style:{width:`${m&&m.total>0?m.pct:0}%`}})})]}),n&&(0,Q.jsx)(Ka,{compact:!0,debounceMs:700,text:v,repoId:o(n.cwd)?.id??null,outbox:i,online:a,onRemove:e=>y(t=>Kn(t,e))}),P&&!I&&(0,Q.jsxs)(`div`,{className:`row-more send-more`,children:[!we&&(0,Q.jsxs)(`div`,{className:`send-where`,children:[(0,Q.jsx)(`span`,{className:`send-where-lead`,children:`Runs in`}),oc().map(e=>(0,Q.jsxs)(`button`,{className:`more-act${j===e.key?` on`:``}`,onPointerDown:$,title:e.title,onClick:()=>{Y(`action:compose.where.${e.key}`),M(e.key),e.key!==`other`&&N(null),ue(n?.cwd,{where:e.key})},children:[e.key===`new`?(0,Q.jsx)(pp,{size:vC}):e.key===`other`?(0,Q.jsx)(Xp,{size:vC}):(0,Q.jsx)(Am,{size:vC}),e.label]},e.key))]}),j===`other`&&(()=>{let e=r.filter(e=>e.running&&e.id!==n?.id);return e.length?(0,Q.jsx)(`div`,{className:`send-where-pick`,children:e.map(e=>(0,Q.jsxs)(`button`,{className:`row${ee===e.id?` sched-on`:``}`,onPointerDown:$,title:`send to ${Pe(e)}`,onClick:()=>{Y(`action:compose.where.pick`),N(e.id)},children:[(0,Q.jsx)(Ad,{children:e.title}),(0,Q.jsx)(Gt,{s:e}),(0,Q.jsx)(qo,{children:e.turnActive?`working`:`idle`})]},e.id))}):(0,Q.jsx)(`div`,{className:`send-where-pick`,children:(0,Q.jsxs)(Mc,{children:[`No other session is open — `,(0,Q.jsx)(`em`,{children:`a new session`}),` opens one.`]})})})(),Ls().map(e=>(0,Q.jsxs)(`button`,{className:`more-act${e.mode&&k===e.mode?` on`:``}`,onPointerDown:$,title:e.title,onClick:()=>{F(!1),e.mode?A(e.mode):e.key===`pad`?le():ce()},children:[e.icon===`hourglass`?(0,Q.jsx)(Zf,{size:vC}):e.icon===`elsewhere`?(0,Q.jsx)(jm,{size:vC}):e.icon===`pad`?(0,Q.jsx)(Op,{size:vC}):(0,Q.jsx)(Am,{size:vC}),e.label]},e.key)),(0,Q.jsxs)(`button`,{className:`more-act more-close`,onPointerDown:$,title:`close this menu — nothing is sent and the mode stays as it is`,onClick:()=>F(!1),children:[(0,Q.jsx)(X,{size:vC}),` close`]})]}),D&&(0,Q.jsxs)(`div`,{className:`snippet-pop`,children:[(0,Q.jsxs)(`div`,{className:`snippet-pop-head`,children:[(0,Q.jsx)(`span`,{children:`Snippets`}),(0,Q.jsxs)(K,{onPointerDown:$,onClick:()=>{O(!1),d(`snippets`)},title:`Manage snippets`,children:[(0,Q.jsx)(lp,{size:14}),` manage`]}),(0,Q.jsx)(K,{onPointerDown:$,onClick:()=>O(!1),title:`Close`,children:(0,Q.jsx)(X,{size:14})})]}),(0,Q.jsxs)(`div`,{className:`snippet-pop-list`,children:[be.length===0&&(0,Q.jsx)(Mc,{children:`No snippets yet — tap “manage” to add one.`}),be.map(e=>(0,Q.jsxs)(`button`,{className:`snippet-pop-item`,onPointerDown:$,title:e.text,onClick:()=>{Y(`action:snippet.insert`),re(e)},children:[(0,Q.jsx)(`span`,{className:`snippet-pop-title`,children:e.title}),(0,Q.jsx)(`span`,{className:`snippet-pop-preview`,children:e.text.replace(/\s+/g,` `).trim()})]},e.id))]})]}),de?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`secret-ask`,children:[(0,Q.jsx)(Mf,{size:12}),`asked on screen: `,(0,Q.jsx)(`code`,{children:de}),` — typed straight in, never kept as a draft or in history`]}),(0,Q.jsxs)(`div`,{className:`secret-row`,children:[(0,Q.jsx)(`input`,{type:me?`text`:`password`,value:fe,onChange:e=>pe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),_e())},placeholder:`password`,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,spellCheck:!1,enterKeyHint:`send`,onFocus:()=>E(!0),onBlur:()=>E(!1)}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>he(e=>!e),"aria-pressed":me,title:me?`Hide what is typed`:`Show what is typed`,children:me?(0,Q.jsx)(Sp,{size:18}):(0,Q.jsx)(Um,{size:18})})]}),(0,Q.jsxs)(`div`,{className:`compose-bar`,children:[(0,Q.jsxs)(K,{className:`secret-other`,onPointerDown:$,onClick:ge,title:`Back to the message box — this line is not asking for a password`,children:[(0,Q.jsx)(X,{size:14}),` not a password`]}),(()=>{let e=ve();return e?z_(e):[]})().map(e=>(0,Q.jsxs)(K,{onPointerDown:$,title:e.unavailable??e.label,onClick:()=>{e.unavailable?G(e.unavailable):(Y(`action:compose.secret.fill`),e.open())},children:[(0,Q.jsx)(e.icon,{size:14}),` `,e.label]},e.key)),(0,Q.jsx)(`div`,{className:`send-split`,children:(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:_e,title:`Type it into the prompt and press Enter — nothing is kept`,children:[(0,Q.jsx)(Mf,{size:vC}),` Send`]})})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{ref:b,className:I?`pipe`:void 0,"data-compose":``,value:I?Ug:v,onChange:I?H:e=>{y(e.target.value),C(-1),T(!1)},onCompositionEnd:I?e=>ie(e.currentTarget):void 0,placeholder:`Message or /command…`,rows:2,autoCapitalize:ye?`off`:void 0,autoCorrect:ye?`off`:void 0,spellCheck:!ye&&void 0,enterKeyHint:I?`enter`:te?`send`:`enter`,onKeyDown:I?ae:oe,onFocus:()=>E(!0),onBlur:()=>E(!1)}),I?(0,Q.jsxs)(`div`,{className:`compose-bar cli-bar`,children:[(0,Q.jsxs)(`span`,{className:`cli-note${a?``:` warn`}`,children:[(0,Q.jsx)(Rf,{size:13}),B.armed?` ${B.heldName} held — the next key you type or tap goes with it${a?``:` (link is down: it is dropped, not held)`}`:a?` keys go straight to the session — nothing is queued or confirmed`:` link is down — these keystrokes are dropped, not held`]}),B.armed?(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:B.clear,title:`Let go of the held keys — your draft comes back`,children:[(0,Q.jsx)(X,{size:vC}),` let go`]}):(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:V,title:`Back to composing — messages queue, survive a dead link and are confirmed on the host`,children:[(0,Q.jsx)(X,{size:vC}),` leave CLI`]})]}):(0,Q.jsxs)(`div`,{className:`compose-bar`,children:[(0,Q.jsxs)(`div`,{className:`compose-scroll`,children:[(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>x.length===0?G(`nothing sent yet — no earlier message to recall`):z(-1),title:`Previous sent command`,children:(0,Q.jsx)(Uf,{size:18})}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>S===-1?G(`this is your draft — there is nothing newer`):z(1),title:`Next sent command`,children:(0,Q.jsx)(kp,{size:18})}),(0,Q.jsx)(`button`,{className:`mic ${w?`on`:``}`,onPointerDown:$,onClick:()=>v?ne():G(`the message box is already empty`),title:w?`Tap again to clear`:`Clear message box`,children:(0,Q.jsx)(Yp,{size:18})}),(0,Q.jsx)(Ar,{voice:L,onPointerDown:$}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>s?c(s):G(`not a known repo`),title:`Send image to this repo`,children:(0,Q.jsx)(qp,{size:18})}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>s?l(s):G(`not a known repo`),title:`Attach a file of any kind (PDF, doc, zip, audio…) to this repo — images open in the annotator`,children:(0,Q.jsx)($f,{size:18})}),(0,Q.jsx)(`button`,{className:`mic ${D?`on`:``}`,onPointerDown:$,onClick:()=>O(e=>!e),title:`Insert a saved snippet`,children:(0,Q.jsx)(Lf,{size:18})}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>d(`pad`),title:`Prompt pad — park this thought without picking a target yet`,children:(0,Q.jsx)(Op,{size:18})}),(()=>{let e=(n?u.filter(e=>e.repoDir===n.cwd):u).filter(e=>!un(e));return(0,Q.jsxs)(`button`,{className:`mic show-backlog`,onPointerDown:$,onClick:()=>Gi(n?.cwd),title:n?`Backlog for this repo — ${e.length} item${e.length===1?``:`s`}`:`Show backlog`,children:[(0,Q.jsx)(zm,{size:18}),e.length>0&&(0,Q.jsx)(`span`,{className:`mic-badge`,children:e.length})]})})()]}),(0,Q.jsxs)(`div`,{className:`send-split`,children:[(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:()=>se(),title:fu(k,j,R?Pe(R):null),children:[k===`idle`?(0,Q.jsx)(Zf,{size:vC}):(0,Q.jsx)(Am,{size:vC}),` `,jl(k)]}),(0,Q.jsx)(`button`,{className:`send send-mode${P?` on`:``}`,onPointerDown:$,onClick:()=>F(e=>!e),"aria-expanded":P,"data-hint":`compose.options`,title:`Change what Send does — which session it runs in, and now or when it's free — or send it somewhere else or later`,children:(0,Q.jsx)(jm,{size:14})})]})]})]})]})]})}var xC=14;function SC({view:e,onSendNow:t,onPastBudget:n,onHold:r,onOpenQueue:i,onOpenBacklog:a,keepFocus:o,editableText:s,onEdit:c,onCancel:l}){let[u,d]=(0,Z.useState)(null);if(u)return(0,Q.jsx)(`div`,{className:`nextp nextp-editing`,children:(0,Q.jsxs)(`div`,{className:`form`,style:{width:`100%`},children:[(0,Q.jsx)(Vn,{inline:!0,rows:3,prompts:[u.text],autoFocus:!0,onChange:e=>d({...u,text:e[0]??``}),placeholder:`the next prompt…`}),!u.text.trim()&&(0,Q.jsx)(gs,{children:`Nothing to save — type the prompt, or cancel to keep it as it was.`}),(0,Q.jsxs)(bc,{children:[u.text.trim()&&(0,Q.jsx)(`button`,{className:`send`,onClick:()=>{let e=u.text.trim();e&&c(u.id,u.holder,e)&&d(null)},children:`Save`}),(0,Q.jsx)(K,{onClick:()=>d(null),children:`Cancel`})]})]})});if(!e)return null;let f=s(e.id,e.holder);return(0,Q.jsx)(nc,{slot:`next-prompt`,stowKey:`${e.holder}:${e.id}`,label:`next prompt`,detail:e.behind>0?`+${e.behind}`:void 0,icon:e.held?Zf:Dm,children:(0,Q.jsxs)(`div`,{className:`nextp${e.held?` nextp-held`:``}`,children:[(0,Q.jsx)(`span`,{className:`nextp-mark`,children:e.held?(0,Q.jsx)(Zf,{size:xC}):(0,Q.jsx)(Dm,{size:xC})}),(0,Q.jsxs)(`span`,{className:`nextp-body`,children:[(0,Q.jsxs)(`span`,{className:`nextp-words`,children:[`next: `,e.words]}),e.tie&&(0,Q.jsx)(`span`,{className:`nextp-why nextp-tie`,children:e.tie}),(0,Q.jsxs)(`span`,{className:`nextp-why`,children:[e.why,e.behind>0?` · ${e.behind} more behind it`:``]}),e.held&&!e.wall&&(0,Q.jsx)(`span`,{className:`nextp-why`,children:$a(!1)}),e.budgetHeld&&!e.wall&&(0,Q.jsx)(`span`,{className:`nextp-why`,children:`past the budget: it still waits for this turn to end`})]}),e.held?e.wall?(0,Q.jsx)(`span`,{className:`nextp-cant`,children:e.wall}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(K,{"data-hint":`queue.sendnow`,onPointerDown:o,title:$a(!1),onClick:()=>t(e.id,e.holder),children:[(0,Q.jsx)(Dm,{size:xC}),` send now`]}),e.budgetHeld&&(0,Q.jsxs)(K,{onPointerDown:o,title:`lifts the usage budget for this prompt only — it still goes in when this session is free`,onClick:()=>n(e.id),children:[(0,Q.jsx)(Wp,{size:xC}),` `,$n(1)]})]}):(0,Q.jsxs)(K,{"data-hint":`queue.hold`,onPointerDown:o,title:`hand it to the desktop and let it go in when this session is free, instead of typing it in mid-turn`,onClick:()=>r(e.id),children:[(0,Q.jsx)(Zf,{size:xC}),` when it's free`]}),f!=null&&(0,Q.jsxs)(K,{onPointerDown:o,title:`rewrite this prompt before it goes in`,onClick:()=>d({id:e.id,holder:e.holder,text:f}),children:[(0,Q.jsx)(lp,{size:xC}),` edit`]}),f!=null&&(0,Q.jsxs)(K,{onPointerDown:o,title:`don't send it — the words are kept on the pad`,onClick:()=>l(e.id,e.holder),children:[(0,Q.jsx)(X,{size:xC}),` cancel`]}),e.holder===`desktop`?(0,Q.jsxs)(K,{onPointerDown:o,title:`this repo's waiting work on the desktop`,onClick:a,children:[(0,Q.jsx)(zm,{size:xC}),` backlog`]}):(0,Q.jsxs)(K,{onPointerDown:o,title:`the whole queue for every session`,onClick:i,children:[(0,Q.jsx)(Hm,{size:xC}),` queue`]}),(0,Q.jsx)(fd,{className:`key`})]})})}function CC(e,t){return t?`timed · ${e} · tied to this conversation — it goes into this session; close it before then and the desktop reopens this conversation and sends it there`:`timed · ${e} · tied to this session — keep it open until then; closed, it waits with nowhere to go`}function wC(e){let t=e.trim().replace(/\s+/g,` `);return t.length>56?`${t.slice(0,56)}…`:t}function TC(e,t){let n=t(e).trim().replace(/\s+/g,` `);return n?wC(n):e.mode===`upload`?`a file`:`an action`}function EC(e){if(!e.sessionId)return null;let t=e.entries.filter(t=>t.sessionId===e.sessionId),n=t.filter(e=>e.status===`queued`),r=n[0],i=e.pinned??[];if(!r&&!i.length)return null;let a=!!r&&t.slice(0,t.indexOf(r)).some(e=>e.mode===`upload`&&e.status!==`failed`);if(!e.busy&&!e.wall&&e.online&&!a&&(r||!i.length))return null;if(!r){let t=i[0],n=e.wall??t.why??(e.busy?`waits for this turn to end`:`the desktop runs it when this session is free`);return{holder:`desktop`,id:t.id,words:wC(t.words),held:!0,behind:i.length-1,why:!e.online&&e.asOf?`${n} · as of ${e.asOf}`:n,tie:t.tie??null,budgetHeld:!!t.budgetHeld&&e.online,wall:e.wall??(e.online?null:`no connection — the desktop is holding it and runs it when this session is free`)}}let o=!!r.holdUntilIdle,s=e.wall?e.wall:e.online?a?`waits for the picture it names to finish uploading`:o?`waits for this turn to end`:`goes in as soon as the queue reaches it`:`waits for the link`;return{holder:`phone`,id:r.ackId,words:TC(r,e.prose),held:o,behind:n.length-1,why:s,tie:null,budgetHeld:!1,wall:e.wall??(e.online?a?`the picture it names is still uploading — it goes the moment the bytes land`:null:`no connection — it goes the moment the link is back`)}}function DC(e){let{active:t,outboxRef:n,isPendingId:r,sendQueuedNow:i,editQueued:a,toggleHoldQueued:o,handToDesktop:s,liveSend:c,setOverlay:l}=e,{items:u,waiting:d,snapAt:f}=Ct(),p=new Map(e.intents.map(e=>[e.id,e])),m=Date.now(),h=(t,r)=>{if(r===`phone`){let e=n.current.find(e=>e.ackId===t);return e&&Ur(e)?e.text:null}let i=u.find(e=>e.id===t);return i&&i.status===`queued`&&e.online?i.text:null};return(0,Q.jsx)(SC,{view:EC({entries:e.outbox,sessionId:t.id,busy:t.hooked?!!t.turnActive:!!t.running&&!t.idle,online:e.online,wall:e.holdWall(t.id),prose:Ai,pinned:u.filter(e=>e.targetSessionId===t.id&&e.autoFire&&e.status===`queued`).sort((e,t)=>e.order-t.order).map(e=>({id:e.id,words:e.text,why:d[e.id],budgetHeld:(()=>{let t=p.get(e.id);return!!t&&Ha(t,m,p)})(),tie:e.at?CC(e.at.nextAt==null?A(e.at.rule):`${wc(e.at.nextAt)} (${A(e.at.rule)})`,!!e.reopensConv):void 0})),asOf:e.online?void 0:f?Dl(f):void 0}),onSendNow:(e,t)=>{Y(`action:nextprompt.sendnow`),t===`phone`?i(e):c({t:`backlog.fire`,id:e},`running it now…`,xn)},editableText:h,onEdit:(n,r,i)=>{if(Y(`action:nextprompt.edit`),r===`desktop`&&!e.online)return G(xn),!1;if(h(n,r)==null){let e=jt({id:Mr(),text:i,ts:Date.now(),...t.cwd?{cwd:t.cwd}:{}});return e?(G(e),!1):(G(`it already went in — your edit is kept on the pad`),!0)}return r===`phone`?(a(n,i),G(`edited`),!0):c({t:`backlog.update`,id:n,text:i},`edited`,xn)},onCancel:(n,r)=>{Y(`action:nextprompt.cancel`);let i=h(n,r);if(i==null){G(r===`desktop`&&!e.online?xn:`it already went in`);return}let a=jt({id:Mr(),text:i,ts:Date.now(),...t.cwd?{cwd:t.cwd}:{}});a?G(a):r===`phone`?(e.removeQueued(n),G(`canceled — the words are kept on the pad`)):c({t:`backlog.remove`,id:n},`canceled — the words are kept on the pad`,xn)},onPastBudget:e=>{Y(`action:nextprompt.pastbudget`),c({t:`intent.waive`,id:e,rung:`budget`,on:!0},ja(1),xn)},onHold:e=>{Y(`action:nextprompt.hold`);let t=n.current.find(t=>t.ackId===e);!t||r(t.sessionId)?(o(e),G(`held on this phone — it goes in when this session opens. Leave the app open`)):s(e)},onOpenQueue:()=>{Y(`overlay:queue`),l(`queue`)},onOpenBacklog:()=>{Y(`overlay:backlog`),Gi(t.cwd)},keepFocus:$})}function OC(e,t,n){if(n.pending)return null;let r=a(e,t);return r?.to===`cli`?{on:`shell`,cli:r.target}:r?.to===`shell`?{on:`cli`,shell:r.target}:null}function kC(e,t,n,r){if(n.pending)return null;let i=OC(e,t,n),a;if(i?.on===`cli`)a=[{kind:`cli`,on:!0},{kind:`shell`,on:!1,target:i.shell}];else if(i?.on===`shell`)a=[{kind:`cli`,on:!1,target:i.cli},{kind:`shell`,on:!0}];else if(r.length)a=[{kind:n.shell||e.companionOf?`shell`:`cli`,on:!0}];else return null;return[...a,...r.map(e=>({kind:`view`,view:e}))]}var AC=ms((()=>{let e=it(W.headerViews,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]})());function jC(e){AC.set(e),pt(W.headerViews,e)}function MC(e){let t=AC.get();t.includes(e)||jC([...t,e])}function NC(e){let t=AC.get();t.includes(e)&&jC(t.filter(t=>t!==e))}function PC(){return Yd(AC)}var FC=d_(Vo,$t);function IC(e,t){return FC.item(e,t)}var LC=16;function RC(e,t,n=!1){let{active:r,pending:i,status:a,activeRepo:o,toolbarCfg:s,pendingStars:c,toggleStar:l,pendingFollowUps:u,toggleFollowUp:d,setOverlay:f,runToolbar:p,backends:m}=e;if(!n&&s.hidden.includes(t.id))return null;let h=!n,g=()=>{n||hc(t.id)},_=no(m,r?.backend);if(t.id===`model`&&_||t.id===`logins`&&!_||t.id===`companion`&&(_||i||!Jl(m)))return null;switch(t.id){case`untracked`:return!o||!wd(o)?null:(0,Q.jsxs)(K,{className:`count`,title:us(o),onClick:()=>{g(),f(`git`)},children:[(0,Q.jsx)(sm,{size:LC}),` `,o.changedCount>0&&o.changedCount,nf(o)&&(0,Q.jsxs)(`span`,{className:`git-ab`,children:[` `,nf(o)]})]},`untracked`);case`star`:{if(!r||i)return null;let e=r.id in c;return(0,Q.jsxs)(K,{className:`star-btn${r.starred?` starred`:``}${e?` star-pending`:``}`,"data-hint":`session.star`,title:e?a===`open`?`starred here — the desktop has not confirmed it yet`:`starred here — offline, so it is only on this phone until the link is back`:r.starred?`unstar (prima interest)`:`star — mark as prima interest to come back to`,onClick:()=>{g(),l(r.id,!r.starred)},children:[(0,Q.jsx)(Af,{size:LC,fill:r.starred?`currentColor`:`none`}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,r.starred?`starred`:`star`]})]},`star`)}case`followup`:{if(!r||i)return null;let e=!!r.followUp;return(0,Q.jsxs)(K,{className:`fu-btn${Ex(r.followUp)}${r.id in u?` star-pending`:``}`,"data-hint":`session.followup`,"aria-pressed":e,title:Dx(r,r.id in u,a===`open`),onClick:()=>{g(),d(r.id,!e)},children:[(0,Q.jsx)(Ox,{on:e,size:LC}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,e?`Done — clear flag`:`Flag for follow up`]})]},`followup`)}case`bookmark`:return!r||i?null:(0,Q.jsx)(ha,{active:r,repo:o,online:a===`open`,compact:n,dismiss:g},`bookmark`);default:{let e=R_(r).find(e=>e.key===t.id);if(e)return(0,Q.jsxs)(K,{title:e.unavailable??e.label,onClick:()=>{g(),Y(`toolbar:${t.id}`),e.unavailable?G(e.unavailable):e.open()},children:[(0,Q.jsx)(e.icon,{size:LC}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,e.label]})]},t.id);let n=IC(t.id,{label:h,dismiss:g,openMenu:()=>Ho(!0),active:r});if(n!==void 0)return(0,Q.jsx)(Z.Fragment,{children:n},t.id);let i=Zt[`toolbar:${t.id}`],a=t.id===`outline`?bx(r):null;return(0,Q.jsxs)(K,{"data-hint":`toolbar:${t.id}`,title:`${i?`${i.title} — ${i.what}`:t.name}${xx(a)}`,onClick:()=>{g(),p(t.id)},children:[(0,Q.jsx)(t.Icon,{size:LC}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,t.id===`model`?Na(r?.model)||`model`:t.name]}),a==null?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,a]})]},t.id)}}}function zC({c:e,usedOrder:t,refreshTerminal:n}){let{active:r,pending:i,toolbarCfg:a,setOverlay:o}=e;return i?(0,Q.jsx)(hu,{className:`toolbar-cants toolbar-cants-menu`,cants:[{label:`terminal keys`,reason:`there is no CLI to type into until the session opens`},{label:`slash commands`,reason:`there is no CLI to type into until the session opens`},{label:`reader, context, /usage`,reason:`the conversation starts when the session does`}]}):(0,Q.jsxs)(`div`,{className:`toolbar`,role:`menu`,"aria-label":`toolbar`,children:[(0,Q.jsxs)(K,{title:`refresh terminal`,onClick:()=>{hc(),n()},children:[(0,Q.jsx)(xm,{size:LC}),` refresh`]}),r.remoteUrl&&(0,Q.jsxs)(K,{onClick:()=>{hc(),window.open(r.remoteUrl,`_blank`)},title:`open in app`,children:[(0,Q.jsx)(Nf,{size:LC}),` open in app`]}),va(a,t).map(t=>RC(e,t)),F_(r.id).map(e=>(0,Q.jsxs)(K,{title:e.unavailable??`open ${e.label} — adds its tab to the header`,onClick:()=>{hc(),Y(`action:view.${e.key}.menu`),e.unavailable?G(e.unavailable):(MC(e.key),e.open())},children:[(0,Q.jsx)(e.icon,{size:LC}),` `,e.label]},e.key)),(0,Q.jsxs)(K,{title:`customize toolbar`,onClick:()=>{hc(),o(`toolbar`)},children:[(0,Q.jsx)(kf,{size:LC}),` customize`]})]})}var BC=()=>{let e=it(W.toldNoticed,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]};function VC(e,t,n,r){return HC(e,r)&&!n.includes(t)}var HC=(e,t)=>e===`none`&&t!==`shell`;function UC(e){let t=BC().filter(t=>t!==e);pt(W.toldNoticed,[...t,e].slice(-32))}var WC=e=>`${e} was not told about the outbox, so it may not know that what you should see goes in .claude/outbox/ — say so in your prompt when you want a file here.`,GC=e=>`Shown once for ${e} on this phone — the crossed-out speech icon beside the title brings it back.`,KC=(e,t)=>e===`none`&&t!==`shell`,qC=e=>`askrules:${e}`,JC=(e,t,n,r)=>KC(e,r)&&!n.includes(qC(t)),YC=e=>`Ask-before rules are not enforced in a ${e} session: neither the CLI nor this app's gate can make it stop and ask, so a command your rules would hold back can run without a tap.`,XC=e=>`Shown once for ${e} on this phone — the shield-with-question-mark icon beside the title brings it back.`;function ZC(e){let t=BC().filter(t=>t!==qC(e));pt(W.toldNoticed,[...t,qC(e)].slice(-32))}function QC({active:e,backends:t}){let n=e.backend??`claude`,r=no(t,e.backend)?`shell`:void 0,[i,a]=(0,Z.useState)(()=>VC(e.told,n,BC(),r));if(!HC(e.told,r))return null;let o=t?.find(e=>e.id===n)?.label??n;return i?(0,Q.jsxs)(gs,{className:`told-note`,role:`note`,children:[WC(o),` `,(0,Q.jsx)(`button`,{className:`link-btn`,onClick:()=>{UC(n),a(!1),G(GC(o))},children:`got it`})]}):(0,Q.jsx)(`button`,{className:`link-btn told-mark`,title:WC(o),"aria-label":`${o} was not told about the outbox — read why`,onClick:()=>a(!0),children:(0,Q.jsx)(fm,{size:12,"aria-hidden":`true`})})}function $C({active:e,backends:t}){let n=no(t,e.backend)?`shell`:void 0;return KC(e.askRulesVia,n)?(0,Q.jsx)(ew,{active:e,backends:t}):null}function ew({active:e,backends:t}){let{rules:n}=Sd(),r=e.backend??`claude`,i=no(t,e.backend)?`shell`:void 0,[a,o]=(0,Z.useState)(()=>JC(e.askRulesVia,r,BC(),i));if(n.length===0)return null;let s=t?.find(e=>e.id===r)?.label??r;return a?(0,Q.jsxs)(gs,{className:`told-note`,role:`note`,children:[YC(s),` `,(0,Q.jsx)(`button`,{className:`link-btn`,onClick:()=>{ZC(r),o(!1),G(XC(s))},children:`got it`})]}):(0,Q.jsx)(`button`,{className:`link-btn told-mark`,title:YC(s),"aria-label":`Ask-before rules are not enforced in ${s} — read why`,onClick:()=>o(!0),children:(0,Q.jsx)(ep,{size:12,"aria-hidden":`true`})})}function tw(e,t,n){let r=Math.round(e+t);return r>=n?null:Math.max(0,r)}function nw(e){if(e==null||e===``)return null;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.round(t):null}var rw=6;function iw(e){e==null?ft(W.sessChromeH):nt(W.sessChromeH,String(e))}function aw({off:e,hidden:t,children:n}){let[r,i]=(0,Z.useState)(()=>nw(ht(W.sessChromeH))),a=(0,Z.useRef)(null),o=(0,Z.useRef)(r);(0,Z.useEffect)(()=>{o.current=r},[r]);let s=!e&&r!=null,c=()=>a.current?.scrollHeight??0,l=()=>a.current?.getBoundingClientRect().height??0,u=e=>{o.current=e,i(e)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:a,className:`sess-chrome${s?` capped`:``}`,style:s?{maxHeight:`${r}px`}:void 0,children:n}),!t&&(0,Q.jsx)(`div`,{className:`sess-chrome-grip${s?` capped`:``}`,role:`separator`,"aria-orientation":`horizontal`,tabIndex:0,"aria-label":s?`header shortened — tap to show all of it, or drag down for more`:`drag up to hide the bottom of the header`,title:s?`header shortened — tap to show all of it, or drag down for more`:`drag up to hide the bottom of the header — the status line goes first`,onPointerDown:t=>{if(t.button!==0||e)return;t.preventDefault();let n=t.currentTarget;n.setPointerCapture(t.pointerId);let r=t.clientY,i=l(),a=!1,s=e=>{let t=e.clientY-r;!a&&Math.abs(t)<rw||(a=!0,u(tw(i,t,c())))},d=()=>{n.removeEventListener(`pointermove`,s),n.removeEventListener(`pointerup`,d),n.removeEventListener(`pointercancel`,d),a?(Y(o.current==null?`action:chrome.showAll`:`action:chrome.cap`),iw(o.current)):o.current!=null&&(Y(`action:chrome.showAll`),u(null),iw(null))};n.addEventListener(`pointermove`,s),n.addEventListener(`pointerup`,d),n.addEventListener(`pointercancel`,d)},onKeyDown:t=>{let n=t.key===`ArrowUp`?-1:+(t.key===`ArrowDown`);if(!n||e)return;t.preventDefault();let r=tw(l(),n*16*(t.shiftKey?4:1),c());u(r),iw(r)},children:s&&(0,Q.jsx)(Zp,{size:12,"aria-hidden":`true`})})]})}var ow=16,sw=54,cw=12,lw=new Set([`star`,`followup`,`bookmark`]);function uw(e){let{active:t,sessions:n,pending:r,pendingEntry:i,status:a,liveSend:o,backends:s,sessionCan:l,sessionRepoName:u,repoForCwd:d,setActiveId:f,setOverlay:p,removeQueued:m,closeSession:h,chrome:g,hdrShown:_,headerCmds:v,runHeaderCmd:y,refreshTerminal:b,toolbar:x}=e,{chromeHidden:S,typingMode:C,typingPeeking:w,setTypingPeek:E,setFullScreen:D}=g,O=sa(),k=Xt(),A=ar(),j=qr(),M=Kt(),ee=oh(),N=qt(),P=l(t,`contextSeries`)&&l(t,`contextMeter`)&&t.contextLeft!=null,F=Pn(t)?.cls??null;return(0,Q.jsxs)(aw,{off:S||O||w,hidden:S,children:[(0,Q.jsxs)(`header`,{className:`topbar sess-top`,style:pf(u(t)),children:[(0,Q.jsx)(`button`,{className:`back`,onClick:()=>f(null),children:(0,Q.jsx)(Qp,{size:24})}),(0,Q.jsxs)(`div`,{className:`brand`,children:[V(t.title)||t.title,(0,Q.jsxs)(qo,{className:Ni(s,t.backend)?`row-foreign`:void 0,children:[` `,Wr(Wn(t),Ni(s,t.backend),s)]}),(0,Q.jsx)(Rt,{}),(0,Q.jsx)(QC,{active:t,backends:s},t.id),(0,Q.jsx)($C,{active:t,backends:s},`ar:${t.id}`),t.tabTitle?(0,Q.jsxs)(`span`,{className:`brand-name`,children:[(0,Q.jsx)(qm,{size:12,"aria-hidden":`true`}),` `,t.tabTitle]}):null]}),(0,Q.jsxs)(`div`,{className:`hdr-view`,children:[(0,Q.jsx)(fw,{active:t,sessions:n,pending:r,backends:s}),yn(x.toolbarCfg).filter(e=>lw.has(e.id)).map(e=>(0,Q.jsx)(`span`,{className:`hdr-pin`,children:RC(x,e,!0)},e.id)),!r&&(0,Q.jsx)(K,{className:`hdr-name-btn`,title:t.tabTitle?`write this session a new name — one cheap call on the desktop`:`name this session — one cheap call on the desktop`,"aria-label":`name this session`,onClick:()=>{Y(`action:session.name`),o({t:`session.name`,id:t.id},`writing a name for this session…`)},children:(0,Q.jsx)(qm,{size:ow})}),!r&&(0,Q.jsx)(K,{className:`hdr-name-btn`,title:`type a name for this session`,"aria-label":`rename this session`,onClick:()=>{Cx(t,o)},children:(0,Q.jsx)(lp,{size:ow})})]}),(0,Q.jsxs)(`div`,{className:`hdr-row2`,children:[(0,Q.jsxs)(`div`,{className:`hdr-cmds`,children:[yn(x.toolbarCfg).filter(e=>e.id!==`outline`&&!lw.has(e.id)).map(e=>(0,Q.jsx)(`span`,{className:`hdr-pin`,children:RC(x,e,!0)},e.id)),_.map(e=>(0,Q.jsx)(K,{className:`hdr-cmd`,title:e.text,onClick:()=>y(e),children:e.title},e.id)),(0,Q.jsx)(K,{className:`hdr-cmd hdr-cmd-manage`,title:`header commands — one-tap chips you configure`,onClick:()=>{Y(`action:hdrcmd.manage`),p(`hdrcmd`)},children:v.length?(0,Q.jsx)(lp,{size:12}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pp,{size:12}),` command`]})})]}),(0,Q.jsx)(`div`,{className:`hdr-ctl`,children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ol,{compact:!0}),(0,Q.jsxs)(K,{className:`notif-btn`,title:`notifications`,onClick:Ja,children:[(0,Q.jsx)(zf,{size:ow}),A>0&&(0,Q.jsx)(`span`,{className:`notif-badge`,children:La(A)})]}),r?(0,Q.jsx)(K,{variant:`danger`,title:yh(t.id)?`close — nothing was queued; a draft stays here for next time`:`drop this open — the prompts written for it stay in Activity`,onClick:()=>{let e=i?.ackId;f(null),e&&(m(e),G(`open dropped`))},children:(0,Q.jsx)(X,{size:ow})}):(0,Q.jsx)(K,{variant:`danger`,title:t.running?`close session — reopen under “Recently closed”`:`remove session`,onClick:()=>{h(t),f(null)},children:(0,Q.jsx)(X,{size:ow})}),(0,Q.jsx)(K,{className:`burger-btn${O?` active`:``}`,title:O?`close the menu`:`menu — refresh, slash commands, files, and the rest`,"aria-label":`toolbar`,"aria-expanded":O,onClick:()=>Ho(!O),children:(0,Q.jsx)(Mm,{size:ow})})]})})]}),S&&!r&&!(x.toolbarCfg.pinned??[]).includes(`outline`)&&(0,Q.jsxs)(K,{className:`hdr-typing-keep hdr-typing-outline`,onPointerDown:$,title:`outline — where you are in this session${xx(bx(t))}`,onClick:()=>x.runToolbar(`outline`),children:[(0,Q.jsx)(Jp,{size:ow}),bx(t)==null?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,bx(t)]})]}),S&&(0,Q.jsx)(K,{className:`hdr-typing-keep hdr-typing-menu`,onPointerDown:$,title:C?`show the header, status and keys again — the keyboard stays up`:`leave full screen — the header, status and toolbar come back`,"aria-label":`show hidden controls`,"aria-expanded":!1,onClick:()=>{C?(Y(`action:typing.peek`),E(!0)):(Y(`action:fullscreen.off`),D(!1))},children:(0,Q.jsx)(Mm,{size:ow})}),w&&(0,Q.jsx)(K,{className:`hdr-typing-hide`,onPointerDown:$,title:`hide these again and give the rows back to the output`,"aria-label":`hide controls`,"aria-expanded":!0,onClick:()=>{Y(`action:typing.hide`),E(!1)},children:(0,Q.jsx)(Fm,{size:ow})}),O&&(0,Q.jsx)(zC,{c:x,usedOrder:k,refreshTerminal:b})]}),r&&(0,Q.jsxs)(`div`,{className:`sess-status`,children:[(0,Q.jsx)(qo,{children:d(t.cwd)?te(d(t.cwd)):t.cwd}),(0,Q.jsx)(qo,{children:yh(t.id)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Zf,{size:11}),` starts when its backlog item runs`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(um,{size:11,className:i?.status===`failed`?``:`spin`}),` `,i?.status===`failed`?`not started`:!i||i.status===`pending`?`opening…`:a===`open`?`queued`:`queued — waiting for the link`]})}),(0,Q.jsx)(Ns,{})]}),!r&&(0,Q.jsxs)(`div`,{className:`sess-status`,children:[mx(t,void 0,void 0,s),t.asking&&!t.prompt&&!t.awaitingInput&&(0,Q.jsxs)(`button`,{className:`row-sub ack-asking`,title:`mark “${t.asking.text}” as handled — clears the “asked you” badge and the waiting count here. Nothing is typed into the session, and the next turn's question raises it again.`,onClick:()=>{Y(`action:session.ackAsking`),o({t:`session.ackAsking`,id:t.id,text:t.asking.text},`marked as handled — nothing was typed into the session`)},children:[(0,Q.jsx)(bm,{size:12}),` mark handled`]}),t.createdAt&&t.running&&(0,Q.jsxs)(qo,{children:[(0,Q.jsx)(Fp,{size:11}),` open `,yu(t.createdAt)]}),l(t,`usageLimits`)&&j.kind===`windows`&&(0,Q.jsx)(qb,{backend:t.backend}),l(t,`usageLimits`)&&j.kind===`usd`&&(0,Q.jsxs)(qo,{className:`usage-inline${j.chip.hot?` danger`:``}`,title:`${j.chip.title}\ntap for the token history`,onClick:()=>{Y(`overlay:tokens`),p(`tokens`)},children:[(0,Q.jsx)(Wp,{size:11}),` `,j.chip.text]}),ou(t.sideChannel)&&(0,Q.jsxs)(qo,{className:`act-cant`,children:[(0,Q.jsx)(ym,{size:11}),` `,ou(t.sideChannel)]}),hx(t,N),yx(t,()=>Di(t)),!P&&gx(t),l(t,`contextSeries`)&&(0,Q.jsxs)(`button`,{className:`row-sub usage-inline`,"data-hint":`session.context`,title:`${l(t,`contextMeter`)&&t.contextTotalTok!=null?`context window: ${Ic(t.contextUsedTok??0)} of ${Ic(t.contextTotalTok)} tokens`:`context window`}${qe(t.contextSpark?.usageTok)?`\n${T(t.contextSpark.usageTok,t.contextSpark.agentTok??null)}`:``}\ntap for the graph: how it filled, and where it compacted`,onClick:()=>{Y(`overlay:context`),Fc()},children:[l(t,`contextMeter`)&&t.contextSpark?(0,Q.jsx)(Xo,{spark:t.contextSpark,width:54,height:14}):(0,Q.jsx)(am,{size:11}),l(t,`contextMeter`)?t.contextTotalTok==null?t.contextLeft==null?(0,Q.jsx)(Q.Fragment,{children:` context`}):(0,Q.jsxs)(Q.Fragment,{children:[` context `,(0,Q.jsx)(dw,{pct:t.contextLeft,warm:F})]}):(0,Q.jsxs)(Q.Fragment,{children:[` context `,Ic(t.contextUsedTok??0),`/`,Ic(t.contextTotalTok),t.contextLeft!=null&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(dw,{pct:t.contextLeft,warm:F})]})]}):(0,Q.jsx)(Q.Fragment,{children:` context`}),(()=>{let e=t.contextSpark;if(e&&ff(e,sw,cw)){let n=c(e.costUsd,M),r=ee(t);return(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Nd,{spark:e,width:sw,height:cw,warn:r}),n&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:r?`spend-warn-${r.level}`:void 0,children:n})]})]})}return qe(e?.usageTok)?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Kf,{size:11}),` used `,qe(e?.usageTok)]}):null})()]}),_x(t),vx(t),Sx(t,()=>Za(null)),(0,Q.jsx)(zr,{s:t}),(0,Q.jsx)(Ns,{})]})]})}function dw({pct:e,warm:t}){return(0,Q.jsxs)(`span`,{className:t?`ctx-free ${t}`:`ctx-free`,children:[e,`% free`]})}function fw({active:e,sessions:t,pending:n,backends:r}){let i=PC(),a=n?[]:F_(e.id).filter(e=>i.includes(e.key)),o=kC(e,t,{pending:n,shell:no(r,e.backend)},a);if(!o)return null;let s=e;for(let e of o)e.kind===`cli`&&!e.on&&(s=e.target);let c=Nt(r,s.backend),l=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bp,{size:14,"aria-hidden":`true`}),` `,c]}),u=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(op,{size:14,"aria-hidden":`true`}),` Shell`]});return(0,Q.jsx)(`div`,{className:`pair-tabs`,role:`tablist`,"aria-label":a.length?`session, its shell or a view of it`:`session or its shell`,"data-hint":`hdr.pair`,children:o.map(e=>{if(e.kind===`view`){let t=e.view,n=t.icon;return(0,Q.jsxs)(`span`,{className:`pair-view`,children:[(0,Q.jsxs)(`button`,{className:`pair-tab`,role:`tab`,"aria-selected":`false`,onPointerDown:$,title:t.unavailable??`open ${t.label}`,onClick:()=>{Y(`action:view.${t.key}`),t.unavailable?G(t.unavailable):t.open()},children:[(0,Q.jsx)(n,{size:14,"aria-hidden":`true`}),` `,t.label]}),(0,Q.jsx)(`button`,{className:`pair-tab pair-view-x`,onPointerDown:$,"aria-label":`close the ${t.label} tab`,title:`close the ${t.label} tab — ☰ menu opens it again`,onClick:()=>{Y(`action:view.${t.key}.unpin`),NC(t.key)},children:(0,Q.jsx)(X,{size:14,"aria-hidden":`true`})})]},t.key)}let t=e.kind===`cli`?l:u;if(e.on)return(0,Q.jsx)(`span`,{className:`pair-tab on`,role:`tab`,"aria-selected":`true`,children:t},e.kind);let n=e.target;return e.kind===`cli`?(0,Q.jsx)(`button`,{className:`pair-tab`,role:`tab`,"aria-selected":`false`,onPointerDown:$,title:`back to the CLI session this shell belongs to`,onClick:()=>{Y(`action:companion.to.cli`),ki(n.id)},children:t},`cli`):(0,Q.jsx)(`button`,{className:`pair-tab`,role:`tab`,"aria-selected":`false`,onPointerDown:$,title:`switch to this session's companion shell`,onClick:()=>{Y(`action:companion.to.shell`),ki(n.id)},children:t},`shell`)})})}function pw({activeId:e}){let t=Yd(Vh);if(!t||!zh(t,e))return null;let n=Rh(t.to.label);return(0,Q.jsxs)(`div`,{className:`filter-bar return-bar`,children:[(0,Q.jsxs)(`button`,{className:`return-go`,title:`open the ${t.to.label} again — this shell stays open`,onClick:()=>{Y(`action:shell.return`),t.to.open()},children:[(0,Q.jsx)(lm,{size:14}),` `,(0,Q.jsx)(`span`,{className:`filter-bar-txt`,children:n})]}),(0,Q.jsx)(`button`,{className:`filter-bar-clear`,"aria-label":`hide ${n}`,title:`hide ${n}`,onClick:()=>{Wh(),G(`Hidden. The shell button on the ${t.to.label} brings it back.`)},children:(0,Q.jsx)(X,{size:13})})]})}var mw={...Me.dark},hw={...Me.light,cursor:Me.light.foreground,cursorAccent:Me.light.background,selectionBackground:`rgba(21, 100, 204, .22)`,black:`#24292f`,red:`#cf222e`,green:`#116329`,yellow:`#4d2d00`,blue:`#0550ae`,magenta:`#6639ba`,cyan:`#1b7c83`,white:`#6e7781`,brightBlack:`#57606a`,brightRed:`#a40e26`,brightGreen:`#1a7f37`,brightYellow:`#633c01`,brightBlue:`#0969da`,brightMagenta:`#8250df`,brightCyan:`#1b7c83`,brightWhite:`#24292f`};function gw(e){let t=e===`light`?hw:mw,n=me(e,vo());return n===Me[e]?t:e===`light`?{...t,...n,cursor:n.foreground,cursorAccent:n.background}:{...t,...n}}var _w=450,vw=400,yw=2500,bw=3e4;function xw(e){let t=e.buffer.active,n=[];for(let r=0;r<e.rows;r++){let e=t.getLine(t.viewportY+r);n.push(e?e.translateToString(!0).replace(/\s+$/,``):``)}return n}function Sw(e,t){let n=e.querySelector(`.xterm-screen`);if(!n||!t.rows)return null;let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();return i.height?{top:i.top-r.top,left:i.left-r.left,width:i.width,rowH:i.height/t.rows,rows:t.rows}:null}var Cw=(0,Z.forwardRef)(function({pending:e,writeSeq:t,onInput:n,onResize:r,linkUp:i,onScreen:a,onCursorLine:o,onReachBack:s,onScrollStalled:c,onLongPress:l,children:u},d){let f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m=(0,Z.useRef)(null),h=(0,Z.useRef)(0),g=(0,Z.useRef)({cols:0,rows:0}),_=(0,Z.useRef)({linkUp:i,onScreen:a,onCursorLine:o,onReachBack:s,onScrollStalled:c,onLongPress:l});_.current={linkUp:i,onScreen:a,onCursorLine:o,onReachBack:s,onScrollStalled:c,onLongPress:l};let v=(0,Z.useRef)(void 0),y=(0,Z.useRef)(void 0),b=(0,Z.useRef)(0);(0,Z.useEffect)(()=>{let e=new Ym({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:Et(),theme:gw(br()),scrollback:5e3,convertEol:!1}),t=new Xm;e.loadAddon(t);let r=()=>{t.fit(),e.cols>$e(e.cols)&&e.resize($e(e.cols),e.rows)};e.open(f.current),f.current.querySelector(`.xterm-helper-textarea`)?.setAttribute(`inputmode`,`none`),r(),e.attachCustomKeyEventHandler(t=>t.type!==`keydown`||!t.ctrlKey||t.shiftKey||t.altKey||t.key.toLowerCase()!==`c`||!e.hasSelection()?!0:(navigator.clipboard?.writeText(e.getSelection()).catch(()=>{}),!1)),e.onData(n),p.current=e;let i=Su(t=>{e.options.theme=gw(t)}),a=Ji(()=>{e.options.fontSize=Et();try{r()}catch{return}x(e.cols,e.rows)});m.current=t,x(e.cols,e.rows);let o,s=new ResizeObserver(()=>{clearTimeout(o),o=window.setTimeout(()=>{try{let t=S();r(),x(e.cols,e.rows),t&&e.scrollToBottom()}catch{}},150)});s.observe(f.current);let c=f.current,l=0,u=0,d=0,h=!1,g,C=()=>{clearTimeout(g),g=void 0},w=()=>{let t=e.buffer.active;return t.getLine(t.viewportY)?.translateToString(!0)??``},T=()=>c.querySelector(`.xterm-rows > div`)?.getBoundingClientRect().height||16,E=e=>{if(n(`\x1b[<${e<0?64:65};1;1M`.repeat(Math.abs(e))),e>=0)return;clearTimeout(y.current);let t=w();y.current=window.setTimeout(()=>{w()===t&&(Date.now()-b.current<bw||(b.current=Date.now(),_.current.onScrollStalled?.()))},yw)},D=t=>{if(C(),t.touches.length!==1){h=!1;return}l=t.touches[0].clientY,u=t.touches[0].clientX,d=0,h=!1;let n=u,r=l;g=window.setTimeout(()=>{g=void 0;let t=Sw(c,e);if(!t)return;let i=Math.floor((r-c.getBoundingClientRect().top-t.top)/t.rowH);i>=0&&i<t.rows&&_.current.onLongPress?.(i,n,r)},_w)},O=t=>{if(t.touches.length!==1)return;let n=t.touches[0].clientY-l,r=t.touches[0].clientX-u;if(g!==void 0&&Math.hypot(r,n)>8&&C(),!h){if(Math.abs(n)<8||Math.abs(r)>Math.abs(n))return;h=!0}t.preventDefault(),d-=n,l=t.touches[0].clientY;let i=T(),a=Math.trunc(d/i);if(a!==0){if(d-=a*i,e.buffer.active.type===`normal`){e.scrollLines(a);return}if(!_.current.linkUp){a<0&&(h=!1,_.current.onReachBack?.());return}E(a)}};return c.addEventListener(`touchstart`,D,{passive:!0}),c.addEventListener(`touchmove`,O,{passive:!1}),c.addEventListener(`touchend`,C,{passive:!0}),c.addEventListener(`touchcancel`,C,{passive:!0}),()=>{try{e.buffer.active.type===`alternate`&&_.current.onScreen?.(xw(e))}catch{}clearTimeout(o),clearTimeout(v.current),clearTimeout(y.current),s.disconnect(),i(),a(),c.removeEventListener(`touchstart`,D),c.removeEventListener(`touchmove`,O),c.removeEventListener(`touchend`,C),c.removeEventListener(`touchcancel`,C),C(),e.dispose(),p.current=null}},[]),(0,Z.useEffect)(()=>{let t=p.current;if(!t||h.current>=e.length)return;let n=S();for(let n=h.current;n<e.length;n++)t.write(e[n]);h.current=e.length,n&&t.scrollToBottom(),clearTimeout(v.current),v.current=window.setTimeout(()=>{if(p.current){if(_.current.onCursorLine&&!p.current.modes.synchronizedOutputMode){let e=p.current.buffer.active;_.current.onCursorLine(e.getLine(e.baseY+e.cursorY)?.translateToString(!0,0,e.cursorX)??``)}p.current.buffer.active.type===`alternate`&&(p.current.modes.synchronizedOutputMode||_.current.onScreen?.(xw(p.current)))}},vw)},[t,e]);function x(e,t){if(!w(e,t))return;let n=g.current;(n.cols!==e||n.rows!==t)&&(g.current={cols:e,rows:t},r(e,t))}function S(){let e=p.current;return!e||e.buffer.active.viewportY>=e.buffer.active.baseY}return(0,Z.useImperativeHandle)(d,()=>({focus(){p.current?.focus()},snapshot(){return p.current?xw(p.current):[]},rowBox(){return p.current&&f.current?Sw(f.current,p.current):null},getText(){let e=p.current;if(!e)return``;let t=t=>{let n=e.buffer[t],r=[];for(let e=0;e<n.length;e++){let t=n.getLine(e);t&&r.push(t.translateToString(!0))}for(;r.length&&r[r.length-1]===``;)r.pop();return r.join(`
|
|
163
|
-
`)};return[t(`normal`),e.buffer.active.type===`alternate`?t(`alternate`):``].filter(Boolean).join(`
|
|
164
|
-
|
|
165
|
-
— current screen —
|
|
166
|
-
|
|
167
|
-
`)}}),[]),(0,Q.jsx)(`div`,{ref:f,style:{width:`100%`,height:`100%`,position:`relative`},children:u})}),ww=18,Tw=520,Ew=`[data-hint="term.read"]`;function Dw({chunks:e,writeSeq:t,cols:n,rows:r,leaving:i,onGone:a,onOpen:o}){let s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),u=(0,Z.useRef)({arr:null,n:0}),[d,f]=(0,Z.useState)(0),[p,m]=(0,Z.useState)(1),[h,g]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=new Ym({cols:Math.max(20,n),rows:Math.max(5,r),fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:Et(),theme:gw(br()),cursorBlink:!1,disableStdin:!0,scrollback:0});e.open(c.current),c.current.querySelector(`.xterm-helper-textarea`)?.setAttribute(`inputmode`,`none`),l.current=e,u.current={arr:null,n:0};let t=Su(t=>{e.options.theme=gw(t)});return()=>{t(),l.current=null,e.dispose()}},[]),(0,Z.useEffect)(()=>{let t=l.current;if(!t)return;let i=u.current,a=Math.max(20,n),o=Math.max(5,r);if((t.cols!==a||t.rows!==o)&&(t.resize(a,o),i.arr=null),(i.arr!==e||i.n>e.length)&&(t.reset(),i.arr=e,i.n=0),!(i.n>=e.length)){for(let n=i.n;n<e.length;n++)t.write(e[n]);i.n=e.length,t.write(``,()=>{if(l.current!==t||t.modes.synchronizedOutputMode)return;let e=t.buffer.active,n=-1;for(let r=0;r<t.rows;r++)e.getLine(e.viewportY+r)?.translateToString(!0).trim()&&(n=r);f(Math.min(ww,n+1));let r=c.current?.querySelector(`.xterm-screen`),i=s.current;if(r&&i){let e=r.offsetWidth;m(e>0?Math.min(1,i.clientWidth/e):1),g(r.offsetHeight/t.rows)}})}},[t,e,n,r]),(0,Z.useLayoutEffect)(()=>{if(!i)return;let e=s.current,t=document.querySelector(Ew),n=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches;if(!e||!t||n||d===0){a();return}let r=e.getBoundingClientRect(),o=t.getBoundingClientRect();Object.assign(e.style,{position:`fixed`,left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,margin:`0`,zIndex:`40`,transformOrigin:`top left`,pointerEvents:`none`});let c=o.width/r.width,l=o.height/r.height,u=e.animate([{transform:`none`,opacity:1,borderRadius:`8px`},{transform:`translate(${o.left-r.left}px, ${o.top-r.top}px) scale(${c}, ${l})`,opacity:.35,borderRadius:`40px`}],{duration:Tw,easing:`cubic-bezier(.55,0,.25,1)`,fill:`forwards`});return u.onfinish=()=>{t.classList.add(`cli-catch`),window.setTimeout(()=>t.classList.remove(`cli-catch`),450),a()},()=>{u.onfinish=null}},[i]);let _=d&&h?Math.ceil(d*h*p):0;return(0,Q.jsxs)(`div`,{className:`cli-peek-wrap`,children:[!d&&(0,Q.jsx)(Mc,{children:`No turns recorded yet.`}),(0,Q.jsx)(`div`,{ref:s,className:`cli-peek${d?``:` cli-peek-blank`}`,style:{height:_},role:`button`,tabIndex:0,"aria-label":`open the CLI`,onClick:o,onKeyDown:e=>{e.key===`Enter`&&o()},children:(0,Q.jsx)(`div`,{ref:c,className:`cli-peek-grid`,style:{transform:`scale(${p})`}})}),d>0&&!i&&(0,Q.jsxs)(`div`,{className:`cli-peek-cap muted`,children:[(0,Q.jsx)(Rf,{size:12}),` no turns yet — this is the top of the CLI; the conversation appears here once you send`]})]})}function Ow(e,t){return!!e&&t&&e.kind===`trust`&&e.options.length>0}var kw=Df(),Aw={hand:Ap,code:Ff,scroll:Cm,zap:Dm,shieldOff:zp,lock:rm};function jw({mode:e,size:t=16}){let n=Aw[Fv[e]?.icon??`hand`];return(0,Q.jsx)(n,{size:t,"aria-hidden":!0})}function Mw(e,t,n){let r=To(e,t.backend)?St(e,t.backend):[];return{rows:zv(r,t,$s(e,t.backend)),ultraOk:r.length>0&&$s(e,t.backend)&&n&&Wt(e,t.backend).length>0}}function Nw(e,t,n){let r=Mw(e,t,n);return r.rows.length>0||r.ultraOk}function Pw({cur:e,backends:t,canSlash:n,submitInput:r,liveAsk:i,onClose:a}){let o=$v(e.id),{rows:s,ultraOk:c}=Mw(t,e,n),l=Lv(e);if(s.length===0&&!c){let n=no(t,e.backend)?null:Io(t,e.backend);return n?(0,Q.jsx)(gs,{className:`mode-sec`,children:n}):null}let u=t=>{Y(`action:mode.${t}`),i({t:`session.mode`,id:e.id,mode:t},`no connection — a mode switch is never queued; try again when the link is back`)&&Zv(e.id,t)},d=async e=>{let t=Bv(e,l);t.kind===`none`?G(t.say):t.kind===`confirm`&&(a(),!await Hs({title:`Switch this session to ${Iv(e)}?`,lines:[...dy.slice(0,2),`This session only — new sessions keep their own launch mode.`],confirmLabel:`Switch to ${Iv(e)}`}))||u(e)},f=t=>{let n=qv(t);Y(`action:ultracode.${t?`on`:`off`}`),r(e.id,e.cwd,n,`command`)&&G(n)},p=Gv(e.ultracode);return(0,Q.jsxs)(`div`,{className:`mode-sec`,children:[s.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mode-head muted`,children:$s(t,e.backend)?`Mode · shift+tab on the desktop`:`Mode`}),(0,Q.jsx)(gs,{className:`mode-now`,children:Rv(l,$s(t,e.backend)?void 0:pi(t,e.backend)?.label??`this backend`)}),(0,Q.jsx)(`div`,{className:`mode-rows`,role:`group`,"aria-label":`permission mode`,children:s.map(e=>{let t=l.mode===e.mode,n=o===e.mode;return(0,Q.jsxs)(`button`,{className:`mode-row${t&&l.source===`live`?` cur`:``}`,"aria-pressed":t&&l.source===`live`,onClick:()=>void d(e.mode),children:[(0,Q.jsx)(`span`,{className:`mode-ico`,children:(0,Q.jsx)(jw,{mode:e.mode})}),(0,Q.jsxs)(`span`,{className:`mode-txt`,children:[(0,Q.jsx)(`span`,{className:`mode-title`,children:e.title}),(0,Q.jsx)(`span`,{className:`mode-desc muted`,children:n?`switching…`:e.desc})]}),(0,Q.jsx)(`span`,{className:`mode-mark`,children:n?(0,Q.jsx)(om,{size:16,className:`spin`}):t&&l.source===`live`?(0,Q.jsx)(bm,{size:16}):t?(0,Q.jsx)(`span`,{className:`muted`,children:`at launch`}):null})]},e.mode)})})]}),c&&(0,Q.jsxs)(`div`,{className:`mode-ultra`,children:[(0,Q.jsx)(`span`,{className:`mode-ico`,children:(0,Q.jsx)(qm,{size:16,"aria-hidden":!0})}),(0,Q.jsxs)(`span`,{className:`mode-txt`,children:[(0,Q.jsx)(`span`,{className:`mode-title`,children:`Ultracode`}),(0,Q.jsx)(`span`,{className:`mode-desc muted`,children:Kv(e.ultracode)})]}),(0,Q.jsxs)(`span`,{className:`mode-acts`,children:[p!==`on`&&(0,Q.jsx)(K,{onClick:()=>f(!0),children:`turn on`}),p!==`off`&&(0,Q.jsx)(K,{onClick:()=>f(!1),children:`turn off`})]})]})]})}var Fw=new Map;function Iw(e){return(0,kw.createPortal)((0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`model-wheel-scrim`,onPointerDown:t=>{t.preventDefault(),e.onClose()}}),(0,Q.jsx)(Lw,{anchor:e.anchor,children:(0,Q.jsx)(Rw,{...e})})]}),document.body)}function Lw({anchor:e,children:t}){let n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(8);return(0,Z.useLayoutEffect)(()=>{let t=n.current;if(!t)return;let r=()=>{let n=e.current?.getBoundingClientRect();i(Mt(n?n.bottom:0,t.offsetHeight,window.innerHeight))};r();let a=new ResizeObserver(r);return a.observe(t),window.addEventListener(`resize`,r),()=>{a.disconnect(),window.removeEventListener(`resize`,r)}},[e]),(0,Q.jsx)(`div`,{ref:n,className:`model-wheel-place`,style:{"--mw-top":`${r}px`},children:t})}function Rw({cur:e,backends:t,canSlash:n,submitInput:r,relaunch:a,liveAsk:o,onClose:s}){let c=Nw(t,e,n),l=(0,Q.jsx)(Pw,{cur:e,backends:t,canSlash:n,submitInput:r,liveAsk:o,onClose:s}),u=mo(t,e.backend),d=Wt(t,e.backend),[f,p]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),s())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s]),fn(u).length===0&&!e.model)return(0,Q.jsxs)(`div`,{className:`model-wheel-pop`,role:`dialog`,"aria-label":`model wheel`,children:[(0,Q.jsx)(zw,{onClose:s,withMode:c}),(0,Q.jsx)(gs,{children:`This backend did not name its models, so there is nothing to put on a wheel. Switch model in the menu takes a typed id.`}),l]});let m=ul(e,u),h=Fw.get(e.id);h&&Ci(h,m,u.ids)&&Fw.delete(e.id);let g=h&&Fw.has(e.id)?h:null,_=f?Sa(m,f,{slash:n,effort:wr(t,e.backend,!0)}):null,v=f?`${f.model}${f.effort?` · ${f.effort}`:``}`:``,y=Ut(e)?`the conversation is resumed`:`no conversation id is known, so it starts clean`,b=_?_.kind===`none`?m.from===`turn`?`The last turn already ran on ${v}.`:`This session started on ${v}.`:_.kind===`live`?`Sends ${_.commands.join(` then `)}.`:`Kills and relaunches this session on ${v}; ${y}.`:`Tap or drag to a point${d.length>0?` — centre is low effort, the rim is max`:``}.${d.length>0?``:` This backend has no effort setting.`}`,x=re(e.contextSpark,{lastTurnAt:e.lastTurnAt,turnActive:e.turnActive,now:Date.now()}),S=f&&_&&_.kind!==`none`?Cn({from:{model:m.model,effort:m.effort},to:f,ids:u.ids,tok:x?.tok??null,baseTok:x?.baseTok??null,cold:i(e.lastTurnAt,Date.now(),e.turnActive)}):null;return(0,Q.jsxs)(`div`,{className:`model-wheel-pop`,role:`dialog`,"aria-label":`model wheel`,children:[(0,Q.jsx)(zw,{onClose:s,withMode:c}),(0,Q.jsxs)(Bd,{cat:u,efforts:d,current:{model:m.model,effort:m.effort},value:f,onPick:p,onClear:()=>p(null),says:b,now:(0,Q.jsxs)(Q.Fragment,{children:[m.from===`turn`?(0,Q.jsxs)(Q.Fragment,{children:[`Last turn ran on `,e.turnModel,e.turnEffort?` · ${e.turnEffort}`:``]}):(0,Q.jsxs)(Q.Fragment,{children:[`Started on `,e.model||`the default model`,e.effort?` · ${e.effort}`:d.length>0?` · default effort`:``]}),g&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`br`,{}),`Sent `,g.commands.join(` then `),` `,Dl(g.at),`; no turn has run on it yet.`]})]}),children:[S&&(0,Q.jsx)(gs,{className:`mw-cost`,children:S}),_&&_.kind!==`none`&&(0,Q.jsx)(`button`,{className:`send mw-apply`,onClick:()=>{if(_&&_.kind!==`none`){if(Y(`action:modelwheel.${_.kind}`),_.kind===`live`){for(let t of _.commands)r(e.id,e.cwd,t,`command`);Fw.set(e.id,{commands:_.commands,model:_.model,effort:_.effort,at:Date.now()}),G(_.commands.join(` · `))}else a(e,_.patch);s()}},children:_.kind===`live`?`Switch to ${v}`:`Relaunch on ${v}`}),l]})]})}function zw({onClose:e,withMode:t}){return(0,Q.jsxs)(`div`,{className:`mw-head`,children:[(0,Q.jsxs)(`span`,{children:[`Model · effort`,t?` · mode`:``]}),(0,Q.jsx)(K,{"aria-label":`close the model wheel`,onClick:e,children:(0,Q.jsx)(X,{size:16})})]})}var Bw=`2.1.304`,Vw=[{name:`shift+tab`,does:`next permission mode`,seq:[{m:{shift:!0},key:`tab`}]},{name:`ctrl+o`,does:`show / hide the transcript`,seq:[{m:{ctrl:!0},key:`o`}]},{name:`ctrl+t`,does:`show / hide the todo list`,seq:[{m:{ctrl:!0},key:`t`}]},{name:`ctrl+b`,does:`send the running command to the background`,seq:[{m:{ctrl:!0},key:`b`}]},{name:`ctrl+r`,does:`search earlier prompts`,seq:[{m:{ctrl:!0},key:`r`}]},{name:`ctrl+s`,does:`stash the prompt being typed`,seq:[{m:{ctrl:!0},key:`s`}]},{name:`ctrl+_`,does:`undo in the prompt`,seq:[{m:{ctrl:!0},key:`_`}]},{name:`ctrl+l`,does:`clear the prompt`,seq:[{m:{ctrl:!0},key:`l`}]},{name:`ctrl+j`,does:`new line in the prompt`,seq:[{m:{ctrl:!0},key:`j`}]},{name:`alt+p`,does:`model picker`,seq:[{m:{alt:!0},key:`p`}]},{name:`alt+t`,does:`thinking on / off`,seq:[{m:{alt:!0},key:`t`}]},{name:`alt+o`,does:`fast mode on / off`,seq:[{m:{alt:!0},key:`o`}]},{name:`esc esc`,does:`jump back to an earlier prompt — from an empty prompt while idle; mid-turn the first Esc stops the turn`,seq:[{m:{},key:`esc`},{m:{},key:`esc`}]}];function Hw(e){let t=[];for(let n of e.seq){let e=Se(n.m,n.key);if(!(`bytes`in e))return null;t.push(e.bytes)}return t}var Uw=16,Ww=150;function Gw({sendInput:e,onClose:t}){(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),e.preventDefault(),t())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t]);function n(n){let r=Vw[n],i=Hw(r);i?(Y(`action:keys.send`),i.forEach((t,n)=>n===0?e(t):window.setTimeout(()=>e(t),n*Ww)),t(),G(`sent ${r.name} — ${r.does}`)):G(`${r.name} has no terminal bytes. Nothing was sent.`)}return(0,Q.jsxs)(`div`,{className:`keys-pop`,role:`dialog`,"aria-label":`claude's shortcuts`,children:[(0,Q.jsxs)(`div`,{className:`keys-pop-head`,children:[(0,Q.jsxs)(`span`,{className:`muted`,children:[`claude `,Bw,`'s default keys — a remapped keybindings.json has others`]}),(0,Q.jsx)(K,{onPointerDown:$,onClick:t,title:`close the list`,"aria-label":`close the list`,children:(0,Q.jsx)(X,{size:Uw})})]}),(0,Q.jsx)(`div`,{className:`keys-pop-list`,children:Vw.map((e,t)=>(0,Q.jsxs)(`button`,{className:`keys-pop-row`,onPointerDown:$,onClick:()=>n(t),title:`${e.name} — ${e.does}`,children:[(0,Q.jsx)(`span`,{className:`keys-pop-key`,children:e.name}),(0,Q.jsx)(`span`,{className:`keys-pop-does`,children:e.does})]},e.name))})]})}var Kw=16,qw=e=>{e.preventDefault(),document.activeElement?.blur()},Jw=e=>[{label:`Esc`,title:`Esc — close a menu or interrupt ${e}`,data:`\x1B`,key:`esc`},{label:`Tab`,title:`Tab — complete`,data:` `,key:`tab`},{label:(0,Q.jsx)(Uf,{size:Kw}),title:`up — move the selection in a box`,data:`\x1B[A`,key:`up`,nav:!0},{label:(0,Q.jsx)(kp,{size:Kw}),title:`down — move the selection in a box`,data:`\x1B[B`,key:`down`,nav:!0},{label:(0,Q.jsx)(Jm,{size:Kw}),title:`left`,data:`\x1B[D`,key:`left`,nav:!0},{label:(0,Q.jsx)(gp,{size:Kw}),title:`right`,data:`\x1B[C`,key:`right`,nav:!0},{label:`^C`,title:`Ctrl-C — cancel`,data:``},{label:(0,Q.jsx)(Wf,{size:Kw}),title:`Return — confirm the selection`,data:`\r`,key:`enter`}],Yw=[{mod:`ctrl`,label:`Ctrl`},{mod:`alt`,label:`Alt`},{mod:`shift`,label:`Shift`}],Xw={off:``,once:`next`,lock:`lock`},Zw=(e,t)=>t===`off`?`${e} — tap, then a key (on this row or typed): it goes with ${e}. Tap twice to lock.`:t===`once`?`${e} is held for the next key. Tap again to lock it, a third time to let go.`:`${e} is locked for every key until you tap it again.`;function Qw({active:e,backends:t,compose:n,keysOpen:r,setKeysOpen:i}){let{cliMode:a,sendInput:o,toggleCliMode:s}=n,c=JSON.stringify(e.keyHints??[]),[l,u]=(0,Z.useState)({of:``,keys:[]}),d=l.of===c?l.keys:[];return(0,Q.jsxs)(`div`,{className:`keys`,children:[(e.keyHints??[]).map(e=>{let t=F(e.key);if(!t||d.includes(e.key))return null;let r=`${e.key} — ${e.verb} (the CLI names this key on screen now)`;return(0,Q.jsxs)(K,{className:`key-hint`,title:r,"aria-label":r,onPointerDown:$,onClick:()=>{n.chord.clear(),o(t),e.key!==`shift+tab`&&u({of:c,keys:[...d,e.key]})},children:[Ge(e.key),` `,(0,Q.jsx)(`span`,{className:`key-hint-verb`,children:e.verb})]},`hint:${e.key}`)}),Jw(Pa(t,e.backend)).map((e,t)=>(0,Q.jsx)(K,{title:e.title,"aria-label":e.title,onPointerDown:e.nav&&!a?qw:$,onClick:()=>e.key?n.chord.sendKey(e.key,e.data):o(e.data),children:e.label},t)),Yw.map(({mod:e,label:t})=>{let r=n.chord.mods[e];return(0,Q.jsxs)(K,{className:`mod-key${r===`off`?``:` active`}`,title:Zw(t,r),"aria-label":Zw(t,r),"aria-pressed":r!==`off`,onPointerDown:$,onClick:()=>n.tapChordMod(e),children:[(0,Q.jsx)(`span`,{children:t}),r!==`off`&&(0,Q.jsx)(`span`,{className:`mod-state`,children:Xw[r]})]},e)}),$s(t,e.backend)&&(0,Q.jsxs)(K,{className:r?`active`:void 0,onPointerDown:$,onClick:()=>i(e=>!e),"aria-expanded":r,title:`claude's own shortcuts (ctrl+o transcript, ctrl+t todos, alt+p model…) — one tap each`,"aria-label":`claude's shortcuts`,children:[(0,Q.jsx)(_m,{size:Kw}),` Keys`]}),(0,Q.jsxs)(K,{className:`cli-key ${a?`active`:``}`,"data-hint":`compose.cli`,onPointerDown:$,onClick:s,title:a?`CLI mode is on — every key you type goes straight to the session. Tap to go back to composing (queued, confirmed sends).`:`CLI mode — type directly at the CLI instead of composing a message: keystrokes go through as you type, nothing is queued or echo-checked.`,children:[(0,Q.jsx)(Rf,{size:Kw}),` CLI`]})]})}function $w(e,t){let[n,r]=(0,Z.useState)(null),i=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{let t=!0,n=async()=>{let n=await Ro(e).catch(()=>null);t&&n&&n.value.updatedAt!==i.current&&(i.current=n.value.updatedAt,r(n.value.turns))};return n().then(()=>Ki(e,!0)).catch(()=>void 0).then(n),()=>{t=!1}},[e,t]),n}function eT({sessionId:e,refreshKey:t,busy:n,turnStartedAt:r,nextTurn:i,usdPerWeekPct:a,weekIncl:o,onOpenCost:s,chipOnly:c}){let l=$w(e,t),[u,d]=(0,Z.useState)(()=>rt(W.termCostOpen)),f=(0,Z.useMemo)(()=>Ti(l??[]),[l]),p=(0,Z.useMemo)(()=>Dn(l??[]),[l]);if(!l||!p)return null;let m=gn(p,n,r);return(0,Q.jsx)(Wd,{className:`tcs`,bodyClass:`tcs-body`,growsUp:!0,t:p,which:m,open:u&&!c,onToggle:()=>{let e=!u;Y(e?`action:term.cost.open`:`action:term.cost.close`),tt(W.termCostOpen,e),d(e)},onChip:c&&s?()=>{Y(`action:term.cost`),s()}:void 0,slots:f,agentsSoFar:Ea(l,p.id),usdPerWeekPct:a,weekIncl:o,onOpen:s,trackId:`action:term.cost`,next:m===`last`&&p.id===l[l.length-1]?.id?Xe(i):null,why:!0})}var tT=e=>e.onSessionScreen&&e.typingRoom&&e.composeFocused;function nT(e){let t=tT(e),n=t&&!e.cliMode,r=n&&!e.typingPeek,i=n&&e.typingPeek,a=t&&e.cliMode,o=(e.fullScreen||a)&&e.onSessionScreen&&!r&&!(t&&e.typingPeek);return{typingMode:r,typingPeeking:i,fullMode:o,chromeHidden:r||o}}function rT(e){let{chromeHidden:t}=nT(e),n=!t;return{fullScreen:n,typingPeek:tT(e)?!n:e.typingPeek}}var iT=40;function aT(e,t,n){if(!e||Math.abs(e.w-n)>2)return{next:{baseH:t,minH:t,w:n},closed:!1};let r={...e,minH:Math.min(e.minH,t),w:n};return{next:r,closed:r.baseH-r.minH>=120&&t>=r.baseH-iT}}var oT=16,sT=e=>`${e} line${e>1?`s`:``}`;function cT(e){return Dr(e.join(`
|
|
168
|
-
`))?(G(`quoted ${sT(e.length)} into compose`),!0):!1}async function lT(e){try{await navigator.clipboard.writeText(e.join(`
|
|
169
|
-
`)),G(`copied ${sT(e.length)}`)}catch{G(`clipboard unavailable (needs https) — quote puts the lines in compose instead`)}}function uT({at:e,onPick:t,onCancel:n}){let r=(0,Z.useRef)(null);return Ju(!0,n),(0,Z.useEffect)(()=>{let e=e=>{r.current?.contains(e.target)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[n]),(0,Q.jsxs)(`div`,{ref:r,className:`tpick-menu`,style:{left:Math.max(8,Math.min(e.x-110,window.innerWidth-236)),top:e.y+220>window.innerHeight?Math.max(8,e.y-220):e.y+28},children:[(0,Q.jsxs)(K,{onClick:t,children:[(0,Q.jsx)(xp,{size:oT}),` pick lines`]}),(0,Q.jsxs)(K,{onClick:()=>{n(),Lr()},children:[(0,Q.jsx)(km,{size:oT}),` answer list`]}),(0,Q.jsxs)(K,{onClick:n,children:[(0,Q.jsx)(mp,{size:oT}),` select text`]}),(0,Q.jsxs)(K,{onClick:()=>{window.getSelection()?.removeAllRanges(),n()},children:[(0,Q.jsx)(X,{size:oT}),` cancel`]})]})}function dT({count:e,off:t,hint:n,lines:r,onStop:i}){return Ju(!0,i),(0,Q.jsxs)(`div`,{className:`tpick-bar`,children:[(0,Q.jsx)(`span`,{className:`tpick-count`,children:e?(0,Q.jsxs)(Q.Fragment,{children:[e,` picked`,t?(0,Q.jsxs)(Q.Fragment,{children:[`, `,t,` out of view`]}):null]}):n}),e>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(K,{onClick:()=>{cT(r())&&i()},children:[(0,Q.jsx)(Lf,{size:oT}),` quote`]}),(0,Q.jsxs)(K,{onClick:()=>void lT(r()),children:[(0,Q.jsx)(Qf,{size:oT}),` copy`]}),(0,Q.jsxs)(K,{onClick:()=>{let e=r();i(),Lr(e)},children:[(0,Q.jsx)(km,{size:oT}),` answer`]})]}),(0,Q.jsxs)(K,{onClick:i,children:[(0,Q.jsx)(X,{size:oT}),` `,e?`cancel`:`done`]})]})}function fT(e,t){let n,r=0,i=0,a=()=>{clearTimeout(n),n=void 0},o=e=>{if(a(),e.touches.length!==1)return;let o=e.touches[0],s=e.target;r=o.clientX,i=o.clientY,n=window.setTimeout(()=>{n=void 0,t(r,i,s)},450)},s=e=>{n!==void 0&&e.touches.length===1&&Math.hypot(e.touches[0].clientX-r,e.touches[0].clientY-i)>8&&a()};return e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),e.addEventListener(`touchend`,a,{passive:!0}),e.addEventListener(`touchcancel`,a,{passive:!0}),()=>{a(),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s),e.removeEventListener(`touchend`,a),e.removeEventListener(`touchcancel`,a)}}var pT=150;function mT(e,t){let n=new Set;return e.map(e=>{if(e.row>=0&&t[e.row]===e.text&&!n.has(e.row))return n.add(e.row),e;let r=-1;return t.forEach((t,i)=>{t===e.text&&!n.has(i)&&(r<0||Math.abs(i-e.row)<Math.abs(r-e.row))&&(r=i)}),r>=0&&n.add(r),{text:e.text,row:r}})}function hT(e,t,n){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)({grid:[],box:null}),d=(0,Z.useRef)(void 0),f=()=>{let t=e.current;if(!t)return;let n=t.snapshot();u({grid:n,box:t.rowBox()}),c(e=>e.length?mT(e,n):e)};(0,Z.useEffect)(()=>{i(null),o(!1),c([])},[n]),(0,Z.useEffect)(()=>{if(a)return clearTimeout(d.current),d.current=window.setTimeout(f,pT),()=>clearTimeout(d.current)},[a,t]),(0,Z.useEffect)(()=>{if(!a)return;let e=()=>{clearTimeout(d.current),d.current=window.setTimeout(f,pT)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[a]);let p=e=>{let t=l.grid[e];t?.trim()&&c(n=>n.some(t=>t.row===e)?n.filter(t=>t.row!==e):[...n,{text:t,row:e}])},m=t=>{Y(`action:termpick.start`),window.getSelection()?.removeAllRanges(),i(null);let n=e.current,r=n?.snapshot()??[];u({grid:r,box:n?.rowBox()??null}),c(t!=null&&r[t]?.trim()?[{text:r[t],row:t}]:[]),o(!0)},h=()=>{o(!1),c([])},g=(0,Z.useCallback)(()=>i(null),[]),_=()=>(s.every(e=>e.row>=0)?[...s].sort((e,t)=>e.row-t.row):s).map(e=>e.text),v=(e,t,n)=>{a||i({row:e,x:t,y:n})},y=new Set(s.filter(e=>e.row>=0).map(e=>e.row)),b=s.filter(e=>e.row<0).length,{box:x,grid:S}=l,C=a&&x?(0,Q.jsx)(`div`,{className:`tpick-layer`,style:{top:x.top,left:x.left,width:x.width,height:x.rowH*x.rows},children:Array.from({length:x.rows},(e,t)=>{let n=!!S[t]?.trim();return(0,Q.jsx)(`div`,{className:`tpick-row${y.has(t)?` on`:``}`,style:{height:x.rowH},onClick:e=>{e.stopPropagation(),p(t)},children:n&&(0,Q.jsx)(`span`,{className:`tpick-box`,style:{width:x.rowH-3,height:x.rowH-3},children:y.has(t)&&(0,Q.jsx)(bm,{size:Math.max(10,x.rowH-5),strokeWidth:3})})},t)})}):null,w=r&&(0,Q.jsx)(uT,{at:r,onPick:()=>m(r.row),onCancel:g}),T=a&&(0,Q.jsx)(dT,{count:s.length,off:b,hint:`tap lines to pick them — panning still scrolls`,lines:_,onStop:h});return{onLongPress:v,gutter:C,chrome:(0,Q.jsxs)(Q.Fragment,{children:[w,T]})}}var gT=`.tr-body .tr-p, .tr-body .tr-list > li, .tr-body .tr-h, .tr-body .tr-quote, .tr-body .tr-code`,_T=`tpick`;function vT(e){let t=e.innerText.trim(),n=e.tagName===`LI`?e.parentElement:null;return n?.tagName===`OL`?`${(Number(n.start)||1)+[...n.children].indexOf(e)}. ${t}`:t}function yT(e,t,n){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)([]),l=(0,Z.useRef)(!1);l.current=a;let u=(0,Z.useCallback)(e=>{for(let t of e)delete t.el.dataset[_T]},[]),d=(0,Z.useCallback)(()=>{o(!1),c(e=>(u(e),[]))},[u]),f=(0,Z.useCallback)(()=>i(null),[]);(0,Z.useEffect)(()=>{i(null),d()},[t,n,d]),(0,Z.useEffect)(()=>{let t=e.current;if(t)return fT(t,(e,t,n)=>{if(l.current)return;let r=n instanceof Element?n.closest(gT):null;i({x:e,y:t,el:r})})},[e,n]),(0,Z.useEffect)(()=>{let t=e.current;if(!t||!a)return;let n=e=>{let n=e.target instanceof Element?e.target.closest(gT):null;n&&t.contains(n)&&(e.preventDefault(),e.stopPropagation(),c(e=>e.some(e=>e.el===n)?(delete n.dataset[_T],e.filter(e=>e.el!==n)):(n.dataset[_T]=`1`,[...e,{el:n,text:vT(n)}])))};return t.addEventListener(`click`,n,!0),t.classList.add(`tpick-reading`),()=>{t.removeEventListener(`click`,n,!0),t.classList.remove(`tpick-reading`)}},[e,a,n]);let p=e=>{Y(`action:readpick.start`),window.getSelection()?.removeAllRanges(),i(null),e&&(e.dataset[_T]=`1`),c(e?[{el:e,text:vT(e)}]:[]),o(!0)},m=()=>[...s.filter(e=>e.el.isConnected).sort((e,t)=>e.el.compareDocumentPosition(t.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),...s.filter(e=>!e.el.isConnected)].map(e=>e.text),h=s.filter(e=>!e.el.isConnected).length;return{chrome:(0,Q.jsxs)(Q.Fragment,{children:[r&&(0,Q.jsx)(uT,{at:r,onPick:()=>p(r.el),onCancel:f}),a&&(0,Q.jsx)(dT,{count:s.length,off:h,hint:`tap paragraphs or list items to pick them`,lines:m,onStop:d})]})}}function bT(e,t,n){return e<=1||t<=0||n<=0?e:Math.max(1,e-Math.floor(t/n))}function xT(e,t,n){return Math.max(0,e-t)*n}var ST={x:0,y:0},CT=40,wT=8,TT=16,ET=12,DT=4,OT=350;function kT(){let e=it(W.termCornerPos,null);if(!e||!Number.isFinite(e.x)||!Number.isFinite(e.y))return ST;let t=Number.isInteger(e.cols)&&e.cols>=1?e.cols:void 0;return{x:e.x,y:e.y,...t?{cols:t}:{}}}function AT(e,t,n){let r=e.offsetParent;if(!r)return n;let i=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=i.left-t.x,s=i.top-t.y,c=a.left-o,l=a.right-wT-(o+i.width),u=a.top-s,d=a.bottom-(s+i.height);return{x:Math.round(Math.min(Math.max(n.x,c),Math.max(c,l))),y:Math.round(Math.min(Math.max(n.y,u),Math.max(u,d)))}}function jT(e){let t=(0,Z.useRef)(null),[n,r]=(0,Z.useState)(kT),i=(0,Z.useRef)(n);i.current=n;let a=(0,Z.useRef)(null),o=(0,Z.useRef)(0),s=(0,Z.useRef)(CT),c=(0,Z.useCallback)(()=>{let e=t.current;if(!e)return;let n=AT(e,i.current,i.current);(n.x!==i.current.x||n.y!==i.current.y)&&r(n)},[]);(0,Z.useLayoutEffect)(c,[c,n.cols]),(0,Z.useEffect)(()=>(window.addEventListener(`resize`,c),()=>window.removeEventListener(`resize`,c)),[c]);let l=e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let n=t.current,r=n?n.children.length:0,o=i.current,c=n?.offsetParent;if(n&&c&&r>1&&!o.cols){let t=c.getBoundingClientRect().right,i=t-wT-n.getBoundingClientRect().right,a=t-TT-e.clientX-i;s.current=Math.max(ET,a/(r-.5))}let l=s.current,u=o.cols?Math.min(o.cols,r):r,d={x:o.x+xT(r,u,l),y:o.y};a.current={id:e.pointerId,sx:e.clientX,sy:e.clientY,base:d,moved:!1,n:r,step:l}},u=e=>{let n=a.current,o=t.current;if(!n||n.id!==e.pointerId||!o)return;let s=e.clientX-n.sx,c=e.clientY-n.sy;if(!n.moved&&Math.hypot(s,c)<DT)return;n.moved=!0;let l={x:n.base.x+s,y:n.base.y+c},u=o.offsetParent,d=u?u.getBoundingClientRect().right-wT-(o.getBoundingClientRect().right-i.current.x):l.x,f=bT(n.n,l.x-d,n.step),p=AT(o,i.current,l);r(f<n.n?{...p,cols:f}:p)},d=t=>{let n=a.current;if(!n||n.id!==t.pointerId)return;if(a.current=null,n.moved){pt(W.termCornerPos,i.current);return}let r=Date.now();r-o.current<OT?(o.current=0,p(),e(!0)):(o.current=r,e(!1))},f=()=>{a.current=null},p=()=>{r(ST),pt(W.termCornerPos,ST)},m=n.x!==0||n.y!==0;return{ref:t,style:m||n.cols?{...m?{transform:`translate(${n.x}px, ${n.y}px)`}:{},...n.cols?{display:`grid`,gridTemplateColumns:`repeat(${n.cols}, auto)`}:{}}:void 0,handle:{onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:f}}}function MT(e,t){return e.defaultPrevented||e.isComposing||t.editable||t.inTerminal||e.ctrlKey||e.altKey||e.metaKey||e.key===`Escape`||e.key===`Tab`||t.activatable&&(e.key===`Enter`||e.key===` `)?null:e.key===`Backspace`?``:e.key.length===1?e.key:qg(e)}function NT(e){let t=e?.tagName?.toUpperCase()??``;return{editable:t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||!!e?.isContentEditable,inTerminal:!!e?.closest?.(`.xterm`),activatable:!!e?.closest?.(`button, a[href], summary, [role=button]`)}}var PT=`#root > .ws-panel, [role=dialog], .bl-modal-backdrop`;function FT(e,t,n,r){let i=i=>{MT(i,NT(i.target))!=null&&e.setTimeout(()=>{if(r())return;let e=MT(i,NT(i.target));e!=null&&(t(e),n())},0)};return e.addEventListener(`keydown`,i),()=>e.removeEventListener(`keydown`,i)}var IT=16;function LT({zoom:e,active:t,pending:n,readerShown:r,readMode:i,setView:a,sessionCan:o,chrome:s,wheel:c,openOutline:l}){let[u,d]=(0,Z.useState)(!1),f=jT(e=>G(e?`buttons back in the corner`:`drag the grip to move these buttons; double-tap it to put them back`)),p=(0,Z.useRef)(null),{chromeHidden:m,setFullScreen:h,setTypingPeek:g,chromeIn:_}=s,v=q(`txtScale`),y=q(`tZoom`),b=q(`rZoom`),x=e!==!1,S=r?b:y,C=r?Hl:Pu,w=r?vl:md,T=r?`reader`:`console`,E=C(S,-1,v),D=C(S,1,v),O=r?``:`, i.e. more columns and rows for the CLI to draw in`,k=r?``:`, i.e. fewer columns and rows`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{ref:f.ref,className:`term-zoom`,"data-hint":`term.zoom`,style:f.style,children:[(0,Q.jsx)(K,{className:`term-zoom-grip`,"data-hint":`term.grip`,"aria-label":`move these buttons`,title:`drag to move these buttons; double-tap to put them back`,...f.handle,children:(0,Q.jsx)(Dp,{size:IT})}),!n&&l&&(0,Q.jsxs)(K,{className:`term-zoom-outline`,"data-hint":`toolbar:outline`,onPointerDown:$,"aria-label":`outline`,title:`outline — where you are in this session${xx(bx(t))}`,onClick:l,children:[(0,Q.jsx)(Jp,{size:IT}),bx(t)==null?null:(0,Q.jsx)(`span`,{className:`term-zoom-count`,children:bx(t)})]}),!n&&o(t,`transcript`)&&!(t.cliSetup&&t.running)&&(0,Q.jsx)(K,{"data-hint":`term.read`,onPointerDown:$,"aria-label":i?`back to the terminal`:`reader view`,title:i?`back to the terminal`:`reader view — scrollable, searchable transcript of this conversation`,onClick:()=>{Y(`action:read.toggle`),a(!i)},children:i?(0,Q.jsx)(Rf,{size:IT}):(0,Q.jsx)(wp,{size:IT})}),!n&&!no(c.backends,t.backend)&&(()=>{let e=Wv(t),n=`model, effort and mode${e?` — now ${Iv(e)}`:``}`;return(0,Q.jsxs)(K,{ref:p,className:[u&&`active`,e&&`mw-badged`].filter(Boolean).join(` `),"data-hint":`term.modelwheel`,onPointerDown:$,"aria-label":n,"aria-expanded":u,title:n,onClick:()=>{Y(`action:modelwheel.open`),d(e=>!e)},children:[(0,Q.jsx)(Cp,{size:IT}),e&&(0,Q.jsx)(`span`,{className:`mw-badge`,children:(0,Q.jsx)(jw,{mode:e,size:12})})]})})(),x&&(0,Q.jsx)(rl,{smaller:E,bigger:D,onZoom:w,what:T,subject:`the ${T}`,smallerHint:O,biggerHint:k,endClassName:`term-zoom-px muted`,iconSize:IT}),(0,Q.jsx)(K,{className:m?`active`:void 0,"data-hint":`term.fullscreen`,onPointerDown:$,"aria-label":m?`leave full screen`:`full screen`,"aria-pressed":m,title:m?`leave full screen — the header, status and toolbar come back`:`full screen — hide the header, status and toolbar and give the rows to the ${r?`conversation`:`output`}. No keyboard${r?``:`: the Esc/arrow row stays`}.`,onClick:()=>{let e=rT(_);Y(e.fullScreen?`action:fullscreen.on`:`action:fullscreen.off`),h(e.fullScreen),g(e.typingPeek)},children:m?(0,Q.jsx)(Gp,{size:IT}):(0,Q.jsx)(Im,{size:IT})})]}),u&&!n&&!no(c.backends,t.backend)&&(0,Q.jsx)(Iw,{cur:t,backends:c.backends,canSlash:o(t,`slash`),submitInput:c.submitInput,relaunch:c.relaunch,liveAsk:c.liveAsk,anchor:p,onClose:()=>d(!1)})]})}function RT(e){let{active:t,pending:n,conn:r,term:i,q:a,compose:o,launch:s,chrome:c,backends:l,readerShown:u,hiddenSlash:d,activeRepoId:p,transportKnown:m,setActiveId:h,closeSession:g,openOutline:_}=e,{pendingEntry:v}=a,{status:y,connVisible:b,send:x}=r,{tailscaleIp:S}=r.info,{termRef:C,geomRef:w,buffers:T,lastPtyAt:E,ptyTail:D,exitedRef:O,staleAt:k,writeSeq:A,termNonce:j,readMode:M,setView:ee,readerCmd:N,outlineJump:P,transcriptNonce:F}=i,I=a.entries,{answerPrompt:te,retryPendingCreate:L,submitInput:R}=a,{cliMode:z,sendInput:ne,focusPipe:B}=o,[V,H]=(0,Z.useState)(!1),{sessionCan:ie,openCwd:oe,runForkRequest:U}=s,{dismissedReply:se,setDismissedReply:ce}=c,[le,ue]=(0,Z.useState)(``),de=Kt(),fe=Sf(),pe=hT(C,A,t.id),me=t.prompt?I.filter(e=>e.answer?.fingerprint===ae(t.prompt)&&e.status!==`failed`).map(e=>({label:e.answer.label})):[],he=(e,n,r,i,a)=>te(t,e,n,r,i,a),ge=(0,Z.useRef)(null),_e=yT(ge,t.id,u),ve=M&&!!t.cliSetup&&t.running,ye=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{ve?ye.current!==t.id&&(ye.current=t.id,G(bf(l,t.backend))):ye.current===t.id&&(ye.current=null,M&&t.running&&!t.cliSetup&&G(ta(l,t.backend)))},[ve,t.id,t.running,t.cliSetup,t.backend,l,M]);let be=(0,Z.useRef)(ne);be.current=ne,(0,Z.useEffect)(()=>u||n?void 0:FT(window,e=>be.current(e),()=>C.current?.focus(),()=>!!document.querySelector(PT)),[u,n,C]);let xe=q(`toolsMode`),Se=q(`txtScale`),Ce=q(`rZoom`),we=e=>(0,Q.jsx)(LT,{zoom:e,active:t,pending:n,readerShown:u,readMode:M,setView:ee,sessionCan:ie,chrome:c,openOutline:_,wheel:{backends:l,submitInput:R,relaunch:s.relaunch,liveAsk:r.liveAsk}});return yh(t.id)?(0,Q.jsx)(`div`,{className:`term-area term-later`,children:(0,Q.jsx)(`div`,{className:`term-overlay as-card`,children:(0,Q.jsxs)(`div`,{className:`term-overlay-box`,children:[(0,Q.jsx)(Zf,{size:16}),(0,Q.jsx)(`span`,{children:`The session starts only once this backlog item runs.`}),(0,Q.jsxs)(`span`,{className:`term-overlay-hint`,children:[`Send queues it for when this repo is free; the arrow beside Send has `,(0,Q.jsx)(`em`,{children:`elsewhere or later…`}),` for a clock. Write, chain and attach here — nothing is queued until you send.`]})]})})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`term-area`,children:[!n&&(0,Q.jsx)(Pl,{className:`toolbar-cants`,cants:ld(l,ni(t),{hiddenSlash:d})}),!n&&Bu(l,t.backend)&&(0,Q.jsx)(`div`,{className:`act-cants toolbar-cants`,children:(0,Q.jsxs)(`span`,{className:`act-cant`,children:[(0,Q.jsx)(Rf,{size:11}),` `,Bu(l,t.backend)]})}),(0,Q.jsxs)(`div`,{className:`term-wrap`,children:[b&&y!==`open`&&(0,Q.jsxs)(`div`,{className:`conn-banner floating conn-${y}`,children:[y===`closed`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kp,{size:12}),` connection lost — reconnecting…`]}):`connecting…`,S?` · ${S}`:``]}),u?(0,Q.jsxs)(`div`,{ref:ge,className:`tr-zoom`,style:{"--ui-font":String(Bc(Se,Ce))},children:[(0,Q.jsx)(an,{sessionId:t.id,refreshKey:F,status:{running:t.running,busy:t.hooked?!!t.turnActive:t.running&&!t.idle,exact:!!t.hooked,waiting:!!t.prompt,prompt:t.prompt,suggestion:t.suggestion,awaitingInput:!!t.awaitingInput,asking:t.asking,agents:t.agents,shells:t.shells,shellList:t.shellList,blocked:!!t.limit?.blocked,turnStartedAt:t.turnStartedAt,lastOutputAt:E.current.get(t.id),tail:D.current.get(t.id),linkDown:y!==`open`},onShowCli:()=>ee(!1),cliPeek:n?void 0:(e,n)=>(0,Q.jsx)(Dw,{chunks:T.current.get(t.id)??[],writeSeq:A,cols:w.current.cols,rows:w.current.rows,leaving:e,onGone:n,onOpen:()=>{Y(`action:read.peekToCli`),ee(!1)}}),onAnswer:he,onStop:()=>ne(`\x1B`),queuedAnswers:me,cmd:N??void 0,toolsMode:xe,fork:ie(t,`fork`)?{online:y===`open`,hasId:!!Ut(t),run:e=>void U(t,e)}:void 0,jumpTo:P??void 0,onOpenCost:Fc,nextTurn:re(t.contextSpark,{lastTurnAt:t.lastTurnAt,turnActive:t.turnActive,now:Date.now()}),usdPerWeekPct:de,weekIncl:fe,onOpenShells:()=>Di(t),files:p?{repoId:p,url:(e,t,n)=>{let r=Gd.artifactUrl(p,e);return t?Iu(r,t,n):r},open:e=>Pt(p,e),known:m}:void 0,onToast:G},t.id),_e.chrome]}):(()=>{let e=T.current.get(t.id)??[],r=e.some(e=>e.length>0),i=k.get(t.id),s=y!==`open`&&b,c=!t.running||y!==`open`&&O.current.has(t.id),u=i??E.current.get(t.id),d=n?`pending`:c?`ended`:s?`offline`:r?null:`empty`,p=!r;return(0,Q.jsxs)(`div`,{className:`term-stage`,children:[(0,Q.jsx)(`div`,{className:`term-canvas${i==null?``:` stale`}`,onClick:z?B:void 0,children:(0,Q.jsx)(Cw,{ref:C,pending:e,writeSeq:A,onInput:ne,onResize:(e,r)=>{w.current={cols:e,rows:r},n||x({t:`session.resize`,id:t.id,cols:e,rows:r})},linkUp:y===`open`,onScreen:e=>ai(t.id,e),onCursorLine:o.noteCursorLine,onReachBack:()=>{Y(`action:scrollback.reachback`),It()},onScrollStalled:()=>G(`no new output from that scroll — “scrollback” reads this device's own copy`),onLongPress:pe.onLongPress,children:pe.gutter},`${t.id}:${j}`)}),we(!p),pe.chrome,V&&!n&&$s(l,t.backend)&&!Ow(t.prompt,t.running)&&(0,Q.jsx)(Gw,{sendInput:ne,onClose:()=>H(!1)}),Ow(t.prompt,t.running)&&(0,Q.jsx)(`div`,{className:`term-answer`,"data-box":`trust`,children:(0,Q.jsx)(Cf,{prompt:t.prompt,queued:me,suggestion:t.suggestion,onAnswer:he,ev:`term.trust`})}),d&&(0,Q.jsx)(`div`,{className:`term-overlay ${p?`as-card`:`as-chip`} term-overlay-${d}${d===`pending`&&v?.status===`failed`?` failed`:``}`,children:(0,Q.jsxs)(`div`,{className:`term-overlay-box`,children:[d===`empty`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(om,{size:16,className:`spin`}),` `,(0,Q.jsx)(`span`,{children:`no output yet — the session is running and hasn’t printed anything`})]}),d===`offline`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xf,{size:16}),(0,Q.jsxs)(`span`,{children:[`offline — `,r?(0,Q.jsxs)(Q.Fragment,{children:[`output as of `,u?Dl(u):`the last connection`]}):(0,Q.jsx)(Q.Fragment,{children:`nothing cached for this session yet`})]}),p&&(0,Q.jsx)(`span`,{className:`term-overlay-hint`,children:`It reappears the moment the tunnel is back. Anything you send is queued, not lost.`}),gi(t.id)&&(0,Q.jsx)(`span`,{className:`term-overlay-acts`,children:(0,Q.jsxs)(K,{title:`earlier output, read from this device (pan up on the terminal does the same)`,onClick:It,children:[(0,Q.jsx)(Cm,{size:14}),` scrollback`]})})]}),d===`pending`&&(()=>{let e=v?.status===`failed`,t=v?.status===`pending`,n=!t&&y===`open`&&v?a.blocked.get(v.ackId):void 0;return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(Kp,{size:16}):(0,Q.jsx)(om,{size:16,className:`spin`}),(0,Q.jsx)(`span`,{children:e?(0,Q.jsxs)(Q.Fragment,{children:[`the session was not started — `,v?.reason||`the desktop refused it`]}):v?n?(0,Q.jsxs)(Q.Fragment,{children:[`not opened yet — `,f(n)]}):t||y===`open`?(0,Q.jsx)(Q.Fragment,{children:`warming up the CLI for you…`}):(0,Q.jsx)(Q.Fragment,{children:`offline — the session will be created once you are back online`}):(0,Q.jsx)(Q.Fragment,{children:`the desktop has it — the session opens in a moment…`})}),(0,Q.jsx)(`span`,{className:`term-overlay-hint`,children:e?`Anything typed here is still in the queue and can be re-aimed from Activity.`:`Write, chain and attach now — it all goes into this session the moment it opens.`}),(0,Q.jsxs)(`span`,{className:`term-overlay-acts`,children:[e&&(0,Q.jsxs)(K,{title:`try this open again`,onClick:L,children:[(0,Q.jsx)(xm,{size:14}),` try again`]}),(0,Q.jsxs)(K,{title:e?`back to the launcher`:`stop waiting — the open stays queued and can be dropped in Activity`,onClick:()=>h(null),children:[(0,Q.jsx)(Qp,{size:14}),` back`]})]})]})})(),d===`ended`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{size:16}),(0,Q.jsxs)(`span`,{children:[`session ended`,s?` · offline, so this is the last state we saw`:``]}),(0,Q.jsxs)(`span`,{className:`term-overlay-acts`,children:[(0,Q.jsxs)(K,{title:`reopen this session — ${yf(!!Ut(t))}`,onClick:()=>oe(t.cwd,t.title,!0,`continue`,{model:t.model,effort:t.effort,permissionMode:t.permissionMode,backend:t.backend},Ut(t)),children:[(0,Q.jsx)(xm,{size:14}),` reopen`]}),(0,Q.jsxs)(K,{title:`remove this session from the list`,onClick:()=>{g(t),h(null)},children:[(0,Q.jsx)(X,{size:14}),` close`]})]})]})]})})]})})(),u&&we(),!n&&(0,Q.jsx)(Dt,{session:t,readMode:M})]})]}),!n&&!u&&ie(t,`transcript`)&&(0,Q.jsx)(eT,{sessionId:t.id,refreshKey:F,busy:t.hooked?!!t.turnActive:t.running&&!t.idle,turnStartedAt:t.turnStartedAt,nextTurn:re(t.contextSpark,{lastTurnAt:t.lastTurnAt,turnActive:t.turnActive,now:Date.now()}),usdPerWeekPct:de,weekIncl:fe,onOpenCost:Fc,chipOnly:c.chromeHidden},t.id),t.login&&(0,Q.jsx)(gl,{login:t.login,onOpen:ku,onCopy:e=>void Jn(e),onPasteCode:()=>void Ri(t.id)}),!t.login&&xs(t)&&(0,Q.jsx)(Uu,{links:t.links??[],awaitingCode:!!t.awaitingCode,onOpen:ku,onCopy:e=>void Jn(e),onCopyCode:ao,onPasteCode:()=>void Ri(t.id),onLogins:Xr}),!t.prompt&&t.suggestion?.reply!=null&&t.suggestion.reply!==se&&(0,Q.jsx)(Zl,{suggestion:t.suggestion,onSend:e=>{R(t.id,t.cwd,e,`prompt`),ce(t.suggestion.reply)},onDismiss:()=>ce(t.suggestion.reply)},t.id+`:`+t.suggestion.reply),!t.prompt&&t.running&&!t.turnActive&&t.cliSuggestion&&t.cliSuggestion!==le&&(t.suggestion?.reply==null||t.suggestion.reply===se)&&(0,Q.jsx)(ia,{text:t.cliSuggestion,onSend:e=>{R(t.id,t.cwd,e,`prompt`),ue(e)},onDismiss:()=>ue(t.cliSuggestion),ev:`term`}),!n&&!u&&(0,Q.jsx)(Qw,{active:t,backends:l,compose:o,keysOpen:V,setKeysOpen:H}),(0,Q.jsx)(Wc,{sessionId:t.id}),!n&&(0,Q.jsx)(al,{session:t,readMode:u})]})}function zT(e){let{active:t,pending:n,conn:r,term:i,q:a,compose:o,launch:s,chrome:c,backends:l,sessions:u,update:d,readerShown:f,activeRepo:p,transportKnown:m,visibleBacklogItems:h,repoForCwd:g,sessionRepoName:_,setActiveId:v,setOverlay:y,runToolbar:b}=e,{pendingStars:x,toggleStar:S,pendingFollowUps:C,toggleFollowUp:w,closeSession:T}=e.verbs,{status:E,liveSend:D,liveAsk:O,reconnectAsk:k,setReconnectAsk:A}=r,j=a.entries,{pendingEntry:M,outboxRef:ee,holdWall:N,isPendingId:P,sendQueuedNow:F,editQueued:I,toggleHoldQueued:te,handToDesktop:L,removeQueued:R}=a,{uploading:z,parking:ne,upProg:re,uploadPending:B,uploadRowLinger:V,cancelUploads:H}=a.uploads,{chromeHidden:ie,fullMode:ae}=c,oe=p?.id??null,U=rf(),se=qd(),ce=$o(),le=q(`autoSend`),ue=q(`confirmQueue`),de=ds(s.sessionCan(t,`slash`)),fe={active:t,pending:n,status:E,activeRepo:p,toolbarCfg:se,pendingStars:x,toggleStar:S,pendingFollowUps:C,toggleFollowUp:w,setOverlay:y,runToolbar:b,backends:l};return(0,Q.jsxs)(`div`,{className:`screen${ie?` typing`:``}${ae?` fullscreen`:``}${f?` reading`:``}`,children:[(0,Q.jsx)(uw,{active:t,sessions:u,pending:n,pendingEntry:M,status:E,liveSend:D,backends:l,sessionCan:s.sessionCan,sessionRepoName:_,repoForCwd:g,setActiveId:v,setOverlay:y,removeQueued:R,closeSession:T,chrome:c,hdrShown:yh(t.id)?[]:de.shown,headerCmds:U,runHeaderCmd:o.runHeaderCmd,refreshTerminal:i.refreshTerminal,toolbar:fe}),(0,Q.jsx)(pw,{activeId:t.id}),(0,Q.jsx)(Ng,{httpsUrl:r.info.httpsUrl}),(0,Q.jsx)(Rg,{update:d,liveAsk:O,liveSend:D}),!n&&(0,Q.jsx)(Hg,{active:t,update:d,relaunch:s.relaunch}),(0,Q.jsx)(RT,{active:t,pending:n,conn:r,term:i,q:a,compose:o,launch:s,chrome:c,backends:l,readerShown:f,hiddenSlash:de.hiddenSlash,activeRepoId:oe,transportKnown:m,setActiveId:v,closeSession:T,openOutline:(se.pinned??[]).includes(`outline`)?()=>b(`outline`):void 0}),(0,Q.jsx)(DC,{active:t,outbox:j,outboxRef:ee,online:E===`open`,holdWall:N,isPendingId:P,sendQueuedNow:F,editQueued:I,removeQueued:R,toggleHoldQueued:te,handToDesktop:L,liveSend:D,setOverlay:y,intents:e.intents}),(0,Q.jsx)(gg,{q:a,status:E,reconnectAsk:k,setReconnectAsk:A,autoSend:le,confirmQueue:ue,pullRecords:ce,setOverlay:y,stripSessionId:t.id}),(0,Q.jsx)(bC,{api:o,active:t,sessions:u,outbox:j,online:E===`open`,repoForCwd:g,uploads:{uploading:z,parking:ne,upProg:re,uploadPending:B,uploadRowLinger:V,cancelUploads:H},activeRepoId:oe,pickImageFor:uf,pickFileFor:jd,visibleBacklogItems:h,setOverlay:y}),(0,Q.jsx)(Rb,{})]})}function BT(e){let{activeId:t,active:n,composeFocused:r,setComposeFocused:i,composeRef:a,cliMode:o}=e,[s,c]=(0,Z.useState)(``),l=q(`typingRoom`),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),g=e=>(!!e!==m&&h(!!e),e),_={onSessionScreen:!!n&&!m,typingRoom:l,composeFocused:r,cliMode:o,typingPeek:f,fullScreen:u},{typingMode:v,typingPeeking:y,fullMode:b,chromeHidden:x}=nT(_);return(0,Z.useEffect)(()=>{let e=document.documentElement;return x?e.dataset.typing=`1`:delete e.dataset.typing,()=>{delete e.dataset.typing}},[x]),(0,Z.useEffect)(()=>{m&&i(!1)},[m]),(0,Z.useEffect)(()=>{r||p(!1)},[r]),(0,Z.useEffect)(()=>{if(!r)return;let e=window.visualViewport,t=null,n=0,i=()=>aT(t,e?.height??window.innerHeight,e?.width??window.innerWidth),o=()=>{t=i().next,clearTimeout(n),n=window.setTimeout(()=>{let e=i();t=e.next,e.closed&&a.current?.blur()},350)};return t=i().next,e?.addEventListener(`resize`,o),window.addEventListener(`resize`,o),()=>{clearTimeout(n),e?.removeEventListener(`resize`,o),window.removeEventListener(`resize`,o)}},[r]),(0,Z.useEffect)(()=>{p(!1)},[t]),(0,Z.useEffect)(()=>{t||d(!1)},[t]),{fullScreen:u,setFullScreen:d,typingPeek:f,setTypingPeek:p,dismissedReply:s,setDismissedReply:c,typingMode:v,typingPeeking:y,fullMode:b,chromeHidden:x,chromeIn:_,drawnSheet:g}}function VT(e,t){if(!(e>0))return`ignore`;if(t&&String(t.tagName??``).toUpperCase()===`TEXTAREA`){let e=typeof t.className==`string`?t.className.split(/\s+/):[];if(e.includes(`pipe`)||e.includes(`xterm-helper-textarea`))return`ignore`}return`back`}function HT(e,t,n){let r=r=>{r.key!==`Escape`||r.isComposing||VT(t(),r.target)===`back`&&e.setTimeout(()=>{!r.defaultPrevented&&t()>0&&n()},0)};return e.addEventListener(`keydown`,r),()=>e.removeEventListener(`keydown`,r)}var UT=`(min-width: 1024px)`,WT=`data-layout`,GT=ms(`phone`);function KT(e,t){let n=()=>{let n=e?.matches?`wide`:`phone`;GT.set(n);try{t?.setAttribute(WT,n)}catch{}};return n(),e?e.addEventListener?(e.addEventListener(`change`,n),()=>e.removeEventListener?.(`change`,n)):(e.addListener?.(n),()=>e.removeListener?.(n)):()=>{}}function qT(){return Yd(GT)}function JT(){return qT()===`wide`}if(typeof window<`u`&&typeof document<`u`){let e=null;try{e=window.matchMedia?.(UT)??null}catch{e=null}KT(e,document.documentElement)}function YT(e,t){if(!Number.isFinite(e))return 320;let n=Number.isFinite(t)?t-600:760;return Math.round(Math.min(Math.max(240,Math.min(760,n)),Math.max(240,e)))}var XT=`--ws-side-w`;function ZT(e){let t=YT(e,window.innerWidth);return document.documentElement.style.setProperty(XT,`${t}px`),t}function QT(){let e=(0,Z.useRef)(320),t=(0,Z.useRef)(null),n=n=>{e.current=n,t.current?.setAttribute(`aria-valuenow`,String(n))};(0,Z.useEffect)(()=>(n(ZT(mt(W.wideSideW,320))),()=>{document.documentElement.style.removeProperty(XT)}),[]);let r=e=>{e===320?ft(W.wideSideW):nt(W.wideSideW,String(e))};return(0,Q.jsx)(`div`,{ref:t,className:`ws-side-grip`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Sidebar width: drag, or arrow keys; double-click resets`,title:`Drag to resize · double-click for the default width`,"aria-valuenow":320,tabIndex:0,onPointerDown:t=>{if(t.button!==0)return;t.preventDefault();let i=t.currentTarget;i.setPointerCapture(t.pointerId);let a=t.clientX,o=e.current;document.documentElement.classList.add(`ws-resizing`);let s=e=>n(ZT(o+e.clientX-a)),c=()=>{i.removeEventListener(`pointermove`,s),i.removeEventListener(`pointerup`,c),i.removeEventListener(`pointercancel`,c),document.documentElement.classList.remove(`ws-resizing`),r(e.current)};i.addEventListener(`pointermove`,s),i.addEventListener(`pointerup`,c),i.addEventListener(`pointercancel`,c)},onKeyDown:t=>{let i=t.key===`ArrowLeft`?-1:+(t.key===`ArrowRight`);if(!i)return;t.preventDefault();let a=ZT(e.current+i*16*(t.shiftKey?5:1));n(a),r(a)},onDoubleClick:()=>{let e=ZT(320);n(e),r(e)}})}var $T={beside:{VAR:`--ws-beside-w`,key:W.wideBesideW,cls:`ws-beside-grip`,label:`Annotator width`},panel:{VAR:`--ws-panel-w`,key:W.widePanelW,cls:`ws-panel-grip`,label:`Panel width`}},eE=440,tE=360,nE=24;function rE(){return document.querySelector(`#root > .ws-side`)?.getBoundingClientRect().width??320}function iE(e){let t=Math.max(eE,window.innerWidth-rE()-tE);return Math.round(Math.min(t,Math.max(eE,e)))}function aE(e){return e?.parentElement?.getBoundingClientRect().width??eE}function oE({of:e=`beside`}){let t=(0,Z.useRef)(null),{VAR:n,key:r,cls:i,label:a}=$T[e],o=e=>{let t=iE(e);return document.documentElement.style.setProperty(n,`${t}px`),t};return(0,Z.useEffect)(()=>{let e=mt(r,0);return e&&o(e),()=>{document.documentElement.style.removeProperty(n)}},[e]),(0,Q.jsx)(`div`,{ref:t,className:i,role:`separator`,"aria-orientation":`vertical`,"aria-label":`${a}: drag, or arrow keys; double-click resets`,title:`Drag to resize · double-click for the default width`,tabIndex:0,onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId);let n=e.clientX,i=aE(t),a=i;document.documentElement.classList.add(`ws-resizing`);let s=e=>{a=o(i-(e.clientX-n))},c=()=>{t.removeEventListener(`pointermove`,s),t.removeEventListener(`pointerup`,c),t.removeEventListener(`pointercancel`,c),document.documentElement.classList.remove(`ws-resizing`),nt(r,String(a))};t.addEventListener(`pointermove`,s),t.addEventListener(`pointerup`,c),t.addEventListener(`pointercancel`,c)},onKeyDown:e=>{let n=e.key===`ArrowLeft`?1:e.key===`ArrowRight`?-1:0;n&&(e.preventDefault(),nt(r,String(o(aE(t.current)+n*nE*(e.shiftKey?5:1)))))},onDoubleClick:()=>{document.documentElement.style.removeProperty(n),ft(r)}})}function sE({sheet:e,overlay:t,launcher:n,session:r}){let i=JT(),a=e||null,o=au()&&t===`image`&&!!a&&!!r,s=bd()&&o;cE(o,s);let c=i&&!!a&&!Es(t);return lE(i&&!!a&&!o,c?t:null),i?o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`aside`,{className:`ws-side`,children:[n,(0,Q.jsx)(QT,{})]}),r,(0,Q.jsxs)(`div`,{className:`ws-beside${s?` full`:``}`,children:[a,s?null:(0,Q.jsx)(oE,{})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`aside`,{className:`ws-side`,children:[n,(0,Q.jsx)(QT,{})]}),(c?null:a)??r??(0,Q.jsx)(`div`,{className:`screen ws-empty`,children:(0,Q.jsx)(Mc,{children:`Pick a session in the list, or start one.`})}),c?(0,Q.jsxs)(`div`,{className:`ws-panel`,children:[a,(0,Q.jsx)(oE,{of:`panel`})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[null,a??r??n,null]})}function cE(e,t){(0,Z.useEffect)(()=>{e||ks.set(!1)},[e]),(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),ks.set(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function lE(e,t){(0,Z.useEffect)(()=>e?HT(window,()=>nu.depth,()=>history.back()):void 0,[e]);let n=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=document.activeElement;if(!t){let t=n.current;n.current=null,t?.isConnected&&(!e||e===document.body)&&t.focus();return}e?.matches?.(`.compose textarea`)&&(n.current=e);let r=document.querySelector(`#root > .ws-panel`);r&&!r.contains(e)&&r.querySelector(`.back`)?.focus()},[t])}var uE=120;function dE(){(0,Z.useEffect)(()=>{let e=window.visualViewport,t=document.documentElement,n=0,r=()=>{t.style.removeProperty(`--app-h`),t.style.removeProperty(`--app-top`)},i=()=>{e?document.visibilityState!==`hidden`&&(e.height>=uE?(t.style.setProperty(`--app-h`,`${e.height}px`),t.style.setProperty(`--app-top`,`${Math.max(0,e.offsetTop)}px`)):r()):r()},a=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(i)},o=()=>{document.visibilityState===`visible`&&(a(),setTimeout(()=>{let e=document.getElementById(`root`);e&&e.getBoundingClientRect().height<uE&&r()},60))};return a(),e?.addEventListener(`resize`,a),e?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a),window.addEventListener(`orientationchange`,o),window.addEventListener(`pageshow`,o),window.addEventListener(`focus`,o),document.addEventListener(`visibilitychange`,o),document.addEventListener(`resume`,o),()=>{cancelAnimationFrame(n),e?.removeEventListener(`resize`,a),e?.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,a),window.removeEventListener(`orientationchange`,o),window.removeEventListener(`pageshow`,o),window.removeEventListener(`focus`,o),document.removeEventListener(`visibilitychange`,o),document.removeEventListener(`resume`,o)}},[])}function fE(){let e=mv(),{connRef:t,status:n,send:r,liveSend:i,liveSendAll:a,liveAsk:o,reconnectAsk:s,setReconnectAsk:c}=e,{httpsUrl:l,root:u}=e.info,d=zt(),f=q(`autoSend`),p=q(`serialSessions`),m=q(`confirmQueue`),{sessionsRaw:h,setSessions:g,recent:_,setRecent:v,closed:y,setClosed:b,repos:x,setRepos:S,reposAt:C,setReposAt:w,reposFailAt:T,setReposFailAt:E,intents:D,setIntents:O,backends:k,setBackends:A,update:j,setUpdate:M,meter:ee,setMeter:N,updateResultSeenRef:P}=dC(),F=jv(e,()=>Ne.current),{pendingStars:I,pendingFollowUps:te,closeSession:L}=F,R=(0,Z.useMemo)(()=>Sn(Sn(h,I,xa),te,zd),[h,I,te]),{initRoute:z,activeId:ne,setActiveId:re,overlay:B,setOverlay:V,closeSheet:H,overlayRef:ie,focusRepo:ae,setFocusRepo:oe}=gv(),U=kv({conn:e,activeId:ne,setActiveId:re,setOverlay:V,sessions:R,getActive:()=>yt,noteVisited:e=>We(e),onExit:()=>Ge.flushOutbox()});function se(e){Ve.current=!1,U.focus(e)}let{termRef:ce,geomRef:le,buffers:ue,exitedRef:de,readMode:fe,readModeRef:pe,setView:me,fireReader:he,setOutlineJump:ge,attach:_e}=U,ve=a_(),{compose:ye,setCompose:be,composeNow:xe,composeRef:Se,pushHistory:Ce,insertCompose:we,composeFocused:Te,setComposeFocused:Ee}=ve,De=q(`enterSends`),Oe=q(`cliMode`);tl(z,!!z.file&&Xi(z.file.relPath));let ke=la(),Ae=$o(),je=xf(),Me=na(),Ne=vc(R),Pe=vc(x),[Fe,Ie]=(0,Z.useState)(null),Le=Ct();Br();let Re=q(`tabsOn`);QS({connRef:t,setLaunch:e=>wt(e),setHiddenRepoIds:e=>Qt(e)}),Td(ne);let ze=hr(),Be=Ln(),Ve=(0,Z.useRef)(!1),He=(0,Z.useRef)(null),[Ue,We]=(0,Z.useState)(null),Ge=rg({conn:e,sessions:R,repos:x,activeId:ne,setActiveId:re,setLastVisitedId:e=>We(e),overlayRef:ie,setOverlay:V,wantNavRef:Ve,buffers:ue,readModeRef:pe,exitedRef:de,composeTextRef:xe,setCompose:be,pushHistory:Ce,openSend:e=>Bt(e),sendTargetFor:(e,t)=>Ut(e,t),repoForCwd:e=>un(e),focusSession:e=>se(e)}),Ke=Ge.entries,{outboxRef:qe,writeOutbox:Je,flushOutbox:Ye,idleReason:Xe,goneLanes:Ze,submitInput:Qe,queueOp:$e,queueBacklog:et,queueImageUpload:tt,pendingSession:nt,answerPrompt:rt,holdQueueRef:it,laneLabel:at,sendQueuedNow:ot,toggleHoldQueued:st,toggleSerialQueued:ct,removeQueued:lt,editQueued:ut,retargetQueued:W,restoreQueued:dt,retryFailedQueued:ft,moveQueued:pt,addPromptToQueuedCreate:mt,scheduleQueueRows:ht,dropScheduleQueue:gt,repoIdOfEntry:_t}=Ge,{allBufsRef:vt}=Ge.uploads,yt=(0,Z.useMemo)(()=>R.find(e=>e.id===ne)??nt,[R,ne,nt]),bt=!!nt&&yt?.id===nt.id,xt=pg({backends:k,setOverlay:V,geomRef:le,queue:Ge,setRepos:S,setReposAt:w,setReposFailAt:E,root:u,repos:x,active:yt,openingCwds:()=>an,repoForCwd:e=>un(e)}),{launch:St,setLaunch:wt,setLaunchOpt:Tt,pickBackend:Et,wireLaunch:Dt,sessionCan:Ot,sessionCant:kt,refreshRepos:At,openRepo:jt,openCwd:Mt,startSessionWithPrompt:Nt,relaunch:Pt}=xt,Ft=fe&&!bt&&nr(k,yt?ni(yt):void 0,`transcript`)&&!(yt?.cliSetup&&yt.running),It=Tg({connRef:t,liveSend:i,liveSendAll:a,queue:Ge,sessions:R,getVisibleRepos:()=>en,intents:D,usage:ze,launch:St,wireLaunch:Dt,geomRef:le,repoForCwd:e=>un(e),startSessionWithPrompt:Nt,setOverlay:V,attach:_e}),{sendSeed:Lt,sendSeedRef:Rt,openSend:Bt,seedFromIntent:Vt,seedFromSchedule:Ht,sendTargetFor:Ut,renderRetime:Wt}=It,Gt=o_(ve,{conn:e,active:yt,pending:bt,activeId:ne,sessions:R,readerShown:Ft,enterSends:De,cliModeOn:Oe,setCliModeOn:e=>J(`cliMode`,e),showCli:()=>me(!1),queue:Ge,sender:It,repoForCwd:e=>un(e),leave:()=>re(null),cliInstalled:j?.current,relaunch:Pt}),{cliMode:Kt,voice:qt}=Gt,Jt=BT({activeId:ne,active:yt,composeFocused:Te,setComposeFocused:Ee,composeRef:Se,cliMode:Kt}),Yt=(0,Z.useMemo)(()=>yt?my(x,yt.cwd):null,[yt,x]),Xt=Yt?.id??null,Zt=$m(Xt,fe),{setHiddenRepoIds:Qt,toggleHideRepo:$t,visibleRepos:en,hiddenRepos:tn,hiddenRepoPaths:rn,openingCwds:an,cwdInFocus:sn,cwdVisible:cn,visibleBacklogItems:ln}=$S({repos:x,focusRepo:ae,outbox:Ke,bl:Le}),un=e=>my(x,e),dn=e=>my(x,e.cwd),fn=e=>hy(x,e),pn=e=>vy(x,e);(0,Z.useEffect)(()=>{ko(ae)},[ae]),dE();let[mn,hn]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=setInterval(()=>{document.hidden||hn(e=>e+1)},3e4);return()=>clearInterval(e)},[]),(0,Z.useEffect)(()=>{B&&Y(`overlay:${B}`)},[B]);let gn=e=>eC(e,{setOverlay:V,activeRepoId:Xt,active:yt,readMode:fe,fireReader:he,send:r,geomRef:le,submitInput:Qe,openCompanionShell:xt.openCompanionShell});ey({conn:e,term:U,verbs:F,q:Ge,focusSession:se},{connRef:t,setBackends:A,setSessions:g,setRecent:v,setClosed:b,setUpdate:M,setMeter:N,setIntents:O,updateResultSeenRef:P,wantNavRef:Ve}),iC({status:n,refreshRepos:At,activeId:ne,active:yt,wantNavRef:Ve,firedIdRef:He,bl:Le,sessions:R,attach:_e,repos:x,overlay:B}),sh(yt);let{installEvt:_n,canInstall:vn,setCanInstall:yn,installed:bn}=aC();(0,Z.useEffect)(()=>{on()},[]),sC({tabsOn:Re,sessions:R,sessionRepoName:fn,activeId:ne,repos:x,attach:_e,closeSession:L,backends:k}),(0,Z.useEffect)(()=>{n===`open`&&(yt&&B!==`settings`||r({t:`usage.refresh`}))},[B,yt,n]),lC({reposRef:Pe,initRoute:z,sessions:R,attach:_e,setOverlay:V});function xn(e){Ie(e),V(`git`)}uC({outbox:Ke,activityFiled:je,activityConfirmedDone:Me,allBufsRef:vt}),ua({conn:{get status(){return t.current.status},send:r,trySend:e=>t.current.trySend(e),liveSend:i,liveSendAll:a,liveAsk:o,info:e.info},queue:{queueOp:$e,submitInput:Qe,mintAckId:eo,entries:Ge.entries,repoIdOf:_t,drop:e=>Je(qe.current.filter(t=>t.ackId!==e)),blocked:Ge.blocked,goneLanes:Ze,laneLabel:at,answerPrompt:rt,queueBacklog:et,flush:Ye,idleReason:Xe,serial:{on:p,set:e=>J(`serialSessions`,e)},verbs:{sendQueuedNow:ot,toggleHoldQueued:st,toggleSerialQueued:ct,removeQueued:lt,editQueued:ut,retargetQueued:W,restoreQueued:dt,retryFailedQueued:ft,moveQueued:pt,addPromptToQueuedCreate:mt,scheduleQueueRows:ht,dropScheduleQueue:gt},uploads:Ge.uploads,queueImageUpload:tt},nav:{overlay:B,open:V,close:H,attach:_e,openRepo:jt,openSend:Bt,startSessionWithPrompt:Nt,openBacklogCut:ho,openScheduleCut:of,closeSession:L,openPlugin:e=>{L_(e)},followFire:e=>{Ve.current=!0,He.current=e},openPadAt:In,sendSeeded:()=>Rt.current!=null,openActivity:mr,openGit:xn,openReader:U.openReader,openCapture:yi},launch:{setOpt:Tt,wire:Dt,openCwd:Mt,relaunch:Pt,focusShell:xt.focusShell,shellCant:xt.shellCant},term:{snapshot:U.snapshot,geom:()=>le.current},compose:{draft:ye,insert:we,seedDraft:Gt.seedDraft,typeOn:Gt.typeOn,send:Gt.sendNow,pushHistory:Ce,removePadNotes:Sr,loadSheetDraft:Ma,seedSheetDraft:Po,appendSheetDraft:Qc,gridText:()=>ce.current?.getText()??``},world:{sessions:R,repos:x,visibleRepos:en,active:yt,activeRepo:Yt,backends:k,recent:_,closed:y,intents:D,launches:Ge.launches,budget:Ge.budget,billing:Be,meter:ee,usage:ze,get usageReadings(){return hi()},get tokensOpenOn(){return Fi()},clearTokensOn:nl,launch:St,update:j,sessionRepo:dn,sessionRowTitle:pn,sessionCan:Ot,sessionCant:kt,repoForCwd:un,refreshRepos:At,schedules:ke,pending:bt,backlog:Le.items,cwdVisible:cn},files:{downloadArtifact:pa,openArtifact:e=>nn(e),viewImage:ri,attachForInbox:xc,annotate:uc,openSweep:fl,editBacklogImage:Jo,annotateUrl:gu,attachFiles:_s,browseTo:Hd,openFileFrom:(e,t)=>nn(e,t)},send:{renderRetime:Wt,seedFromSchedule:Ht,seedFromIntent:Vt,targetFor:Ut},say:{toast:G,track:Y,confirm:Hs}});let Cn=(0,Z.useRef)(B);if((0,Z.useEffect)(()=>{Z_(Cn.current,B),Cn.current=B},[B]),(0,Z.useEffect)(()=>G_(),[]),d)return(0,Q.jsx)(hf,{reconnect:()=>t.current.reconnect()});let wn=Jt.drawnSheet(ZS({overlay:B,setOverlay:V,closeSheet:H,connRef:t,status:n,setReconnectAsk:c,submitInput:Qe,holdQueueRef:it,flushOutbox:Ye,removeQueued:lt,pendingSession:nt,insertCompose:we,setOutlineJump:ge,setView:me,active:yt,sessions:R,visibleRepos:en,outbox:Ke,usage:ze,intents:D,launchCore:xt,sessionCant:kt,pickBackend:Et,refreshRepos:At,sendCore:It,sendSeed:Lt,voice:qt,installed:bn,canInstall:vn,installEvt:_n,setCanInstall:yn,gitRepoId:Fe,setGitRepoId:Ie,activeRepoId:Xt,repos:x,backends:k}));return(0,Q.jsx)(sE,{sheet:wn,overlay:B,session:yt?(0,Q.jsx)(zT,{active:yt,pending:bt,conn:e,term:U,q:Ge,compose:Gt,launch:xt,chrome:Jt,backends:k,sessions:R,update:j,readerShown:Ft,activeRepo:Yt,transportKnown:Zt,visibleBacklogItems:ln,intents:D,verbs:F,repoForCwd:un,sessionRepoName:fn,setActiveId:re,setOverlay:V,runToolbar:gn}):null,launcher:(0,Q.jsx)(XS,{sessions:R,recent:_,closed:y,repos:x,reposAt:C,reposFailAt:T,backends:k,intents:D,outbox:Ke,nowTick:mn,launch:St,conn:e,route:{focusRepo:ae,setFocusRepo:oe,setOverlay:V,lastVisitedId:Ue},view:{visibleRepos:en,hiddenRepos:tn,hiddenRepoPaths:rn,cwdInFocus:sn,toggleHideRepo:$t,openingCwds:an},launchCore:xt,term:U,queue:Ge,openSend:Bt,verbs:F,openGitFor:xn,banners:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(gg,{q:Ge,status:n,reconnectAsk:s,setReconnectAsk:c,autoSend:f,confirmQueue:m,pullRecords:Ae,setOverlay:V}),(0,Q.jsx)(Ng,{httpsUrl:l}),(0,Q.jsx)(Ig,{onOpen:()=>V(`phonesetup`)}),(0,Q.jsx)(Rg,{update:j,liveAsk:o,liveSend:i}),(0,Q.jsx)(Lg,{})]})})})}var pE=`.bl-modal-backdrop, [role=dialog][aria-modal=true], [data-primary-key]`;function mE(e){return e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&!e.isComposing}function hE(e){let t=e.querySelectorAll(pE);return t[t.length-1]?.querySelector(`button.send:not(:disabled)`)??null}function gE(e){let t=(e??``).replace(/\s+/g,` `).trim();return t&&t.length<=24?`press “${t}”`:`press the dialog's button`}function _E(e=window){let t=vn({id:`primaryKey`,mods:[`ctrl`,`meta`],key:`Enter`,what:()=>gE(hE(e.document)?.textContent),when:()=>hE(e.document)!=null}),n=t=>{if(!mE(t))return;let n=hE(e.document);n&&(t.preventDefault(),t.stopPropagation(),n.click())};return e.addEventListener(`keydown`,n,!0),()=>{t(),e.removeEventListener(`keydown`,n,!0)}}function vE(e,t){return t||!e||!e.matches(`textarea[data-compose]:not(.pipe)`)?!1:(e.value??``).trim()!==``}function yE(e=document){return vn({id:`composeSend`,mods:[`ctrl`,`meta`],key:`Enter`,what:()=>`send`,when:()=>vE(e.activeElement,hE(e)!=null)})}var bE=[{ms:3e5,label:`5m`},{ms:36e5,label:`1h`},{ms:144e5,label:`4h`},{ms:864e5,label:`1d`}],xE=bE.reduce((e,t)=>Math.max(e,t.ms),0);function SE(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let{id:n,until:r}=t;return typeof n!=`string`||!n||typeof r!=`number`||!Number.isFinite(r)?null:{id:n,until:r}}catch{return null}}function CE(e,t,n){return{id:e,until:t+n}}function wE(e,t,n){return!e||!t||e.id!==t?!1:n<e.until&&e.until-n<=xE}function TE(e){return`Hidden for ${e<36e5?`${Math.round(e/6e4)} min`:e<864e5?`${Math.round(e/36e5)} hours`:`${Math.round(e/864e5)} day${e>=1728e5?`s`:``}`} — it still applies on its own once you put the phone down.`}var EE=null;function DE(){let[e,t]=(0,Z.useState)(()=>yo.get()),[,n]=(0,Z.useState)(0),[r,i]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>yo.subscribe(t),[]),!vr()||e.phase!==`staged`||!e.stagedId||EE===e.stagedId||wE(SE(ht(W.webUpdateSnooze)),e.stagedId,Date.now()))return null;let a=e.stagedId;return(0,Q.jsxs)(`div`,{className:`staged-bar`,role:`status`,children:[(0,Q.jsx)(dm,{size:15}),(0,Q.jsx)(`span`,{className:`staged-bar-text`,children:r?`Hide this for how long?`:`A newer build is ready and verified on this phone.`}),!r&&(0,Q.jsx)(K,{className:`staged-bar-go`,title:`restart into the new build — anything half-written in a box is lost`,onClick:()=>{Y(`action:update.applyNow`),yo.applyNow()},children:`Restart into it`}),(0,Q.jsx)(`button`,{className:`staged-bar-later`,"aria-label":r?`keep showing it`:`hide for a while`,"aria-expanded":r,title:r?`keep showing it`:`hide for a while — pick how long; the build still applies on its own once you put the phone down`,onClick:()=>i(e=>!e),children:(0,Q.jsx)(Fp,{size:14})}),r&&bE.map(e=>(0,Q.jsx)(K,{className:`staged-bar-span`,title:`hide the bar for ${e.label}, across reloads — the build still applies on its own once you put the phone down`,onClick:()=>{Y(`action:update.snooze`),pt(W.webUpdateSnooze,CE(a,Date.now(),e.ms)),G(TE(e.ms)),i(!1),n(e=>e+1)},children:e.label},e.ms)),(0,Q.jsx)(`button`,{className:`staged-bar-x`,"aria-label":`not now`,title:`not now — it applies on its own once you put the phone down`,onClick:()=>{EE=a,n(e=>e+1)},children:(0,Q.jsx)(X,{size:14})})]})}function OE(e,t,n=Date.now()){return t?t.scope===`passive`?t.unlockedUntil&&t.unlockedUntil>n?`full`:`passive`:`full`:e?`passive`:`full`}function kE(){return ht(W.passive)===`1`}function AE(e){e&&(e.scope===`passive`?nt(W.passive,`1`):ft(W.passive))}function jE(e){return e.filter(e=>Ue(e.item)).sort((e,t)=>t.item.ts-e.item.ts)}function ME(e){switch(e.state){case`queued`:return`new build — waiting to download`;case`downloading`:{let t=e.item.size>0?Math.min(99,Math.floor(e.received/e.item.size*100)):null;return t===null?`downloading`:`downloading ${t}%`}case`paused`:return`download paused`;case`done`:return`downloaded — installs itself if this app is allowed to`;case`failed`:return e.error?`download failed: ${e.error}`:`download failed — tries again on the next check`;default:return e.state}}function NE(e,t=Date.now()){return Math.max(0,e-t)+750}var PE=6e4;function FE({onUnlocked:e}){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>(ci.start(),ci.subscribe(n)),[]);let l=async()=>{let t=await Xn.state();t?(o(`ok`),i(t.checkedAt),t.unlockedUntil&&t.unlockedUntil>Date.now()?e(t.unlockedUntil):(ci.sync(t.items),ci.pump())):o(`unreachable`)};(0,Z.useEffect)(()=>{l();let e=setInterval(()=>{document.visibilityState===`visible`&&l()},PE),t=()=>{document.visibilityState===`visible`&&l()};return document.addEventListener(`visibilitychange`,t),()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,t)}},[]);let u=jE(t);return(0,Q.jsx)(`div`,{className:`auth-gate passive-screen`,children:(0,Q.jsxs)(`div`,{className:`auth-card`,children:[(0,Q.jsxs)(`div`,{className:`auth-title`,children:[(0,Q.jsx)(yp,{size:16,style:{verticalAlign:`-3px`}}),` Apps`]}),u.length===0&&(0,Q.jsx)(`div`,{className:`set-note`,children:`No new app builds right now. New ones download here by themselves.`}),u.map(e=>(0,Q.jsxs)(`div`,{className:`passive-row`,children:[(0,Q.jsx)(`div`,{className:`passive-name`,children:e.item.name}),(0,Q.jsxs)(`div`,{className:`set-note`,children:[e.item.repoName,` · `,ME(e)]})]},e.item.id)),(0,Q.jsxs)(`div`,{className:`passive-foot`,children:[(0,Q.jsx)(`span`,{className:`set-note`,children:a===`unreachable`?`Desktop not reachable${r?` — last check ${wc(r)}`:``}`:r?`Last check ${wc(r)}`:`Checking…`}),(0,Q.jsxs)(`button`,{className:`link-btn`,title:`check the desktop for new builds now`,onClick:()=>{l(),G(`checking for new builds`)},children:[(0,Q.jsx)(xm,{size:12}),` check now`]})]}),!s&&(0,Q.jsxs)(`button`,{className:`link-btn passive-unlock`,title:`unlock the full app with the PIN`,onClick:()=>c(!0),children:[(0,Q.jsx)(rm,{size:12}),` Unlock`]}),s&&(0,Q.jsx)(IE,{onCancel:()=>c(!1),onUnlocked:e})]})})}function IE({onCancel:e,onUnlocked:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{c.current?.focus()},[]);let l=async()=>{a(!0),s(null);let e=null;try{e=await Xn.unlock(n)}catch{e=null}a(!1),e?e.ok?t(e.unlockedUntil):(r(``),s(e.message||z(e.error))):s(`The desktop did not answer. Try again when it is reachable.`)};return(0,Q.jsxs)(`form`,{className:`passive-pin`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,Q.jsx)(`input`,{ref:c,className:`auth-input`,type:`password`,inputMode:`numeric`,autoComplete:`off`,placeholder:`PIN`,value:n,onChange:e=>r(e.target.value.replace(/\D/g,``).slice(0,12)),"aria-label":`unlock PIN`}),(0,Q.jsx)(K,{variant:`primary`,type:`submit`,title:`unlock for 30 minutes`,children:i?`checking…`:`unlock`}),(0,Q.jsx)(K,{type:`button`,onClick:e,children:`not now`}),o&&(0,Q.jsx)(`div`,{className:`set-note`,style:{color:`var(--dead)`},children:o})]})}function LE({until:e}){let[t,n]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let t=setTimeout(()=>window.location.reload(),NE(e));return()=>clearTimeout(t)},[e]);let r=Ze(e);if(!r)return null;let i=async()=>{n(!0);try{await Xn.lock()}catch{}window.location.reload()};return(0,Q.jsxs)(`div`,{className:`passive-bar`,role:`status`,children:[(0,Q.jsx)(Tm,{size:13}),` `,r,` ·`,` `,(0,Q.jsx)(`button`,{className:`link-btn`,title:`back to the passive screen now`,onClick:()=>void i(),children:t?`locking…`:`Lock now`})]})}var RE=22,zE=36;function BE(){let e=ot(),t=Kc(),n=t===`static`?zE:RE;if((0,Z.useEffect)(()=>{if(e)return document.documentElement.style.setProperty(`--ui-demo-h`,`${n}px`),()=>{document.documentElement.style.removeProperty(`--ui-demo-h`)}},[e,n]),!e)return null;let r=t===`shell`&&!cs();return(0,Q.jsxs)(`div`,{className:t===`static`?`demo-line static`:`demo-line`,role:`status`,style:{height:n},children:[(0,Q.jsx)(pm,{size:12}),(0,Q.jsx)(`span`,{className:`demo-line-text`,children:t===`static`?(0,Q.jsxs)(Q.Fragment,{children:[`Demo — nothing runs on a computer. To use `,C.name,` for real, open it from your own desktop host.`]}):`Demo — nothing runs on a computer`}),(0,Q.jsxs)(K,{className:`demo-line-go`,onClick:$u,children:[(0,Q.jsx)(qm,{size:11}),` More to try`]}),t!==`static`&&(0,Q.jsx)(K,{className:`demo-line-go`,onClick:su,children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vm,{size:11}),` Connect a real desktop`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($p,{size:11}),` Leave the demo`]})})]})}var VE=3e5;oy();var HE=Ao(location,Date.now());HE&&history.replaceState(null,``,HE),Au(),jr();try{ut()}catch(e){st(null,`The demo could not start: ${String(e?.message??e)}`)}Ku(),ga(),Or(On),xt(),bu(),kn(),ys(),ol(),yr(),Ps(),ya(),_E(),ib(),yE(),Yt();function UE(){let[e,t]=(0,Z.useState)(()=>!eu()),[n,r]=(0,Z.useState)(null);(0,Z.useEffect)(()=>e?cd(r):void 0,[e]);let[i,a]=(0,Z.useState)(()=>eu()?OE(kE(),null):`full`),o=(0,Z.useRef)(i===`full`),[s,c]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(e)return;let t=!0;return Xn.status().then(e=>{if(!t||!e)return;AE(e);let n=OE(kE(),e);c(n===`full`&&e.scope===`passive`&&e.unlockedUntil?e.unlockedUntil:null),n===`passive`&&o.current?window.location.reload():a(n)}),()=>{t=!1}},[e]),(0,Z.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(`app:host-setup`,e),()=>window.removeEventListener(`app:host-setup`,e)},[]),(0,Z.useEffect)(()=>{if(!vr())return;yo.markHealthy().then(()=>yo.check());let e=setInterval(()=>{document.visibilityState===`visible`&&yo.check()},VE),t=Date.now(),n=()=>{document.visibilityState===`visible`&&(Date.now()-t<6e4||(t=Date.now(),yo.check()))};document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n);let r=()=>{t=Date.now(),yo.check()};window.addEventListener(Ui,r);let i=yo.watchAutoApply();return()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n),window.removeEventListener(Ui,r),i()}},[]);let l=at();return l?(0,Q.jsx)(`div`,{className:`auth-gate`,children:(0,Q.jsxs)(`div`,{className:`auth-card`,children:[(0,Q.jsxs)(`div`,{className:`auth-title`,children:[(0,Q.jsx)(pm,{size:16,style:{verticalAlign:`-3px`}}),` Demo not available`]}),(0,Q.jsx)(`div`,{className:`set-note`,children:l}),(0,Q.jsx)(`div`,{className:`set-row demo-problem`,children:(0,Q.jsx)(K,{variant:`primary`,onClick:su,children:`Leave the demo`})})]})}):e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(zl,{}),(0,Q.jsx)(Bn,{mode:`first`,pair:n,pairFromLink:!!n,onDone:()=>t(!eu()),onCancel:eu()?()=>t(!1):void 0})]}):i===`passive`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(zl,{}),(0,Q.jsx)(DE,{}),(0,Q.jsx)(FE,{onUnlocked:e=>{c(e),o.current=!0,a(`full`)}})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fE,{}),(0,Q.jsx)(WE,{}),(0,Q.jsx)(Qo,{}),(0,Q.jsx)(Lc,{}),(0,Q.jsx)(ju,{}),(0,Q.jsx)(lu,{}),(0,Q.jsx)(zl,{}),(0,Q.jsx)(td,{}),(0,Q.jsx)(Tl,{}),(0,Q.jsx)(Oa,{}),(0,Q.jsx)(oa,{}),(0,Q.jsx)(ab,{}),(0,Q.jsx)(DE,{}),(0,Q.jsx)(Mg,{}),(0,Q.jsx)(BE,{}),s&&(0,Q.jsx)(LE,{until:s})]})}function WE(){return(0,Z.useEffect)(()=>{try{tf(dv())}catch{}try{Aa(dv())}catch{}try{_l(dv())}catch{}try{Yr(dv(),_n)}catch{}try{kr(dv())}catch{}},[]),null}if(Bo(),(0,Zm.createRoot)(document.getElementById(`root`)).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(ay,{children:(0,Q.jsx)(UE,{})})})),`serviceWorker`in navigator&&!ws()){let e=!!navigator.serviceWorker.controller,t=!1,n=()=>{t||(t=!0,window.location.reload())};navigator.serviceWorker.addEventListener(`controllerchange`,()=>{!t&&e&&(document.visibilityState===`hidden`?n():document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&n()}))}),window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).then(e=>e.update().catch(()=>{})).catch(()=>{})})}
|