waterplane 0.1.24 → 0.1.26
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 +49 -0
- package/SECURITY.md +25 -5
- package/node_modules/@waterplane/shared/dist/agentseries/compare.d.ts +8 -0
- package/node_modules/@waterplane/shared/dist/agentseries/compare.js +103 -0
- package/node_modules/@waterplane/shared/dist/agentseries/compare.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/agentseries/markers.d.ts +17 -0
- package/node_modules/@waterplane/shared/dist/agentseries/markers.js +125 -0
- package/node_modules/@waterplane/shared/dist/agentseries/markers.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/agentseries/series.d.ts +16 -0
- package/node_modules/@waterplane/shared/dist/agentseries/series.js +93 -0
- package/node_modules/@waterplane/shared/dist/agentseries/series.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/agentseries/stats.d.ts +8 -0
- package/node_modules/@waterplane/shared/dist/agentseries/stats.js +33 -0
- package/node_modules/@waterplane/shared/dist/agentseries/stats.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/agentseries/types.d.ts +103 -0
- package/node_modules/@waterplane/shared/dist/agentseries/types.js +11 -0
- package/node_modules/@waterplane/shared/dist/agentseries/types.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/agentseries.d.ts +10 -0
- package/node_modules/@waterplane/shared/dist/agentseries.js +11 -0
- package/node_modules/@waterplane/shared/dist/agentseries.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/calday.d.ts +5 -0
- package/node_modules/@waterplane/shared/dist/calday.js +10 -0
- package/node_modules/@waterplane/shared/dist/calday.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/clihealth/healthfixture.d.ts +13 -1
- package/node_modules/@waterplane/shared/dist/clihealth/healthfixture.js +22 -4
- package/node_modules/@waterplane/shared/dist/clihealth/healthfixture.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/clihealth.d.ts +1 -1
- package/node_modules/@waterplane/shared/dist/clihealth.js +1 -1
- package/node_modules/@waterplane/shared/dist/clihealth.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/dictate.d.ts +6 -0
- package/node_modules/@waterplane/shared/dist/dictate.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/dictatemodels.d.ts +23 -0
- package/node_modules/@waterplane/shared/dist/dictatemodels.js +31 -0
- package/node_modules/@waterplane/shared/dist/dictatemodels.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/commits.d.ts +1 -1
- package/node_modules/@waterplane/shared/dist/healthindex/commits.js +2 -2
- package/node_modules/@waterplane/shared/dist/healthindex/commits.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/healthindex/coverage.d.ts +128 -0
- package/node_modules/@waterplane/shared/dist/healthindex/coverage.js +343 -0
- package/node_modules/@waterplane/shared/dist/healthindex/coverage.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/healthindex/readings.d.ts +9 -1
- package/node_modules/@waterplane/shared/dist/healthindex/readings.js +122 -4
- package/node_modules/@waterplane/shared/dist/healthindex/readings.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/healthindex/repoindex.d.ts +5 -0
- package/node_modules/@waterplane/shared/dist/healthindex/repoindex.js +2 -0
- package/node_modules/@waterplane/shared/dist/healthindex/repoindex.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/healthindex/score.d.ts +3 -0
- package/node_modules/@waterplane/shared/dist/healthindex/score.js +52 -16
- package/node_modules/@waterplane/shared/dist/healthindex/score.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/healthindex/types.d.ts +82 -6
- package/node_modules/@waterplane/shared/dist/healthindex/types.js +35 -2
- package/node_modules/@waterplane/shared/dist/healthindex/types.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/healthindex/words.js +65 -6
- package/node_modules/@waterplane/shared/dist/healthindex/words.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/healthindex.d.ts +21 -7
- package/node_modules/@waterplane/shared/dist/healthindex.js +20 -7
- package/node_modules/@waterplane/shared/dist/healthindex.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/healthindexresponse.js +3 -2
- package/node_modules/@waterplane/shared/dist/healthindexresponse.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/healthspend.d.ts +23 -0
- package/node_modules/@waterplane/shared/dist/healthspend.js +32 -1
- package/node_modules/@waterplane/shared/dist/healthspend.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/hints.js +9 -0
- package/node_modules/@waterplane/shared/dist/hints.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/index.d.ts +9 -0
- package/node_modules/@waterplane/shared/dist/index.js +9 -0
- package/node_modules/@waterplane/shared/dist/index.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/installrow.js +10 -0
- package/node_modules/@waterplane/shared/dist/installrow.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/intent/kind.d.ts +45 -1
- package/node_modules/@waterplane/shared/dist/intent/kind.js +60 -2
- package/node_modules/@waterplane/shared/dist/intent/kind.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/intent.d.ts +1 -1
- package/node_modules/@waterplane/shared/dist/intent.js +1 -1
- package/node_modules/@waterplane/shared/dist/intent.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/itempaths.d.ts +23 -0
- package/node_modules/@waterplane/shared/dist/itempaths.js +38 -0
- package/node_modules/@waterplane/shared/dist/itempaths.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/pluginlaunch.d.ts +3 -2
- package/node_modules/@waterplane/shared/dist/pluginlaunch.js +1 -1
- package/node_modules/@waterplane/shared/dist/pluginlaunch.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/pricelist.d.ts +57 -0
- package/node_modules/@waterplane/shared/dist/pricelist.js +128 -0
- package/node_modules/@waterplane/shared/dist/pricelist.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/pricing.d.ts +86 -9
- package/node_modules/@waterplane/shared/dist/pricing.js +140 -20
- package/node_modules/@waterplane/shared/dist/pricing.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/queue/queuelanestate.d.ts +14 -0
- package/node_modules/@waterplane/shared/dist/queue/queuelanestate.js +25 -0
- package/node_modules/@waterplane/shared/dist/queue/queuelanestate.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/queue/queueplan.d.ts +4 -0
- package/node_modules/@waterplane/shared/dist/queue/queueplan.js +21 -0
- package/node_modules/@waterplane/shared/dist/queue/queueplan.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/queue/queuewords.js +2 -1
- package/node_modules/@waterplane/shared/dist/queue/queuewords.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/queue.d.ts +2 -0
- package/node_modules/@waterplane/shared/dist/queue.js +1 -0
- package/node_modules/@waterplane/shared/dist/queue.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/repohealth.d.ts +178 -0
- package/node_modules/@waterplane/shared/dist/repohealth.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/repohealthhabits.d.ts +15 -0
- package/node_modules/@waterplane/shared/dist/repohealthhabits.js +117 -0
- package/node_modules/@waterplane/shared/dist/repohealthhabits.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/repohealthnative.d.ts +10 -0
- package/node_modules/@waterplane/shared/dist/repohealthnative.js +94 -0
- package/node_modules/@waterplane/shared/dist/repohealthnative.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/repohealthread.js +23 -1
- package/node_modules/@waterplane/shared/dist/repohealthread.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/skillstate.d.ts +51 -0
- package/node_modules/@waterplane/shared/dist/skillstate.js +176 -0
- package/node_modules/@waterplane/shared/dist/skillstate.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/skillwords.d.ts +10 -0
- package/node_modules/@waterplane/shared/dist/skillwords.js +18 -0
- package/node_modules/@waterplane/shared/dist/skillwords.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/wire/agentreadings.d.ts +248 -0
- package/node_modules/@waterplane/shared/dist/wire/agentreadings.js +36 -0
- package/node_modules/@waterplane/shared/dist/wire/agentreadings.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/wire/backend.d.ts +2 -0
- package/node_modules/@waterplane/shared/dist/wire/costwindow.d.ts +4 -0
- package/node_modules/@waterplane/shared/dist/wire/dictatesetup.d.ts +42 -0
- package/node_modules/@waterplane/shared/dist/wire/dictatesetup.js +9 -0
- package/node_modules/@waterplane/shared/dist/wire/dictatesetup.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/wire/messages/hostcore.d.ts +22 -1
- package/node_modules/@waterplane/shared/dist/wire/notify.d.ts +6 -1
- package/node_modules/@waterplane/shared/dist/wire/notify.js +6 -1
- package/node_modules/@waterplane/shared/dist/wire/notify.js.map +1 -1
- package/node_modules/@waterplane/shared/dist/wire/repo.d.ts +1 -1
- package/node_modules/@waterplane/shared/dist/wire/skills.d.ts +142 -0
- package/node_modules/@waterplane/shared/dist/wire/skills.js +6 -0
- package/node_modules/@waterplane/shared/dist/wire/skills.js.map +1 -0
- package/node_modules/@waterplane/shared/dist/wire/sysstat.d.ts +17 -0
- package/node_modules/@waterplane/shared/dist/wire/telemetry.d.ts +4 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/packages/extensions/diskspace/waterplane-plugin.json +16 -0
- package/packages/extensions/links/waterplane-plugin.json +18 -0
- package/packages/host/dist/agentclass.d.ts +116 -0
- package/packages/host/dist/agentclass.js +339 -0
- package/packages/host/dist/agentclass.js.map +1 -0
- package/packages/host/dist/agentintents.d.ts +18 -0
- package/packages/host/dist/agentintents.js +40 -7
- package/packages/host/dist/agentintents.js.map +1 -1
- package/packages/host/dist/agentmarkers.d.ts +49 -0
- package/packages/host/dist/agentmarkers.js +255 -0
- package/packages/host/dist/agentmarkers.js.map +1 -0
- package/packages/host/dist/agentreadings.d.ts +68 -0
- package/packages/host/dist/agentreadings.js +336 -0
- package/packages/host/dist/agentreadings.js.map +1 -0
- package/packages/host/dist/agentscan.d.ts +8 -0
- package/packages/host/dist/agentscan.js +427 -0
- package/packages/host/dist/agentscan.js.map +1 -0
- package/packages/host/dist/archive.js +9 -3
- package/packages/host/dist/archive.js.map +1 -1
- package/packages/host/dist/artifacts.js +4 -7
- package/packages/host/dist/artifacts.js.map +1 -1
- package/packages/host/dist/askrules.js +12 -4
- package/packages/host/dist/askrules.js.map +1 -1
- package/packages/host/dist/auth.d.ts +1 -0
- package/packages/host/dist/auth.js +5 -3
- package/packages/host/dist/auth.js.map +1 -1
- package/packages/host/dist/autopull.js +4 -8
- package/packages/host/dist/autopull.js.map +1 -1
- package/packages/host/dist/backends/claude.js +1 -0
- package/packages/host/dist/backends/claude.js.map +1 -1
- package/packages/host/dist/backends/derive.js +3 -1
- package/packages/host/dist/backends/derive.js.map +1 -1
- package/packages/host/dist/binguard.js +19 -2
- package/packages/host/dist/binguard.js.map +1 -1
- package/packages/host/dist/capture.js +7 -10
- package/packages/host/dist/capture.js.map +1 -1
- package/packages/host/dist/clifixtures.d.ts +24 -4
- package/packages/host/dist/clifixtures.js +50 -10
- package/packages/host/dist/clifixtures.js.map +1 -1
- package/packages/host/dist/clihealth.d.ts +8 -2
- package/packages/host/dist/clihealth.js +11 -3
- package/packages/host/dist/clihealth.js.map +1 -1
- package/packages/host/dist/costwindow.js +4 -2
- package/packages/host/dist/costwindow.js.map +1 -1
- package/packages/host/dist/ctxlog/ctxagents.d.ts +2 -0
- package/packages/host/dist/ctxlog/ctxagents.js +5 -5
- package/packages/host/dist/ctxlog/ctxagents.js.map +1 -1
- package/packages/host/dist/ctxlog/ctxcursor.d.ts +2 -0
- package/packages/host/dist/ctxlog/ctxcursor.js +2 -2
- package/packages/host/dist/ctxlog/ctxcursor.js.map +1 -1
- package/packages/host/dist/ctxlog/ctxupdate.js +11 -6
- package/packages/host/dist/ctxlog/ctxupdate.js.map +1 -1
- package/packages/host/dist/deliver/deliverknobs.d.ts +0 -2
- package/packages/host/dist/deliver/deliverknobs.js +0 -2
- package/packages/host/dist/deliver/deliverknobs.js.map +1 -1
- package/packages/host/dist/deliver/deliverproof.d.ts +3 -2
- package/packages/host/dist/deliver/deliverproof.js +9 -8
- package/packages/host/dist/deliver/deliverproof.js.map +1 -1
- package/packages/host/dist/deliver/deliverreturn.d.ts +3 -2
- package/packages/host/dist/deliver/deliverreturn.js +13 -12
- package/packages/host/dist/deliver/deliverreturn.js.map +1 -1
- package/packages/host/dist/deliver/deliverrun.js +20 -18
- package/packages/host/dist/deliver/deliverrun.js.map +1 -1
- package/packages/host/dist/deliver/deliverscreen.d.ts +2 -1
- package/packages/host/dist/deliver/deliverscreen.js +9 -8
- package/packages/host/dist/deliver/deliverscreen.js.map +1 -1
- package/packages/host/dist/deliver/delivertypes.d.ts +4 -0
- package/packages/host/dist/deliver.js +2 -1
- package/packages/host/dist/deliver.js.map +1 -1
- package/packages/host/dist/dictate.d.ts +11 -0
- package/packages/host/dist/dictate.js +20 -10
- package/packages/host/dist/dictate.js.map +1 -1
- package/packages/host/dist/dictatesetup.d.ts +54 -0
- package/packages/host/dist/dictatesetup.js +261 -0
- package/packages/host/dist/dictatesetup.js.map +1 -0
- package/packages/host/dist/doctor.js +1 -1
- package/packages/host/dist/doctor.js.map +1 -1
- package/packages/host/dist/exposure.d.ts +10 -0
- package/packages/host/dist/exposure.js +25 -0
- package/packages/host/dist/exposure.js.map +1 -1
- package/packages/host/dist/exposurepush.js +2 -2
- package/packages/host/dist/exposurepush.js.map +1 -1
- package/packages/host/dist/extensions/diskspace/host/candidates.d.mts +180 -0
- package/packages/host/dist/extensions/diskspace/host/candidates.mjs +716 -0
- package/packages/host/dist/extensions/diskspace/host/candidates.mjs.map +1 -0
- package/packages/host/dist/extensions/diskspace/host/engine.d.mts +21 -0
- package/packages/host/dist/extensions/diskspace/host/engine.mjs +498 -0
- package/packages/host/dist/extensions/diskspace/host/engine.mjs.map +1 -0
- package/packages/host/dist/extensions/diskspace/host/index.d.mts +25 -0
- package/packages/host/dist/extensions/diskspace/host/index.mjs +135 -0
- package/packages/host/dist/extensions/diskspace/host/index.mjs.map +1 -0
- package/packages/host/dist/extensions/diskspace/host/large.d.mts +11 -0
- package/packages/host/dist/extensions/diskspace/host/large.mjs +56 -0
- package/packages/host/dist/extensions/diskspace/host/large.mjs.map +1 -0
- package/packages/host/dist/extensions/diskspace/host/run.d.mts +94 -0
- package/packages/host/dist/extensions/diskspace/host/run.mjs +200 -0
- package/packages/host/dist/extensions/diskspace/host/run.mjs.map +1 -0
- package/packages/host/dist/extensions/diskspace/shared/wire.d.mts +197 -0
- package/packages/host/dist/extensions/diskspace/shared/wire.mjs +23 -0
- package/packages/host/dist/extensions/diskspace/shared/wire.mjs.map +1 -0
- package/packages/host/dist/extensions/links/host/engine.d.mts +39 -0
- package/packages/host/dist/extensions/links/host/engine.mjs +285 -0
- package/packages/host/dist/extensions/links/host/engine.mjs.map +1 -0
- package/packages/host/dist/extensions/links/host/index.d.mts +10 -0
- package/packages/host/dist/extensions/links/host/index.mjs +72 -0
- package/packages/host/dist/extensions/links/host/index.mjs.map +1 -0
- package/packages/host/dist/extensions/links/host/parse.d.mts +61 -0
- package/packages/host/dist/extensions/links/host/parse.mjs +225 -0
- package/packages/host/dist/extensions/links/host/parse.mjs.map +1 -0
- package/packages/host/dist/extensions/links/host/run.d.mts +15 -0
- package/packages/host/dist/extensions/links/host/run.mjs +32 -0
- package/packages/host/dist/extensions/links/host/run.mjs.map +1 -0
- package/packages/host/dist/extensions/links/host/store.d.mts +11 -0
- package/packages/host/dist/extensions/links/host/store.mjs +76 -0
- package/packages/host/dist/extensions/links/host/store.mjs.map +1 -0
- package/packages/host/dist/extensions/links/shared/wire.d.mts +141 -0
- package/packages/host/dist/extensions/links/shared/wire.mjs +20 -0
- package/packages/host/dist/extensions/links/shared/wire.mjs.map +1 -0
- package/packages/host/dist/git.d.ts +5 -3
- package/packages/host/dist/git.js +16 -28
- package/packages/host/dist/git.js.map +1 -1
- package/packages/host/dist/halt.js +16 -3
- package/packages/host/dist/halt.js.map +1 -1
- package/packages/host/dist/jsonstore.d.ts +16 -4
- package/packages/host/dist/jsonstore.js +32 -8
- package/packages/host/dist/jsonstore.js.map +1 -1
- package/packages/host/dist/landedbase.d.ts +41 -0
- package/packages/host/dist/landedbase.js +59 -0
- package/packages/host/dist/landedbase.js.map +1 -0
- package/packages/host/dist/lantls.js +2 -2
- package/packages/host/dist/lantls.js.map +1 -1
- package/packages/host/dist/limitretry.js +2 -3
- package/packages/host/dist/limitretry.js.map +1 -1
- package/packages/host/dist/localledger.js +9 -12
- package/packages/host/dist/localledger.js.map +1 -1
- package/packages/host/dist/main.js +2 -0
- package/packages/host/dist/main.js.map +1 -1
- package/packages/host/dist/opendeliveries.d.ts +4 -0
- package/packages/host/dist/opendeliveries.js +27 -1
- package/packages/host/dist/opendeliveries.js.map +1 -1
- package/packages/host/dist/plugins/setupcontrib.js +3 -2
- package/packages/host/dist/plugins/setupcontrib.js.map +1 -1
- package/packages/host/dist/pricefetch.d.ts +80 -0
- package/packages/host/dist/pricefetch.js +289 -0
- package/packages/host/dist/pricefetch.js.map +1 -0
- package/packages/host/dist/pricegap.d.ts +11 -0
- package/packages/host/dist/pricegap.js +30 -0
- package/packages/host/dist/pricegap.js.map +1 -0
- package/packages/host/dist/repohealthscopes.js +16 -24
- package/packages/host/dist/repohealthscopes.js.map +1 -1
- package/packages/host/dist/repos.d.ts +4 -0
- package/packages/host/dist/repos.js +1 -1
- package/packages/host/dist/repos.js.map +1 -1
- package/packages/host/dist/reposkilltext.d.ts +2 -0
- package/packages/host/dist/reposkilltext.js +8 -2
- package/packages/host/dist/reposkilltext.js.map +1 -1
- package/packages/host/dist/routes/apiagentpoints.d.ts +5 -0
- package/packages/host/dist/routes/apiagentpoints.js +48 -0
- package/packages/host/dist/routes/apiagentpoints.js.map +1 -0
- package/packages/host/dist/routes/apidictate.d.ts +2 -0
- package/packages/host/dist/routes/apidictate.js +27 -0
- package/packages/host/dist/routes/apidictate.js.map +1 -0
- package/packages/host/dist/routes/apihost.js +3 -2
- package/packages/host/dist/routes/apihost.js.map +1 -1
- package/packages/host/dist/routes/apirepofiles.js +3 -1
- package/packages/host/dist/routes/apirepofiles.js.map +1 -1
- package/packages/host/dist/routes/apirepowork.js +14 -0
- package/packages/host/dist/routes/apirepowork.js.map +1 -1
- package/packages/host/dist/routes/apiroutes.js +4 -1
- package/packages/host/dist/routes/apiroutes.js.map +1 -1
- package/packages/host/dist/routes/apiskills.d.ts +3 -0
- package/packages/host/dist/routes/apiskills.js +81 -0
- package/packages/host/dist/routes/apiskills.js.map +1 -0
- package/packages/host/dist/routes/apistats.js +2 -2
- package/packages/host/dist/routes/apistats.js.map +1 -1
- package/packages/host/dist/routes/apisystem.js +3 -1
- package/packages/host/dist/routes/apisystem.js.map +1 -1
- package/packages/host/dist/routes/apitable.d.ts +2 -0
- package/packages/host/dist/routes/apitable.js.map +1 -1
- package/packages/host/dist/server/billingwire.js +5 -0
- package/packages/host/dist/server/billingwire.js.map +1 -1
- package/packages/host/dist/server/deliveries.d.ts +4 -1
- package/packages/host/dist/server/deliveries.js +38 -6
- package/packages/host/dist/server/deliveries.js.map +1 -1
- package/packages/host/dist/server/http.js +1 -1
- package/packages/host/dist/server/http.js.map +1 -1
- package/packages/host/dist/server/intentDeps.js +20 -6
- package/packages/host/dist/server/intentDeps.js.map +1 -1
- package/packages/host/dist/server/wsops.js +2 -1
- package/packages/host/dist/server/wsops.js.map +1 -1
- package/packages/host/dist/sessions/core.d.ts +1 -0
- package/packages/host/dist/sessions/ctxseries.js +7 -5
- package/packages/host/dist/sessions/ctxseries.js.map +1 -1
- package/packages/host/dist/sessions/drive.d.ts +6 -1
- package/packages/host/dist/sessions/drive.js +13 -10
- package/packages/host/dist/sessions/drive.js.map +1 -1
- package/packages/host/dist/sessions/record.js +16 -17
- package/packages/host/dist/sessions/record.js.map +1 -1
- package/packages/host/dist/sessions/sidechannel.js +1 -1
- package/packages/host/dist/sessions/sidechannel.js.map +1 -1
- package/packages/host/dist/sessions/tmux.js +6 -1
- package/packages/host/dist/sessions/tmux.js.map +1 -1
- package/packages/host/dist/sessions/turn.js +5 -0
- package/packages/host/dist/sessions/turn.js.map +1 -1
- package/packages/host/dist/sessions.d.ts +2 -1
- package/packages/host/dist/sessions.js +1 -1
- package/packages/host/dist/sessions.js.map +1 -1
- package/packages/host/dist/settle.d.ts +3 -2
- package/packages/host/dist/settle.js +13 -13
- package/packages/host/dist/settle.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/skills/skillinventory.d.ts +23 -0
- package/packages/host/dist/skills/skillinventory.js +275 -0
- package/packages/host/dist/skills/skillinventory.js.map +1 -0
- package/packages/host/dist/skills/skilllayers.d.ts +28 -0
- package/packages/host/dist/skills/skilllayers.js +73 -0
- package/packages/host/dist/skills/skilllayers.js.map +1 -0
- package/packages/host/dist/skills/skillrecommend.d.ts +42 -0
- package/packages/host/dist/skills/skillrecommend.js +171 -0
- package/packages/host/dist/skills/skillrecommend.js.map +1 -0
- package/packages/host/dist/skills/skillrefs.d.ts +2 -0
- package/packages/host/dist/skills/skillrefs.js +50 -0
- package/packages/host/dist/skills/skillrefs.js.map +1 -0
- package/packages/host/dist/skills/skilluse.d.ts +57 -0
- package/packages/host/dist/skills/skilluse.js +242 -0
- package/packages/host/dist/skills/skilluse.js.map +1 -0
- package/packages/host/dist/skills/skillweight.d.ts +18 -0
- package/packages/host/dist/skills/skillweight.js +69 -0
- package/packages/host/dist/skills/skillweight.js.map +1 -0
- package/packages/host/dist/skills/skillwrite.d.ts +56 -0
- package/packages/host/dist/skills/skillwrite.js +183 -0
- package/packages/host/dist/skills/skillwrite.js.map +1 -0
- package/packages/host/dist/sysstat.d.ts +34 -1
- package/packages/host/dist/sysstat.js +82 -14
- package/packages/host/dist/sysstat.js.map +1 -1
- package/packages/host/dist/tokenscan.js +5 -2
- package/packages/host/dist/tokenscan.js.map +1 -1
- package/packages/host/dist/tokenstats.js +7 -4
- package/packages/host/dist/tokenstats.js.map +1 -1
- package/packages/host/dist/transcript/transcriptparse.js +2 -2
- package/packages/host/dist/transcript/transcriptparse.js.map +1 -1
- package/packages/host/dist/waitclock.d.ts +12 -0
- package/packages/host/dist/waitclock.js +23 -0
- package/packages/host/dist/waitclock.js.map +1 -0
- package/packages/host/dist/weekburn.js +7 -5
- package/packages/host/dist/weekburn.js.map +1 -1
- package/packages/host/dist/worktreeleftover.js +13 -15
- package/packages/host/dist/worktreeleftover.js.map +1 -1
- package/packages/web/dist/assets/demo-DHkwSmU5.js +26 -0
- package/packages/web/dist/assets/{icons-D8RlmSLR.js → icons-5lVTFNUU.js} +1 -1
- package/packages/web/dist/assets/index-Bh4cH6X8.js +170 -0
- package/packages/web/dist/assets/index-F7VHtsLI.css +1 -0
- package/packages/web/dist/assets/shared-BvQMg9ra.js +51 -0
- package/packages/web/dist/assets/sheets-Cwi72V02.js +257 -0
- package/packages/web/dist/assets/sheets-DjU2XiUd.css +1 -0
- package/packages/web/dist/build-id.txt +1 -1
- package/packages/web/dist/buildstamp.json +1 -1
- package/packages/web/dist/index.html +7 -7
- package/packages/web/dist/sw.js +2 -2
- package/release.json +11 -3
- package/tools/repohealth/constants.mjs +34 -1
- package/tools/repohealth/fixture.json +5374 -38
- package/tools/repohealth/git.mjs +77 -0
- package/tools/repohealth/lang/dart-analyze.mjs +181 -0
- package/tools/repohealth/lang/dart-lex.mjs +494 -0
- package/tools/repohealth/lang/dart-resolve.mjs +95 -0
- package/tools/repohealth/lang/python-ast.mjs +602 -0
- package/tools/repohealth/lang/python-resolve.mjs +228 -0
- package/tools/repohealth/metrics/habits.mjs +286 -0
- package/tools/repohealth/metrics/native.mjs +542 -0
- package/tools/repohealth/metrics/untested.mjs +20 -8
- package/tools/repohealth/metrics/workspace.mjs +256 -0
- package/tools/repohealth/own.mjs +67 -5
- package/tools/repohealth/packs/dart.mjs +153 -85
- package/tools/repohealth/packs/python.mjs +51 -14
- package/tools/repohealth/plot.mjs +143 -1
- package/tools/repohealth/reach.mjs +98 -0
- package/tools/repohealth/scope.mjs +14 -1
- package/tools/repohealth/series.mjs +5 -0
- package/tools/repohealth/types.mjs +4 -0
- package/tools/repohealth.mjs +39 -5
- package/packages/web/dist/assets/demo-ad3g3HDa.js +0 -26
- package/packages/web/dist/assets/index-Csb7jynu.js +0 -170
- package/packages/web/dist/assets/index-Cz9Haocy.css +0 -1
- package/packages/web/dist/assets/shared-DBaaGttP.js +0 -51
- package/packages/web/dist/assets/sheets-CqsP9w1V.js +0 -256
- package/packages/web/dist/assets/sheets-DoUhPGK0.css +0 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import{B as e,Bc as t,Bo as n,Bs as r,Bu as i,Cc as a,Cl as o,Dc as s,Du as c,Ec as l,Et as u,Fc as d,Fo as f,Fs as p,G as m,Gi as h,H as g,Hc as _,Hs as v,Hu as y,Ic as b,Ii as x,In as S,Is as C,Iu as w,Ja as T,Jt as E,K as D,Ka as O,Kc as k,Ki as A,Kn as ee,L as j,Lc as M,Ln as N,Lu as te,Mi as P,Nc as F,Ns as I,Oc as L,Pc as R,Ps as z,Qa as B,R as V,Rc as ne,Rs as H,Sc as U,St as re,Tt as W,U as ie,Uo as ae,Vc as oe,Vs as se,Vu as ce,W as le,Wc as ue,Ws as de,Xa as fe,Xc as pe,Xn as me,Ya as he,Yc as ge,Za as _e,Zu as ve,_ as ye,_c as be,_o as xe,ad as Se,at as Ce,b as we,bc as Te,bl as Ee,bt as De,cd as Oe,dl as ke,dt as Ae,ec as je,fa as Me,fl as Ne,fr as Pe,gc as Fe,gd as Ie,gi as Le,hd as Re,ic as ze,it as Be,js as Ve,kc as He,kd as Ue,ko as We,ks as Ge,ll as Ke,mt as qe,ns as Je,pa as Ye,pt as Xe,qa as Ze,qc as Qe,qt as $e,sl as et,ui as tt,ul as nt,vc as rt,vt as it,wd as at,wu as ot,xa as st,xc as ct,xt as lt,yc as ut,yt as dt,zc as ft,zs as pt}from"./shared-BvQMg9ra.js";import{C as mt,E as ht,S as gt,T as _t,b as vt,f as yt,h as G,l as bt,m as xt,n as St,p as Ct,t as wt,u as Tt,w as Et,x as Dt,y as Ot}from"./demo-DHkwSmU5.js";import{$ as kt,$a as At,$c as jt,$d as Mt,$i as Nt,$l as Pt,$n as Ft,$o as It,$r as Lt,$s as Rt,$t as zt,$u as Bt,A as Vt,Aa as Ht,Ac as Ut,Ad as Wt,Af as Gt,Ai as Kt,Al as qt,An as Jt,Ao as Yt,Ar as Xt,As as Zt,At as Qt,Au as $t,B as en,Ba as tn,Bc as nn,Bd as rn,Bi as an,Bl as on,Bn as sn,Bo as cn,Br as ln,Bs as un,Bt as dn,Bu as fn,C as pn,Ca as mn,Cc as hn,Cd as gn,Cf as _n,Ci as vn,Cl as yn,Cn as bn,Co as xn,Cr as Sn,Cs as Cn,Ct as wn,Cu as Tn,D as En,Da as Dn,Dc as On,Dd as kn,Df as An,Di as jn,Dl as Mn,Dn as Nn,Do as Pn,Dr as Fn,Ds as In,Dt as Ln,Du as Rn,E as zn,Ea as Bn,Ec as Vn,Ed as Hn,Ef as Un,Ei as Wn,El as Gn,En as Kn,Eo as qn,Er as Jn,Es as Yn,Et as Xn,Eu as Zn,F as Qn,Fa as $n,Fc as er,Fd as tr,Ff as nr,Fi as rr,Fl as ir,Fn as ar,Fo as or,Fr as sr,Fs as cr,Ft as lr,Fu as ur,G as dr,Ga as fr,Gc as pr,Gd as mr,Gi as hr,Gl as gr,Gn as _r,Go as vr,Gr as yr,Gs as br,Gt as xr,Gu as Sr,H as Cr,Ha as wr,Hc as Tr,Hd as Er,Hi as Dr,Hl as Or,Hn as kr,Ho as Ar,Hr as jr,Hs as Mr,Ht as Nr,Hu as Pr,I as Fr,Ia as Ir,Ic as Lr,Id as Rr,If as zr,Ii as Br,Il as Vr,In as Hr,Io as Ur,Ir as Wr,Is as Gr,It as Kr,Iu as qr,J as Jr,Ja as Yr,Jc as Xr,Jd as Zr,Ji as Qr,Jl as $r,Jn as ei,Jo as ti,Jr as ni,Js as ri,Jt as ii,Ju as ai,K as oi,Ka as si,Kc as ci,Kd as li,Ki as ui,Kl as di,Kn as fi,Ko as pi,Kr as mi,Ks as hi,Kt as gi,Ku as _i,L as vi,La as yi,Lc as bi,Ld as xi,Li as Si,Ll as Ci,Ln as wi,Lo as Ti,Lr as Ei,Ls as Di,Lt as Oi,Lu as ki,M as Ai,Ma as ji,Mc as Mi,Md as Ni,Mf as Pi,Mi as Fi,Ml as Ii,Mn as Li,Mo as Ri,Mr as zi,Ms as Bi,Mt as Vi,Mu as Hi,N as Ui,Na as Wi,Nc as Gi,Nd as Ki,Nf as qi,Ni as Ji,Nl as Yi,Nn as Xi,No as Zi,Nr as Qi,Ns as $i,Nt as ea,Nu as ta,O as na,Oa as ra,Oc as ia,Od as aa,Of as oa,Oi as sa,Ol as ca,On as la,Oo as ua,Or as da,Os as fa,Ot as pa,Ou as ma,P as ha,Pa as ga,Pc as _a,Pd as va,Pf as ya,Pi as ba,Pl as xa,Pn as Sa,Po as Ca,Pr as wa,Ps as Ta,Pt as Ea,Pu as Da,Q as Oa,Qa as ka,Qc as Aa,Qd as ja,Qi as Ma,Ql as Na,Qn as Pa,Qo as Fa,Qs as Ia,Qt as La,Qu as Ra,R as za,Ra as Ba,Rc as Va,Rd as Ha,Ri as Ua,Rl as Wa,Rn as Ga,Ro as Ka,Rr as qa,Rs as Ja,Rt as Ya,Ru as Xa,S as Za,Sa as Qa,Sc as $a,Sd as eo,Sf as to,Si as no,Sl as ro,Sn as io,So as ao,Sr as oo,Ss as so,St as co,Su as lo,T as uo,Ta as fo,Tc as po,Td as mo,Tf as ho,Ti as go,Tl as _o,Tn as vo,To as yo,Tr as bo,Ts as xo,Tt as So,Tu as Co,U as wo,Ua as To,Uc as Eo,Ud as Do,Ui as Oo,Ul as ko,Un as Ao,Uo as jo,Ur as Mo,Us as No,Ut as Po,Uu as Fo,V as Io,Va as Lo,Vc as Ro,Vd as zo,Vi as Bo,Vl as Vo,Vn as Ho,Vo as Uo,Vr as Wo,Vs as Go,Vt as Ko,Vu as qo,W as Jo,Wa as Yo,Wc as Xo,Wd as Zo,Wi as Qo,Wl as $o,Wn as es,Wo as ts,Wr as ns,Ws as rs,Wt as is,Wu as as,X as os,Xa as ss,Xc as cs,Xd as ls,Xi as us,Xl as ds,Xn as fs,Xo as ps,Xr as ms,Xs as hs,Xt as gs,Xu as _s,Y as vs,Ya as ys,Yc as bs,Yd as xs,Yi as Ss,Yl as Cs,Yn as ws,Yo as Ts,Yr as Es,Ys as Ds,Yt as Os,Yu as ks,Z as As,Za as js,Zc as Ms,Zd as Ns,Zi as Ps,Zl as Fs,Zn as Is,Zo as Ls,Zr as Rs,Zs as zs,Zt as Bs,Zu as Vs,_ as Hs,_a as Us,_c as Ws,_d as Gs,_f as Ks,_i as qs,_l as Js,_n as Ys,_o as Xs,_r as Zs,_s as Qs,_t as $s,_u as ec,a as tc,aa as nc,ac as rc,ad as ic,af as ac,ai as oc,al as K,an as sc,ao as cc,ar as lc,as as uc,at as dc,au as fc,b as pc,ba as mc,bc as hc,bd as gc,bf as _c,bi as vc,bl as yc,bn as bc,bo as xc,br as Sc,bt as Cc,bu as wc,c as Tc,ca as Ec,cc as Dc,cd as Oc,cf as kc,ci as Ac,cl as jc,cn as Mc,co as Nc,cr as Pc,cs as Fc,ct as Ic,cu as Lc,d as Rc,da as zc,dc as Bc,dd as Vc,df as Hc,di as Uc,dl as Wc,dn as Gc,do as Kc,dr as qc,ds as Jc,dt as Yc,du as Xc,ea as Zc,ec as Qc,ed as $c,ef as el,ei as tl,el as nl,en as rl,eo as il,er as al,es as ol,et as sl,eu as cl,f as ll,fa as ul,fc as dl,fd as fl,ff as pl,fi as ml,fl as hl,fn as gl,fo as _l,fr as vl,fs as yl,ft as bl,fu as xl,g as Sl,ga as Cl,gc as wl,gd as Tl,gf as El,gi as Dl,gl as Ol,gn as kl,go as Al,gr as jl,gs as Ml,gt as Nl,gu as Pl,h as Fl,ha as Il,hc as Ll,hd as Rl,hf as zl,hi as Bl,hl as Vl,hn as Hl,ho as Ul,hr as Wl,hs as Gl,ht as Kl,hu as ql,i as Jl,ia as Yl,ic as Xl,id as Zl,if as Ql,ii as $l,il as eu,in as tu,io as nu,ir as ru,is as iu,it as au,iu as ou,j as su,ja as cu,jc as lu,jd as uu,jf as du,ji as fu,jl as pu,jn as mu,jo as hu,jr as gu,js as _u,jt as vu,ju as yu,k as bu,ka as xu,kc as Su,kd as Cu,kf as wu,ki as Tu,kl as Eu,kn as Du,ko as Ou,kr as ku,ks as Au,kt as ju,ku as Mu,l as Nu,la as Pu,lc as Fu,ld as Iu,lf as Lu,li as Ru,ll as zu,ln as Bu,lo as Vu,lr as Hu,ls as Uu,lt as Wu,lu as Gu,m as Ku,ma as qu,mc as Ju,md as Yu,mf as Xu,mi as Zu,ml as Qu,mn as $u,mo as ed,mr as td,ms as nd,mt as rd,mu as id,n as ad,na as od,nc as sd,nd as cd,nf as ld,ni as ud,nl as dd,nn as fd,no as pd,nr as md,ns as hd,nt as gd,nu as _d,o as vd,oa as yd,oc as bd,od as xd,of as Sd,oi as Cd,ol as q,on as wd,oo as Td,or as Ed,os as Dd,ot as Od,ou as kd,p as Ad,pa as jd,pc as Md,pd as Nd,pf as Pd,pi as Fd,pl as J,pn as Id,po as Ld,pr as Rd,ps as zd,pt as Bd,pu as Vd,q as Hd,qa as Ud,qc as Wd,qd as Gd,qi as Kd,ql as qd,qn as Jd,qo as Yd,qr as Xd,qs as Zd,qt as Qd,qu as $d,r as ef,ra as tf,rc as nf,rd as rf,rf as af,ri as of,rl as sf,rn as cf,ro as lf,rr as uf,rs as df,rt as ff,ru as pf,s as mf,sa as hf,sc as gf,sd as _f,sf as vf,si as yf,sl as bf,sn as xf,sr as Sf,ss as Cf,st as wf,su as Tf,t as Ef,ta as Df,tc as Of,td as kf,tf as Af,tl as jf,tn as Mf,to as Nf,tr as Pf,ts as Ff,tt as If,tu as Lf,u as Rf,ua as zf,uc as Bf,ud as Vf,uf as Hf,ui as Uf,ul as Wf,un as Gf,uo as Kf,ur as qf,us as Jf,ut as Yf,uu as Xf,v as Zf,va as Qf,vc as $f,vd as ep,vf as tp,vi as np,vl as rp,vn as ip,vo as ap,vr as op,vs as sp,vt as cp,vu as lp,w as up,wa as dp,wc as fp,wd as pp,wf as mp,wi as hp,wl as gp,wn as _p,wo as vp,wr as yp,ws as bp,wt as xp,wu as Sp,x as Cp,xa as wp,xc as Y,xd as Tp,xf as Ep,xi as Dp,xl as Op,xn as kp,xo as Ap,xr as jp,xs as Mp,xt as Np,xu as Pp,y as Fp,ya as Ip,yc as Lp,yd as Rp,yf as zp,yi as Bp,yl as Vp,yn as Hp,yo as Up,yr as Wp,ys as Gp,yt as Kp,yu as qp,z as Jp,za as Yp,zc as Xp,zd as Zp,zi as Qp,zl as X,zn as $p,zo as em,zr as tm,zs as nm,zt as rm,zu as im}from"./sheets-Cwi72V02.js";import{i as am,n as om,r as sm,t as cm}from"./react-CjmvHigY.js";import{$i as lm,$r as um,A as dm,At as fm,B as pm,Bn as mm,Bt as hm,Ci as gm,Cn as _m,Ct as vm,Di as ym,Dn as bm,Dr as xm,Ei as Sm,Et as Cm,F as wm,Fn as Tm,Fr as Em,Ft as Dm,G as Om,Gn as km,Hr as Am,Ii as jm,In as Mm,Ir as Nm,Jn as Pm,Ki as Fm,Kr as Im,Kt as Lm,Ln as Rm,Lr as zm,Lt as Bm,Mr as Vm,Mt as Hm,N as Um,Ni as Wm,Nn as Gm,Nr as Km,O as qm,Oi as Jm,On as Ym,Pr as Xm,Q as Zm,Qr as Qm,R as $m,Ri as eh,Rr as th,Rt as nh,S as rh,Si as ih,Sn as ah,St as oh,Tn as sh,Ui as ch,Un as lh,V as uh,Vi as dh,Wt as fh,X as ph,Xi as mh,Xn as hh,Xt as gh,Y as _h,Yn as vh,Yr as yh,Z as bh,Zi as xh,Zr as Sh,_ as Ch,_n as wh,_r as Th,_t as Eh,aa as Dh,ai as Oh,an as kh,ar as Ah,at as jh,b as Mh,bi as Nh,bn as Ph,c as Fh,cn as Ih,di as Lh,dt as Rh,ea as zh,fr as Bh,g as Vh,gi as Hh,gn as Uh,h as Wh,hi as Gh,hr as Kh,ht as qh,i as Jh,in as Yh,ir as Xh,it as Zh,j as Qh,jt as $h,k as eg,ki as tg,kn as ng,kt as rg,m as ig,mi as ag,na as og,nn as sg,oi as cg,on as lg,pn as ug,q as dg,qi as fg,qn as pg,qr as mg,r as hg,ra as gg,ri as _g,s as vg,sa as yg,si as bg,st as xg,ta as Sg,ti as Cg,tt as wg,u as Tg,un as Eg,ur as Dg,vi as Og,vn as kg,wi as Ag,wn as jg,wt as Mg,yi as Ng,yn as Pg,z as Fg,zr as Ig,zt as Lg}from"./icons-5lVTFNUU.js";import{n as Rg,t as zg}from"./xterm-BHsKrDzh.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)}})();var Z=am(),Bg=om();async function Vg(e,t){let[n,r]=await Promise.all([va.artifacts(e,`outbox`,void 0,{signal:t}).then(e=>e.files).catch(()=>[]),va.inbox(e,t).catch(()=>[])]);return[...n,...r].map(e=>e.relPath).filter(Boolean)}function Hg(e,t){return ki(e??``,t=>Vg(e,t),{enabled:t&&!!e}).data??void 0}var Ug={fresh:0,warm:1,heavy:2,steep:3},Wg=60;function Gg(e,t,n){if((Ug[n[e]]??0)>=Ug[t])return{notice:!1,next:n};let r={...n,[e]:t},i=Object.keys(r);if(i.length>Wg)for(let e of i.slice(0,i.length-Wg))delete r[e];return{notice:!0,next:r}}function Kg(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>Wg)for(let e of i.slice(0,i.length-Wg))delete r[e];return{notice:!0,next:r}}var qg={warn:1,high:2};function Jg(e,t,n){if(!t||(qg[n[e]]??0)>=qg[t])return{notice:!1,next:n};let r={...n,[e]:t},i=Object.keys(r);if(i.length>Wg)for(let e of i.slice(0,i.length-Wg))delete r[e];return{notice:!0,next:r}}function Yg(){let e=q(`spendWarn`),t=Gi();return n=>n?fe(n.contextSpark?.costUsd,t,e):null}function Xg(e){let t=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!e||!e.running)return;let n=ot(e.contextSpark,{lastTurnAt:e.lastTurnAt,turnActive:e.turnActive,now:Date.now()});if(!n||n.level===`fresh`)return;let r=t.current??=gt(G.costNoticed,{}),{notice:i,next:a}=Gg(e.id,n.level,r);i&&(t.current=a,ht(G.costNoticed,a),X(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?c(t?.liveAgentTok,t?.liveAgentAt,Date.now(),nl()):null,i=n.current??=gt(G.agentNoticed,{}),{notice:a,next:o}=Kg(e.id,r?t?.liveAgentId??`agent`:null,i);o!==i&&(n.current=o,ht(G.agentNoticed,o)),a&&r&&X(r)},[e]);let r=(0,Z.useRef)(null),i=Yg()(e);(0,Z.useEffect)(()=>{if(!e||!i)return;let t=r.current??=gt(G.spendNoticed,{}),{notice:n,next:a}=Jg(e.id,i.level,t);n&&(r.current=a,ht(G.spendNoticed,a),X(`${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}=Ri(e.id,t?.verdict.state===`over`,a.current);a.current=r,n&&t&&X(hu(e.title,t))},[e])}function Zg(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 Qg=6e3,$g=2e4,e_=9e4,t_=1500,n_=5e3,r_=45e3;function i_(e,t=!1){return e.map(e=>t?`failed ${e.ackId}`:e.ackId).join(`
|
|
2
|
+
`)}var a_=`pending:`,o_=e=>!!e?.startsWith(a_),s_=e=>`${a_}${e}`,c_=`${a_}later:`,l_=e=>!!e?.startsWith(c_),u_=e=>`${c_}${e}`,d_=(e,t)=>o_(e)&&t?`create:${t}`:e;function f_(e,t){let n=e.attempts??0,r=1+Math.min(3,n);return e.mode===`op`?(t==null?$g:Math.max($g,Math.min(12e4,t*6)))*r:e.mode===`backlog`||e.mode===`upload`?Qg*r:e_}function p_(e,n,r=Date.now()){let i=(e.tries??0)+1;return{...e,status:`queued`,attempts:n?Math.max(0,(e.attempts??1)-1):e.attempts,tries:i,retryAt:r+t(i)}}function m_(e){return e.pendingCreate&&e.holdUntilIdle?!0:void 0}function h_(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 g_(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 __(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 v_(e){let t=Dr(e).trim().replace(/\s+/g,` `);return t?t.length>64?`${t.slice(0,64)}…`:t:e.mode===`upload`?`a file`:`an action`}function y_(e){return new Set(e.filter(Ee).map(e=>e.id))}function b_(e,t){for(let n of e)if(!t.has(n))return!0;return!1}function x_(e,t){return{...e,status:`pending`,attempts:(e.attempts??0)+1,sentAt:t,firstTryAt:e.firstTryAt??t,waitReason:void 0}}function S_(e){let t=e.firstTryAt;return e.mode===`upload`?null:e.mode===`op`?e.op?t==null?e.op:O(e.op,t):null:e.mode===`backlog`?{t:`backlog.add`,text:e.text,repoDir:e.cwd,label:e.label??e.text.slice(0,40),fire:e.fire,targetSessionId:e.targetSessionId,autoFire:e.autoFire,ackId:e.ackId,firstSentAt:t,steps:e.steps,resume:e.resume,...typeof e.closeWhenDone==`boolean`?{closeWhenDone:e.closeWhenDone}:{},...e.flagWhenDone?{flagWhenDone:!0}:{},...e.budget?{budget:e.budget}:{},...e.launch?{launch:e.launch}:{},...e.pastBudget?{pastBudget:!0}:{}}:e.answer?{t:`session.input`,id:e.sessionId,data:e.text,ackId:e.ackId,firstSentAt:t,expectPrompt:e.answer.fingerprint,promptSubmit:e.answer.submitBox,promptChoice:e.answer.choice,...e.answer.text===void 0?{}:{promptText:e.answer.text}}:{t:`session.input`,id:e.sessionId,data:e.text,ackId:e.ackId,firstSentAt:t,submit:!0,cwd:e.cwd,view:e.view}}function C_(e){return`sending “${e}”…`}var w_=`pending:`;function T_(e){let t=e.remembered;if(t?.startsWith(w_)){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 E_(e,t,n){return e===`${w_}${t}`?n:e}function D_(e,t,n){let r=!1,i={};for(let[a,o]of Object.entries(e)){let e=E_(o,t,n);e!==o&&(r=!0),i[a]=e}return r?i:e}function O_(e){return`back to ${e}`}function k_(e,t){return!!e&&!!t&&e.sessionId===t}var A_=Mu({}),j_=Mu(null);function M_(e,t,n){A_.set(n=>n[e]===t?n:{...n,[e]:t}),n&&j_.set(()=>({sessionId:t,to:n}))}function N_(e,t){A_.set(n=>D_(n,e,t)),j_.set(n=>{if(!n)return n;let r=E_(n.sessionId,e,t);return r===n.sessionId?n:{...n,sessionId:r}})}function P_(){j_.set(null)}var F_=3e4;function I_(e){return e?.adoptedAt&&Date.now()-e.adoptedAt>F_?void 0:e}function L_(e,t,n){let r=(0,Z.useRef)(new Map),i=(0,Z.useMemo)(()=>{if(!o_(e))return null;let n=e.slice(a_.length);return t.find(e=>e.ackId===n&&Sr(e))??null},[t,e]);return{pendingKept:r,pendingEntry:i,pendingSession:(0,Z.useMemo)(()=>{if(e&&!o_(e)){if(n.some(t=>t.id===e))return null;let t=I_(r.current.get(e));return t?.adoptedAt?{id:e,cwd:t.cwd,title:t.title,remoteControl:!1,running:!0,createdAt:t.ts}:null}if(!o_(e))return null;if(l_(e)){let t=e.slice(c_.length);return{id:e,cwd:t,title:Tp(t)||`new session`,remoteControl:!1,running:!0,createdAt:Date.now()}}let t=i,a=I_(r.current.get(e.slice(a_.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||Tp(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 R_(e){let{outboxRef:t,pendingKept:n,activeIdRef:r,connRef:i,wantNavRef:a,buffers:o,pendingEntry:s,backendsRef:c}=e,l=t=>e.writeOutbox(t),u=(t,n)=>e.addOutbox(t,n),d=(t,n,r,i)=>e.queueOp(t,n,r,i),f=e.setOverlay,p=e.setActiveId,m=e.setLastVisitedId;function h(e){let n=t.current.find(t=>Sr(t)&&t.cwd===e&&t.status!==`failed`);n&&_(n.ackId)}function g(e){a.current=!1,f(null),p(u_(e))}function _(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||Tp(r.cwd),ts:r.ts});n.current.size>8;)n.current.delete(n.current.keys().next().value);a.current=!1,f(null),p(s_(e))}function v(e){let n=s,r=n?.op;if(!n||n.status!==`failed`||r?.t!==`session.create`)return;J(e?`action:session.pending.instead`:`action:session.pending.retry`);let a=t.current.filter(e=>e.mode===`input`&&e.createAck===n.ackId&&e.status===`failed`).sort((e,t)=>e.ts-t.ts),o=new Set([n.ackId,...a.map(e=>e.ackId)]);l(t.current.filter(e=>!o.has(e.ackId)));let c=Bt(),{ackId:u,...f}=r;e&&(f.launch={backend:e}),d(f,n.sessionId,n.text,{cwd:n.cwd,focus:!0,ackId:c});for(let e of a)b(e.cwd,e.text,c,e.kind===`command`?`command`:`prompt`);let p=s_(n.ackId),m=ai(p);m&&ic(s_(c),m)&&ic(p,``),_(c),X(i.current.status===`open`?`trying again…`:`queued — it opens when the link is back`)}function y(e,t){let i=s_(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(N_(e,t),r.current!==i)return;let s=ai(i);(!s||ic(t,s))&&ic(i,``),o.current.has(t)||o.current.set(t,[]),p(t),m(t)}function b(e,n,r,i=`prompt`){let a=new Set((c?.current??[]).filter(e=>e.kind===`shell`).map(e=>e.id)),o=i===`prompt`?z_(t.current,r,n,a):null;o?l(o):u({ackId:Bt(),sessionId:`create:${e}`,cwd:e,text:n,ts:Date.now(),status:`queued`,attempts:0,kind:i,mode:`input`,pendingCreate:!0,holdUntilIdle:!0,createAck:r,armed:!0})}function x(e,n){let r=new Set(L(t.current,e,n).map(e=>e.ackId));l(t.current.map(e=>r.has(e.ackId)?{...e,noTtl:!0}:e))}function S(e,n,r){let i=new Set(L(t.current,e,r).map(e=>e.ackId));l(t.current.map(e=>i.has(e.ackId)?(Zo(),{...e,status:`failed`,reason:n,failedAt:Date.now()}):e))}function C(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);l(t.current.map(t=>t.ackId!==e.ackId&&t.status===`queued`&&t.sessionId===e.sessionId&&i(t)?(Zo(),{...t,status:`failed`,reason:n,failedAt:Date.now()}):t))}return{enterPending:_,enterOldestPending:h,enterLater:g,retryPendingCreate:v,adoptPendingSession:y,queueSessionPrompt:b,holdForLaunch:x,failPendingCreates:S,failDependentUploads:C}}function z_(e,t,n,r=new Set){let i=n.trim();if(!i)return null;let a=e.findIndex(e=>e.ackId===t&&Sr(e)),o=e[a];if(!o||o.status!==`queued`||o.attempts||o.tries||o.firstTryAt||o.sentAt)return null;let s=o.op;if(s.prompt||s.replaceSessionId||s.companionOf||s.launch?.backend&&r.has(s.launch.backend)||e.some(e=>e.createAck===t&&e.mode===`input`))return null;let c=[...new Set([...s.needs??[],...B_(i)])],l=e.slice();return l[a]={...o,text:i,op:{...s,prompt:i,...c.length?{needs:c}:{}}},l}function B_(e){let t=new Set;for(let n of e.matchAll(/\.claude\/inbox\/[A-Za-z0-9._-]+/g))t.add(n[0]);return[...t]}function V_(e){let{connRef:t,sessionsRef:n,backendsRef:r,exitedRef:i,outboxRef:o,ackTimers:s,uploadsInFlight:c,uploadAborts:u,busyLanesRef:d,budgetHeldLanesRef:f,busySerialRef:p,serialWatchRef:m,budgetRef:h,autoSendRef:g,holdQueueRef:v,flushIdleReason:y,queueBlockedRef:S,readModeRef:C,serialSessionsRef:w,sessions:T}=e,{inflightRef:D,upBytesRef:O}=e.up,k=()=>e.up.refreshUploadLabel(),A=t=>e.writeOutbox(t),ee=(t,n)=>e.addOutbox(t,n),j=t=>e.addOutboxFirstInLane(t),M=(t,n,r)=>e.failOutbox(t,n,r),N=t=>e.holdWall(t),te=(t,n,r,i)=>e.queueSessionPrompt(t,n,r,i);async function P(e,t=!0){if(e.mode!==`upload`)return;let n=e.upload?await ls(`uploads`,e.ackId):null;n&&e.upload&&await Wo(e.upload.relPath,n),t&&await xs(`uploads`,e.ackId)}function F(e){return f_(e,li())}function I(e){let t=Date.now();A(o.current.map(n=>{if(n.ackId!==e||n.status===`failed`)return n;let r=(n.round??0)+1,i=oe(r);return{...n,status:`queued`,attempts:0,round:r,retryAt:t+i,waitReason:`the desktop hasn't answered yet`}}));let n=o.current.find(t=>t.ackId===e);n&&(n.round??0)===1&&X(`still sending — the desktop hasn't confirmed yet. Retrying in ${Math.round(oe(1)/6e4)} min; your text is safe.`)}function L(e,n=Qg){let r=window.setTimeout(()=>{s.current.delete(e);let n=o.current,r=t.current.status!==`open`;n.some(t=>t.ackId===e&&t.status===`pending`)&&(Ha(),A(n.map(t=>t.ackId===e?p_(t,r):t))),z()},n);s.current.set(e,r)}function R(){if(t.current.status!==`open`||ep().pending.includes(`sessions`))return[];let e=new Set(n.current.filter(e=>e.running).map(e=>e.id));return h_(o.current,e,i.current)}function z(i=!1){if(i&&(v.current=!1,A(o.current.map(e=>e.status===`queued`?{...e,armed:!0,retryAt:void 0,waitReason:void 0,holdUntilIdle:e.holdUntilIdle&&(e.pendingCreate||N(e.sessionId))?!0:void 0}:e))),t.current.status!==`open`)return y.current=Te([],{online:!1,queued:1}),0;let a=R(),u=He(o.current,{now:Date.now(),inflight:[...s.current.keys(),...c.current],maxAttempts:8,minTryMs:ft,busyLanes:d.current,busySerial:(()=>{let e=ct(Tu(n.current,r.current),m.current,Date.now());return p.current=e.busy,m.current=e.watches,e.busy})(),budgetBlocked:h.current?.verdict.blocked??!1,goneLanes:a,budgetHeldLanes:f.current});u.release.length&&A(l(o.current,u.release));for(let e of u.expire)Do(),I(e.ackId);let _={autoSend:g.current,hold:v.current},b=0,x=[...u.blocked];for(let e of u.send){if(!U(e,_)){x.push({ackId:e.ackId,sessionId:e.sessionId,reason:`gate`});continue}let n=Date.now(),r=x_(e,n);if(A(o.current.map(t=>t.ackId===e.ackId?x_(t,n):t)),e.mode===`upload`){ce(e),b++;continue}let i=S_(r);i&&t.current.send(i),L(e.ackId,F(e)),b++}let C=new Map(x.map(e=>[e.ackId,e.reason]));return S.current=C,e.setQueueBlocked(C),y.current=b?null:Te(x,{online:!0,queued:o.current.filter(e=>e.status===`queued`).length,serialText:(()=>{let e=x.find(e=>e.reason===`serial`),t=e&&o.current.find(t=>t.ackId===e.ackId);return t?.serial?Kt(t.serial,n.current,r.current):void 0})()}),b}function B(e=`nothing queued`){return y.current??e}function V(){window.setTimeout(()=>{z()},450)}function H(e){let t=ne(o.current,e)[0],n=t?{relPath:t,reason:`it never uploaded`}:Fo(e);return n?`${n.relPath.split(`/`).pop()} — ${n.reason}. Re-attach it before sending.`:null}function re(e,t){let n=H(e);if(n)return X(n),!1;let r=b(o.current,e,t);return r.some((e,t)=>e!==o.current[t])&&A(r),!0}function W(e){let t=H(e.join(`
|
|
3
|
+
`));return!t||(X(t),!1)}function ie(e,n,r,i,a=!1){if(!a&&E(r)){let t=T.find(t=>t.id===e);t&&(t.hooked?t.turnActive:t.running&&!t.idle)&&(a=!0,X(`${r.trim().split(/\s+/)[0]} opens a view — held until this turn ends`))}if(!re(r,d_(e,n)))return!1;if(l_(e))return X(`this session starts only when its backlog item runs — write it in the box and Send`),!1;if(o_(e))return te(n,r,e.slice(a_.length),i),z(),!0;let o=Bt(),s=t.current.status!==`open`;return ee({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:C.current?`read`:`term`}),s||ue(e),z(),!0}function ae(e,n,r,i){let o=i?.ackId??Bt(),s=t.current.status!==`open`,c=i?.cwd??``,l=(i?.serial??w.current)&&e.t===`session.create`&&e.prompt&&c?a(c):void 0;return ee({ackId:o,sessionId:n,cwd:c,text:r,ts:Date.now(),status:`queued`,attempts:0,mode:`op`,serial:l,op:{...e,ackId:o},focus:i?.focus&&!s?!0:void 0,offline:s,armed:!s},i?.frontOfLane),i?.track&&vp(o),s||ue(n),z(),s}async function se(e,t,n,r,i){r=d_(r,i);let a=Bt(),{name:o,relPath:s}=cd(n);return await ja(`uploads`,a,t),await ls(`uploads`,a)?(ee({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}),z(),{relPath:s,ackId:a}):null}async function ce(e){let n=e.upload;if(!n){M(e.ackId,`not an image`),V();return}c.current.add(e.ackId);let r=new AbortController;u.current.set(e.ackId,r),D.current++,O.current.startedAt||(O.current.startedAt=Date.now()),O.current.total+=n.size,k();let i=0,a=Date.now(),s=!1,l=0,d=()=>{window.clearTimeout(l),l=window.setTimeout(()=>{s=!0,r.abort(new Le(`upload`,r_))},r_)};d();try{let t=await ls(`uploads`,e.ackId);if(!t){M(e.ackId,`the file's bytes are no longer on this device`);return}let s=await va.uploadInbox(n.repoId,t,n.name,r.signal,e=>{O.current.sent+=Math.max(0,e-i),i=e,d(),k()},!0),c=s.saved?.[0]?.relPath;if(!c){M(e.ackId,s.skipped?.[0]?.error||`the host refused the file`);return}Ul(n.repoId,c,s.saved[0].mtime),us(n.size,Date.now()-a),xs(`uploads`,e.ackId),c!==n.relPath&&le(n.relPath,c),A(o.current.filter(t=>t.ackId!==e.ackId))}catch(n){if(n?.permanent){M(e.ackId,n.message);return}let r=_({responded:n?.responded,stalled:s,socketOpen:t.current.status===`open`});A(o.current.map(t=>t.ackId===e.ackId&&t.status===`pending`?p_(t,r):t))}finally{window.clearTimeout(l),O.current.sent+=Math.max(0,n.size-i),D.current=Math.max(0,D.current-1),k(),u.current.delete(e.ackId),c.current.delete(e.ackId),V()}}function le(t,n){A(o.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 ue(e){let t=o.current.filter(t=>t.sessionId===e&&t.status===`queued`&&!t.armed);t.length&&(A(o.current.map(t=>t.sessionId===e&&t.status===`queued`?{...t,armed:!0}:t)),X(`sending ${t.length} earlier queued message${t.length>1?`s`:``} first`))}function de(e){if(!re(e.text,e.targetSessionId??e.repoDir))return null;let n=Bt(),r=t.current.status!==`open`;return ee({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||ue(e.targetSessionId??e.repoDir),z(),r}function fe(e,n,r,i,a,o){let s=e.prompt;if(!s)return;let c=t.current.status!==`open`;j({ackId:Bt(),sessionId:e.id,cwd:e.cwd,text:n,ts:Date.now(),status:`queued`,attempts:0,mode:`input`,answer:{fingerprint:x(s),question:s.question,label:r,...i?{submitBox:!0}:{},...a==null?{}:{choice:a},...o===void 0?{}:{text:o}},offline:c,armed:!0}),X(c?`answer saved — “${r}” goes out when the link is back`:C_(r)),z()}return{retainUploadBytes:P,ackWindowFor:F,nextRound:I,armAckTimeout:L,goneLanes:R,flushOutbox:z,idleReason:B,releaseLane:V,uploadRefusal:H,guardUploadRefs:re,guardChain:W,submitInput:ie,queueOp:ae,queueImageUpload:se,runUpload:ce,rewriteQueuedPath:le,armLane:ue,queueBacklog:de,answerPrompt:fe}}function H_(e){let{outboxRef:t,outbox:n,pendingKept:r,activeIdRef:i,connRef:o,sessions:s,activeId:c}=e,l=t=>e.writeOutbox(t),u=t=>e.flushOutbox(t),d=t=>e.idleReason(t),f=t=>e.holdWall(t),p=(t,n)=>e.retainUploadBytes(t,n),m=(t,n,r)=>e.failPendingCreates(t,n,r),h=(t,n,r)=>e.queueSessionPrompt(t,n,r),g=e.openSend,_=e.sendTargetFor,v=e.setActiveId,y=e.setCompose;function b(){let e=ui(n);if(!e){X(Qo(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;g({prompts:[Dr(e)],target:_(e.sessionId,e.cwd),cwdHint:e.cwd,repoId:P(e),ackId:e.ackId,repair:!0,openAfter:!0,origin:t>0?`This one never went — ${t} more under Manage`:`This one never went`})}function x(){for(let e of t.current)e.status===`failed`&&e.mode===`upload`&&p(e);l(t.current.filter(e=>e.status!==`failed`))}function S(e,n){l(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 C(e,n){let r=t.current,i=r.find(t=>t.ackId===e);return i?Fe(i)?(J(`action:queue.retarget`),l(rt(r,e,{...n,ackId:Bt()})),X(n.mode===`backlog`?`moved to that repo's backlog`:`moved to that session`),!0):(X(i.mode===`op`?`an action can't be re-aimed`:`already on its way`),!1):!1}function w(e){let n=t.current,r=n.find(t=>t.ackId===e);if(!r)return;if(!Fe(r)){X(`already on its way`);return}if(E(r.text??``)){r.holdUntilIdle||T(e),X(ml(`idle`,{online:o.current.status===`open`,holder:`phone`,phoneHold:`opens-a-view`}));return}J(`action:queue.handtodesktop`);let i=Bt();l(rt(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(),X(ml(`idle`,{online:o.current.status===`open`,holder:`desktop`}))}function T(e){J(`action:queue.hold`),l(t.current.map(t=>t.ackId===e&&t.status===`queued`?{...t,holdUntilIdle:!t.holdUntilIdle||void 0}:t)),u()}function D(e){J(`action:queue.serial`),l(t.current.map(t=>t.ackId===e&&t.status===`queued`&&$d(t)?{...t,serial:t.serial?void 0:a(t.cwd)}:t)),u()}function O(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 k(e){if(!e.length)return;let n=new Set(e.map(e=>e.ackId));l(t.current.filter(e=>!n.has(e.ackId)))}function A(e){let n=t.current.find(t=>t.ackId===e);r.current.delete(e),i.current===s_(e)&&v(null),n?p(n):xs(`uploads`,e),n?.mode===`upload`&&n.upload&&$c(n.upload.relPath,`the upload was canceled`),l(t.current.filter(t=>t.ackId!==e)),n&&Sr(n)&&m(n.sessionId,`the session it was queued for was discarded`,n.ackId)}function ee(e,n){let r=t.current.find(t=>t.ackId===e);!r||!Sr(r)||r.status!==`queued`?X(`that session is already on its way`):(J(`action:queue.addprompt`),h(r.cwd,n,r.ackId),X(`queued — it runs after the one before it finishes`))}function j(e,n){l(be(t.current,e,n))}function M(e){let n=t.current,r=n.find(t=>t.ackId===e);if(!r)return;if(r.status===`failed`){if(!ba(r)){X(Ji(r)?`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&&(qo(r.upload.relPath),ln(r.upload.relPath)),n=l(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?X(s):(l(n.map((t,n)=>t.ackId===e?{...t,armed:!0,retryAt:void 0,waitReason:void 0,serial:void 0,holdUntilIdle:m_(t)}:n<a&&t.sessionId===i.sessionId&&t.status===`queued`?{...t,armed:!0,retryAt:void 0,waitReason:void 0,holdUntilIdle:m_(t)}:t)),u()?o.length&&X(`${o.length} earlier message${o.length>1?`s`:``} in this session go first`):X(d(`nothing left to send`)))}function N(){let e=t.current.filter(ba);if(!e.length){X(`nothing to try again`);return}for(let t of e)t.mode===`upload`&&t.upload&&(qo(t.upload.relPath),ln(t.upload.relPath));let n=new Set(e.map(e=>e.ackId));l(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();X(r?`${e.length} back in the queue — sending…`:`${e.length} back in the queue — ${d(`waiting`)}`)}function te(e){let n=t.current.find(t=>t.ackId===e);if(!n)return;if(n.mode===`op`){X(`that's an action — discard it instead`);return}if(n.pendingCreate){A(e),y(e=>e?`${e}\n${n.text}`:n.text),X(`moved into the message box`);return}let r=s.find(e=>e.id===n.sessionId);if(!r){A(e),y(e=>e?`${e}\n${n.text}`:n.text),X(`moved into the message box`);return}let i=ai(r.id),a=i?`${i}\n${n.text}`:n.text;!ic(r.id,a)&&c!==r.id?X(`couldn't save to ${r.title}'s message box — it stays in the queue`):(A(e),c===r.id&&y(a),X(`moved into ${r.title}'s message box`))}function P(t){return e.repoForCwd(t.cwd)?.id??null}return{restoreOutbox:b,dismissOutbox:x,editQueued:S,retargetQueued:C,handToDesktop:w,toggleHoldQueued:T,toggleSerialQueued:D,scheduleQueueRows:O,dropScheduleQueue:k,removeQueued:A,addPromptToQueuedCreate:ee,moveQueued:j,sendQueuedNow:M,retryFailedQueued:N,restoreQueued:te,repoIdOfEntry:P}}function U_(){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?Ss(l-i,f):null;t(l<=0?`Uploading ${e}…`:p?`Sent ${pp(l)} · waiting for the host${m>2?` · ${m}s`:``}`:`Uploading ${e} · ${h}% · ${pp(i)}/${pp(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=Zg(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 W_(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}=Qr(),s=await Ps(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`,X(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?ru(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),X(`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){X(t.fail??`Upload failed`);return}let r=n.join(` `);tr(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&&l_(t.target.id)&&e.setActiveId(null),X(o?`Attached ${n.length} · ${ml(`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(``),X(`Attached ${n.length} · submitted`)}else s?(S(l),X(t.submit&&!l_(t.target?.id)?`Attached ${n.length} · session gone, in box`:`Attached ${n.length} · ready`)):X(`Attached ${n.length} · copied (switched away)`)}return{ensureUploadBuf:C,queueUpload:w,cancelUploads:T,settleUploads:E}}function G_(e){let{ackTimers:t,outboxRef:n,serialWatchRef:r}=e,i=e,a=t=>e.writeOutbox(t),o=t=>e.flushOutbox(t),c=(t,n,r)=>e.failOutbox(t,n,r),l=()=>e.releaseLane(),u=e.applyDeliverySettled,d=(t,n,r)=>e.failPendingCreates(t,n,r),f=(t,n)=>e.adoptPendingSession(t,n),p=(t,n)=>e.holdForLaunch(t,n);function m(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)):c(e.ackId,e.reason||`could not queue`),l()}function h(e){let o=t.current.get(e.ackId);o!=null&&(clearTimeout(o),t.current.delete(e.ackId));let u=n.current.find(t=>t.ackId===e.ackId);xn(e.ackId,e.ok,e.runId,e.reason),u?.op?.t===`signin.continue`&&X(e.reason||(e.ok?`continuing after the sign-in`:`nothing was continued`)),e.ok?(a(n.current.filter(t=>t.ackId!==e.ackId)),u&&Sr(u)&&(u.serial&&e.sessionId&&(r.current=[...r.current.filter(e=>e.group!==u.serial),{group:u.serial,sessionId:e.sessionId,at:Date.now()}]),e.sessionId?(a(s(n.current,u.sessionId,e.sessionId,Date.now(),u.ackId)),f(u.ackId,e.sessionId)):e.launchId?p(u.sessionId,u.ackId):d(u.sessionId,`the session was never named — re-aim these or discard them`,u.ackId)),u?.focus&&e.sessionId&&i.focusSession(e.sessionId)):(c(e.ackId,e.reason||`could not start`,`refused`),u?.op?.t===`intent.requeue`&&X(e.reason||`it was not put back — the desktop refused it`)),l()}function g(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`?X(e.reason||`forked into a new session`):i&&Er(Date.now()-i.ts),i?.answer&&Wa(C_(i.answer.label)),a(n.current.filter(t=>t.ackId!==e.ackId)),l();else if(e.retryable)a(n.current.map(t=>t.ackId===e.ackId&&t.status===`pending`?{...p_(t,!1),waitReason:e.reason||void 0}:t)),l();else if(e.state===`rescued`)a(n.current.filter(t=>t.ackId!==e.ackId)),X(e.reason||`that session is gone — the words are a backlog item now`),l();else{if(c(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;X(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`&&X(`prompt is in the composer but Return didn't take — open the session and press Return`);l()}}function _(e){for(let t of e.items)u(t)}function v(e){u(e.item)}function y(e){i.setLaunches(e.launches);for(let t of e.launches)(t.state===`failed`||t.state===`canceled`)&&d(`create:${t.cwd}`,t.reason||`the session never opened`,t.id)}function b(e){a(s(n.current,`create:${e.cwd}`,e.sessionId,Date.now(),e.id)),f(e.id,e.sessionId),o()}function x(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:m,onOpAck:h,onInputAck:g,onDeliveryList:_,onDeliverySettled:v,onLaunchList:y,onLaunchOpened:b,onBudget:x}}function K_(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=me(o,u),a.set(e.id,s)}return{doc:o,n:a.size}}function q_(){if(Dt(G.padRescueMigrated))return 0;let e=()=>Et(G.padRescueMigrated,String(Date.now())),{doc:t,n}=K_(gt(G.padRescue,[]),Vs(),Date.now());return n?Oc(t)?(e(),n):0:(e(),0)}function J_(e){if(Dt(G.giveupsMigrated))return e;let t=gt(G.giveups,[]);if(Et(G.giveupsMigrated,String(Date.now())),!Array.isArray(t)||!t.length)return e;let n=new Set(e.map(e=>e.ackId)),r=new Map(_s().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(`
|
|
4
|
+
|
|
5
|
+
`):e.text??``).trim();if(!a)continue;let o=e.cwd??``;i.push({ackId:Bt(),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 Y_(e){ma(ks);let t=$t(Zn),n=$t(Co),{conn:r,...i}=e,{status:a,connRef:o,reconnectAsk:s,setReconnectAsk:c}=r,{sessions:l}=i,u=Sp(l),f=Sp(i.backends),p=Sp(i.activeId),m=sf(`confirmQueue`),[h,g]=(0,Z.useState)(null),_=(0,Z.useRef)(null),[v,y]=(0,Z.useState)([]),b=Sp(v),[,x]=(0,Z.useState)(0),S=t.some(e=>e.status===`pending`||e.status===`queued`&&e.retryAt!=null);(0,Z.useEffect)(()=>{if(!S)return;let e=window.setInterval(()=>x(e=>e+1),1e3);return()=>window.clearInterval(e)},[S]);let C=Zg(t.some(e=>e.status!==`failed`),t_),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),j=(0,Z.useRef)([]),N=(0,Z.useRef)(new Map),te=(0,Z.useRef)(!1),F=(0,Z.useRef)(null),I=(0,Z.useRef)(new Map),{pendingKept:L,pendingEntry:z,pendingSession:B}=L_(i.activeId,t,l),V=U_(),ne={...i,connRef:o,status:a,reconnectAsk:s,setReconnectAsk:c,sessionsRef:u,backendsRef:f,activeIdRef:p,getActive:()=>l.find(e=>e.id===i.activeId)??B,budgetRef:_,setBudget:g,launchesRef:b,setLaunches:y,serialSessionsRef:sf(`serialSessions`),confirmQueueRef:m,autoSendRef:sf(`autoSend`)},H=ne,U={...ne,outbox:t,outboxRef:w,ackTimers:T,uploadsInFlight:E,uploadAborts:D,busyLanesRef:O,budgetHeldLanesRef:k,busySerialRef:A,serialWatchRef:j,holdQueueRef:te,flushIdleReason:F,queueBlockedRef:I,setQueueBlocked:e=>Co.set(e),pendingKept:L,pendingEntry:z,up:V},re=e=>U.writeOutbox(e),W=e=>U.flushOutbox(e),ie=(e,t)=>U.retainUploadBytes(e,t),ae=(e,t,n)=>U.failPendingCreates(e,t,n),oe=(e,t)=>U.failDependentUploads(e,t);function se(e){let t=u.current.find(t=>t.id===e);if(!t)return null;let n=d({...sa(t,f.current),turnActive:void 0});return n===`limit`?`blocked on a usage limit — it goes out at the reset`:n===`auth`?`that session is signed out — it goes out once you sign in there`:n===`net`?`the desktop is retrying that session's last turn after a network error — it goes out once that gets through`: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 Rn.set(xd(e)?null:Date.now()),w.current=e,Zn.set(e),Ft(e.filter(e=>e.status!==`failed`).length),e}function le(e,t=!1){let n=w.current,r=t?M(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)?(Zo(),{...e,status:`failed`,reason:`queue full — older messages were pushed out`,failedAt:Date.now()}):e),X(`queue full — ${t.size} older message${t.size>1?`s`:``} stopped; their words are in ${Td.activity}`))}if(i.length>1e3){let e=i.filter(e=>e.status===`failed`),t=new Set(e.slice(0,i.length-Xa).map(e=>e.ackId));t.size&&(i=i.filter(e=>!t.has(e.ackId)),X(`${t.size} of the oldest failed sends had to be dropped — this device is out of room for them`))}re(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&&(Zo(),X(fu(n,t,H.overlayRef.current===`queue`)),re(r.map(r=>r.ackId===e?{...r,status:`failed`,reason:t,failState:n??`other`,failedAt:Date.now()}:r)),Sr(i)&&ae(i.sessionId,`the session never opened — ${t}`,i.ackId),i.mode===`upload`&&i.upload)){$c(i.upload.relPath,`it never uploaded — ${t}`),ie(i,!1),oe(i,`the image it refers to never uploaded — ${t}`);for(let e of H.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`){re(w.current.filter(e=>e.ackId!==t.ackId)),X(`“${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`);re(w.current.map(e=>e.ackId===t.ackId?{...e,reason:n,hostSettled:!0}:e))}Object.assign(U,{writeOutbox:ce,addOutbox:le,addOutboxFirstInLane:ue,failOutbox:de,applyDeliverySettled:fe,holdWall:se}),Object.assign(U,V_(U)),Object.assign(U,R_(U)),Object.assign(U,H_(U)),Object.assign(U,W_(U));let pe=G_(U);(0,Z.useEffect)(()=>{if(a!==`open`)return;let e=w.current.filter(e=>e.status===`queued`&&e.offline&&!e.armed);if(m.current&&e.length>0){te.current=!0,c(!0),W();return}te.current=!1;let t=W();if(t>0){let e=w.current.filter(e=>e.status!==`failed`).length;X(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&&(te.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));re(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(()=>{W()},n_);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 ${et.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=>R(sa(e,f.current));O.current=new Set(l.filter(e).map(e=>e.id));let t=y_(l),n=b_(k.current,t);k.current=t;{let e=ct(Tu(l,f.current),j.current,Date.now());A.current=e.busy,j.current=e.watches}let r=!1,i=N.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)&&W()},[l,i.backends]);let[_e,ve]=(0,Z.useState)(0);(0,Z.useEffect)(()=>ac(()=>ve(e=>e+1)),[]),(0,Z.useEffect)(()=>{let e=t.filter(e=>e.status===`queued`||e.status===`pending`).length;Zp(e+Ql(P))},[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(Sr).map(e=>e.sessionId)),n=new Set(e.filter(Sr).map(e=>e.ackId)),r=e=>e.pendingCreate&&(e.createAck?!n.has(e.createAck):!t.has(e.sessionId));e=e.map(e=>r(e)?(Zo(),{...e,pendingCreate:void 0,status:`failed`,reason:`the session it was queued for is gone`,failedAt:Date.now()}):e),re(J_(e));let i=q_();i&&X(ee(i))},[]),(0,Z.useEffect)(()=>{let e=new Set(t.filter(Sr).map(e=>s_(e.ackId))),n=Zl(t=>t===i.activeId||e.has(t),e=>L.current.get(e.slice(a_.length))?.cwd);n.moved?X(`the words written for a session that never opened are on the pad (${n.moved})`):n.refused&&X(`words written for a session that never opened are kept on this device — the pad is full`)},[t,i.activeId]);let ye=U,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:te,flushIdleReason:F,parkedSends:me,sendSettled:C,budget:h,launches:v,laneLabel:e=>g_(e,l),PENDING_PREFIX:a_,isPendingId:o_,pendingLaneId:s_,laneFor:d_,pendingEntry:z,pendingSession:B,uploads:{uploading:V.uploading,parking:V.parking,upProg:V.upProg,current:()=>V.uploadBufRef.current,ensureUploadBuf:ye.ensureUploadBuf,queueUpload:ye.queueUpload,settleUploads:ye.settleUploads,cancelUploads:ye.cancelUploads,parkingRef:V.parkingRef,uploadBufRef:V.uploadBufRef,allBufsRef:V.allBufsRef,uploadPending:V.uploadPending,uploadRowLinger:V.uploadRowLinger}}}var X_=e=>I(e);function Z_(e,t,n){if(n?.v===1)return!1;let r=t?.model;if(!r)return!1;let i=xo(e,t?.backend)?.models.where;return i?i[r]===`hosted`:!1}function Q_(){let e=gt(G.hostedAck,null);return e&&typeof e.v==`number`?e:null}function $_(e=Date.now()){let t={at:e,v:1};return ht(G.hostedAck,t),t}function ev(){vt(G.hostedAck)}var Q=cm();function tv({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=ki(e.id,()=>va.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 va.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)(nd,{title:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xh,{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)(rg,{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)(Cf,{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)(Fc,{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)(Jf,{className:`mono`,children:e.name}),(0,Q.jsx)(Uu,{children:i===e.name?`creating…`:e.current?`primary`:t?`worktree`:`new worktree`})]},e.name)})]})]})}function nv({cur:e,backends:t,modelInput:n,setModelInput:r,submitInput:i,relaunch:a,sessionCan:o,sessionCant:s,onClose:c}){let l=Mr(t,e.backend),u=o(e,`slash`),d=Bi(t,e.backend),f=t=>{i(e.id,e.cwd,`/model ${t}`,`command`),c(),X(`/model ${t}`)},p=t=>a(e,t),m=e=>u?f(e):p({model:e}),h=un(t,e.backend,u),g=t=>{h?(i(e.id,e.cwd,`/effort ${t}`,`command`),c(),X(`/effort ${t}`)):p({effort:t})};return(0,Q.jsxs)(`div`,{className:`sheet`,children:[(0,Q.jsx)(nd,{title:`Switch model`,onClose:c}),(0,Q.jsxs)(yl,{children:[`Current: `,Sa(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)(Fc,{as:`button`,onClick:()=>m(t),children:[(0,Q.jsx)(Jf,{className:`mono`,children:t}),e.model===t&&(0,Q.jsx)(Jc,{tone:`ok`,children:`current`})]},t)),l.ids.length>0&&(0,Q.jsx)(`div`,{className:`section`,children:`Versions`}),l.ids.map(t=>(0,Q.jsxs)(Fc,{as:`button`,onClick:()=>m(t),children:[(0,Q.jsx)(Jf,{className:`mono`,children:t}),e.model===t&&(0,Q.jsx)(Jc,{tone:`ok`,children:`current`})]},t)),(0,Q.jsx)(`div`,{className:`section`,children:`Custom`}),l.freeText&&(0,Q.jsx)(yl,{children:$i(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(``)):X(`type a model id first`)},children:u?`Send /model`:`Relaunch on it`})]}),u?(0,Q.jsx)(Fc,{as:`button`,onClick:()=>{i(e.id,e.cwd,`/model`,`command`),c()},children:(0,Q.jsx)(Jf,{children:`Open the model picker…`})}):(0,Q.jsx)(uc,{cants:[{label:`the CLI’s own model picker`,reason:s(e,`slash`)}]})]}),d.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yl,{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)(Y,{className:e.effort===t?`active`:``,onClick:()=>g(t),children:t},t))})})]}):(0,Q.jsx)(uc,{cants:[{label:`effort`,reason:s(e,`effort`)??`this session has no effort setting`}]})]})}function rv(e){let{backends:t,launch:n,setOverlay:r}=e;return{branches:()=>e.branchPick?(0,Q.jsx)(tv,{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)(_p,{root:e.root,repos:e.repos,onClose:()=>r(null),onChanged:e.refreshRepos,onOpen:e.openCwd,backends:zs(t)?[...Mp(t)]:void 0,backend:n.backend,onBackend:e.pickBackend,onBuildApp:Id}),launchask:()=>{if(!e.launchAskFor)return null;let i=e.launchAskFor;return(0,Q.jsx)(Hl,{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)($u,{title:n.title,backends:t,launch:n.launch,onAccept:()=>{$_(),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)(nv,{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 iv=`This desktop can’t open a shell — it needs an update.`,av=1200;function ov(e){let{backends:t,setOverlay:n,geomRef:r,setRepos:i,setReposAt:a,setReposFailAt:o}=e,s=sf(`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)(pi),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(``),S=(0,Z.useRef)(t);S.current=t;function C(){va.repos().then(e=>{i(e),Fa(e),a(Date.now()),Gs(`repos`)}).catch(()=>{o(Date.now())})}function w(e){_(t=>{let n={...t,...e};return Object.keys(n).forEach(e=>{n[e]||delete n[e]}),ht(G.launch,n),n})}let T=e=>Di(e,S.current);function E(e){let{launch:t,...n}=e,i=t?nm(t,S.current):null;return i&&X(i),{t:`session.create`,...n,cols:r.current.cols,rows:r.current.rows,...t?{launch:T(t)}:null}}function D(t,r,i){let a=fa(S.current,r.launch?.backend),o=!!a&&!r.resume&&Rt(S.current,r.launch?.backend).length>0;if(a&&!o&&!hs(s.current,!!r.resume,!!r.override))return X(`Not started — ${a}`),r.onCancel?.(),!0;if(o||hs(s.current,!!r.resume,!!r.override)){let a=se(e.repos,t);return p({title:a,run:(e,t)=>{O(a,e,i,r.onCancel,t)||i(e,t)},onCancel:r.onCancel,budget:r.budget}),n(`launchask`),!0}return!r.resume&&O(se(e.repos,t),r.launch,i,r.onCancel,void 0)}function O(e,t,r,i,a){return!t||!Z_(S.current,t,Q_())?!1:(J(`overlay:hostedack`),h({title:e,launch:t,run:r,onCancel:i,budget:a}),n(`hostedack`),!0)}let k=(e,n)=>Ta(t,e?bp(e):void 0,n),A=(e,n)=>Au(t,e?bp(e):void 0,n),ee=e=>{if(e.unadopted)return(0,Z.createElement)(iu,null,e.unadopted);if(Gr(t,e.launch?.backend)||Li(e))return null;let n=Au(t,e.launch?.backend,`resumePick`);return n?(0,Z.createElement)(iu,null,n):null},j=e=>w({backend:e,model:void 0,effort:void 0});function M(t){let n=e.openingCwds().get(t.worktreePath);n&&X(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(X_(t),{launch:g},(e,n)=>N(t,e,n??void 0))&&N(t,g)}function N(e,t,n){let r=Bt();c(E({cwd:e.worktreePath,title:I(e),launch:t,...n?{budget:n}:{}}),`create:${e.worktreePath}`,`open ${I(e)}`,{cwd:e.worktreePath,focus:!0,ackId:r})&&J(`action:repo.new.offline`),l(r)}function te(e){let t=ri(S.current);return t?(J(`action:shell.new`),R(e.worktreePath,`shell · ${I(e)}`,!1,void 0,{backend:t.id})):(X(iv),null)}function P(e){let t=ri(S.current);return t?(J(`action:shell.companion`),R(e.cwd,`shell · ${e.title}`,!1,void 0,{backend:t.id},void 0,void 0,e.id)):(X(iv),null)}function F(){return ri(S.current)?null:iv}function L(t,n={}){let r=ri(S.current);if(!r)return X(iv),null;let i=Hi(),a=n.cwd||e.root,o=T_({remembered:A_.get()[t]??null,sessions:i.world.sessions,cwd:a,isShell:e=>Gr(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);J(`action:shell.focus`),i.nav.attach(e),s=e.id}else o.do===`enter`?(l(o.ack),s=s_(o.ack)):(J(`action:shell.new`),s=R(a,n.title||`shell · ${Tp(a)}`,!1,void 0,{backend:r.id}));return s?(M_(t,s,n.back),s):null}function R(e,t,n=!1,r,i,a,o,s){if(n&&Gr(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;J(n?`action:session.resume`:`action:session.new`);let u=Bt();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),s_(u)}async function z(e){let t=d(e)?.id;if(!t)return null;try{let e=await Promise.race([va.gitStatus(t),new Promise(e=>setTimeout(()=>e(null),av))]),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 B(e,t){let n=t.sourceId||Li(e);if(!n){X(`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 Xl({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});X(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 V(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=Li(r),u=a?.prompt?.trim()||void 0,d=u?B_(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} · ${Du(s,Yn(t,s.backend),t)}`,{cwd:r.cwd,focus:!a?.quiet||e.active?.id===r.id,frontOfLane:d.length>0}),!a?.quiet&&(n(null),X(`relaunch · ${Du(s,Yn(t,s.backend),t)}`))}function ne(e,t,n,r,i,a,o,s){if(D(t,{override:!!i,launch:i??g,onCancel:o,budget:s},(i,c)=>ne(e,t,n,r,i,a,o,c===void 0?s:c??void 0)))return;let d=i??g;J(`action:session.newprompt`);let f=n.map(e=>e.trim()).filter(Boolean),[p,...m]=f,h=B_(p??``),_=Bt(),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;X(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:j,wireLaunch:T,sessionCan:k,sessionCant:A,reopenCant:ee,refreshRepos:C,openRepo:M,openShell:te,openCompanionShell:P,focusShell:L,shellCant:F,openCwd:R,runForkRequest:B,startSessionWithPrompt:ne,relaunch:V,setBranchPick:y,sheets:rv({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:j,relaunch:V,sessionCan:k,sessionCant:A,recheckBackends:()=>{Hi().conn.send({t:`backends.recheck`})}})}}var sv=e=>e.preventDefault();function cv(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=>rr(e,b)===`confirming`),S=u.filter(e=>Fi(rr(e,b))),C=e=>rr(e,b)===`retrying`,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)(Nt,{records:s,onRemove:e=>{J(`action:pull.strip.remove`);for(let t of e)Xr.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?Hi().conn.liveSendAll(t,n,`${n} here — the desktop's queue still lists ${t.length===1?`it`:`them`} until the link is back`):X(n)},onOpen:()=>{J(`overlay:pull`),c(`pull`)}}),A=bs(s,cs()).length>0,ee=S.length?{rows:S,label:`not delivered`,icon:Ch}:x.length?{rows:x,label:`being confirmed`,icon:lh}:T.length?{rows:T,label:`queued`,icon:n===`open`?p.current?Bm:lh:um}:{rows:E,label:`sending`,icon:ah};return!O&&!S.length&&!x.length&&!T.length&&!D&&!A&&!f?null:(0,Q.jsxs)(Q.Fragment,{children:[k,(0,Q.jsx)(Zc,{records:s}),r&&d.length>0&&(0,Q.jsx)(qu,{slot:`queue-ask`,stowKey:i_(d),label:`send what you queued?`,detail:String(d.length),icon:oh,children:(0,Q.jsxs)(`div`,{className:`outbox-recover ask`,children:[(0,Q.jsx)(oh,{size:14}),(0,Q.jsxs)(`span`,{children:[`Back online — send `,d.length,` message`,d.length>1?`s`:``,` you queued while offline?`]}),(0,Q.jsxs)(Y,{onPointerDown:sv,onClick:()=>{J(`action:queue.confirm.send`);let e=h(!0);i(!1),X(e?`sending queued messages…`:g(`nothing left to send`))},children:[(0,Q.jsx)(Zh,{size:14}),` Send`]}),(0,Q.jsxs)(Y,{onPointerDown:sv,onClick:()=>{J(`action:queue.confirm.review`),c(`queue`)},children:[(0,Q.jsx)(Ym,{size:14}),` Review`]}),(0,Q.jsxs)(Y,{onPointerDown:sv,onClick:()=>{J(`action:queue.confirm.hold`),i(!1)},title:`keep them queued — nothing is sent until you release it`,children:[(0,Q.jsx)(Jh,{size:14}),` Hold`]}),(0,Q.jsx)(zc,{})]})}),S.length===0&&x.length===0&&w.length===0&&!D&&f&&(0,Q.jsxs)(`div`,{className:`outbox-recover sending`,children:[(0,Q.jsx)(Sm,{size:14}),(0,Q.jsx)(`span`,{children:`sent`})]}),(S.length>0||x.length>0||T.length>0||D)&&(0,Q.jsx)(qu,{slot:`queue`,stowKey:i_(ee.rows,S.length>0),label:ee.label,detail:String(ee.rows.length),icon:ee.icon,children:(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)(Ch,{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)(Y,{onPointerDown:sv,onClick:_,children:[(0,Q.jsx)(qh,{size:14}),` Restore`]}),(0,Q.jsxs)(Y,{onPointerDown:sv,onClick:()=>{J(`action:queue.manage`),wa(S,`the messages that were not delivered`)},children:[(0,Q.jsx)(Ym,{size:14}),` Manage`]}),(0,Q.jsxs)(Y,{onPointerDown:sv,onClick:v,children:[(0,Q.jsx)(Jh,{size:14}),` Dismiss`]}),(0,Q.jsx)(zc,{}),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:sv,title:`open this one in ${Td.activity}`,onClick:()=>{J(`action:queue.which`),wa([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:v_(e)})]},e.ackId)),S.length>3?(0,Q.jsxs)(`button`,{className:`outbox-which-row more`,onPointerDown:sv,onClick:()=>{J(`action:queue.which.more`),wa(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)(lh,{size:14}),(0,Q.jsx)(`span`,{children:Br(x.length)}),(0,Q.jsxs)(Y,{onPointerDown:sv,onClick:()=>{J(`action:queue.confirming`),wa(x,`the messages the desktop is still confirming`)},children:[(0,Q.jsx)(Ym,{size:14}),` Which`]}),(0,Q.jsx)(zc,{})]}):T.length>0?(0,Q.jsxs)(Q.Fragment,{children:[n===`open`?p.current?(0,Q.jsx)(Bm,{size:14}):(0,Q.jsx)(lh,{size:14}):(0,Q.jsx)(um,{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)(Y,{onPointerDown:sv,onClick:()=>{J(`action:outbox.retry`),h(!0)||X(g(`nothing left to send`))},children:[(0,Q.jsx)(qh,{size:14}),` Send now`]}),(n!==`open`||p.current||!(a&&!o))&&(0,Q.jsxs)(Y,{className:a&&!o?`active`:``,onPointerDown:sv,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);J(`action:outbox.auto`),K(`autoSend`,e),K(`confirmQueue`,!e),e&&(p.current=!1,i(!1),h()),X(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)(hg,{size:14}),` auto `,a&&!o?`on`:`off`]}),(0,Q.jsxs)(Y,{onPointerDown:sv,onClick:()=>{J(`action:queue.manage`),wa(T,`the messages still waiting to go out`)},children:[(0,Q.jsx)(Ym,{size:14}),` Manage`]}),(0,Q.jsx)(zc,{})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ah,{size:14,className:`spin`}),(0,Q.jsx)(`span`,{children:__(E)}),(0,Q.jsxs)(Y,{onPointerDown:sv,onClick:()=>{J(`action:queue.manage`),wa(E,`the messages going out now`)},children:[(0,Q.jsx)(Ym,{size:14}),` Manage`]}),(0,Q.jsx)(zc,{})]})})})]})}function lv(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 uv(e){return e===`now`||e===`idle`?e:null}function dv(e){return e===`this`||e===`new`?e:null}function fv(e,t,n,r,i=40){if(!t)return e;let a={...e[t],at:r};if(n.mode!==void 0){let e=uv(n.mode);e?a.mode=e:delete a.mode}if(n.when!==void 0){let e=lv(n.when,r);e?a.when=e:delete a.when}if(n.where!==void 0){let e=dv(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 pv(e,t){return t?uv(e[t]?.mode)??`now`:`now`}function mv(e,t){return t?dv(e[t]?.where)??`this`:`this`}function hv(e,t,n){return t?lv(e[t]?.when,n):null}function gv(e){return`When is set the way you last sent to ${e} — open When to change it`}function _v(e){let{connRef:t,liveSend:n,liveSendAll:i,queue:a,sessions:o,getVisibleRepos:s,intents:c,usage:l,launch:u,wireLaunch:d,geomRef:f,repoForCwd:p,startSessionWithPrompt:m,setOverlay:h,attach:g}=e,{pendingSession:_,budget:v}=a,{guardChain:y,guardUploadRefs:b,queueOp:x,submitInput:C,queueBacklog:w,writeOutbox:T,outboxRef:E,addOutbox:D,flushOutbox:O,queueImageUpload:A}=a,ee=a.entries,j=Ht(),[M,te]=(0,Z.useState)(null),P=(0,Z.useRef)(null);P.current=M;let F=(0,Z.useRef)(null),L=(0,Z.useRef)(gt(G.sendMemory,{}));function R(e,t){let n=fv(L.current,e,t,Date.now());n!==L.current&&(L.current=n,ht(G.sendMemory,n))}function z(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},a=t.kind===`at`?Re(t.rule):t.kind===`now`?At:k(t,cc(t,l??void 0)),o=[...new Set(e.flatMap(e=>{let t=c.find(t=>t.id===e)?.cwd,n=t?p(t):null,i=n?r(n):t?Tp(t):``;return i?[i]:[]}))],s=v?.verdict.blocked&&il(e,c).length>0?v.verdict.resumeAt?ue(v.verdict.resumeAt):`it clears`:null,u=t.kind===`at`?Wn(e.length,a):go(e.length,a,o,s),d=t.kind===`at`?c.find(t=>t.id===e[0])?.cwd:void 0;return d&&np(e[0],d),i(e.map(e=>({t:`intent.update`,id:e,patch:{trigger:n,...t.kind===`at`?{holdForHost:!!t.waitUntilFree}:{}}})),u,jn)}let B=(e,n)=>{let r=c.find(t=>t.id===e[0]),a=r?.trigger.kind===`at`?{kind:`at`,rule:r.trigger.rule,graceMin:r.trigger.graceMin,...r.holdForHost?{waitUntilFree:!0}:{}}:Kc(36e5),u=!1;return(0,Q.jsx)(Gc,{seed:{retime:{ids:e},when:a,draftKey:`send.retime`},sessions:o,repos:s(),outbox:ee,online:t.current.status===`open`,usage:l,intents:c,buildName:j,onAttach:async()=>[],onAnnotate:()=>{},onSend:t=>(u=z(e,t.when),u),onClose:()=>u?n.onSent():n.onCancel(),budgetHeld:v?.verdict.blocked?{note:Oe(v.verdict),resumeAt:v.verdict.resumeAt,ids:il(e,c)}:null,onPastBudget:e=>{i(e.map(e=>({t:`intent.waive`,id:e,rung:`budget`,on:!0})),lf(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?o.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 ne(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||Ie(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 H(e){let t=e.action;return{prompts:t.kind===`backlog`&&t.steps?.length?[...t.steps]:[at(t)],target:t.kind===`fanout`?{kind:`repos`,dirs:t.dirs,...t.budget?{budget:t.budget}:{},...t.launch?{launch:t.launch}:{}}:{kind:`repo`,cwd:t.repoDir,...t.kind===`backlog`&&typeof t.closeWhenDone==`boolean`?{closeWhenDone:t.closeWhenDone}:{},...t.kind===`backlog`&&t.flagWhenDone?{flagWhenDone:!0}:{},...t.kind===`backlog`&&t.budget?{budget:t.budget}:{},...t.kind===`backlog`&&t.launch?{launch:t.launch}:{}},when:{kind:`at`,rule:e.rule,graceMin:e.graceMin??120,name:Ie(e.name,at(t))||void 0,waitUntilFree:e.waitUntilFree},cwdHint:t.kind===`fanout`?t.dirs[0]??null:t.repoDir,scheduleId:e.id,origin:`Editing a schedule`}}function U(e){let t=(_?[...o,_]:o).find(t=>t.id===e);t&&g(t)}function re(e){let t=_f(_l,(e.prompts?.length?e.prompts:[``]).join(`\f`),e.cwdHint);t===`kept`?X(S):t===`refused`&&X(N),F.current=null,te(Ld(e,t)),h(`send`)}function W(e,i){let a=e.prompts.map(e=>e.trim()).filter(Boolean),o=a[0]??``,s=o.slice(0,40),h=e=>e.trimStart().startsWith(`/`)?`command`:`prompt`;if(e.target.kind!==`shell`&&!y(a))return!1;let g=i.scheduleId?c.find(e=>e.id===i.scheduleId)??null:null,_=Vu(e,g);if(_.kind===`refuse`)return X(_.why),!1;if(_.kind===`patch`&&g){let t=e.target.kind===`repo`||e.target.kind===`repos`?e.target.budget:void 0;if(JSON.stringify(t??null)!==JSON.stringify(g.budget??null))return X(`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:a},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`?Kf(e.target,e.when)??null:void 0,launch:e.target.kind===`repo`?e.target.launch?d(e.target.launch):null:void 0,holdForHost:e.when.kind===`at`?!!e.when.waitUntilFree:void 0,label:s};return J(`action:send.retime`),n({t:`intent.update`,id:g.id,patch:r},Nc(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`&&g.cwd&&np(g.id,g.cwd),!0):!1}if(e.when.kind===`at`&&e.target.kind===`session`){let t=e.when,n=e.target,r={id:i.scheduleId??`i_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,cwd:n.cwd,payload:{kind:`prompt`,steps:a},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:s};if(J(`action:send.clockSession`),!b(a.join(`
|
|
6
|
+
`),n.sessionId))return!1;let c=x({t:`intent.post`,intent:r},n.sessionId,o,{cwd:n.cwd});np(r.id,n.cwd);let u=a.length>1?` · ${a.length} turns`:``,d=cc(e.when,l??void 0),f=d==null?`when its window opens`:ue(d);return X(c?`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=g?.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:o,...e.target.kind===`repos`&&e.target.budget?{budget:e.target.budget}:t,...e.target.launch?{launch:d(e.target.launch)}:{}}:{kind:`backlog`,repoDir:e.target.cwd,text:o,autoFire:!0,...a.length>1?{steps:a}:{},...e.target.kind===`repo`&&typeof e.target.closeWhenDone==`boolean`?{closeWhenDone:e.target.closeWhenDone}:{},...Kf(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:d(e.target.launch)}:{}},s={id:i.scheduleId??`s_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,name:(e.when.name??``).trim()||o.split(`
|
|
7
|
+
`)[0].slice(0,60),enabled:!0,rule:e.when.rule,action:n,createdAt:Date.now(),nextAt:cc(e.when,l??void 0),graceMin:e.when.graceMin,waitUntilFree:e.when.waitUntilFree};J(`action:schedule.save`);let c=x({t:`schedule.save`,entry:s},`sched:${s.id}`,s.name),u=a.length>1?` · ${a.length} turns`:``,f=e.target.kind===`repo`&&!Ue(e.when.rule),m=p(e.target.kind===`repo`?e.target.cwd:``),h=f?` in ${m?r(m):`that repo`}`:``;return f&&e.target.kind===`repo`&&np(s.id,e.target.cwd),e.target.kind===`repos`&&a.length>1?X(`scheduled the first step — a sweep is ONE prompt, so the other ${a.length-1} were dropped`):X(f?c?`queued${u} — it is saved to the backlog when the link is back`:`queued${h}${u} for ${s.nextAt==null?`when its window opens`:ue(s.nextAt)} — it is in the backlog`:c?`queued${u} — the schedule is saved when the link is back`:`schedule saved${u}`),!0}if(e.when.kind===`after`){let t=e.when;if(e.target.kind===`repos`&&a.length>1)return X(`a sweep is ONE prompt — the other ${a.length-1} step${a.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`},i={id:`i_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,cwd:n,payload:{kind:`prompt`,steps:a},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:Kf(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:d(e.target.launch)}:{},label:s};J(`action:send.after`);let c=e.target.kind===`session`?e.target.sessionId:n;if(!b(a.join(`
|
|
8
|
+
`),c))return!1;let l=x({t:`intent.post`,intent:i},c,o,{cwd:n}),u=a.length>1?` · ${a.length} turns`:``,f=t.title?`“${t.title}”`:`the item before it`;return X(l?`Queued offline${u} — it reaches the desktop when the link is back, then waits for ${f}`:`Queued${u} — it goes in after ${f} finishes`),!0}let v=e.when.kind===`idle`;switch(e.target.kind){case`session`:{let n=e.target.sessionId,r=e.target.cwd,i=0,o=!1;for(let[e,t]of a.entries()){if(e===0&&!v){if(!C(n,r,t,h(t)))return!1;i++;continue}let a=w({text:t,repoDir:r,label:t.slice(0,40),targetSessionId:n,autoFire:!0});if(a===null)return X(`part of that chain could not be queued — its words are still in the box`),!1;o||=a,i++}if(!i)return!1;let s=a.length>1?` · ${a.length-1} more behind it`:``;return X(o||t.current.status!==`open`?`queued — it reaches the desktop when the link is back${s}`:v?`queued on the desktop — it goes in when this session is free${s}`:`sent${s}`),!0}case`repo`:{let t=e.target.cwd;if(!v){let n=p(t),r=e.target.launch??(e.launchChosen?u:void 0);return m(t,n?I(n):Tp(t),a,e.sequential,r,e.target.resume,()=>{re({prompts:a,target:e.target,cwdHint:t,repoId:i.repoId,origin:i.origin}),X(`nothing was started — your words are back in the send sheet`)},e.target.budget),!0}let n=w({text:o,steps:a,repoDir:t,label:s,autoFire:!0,resume:e.target.resume,closeWhenDone:e.target.closeWhenDone,budget:e.target.budget,flagWhenDone:Kf(e.target,e.when),...e.target.launch?{launch:d(e.target.launch)}:{}});if(n===null)return!1;let r=a.length>1?` · ${a.length} turns`:``;return X(n?`Queued offline${r} · it reaches the desktop when the link is back`:`Queued${r} · a new session when this repo is free`),!0}case`repos`:{if(!e.sequential){let t=x({t:`fanout.run`,dirs:e.target.dirs,text:o,launch:d(e.target.launch??u),...e.target.budget?{budget:e.target.budget}:{},...Kf(e.target,e.when)?{flagWhenDone:!0}:{},cols:f.current.cols,rows:f.current.rows},`fanout`,o);return a.length>1?X(`a sweep is ONE prompt — the other ${a.length-1} steps were dropped`):X(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 i=w({text:o,steps:a,repoDir:r,label:s,autoFire:!0,budget:e.target.budget,flagWhenDone:Kf(e.target,e.when),...e.target.launch?{launch:d(e.target.launch)}:{}});if(i===null)return X(`part of that sweep could not be queued — its words are still in the box`),!1;n||=i,t++}if(!t)return!1;let r=a.length>1?` · ${a.length} turns each`:``;return X(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=ra(e.target.cwd,e.target.buildId),n=x({t:`build.run`,repoDir:e.target.cwd,buildId:e.target.buildId},cu(e.target.cwd),ji(t),{cwd:e.target.cwd});return X(Wi(n,t)),!0}}}function ie(e){e.ackId&&T(E.current.filter(t=>t.ackId!==e.ackId)),e.padId&&rf([e.padId])}async function ae(e,n,r){J(`action:resend.reattach`);let i=await jr(e);if(!i){X(`those bytes are no longer on this device`);return}let a=Bt(),o=e.split(`/`).pop()||`file`;await ja(`uploads`,a,i),await ls(`uploads`,a)?(D({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}),qo(e),await ln(e),O(),X(t.current.status===`open`?`re-attached — uploading`:`re-attached — uploads when the link is back`)):X(`couldn't park the file on this device`)}let oe=(0,Z.useRef)(null),se=(0,Z.useRef)(null);function ce(e,t,n){return J(`action:resend.replace`),se.current?.(null),new Promise(e=>{se.current=async t=>{se.current=null,e(t)};let r=oe.current;r?(r.value=``,r.dataset.repoId=t,r.dataset.cwd=n,r.click()):(se.current=null,e(null))})}async function le(e){let t=e.target,n=t.files?.[0]??null,r=t.dataset.repoId??``,i=t.dataset.cwd??``,a=se.current;if(!n||!r||!a)a?.(null);else try{let{width:e}=Qr(),t=await Ps(n,n.name,e),o=await A(r,t.blob,t.name,i,i);a(o?.relPath??null),X(o?`attached — it uploads before the message`:`couldn't park that file`)}catch{a(null),X(`couldn't read that file`)}}return{sendSeed:M,setSendSeed:te,sendSeedRef:P,sendResumeRef:F,sendMemRef:L,noteSendAim:R,openSend:re,openSent:U,dispatchIntent:W,retireSendSource:ie,seedFromIntent:ne,seedFromSchedule:H,sendTargetFor:V,retimeMany:z,renderRetime:B,reattachKept:ae,pickReplacement:ce,onPickReplacement:le,replacePick:oe,buildNames:j}}var vv=` `;function yv(e){return e.replace(/\r?\n/g,`\r`)}function bv(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)+yv(t.slice(n))}var xv={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 Sv(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=xv[e.key];return t?e.key===`Enter`&&e.altKey?`\x1B\r`:t:null}var Cv={ctrl:`off`,alt:`off`,shift:`off`},wv=e=>({ctrl:e.ctrl!==`off`,alt:e.alt!==`off`,shift:e.shift!==`off`});function Tv(e){return e===`off`?`once`:e===`once`?`lock`:`off`}function Ev(e){return{ctrl:e.ctrl===`lock`?`lock`:`off`,alt:e.alt===`lock`?`lock`:`off`,shift:e.shift===`lock`?`lock`:`off`}}function Dv(e){return e===``?`backspace`:e===`\r`?`enter`:e===` `?`tab`:e===` `?`space`:e}var Ov={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 kv(e){let[t,n]=(0,Z.useState)(Cv),r=(0,Z.useRef)(Cv),i=e=>{r.current=e,n(e)};function a(t,n){let a=wv(r.current);if(!De(a)){e(n);return}let o=it(a,t);`refused`in o?X(`${o.refused}. Nothing was sent.`):(J(`action:chord.send`),e(o.bytes)),i(Ev(r.current))}let o=dt(wv(t),``).replace(/\+$/,``);return{mods:t,armed:De(wv(t)),heldName:o,tapMod(e){i({...r.current,[e]:Tv(r.current[e])})},clear(){i(Cv)},sendKey:a,sendTyped(t){if(!t)return;if(!De(wv(r.current))){e(t);return}let n=Array.from(t),i=0;for(;i<n.length&&De(wv(r.current));)a(Dv(n[i]),n[i]),i++;i<n.length&&e(n.slice(i).join(``))}}}var Av=/(?:^|[\s[(])(?:password|passphrase|passcode|pin)\b(?:'[^']*'|"[^"]*"|[^:'"\n]){0,160}:$/i;function jv(e){let t=e.replace(/\s+$/,``);return!t||t.length>200||!Av.test(t)?null:t.trim()}var Mv=200,Nv=new Set;function Pv(){let[e,t]=(0,Z.useState)(``),n=(0,Z.useRef)(``);n.current=e;let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(jo),[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,Mv)}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 ht(G.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 Fv(e,t){let{compose:n,setCompose:r,composeNow:i,composeRef:a,cmdHistory:s,histIdx:c,setHistIdx:l,histStash:u,clearArmed:d,setClearArmed:f,setSnippetOpen:p,pushHistory:h}=e,{active:g,pending:_,activeId:v,sessions:y,readerShown:b,enterSends:x,cliModeOn:S,setCliModeOn:C,repoForCwd:w}=t,{connRef:T,send:O}=t.conn,k=Sp(v),{submitInput:A,queueBacklog:ee}=t.queue,{parkingRef:j}=t.queue.uploads,{dispatchIntent:M,openSend:N,noteSendAim:te,sendMemRef:P}=t.sender,F=sf(`closeKbOnSend`),I=sf(`btwToCli`),L=sf(`busySend`);function R(){let e=()=>{t.showCli(),X(`switched to the CLI for the /btw answer — the book button above brings the reader back`)};I.current===`switch`?e():I.current!==`stay`&&rc({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&&(K(`btwToCli`,t?`switch`:`stay`),t||X(`won't ask again — Settings › Writing & reading › /btw from the reader changes it`)),t&&(J(`action:compose.btwToCli`),e())})}let[z,B]=(0,Z.useState)(`now`),[V,ne]=(0,Z.useState)(`this`),[H,U]=(0,Z.useState)(null),[re,W]=(0,Z.useState)(!1),ie=(0,Z.useRef)(vv),ae=(0,Z.useRef)(null),oe=kv(Me),se=(S||oe.armed)&&!_&&!b,ce=(0,Z.useRef)(!1);function ue(e){!oe.armed&&!S?(ce.current=document.activeElement===a.current,ie.current=vv,oe.tapMod(e),Ie()):oe.tapMod(e)}let de=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{oe.armed?(de.current=!0,ie.current=vv):de.current&&(de.current=!1,!S&&!ce.current&&a.current?.blur())},[oe.armed]),(0,Z.useEffect)(()=>{oe.clear()},[v,_,b]);let fe=l_(v);(0,Z.useEffect)(()=>{let e=ae.current;e&&e===v&&ic(e,n)},[n,v]),(0,Z.useEffect)(()=>{v?(ae.current=v,r(ai(v)),W(!1)):ae.current=null},[v]),(0,Z.useEffect)(()=>{fe?(B(`idle`),ne(`new`),U(null)):(B(pv(P.current,g?.cwd)),ne(mv(P.current,g?.cwd)),U(null))},[g?.cwd,fe]);let pe=Ti({read:()=>i.current,write:e=>r(e),key:()=>k.current??``});function me(t,n,r={}){let i=S;S&&(C(!1),ie.current=vv),oe.clear();let a=k.current===t,o=a?e.composeNow.current:ai(t)??``,s=n.trim()!==``&&o.includes(n.trim()),c=o.trim()!==``;if(s)return{leftCli:i,already:s,joined:c};if(r.ownLine){let r=c?`${o.replace(/\s+$/,``)}\n${n}`:n;a?e.setCompose(r):ic(t,r)}else a?e.insertCompose(n):ic(t,o?`${o}${o.endsWith(` `)?``:` `}${n}`:n);return{leftCli:i,already:s,joined:c}}function he(t,n){return e.composeNow.current===t&&(e.composeNow.current=n,e.setCompose(n),!0)}let[ge,_e]=(0,Z.useState)(null),[ve,ye]=(0,Z.useState)(null),[be,xe]=(0,Z.useState)(``),[Se,Ce]=(0,Z.useState)(!1);function we(e){let t=jv(e);_e(t),t||(xe(``),Ce(!1),ye(null))}(0,Z.useEffect)(()=>{_e(null),xe(``),Ce(!1),ye(null)},[v]);let Te=ge&&ge!==ve&&!_&&!se&&Gr(null,g?.backend)?ge:null;function De(){ge&&ye(ge),xe(``),Ce(!1)}let ke=Sp(Te);function Ae(){let e=k.current,t=ke.current;return!e||!t?null:{sessionId:e,askLine:t,fill(n){return!n||k.current!==e||ke.current!==t?!1:(xe(n),Ce(!1),!0)}}}function je(){g&&(be?T.current.status===`open`?(J(`action:compose.secret.send`),Me(`${be}\r`),xe(``),Ce(!1)):X(`link is down — a password is never queued; send it once the link is back`):X(`type the password first — Send types it into the prompt`))}function Me(e){g&&(_?X(`no terminal yet — keys reach the CLI once the session opens`):O({t:`session.input`,id:g.id,data:e}))}function Ne(e){if(s.length===0)return;if(f(!1),c===-1){if(e>0)return;u.current=n;let t=s.length-1;l(t),r(s[t]);return}let t=c+e;t<0?(l(0),r(s[0])):t>=s.length?(l(-1),r(u.current)):(l(t),r(s[t]))}function Pe(){d?(r(``),l(-1),u.current=``,f(!1)):(f(!0),X(`Tap clear again to wipe the message box`))}function Fe(e){r(t=>(t&&!/\s$/.test(t)?t+`
|
|
9
|
+
`:t)+e.text),l(-1),f(!1),p(!1),a.current?.focus()}function Ie(){let e=a.current;if(e){e.focus();try{e.setSelectionRange(e.value.length,e.value.length)}catch{}}}function Le(){let e=!S;J(e?`action:cli.on`:`action:cli.off`),oe.clear(),C(e),ie.current=vv,e&&(Ie(),X(T.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 Re(e){e.nativeEvent.isComposing||ze(e.target)}function ze(e){let t=bv(ie.current,e.value);ie.current=vv,e.value=vv,t&&oe.sendTyped(t)}function Be(e){if(e.nativeEvent.isComposing||e.keyCode===229)return;let t=Sv(e);if(!t)return;e.preventDefault();let n=Ov[e.key];oe.armed&&n?oe.sendKey(n,t):Me(t)}function Ve(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&!e.nativeEvent.isComposing?(e.preventDefault(),(n.trim()||Ed())&&Ge()):e.key===`Enter`&&x&&(e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||e.nativeEvent.isComposing||e.keyCode===229||(e.preventDefault(),(n.trim()||Ed())&&Ge()))}function He(){if(!g)return{refuse:``};if(V===`new`)return{target:{kind:`repo`,cwd:g.cwd}};if(V===`other`){if(!H)return{refuse:ud};let e=y.find(e=>e.id===H&&e.running);return e?{target:{kind:`session`,sessionId:e.id,cwd:e.cwd}}:{refuse:Zu(y.find(e=>e.id===H)?.title??null)}}return{target:{kind:`session`,sessionId:g.id,cwd:g.cwd}}}function Ue(){fe||(ne(`this`),U(null),te(g?.cwd,{where:`this`}))}let We=V===`other`&&H?y.find(e=>e.id===H&&e.running)??null:null;function Ge(e,i=!1,a,s=!1,c=!1,l=!1){let u=!i&&g&&V===`this`?Ed():null;if(u){let t=e??z;Xl({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.`,n?`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?(J(`action:compose.send.picture`),u(t===`idle`?`queue`:`run`)):Ge(e,!0)});return}if(!g||!n)return;if(j.current>0){X(`still reading that picture — Send goes the moment it is readable`);return}let d=Cd({how:a??e??z,explicit:e!==void 0||a!==void 0,aimedHere:V===`this`,turnActive:!!g.turnActive,pending:_,localCmd:E(n),pref:L.current});if(d===`ask`){let e=t.queue.budget;nf($l(e?.verdict.blocked?Oe(e.verdict):null)).then(e=>{if(!e)return;let t=e.ok?`now`:`idle`;J(e.alt?`action:compose.busy.pastbudget`:`action:compose.busy.${t}`),e.remember&&(K(`busySend`,t),X(oc(t))),Ge(void 0,!0,t,!!e.alt)});return}let f=e??d,p=g.budget;if(!c&&f===`now`&&V===`this`&&p?.cfg.hard&&Ee(g)&&!E(n)){Xl(Gp(o(p.verdict))).then(t=>{J(t?`action:compose.hardbudget.send`:`action:compose.hardbudget.keep`),t&&Ge(e,!0,f,s,!0)});return}let v=!l&&f===`now`&&V===`this`&&!_&&!E(n)?le(g.cliVersion,t.cliInstalled):null,y=v?`${g.id}|${v.installed}`:``;if(v&&!cf(g.id,v.installed)&&!Nv.has(y)){let i=D(v,{turnActive:g.turnActive,agents:g.agents?.length,shells:g.shells,resumeId:Li(g)});if(!i.cant&&!i.loses){let i=g;nf({...m(v),tone:`info`}).then(a=>{if(!a)return;if(!a.ok){J(`action:compose.restart.sendOld`),Nv.add(y),Ge(e,!0,f,s,!0,!0);return}J(`action:compose.restart.thenSend`);let o=n;t.relaunch(i,{},{prompt:o}),h(o),r(``),Ke()});return}}let x=e??z;J(`action:compose.send.${f}`);let S=n,C=T.current.status===`open`;if(V!==`this`){let e=He();if(`refuse`in e){e.refuse&&X(e.refuse),V===`other`&&H&&Ue();return}let n=e.target.cwd;if(!M({prompts:[S],target:e.target,when:f===`idle`?{kind:`idle`}:{kind:`now`},sequential:!1},{prompts:[S],target:e.target,cwdHint:n,repoId:w(n)?.id??null,origin:g.title}))return;if(h(S),r(``),fe){Ke(),t.leave();return}te(g.cwd,{mode:x,where:V}),B(x),Ke();return}let O=E(S),k=f===`idle`&&!_&&!O?`desktop`:`phone`;if(f===`idle`&&k===`desktop`){let e=ee({text:S.trim(),repoDir:g.cwd,label:S.trim().slice(0,40),targetSessionId:g.id,autoFire:!0,...s?{pastBudget:!0}:{}});if(e===null)return;h(S),r(``);let t=s?of(!e):ml(`idle`,{online:!e,holder:k});t&&X(t),te(g.cwd,{mode:x}),B(x),Ke();return}if(!A(g.id,g.cwd,S,S.trimStart().startsWith(`/`)?`command`:`prompt`,f===`idle`))return;h(S),r(``);let N=ml(f,{online:C,holder:k,phoneHold:O?`opens-a-view`:`session-not-open`});N&&X(N),b&&f!==`idle`&&$e(S)&&R(),te(g.cwd,{mode:x}),B(x),Ke()}function Ke(){F.current&&a.current?.blur()}function qe(){if(!g)return;J(`action:compose.options`);let e=hv(P.current,g.cwd,Date.now()),i=He(),a=g.id,o=n;N({prompts:n?[n]:[``],target:`target`in i?i.target:{kind:`session`,sessionId:g.id,cwd:g.cwd},cwdHint:g.cwd,repoId:w(g.cwd)?.id??null,...e?{when:e}:{},origin:e&&e.kind!==`now`?`${g.title} · ${gv(w(g.cwd)?.repoName??Tp(g.cwd))}`:g.title,onPosted:()=>{k.current===a?(r(``),l_(a)&&t.leave()):ai(a)===o&&ic(a,``)}})}function Je(){let e=n.trim();if(!e){X(Lt);return}J(`action:compose.pad`);let t=He(),i=`target`in t?t.target.cwd:g?.cwd,a=im({id:kf(),text:e,ts:Date.now(),...i?{cwd:i}:{}});a?X(a):(h(n),r(``),X(tl))}function Ye(e){if(!g)return;J(`action:hdrcmd.send`);let t=e.text;A(g.id,g.cwd,t,t.trimStart().startsWith(`/`)?`command`:`prompt`)&&(h(t),X(T.current.status===`open`?`sent ${e.title}`:`queued ${e.title} — sends when the link is back`))}return{...e,sendMode:z,setSendMode:B,sendWhere:V,setSendWhere:ne,sendWhereSid:H,setSendWhereSid:U,sendMenu:re,setSendMenu:W,cliMode:se,enterSends:x,voice:pe,aimedSession:We,noteSendAim:te,chord:oe,tapChordMod:ue,sendInput:Me,stepHistory:Ne,clearCompose:Pe,appendSnippet:Fe,focusPipe:Ie,toggleCliMode:Le,onPipeInput:Re,flushPipe:ze,onPipeKey:Be,onComposeKey:Ve,aimHere:Ue,sendCompose:Ge,openComposeSend:qe,keepOnPad:Je,runHeaderCmd:Ye,seedDraft:me,typeOn:he,sendNow:()=>Ge(`now`),secretAskLine:Te,secret:be,setSecret:xe,secretShown:Se,setSecretShown:Ce,noteCursorLine:we,dismissSecret:De,sendSecret:je,secretFillContext:Ae}}var Iv=bu(Qn,Hi);function Lv(e){jt().onFrame(e),ci().onText(e),Iv.dispatch(e)}function Rv(e){return Iv.runCommand(e)}function zv(){return Iv.boot()}var Bv=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)}))}},Vv=1e4,Hv=4e4;function Uv(e){return Math.min(Vv*2**Math.min(Number.isFinite(e)?Math.max(0,Math.floor(e)):0,8),Hv)}function Wv(e){let t=B(Ze(e,Date.now()));return Zr(`up`,t.length,`socket`),t}function Gv(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof Blob<`u`&&e instanceof Blob?e.size:0}var Kv=12e3,qv=1200,Jv=2,Yv=8e3,Xv=3e4,Zv=4e3,Qv=null;function $v(e){Qv=e}var ey=class{url;dial;ws=null;listeners=new Set;binaryListeners=new Set;early=new Bv;queue=[];reconnectTimer=null;dialTimer=null;dialsCut=0;heartbeatTimer=null;awaitingPong=!1;pingAt=0;probeResolve=null;probeTimer=null;probeAt=0;verifyTimer=null;verifyPending=!1;verifyPings=0;watchdogTimer=null;authPaused=!1;redialing=!1;heldToken=!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(ei,()=>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(Wv({t:`ping`}))}catch{this.forceReconnect();return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.verifyPending&&(this.verifyPending=!1,this.verifyPings<Jv?this.sendVerifyPing():this.forceReconnect())},qv)}}probe(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN||this.probeResolve)return Promise.resolve(null);try{this.ws.send(Wv({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()},Yv)}async maybeForceReload(){if(this.status!==`open`){if(Qv?.())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(G.lastForcedReload)||0);if(Date.now()-e<Xv)return;sessionStorage.setItem(G.lastForcedReload,String(Date.now()))}catch{}rn(),location.reload()}}}hasShellCache(){try{return!!navigator.serviceWorker?.controller}catch{return!1}}async hostReachable(){try{let e=new AbortController,t=window.setTimeout(()=>e.abort(),Zv);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}get tokenHeld(){return this.heldToken}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`&&$r($o())?this.awaitingPong=!1:this.awaitingPong?(this.awaitingPong=!1,this.forceReconnect()):(this.awaitingPong=!0,this.pingAt=Date.now(),this.ws.send(Wv({t:`ping`}))))},Kv)}stopHeartbeat(){this.heartbeatTimer!=null&&(window.clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}forceReconnect(){this.clearDialFuse(),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,t=ho(_c(this.url));this.heldToken=t&&!!An();try{let n=oa(t?null:An());e=this.dial?this.dial(this.url,n):n?new WebSocket(this.url,n):new WebSocket(this.url)}catch{this.status=`closed`,this.emitStatus(),this.scheduleReconnect();return}this.ws=e,this.armDialFuse(e);try{e.binaryType=`arraybuffer`}catch{}e.onopen=()=>{this.clearDialFuse(),this.dialsCut=0,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=n=>{let r=typeof n.data!=`string`;if(r?Zr(`down`,Gv(n.data),`socket`):Zr(`down`,n.data.length,`socket`),Tl(),this.awaitingPong=!1,this.verifyPending=!1,this.verifyTimer!=null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null),this.clearWatchdog(),r){n.data instanceof ArrayBuffer&&this.deliverBinary(n.data);return}let i;try{i=_e(n.data)}catch{return}i.t===`pong`?(this.pingAt&&=(zo(Date.now()-this.pingAt),0),this.probeResolve&&this.settleProbe(Date.now()-this.probeAt)):i.t===`authRequired`&&t?e.close():(i.t===`authRequired`&&(this.authPaused=!0,this.clearWatchdog()),this.deliver(i))},e.onclose=()=>{this.clearDialFuse(),this.status=`closed`,this.settleProbe(null),this.stopHeartbeat(),this.emitStatus(),this.scheduleReconnect()},e.onerror=()=>e.close()}armDialFuse(e){this.clearDialFuse(),this.dialTimer=window.setTimeout(()=>{if(this.dialTimer=null,this.ws===e&&e.readyState===WebSocket.CONNECTING){this.dialsCut++,e.onopen=e.onmessage=e.onclose=e.onerror=null;try{e.close()}catch{}this.ws=null,this.status=`closed`,this.emitStatus(),this.scheduleReconnect()}},Uv(this.dialsCut))}clearDialFuse(){this.dialTimer!=null&&(window.clearTimeout(this.dialTimer),this.dialTimer=null)}scheduleReconnect(){this.authPaused||(this.reconnectTimer??=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},1e3))}emitStatus(){Mt(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(`%s socket listener failed on %s`,ke,String(e.t),t)}}deliverBinary(e){for(let t of this.binaryListeners)try{t(e)}catch(e){console.error(`${ke} binary listener failed`,e)}}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(Wv(e)):this.queue.push(e)}trySend(e){return!this.ws||this.ws.readyState!==WebSocket.OPEN?!1:(this.ws.send(Wv(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)}},ty=null;function ny(){if(!ty){let e=Un();if(!e)throw Error(`no host paired — open the host setup screen`);let t=wt();ty=t?new ey(e,t.dial):new ey(e)}return ty}var ry=1800,iy={enabled:!1,gateTailscale:!1,canManage:!1};function ay(){let e=(0,Z.useRef)(ny()),[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:iy}),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),X(n),!0):(X(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 X(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 X(n),!0}function m(t,n=`no connection — the host can't be asked from here`){return e.current.status===`open`?(d(t),!0):(X(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,ry-(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 oy(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=lo(e,t,n),a={navRoute:i,navDepth:r},o=Tn(e,t,n);r===0?history.replaceState(a,``,o):history.pushState(a,``,o),Gu.keys[r]=i}),Gu.depth=r.length-1,Gu.keys.length=r.length,fc()}function sy(e,t,n,r){let i=id(),a=lo(e,t,n),o=history.state,s=o?.navRoute===a?o.navDepth||0:-1,c=Lc(Gu.keys,Gu.depth,a,r,s);if(c.kind===`seed`)Pt(a),oy(e,t,n);else if(c.kind===`known`)Gu.depth=c.depth,Gu.keys[c.depth]=a,fc();else if(c.kind===`go`)Gu.depth+=c.delta,c.forget&&Lf(Gu.depth);else if(c.kind===`push`){pf(Gu.depth);let r=Tn(e,t,n),i=Gu.depth+1,o={navRoute:a,navDepth:i};history.pushState(o,``,r),Gu.depth=i,Gu.keys[i]=a,Gu.keys.length=i+1,fc()}Tf(Gu.depth,Gu.keys[Gu.depth]??``,c.how),c.kind===`go`&&history.go(c.delta),cl(i);let l=t?Xc(t):null;Pu(Tn(e,t,n),Date.now(),l&&t?{navRoute:a,navParams:{overlay:t,params:{...l}}}:null)}function cy(){let e=id(),t=history.state,n=Pp(t,{...wc(),focusRepo:qp()},Gu.keys,Gu.depth);return!n.adopt&&ou(n.depth)&&n.depth>0?(Gu.depth=n.depth,cl(e),history.back(),null):(Gu.depth=n.depth,n.key&&(Gu.keys[n.depth]=n.key),n.adopt&&n.key&&(history.replaceState({navRoute:n.key,navDepth:n.depth},``),Gu.keys.length=n.depth+1),fc(),n.adopt||kd(n.depth,n.key),Tf(n.depth,Gu.keys[n.depth]??``,n.adopt?`push`:`return`),cl(e),{activeId:n.activeId,overlay:n.overlay})}function ly(){let e=(0,Z.useRef)(wc()).current,t=(0,Z.useRef)(!1),[n,r]=(0,Z.useState)(e.activeId),[i,a]=(0,Z.useState)(e.image?`swipe`:e.file&&Pn(e.file.relPath)?`gallery`:e.overlay),o=e=>a(t=>t===e?null:t),s=Sp(i),[c,l]=(0,Z.useState)(()=>qp()),u=(0,Z.useSyncExternalStore)(ql,Xf);return(0,Z.useEffect)(()=>{let e=!t.current;t.current=!0,sy(n,i,c,e)},[n,i,c,u]),(0,Z.useEffect)(()=>{let e=()=>{let e=cy();e&&(r(e.activeId),a(e.overlay),l(qp()))};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[]),(0,Z.useEffect)(()=>Gt(`Back`,()=>Gu.depth<=0||_d()?!1:(history.back(),!0),``),[]),{initRoute:e,activeId:n,setActiveId:r,overlay:i,setOverlay:a,closeSheet:o,overlayRef:s,focusRepo:c,setFocusRepo:l}}var uy=4e3,dy=`pty`,fy=65536,py=3e4,my=3e5,hy=12;function gy(e){let t=e.indexOf(`\x1B`);return t>0&&t<=1024?e.slice(t):e}async function _y(e,t,n,r){if(!t||n==null)return;let i={sessionId:e,tail:gy(t.slice(-65536)),seq:n,savedAt:Date.now(),boot:r};await ja(dy,e,i);let a=await Ns(dy);if(!(a.length<=hy))for(let e of[...a].sort((e,t)=>t.savedAt-e.savedAt).slice(hy))await xs(dy,e.sessionId)}async function vy(){return(await Ns(dy)).filter(e=>e&&e.sessionId&&typeof e.tail==`string`)}var yy=9e5;function by(e,t,n,r,i){let a=yy*(i?4:1);return e.filter(e=>e.id!==t).slice(0,12).filter(e=>!(e.running&&!e.idle)||r-(n.get(e.id)??0)>=a).map(e=>e.id)}var xy=!1;async function Sy(e,t,n){if(!xy){xy=!0;try{for(let r of e){n.set(r,Date.now());try{let e=await t.fetchTail(r,t.heldSeq(r));e&&e.data&&!t.attached(r)&&await t.apply(r,e)}catch{n.delete(r)}}}finally{xy=!1}}}function Cy(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 wy(e,t,n){return((e??``)+t).slice(-n)}function Ty(e,t,n=!1){let r=new Map;for(let i of e)!n&&(t.buffers.get(i.sessionId)?.length??0)>0||(t.buffers.set(i.sessionId,[i.tail]),r.set(i.sessionId,i.savedAt),i.boot&&(t.lastSeqById.set(i.sessionId,i.seq),t.restore.set(i.sessionId,i.seq),t.resumeBoot.set(i.sessionId,i.boot)));return r}function Ey(e,t){return[...e].sort((e,n)=>+(n.id===t)-(e.id===t)||n.createdAt-e.createdAt).map(e=>e.id)}function Dy(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)(()=>Ot(G.readMode)),D=(0,Z.useRef)(T);D.current=T;let[O,k]=(0,Z.useState)(null),[A,ee]=(0,Z.useState)(0),[j,M]=(0,Z.useState)(null);function N(e){M(t=>({kind:e,key:(t?.key??0)+1}))}let te=(0,Z.useRef)({cols:80,rows:30}),P=(0,Z.useRef)(null),F=(0,Z.useRef)(s),I=Sp(i),L=(0,Z.useRef)(!1),R=(0,Z.useRef)(null),z=(0,Z.useRef)(void 0),[B,V]=(0,Z.useState)(0),ne=Sp(s);function H(e){R.current===e&&ve(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 U(t){if(J(`action:session.attach`),e.noteVisited(t.id),r(null),M(null),!y){n(t.id);return}let i=h.current.get(t.id);i==null&&!p.has(t.id)&&l.current.set(t.id,[]),P.current=t.id,n(t.id),o({t:`session.attach`,id:t.id,resumeSeq:i,resumeBoot:g.current.get(t.id)??_.current}),D.current||Xo(t.id)}function re(){W(!0)}function W(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}=te.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 ie(e){E(e),_t(G.readMode,e),e?ee(e=>e+1):setTimeout(()=>W(!1),0)}function ae(e,t=!0){J(`action:session.read`),D.current=!0,ie(!0),U(e),t&&N(`outline`)}function oe(){ee(e=>e+1)}function se(t){l.current.has(t)||l.current.set(t,[]),P.current=t,n(t),e.noteVisited(t),r(null),o({t:`session.attach`,id:t})}function ce(e){_.current=e,P.current&&!D.current&&Xo(P.current),me.current()}function le(e){e.id===P.current&&e.idle&&oe(),e.idle&&!(D.current&&e.id===P.current)&&Xo(e.id)}function ue(e){let t=gc(e.dataB64);Cy(l.current,e.id,t,e.full)&&P.current===e.id&&w(e=>e+1),e.seq!=null&&u.current.set(e.id,e.seq),H(e.id),!e.full&&t&&(d.current.set(e.id,Date.now()),f.current.set(e.id,wy(f.current.get(e.id),t,uy))),S(e=>e+1)}function de(t){v.current.add(t.id),S(e=>e+1),e.onExit()}let fe=()=>c.current?.snapshot()??[];(0,Z.useEffect)(()=>{s===`open`&&F.current!==`open`&&(P.current=null),F.current=s},[s]),(0,Z.useEffect)(()=>{t?L.current||P.current!==t&&i.some(e=>e.id===t)&&y&&(P.current=t,o({t:`session.attach`,id:t,resumeSeq:u.current.get(t),resumeBoot:g.current.get(t)??_.current}),D.current||Xo(t)):P.current=null},[t,i,y,B]);let pe=Sp(s),me=(0,Z.useRef)(()=>{});me.current=()=>{if(pe.current!==`open`)return;let e=Ey(I.current,P.current);e.length&&pr(e).then(()=>{let e=by([...I.current].sort((e,t)=>t.createdAt-e.createdAt),P.current,he.current,Date.now(),ds());return e.length?Sy(e,ge,he.current):void 0})};let he=(0,Z.useRef)(new Map),ge={fetchTail:(e,t)=>va.screenTail(e,t),heldSeq:e=>{let t=g.current.get(e);return t&&t!==_.current?void 0:u.current.get(e)},attached:e=>P.current===e,apply:async(e,t)=>{let n=t.boot??_.current;await _y(e,t.data,t.seq,n),Ty([{sessionId:e,tail:gy(t.data.slice(-fy)),seq:t.seq,savedAt:Date.now(),boot:n}],{buffers:l.current,lastSeqById:u.current,restore:h.current,resumeBoot:g.current},!0),m(t=>new Map(t).set(e,Date.now()))}};(0,Z.useEffect)(()=>{let e=()=>{(document.visibilityState===`visible`||Cs($o(),_n()))&&me.current()},t=setInterval(e,my);return document.addEventListener(`visibilitychange`,e),e(),()=>{clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[]),(0,Z.useEffect)(()=>{let e=!1;return vy().then(t=>{if(e)return;let n=Ty(t,{buffers:l.current,lastSeqById:u.current,restore:h.current,resumeBoot:g.current});n.size&&m(n)}).finally(()=>{e||b(!0)}),Xn(),()=>{e=!0}},[]),(0,Z.useEffect)(()=>{let e=t;if(!e)return;let n=()=>{Ln(e),!h.current.has(e)&&_y(e,(l.current.get(e)??[]).join(``),u.current.get(e),_.current)},r=window.setInterval(()=>{L.current||n()},py);return window.addEventListener(`pagehide`,n),window.addEventListener(`freeze`,n),()=>{window.clearInterval(r),window.removeEventListener(`pagehide`,n),window.removeEventListener(`freeze`,n),n()}},[t]);function _e(e){Ln(e),!h.current.has(e)&&_y(e,(l.current.get(e)??[]).join(``),u.current.get(e),_.current)}function ve(e){R.current=null,window.clearTimeout(z.current),L.current&&(_e(e),o({t:`session.detach`,id:e}))}return(0,Z.useEffect)(()=>{let e=t;if(!e||o_(e))return;let n,r=()=>{let t=$o();if(!$r(t)||L.current)return;L.current=!0,_e(e),o({t:`session.detach`,id:e});let r=qd(t);r!=null&&(n=window.setInterval(i,r))},i=()=>{L.current&&!R.current&&ne.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(()=>ve(e),2e4),me.current())},a=()=>{window.clearInterval(n),n=void 0,L.current&&(L.current=!1,R.current=null,window.clearTimeout(z.current),P.current=null,V(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&&!o_(t))return()=>o({t:`session.detach`,id:t})},[t]),{termRef:c,geomRef:te,buffers:l,lastPtyAt:d,ptyTail:f,exitedRef:v,staleAt:p,writeSeq:x,termNonce:C,readMode:T,readModeRef:D,setView:ie,openReader:ae,readerCmd:j,fireReader:N,outlineJump:O,setOutlineJump:k,transcriptNonce:A,attach:U,focus:se,refreshTerminal:re,hostAnsweredFor:H,onWelcome:ce,onSessionUpdated:le,onPty:ue,onSessionExit:de,snapshot:fe}}function Oy(e){let t=[];return e.isRepo&&(e.dirty&&t.push(`• uncommitted changes (no commit done)`),!e.isMain&&e.unmerged>0?t.push(`• ${e.unmerged} commit(s) not merged to ${e.mainBranch||`main`}`):!e.isMain&&e.unmergedUnknown&&t.push(`• could not check for unmerged commits (no base branch found to compare with)`)),t}function ky(e,t=1){return`${t>1?`archived ${t} sessions`:`archived ${e}`} — the conversation is kept: reopen it under “Recently closed”, or in Archive`}function Ay(t,n){let{connRef:r,send:i,liveSend:a,liveAsk:o}=t,s=jy(t,Uo,Da,(e,t)=>({t:`session.star`,id:e,starred:t})),c=jy(t,cn,ta,(e,t)=>({t:`session.followup`,id:e,on:t}));function l(e){J(`action:session.close`),e.running?o({t:`session.closecheck`,id:e.id},`no connection — the desktop didn't get that, the session is still open`):(vs(e.id),a({t:`session.remove`,id:e.id},ky(e.title),`no connection — the desktop didn't get that, the session is still listed`))}function u(){let e=n().filter(e=>!e.running&&!$p(e));if(e.length){if(r.current.status!==`open`)X(`no connection — the desktop didn't get that, the sessions are still listed`);else{for(let t of e)i({t:`session.remove`,id:t.id});X(ky(e[0].title,e.length))}}}function d(t){let r=Oy(t);if(t.shells?.length){let n=e(ie(t.shells,Date.now()),t.shells);n&&r.push(`• ${n}`)}let a=n().find(e=>e.id===t.id)?.title??t.branch??`session`;if(r.length===0){vs(t.id),i({t:`session.remove`,id:t.id}),X(ky(a));return}let o=t.branch||`this session`,s=r.map(e=>e.replace(/^• /,``)),c=e=>{vs(t.id),i({t:`session.remove`,id:t.id}),X(e)};sf(`confirmClose`).current?(async()=>{let{ok:e,remember:t}=await rc({title:`Close ${o}?`,lines:s,confirmLabel:`Close anyway`,tone:`warn`});e&&(t?(K(`confirmClose`,!1),c(`won't ask again — Settings › Sessions › ask before closing a session turns it back on`)):c(ky(a)))})():c(`${ky(a)} — left: ${s.join(`; `)}`)}function f(e,t){J(`action:session.star`),s.press(e,t)}function p(e,t){J(`action:session.followup`),c.press(e,t)}function m(e,t){s.settle(e,t),c.settle(e,t)}return{pendingStars:s.pending,toggleStar:f,pendingFollowUps:c.pending,toggleFollowUp:p,settleStars:m,closeSession:l,archivedToast:ky,clearExited:u,onCloseCheck:d}}function jy(e,t,n,r){let{connRef:i,status:a,send:o}=e,[s,c]=(0,Z.useState)(()=>Yd(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),Ls(t,e)}return{pending:s,press(e,t){u({...l.current,[e]:t}),o(r(e,t))},settle(e,t){let r=qr(l.current,e,t,n);r&&u(r)}}}var My=[`default`,`acceptEdits`,`plan`,`auto`],Ny=[`bypassPermissions`,`dontAsk`],Py={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 Fy(e){return Py[e]?.title??e}function Iy(e){return e.liveMode?{mode:e.liveMode,source:`live`}:e.permissionMode?{mode:e.permissionMode,source:`launch`}:{mode:null,source:`unknown`}}function Ly(e,t=`the CLI’s footer`){let n=t===`the CLI’s footer`;return e.source===`live`?`Now: ${Fy(e.mode)}, read ${n?`off`:`from`} ${t}.`:e.source===`launch`?`Launched in ${Fy(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 Ry(e,t,n=!0){let r=My.filter(t=>e.includes(t));for(let i of Ny)e.includes(i)&&(!n||t.liveMode===i||t.permissionMode===i)&&r.push(i);return r.map(e=>Py[e])}function zy(e,t){return t.source===`live`&&t.mode===e?{kind:`none`,say:`already in ${Fy(e)}`}:Ny.includes(e)?{kind:`confirm`}:{kind:`send`}}function By(e){return e.reason?e.reason:e.mode?`now in ${Fy(e.mode)}`:`the desktop switched, but could not read the footer afterwards`}var Vy=12e3;function Hy(e){return`the desktop did not answer the switch to ${Fy(e)} — check the footer in the terminal`}function Uy(e){return e.liveMode&&e.liveMode!=="default"?e.liveMode:null}function Wy(e){return e===!0?`on`:e===!1?`off`:`unknown`}function Gy(e){let t=Wy(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 Ky(e){return`/effort ultracode ${e?`on`:`off`}`}var qy=new Map,Jy=new Set,Yy=()=>{for(let e of Jy)e()};function Xy(e,t){let n=qy.get(e);n&&window.clearTimeout(n.timer);let r=window.setTimeout(()=>{qy.get(e)?.timer===r&&(qy.delete(e),Yy(),X(Hy(t)))},Vy);qy.set(e,{mode:t,timer:r}),Yy()}function Zy(e){let t=qy.get(e.id);t&&(window.clearTimeout(t.timer),qy.delete(e.id),Yy()),X(By(e))}function Qy(e){return(0,Z.useSyncExternalStore)(e=>(Jy.add(e),()=>{Jy.delete(e)}),()=>qy.get(e)?.mode??null)}function $y(e,t){let n=Sp(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(t=>{let{conn:f,term:p,verbs:m,q:h,focusSession:g}=n.current;switch(t.t){case`welcome`:od.noteWelcome(t,e.current.dialUrl),ve(t.prices??null),t.protocol!==2&&X(t.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),f.noteWelcome(t);{let e=ld(t);e&&X(e.announced?`desktop restarted — back${e.downMs==null?``:` after ${el(e.downMs)}`}`:`desktop restarted without warning (crash?)${e.downMs==null?``:` — back after ${el(e.downMs)}`}`)}Xr.pump(),p.onWelcome(t.bootId);break;case`backends`:r(t.list);break;case`host.restarting`:{Af(Date.now(),t.reason);let e=af().usualMs;X(`desktop is restarting${t.reason?` (${t.reason})`:``}${e==null?` — the app cannot reach it until it is back`:` — usually back in ~${el(e)}`}`);break}case`auth.state`:f.setInfo({auth:t.auth});break;case`backlog.ack`:h.onBacklogAck(t);break;case`op.ack`:mi(t.ackId,t.ok,t.filed,rf),h.onOpAck(t);break;case`session.list`:i(t.sessions),m.settleStars(t.sessions,!0),It(t.sessions),Gs(`sessions`);break;case`recent.list`:a(t.recent),ol(G.snapRecent,t.recent);break;case`closed.list`:o(t.closed),ol(G.snapClosed,t.closed);break;case`input.ack`:h.onInputAck(t);break;case`delivery.list`:h.onDeliveryList(t);break;case`delivery.settled`:h.onDeliverySettled(t);break;case`session.created`:i(e=>[...e.filter(e=>e.id!==t.session.id),t.session]),p.buffers.current.set(t.session.id,[]),d.current&&g(t.session.id);break;case`session.focus`:g(t.id);break;case`session.updated`:m.settleStars([t.session],!1),i(e=>{let n=e.map(e=>e.id===t.session.id?t.session:e);return It(n),n}),p.onSessionUpdated(t.session);break;case`pty`:p.onPty(t);break;case`session.exit`:p.onSessionExit(t);break;case`session.closecheck`:m.onCloseCheck(t);break;case`session.history`:p.hostAnsweredFor(t.id),pa(t.id,t.entries);break;case`session.named`:X(t.name?`named “${t.name}”`:t.reason??`no name was written`);break;case`session.moded`:Zy(t);break;case`update.status`:s(t.info),t.info.lastResult&&t.info.lastResult.at>u.current&&(u.current=t.info.lastResult.at,X(t.info.lastResult.ok?`Claude updated`:`Update failed: ${t.info.lastResult.message}`));break;case`budget.state`:h.onBudget(t);break;case`settings.all`:Vc(t.doc);break;case`settings.update`:Iu(t.key,t.value,t.ts);break;case`toast`:X(t.text);break;case`meter.status`:c(t.summary);break;case`intent.list`:l(t.intents);break;case`intent.changed`:l(e=>{let n=e.findIndex(e=>e.id===t.intent.id);if(n<0)return[t.intent,...e];let r=e.slice();return r[n]=t.intent,r});break;case`launch.list`:h.onLaunchList(t);break;case`launch.opened`:h.onLaunchOpened(t);break;case`error`:t.context===`__status`&&f.setStatus(t.message)}}),p=e.current.on(Lv),m=e.current.onBinary(e=>ci().onBinary(e));return()=>{f(),p(),m()}},[])}var eb=`theme.textScale.iconScale.termZoom.readerZoom.scrollZoom.gitZoom.textDumpWrap.readerTableWrap.sessionTabs.sessionTabsCount.sessionTabsOrder.sessionTabsLimit.sessionTabsSync.netPulse.localRtBar.unfoldToEnd.typingRoom.closeKbOnSend.shortcutCard.busySend.btwToCli.toolbarOpen.readMode.cliMode.termCostOpen.termCornerPos.hintChip.annHintHidden`.split(`.`),tb=[G.outbox,G.pad,G.compose,G.fileRemarks,G.padRescue,G.padRescueMigrated,G.giveups,G.giveupsMigrated,G.syncTs,G.hosts,G.hostActive,G.hostSwitch,G.hostsGone,Me,G.tokenSeal,G.tokenSealOn,G.tokenSealDead,G.tokenSealAuth,G.appLock,G.appLockBlob,xt,...Ye,G.brandMigrated,G.brandStores];async function nb(){try{for(let e of Object.keys(localStorage))tb.some(t=>e.startsWith(t))||localStorage.removeItem(e)}catch{}try{let e=await caches.keys();await Promise.all(e.filter(e=>!zr.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 rb({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:[Sd(),` 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:()=>{nb()},children:`Reset caches & reload`})]}),(0,Q.jsx)(`p`,{children:`Queued text and prompt-pad drafts are kept by the reset.`})]})}var ib=class extends Z.Component{state={err:null};static getDerivedStateFromError(e){return{err:e}}componentDidCatch(e,t){console.error(`${ke} render failed`,e,t.componentStack)}render(){return this.state.err?(0,Q.jsx)(rb,{err:this.state.err}):this.props.children}};function ab(){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=`${Sd()} 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=()=>{nb()},i.append(a,o),n.append(i),t.append(n)},4e3)}var ob=class extends Z.Component{state={err:!1};static getDerivedStateFromError(){return{err:!0}}componentDidCatch(e,t){console.error(`${ke} 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}},sb=Vt(Qn,Hi);function cb(e,t){return sb.rows(e,t).map(e=>(0,Z.createElement)(Z.Fragment,{key:e.key},e.node))}var lb=new Set([`dontAsk`,`bypassPermissions`]),ub=[`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.`],db=[{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 fb(){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),J(`action:spendWarn.set`),K(`spendWarn`,he(s))):i(`Red has to be above orange — kept what was there.`)},o=[`warnPct`,`highPct`,`warnUsd`,`highUsd`].every(t=>e[t]===T[t]);return(0,Q.jsxs)(Ws,{id:`spend-warn`,label:`spend marks`,icon:Ch,on:e.on,onChange:()=>{J(`action:spendWarn.toggle`),K(`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: `,T.warnPct,`% / `,T.highPct,`% of week, $`,T.warnUsd,` / $`,T.highUsd,`.`]})]}),children:[e.on&&db.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 pb=(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},mb=(e,t)=>{let n=pb(e,t.cwd);return n?pt(n):Tp(t.cwd)},hb=(e,t)=>{let n=pb(e,t.cwd);return n?r(n):Tp(t.cwd)},gb=(e,t)=>{let n=e.find(e=>pt(e)===t);return n?r(n):t},_b=(e,t)=>{let n=pb(e,t.cwd);return n?`${pt(n)} · ${n.branch}`:Tp(t.cwd)},vb=(e,t)=>{let n=pb(e,t.cwd);return n?Ge(n):Tp(t.cwd)},yb=(e,t)=>vb(e,t)||(t.tabTitle??``).trim()||hb(e,t),bb=e=>`${e.status===`pending`?`opening…`:`queued`} ${e.n}`,xb=e=>`${e.n>1?`${e.n} sessions `:``}${e.status===`pending`?`opening — waiting for the desktop to confirm`:`queued — opens when the link is back`}`,Sb=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`,Cb=e=>e&&e.issues>0?`repo readings · ${e.issues}`:`repo readings`,wb=e=>e&&e.issues>0?Sb(e):`open this repo's readings`;function Tb(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 V([...a.values()].flat())}function Eb(e,t,n){let r=new Set(t),i=e.filter(e=>n.has(e)&&!r.has(e));return[...t,...i]}function Db(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 Ob(e,t,n,r){return t?e.filter(e=>n(e,t.status)&&(!t.repo||r(e)===t.repo)):e}function kb(e,t,n){let r=new Map;for(let i of e){let e=n(i),a=r.get(e)??{wait:0,blocked:0,coding:0,done:0,exited:0};a[t(i)]++,r.set(e,a)}return r}var Ab=(e,t)=>[...e.values()].reduce((e,n)=>e+n[t],0);function jb(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 Mb(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 Nb=[`name`,`sessions`],Pb={name:`alphabetical`,sessions:`most open sessions first`};function Fb(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 Ib(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){let t=pt(e);n&&!i.includes(t)||o.has(t)||(o.set(t,[]),s.push(t))}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 Lb(e){return e===`rows`?null:e===`unread`?`Waiting for the desktop's repo list.`:`No repos under host root.`}function Rb(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`||ze(e)||e.cwd&&a(e.cwd,Oo(e.id));return i}function zb(e,t,n){let r=t.filter(e=>!e.archived&&(e.groupId==null||e.groupId===e.id)&&Si(e.state,e.blockReason??null)===`needsYou`),i=new Set(t.filter(e=>!e.archived&&(e.state===`queued`||e.state===`blocked`||e.state===`starting`)).map(e=>e.id));return[...e.filter(e=>(e.status===`queued`||e.status===`failed`)&&!i.has(e.ackId)).map(e=>hr(e.ackId)),...r.map(e=>Oo(e.id))].filter(e=>!n.has(e))}function Bb(e,t){let n=new Set(e),r=t.filter(e=>n.has(Oo(e.id))),i=new Set(r.map(e=>e.cwd));return r.length===e.length&&i.size===1&&r[0].cwd&&r.every(je)?{kind:`backlog`,cwd:r[0].cwd,ids:r.map(e=>e.id)}:{kind:`activity`}}var Vb=e=>!!e.starred||_r(e);function Hb(e,t,n,r){let i=t?e.filter(e=>r(e)===t):[...e];return n?i.filter(e=>!Vb(e)):i}function Ub(e,t,n){let r=(t?e.filter(e=>n(e)===t):e).filter(Vb);return{n:r.length,starred:r.filter(e=>e.starred).length,flagged:r.filter(_r).length}}function Wb(e,t,n,r){return n?Ub(e,t,r).n:0}function Gb(e){let t=e.starred&&e.flagged?`starred & flagged`:e.flagged?`flagged`:`starred`;return`${e.n} ${t}`}function Kb(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))}var qb=1500,Jb=e=>`${Math.max(1,Math.round(e/1e6))} MB`,Yb={engine:`Installing whisper-cpp on the desktop`,disk:`Checking the desktop has room`,download:`Downloading the model`,verify:`Checking the download`};function Xb(e){return e.step===`download`&&e.bytesTotal>0?`${Yb.download}: ${Jb(e.bytesDone)} of ${Jb(e.bytesTotal)}`:`${Yb[e.step]??`Setting up`}…`}function Zb(e){return[`Downloads the ${e.id} model (${Jb(e.bytes)}) to the desktop.`,`If whisper-cpp is missing, it also runs brew install whisper-cpp there.`,`Dictation then runs on the desktop instead of the phone's recogniser.`]}function Qb({id:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(!0),u=(0,Z.useRef)(!1),d=(0,Z.useRef)(void 0),f=(0,Z.useCallback)(async()=>{let e=await va.dictateStatus();return l.current&&n(e),e},[]),p=(0,Z.useCallback)(async()=>{let e=await va.dictateSetupState();l.current&&(i(e),e?.state===`running`&&(u.current=!0),e?.state===`running`||e===null&&u.current?d.current=setTimeout(()=>void p(),qb):(u.current=!1,e?.state===`done`&&(await f()).available&&Ur()))},[f]);(0,Z.useEffect)(()=>(l.current=!0,u.current=!1,f().then(e=>{!e.available&&e.canSetup&&p()}),()=>{l.current=!1,d.current&&clearTimeout(d.current)}),[f,p]);let m=t?.models??[],h=m.find(e=>e.id===a)??m.find(e=>e.recommended)??m[0],g=async()=>{if(!h||s)return;if(c(!0),!await Xl({title:`Set up local dictation on this desktop?`,lines:Zb(h),confirmLabel:`Set up`,tone:`info`})){c(!1);return}J(`action:voice.localSetup`);let e=await va.dictateSetupStart(h.id);l.current&&c(!1),e.ok?(X(`Setting up local dictation on the desktop.`),p()):(X(`Setup did not start: ${e.error}`),p())},_=`local dictation`;return t?t.available?(0,Q.jsx)(Dc,{id:e,label:_,icon:kh,note:`The microphone uses ${t.engine??`the desktop's whisper`}${t.model?` with ${t.model}`:``}.`}):t.canSetup?r?.state===`running`?(0,Q.jsx)(Dc,{id:e,label:_,icon:kh,note:Xb(r),children:r.step===`download`&&r.bytesTotal>0&&(0,Q.jsx)(`progress`,{max:r.bytesTotal,value:r.bytesDone,style:{width:`100%`}})}):(0,Q.jsxs)(Dc,{id:e,label:_,icon:kh,note:`The microphone is using the phone's own recogniser, which is weaker on code words and mixed languages. The desktop can run whisper instead.`,children:[r?.state===`failed`&&(0,Q.jsx)($f,{children:r.reason}),r?.state===`done`&&(0,Q.jsx)($f,{children:t.reason??`The setup finished, but the desktop still cannot transcribe.`}),(0,Q.jsx)(`div`,{className:`set-chips`,children:m.map(e=>(0,Q.jsxs)(Y,{className:h?.id===e.id?`active`:``,onClick:()=>o(e.id),children:[e.id,` · `,Jb(e.bytes),e.recommended?` · recommended`:``]},e.id))}),h&&(0,Q.jsxs)(dl,{children:[h.note,h.installed?` Already downloaded.`:``]}),(0,Q.jsx)(Y,{variant:`primary`,onClick:()=>{s||g()},children:s?`Starting…`:r?.state===`failed`?`Try again`:`Set up on this desktop`})]}):(0,Q.jsx)(Dc,{id:e,label:_,icon:kh,children:(0,Q.jsx)($f,{tone:`plain`,children:t.reason??`The desktop cannot transcribe yet.`})}):(0,Q.jsx)(Dc,{id:e,label:_,icon:kh,note:`Asking the desktop…`})}async function $b(e){if(!xa())return;Et(G.tabsSaverAsked,`1`);let t=await nf({title:`Stop sharing tab order while ${yc[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?(K(`tabsSync`,!1),eu.reload(`tabsSort`),X(`tab order kept on this device — Settings › Appearance shares it again`)):X(`tab order still shared`))}var ex=()=>navigator.connection;async function tx(){let e=qt({app:ds(),phoneData:!!ex()?.saveData,battery:await Pa()});e?ca(e,xa(),Dt(G.tabsSaverAsked)===`1`)&&$b(e):vt(G.tabsSaverAsked)}var nx=!1;function rx(){if(!(nx||typeof document>`u`)){nx=!0,setTimeout(()=>{tx()},4e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&tx()});try{ex()?.addEventListener(`change`,()=>{tx()})}catch{}}}var ix=()=>{let e=qi();return e&&Pi(e)||`-`},ax=16;function ox(){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=Ks(r,-1,t),h=Ks(r,1,t),g=e=>{K(`tabsN`,e),X(`${e} tabs across the strip`)},_=e=>{K(`tabsMax`,e),X(`at most ${e} session tabs`)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(gf,{id:`theme`,radio:!0,label:`theme`,icon:dm,value:e,options:[[`system`,`follow device`,dm],[`light`,`light`,eg],[`dark`,`dark`,gh]].map(([e,t,n])=>({value:e,label:t,icon:n})),onChange:e=>{K(`theme`,e),X(`theme: ${e===`system`?`following this device (${Or()})`:e}`)},note:e===`system`?`Following this device — it is ${Or()} 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)(gf,{id:`text-size`,label:`text size`,icon:Vh,value:t,options:zl.map(e=>({value:e.value,label:e.label,icon:Vh,style:{fontSize:`${Math.round(14*e.value)}px`}})),onChange:e=>{J(`action:uiscale.text`),K(`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)(gf,{id:`icon-size`,label:`icon size`,icon:mm,value:n,options:Xu.map(e=>({value:e.value,label:e.label})),onChange:e=>{J(`action:uiscale.icon`),K(`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)(wl,{id:`terminal-zoom`,label:`terminal size`,icon:qm,readout:(0,Q.jsxs)(Q.Fragment,{children:[zp(t,r),`px`,m==null?` · smallest`:h==null?` · biggest`:``]}),onLess:m==null?null:()=>dd(m),onMore:h==null?null:()=>dd(h),lessLabel:`smaller`,moreLabel:`bigger`,extra:r!==1&&(0,Q.jsxs)(Y,{onClick:()=>dd(1),title:`back to the text size on its own — ${zp(t,1)}px`,children:[(0,Q.jsx)(qh,{size:ax}),` 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)(bd,{id:`repo-colours`,label:`repo colours`,icon:Lg,opens:!0,onClick:()=>{J(`action:repocolor.open`),Hi().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)(Ws,{id:`tabs`,label:`session tabs`,icon:Gm,on:i,onChange:()=>{let e=!i;K(`tabsOn`,e),J(`action:sessiontabs.${e?`on`:`off`}`),X(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)(wl,{id:`tabs-count`,label:`tabs that fit`,icon:Gm,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)(wl,{id:`tabs-limit`,label:`most tabs shown`,icon:Gm,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)(gf,{id:`tabs-order`,radio:!0,label:`tab order`,icon:Gm,value:o,options:yn.map(e=>({value:e,label:gp[e]})),onChange:e=>{K(`tabsSort`,e),J(`action:sessiontabs.order.${e}`),X(`session tabs: ${gp[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)(Ws,{id:`tabs-sync`,label:`same tab order on every device`,icon:Gm,on:c,onChange:()=>{let e=!c;K(`tabsSync`,e),eu.reload(`tabsSort`),J(`action:sessiontabs.sync.${e?`on`:`off`}`),X(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)(gf,{id:`repo-order`,radio:!0,label:`repo order`,icon:zh,value:d,options:Nb.map(e=>({value:e,label:Pb[e]})),onChange:e=>{K(`repoSort`,e),J(`action:reposort.${e}`),X(`repos: ${Pb[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)(Ws,{id:`unfold-to-end`,label:`unfolding a repo shows its last row`,icon:og,on:u,onChange:()=>{let e=!u;K(`unfoldToEnd`,e),J(`action:unfoldtoend.${e?`on`:`off`}`),X(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)(Ws,{id:`net-pulse`,label:`connection strip`,icon:yg,on:l,onChange:()=>{let e=!l;K(`netPulse`,e),J(`action:netpulse.${e?`on`:`off`}`),X(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)(gf,{id:`local-rt`,radio:!0,label:`desktop strip`,icon:Am,value:f,options:ir.map(e=>({value:e,label:Vr[e]})),onChange:e=>{K(`localRtBar`,e),J(`action:localrt.${e}`),X(e===`off`?`desktop strip off`:`desktop strip: ${Vr[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)(lx,{id:`agent-warn`,label:`warn above this many agents`,icon:Wm,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)(lx,{id:`agent-alarm`,label:`alarm above this many agents`,icon:Om,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)(bd,{id:`ui-reset`,label:`reset UI settings to default`,icon:qh,onClick:()=>{(async()=>{if(await Xl({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 device.`,`Drafts, queued prompts, header commands, pins and everything synced stay as they are.`],confirmLabel:`Reset and reload`})){J(`action:settings.uiReset`);for(let e of eb)vt(G[e]);location.reload()}})()},note:`Everything about how this device draws the app, back to how it shipped. Your words and synced choices are kept.`})]})}function sx({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=Fl(),l=q(`btwToCli`),u=q(`busySend`),d=q(`toolsMode`),f=q(`hints`),p=q(`hintChip`),m=Xe(r,n,Qu()),h=Ce(i),g=Be(i);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(gf,{id:`enter-sends`,radio:!0,label:`the Return key`,icon:Im,value:t?`send`:`newline`,options:[{value:`send`,label:`sends`},{value:`newline`,label:`inserts a newline`}],onChange:e=>K(`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)(gf,{id:`dictate-lang`,radio:!0,label:`dictation is read as`,icon:Tm,value:n,options:m.map(e=>({value:e.code,label:e.code===`auto`?`auto`:e.label,title:qe(e.code)})),onChange:e=>{J(`action:voice.lang`),K(`dictLang`,e)},note:qe(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 device 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)(Bc,{id:`dictate-langs`,label:`languages on the microphone`,icon:Tm,value:m.map(e=>e.code),options:Ae(Qu()).map(e=>({value:e.code,label:e.code===`auto`?`auto`:e.label})),onChange:e=>{J(`action:voice.langs`),K(`dictLangCodes`,e)},note:`The picker beside the microphone lists these — ${m.length} of ${Ae(Qu()).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.`})]})}),(0,Q.jsx)(Qb,{id:`dictate-local`},ix()),e.supported&&(0,Q.jsx)(Dc,{id:`dictate-terms`,label:`words dictation should know`,icon:Fg,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 device 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=>K(`dictTerms`,e.target.value)})}),(0,Q.jsx)(Ws,{id:`close-kb-on-send`,label:`close the keyboard after Send`,icon:Mm,on:o,onChange:()=>K(`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)(Ws,{id:`shortcut-card`,label:`hold Ctrl to see shortcuts`,icon:yh,on:s,onChange:()=>K(`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)(gf,{id:`busy-send`,radio:!0,label:`Send while it works`,icon:lh,value:u,options:[{value:``,label:`ask`},{value:`now`,label:`send now`},{value:`idle`,label:`when it's free`}],onChange:e=>K(`busySend`,e),note:u===`now`?`Send on a session that is still working hands the words to claude, which takes them at its next pause.`: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)(gf,{id:`btw-to-cli`,radio:!0,label:`/btw from the reader`,icon:qm,value:l,options:[{value:``,label:`ask`},{value:`switch`,label:`switch to the CLI`},{value:`stay`,label:`stay`}],onChange:e=>K(`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)(Ws,{id:`typing-room`,label:`typing room`,icon:Nh,on:a,onChange:()=>K(`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)(gf,{id:`reader-tools`,radio:!0,label:`tool calls in the reader`,icon:jm,value:d,options:[[`fold`,`fold runs`],[`list`,`one row each`],[`full`,`download details`]].map(([e,t])=>({value:e,label:t})),onChange:e=>K(`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)(gf,{id:`hints-mode`,radio:!0,label:`button hints`,icon:bg,value:f.mode,options:[[`first`,`explain once`],[`press`,`long-press only`],[`off`,`off`]].map(([e,t])=>({value:e,label:t})),onChange:e=>K(`hints`,{mode:e,seen:Ol()}),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)(bd,{id:`hints-explain`,label:`explain mode`,icon:bg,onClick:()=>{Vp(!0),Hi().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)(Ws,{id:`hints-chip`,label:`? button in the headers`,icon:bg,on:p!==`hidden`,onChange:()=>K(`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)(bd,{id:`hints-reset`,label:`explain them again`,icon:qh,cant:f.seen===0?`nothing has been dismissed yet`:void 0,onClick:()=>{rp(),eu.reload(`hints`),X(`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 cx({install:e,reconnect:t}){let n=rd(),r=q(`autoSend`),i=q(`serialSessions`),a=q(`confirmQueue`),o=q(`saver`),s=q(`bgFresh`),c=Hi().queue.entries.filter(e=>e.status===`queued`);return(0,Q.jsxs)(Q.Fragment,{children:[e.installed?(0,Q.jsx)(Dc,{id:`install`,label:`install this app`,icon:Sm,note:`Running as an installed app.`}):n===`insecure`?(0,Q.jsx)(Dc,{id:`install`,label:`install this app`,icon:uh,children:(0,Q.jsxs)($f,{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)(bd,{id:`install`,label:`install this app`,icon:uh,onClick:async()=>{J(`action:install.app`);let t=e.evt.current;if(!t)X(`install offer expired — reload and try again`);else{e.evt.current=null,e.taken();try{t.prompt(),await t.userChoice}catch{X(`install cancelled`)}}},note:`Adds it to your home screen and runs it full-screen, without browser chrome.`}):Sl()?(0,Q.jsx)(Dc,{id:`install`,label:`install this app`,icon:uh,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)(Dc,{id:`install`,label:`install this app`,icon:uh,note:`No install offer from this browser right now — it may already be installed, or the browser needs another visit first.`}),(0,Q.jsx)(Ws,{id:`auto-send`,label:`auto-send the queue`,icon:Zh,on:r,onChange:()=>{K(`autoSend`,!r),X(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)(Ws,{id:`serial-sessions`,label:`one session at a time per repo`,icon:Ym,on:i,onChange:()=>{K(`serialSessions`,!i),X(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)(Ws,{id:`confirm-queue`,label:`ask on reconnect`,icon:oh,on:a,onChange:()=>{a&&(t.holdRef.current=!1,t.setReconnectAsk(!1),t.flush()),K(`confirmQueue`,!a),X(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)(bd,{id:`queue-manage`,label:`manage ${c.length} queued`,icon:Ym,opens:!0,onClick:()=>{J(`action:queue.manage`),Hi().nav.open(`queue`)}}),(0,Q.jsx)(Ws,{id:`data-saver`,label:`data saver`,icon:oh,on:o,onChange:()=>{let e=!o;K(`saver`,e),J(`action:datasaver`),X(e?`data saver on — smaller images, slower polling`:`data saver off`),e&&$b(`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)(Ll,{id:`bg-fresh`,label:`in the background`,icon:dh,min:0,max:ko.length-1,step:1,value:Math.max(0,ko.indexOf(s)),readout:gr(s),onInput:e=>K(`bgFresh`,ko[e]??s),onCommit:()=>J(`action:bgfresh`),note:di(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 lx({id:e,label:t,icon:n,cfg:r,k:i,note:a,more:o}){let s=[...bf,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=>{J(`action:agentWarn.${i}`),K(`agentWarn`,{...r,[i]:e})};return(0,Q.jsx)(wl,{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 ux=Mu(``),dx=0,fx=Mu(``);function px(e){let t=$t(ux),n=yr(),r=$t(Mo),i=e.pluginView?r:null,a=i??n,o=e.pluginView?`pluginSettings`:`settings`;(0,Z.useEffect)(()=>(dx++,()=>{dx--,queueMicrotask(()=>{dx===0&&(ns.set(null),Mo.set(null))})}),[]);let s=Hi(),{status:c}=s.conn,{tailscaleIp:l}=s.conn.info,u=hc(t,a);return(0,Q.jsxs)(`div`,{className:`sheet`,children:[(0,Q.jsx)(nd,{title:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wg,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),` Settings`]}),onClose:()=>s.nav.close(o),children:(0,Q.jsxs)(`div`,{className:`conn conn-${c}`,children:[c,l?` · ${l}`:``]})}),(0,Q.jsx)(Bn,{keys:P,thing:`your settings`}),(0,Q.jsx)(`div`,{className:`set-doors set-doors-top`,children:(0,Q.jsxs)(`button`,{className:`set-door`,title:`Every plugin: on or off, what it does, where it shows up`,onClick:()=>s.nav.open(`pluginManager`),children:[(0,Q.jsx)(Cm,{size:14}),` Plugins`]})}),(0,Q.jsx)(Ju,{value:t,onChange:e=>{ns.set(null),Mo.set(null),ux.set(e)}}),(0,Q.jsx)(Lp,{value:u,children:(0,Q.jsxs)(`div`,{className:`settings`,children:[(0,Q.jsxs)(Bf,{id:`sessions`,title:`Sessions`,icon:Wm,children:[cb(`sessions`,{to:0}),(0,Q.jsx)(mx,{pickBackend:e.pickBackend}),cb(`sessions`,{from:0})]}),(0,Q.jsx)(Bf,{id:`notifications`,title:`Notifications`,icon:eh,children:cb(`notifications`)}),(0,Q.jsxs)(Bf,{id:`appearance`,title:`Appearance`,icon:dm,children:[cb(`appearance`,{to:0}),(0,Q.jsx)(ox,{}),cb(`appearance`,{from:0})]}),(0,Q.jsxs)(Bf,{id:`writing`,title:`Writing & reading`,icon:Im,children:[cb(`writing`,{to:0}),(0,Q.jsx)(sx,{voice:e.voice}),cb(`writing`,{from:0})]}),(0,Q.jsxs)(Bf,{id:`offline`,title:`Offline & data`,icon:uh,children:[cb(`offline`,{to:0}),(0,Q.jsx)(cx,{install:e.install,reconnect:e.reconnect}),cb(`offline`,{from:0})]}),(0,Q.jsxs)(Bf,{id:`connection`,title:`Connection`,icon:Xm,children:[cb(`connection`,{to:0}),(0,Q.jsx)(hx,{redial:e.redial}),cb(`connection`,{from:0})]}),(0,Q.jsxs)(Bf,{id:`tools`,title:`Tools & diagnostics`,icon:Fh,children:[cb(`tools`,{to:-10}),(0,Q.jsxs)(`div`,{className:`set-doors`,children:[cb(`tools`,{from:-10,to:0}),(0,Q.jsx)(gx,{})]}),cb(`tools`,{from:0})]}),(0,Q.jsx)(Fu,{tally:u,onClear:()=>{i?s.nav.close(o):(ns.set(null),ux.set(``))}})]})})]})}function mx({pickBackend:e}){let t=Hi(),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:[zs(n)&&(0,Q.jsxs)(Md,{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:Mp(n).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:In(e)},e.id))}),note:(0,Q.jsxs)(Q.Fragment,{children:[`What a new session runs.`,Qc(n,r.backend)?` ${Qc(n,r.backend)}.`:``,Cn(n,r.backend)?` ${Cn(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:[fa(n,r.backend)&&(0,Q.jsx)(dl,{className:`act-cants`,children:(0,Q.jsx)(iu,{children:fa(n,r.backend)})}),(0,Q.jsx)(uc,{className:`set-note`,cants:[[`context meter`,`contextMeter`],[`transcript`,`transcript`],[`slash commands`,`slash`],[`effort`,`effort`],[`remote control`,`remoteControl`]].flatMap(([e,t])=>{let i=Au(n,r.backend,t);return i?[{label:e,reason:i}]:[]})})]}),(0,Q.jsx)(Md,{id:`launch-model`,label:`model`,control:(0,Q.jsx)(bn,{backends:n,backend:r.backend,value:r.model,onChange:e=>i({model:e})})}),Bi(n,r.backend).length===0&&Au(n,r.backend,`effort`)&&(0,Q.jsx)(dl,{children:Au(n,r.backend,`effort`)}),Bi(n,r.backend).length>0&&(0,Q.jsx)(Md,{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`}),Bi(n,r.backend).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})}),Ja(n,r.backend).length>0&&(0,Q.jsxs)(Md,{id:`launch-permission`,label:`permission`,control:(0,Q.jsxs)(`select`,{className:r.permissionMode&&lb.has(r.permissionMode)?`danger`:``,value:r.permissionMode??``,onChange:e=>{let t=e.target.value||void 0;!t||!lb.has(t)?i({permissionMode:t}):(e.target.value=r.permissionMode??``,(async()=>{await Xl({title:t,lines:ub,confirmLabel:`Run without asking`})&&i({permissionMode:t})})())},children:[(0,Q.jsx)(`option`,{value:``,children:`default`}),Ja(n,r.backend).map(e=>(0,Q.jsxs)(`option`,{value:e,children:[e,lb.has(e)?` — no approvals`:``]},e))]}),children:[r.permissionMode&&lb.has(r.permissionMode)&&(0,Q.jsxs)(dl,{className:`danger-note`,children:[(0,Q.jsx)(Zm,{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`})]}),nm(r,n)&&(0,Q.jsx)($f,{tone:`plain`,children:nm(r,n)})]}),Ta(n,r.backend,`remoteControl`)&&(0,Q.jsx)(Ws,{id:`launch-remote`,label:`remote control`,icon:oh,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)(Ws,{id:`launch-ask`,label:`ask before each launch`,icon:bg,on:a,onChange:()=>{J(`action:launchAsk.toggle`),K(`launchAsk`,!a)},note:(0,Q.jsxs)(Q.Fragment,{children:[`On, starting a new session asks `,zs(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)(fb,{}),(0,Q.jsx)(Ws,{id:`confirm-close`,label:`ask before closing a session`,icon:th,on:s,onChange:()=>{J(`action:confirmClose.toggle`),K(`confirmClose`,!s),X(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)(bd,{id:`automation`,label:Td.automation,icon:tg,opens:!0,onClick:()=>{J(`overlay:schedule`),vc(null)},note:`Prompts that run on their own: on a clock, every week, or around a usage window.`}),(0,Q.jsx)(Ws,{id:`close-when-done`,label:`close automatic sessions when done`,icon:Ig,on:o,onChange:()=>{J(`action:closeWhenDone.toggle`),K(`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 `,et.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:Ke(`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)(gf,{id:`local-sessions`,label:`local model sessions at once`,icon:Am,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=>{J(`action:localSessions.set`),K(`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:Ke(`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)(bd,{id:`hosted-notice`,label:`show the hosted-model notice again`,icon:qh,onClick:()=>{J(`action:hostedAck.reset`),ev(),X(`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 hx({redial:e}){let t=Hi(),n=t.conn.info.auth,r=t.conn.status,i=$t(fx);return(0,Q.jsxs)(Q.Fragment,{children:[n.canManage?(0,Q.jsx)(Dc,{id:`lan-password`,label:`LAN password`,icon:Pg,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 (${Ke(`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=>fx.set(e.target.value),style:{maxWidth:220}}),i.length>=4?(0,Q.jsx)(Y,{variant:`primary`,onClick:()=>{t.conn.send({t:`auth.set`,password:i}),fx.set(``),X(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)(Y,{variant:`danger`,onClick:()=>{t.conn.send({t:`auth.clear`}),X(`password cleared — LAN blocked`)},children:`clear`})]})}):(0,Q.jsx)(bd,{id:`lan-logout`,label:`log out this device`,icon:Pg,onClick:async()=>{await va.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)(Ws,{id:`lan-gate-tailscale`,label:`gate Tailscale too`,icon:Pg,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)(bd,{id:`sync-push`,label:`use this device's copy`,icon:Qm,cant:r===`open`?void 0:`no connection to the host right now`,onClick:()=>{let e=Yu();X(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 gx(){let e=Hi().nav.open;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bd,{id:`tool-net-health`,compact:!0,label:`connection health`,icon:yg,title:`what the link has been doing to your prompts`,onClick:()=>{J(`overlay:nethealth`),e(`nethealth`)}}),(0,Q.jsx)(bd,{id:`tool-storage`,compact:!0,label:`storage`,icon:pg,title:`what this device is holding, and what clearing any of it would cost`,onClick:()=>{J(`overlay:storage`),e(`storage`)}}),(0,Q.jsx)(bd,{id:`tool-speedtest`,compact:!0,label:`speed test`,icon:Ah,title:`connection speed test + diagnostics`,onClick:()=>e(`speedtest`)}),(0,Q.jsx)(bd,{id:`tool-host-stat`,compact:!0,label:`host stat`,icon:Am,title:`host CPU / memory load`,onClick:()=>void Bd()}),(0,Q.jsx)(bd,{id:`tool-repo-setup`,compact:!0,label:`repo setup`,icon:ng,title:`repo setup checklist`,onClick:()=>e(`setup`)}),(0,Q.jsx)(bd,{id:`tool-secret`,compact:!0,label:`secret`,icon:Rm,title:`set a secret (write-only)`,onClick:()=>e(`secret`)}),(0,Q.jsx)(bd,{id:`tool-features`,compact:!0,label:`feature usage`,icon:ym,title:`which features you actually use (and which you never do)`,onClick:()=>e(`features`)})]})}function _x(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)(Gc,{seed:a,sessions:r&&!l_(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?()=>{J(`action:send.discard`),a.ackId&&i(a.ackId),a.padId&&rf([a.padId]),Pr(_l),X(`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 vx=su(Qn);xl(e=>vx.sheets.get(lp(e))?.keep?.()??null),Vd((e,t)=>vx.leave(e,t));var yx=new Map;for(let[e,t]of vx.sheets){let n=/^feature:([^/]+)\//.exec(e);if(!n)continue;let r=()=>t.render(Hi());yx.set(e,()=>(0,Z.createElement)(ll,{feature:n[1],what:`its sheet`,children:(0,Z.createElement)(r)}))}function bx(){let e={};for(let[t,n]of vx.sheets)e[t]=yx.get(t)??(()=>n.render(Hi()));return e}function xx(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:ee,gitRepoId:j,activeRepoId:M,repos:N,reposAt:te,backends:P}=e,F=(e,t)=>{n(null),X(`${e} failed to open — ${t}`)},I=e=>(0,Q.jsx)(px,{pluginView:e,pickBackend:C,voice:D,install:{installed:O,canInstall:k,evt:A,taken:()=>ee(!1)},reconnect:{holdRef:c,setReconnectAsk:o,flush:l},redial:()=>i.current.reconnect()}),L={...bx(),...x.sheets,slash:()=>h?(0,Q.jsx)(pc,{cwd:h.cwd,backends:P,backend:rs(P,bp(h))?bp(h):void 0,onClose:()=>n(null),unsupported:rs(P,bp(h))?void 0:S(h,`slash`)??void 0,onPick:(e,t)=>{t?(n(null),s(h.id,h.cwd,e,`command`)&&X(i.current.status===`open`?`running ${e}`:`${e} queued — it runs when the link is back`)):(f(e),n(null))}}):null,settings:()=>I(!1),pluginSettings:()=>I(!0),git:()=>{let e=qp(),t=Ya(j,e,M,N);if(!t)return(0,Q.jsx)(Zf,{focus:e,list:Tr({rows:N,readAt:te}),session:!!h,onClose:()=>n(null)});let r=N.find(e=>e.id===t);return(0,Q.jsx)(Fp,{repoId:t,onAskAgent:r?e=>T.openSend(ga(e,r)):void 0,stored:r?.gitFailed,failures:r?.gitFailures,onDone:lr,onBrowse:()=>oo(t,`git`),fileSheet:r?(e,n)=>(0,Q.jsx)(md,{repoId:t,repoName:r.repoName,path:e.path,edit:e.edit,onClose:n}):void 0,onClose:()=>{n(null),w()}})},outline:()=>h?(0,Q.jsx)(Cc,{sessionId:h.id,title:h.title,onJump:e=>{J(`action:outline.jump`),p({n:e,key:Date.now()}),m(!0),n(null)},onClose:()=>n(null)}):null,send:()=>E?(0,Q.jsx)(_x,{send:T,sessions:g,pendingSession:d,visibleRepos:_,outbox:v,online:a===`open`,usage:y,intents:b,removeQueued:u,backends:P,launch:x.launch,closeSheet:r,onAttach:(e,t)=>Rd(t,e),onAnnotate:(e,t)=>Hu(t,e,`send`),onBrowseRepoFiles:yp}):null},R=t?L[t]?.()??null:null;return R?(0,Q.jsx)(ob,{name:t??``,onFail:F,children:R},t??``):null}function Sx(e){let{connRef:t,setLaunch:n,setHiddenRepoIds:r}=e;(0,Z.useEffect)(()=>(Vf(e=>t.current.send(e)),Nd(e=>{switch(e){case G.launch:n(pi());break;case G.hiddenRepos:r(vr());break;case G.repoColors:yo()}})),[])}function Cx(e){let{repos:t,focusRepo:n,outbox:r,bl:i}=e,[a,o]=(0,Z.useState)(vr),s=(0,Z.useMemo)(()=>la(t.filter(e=>!a.has(e.id)&&(!n||pt(e)===n))),[t,a,n]),c=(0,Z.useMemo)(()=>la(t.filter(e=>a.has(e.id)&&(!n||pt(e)===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(!Sr(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=>pt(e)===n).map(e=>e.worktreePath)):null,[t,n]),f=e=>!d||d.has(e)||Tp(e)===n,p=(0,Z.useCallback)(e=>!l.has(e)&&(!d||d.has(e)||Tp(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),ht(G.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 wx(e,t){let{setOverlay:n,activeRepoId:r,active:i,readMode:a,fireReader:o,send:s,geomRef:c}=t,l=e=>Tx(e,t);switch(J(`toolbar:${e}`),e){case`model`:n(`model`);break;case`cmd`:n(`slash`);break;case`diff`:dn(r,n)||X(`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`:ms(i?.cwd);break;case`history`:n(`history`);break;case`outline`:if(!i){X(`no active session`);break}a?o(`outline`):n(`outline`);break;case`find`:if(!i){X(`no active session`);break}a?o(`find`):ju(i.id);break;case`refresh`:if(!i){X(`no active session`);break}a?o(`refresh`):X(`refresh is the reader's — the terminal is live`);break;case`scrollback`:co();break;case`fork`:if(!i)break;s({t:`session.fork`,id:i.id,cols:c.current.cols,rows:c.current.rows}),X(`forking conversation into a new session…`);break;case`companion`:if(!i){X(`no active session`);break}t.openCompanionShell(i);break;default:Rv(e)}}function Tx(e,t){let{active:n,submitInput:r}=t;n&&(J(`action:slash:${e.split(/\s/)[0].replace(/[^a-zA-Z0-9-]/g,``)||`other`}`),r(n.id,n.cwd,e,`command`))}var Ex=1e4;function Dx(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,Ex);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 Ox(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]);let f=(0,Z.useRef)(d);(0,Z.useEffect)(()=>{let e=f.current;f.current=d,e&&!d&&!r&&n()},[d]),Dx({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 kx(){let e=(0,Z.useRef)(null),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(()=>Hs());return(0,Z.useEffect)(()=>{let t=t=>{t.preventDefault(),e.current=t,n(!0)},r=()=>{e.current=null,n(!1),i(!0),X(`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 Ax(e,t,n,r=null){let i=sn(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)(Qh,{size:11,fill:`currentColor`}),` `,a]}):a;if(!t)return(0,Q.jsx)(Jc,{className:o,title:s,children:c});let l=t.isOn(i);return(0,Q.jsx)(Jc,{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 ${vo[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=ar(e,r);return a(o.cls,o.title,o.body)}function jx(e,t){let n=e.limit;return!n||n.blocked||!e.running||n.autoContinue===t?null:n.autoContinue?(0,Q.jsxs)(Jc,{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)(lh,{size:12}),` auto`]}):(0,Q.jsxs)(Jc,{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)(lh,{size:12}),` no auto`]})}function Mx(e){let t=Nn(e);return t&&(0,Q.jsx)(Jc,{className:t.cls,title:t.title,children:t.body})}function Nx(e){let t=Xi(e);return t&&(0,Q.jsx)(Jc,{className:t.cls,title:t.title,children:t.body})}function Px(e){let t=e.contextSpark,n=e.running?c(t?.liveAgentTok,t?.liveAgentAt,Date.now(),nl()):null;return!n||t?.liveAgentTok==null?null:(0,Q.jsxs)(Jc,{className:`cost-heavy`,title:`${n}\n\nTap the context readout for the whole picture. Nothing here stops it.`,children:[(0,Q.jsx)(Wm,{size:12}),` `,t.liveAgentType?`${t.liveAgentType} `:`agent `,`re-reads `,w(t.liveAgentTok)]})}function Fx(e,t){let n=e.shellList;if(!n?.length)return null;let r=ie(n,Date.now()),i=r.working>0?`coding`:`idle`;return(0,Q.jsxs)(Jc,{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)(Um,{size:12}),` `,g(r)]})}var Ix=e=>e?.contextSpark?.turns||null,Lx=e=>e==null?``:` · ${e} turn${e===1?``:`s`} logged so far`;function Rx(e,t){let n=Yt(e,Date.now());return n?(0,Q.jsxs)(Jc,{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)(Tg,{size:12}),` `,n.text]}):null}function zx(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:Yi(e,t,pu(t)),repo:t,working:!e.idle&&sn(e,n)===`coding`,agents:e.running?(e.agents??[]).map(e=>({what:e.what,model:e.model,startedAt:e.startedAt})):[]}}),o=Wf(e.map(e=>({working:e.working,agents:e.agents.length}))),s=jc(o.total,i);hl(o,e,s),Wc(a.current,s)&&X(zu(o,s,i)),a.current=s},[t,n,i])}fl(G.tabOpensShared,(e,t)=>_o(e,t,Date.now())),Nd(Eu,[G.tabOrderShared,G.tabOpensShared]),rx();function Bx(e){let{sessions:t,sessionRepoName:n,activeId:r,repos:i,attach:a,closeSession:o,backends:s}=e;(0,Z.useEffect)(()=>{Mn(t.map(e=>{let t=n(e);return{id:e.id,label:Yi(e,t),repo:t,status:sn(e,s),createdAt:e.createdAt,...Ii(e,Ix(e)),...e.companionOf?{companionOf:e.companionOf}:{}}}),r,i)},[t,r,i,s]),(0,Z.useEffect)(()=>{let e=e=>e.detail?.id??``,n=n=>{let r=t.find(t=>t.id===e(n));r&&a(r)},r=n=>{let r=t.find(t=>t.id===e(n));r&&o(r)};return window.addEventListener(Op,n),window.addEventListener(ro,r),()=>{window.removeEventListener(Op,n),window.removeEventListener(ro,r)}}),zx({sessions:t,backends:s,sessionRepoName:n})}var Vx=We;function Hx(e){let t=f(e);return t?{notif:t}:e===Vx?{view:`notifications`}:e.startsWith(`plugin:`)&&e.length>7?{plugin:e.slice(7)}:{sessionId:e}}function Ux(e){if(!e.startsWith(`host:`))return null;let t=e.indexOf(`|`);if(t<0)return null;let n=e.slice(5,t),r=e.slice(t+1);return!st(n)||r.startsWith(`host:`)?null:{hostId:n,rest:r}}function Wx(e){let{reposRef:t,initRoute:n,sessions:r,attach:i,setOverlay:a}=e;(0,Z.useEffect)(()=>{Ap(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&&!Pn(n.file.relPath)&&ao(n.file),n.plugin&&pn(n.plugin),n.notif&&Kr(n.notif)},[]),(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(!Wd(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;Pn(t.relPath)?Sc(t):ao(t)}else if(e.data?.type===`open-image`&&e.data.image){let t=r.find(t=>t.id===e.data.sessionId);t&&i(t),ku(e.data.image,e.data.sessionId)}else e.data?.type===`open-plugin`&&typeof e.data.plugin==`string`?pn(e.data.plugin):e.data?.type===`open-notif`&&e.data.item&&Kr(e.data.item)}};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)(()=>fs(e=>{let t=Ux(e);if(t&&t.hostId!==Ic()){Wu(t.hostId,t.rest);return}let n=t?t.rest:e;if(!n)return;let r=Hx(n);`plugin`in r?pn(r.plugin):`notif`in r?Kr(r.notif):`view`in r?Oi():(o.current=n,c(n))}),[]),(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 Gx(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)(()=>{mr(a)},[a]),(0,Z.useEffect)(()=>($v(()=>qc()||i.current.size>0),()=>$v(null)),[])}function Kx(){let[e,t]=(0,Z.useState)(()=>ps(G.snapSessions,[])),[n,r]=(0,Z.useState)(()=>ps(G.snapRecent,[])),[i,a]=(0,Z.useState)(()=>ps(G.snapClosed,[])),[o,s]=(0,Z.useState)(()=>ps(G.snapRepos,[])),[c,l]=(0,Z.useState)(ti),[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)}}var qx=400,Jx=2e3,Yx=tt,Xx=400;function Zx(){let e=Rl(e=>e.ops),t=Rl(e=>e.status===`open`),[,n]=(0,Z.useState)(0),r=(0,Z.useRef)(!1),i=(0,Z.useRef)(!1),[a,o]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!e.length)return;let t=window.setInterval(()=>n(e=>e+1),500);return()=>window.clearInterval(t)},[e.length]),(0,Z.useEffect)(()=>{if(e.length){o(!1);return}if(!r.current)return;o(!0);let t=window.setTimeout(()=>{r.current=!1,i.current=!1,o(!1)},Xx);return()=>window.clearTimeout(t)},[e.length]);let s=e.length?e.reduce((e,t)=>e.started<=t.started?e:t):null,c=s?Date.now()-s.started:0;if(s&&c>=qx&&(r.current=!0),s&&c>=Jx&&(i.current=!0),!r.current||!s&&!a||!t)return null;let l=Math.floor(c/1e3),u=!!s&&c>=Yx;return(0,Q.jsxs)(`div`,{className:`net-activity${u?` stalled`:``}`,role:`status`,"aria-live":`polite`,children:[(0,Q.jsx)(`div`,{className:`net-bar`,children:(0,Q.jsx)(`span`,{})}),i.current&&s&&(0,Q.jsxs)(`div`,{className:`net-chip`,children:[u?(0,Q.jsx)(Ch,{size:12}):(0,Q.jsx)(_m,{size:12,className:`spin`}),(0,Q.jsxs)(`span`,{children:[s.label,e.length>1?` +${e.length-1}`:``,` · `,l,`s`,u?nr(ya(),du()?.id??null):``]})]})]})}function Qx(e,t,n){return t.trim()?e.filter(e=>!n(e)):[...e]}function $x(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 eS=e=>!!e&&Array.from(e.types??[]).includes(`Files`);function tS(e,t){let n=Hi(),r=n.world.activeRepo?.id;r?qc()?Pc(e).then(r=>{r?(n.say.track(`action:attach.${t}.repeat`),n.say.toast(`That picture is already open for marking — not added twice`)):nS(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 nS(e,t){let n=Hi(),r=e.filter(Fs).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`),vl(e))})}function rS(){let[e,t]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let e=e=>{let t=Qx($x(e.clipboardData),e.clipboardData?.getData(`text/plain`)??``,Fs),n=e.target,r=Hi();Xt({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:qc(),repoId:r.world.activeRepo?.id??null,handled:e.defaultPrevented})!==`ignore`&&(e.preventDefault(),tS(t,`paste`))},t=e=>{eS(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){eS(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,t(!0))},onDragLeave(e){e.currentTarget.contains(e.relatedTarget)||t(!1)},onDrop(e){if(!eS(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),t(!1);let n=$x(e.dataTransfer);n.length&&tS(n,`drop`)}}}}function iS(){try{return typeof window<`u`&&window.isSecureContext&&typeof navigator.mediaDevices?.getDisplayMedia==`function`}catch{return!1}}function aS(e,t){return e===`NotAllowedError`?/system/i.test(t)?`The system refused screen capture — allow this browser under Privacy & Security → Screen Recording, then restart it`:null:e===`NotFoundError`?`No window or screen to capture was offered`:e===`NotSupportedError`||e===`TypeError`?`This browser cannot capture a window`:`Window capture failed: ${t||e}`}function oS(e){let t=e=>String(e).padStart(2,`0`);return`window-${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}.png`}async function sS(){let e;try{let t=globalThis.CaptureController,n=t?new t:void 0;e=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:`window`},audio:!1,selfBrowserSurface:`exclude`,surfaceSwitching:`exclude`,monitorTypeSurfaces:`include`,...n?{controller:n}:{}});try{n?.setFocusBehavior?.(`no-focus-change`)}catch{}}catch(e){let t=e,n=aS(t?.name??``,t?.message??``);return n?{error:n}:{cancelled:!0}}try{let t=await cS(e);return t?{file:new File([t],oS(new Date),{type:`image/png`})}:{error:`The window gave no picture`}}catch(e){return{error:`Window capture failed: ${e?.message||e}`}}finally{for(let t of e.getTracks())t.stop()}}async function cS(e){let t=document.createElement(`video`);t.muted=!0,t.playsInline=!0,t.srcObject=e;try{await t.play(),await new Promise(e=>{let n=t,r=setTimeout(e,1e3);n.requestVideoFrameCallback?n.requestVideoFrameCallback(()=>{clearTimeout(r),e()}):t.readyState>=2?(clearTimeout(r),e()):t.addEventListener(`loadeddata`,()=>{clearTimeout(r),e()},{once:!0})});let e=t.videoWidth,n=t.videoHeight;if(!e||!n)return null;let r=document.createElement(`canvas`);r.width=e,r.height=n;let i=r.getContext(`2d`);return i?(i.drawImage(t,0,0,e,n),await new Promise(e=>r.toBlob(e,`image/png`))):null}finally{t.srcObject=null}}var lS=16,$=e=>e.preventDefault();function uS(){try{return window.matchMedia?.(`(pointer: coarse)`).matches??!1}catch{return!1}}function dS(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:m,upProg:h,uploadPending:g,uploadRowLinger:_,cancelUploads:v}=e.uploads,{compose:y,setCompose:b,composeRef:x,cmdHistory:S,histIdx:C,setHistIdx:w,clearArmed:T,setClearArmed:E,setComposeFocused:D,snippetOpen:O,setSnippetOpen:k,sendMode:A,setSendMode:ee,sendWhere:j,setSendWhere:M,sendWhereSid:N,setSendWhereSid:te,sendMenu:P,setSendMenu:F,cliMode:I,enterSends:L,voice:R,aimedSession:z,stepHistory:B,clearCompose:V,appendSnippet:ne,chord:H,toggleCliMode:U,onPipeInput:re,flushPipe:W,onPipeKey:ie,onComposeKey:ae,aimHere:oe,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||Gr(null,n.backend),be=Kl(),{dragOver:xe,dropProps:Se}=rS();(0,Z.useLayoutEffect)(()=>{t.growCompose()},[I]);let Ce=n?.id,we=l_(Ce);(0,Z.useEffect)(()=>{o_(Ce)&&!uS()&&x.current?.focus()},[Ce,x]);let Te=gu();return(0,Z.useEffect)(()=>{if(!Te||!op()||uS()||I)return;let e=x.current;if(e){e.focus();try{e.setSelectionRange(e.value.length,e.value.length)}catch{}}},[Te,x,I]),(0,Q.jsxs)(Q.Fragment,{children:[n&&!we&&(()=>{let e=yf(j,{repoName:o(n.cwd)?.repoName??Tp(n.cwd),sessionName:z?p(z):null});return e?(0,Q.jsxs)(`div`,{className:`compose-aim`,children:[(0,Q.jsxs)(`span`,{className:`compose-aim-what`,children:[(0,Q.jsx)(Fh,{size:12}),` `,e]}),(0,Q.jsxs)(Y,{onPointerDown:$,title:`send to ${Fd(`this`)} instead — the conversation on screen`,onClick:()=>{J(`action:compose.where.here`),oe()},children:[(0,Q.jsx)(Zh,{size:12}),` `,`aim it here`]})]}):null})(),(0,Q.jsxs)(`div`,{className:`compose${xe?` drop-over`:``}`,...Se,children:[(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:[g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ah,{size:12,className:`spin`}),` `,f,m>0?` · still reading it`:``]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Sm,{size:12}),` uploads done`]}),g&&(0,Q.jsxs)(Y,{className:`upload-cancel`,onPointerDown:$,onClick:v,title:`cancel uploads`,children:[(0,Q.jsx)(Jh,{size:12}),` cancel`]})]}),g&&y.trim()&&(0,Q.jsxs)(`div`,{className:`upload-acts`,children:[(0,Q.jsx)(`span`,{className:`upload-acts-what`,children:m>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)(Y,{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:()=>{J(`action:upload.sendnow`),se(`now`)},children:[(0,Q.jsx)(hg,{size:14}),` send now`]}),(0,Q.jsxs)(Y,{onPointerDown:$,"data-hint":`queue.hold`,title:`park it until this session is free, instead of typing it in mid-turn`,onClick:()=>{J(`action:upload.hold`),se(`idle`)},children:[(0,Q.jsx)(lh,{size:14}),` let it wait`]})]}),(0,Q.jsx)(`div`,{className:`upload-bar`,children:(0,Q.jsx)(`div`,{className:`upload-bar-fill${h?.waiting?` waiting`:``}`,style:{width:`${h&&h.total>0?h.pct:0}%`}})})]}),n&&(0,Q.jsx)(tm,{compact:!0,debounceMs:700,text:y,repoId:o(n.cwd)?.id??null,outbox:i,online:a,onRemove:e=>b(t=>Al(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`}),Ru().map(e=>(0,Q.jsxs)(`button`,{className:`more-act${j===e.key?` on`:``}`,onPointerDown:$,title:e.title,onClick:()=>{J(`action:compose.where.${e.key}`),M(e.key),e.key!==`other`&&te(null),ue(n?.cwd,{where:e.key})},children:[e.key===`new`?(0,Q.jsx)(rg,{size:lS}):e.key===`other`?(0,Q.jsx)(Fh,{size:lS}):(0,Q.jsx)(Zh,{size:lS}),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${N===e.id?` sched-on`:``}`,onPointerDown:$,title:`send to ${p(e)}`,onClick:()=>{J(`action:compose.where.pick`),te(e.id)},children:[(0,Q.jsx)(Jf,{children:e.title}),(0,Q.jsx)(Ei,{s:e}),(0,Q.jsx)(Uu,{children:e.turnActive?`working`:`idle`})]},e.id))}):(0,Q.jsx)(`div`,{className:`send-where-pick`,children:(0,Q.jsxs)(Cf,{children:[`No other session is open — `,(0,Q.jsx)(`em`,{children:`a new session`}),` opens one.`]})})})(),Ac().map(e=>(0,Q.jsxs)(`button`,{className:`more-act${e.mode&&A===e.mode?` on`:``}`,onPointerDown:$,title:e.title,onClick:()=>{F(!1),e.mode?ee(e.mode):e.key===`pad`?le():ce()},children:[e.icon===`hourglass`?(0,Q.jsx)(lh,{size:lS}):e.icon===`elsewhere`?(0,Q.jsx)(Og,{size:lS}):e.icon===`pad`?(0,Q.jsx)(Lm,{size:lS}):(0,Q.jsx)(Zh,{size:lS}),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)(Jh,{size:lS}),` close`]})]}),O&&(0,Q.jsx)(Ff,{list:be.list,starter:be.starter,keepFocus:$,emptyText:`No snippets yet — tap “manage” to add one.`,onManage:()=>{k(!1),d(`snippets`)},onClose:()=>k(!1),onInsert:e=>{J(`action:snippet.insert`),e.length>1&&J(`action:snippet.insert.multi`),ne({text:hd(e)})}}),de?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`secret-ask`,children:[(0,Q.jsx)(Rm,{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:()=>D(!0),onBlur:()=>D(!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)(Km,{size:18}):(0,Q.jsx)(Vm,{size:18})})]}),(0,Q.jsxs)(`div`,{className:`compose-bar`,children:[(0,Q.jsxs)(Y,{className:`secret-other`,onPointerDown:$,onClick:ge,title:`Back to the message box — this line is not asking for a password`,children:[(0,Q.jsx)(Jh,{size:14}),` not a password`]}),(()=>{let e=ve();return e?zn(e):[]})().map(e=>(0,Q.jsxs)(Y,{onPointerDown:$,title:e.unavailable??e.label,onClick:()=>{e.unavailable?X(e.unavailable):(J(`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)(Rm,{size:lS}),` Send`]})})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{ref:x,className:I?`pipe`:void 0,"data-compose":``,value:I?vv:y,onChange:I?re:e=>{b(e.target.value),w(-1),E(!1)},onCompositionEnd:I?e=>W(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`:L?`send`:`enter`,onKeyDown:I?ie:ae,onFocus:()=>D(!0),onBlur:()=>D(!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)(qm,{size:13}),H.armed?` ${H.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`]}),H.armed?(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:H.clear,title:`Let go of the held keys — your draft comes back`,children:[(0,Q.jsx)(Jh,{size:lS}),` let go`]}):(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:U,title:`Back to composing — messages queue, survive a dead link and are confirmed on the host`,children:[(0,Q.jsx)(Jh,{size:lS}),` 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:()=>S.length===0?X(`nothing sent yet — no earlier message to recall`):B(-1),title:`Previous sent command`,children:(0,Q.jsx)(fg,{size:18})}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>C===-1?X(`this is your draft — there is nothing newer`):B(1),title:`Next sent command`,children:(0,Q.jsx)(lm,{size:18})}),(0,Q.jsx)(`button`,{className:`mic ${T?`on`:``}`,onPointerDown:$,onClick:()=>y?V():X(`the message box is already empty`),title:T?`Tap again to clear`:`Clear message box`,children:(0,Q.jsx)(Mh,{size:18})}),(0,Q.jsx)(or,{voice:R,onPointerDown:$}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>s?c(s):X(`not a known repo`),title:`Send image to this repo`,children:(0,Q.jsx)(Jm,{size:18})}),iS()&&(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>s?void sS().then(e=>{`file`in e?tS([e.file],`window`):`error`in e&&X(e.error)}):X(`not a known repo`),title:`Picture of a window or screen on this computer — opens in the annotator, then attached`,children:(0,Q.jsx)(Dh,{size:18})}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>s?l(s):X(`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)(nh,{size:18})}),(0,Q.jsx)(`button`,{className:`mic ${O?`on`:``}`,onPointerDown:$,onClick:()=>k(e=>!e),title:`Insert a saved snippet`,children:(0,Q.jsx)(Mg,{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)(Lm,{size:18})}),(()=>{let e=Dp(n?u.filter(e=>e.repoDir===n.cwd):u),t=[...e.waiting,...e.failed];return(0,Q.jsxs)(`button`,{className:`mic show-backlog`,onPointerDown:$,onClick:()=>n&&t.length?ni(n.cwd,t,no(e)):ms(n?.cwd),title:n?`Backlog for this repo — ${vn(e)}`:`Show backlog`,children:[(0,Q.jsx)(sh,{size:18}),e.waiting.length>0&&(0,Q.jsxs)(`span`,{className:`mic-badge`,children:[(0,Q.jsx)(lh,{size:9}),e.waiting.length]}),e.failed.length>0&&(0,Q.jsxs)(`span`,{className:`mic-badge failed`,children:[(0,Q.jsx)(Hh,{size:9}),e.failed.length]})]})})()]}),(0,Q.jsxs)(`div`,{className:`send-split`,children:[(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:()=>se(),title:Uf(A,j,z?p(z):null),children:[A===`idle`?(0,Q.jsx)(lh,{size:lS}):(0,Q.jsx)(Zh,{size:lS}),` `,Uc(A)]}),(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)(Og,{size:14})})]})]})]})]})]})}var fS=14;function pS({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)(Ca,{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)(yl,{children:`Nothing to save — type the prompt, or cancel to keep it as it was.`}),(0,Q.jsxs)(Fc,{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)(Y,{onClick:()=>d(null),children:`Cancel`})]})]})});if(!e)return null;let f=s(e.id,e.holder);return(0,Q.jsx)(qu,{slot:`next-prompt`,stowKey:`${e.holder}:${e.id}`,label:`next prompt`,detail:e.behind>0?`+${e.behind}`:void 0,icon:e.held?lh:hg,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)(lh,{size:fS}):(0,Q.jsx)(hg,{size:fS})}),(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:nu(!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)(Y,{"data-hint":`queue.sendnow`,onPointerDown:o,title:nu(!1),onClick:()=>t(e.id,e.holder),children:[(0,Q.jsx)(hg,{size:fS}),` send now`]}),e.budgetHeld&&(0,Q.jsxs)(Y,{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)(Ah,{size:fS}),` `,pd(1)]})]}):(0,Q.jsxs)(Y,{"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)(lh,{size:fS}),` when it's free`]}),f!=null&&(0,Q.jsxs)(Y,{onPointerDown:o,title:`rewrite this prompt before it goes in`,onClick:()=>d({id:e.id,holder:e.holder,text:f}),children:[(0,Q.jsx)(Dm,{size:fS}),` edit`]}),f!=null&&(0,Q.jsxs)(Y,{onPointerDown:o,title:`don't send it — the words are kept on the pad`,onClick:()=>l(e.id,e.holder),children:[(0,Q.jsx)(Jh,{size:fS}),` cancel`]}),e.holder===`desktop`?(0,Q.jsxs)(Y,{onPointerDown:o,title:`this repo's waiting work on the desktop`,onClick:a,children:[(0,Q.jsx)(sh,{size:fS}),` backlog`]}):(0,Q.jsxs)(Y,{onPointerDown:o,title:`the whole queue for every session`,onClick:i,children:[(0,Q.jsx)(Ym,{size:fS}),` queue`]}),(0,Q.jsx)(zc,{})]})})}function mS(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 hS(e){let t=e.trim().replace(/\s+/g,` `);return t.length>56?`${t.slice(0,56)}…`:t}function gS(e,t){let n=t(e).trim().replace(/\s+/g,` `);return n?hS(n):e.mode===`upload`?`a file`:`an action`}function _S(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:hS(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:gS(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 vS(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}=Rs(),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&&_i(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)(pS,{view:_S({entries:e.outbox,sessionId:t.id,busy:t.hooked?!!t.turnActive:!!t.running&&!t.idle,online:e.online,wall:e.holdWall(t.id),prose:Dr,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&&Nf(t,m,p)})(),tie:e.at?mS(e.at.nextAt==null?Re(e.at.rule):`${Hn(e.at.nextAt)} (${Re(e.at.rule)})`,!!e.reopensConv):void 0})),asOf:e.online?void 0:f?Rp(f):void 0}),onSendNow:(e,t)=>{J(`action:nextprompt.sendnow`),t===`phone`?i(e):c({t:`backlog.fire`,id:e},`running it now…`,jn)},editableText:h,onEdit:(n,r,i)=>{if(J(`action:nextprompt.edit`),r===`desktop`&&!e.online)return X(jn),!1;if(h(n,r)==null){let e=im({id:kf(),text:i,ts:Date.now(),...t.cwd?{cwd:t.cwd}:{}});return e?(X(e),!1):(X(`it already went in — your edit is kept on the pad`),!0)}return r===`phone`?(a(n,i),X(`edited`),!0):c({t:`backlog.update`,id:n,text:i},`edited`,jn)},onCancel:(n,r)=>{J(`action:nextprompt.cancel`);let i=h(n,r);if(i==null){X(r===`desktop`&&!e.online?jn:`it already went in`);return}let a=im({id:kf(),text:i,ts:Date.now(),...t.cwd?{cwd:t.cwd}:{}});a?X(a):r===`phone`?(e.removeQueued(n),X(`canceled — the words are kept on the pad`)):c({t:`backlog.remove`,id:n},`canceled — the words are kept on the pad`,jn)},onPastBudget:e=>{J(`action:nextprompt.pastbudget`),c({t:`intent.waive`,id:e,rung:`budget`,on:!0},lf(1),jn)},onHold:e=>{J(`action:nextprompt.hold`);let t=n.current.find(t=>t.ackId===e);!t||r(t.sessionId)?(o(e),X(`held on this device — it goes in when this session opens. Leave the app open`)):s(e)},onOpenQueue:()=>{J(`overlay:queue`),l(`queue`)},onOpenBacklog:()=>{J(`overlay:backlog`),ms(t.cwd)},keepFocus:$})}function yS(e,t,n){if(n.pending)return null;let r=j(e,t);return r?.to===`cli`?{on:`shell`,cli:r.target}:r?.to===`shell`?{on:`cli`,shell:r.target}:null}function bS(e,t,n,r){if(n.pending)return null;let i=yS(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 xS=16,SS=`
|
|
12
|
+
tap for both windows, their reset times and the token history`,CS=`
|
|
13
|
+
tap for its quota windows and the readings kept`,wS=e=>e.source===`claude`;function TS({f:e,size:t,gauge:n=!0}){return(0,Q.jsxs)(Q.Fragment,{children:[n&&(0,Q.jsx)(Ah,{size:t}),e.reading&&(0,Q.jsx)(`span`,{className:`usage-unit`,children:`reading…`}),!e.reading&&(0,Q.jsxs)(Q.Fragment,{children:[!e.noSess&&(0,Q.jsxs)(Q.Fragment,{children:[(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)(Cg,{size:11}),` `,Hn(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 ES({seg:e,size:t,gauge:n=!0}){return(0,Q.jsxs)(Q.Fragment,{children:[n&&(0,Q.jsx)(Ah,{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 DS(e,t,n=Date.now()){return`${wS(e)&&t?Wt(t):ae(e.reading,n)}${wS(e)?SS:CS}${Va(e.hidden)}`}function OS({sessions:e}){let t=ia(),r=nn(Ut(),e),{segments:i}=n(r,3),a=e=>{J(`overlay:tokens`),fp(Ro(e.source))},o=()=>{let e=Xp(t);return(0,Q.jsx)(Y,{className:`usage-key${Lr(e)?` danger`:``}`,title:`${Wt(t)}${SS}`,onClick:()=>{J(`overlay:tokens`),fp(null)},children:(0,Q.jsx)(TS,{f:e,size:xS})},`claude`)};if(!i.length)return o();let s=_a(i,t),c=s||i.length>1,l=i.map((e,n)=>{let r=wS(e)?er(e.reading,t):null,i=!c||!s&&n===0;return(0,Q.jsx)(Y,{className:`usage-key${c?` usage-seg`:``}${(r?Lr(r):e.hot)?` danger`:``}`,title:DS(e,t),onClick:()=>a(e),children:r?(0,Q.jsx)(TS,{f:r,size:xS,gauge:i}):(0,Q.jsx)(ES,{seg:e,size:xS,gauge:i})},e.source)});return c?(0,Q.jsxs)(`div`,{className:`usage-multi`,children:[s&&o(),l]}):(0,Q.jsx)(Q.Fragment,{children:l})}function kS({backend:e}){let t=ia(),r=Ut(),{segments:i}=n(bi(r,e),3),a=e=>{J(`overlay:tokens`),fp(e?Ro(e.source):null)},o=(e,t,n)=>(0,Q.jsxs)(Uu,{className:`usage-inline${(e.sess??0)>=80?` danger`:``}`,title:t,onClick:()=>a(n),children:[(0,Q.jsx)(Ah,{size:11}),e.reading&&(0,Q.jsx)(Q.Fragment,{children:` reading…`}),!e.reading&&!e.noSess&&(0,Q.jsxs)(Q.Fragment,{children:[` sess `,e.sess==null?`?`:`${e.sess}%`,e.sessResetAt!=null&&(0,Q.jsxs)(Q.Fragment,{children:[` resets `,Hn(e.sessResetAt)]}),` ·`]}),!e.reading&&(0,Q.jsxs)(Q.Fragment,{children:[` `,`wk `,e.wk==null?`?`:`${e.wk}%`]})]},n?.source??`claude`);return i.length?(0,Q.jsx)(Q.Fragment,{children:i.map(e=>wS(e)?o(er(e.reading,t),DS(e,t),e):(0,Q.jsxs)(Uu,{className:`usage-inline${e.hot?` danger`:``}`,title:DS(e,t),onClick:()=>a(e),children:[(0,Q.jsx)(Ah,{size:11}),` `,e.label,` `,e.text,e.unit?` ${e.unit}`:``]},e.source))}):o(Xp(t),`${Wt(t)}${SS}`,null)}async function AS(e,t){let n=await wf({title:`Name this session`,initial:z(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=Ve(n);if(!r){X(`that name was not kept — one word longer than the tab, or an ellipsis in it`);return}J(`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 jS=()=>null;function MS(e,t,n,r){J(`action:launcher.${t}${e.key}`),r?.(),e.unavailable?X(e.unavailable):n>0&&e.openCount?e.openCount():e.open()}function NS({it:e,size:t,onOpen:n}){let r=(e.useCount??jS)(),i=na(r),a=e.icon;return(0,Q.jsxs)(`button`,{className:`more-act${i?` notif-btn`:``}`,title:e.unavailable??(i?r.title:e.title??`open ${e.label}`),onClick:()=>MS(e,``,i,n),children:[(0,Q.jsx)(a,{size:t}),e.label,i>0&&(0,Q.jsx)(`span`,{className:`notif-badge`,children:Nr(i)})]})}function PS({size:e,onOpen:t}){Aa();let n=Cp();return n.length?(0,Q.jsx)(Q.Fragment,{children:n.map(n=>(0,Q.jsx)(ll,{feature:n.feature,what:`its ${n.label} menu line`,children:(0,Q.jsx)(NS,{it:n,size:e,onOpen:t})},n.key))}):null}function FS({it:e,size:t,where:n}){let r=e.useCount(),i=na(r);if(!i)return null;let a=e.icon;return(0,Q.jsxs)(Y,{className:`notif-btn`,"aria-label":r.title,title:r.title,onClick:()=>MS(e,n,i),children:[(0,Q.jsx)(a,{size:t}),(0,Q.jsx)(`span`,{className:`notif-badge`,children:Nr(i)})]})}function IS({items:e,size:t,where:n}){let r=Ui(e);return r.length?(0,Q.jsx)(Q.Fragment,{children:r.map(e=>(0,Q.jsx)(ll,{feature:e.feature,what:`its ${e.label} header key`,children:(0,Q.jsx)(FS,{it:e,size:t,where:n})},e.key))}):null}function LS({size:e}){return Aa(),(0,Q.jsx)(IS,{items:Cp(),size:e,where:`key.`})}function RS({items:e,base:t}){let n=ha(t,e.map(e=>e.useCount()));return n>0?(0,Q.jsx)(`span`,{className:`mic-badge`,children:Nr(n)}):null}function zS({base:e}){Aa();let t=Cp().filter(e=>e.useCount);return t.length?(0,Q.jsx)(ll,{feature:t.map(e=>e.feature).join(`, `),what:`the menu badge`,children:(0,Q.jsx)(RS,{items:t,base:e},t.map(e=>e.key).join(`|`))},t.map(e=>e.key).join(`|`)):e>0?(0,Q.jsx)(`span`,{className:`mic-badge`,children:Nr(e)}):null}var BS=Mu((()=>{let e=gt(G.headerViews,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]})());function VS(e){BS.set(e),ht(G.headerViews,e)}function HS(e){let t=BS.get();t.includes(e)||VS([...t,e])}function US(e){let t=BS.get();t.includes(e)&&VS(t.filter(t=>t!==e))}function WS(){return $t(BS)}var GS=`Flag for follow up`,KS=`Done — clear flag`,qS=e=>e?` fu-${e.by}`:``;function JS(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 device until the link is back`}return e.followUp?`${KS} — ${Je(e.followUp)}`:`${GS} — a one-shot mark; opening the session does not clear it`}var YS=({on:e,size:t})=>(0,Q.jsx)(Th,{size:t,fill:e?`currentColor`:`none`});function XS({f:e}){return(0,Q.jsxs)(`span`,{className:`fu-line${qS(e)}`,children:[(0,Q.jsx)(Th,{size:12,fill:`currentColor`}),` `,Je(e)]})}var ZS=Ai(Qn,Hi);function QS(e,t){return ZS.item(e,t)}var $S=16;function eC(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||Cl(t.id)},_=Gr(m,r?.backend);if(t.id===`model`&&_||t.id===`logins`&&!_||t.id===`companion`&&(_||i||!ri(m)))return null;switch(t.id){case`untracked`:return!o||!vi(o)?null:(0,Q.jsxs)(Y,{className:`count`,title:Jp(o),onClick:()=>{g(),dn(o.id,f)},children:[(0,Q.jsx)(xm,{size:$S}),` `,o.changedCount>0&&o.changedCount,za(o)&&(0,Q.jsxs)(`span`,{className:`git-ab`,children:[` `,za(o)]})]},`untracked`);case`star`:{if(!r||i)return null;let e=r.id in c;return(0,Q.jsxs)(Y,{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 device 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)(Qh,{size:$S,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)(Y,{className:`fu-btn${qS(r.followUp)}${r.id in u?` star-pending`:``}`,"data-hint":`session.followup`,"aria-pressed":e,title:JS(r,r.id in u,a===`open`),onClick:()=>{g(),d(r.id,!e)},children:[(0,Q.jsx)(YS,{on:e,size:$S}),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)(cp,{active:r,repo:o,online:a===`open`,compact:n,dismiss:g},`bookmark`);default:{let e=Za(r).find(e=>e.key===t.id);if(e)return e.useCount?(0,Q.jsx)(ll,{feature:e.feature,what:`its ${e.label} menu line`,children:(0,Q.jsx)(tC,{ext:e,label:h,dismiss:g})},t.id):(0,Q.jsxs)(Y,{title:e.unavailable??e.label,onClick:()=>{g(),J(`toolbar:${t.id}`),e.unavailable?X(e.unavailable):e.open()},children:[(0,Q.jsx)(e.icon,{size:$S}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,e.label]})]},t.id);let n=QS(t.id,{label:h,dismiss:g,openMenu:()=>Us(!0),active:r});if(n!==void 0)return(0,Q.jsx)(Z.Fragment,{children:n},t.id);let i=Vl[`toolbar:${t.id}`],a=t.id===`outline`?Ix(r):null;return(0,Q.jsxs)(Y,{"data-hint":`toolbar:${t.id}`,title:`${i?`${i.title} — ${i.what}`:t.name}${Lx(a)}`,onClick:()=>{g(),p(t.id)},children:[(0,Q.jsx)(t.Icon,{size:$S}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,t.id===`model`?Sa(r?.model)||`model`:t.name]}),a==null?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,a]})]},t.id)}}}function tC({ext:e,label:t,dismiss:n}){let r=e.useCount(),i=na(r);return(0,Q.jsxs)(Y,{className:i?`notif-btn`:void 0,title:e.unavailable??(i?r.title:e.label),onClick:()=>{n(),J(`toolbar:${e.key}`),e.unavailable?X(e.unavailable):i>0&&e.openCount?e.openCount():e.open()},children:[(0,Q.jsx)(e.icon,{size:$S}),t&&(0,Q.jsxs)(Q.Fragment,{children:[` `,e.label]}),i>0&&(0,Q.jsx)(`span`,{className:`notif-badge`,children:Nr(i)})]})}function nC({c:e,usedOrder:t,refreshTerminal:n}){let{active:r,pending:i,toolbarCfg:a,setOverlay:o}=e;return i?(0,Q.jsx)(uc,{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)(Y,{title:`refresh terminal`,onClick:()=>{Cl(),n()},children:[(0,Q.jsx)(qh,{size:$S}),` refresh`]}),r.remoteUrl&&(0,Q.jsxs)(Y,{onClick:()=>{Cl(),window.open(r.remoteUrl,`_blank`)},title:`open in app`,children:[(0,Q.jsx)(uh,{size:$S}),` open in app`]}),dp(a,t).map(t=>eC(e,t)),En(r.id).map(e=>(0,Q.jsxs)(Y,{title:e.unavailable??`open ${e.label} — adds its tab to the header`,onClick:()=>{Cl(),J(`action:view.${e.key}.menu`),e.unavailable?X(e.unavailable):(HS(e.key),e.open())},children:[(0,Q.jsx)(e.icon,{size:$S}),` `,e.label]},e.key)),(0,Q.jsxs)(Y,{title:`customize toolbar`,onClick:()=>{Cl(),o(`toolbar`)},children:[(0,Q.jsx)(wg,{size:$S}),` customize`]})]})}var rC=()=>{let e=gt(G.toldNoticed,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]};function iC(e,t,n,r){return aC(e,r)&&!n.includes(t)}var aC=(e,t)=>e===`none`&&t!==`shell`;function oC(e){let t=rC().filter(t=>t!==e);ht(G.toldNoticed,[...t,e].slice(-32))}var sC=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.`,cC=e=>`Shown once for ${e} on this device — the crossed-out speech icon beside the title brings it back.`,lC=(e,t)=>e===`none`&&t!==`shell`,uC=e=>`askrules:${e}`,dC=(e,t,n,r)=>lC(e,r)&&!n.includes(uC(t)),fC=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.`,pC=e=>`Shown once for ${e} on this device — the shield-with-question-mark icon beside the title brings it back.`;function mC(e){let t=rC().filter(t=>t!==uC(e));ht(G.toldNoticed,[...t,uC(e)].slice(-32))}function hC({active:e,backends:t}){let n=e.backend??`claude`,r=Gr(t,e.backend)?`shell`:void 0,[i,a]=(0,Z.useState)(()=>iC(e.told,n,rC(),r));if(!aC(e.told,r))return null;let o=t?.find(e=>e.id===n)?.label??n;return i?(0,Q.jsxs)(yl,{className:`told-note`,role:`note`,children:[sC(o),` `,(0,Q.jsx)(`button`,{className:`link-btn`,onClick:()=>{oC(n),a(!1),X(cC(o))},children:`got it`})]}):(0,Q.jsx)(`button`,{className:`link-btn told-mark`,title:sC(o),"aria-label":`${o} was not told about the outbox — read why`,onClick:()=>a(!0),children:(0,Q.jsx)(Eg,{size:12,"aria-hidden":`true`})})}function gC({active:e,backends:t}){let n=Gr(t,e.backend)?`shell`:void 0;return lC(e.askRulesVia,n)?(0,Q.jsx)(_C,{active:e,backends:t}):null}function _C({active:e,backends:t}){let{rules:n}=Xs(),r=e.backend??`claude`,i=Gr(t,e.backend)?`shell`:void 0,[a,o]=(0,Z.useState)(()=>dC(e.askRulesVia,r,rC(),i));if(n.length===0)return null;let s=t?.find(e=>e.id===r)?.label??r;return a?(0,Q.jsxs)(yl,{className:`told-note`,role:`note`,children:[fC(s),` `,(0,Q.jsx)(`button`,{className:`link-btn`,onClick:()=>{mC(r),o(!1),X(pC(s))},children:`got it`})]}):(0,Q.jsx)(`button`,{className:`link-btn told-mark`,title:fC(s),"aria-label":`Ask-before rules are not enforced in ${s} — read why`,onClick:()=>o(!0),children:(0,Q.jsx)(_h,{size:12,"aria-hidden":`true`})})}function vC({off:e,hidden:t,children:n}){let{frame:r,cap:i,capped:a,grip:o}=Np({key:G.sessChromeH,off:e,showAllEvent:`action:chrome.showAll`,capEvent:`action:chrome.cap`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:r,className:`sess-chrome${a?` capped`:``}`,style:a?{maxHeight:`${i}px`}:void 0,children:n}),!t&&(0,Q.jsx)(`div`,{className:`sess-chrome-grip${a?` capped`:``}`,role:`separator`,"aria-orientation":`horizontal`,tabIndex:0,"aria-label":a?`header shortened — tap to show all of it, or drag down for more`:`drag up to hide the bottom of the header`,title:a?`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`,...o,children:a&&(0,Q.jsx)(Ng,{size:12,"aria-hidden":`true`})})]})}var yC=16,bC=54,xC=12,SC=new Set([`star`,`followup`,`bookmark`]);function CC(e){let{active:t,sessions:n,pending:r,pendingEntry:a,status:o,liveSend:s,backends:c,sessionCan:l,sessionRepoName:u,repoForCwd:d,setActiveId:f,setOverlay:p,removeQueued:m,closeSession:h,chrome:g,hdrShown:_,headerCmds:b,runHeaderCmd:x,refreshTerminal:S,toolbar:w}=e,{chromeHidden:T,typingMode:E,typingPeeking:D,setTypingPeek:O,setFullScreen:k}=g,A=Qa(),ee=mn(),j=Su(),M=Gi(),N=Yg(),te=Vi(),P=l(t,`contextSeries`)&&l(t,`contextMeter`)&&t.contextLeft!=null,F=Nn(t)?.cls??null;return(0,Q.jsxs)(vC,{off:T||A||D,hidden:T,children:[(0,Q.jsxs)(`header`,{className:`topbar sess-top`,style:Cu(u(t)),children:[(0,Q.jsx)(`button`,{className:`back`,onClick:()=>f(null),children:(0,Q.jsx)(gm,{size:24})}),(0,Q.jsxs)(`div`,{className:`brand`,children:[v(d(t.cwd),C(t.title)||t.title),(0,Q.jsxs)(Uu,{className:Yn(c,t.backend)?`row-foreign`:void 0,children:[` `,Du(Ho(t),Yn(c,t.backend),c)]}),(0,Q.jsx)(ff,{}),(0,Q.jsx)(hC,{active:t,backends:c},t.id),(0,Q.jsx)(gC,{active:t,backends:c},`ar:${t.id}`),t.tabTitle?(0,Q.jsxs)(`span`,{className:`brand-name`,children:[(0,Q.jsx)(pm,{size:12,"aria-hidden":`true`}),` `,t.tabTitle]}):null]}),(0,Q.jsxs)(`div`,{className:`hdr-view`,children:[(0,Q.jsx)(TC,{active:t,sessions:n,pending:r,backends:c}),fo(w.toolbarCfg).filter(e=>SC.has(e.id)).map(e=>(0,Q.jsx)(`span`,{className:`hdr-pin`,children:eC(w,e,!0)},e.id)),!r&&(0,Q.jsx)(Y,{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:()=>{J(`action:session.name`),s({t:`session.name`,id:t.id},`writing a name for this session…`)},children:(0,Q.jsx)(pm,{size:yC})}),!r&&(0,Q.jsx)(Y,{className:`hdr-name-btn`,title:`type a name for this session`,"aria-label":`rename this session`,onClick:()=>{AS(t,s)},children:(0,Q.jsx)(Dm,{size:yC})})]}),(0,Q.jsxs)(`div`,{className:`hdr-row2`,children:[(0,Q.jsxs)(`div`,{className:`hdr-cmds`,children:[fo(w.toolbarCfg).filter(e=>e.id!==`outline`&&!SC.has(e.id)).map(e=>(0,Q.jsx)(`span`,{className:`hdr-pin`,children:eC(w,e,!0)},e.id)),_.map(e=>(0,Q.jsx)(Y,{className:`hdr-cmd`,title:e.text,onClick:()=>x(e),children:e.title},e.id)),(0,Q.jsx)(Y,{className:`hdr-cmd hdr-cmd-manage`,title:`header commands — one-tap chips you configure`,onClick:()=>{J(`action:hdrcmd.manage`),p(`hdrcmd`)},children:b.length?(0,Q.jsx)(Dm,{size:12}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(rg,{size:12}),` command`]})})]}),(0,Q.jsx)(`div`,{className:`hdr-ctl`,children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Rc,{compact:!0}),!r&&(0,Q.jsx)(IS,{items:Za(t).filter(e=>!(w.toolbarCfg.pinned??[]).includes(e.key)),size:yC,where:`session.key.`}),(0,Q.jsx)(Ea,{size:yC}),r?(0,Q.jsx)(Y,{variant:`danger`,title:l_(t.id)?`close — nothing was queued; a draft stays here for next time`:`drop this open — the prompts written for it stay in ${Td.activity}`,onClick:()=>{let e=a?.ackId;f(null),e&&(m(e),X(`open dropped`))},children:(0,Q.jsx)(Jh,{size:yC})}):(0,Q.jsx)(Y,{variant:`danger`,title:t.running?`close session — reopen under “Recently closed”`:`remove session`,onClick:()=>{h(t),f(null)},children:(0,Q.jsx)(Jh,{size:yC})}),(0,Q.jsx)(Y,{className:`burger-btn${A?` active`:``}`,title:A?`close the menu`:`menu — refresh, slash commands, files, and the rest`,"aria-label":`toolbar`,"aria-expanded":A,onClick:()=>Us(!A),children:(0,Q.jsx)(ug,{size:yC})})]})})]}),T&&!r&&!(w.toolbarCfg.pinned??[]).includes(`outline`)&&(0,Q.jsxs)(Y,{className:`hdr-typing-keep hdr-typing-outline`,onPointerDown:$,title:`outline — where you are in this session${Lx(Ix(t))}`,onClick:()=>w.runToolbar(`outline`),children:[(0,Q.jsx)(jg,{size:yC}),Ix(t)==null?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,Ix(t)]})]}),T&&(0,Q.jsx)(Y,{className:`hdr-typing-keep hdr-typing-menu`,onPointerDown:$,title:E?`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:()=>{E?(J(`action:typing.peek`),O(!0)):(J(`action:fullscreen.off`),k(!1))},children:(0,Q.jsx)(ug,{size:yC})}),D&&(0,Q.jsx)(Y,{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:()=>{J(`action:typing.hide`),O(!1)},children:(0,Q.jsx)(Nh,{size:yC})}),A&&(0,Q.jsx)(nC,{c:w,usedOrder:ee,refreshTerminal:S})]}),r&&(0,Q.jsxs)(`div`,{className:`sess-status`,children:[(0,Q.jsx)(Uu,{children:d(t.cwd)?I(de(d(t.cwd))):t.cwd}),(0,Q.jsx)(Uu,{children:l_(t.id)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(lh,{size:11}),` starts when its backlog item runs`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ah,{size:11,className:a?.status===`failed`?``:`spin`}),` `,a?.status===`failed`?`not started`:!a||a.status===`pending`?`opening…`:o===`open`?`queued`:`queued — waiting for the link`]})})]}),!r&&(0,Q.jsxs)(`div`,{className:`sess-status`,children:[Ax(t,void 0,void 0,c),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:()=>{J(`action:session.ackAsking`),s({t:`session.ackAsking`,id:t.id,text:t.asking.text},`marked as handled — nothing was typed into the session`)},children:[(0,Q.jsx)(Sm,{size:12}),` mark handled`]}),t.createdAt&&t.running&&(0,Q.jsxs)(Uu,{children:[(0,Q.jsx)(Cg,{size:11}),` open `,gn(t.createdAt)]}),l(t,`usageLimits`)&&j.kind===`windows`&&(0,Q.jsx)(kS,{backend:t.backend}),l(t,`usageLimits`)&&j.kind===`usd`&&(0,Q.jsxs)(Uu,{className:`usage-inline${j.chip.hot?` danger`:``}`,title:`${j.chip.title}\ntap for the token history`,onClick:()=>{J(`overlay:tokens`),p(`tokens`)},children:[(0,Q.jsx)(Ah,{size:11}),` `,j.chip.text]}),Ia(t.sideChannel)&&(0,Q.jsxs)(Uu,{className:`act-cant`,children:[(0,Q.jsx)(ig,{size:11}),` `,Ia(t.sideChannel)]}),jx(t,te),Fx(t,()=>os(t)),!P&&Mx(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: ${mo(t.contextUsedTok??0)} of ${mo(t.contextTotalTok)} tokens`:`context window`}${i(t.contextSpark?.usageTok)?`\n${ce(t.contextSpark.usageTok,t.contextSpark.agentTok??null)}`:``}\ntap for the graph: how it filled, and where it compacted`,onClick:()=>{J(`overlay:context`),$n()},children:[l(t,`contextMeter`)&&t.contextSpark?(0,Q.jsx)(To,{spark:t.contextSpark,width:54,height:14}):(0,Q.jsx)(ym,{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)(wC,{pct:t.contextLeft,warm:F})]}):(0,Q.jsxs)(Q.Fragment,{children:[` context `,mo(t.contextUsedTok??0),`/`,mo(t.contextTotalTok),t.contextLeft!=null&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(wC,{pct:t.contextLeft,warm:F})]})]}):(0,Q.jsx)(Q.Fragment,{children:` context`}),(()=>{let e=t.contextSpark;if(e&&fr(e,bC,xC)){let n=y(e.costUsd,M),r=N(t);return(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Yo,{spark:e,width:bC,height:xC,warn:r}),n&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:r?`spend-warn-${r.level}`:void 0,children:n})]})]})}return i(e?.usageTok)?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(dg,{size:11}),` used `,i(e?.usageTok)]}):null})()]}),Nx(t),Px(t),Rx(t,()=>Zi(null)),(0,Q.jsx)(kt,{s:t})]})]})}function wC({pct:e,warm:t}){return(0,Q.jsxs)(`span`,{className:t?`ctx-free ${t}`:`ctx-free`,children:[e,`% free`]})}function TC({active:e,sessions:t,pending:n,backends:r}){let i=WS(),a=n?[]:En(e.id).filter(e=>i.includes(e.key)),o=bS(e,t,{pending:n,shell:Gr(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=so(r,s.backend),l=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Wm,{size:14,"aria-hidden":`true`}),` `,c]}),u=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Um,{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:()=>{J(`action:view.${t.key}`),t.unavailable?X(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:()=>{J(`action:view.${t.key}.unpin`),US(t.key)},children:(0,Q.jsx)(Jh,{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:()=>{J(`action:companion.to.cli`),Gn(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:()=>{J(`action:companion.to.shell`),Gn(n.id)},children:t},`shell`)})})}function EC({activeId:e}){let t=$t(j_);if(!t||!k_(t,e))return null;let n=O_(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:()=>{J(`action:shell.return`),t.to.open()},children:[(0,Q.jsx)(Wh,{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:()=>{P_(),X(`Hidden. The shell button on the ${t.to.label} brings it back.`)},children:(0,Q.jsx)(Jh,{size:13})})]})}function DC({session:e,onSendLogin:t}){let n=F(e)?.kind;return n===`auth`?e.login?(0,Q.jsx)(OC,{login:e.login,id:e.id}):e.signedOut&&e.running?(0,Q.jsx)(kC,{onSendLogin:t}):null:n===`net`&&e.netRetry&&e.running?(0,Q.jsx)(AC,{id:e.id,retry:e.netRetry}):null}function OC({login:e,id:t}){return(0,Q.jsx)(qu,{slot:`login`,stowKey:`${e.url}\n${e.awaitingCode?`await`:``}`,label:`sign-in link`,icon:Rm,children:(0,Q.jsxs)(`div`,{className:`approve login`,children:[(0,Q.jsxs)(`div`,{className:`login-head`,children:[(0,Q.jsxs)(`span`,{className:`login-title`,children:[(0,Q.jsx)(Rm,{size:14}),` sign-in link`]}),(0,Q.jsx)(`span`,{className:`login-age`,title:`when the CLI printed this link`,children:Rp(e.at)}),(0,Q.jsx)(zc,{})]}),(0,Q.jsx)(Nu,{url:e.url,openLabel:`Open sign-in page`,onOpen:Qd,onCopy:e=>void is(e),onPasteCode:e.awaitingCode?()=>void bl(t):void 0,children:e.awaitingCode&&(0,Q.jsxs)(`div`,{className:`approve-hint`,children:[`the CLI is waiting for the code — sign in, then `,(0,Q.jsx)(`b`,{children:`paste code`}),` (or type it in the compose bar)`]})})]})})}function kC({onSendLogin:e}){return(0,Q.jsx)(qu,{slot:`login`,stowKey:`signed-out`,label:`signed out`,icon:kg,children:(0,Q.jsxs)(`div`,{className:`approve login`,children:[(0,Q.jsxs)(`div`,{className:`login-head`,children:[(0,Q.jsxs)(`span`,{className:`login-title`,children:[(0,Q.jsx)(kg,{size:14}),` Claude is signed out on this desktop`]}),(0,Q.jsx)(zc,{})]}),(0,Q.jsxs)(`div`,{className:`approve-hint`,children:[`Your message was not sent to Claude. Sign in first: tap `,(0,Q.jsx)(`b`,{children:`Sign in`}),` below, or type `,(0,Q.jsx)(`b`,{children:`/login`}),` in the message box and send it. Claude then shows a sign-in link here — open it, sign in, and paste the code back.`]}),(0,Q.jsx)(`div`,{className:`approve-opts`,children:(0,Q.jsxs)(`button`,{className:`approve-btn primary`,onClick:e,children:[(0,Q.jsx)(kg,{size:14}),` Sign in (sends /login)`]})})]})})}function AC({id:e,retry:t}){let[n,r]=(0,Z.useState)(()=>Date.now()),i=t.nextAt!=null&&!t.dismissed;(0,Z.useEffect)(()=>{if(!i)return;let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[i]);let a=Pe(t,n);if(!a||t.dismissed)return null;let o=t.state===`gaveup`,s=t.state===`sent`;return(0,Q.jsxs)(`div`,{className:`approve netretry`,role:`status`,children:[(0,Q.jsxs)(`div`,{className:`netretry-line`,children:[(0,Q.jsx)(vg,{size:14,"aria-hidden":`true`}),` `,a]}),(0,Q.jsx)(`div`,{className:`approve-hint netretry-error`,children:t.error}),(0,Q.jsxs)(`div`,{className:`approve-opts netretry-opts`,children:[!s&&(0,Q.jsxs)(`button`,{className:`approve-btn primary`,onClick:()=>Dl(e),title:`Retry now types “continue” into that session, the way the automatic retry does; the work completes on the next real reply.`,children:[(0,Q.jsx)(fm,{size:14,"aria-hidden":`true`}),` retry now`]}),(0,Q.jsxs)(`button`,{className:`approve-btn`,onClick:()=>Bl(e,o),title:o?`hide this line — work waiting on this session stays stalled, with its note on its own row`:`stop the desktop retrying this turn — it types nothing`,children:[(0,Q.jsx)(Jh,{size:14,"aria-hidden":`true`}),` `,o?`dismiss`:`cancel`]}),!o&&(0,Q.jsxs)(`button`,{className:`approve-btn`,onClick:qs,title:`stop the desktop retrying network errors in every session — Settings › Sessions brings it back`,children:[(0,Q.jsx)(rh,{size:14,"aria-hidden":`true`}),` turn off`]})]})]})}var jC={...we.dark},MC={...we.light,cursor:we.light.foreground,cursorAccent:we.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 NC(e){let t=e===`light`?MC:jC,n=ye(e,Hf());return n===we[e]?t:e===`light`?{...t,...n,cursor:n.foreground,cursorAccent:n.background}:{...t,...n}}var PC=450,FC=400,IC=2500,LC=3e4;function RC(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 zC(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 BC=(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:d},f){let p=(0,Z.useRef)(null),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(0),_=(0,Z.useRef)({cols:0,rows:0}),v=(0,Z.useRef)({linkUp:i,onScreen:a,onCursorLine:o,onReachBack:s,onScrollStalled:c,onLongPress:l});v.current={linkUp:i,onScreen:a,onCursorLine:o,onReachBack:s,onScrollStalled:c,onLongPress:l};let y=(0,Z.useRef)(void 0),b=(0,Z.useRef)(void 0),x=(0,Z.useRef)(0);(0,Z.useEffect)(()=>{let e=new Rg({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:Pd(),theme:NC(Or()),scrollback:5e3,convertEol:!1}),t=new zg;e.loadAddon(t);let r=()=>{t.fit(),e.cols>W(e.cols)&&e.resize(W(e.cols),e.rows)};e.open(p.current),p.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),m.current=e;let i=Vo(t=>{e.options.theme=NC(t)}),a=pl(()=>{e.options.fontSize=Pd();try{r()}catch{return}S(e.cols,e.rows)});h.current=t,S(e.cols,e.rows);let o,s=new ResizeObserver(()=>{clearTimeout(o),o=window.setTimeout(()=>{try{let t=C();r(),S(e.cols,e.rows),t&&e.scrollToBottom()}catch{}},150)});s.observe(p.current);let c=p.current,l=0,u=0,d=0,f=!1,g,_=()=>{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(b.current);let t=w();b.current=window.setTimeout(()=>{w()===t&&(Date.now()-x.current<LC||(x.current=Date.now(),v.current.onScrollStalled?.()))},IC)},D=t=>{if(_(),t.touches.length!==1){f=!1;return}l=t.touches[0].clientY,u=t.touches[0].clientX,d=0,f=!1;let n=u,r=l;g=window.setTimeout(()=>{g=void 0;let t=zC(c,e);if(!t)return;let i=Math.floor((r-c.getBoundingClientRect().top-t.top)/t.rowH);i>=0&&i<t.rows&&v.current.onLongPress?.(i,n,r)},PC)},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&&_(),!f){if(Math.abs(n)<8||Math.abs(r)>Math.abs(n))return;f=!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(!v.current.linkUp){a<0&&(f=!1,v.current.onReachBack?.());return}E(a)}};return c.addEventListener(`touchstart`,D,{passive:!0}),c.addEventListener(`touchmove`,O,{passive:!1}),c.addEventListener(`touchend`,_,{passive:!0}),c.addEventListener(`touchcancel`,_,{passive:!0}),()=>{try{e.buffer.active.type===`alternate`&&v.current.onScreen?.(RC(e))}catch{}clearTimeout(o),clearTimeout(y.current),clearTimeout(b.current),s.disconnect(),i(),a(),c.removeEventListener(`touchstart`,D),c.removeEventListener(`touchmove`,O),c.removeEventListener(`touchend`,_),c.removeEventListener(`touchcancel`,_),_(),e.dispose(),m.current=null}},[]),(0,Z.useEffect)(()=>{let t=m.current;if(!t||g.current>=e.length)return;let n=C();for(let n=g.current;n<e.length;n++)t.write(e[n]);g.current=e.length,n&&t.scrollToBottom(),clearTimeout(y.current),y.current=window.setTimeout(()=>{if(m.current){if(v.current.onCursorLine&&!m.current.modes.synchronizedOutputMode){let e=m.current.buffer.active;v.current.onCursorLine(e.getLine(e.baseY+e.cursorY)?.translateToString(!0,0,e.cursorX)??``)}m.current.buffer.active.type===`alternate`&&(m.current.modes.synchronizedOutputMode||v.current.onScreen?.(RC(m.current)))}},FC)},[t,e]);function S(e,t){if(!u(e,t))return;let n=_.current;(n.cols!==e||n.rows!==t)&&(_.current={cols:e,rows:t},r(e,t))}function C(){let e=m.current;return!e||e.buffer.active.viewportY>=e.buffer.active.baseY}return(0,Z.useImperativeHandle)(f,()=>({focus(){m.current?.focus()},snapshot(){return m.current?RC(m.current):[]},rowBox(){return m.current&&p.current?zC(p.current,m.current):null},getText(){let e=m.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(`
|
|
14
|
+
`)};return[t(`normal`),e.buffer.active.type===`alternate`?t(`alternate`):``].filter(Boolean).join(`
|
|
15
|
+
|
|
16
|
+
— current screen —
|
|
17
|
+
|
|
18
|
+
`)}}),[]),(0,Q.jsx)(`div`,{ref:p,style:{width:`100%`,height:`100%`,position:`relative`},children:d})}),VC=18,HC=520,UC=`[data-hint="term.read"]`;function WC({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 Rg({cols:Math.max(20,n),rows:Math.max(5,r),fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:Pd(),theme:NC(Or()),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=Vo(t=>{e.options.theme=NC(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(VC,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(UC),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:HC,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)(Cf,{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)(qm,{size:12}),` no turns yet — this is the top of the CLI; the conversation appears here once you send`]})]})}function GC(e,t){return!!e&&t&&e.kind===`trust`&&e.options.length>0}var KC=sm(),qC={hand:Pm,code:Sh,scroll:xg,zap:hg,shieldOff:ph,lock:Pg};function JC({mode:e,size:t=16}){let n=qC[Py[e]?.icon??`hand`];return(0,Q.jsx)(n,{size:t,"aria-hidden":!0})}function YC(e,t,n){let r=Go(e,t.backend)?br(e,t.backend):[];return{rows:Ry(r,t,hi(e,t.backend)),ultraOk:r.length>0&&hi(e,t.backend)&&n&&Bi(e,t.backend).length>0}}function XC(e,t,n){let r=YC(e,t,n);return r.rows.length>0||r.ultraOk}function ZC({cur:e,backends:t,canSlash:n,submitInput:r,liveAsk:i,onClose:a}){let o=Qy(e.id),{rows:s,ultraOk:c}=YC(t,e,n),l=Iy(e);if(s.length===0&&!c){let n=Gr(t,e.backend)?null:No(t,e.backend);return n?(0,Q.jsx)(yl,{className:`mode-sec`,children:n}):null}let u=t=>{J(`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`)&&Xy(e.id,t)},d=async e=>{let t=zy(e,l);t.kind===`none`?X(t.say):t.kind===`confirm`&&(a(),!await Xl({title:`Switch this session to ${Fy(e)}?`,lines:[...ub.slice(0,2),`This session only — new sessions keep their own launch mode.`],confirmLabel:`Switch to ${Fy(e)}`}))||u(e)},f=t=>{let n=Ky(t);J(`action:ultracode.${t?`on`:`off`}`),r(e.id,e.cwd,n,`command`)&&X(n)},p=Wy(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:hi(t,e.backend)?`Mode · shift+tab on the desktop`:`Mode`}),(0,Q.jsx)(yl,{className:`mode-now`,children:Ly(l,hi(t,e.backend)?void 0:xo(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)(JC,{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)(_m,{size:16,className:`spin`}):t&&l.source===`live`?(0,Q.jsx)(Sm,{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)(pm,{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:Gy(e.ultracode)})]}),(0,Q.jsxs)(`span`,{className:`mode-acts`,children:[p!==`on`&&(0,Q.jsx)(Y,{onClick:()=>f(!0),children:`turn on`}),p!==`off`&&(0,Q.jsx)(Y,{onClick:()=>f(!1),children:`turn off`})]})]})]})}var QC=new Map;function $C(e){return(0,KC.createPortal)((0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`model-wheel-scrim`,onPointerDown:t=>{t.preventDefault(),e.onClose()}}),(0,Q.jsx)(ew,{anchor:e.anchor,children:(0,Q.jsx)(tw,{...e})})]}),document.body)}function ew({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(io(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 tw({cur:e,backends:t,canSlash:n,submitInput:r,relaunch:i,liveAsk:a,onClose:o}){let s=XC(t,e,n),c=(0,Q.jsx)(ZC,{cur:e,backends:t,canSlash:n,submitInput:r,liveAsk:a,onClose:o}),l=Mr(t,e.backend),u=Bi(t,e.backend),[d,f]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]),Hp(l).length===0&&!e.model)return(0,Q.jsxs)(`div`,{className:`model-wheel-pop`,role:`dialog`,"aria-label":`model wheel`,children:[(0,Q.jsx)(nw,{onClose:o,withMode:s}),(0,Q.jsx)(yl,{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.`}),c]});let p=kp(e,l),m=QC.get(e.id);m&&bc(m,p,l.ids)&&QC.delete(e.id);let h=m&&QC.has(e.id)?m:null,g=d?Ys(p,d,{slash:n,effort:un(t,e.backend,!0)}):null,_=d?`${d.model}${d.effort?` · ${d.effort}`:``}`:``,v=Li(e)?`the conversation is resumed`:`no conversation id is known, so it starts clean`,y=g?g.kind===`none`?p.from===`turn`?`The last turn already ran on ${_}.`:`This session started on ${_}.`:g.kind===`live`?`Sends ${g.commands.join(` then `)}.`:`Kills and relaunches this session on ${_}; ${v}.`:`Tap or drag to a point${u.length>0?` — centre is low effort, the rim is max`:``}.${u.length>0?``:` This backend has no effort setting.`}`,b=ot(e.contextSpark,{lastTurnAt:e.lastTurnAt,turnActive:e.turnActive,now:Date.now()}),x=d&&g&&g.kind!==`none`?ip({from:{model:p.model,effort:p.effort},to:d,ids:l.ids,tok:b?.tok??null,baseTok:b?.baseTok??null,cold:Se(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)(nw,{onClose:o,withMode:s}),(0,Q.jsxs)(kl,{cat:l,efforts:u,current:{model:p.model,effort:p.effort},value:d,onPick:f,onClear:()=>f(null),says:y,now:(0,Q.jsxs)(Q.Fragment,{children:[p.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}`:u.length>0?` · default effort`:``]}),h&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`br`,{}),`Sent `,h.commands.join(` then `),` `,Rp(h.at),`; no turn has run on it yet.`]})]}),children:[x&&(0,Q.jsx)(yl,{className:`mw-cost`,children:x}),g&&g.kind!==`none`&&(0,Q.jsx)(`button`,{className:`send mw-apply`,onClick:()=>{if(g&&g.kind!==`none`){if(J(`action:modelwheel.${g.kind}`),g.kind===`live`){for(let t of g.commands)r(e.id,e.cwd,t,`command`);QC.set(e.id,{commands:g.commands,model:g.model,effort:g.effort,at:Date.now()}),X(g.commands.join(` · `))}else i(e,g.patch);o()}},children:g.kind===`live`?`Switch to ${_}`:`Relaunch on ${_}`}),c]})]})}function nw({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)(Y,{"aria-label":`close the model wheel`,onClick:e,children:(0,Q.jsx)(Jh,{size:16})})]})}var rw=`2.1.304`,iw=[{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 aw(e){let t=[];for(let n of e.seq){let e=it(n.m,n.key);if(!(`bytes`in e))return null;t.push(e.bytes)}return t}var ow=16,sw=150;function cw({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=iw[n],i=aw(r);i?(J(`action:keys.send`),i.forEach((t,n)=>n===0?e(t):window.setTimeout(()=>e(t),n*sw)),t(),X(`sent ${r.name} — ${r.does}`)):X(`${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 `,rw,`'s default keys — a remapped keybindings.json has others`]}),(0,Q.jsx)(Y,{onPointerDown:$,onClick:t,title:`close the list`,"aria-label":`close the list`,children:(0,Q.jsx)(Jh,{size:ow})})]}),(0,Q.jsx)(`div`,{className:`keys-pop-list`,children:iw.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 lw=16,uw=e=>{e.preventDefault(),document.activeElement?.blur()},dw=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)(fg,{size:lw}),title:`up — move the selection in a box`,data:`\x1B[A`,key:`up`,nav:!0},{label:(0,Q.jsx)(lm,{size:lw}),title:`down — move the selection in a box`,data:`\x1B[B`,key:`down`,nav:!0},{label:(0,Q.jsx)(xh,{size:lw}),title:`left`,data:`\x1B[D`,key:`left`,nav:!0},{label:(0,Q.jsx)(mh,{size:lw}),title:`right`,data:`\x1B[C`,key:`right`,nav:!0},{label:`^C`,title:`Ctrl-C — cancel`,data:``},{label:(0,Q.jsx)(Im,{size:lw}),title:`Return — confirm the selection`,data:`\r`,key:`enter`}],fw=[{mod:`ctrl`,label:`Ctrl`},{mod:`alt`,label:`Alt`},{mod:`shift`,label:`Shift`}],pw={off:``,once:`next`,lock:`lock`},mw=(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 hw({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:[],f=e.keyHints??[],p=e=>{let t=lt(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)(Y,{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:[re(e.key),` `,(0,Q.jsx)(`span`,{className:`key-hint-verb`,children:e.verb})]},`hint:${e.key}`)};return(0,Q.jsxs)(`div`,{className:`keys`,children:[f.filter(e=>e.key!==`shift+tab`).map(p),dw(cr(t,e.backend)).map((e,t)=>(0,Q.jsx)(Y,{title:e.title,"aria-label":e.title,onPointerDown:e.nav&&!a?uw:$,onClick:()=>e.key?n.chord.sendKey(e.key,e.data):o(e.data),children:e.label},t)),fw.map(({mod:e,label:t})=>{let r=n.chord.mods[e];return(0,Q.jsxs)(Y,{className:`mod-key${r===`off`?``:` active`}`,title:mw(t,r),"aria-label":mw(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:pw[r]})]},e)}),hi(t,e.backend)&&(0,Q.jsxs)(Y,{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)(Mm,{size:lw}),` Keys`]}),(0,Q.jsxs)(Y,{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)(qm,{size:lw}),` CLI`]}),f.filter(e=>e.key===`shift+tab`).map(p)]})}function gw(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 Eo(e).catch(()=>null);t&&n&&n.value.updatedAt!==i.current&&(i.current=n.value.updatedAt,r(n.value.turns))};return n().then(()=>Xo(e,!0)).catch(()=>void 0).then(n),()=>{t=!1}},[e,t]),n}function _w({sessionId:e,refreshKey:t,busy:n,turnStartedAt:r,nextTurn:i,usdPerWeekPct:a,weekIncl:o,weekRefused:s,onOpenCost:c,chipOnly:l}){let u=gw(e,t),[d,f]=(0,Z.useState)(()=>Ot(G.termCostOpen)),p=(0,Z.useMemo)(()=>wr(u??[]),[u]),m=(0,Z.useMemo)(()=>tn(u??[]),[u]);if(!u||!m)return null;let h=Lo(m,n,r);return(0,Q.jsx)(Ba,{className:`tcs`,bodyClass:`tcs-body`,growsUp:!0,t:m,which:h,open:d&&!l,onToggle:()=>{let e=!d;J(e?`action:term.cost.open`:`action:term.cost.close`),_t(G.termCostOpen,e),f(e)},onChip:l&&c?()=>{J(`action:term.cost`),c()}:void 0,slots:p,agentsSoFar:Yp(u,m.id),usdPerWeekPct:a,weekIncl:o,weekRefused:s??null,onOpen:c,trackId:`action:term.cost`,next:h===`last`&&m.id===u[u.length-1]?.id?te(i):null,why:!0})}var vw=e=>e.onSessionScreen&&e.typingRoom&&e.composeFocused;function yw(e){let t=vw(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 bw(e){let{chromeHidden:t}=yw(e),n=!t;return{fullScreen:n,typingPeek:vw(e)?!n:e.typingPeek}}var xw=40;function Sw(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-xw}}var Cw=16,ww=e=>`${e} line${e>1?`s`:``}`;function Tw(e){return ii(e.join(`
|
|
19
|
+
`))?(X(`quoted ${ww(e.length)} into compose`),!0):!1}async function Ew(e){try{await navigator.clipboard.writeText(e.join(`
|
|
20
|
+
`)),X(`copied ${ww(e.length)}`)}catch{X(`clipboard unavailable (needs https) — quote puts the lines in compose instead`)}}function Dw({at:e,onPick:t,onCancel:n}){let r=(0,Z.useRef)(null);return Pl(!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)(Y,{onClick:t,children:[(0,Q.jsx)(ng,{size:Cw}),` pick lines`]}),(0,Q.jsxs)(Y,{onClick:()=>{n(),gi()},children:[(0,Q.jsx)(Ih,{size:Cw}),` answer list`]}),(0,Q.jsxs)(Y,{onClick:n,children:[(0,Q.jsx)(wm,{size:Cw}),` select text`]}),(0,Q.jsxs)(Y,{onClick:()=>{window.getSelection()?.removeAllRanges(),n()},children:[(0,Q.jsx)(Jh,{size:Cw}),` cancel`]})]})}function Ow({count:e,off:t,hint:n,lines:r,onStop:i}){return Pl(!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)(Y,{onClick:()=>{Tw(r())&&i()},children:[(0,Q.jsx)(Mg,{size:Cw}),` quote`]}),(0,Q.jsxs)(Y,{onClick:()=>void Ew(r()),children:[(0,Q.jsx)(mg,{size:Cw}),` copy`]}),(0,Q.jsxs)(Y,{title:`copy with this session's reference — to paste into another session`,onClick:()=>void xr(r().join(`
|
|
21
|
+
`)),children:[(0,Q.jsx)(Fm,{size:Cw}),` copy + ref`]}),(0,Q.jsxs)(Y,{onClick:()=>{let e=r();i(),gi(e)},children:[(0,Q.jsx)(Ih,{size:Cw}),` answer`]})]}),(0,Q.jsxs)(Y,{onClick:i,children:[(0,Q.jsx)(Jh,{size:Cw}),` `,e?`cancel`:`done`]})]})}function kw(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 Aw=150;function jw(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 Mw(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?jw(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,Aw),()=>clearTimeout(d.current)},[a,t]),(0,Z.useEffect)(()=>{if(!a)return;let e=()=>{clearTimeout(d.current),d.current=window.setTimeout(f,Aw)};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=>{J(`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)(Sm,{size:Math.max(10,x.rowH-5),strokeWidth:3})})},t)})}):null,w=r&&(0,Q.jsx)(Dw,{at:r,onPick:()=>m(r.row),onCancel:g}),T=a&&(0,Q.jsx)(Ow,{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 Nw=`.tr-body .tr-p, .tr-body .tr-list > li, .tr-body .tr-h, .tr-body .tr-quote, .tr-body .tr-code`,Pw=`tpick`;function Fw(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 Iw(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[Pw]},[]),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 kw(t,(e,t,n)=>{if(l.current)return;let r=n instanceof Element?n.closest(Nw):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(Nw):null;n&&t.contains(n)&&(e.preventDefault(),e.stopPropagation(),c(e=>e.some(e=>e.el===n)?(delete n.dataset[Pw],e.filter(e=>e.el!==n)):(n.dataset[Pw]=`1`,[...e,{el:n,text:Fw(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=>{J(`action:readpick.start`),window.getSelection()?.removeAllRanges(),i(null),e&&(e.dataset[Pw]=`1`),c(e?[{el:e,text:Fw(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)(Dw,{at:r,onPick:()=>p(r.el),onCancel:f}),a&&(0,Q.jsx)(Ow,{count:s.length,off:h,hint:`tap paragraphs or list items to pick them`,lines:m,onStop:d})]})}}function Lw(e,t){let[n,r]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(!t)return;let n=!0;return Eo(e).then(t=>{n&&r(t?{id:e,savedAt:t.savedAt}:null)}).catch(()=>{n&&r(null)}),()=>{n=!1}},[e,t]),t&&n?.id===e?n.savedAt:null}function Rw(e,t,n){return e<=1||t<=0||n<=0?e:Math.max(1,e-Math.floor(t/n))}function zw(e,t,n){return Math.max(0,e-t)*n}var Bw={x:0,y:0},Vw=40,Hw=8,Uw=16,Ww=12,Gw=4,Kw=350;function qw(){let e=gt(G.termCornerPos,null);if(!e||!Number.isFinite(e.x)||!Number.isFinite(e.y))return Bw;let t=Number.isInteger(e.cols)&&e.cols>=1?e.cols:void 0;return{x:e.x,y:e.y,...t?{cols:t}:{}}}function Jw(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-Hw-(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 Yw(e){let t=(0,Z.useRef)(null),[n,r]=(0,Z.useState)(qw),i=(0,Z.useRef)(n);i.current=n;let a=(0,Z.useRef)(null),o=(0,Z.useRef)(0),s=(0,Z.useRef)(Vw),c=(0,Z.useCallback)(()=>{let e=t.current;if(!e)return;let n=Jw(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-Hw-n.getBoundingClientRect().right,a=t-Uw-e.clientX-i;s.current=Math.max(Ww,a/(r-.5))}let l=s.current,u=o.cols?Math.min(o.cols,r):r,d={x:o.x+zw(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)<Gw)return;n.moved=!0;let l={x:n.base.x+s,y:n.base.y+c},u=o.offsetParent,d=u?u.getBoundingClientRect().right-Hw-(o.getBoundingClientRect().right-i.current.x):l.x,f=Rw(n.n,l.x-d,n.step),p=Jw(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){ht(G.termCornerPos,i.current);return}let r=Date.now();r-o.current<Kw?(o.current=0,p(),e(!0)):(o.current=r,e(!1))},f=()=>{a.current=null},p=()=>{r(Bw),ht(G.termCornerPos,Bw)},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 Xw(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:Sv(e)}function Zw(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 Qw=`#root > .ws-panel, [role=dialog], .bl-modal-backdrop`;function $w(e,t,n,r){let i=i=>{Xw(i,Zw(i.target))!=null&&e.setTimeout(()=>{if(r())return;let e=Xw(i,Zw(i.target));e!=null&&(t(e),n())},0)};return e.addEventListener(`keydown`,i),()=>e.removeEventListener(`keydown`,i)}var eT=16;function tT({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=Yw(e=>X(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?El:Ks,w=r?jf:dd,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)(Y,{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)(hh,{size:eT})}),(0,Q.jsx)(ul,{iconSize:eT}),!n&&l&&(0,Q.jsxs)(Y,{className:`term-zoom-outline`,"data-hint":`toolbar:outline`,onPointerDown:$,"aria-label":`outline`,title:`outline — where you are in this session${Lx(Ix(t))}`,onClick:l,children:[(0,Q.jsx)(jg,{size:eT}),Ix(t)==null?null:(0,Q.jsx)(`span`,{className:`term-zoom-count`,children:Ix(t)})]}),!n&&o(t,`transcript`)&&!(t.cliSetup&&t.running)&&(0,Q.jsx)(Y,{"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:()=>{J(`action:read.toggle`),a(!i)},children:i?(0,Q.jsx)(qm,{size:eT}):(0,Q.jsx)(jm,{size:eT})}),!n&&!Gr(c.backends,t.backend)&&(()=>{let e=Uy(t),n=Wy(t.ultracode)===`on`,r=`model, effort and mode${e?` — now ${Fy(e)}`:``}${n?` — ultracode on`:``}`;return(0,Q.jsxs)(Y,{ref:p,className:[u&&`active`,(e||n)&&`mw-badged`].filter(Boolean).join(` `),"data-hint":`term.modelwheel`,onPointerDown:$,"aria-label":r,"aria-expanded":u,title:r,onClick:()=>{J(`action:modelwheel.open`),d(e=>!e)},children:[(0,Q.jsx)(vm,{size:eT}),e&&(0,Q.jsx)(`span`,{className:`mw-badge`,children:(0,Q.jsx)(JC,{mode:e,size:12})}),n&&(0,Q.jsx)(`span`,{className:`mw-badge`,children:(0,Q.jsx)(pm,{size:12,"aria-hidden":!0})})]})})(),x&&(0,Q.jsx)(wn,{smaller:E,bigger:D,onZoom:w,what:T,subject:`the ${T}`,smallerHint:O,biggerHint:k,endClassName:`term-zoom-px muted`,iconSize:eT}),(0,Q.jsx)(Y,{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=bw(_);J(e.fullScreen?`action:fullscreen.on`:`action:fullscreen.off`),h(e.fullScreen),g(e.typingPeek)},children:m?(0,Q.jsx)(Yh,{size:eT}):(0,Q.jsx)(Uh,{size:eT})})]}),u&&!n&&!Gr(c.backends,t.backend)&&(0,Q.jsx)($C,{cur:t,backends:c.backends,canSlash:o(t,`slash`),submitInput:c.submitInput,relaunch:c.relaunch,liveAsk:c.liveAsk,anchor:p,onClose:()=>d(!1)})]})}function nT(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:f,transportKnown:p,setActiveId:m,closeSession:h,openOutline:g}=e,{pendingEntry:_}=a,{status:v,connVisible:y,send:b}=r,{tailscaleIp:S}=r.info,{termRef:C,geomRef:w,buffers:T,lastPtyAt:E,ptyTail:D,exitedRef:O,staleAt:k,writeSeq:A,termNonce:ee,readMode:j,setView:M,readerCmd:N,outlineJump:te,transcriptNonce:P}=i,F=a.entries,{answerPrompt:I,retryPendingCreate:L,submitInput:R}=a,{cliMode:z,sendInput:B,focusPipe:V}=o,[ne,H]=(0,Z.useState)(!1),{sessionCan:U,openCwd:re,runForkRequest:W}=s,{dismissedReply:ie,setDismissedReply:ae}=c,[oe,se]=(0,Z.useState)(``),ce=Gi(),le=lu(),ue=Mi(),de=Mw(C,A,t.id),fe=t.prompt?F.filter(e=>e.answer?.fingerprint===x(t.prompt)&&e.status!==`failed`).map(e=>({label:e.answer.label})):[],pe=(e,n,r,i,a)=>I(t,e,n,r,i,a),me=Lw(t.id,!u&&!n&&v!==`open`&&y&&!(T.current.get(t.id)??[]).some(e=>e.length>0)),he=(0,Z.useRef)(null),ge=Iw(he,t.id,u),_e=j&&!!t.cliSetup&&t.running,ve=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{_e?ve.current!==t.id&&(ve.current=t.id,X(_u(l,t.backend))):ve.current===t.id&&(ve.current=null,j&&t.running&&!t.cliSetup&&X(Zt(l,t.backend)))},[_e,t.id,t.running,t.cliSetup,t.backend,l,j]);let ye=(0,Z.useRef)(B);ye.current=B,(0,Z.useEffect)(()=>u||n?void 0:$w(window,e=>ye.current(e),()=>C.current?.focus(),()=>!!document.querySelector(Qw)),[u,n,C]);let be=q(`toolsMode`),xe=q(`txtScale`),Se=q(`rZoom`),Ce=e=>(0,Q.jsx)(tT,{zoom:e,active:t,pending:n,readerShown:u,readMode:j,setView:M,sessionCan:U,chrome:c,openOutline:g,wheel:{backends:l,submitInput:R,relaunch:s.relaunch,liveAsk:r.liveAsk}});return l_(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)(lh,{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)(Dd,{className:`toolbar-cants`,cants:Zd(l,bp(t),{hiddenSlash:d})}),!n&&Ds(l,t.backend)&&(0,Q.jsx)(`div`,{className:`act-cants toolbar-cants`,children:(0,Q.jsxs)(`span`,{className:`act-cant`,children:[(0,Q.jsx)(qm,{size:11}),` `,Ds(l,t.backend)]})}),(0,Q.jsxs)(`div`,{className:`term-wrap`,children:[y&&v!==`open`&&(0,Q.jsxs)(`div`,{className:`conn-banner floating conn-${v}`,children:[v===`closed`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ch,{size:12}),` connection lost — reconnecting…`]}):`connecting…`,S?` · ${S}`:``]}),u?(0,Q.jsxs)(`div`,{ref:he,className:`tr-zoom`,style:{"--ui-font":String(tp(xe,Se))},children:[(0,Q.jsx)(Kp,{sessionId:t.id,refreshKey:P,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:v!==`open`},onShowCli:()=>M(!1),cliPeek:n?void 0:(e,n)=>(0,Q.jsx)(WC,{chunks:T.current.get(t.id)??[],writeSeq:A,cols:w.current.cols,rows:w.current.rows,leaving:e,onGone:n,onOpen:()=>{J(`action:read.peekToCli`),M(!1)}}),onAnswer:pe,onStop:()=>B(`\x1B`),queuedAnswers:fe,cmd:N??void 0,toolsMode:be,fork:U(t,`fork`)?{online:v===`open`,hasId:!!Li(t),run:e=>void W(t,e)}:void 0,jumpTo:te??void 0,onOpenCost:$n,nextTurn:ot(t.contextSpark,{lastTurnAt:t.lastTurnAt,turnActive:t.turnActive,now:Date.now()}),usdPerWeekPct:ce,weekIncl:le,weekRefused:ue,onOpenShells:()=>os(t),files:f?{repoId:f,url:(e,t,n)=>{let r=va.artifactUrl(f,e);return t?Na(r,t,n):r},open:e=>Fn(f,e),known:p,toShell:e=>Jr(t,e)}:void 0,onToast:X},t.id),ge.chrome]}):(()=>{let e=T.current.get(t.id)??[],r=e.some(e=>e.length>0),i=k.get(t.id),s=v!==`open`&&y,c=!t.running||v!==`open`&&O.current.has(t.id),u=i??E.current.get(t.id),d=n?`pending`:c?`ended`:s?`offline`:r?null:`empty`,f=!r;return(0,Q.jsxs)(`div`,{className:`term-stage`,children:[(0,Q.jsx)(`div`,{className:`term-canvas${i==null?``:` stale`}`,onClick:z?V:void 0,children:(0,Q.jsx)(BC,{ref:C,pending:e,writeSeq:A,onInput:B,onResize:(e,r)=>{w.current={cols:e,rows:r},n||b({t:`session.resize`,id:t.id,cols:e,rows:r})},linkUp:v===`open`,onScreen:e=>xp(t.id,e),onCursorLine:o.noteCursorLine,onReachBack:()=>{J(`action:scrollback.reachback`),co()},onScrollStalled:()=>X(`no new output from that scroll — “scrollback” reads this device's own copy`),onLongPress:de.onLongPress,children:de.gutter},`${t.id}:${ee}`)}),Ce(!f),de.chrome,ne&&!n&&hi(l,t.backend)&&!GC(t.prompt,t.running)&&(0,Q.jsx)(cw,{sendInput:B,onClose:()=>H(!1)}),GC(t.prompt,t.running)&&(0,Q.jsx)(`div`,{className:`term-answer`,"data-box":`trust`,children:(0,Q.jsx)(vu,{prompt:t.prompt,queued:fe,suggestion:t.suggestion,onAnswer:pe,ev:`term.trust`})}),d&&(0,Q.jsx)(`div`,{className:`term-overlay ${f?`as-card`:`as-chip`} term-overlay-${d}${d===`pending`&&_?.status===`failed`?` failed`:``}`,children:(0,Q.jsxs)(`div`,{className:`term-overlay-box`,children:[d===`empty`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_m,{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)(um,{size:16}),(0,Q.jsxs)(`span`,{children:[`offline — `,r?(0,Q.jsxs)(Q.Fragment,{children:[`output as of `,u?Rp(u):`the last connection`]}):(0,Q.jsx)(Q.Fragment,{children:`nothing cached for this session yet`})]}),f&&(0,Q.jsx)(`span`,{className:`term-overlay-hint`,children:`It reappears the moment the tunnel is back. Anything you send is queued, not lost.`}),f&&me!=null&&(0,Q.jsxs)(`span`,{className:`term-overlay-hint`,children:[`The conversation was saved on this device `,Rp(me),` — the reader shows it.`]}),(So(t.id)||f&&me!=null)&&(0,Q.jsxs)(`span`,{className:`term-overlay-acts`,children:[f&&me!=null&&(0,Q.jsxs)(Y,{title:`the conversation as saved on this device`,onClick:()=>{J(`action:read.offline`),M(!0)},children:[(0,Q.jsx)(jm,{size:14}),` read it`]}),So(t.id)&&(0,Q.jsxs)(Y,{title:`earlier output, read from this device (pan up on the terminal does the same)`,onClick:co,children:[(0,Q.jsx)(xg,{size:14}),` scrollback`]})]})]}),d===`pending`&&(()=>{let e=_?.status===`failed`,t=_?.status===`pending`,n=!t&&v===`open`&&_?a.blocked.get(_.ackId):void 0,r=e&&_?.op?.t===`session.create`?_.op:null,i=r&&!r.resume?Rt(l,r.launch?.backend):[];return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(Ch,{size:16}):(0,Q.jsx)(_m,{size:16,className:`spin`}),(0,Q.jsx)(`span`,{children:e?(0,Q.jsxs)(Q.Fragment,{children:[`the session was not started — `,_?.reason||`the desktop refused it`]}):_?n?(0,Q.jsxs)(Q.Fragment,{children:[`not opened yet — `,ut(n)]}):t||v===`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&&i.length>0?`Start it with another program this desktop has instead? Anything typed here goes with it.`:e?`Anything typed here is still in the queue and can be re-aimed from ${Td.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:[i.map(e=>(0,Q.jsxs)(Y,{title:`open this session with ${e.label} instead`,onClick:()=>L(e.id),children:[(0,Q.jsx)(Hm,{size:14}),` use `,e.label]},e.id)),e&&(0,Q.jsxs)(Y,{title:`try this open again`,onClick:()=>L(),children:[(0,Q.jsx)(qh,{size:14}),` try again`]}),(0,Q.jsxs)(Y,{title:e?`back to the launcher`:`stop waiting — the open stays queued and can be dropped in ${Td.activity}`,onClick:()=>m(null),children:[(0,Q.jsx)(gm,{size:14}),` back`]})]})]})})(),d===`ended`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Jh,{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)(Y,{title:`reopen this session — ${mu(!!Li(t))}`,onClick:()=>re(t.cwd,t.title,!0,`continue`,{model:t.model,effort:t.effort,permissionMode:t.permissionMode,backend:t.backend},Li(t)),children:[(0,Q.jsx)(qh,{size:14}),` reopen`]}),(0,Q.jsxs)(Y,{title:`remove this session from the list`,onClick:()=>{h(t),m(null)},children:[(0,Q.jsx)(Jh,{size:14}),` close`]})]})]})]})})]})})(),u&&Ce(),!n&&(0,Q.jsx)(dr,{session:t,readMode:j})]})]}),!n&&!u&&U(t,`transcript`)&&(0,Q.jsx)(_w,{sessionId:t.id,refreshKey:P,busy:t.hooked?!!t.turnActive:t.running&&!t.idle,turnStartedAt:t.turnStartedAt,nextTurn:ot(t.contextSpark,{lastTurnAt:t.lastTurnAt,turnActive:t.turnActive,now:Date.now()}),usdPerWeekPct:ce,weekIncl:le,weekRefused:ue,onOpenCost:$n,chipOnly:c.chromeHidden},t.id),(0,Q.jsx)(DC,{session:t,onSendLogin:()=>o.runHeaderCmd(ea)}),!t.login&&Tc(t)&&(0,Q.jsx)(mf,{links:t.links??[],awaitingCode:!!t.awaitingCode,onOpen:Qd,onCopy:e=>void is(e),onCopyCode:Po,onPasteCode:()=>void bl(t.id),onLogins:Hd}),!t.prompt&&t.suggestion?.reply!=null&&t.suggestion.reply!==ie&&(0,Q.jsx)(vd,{suggestion:t.suggestion,onSend:e=>{R(t.id,t.cwd,e,`prompt`),ae(t.suggestion.reply)},onDismiss:()=>ae(t.suggestion.reply)},t.id+`:`+t.suggestion.reply),!t.prompt&&t.running&&!t.turnActive&&t.cliSuggestion&&t.cliSuggestion!==oe&&(t.suggestion?.reply==null||t.suggestion.reply===ie)&&(0,Q.jsx)(Qt,{text:t.cliSuggestion,onSend:e=>{R(t.id,t.cwd,e,`prompt`),se(e)},onDismiss:()=>se(t.cliSuggestion),ev:`term`}),!n&&!u&&(0,Q.jsx)(hw,{active:t,backends:l,compose:o,keysOpen:ne,setKeysOpen:H}),(0,Q.jsx)(al,{sessionId:t.id}),!n&&(0,Q.jsx)(Jo,{session:t,readMode:u})]})}function rT(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,ee=a.entries,{pendingEntry:j,outboxRef:M,holdWall:N,isPendingId:te,sendQueuedNow:P,editQueued:F,toggleHoldQueued:I,handToDesktop:L,removeQueued:R}=a,{uploading:z,parking:B,upProg:V,uploadPending:ne,uploadRowLinger:H,cancelUploads:U}=a.uploads,{chromeHidden:re,fullMode:W}=c,ie=p?.id??null,ae=Ip(),oe=wp(),se=Il(),ce=q(`autoSend`),le=q(`confirmQueue`),ue=mc(s.sessionCan(t,`slash`)),de={active:t,pending:n,status:E,activeRepo:p,toolbarCfg:oe,pendingStars:x,toggleStar:S,pendingFollowUps:C,toggleFollowUp:w,setOverlay:y,runToolbar:b,backends:l};return(0,Q.jsx)(jd,{children:(0,Q.jsxs)(`div`,{className:`screen${re?` typing`:``}${W?` fullscreen`:``}${f?` reading`:``}`,children:[(0,Q.jsx)(CC,{active:t,sessions:u,pending:n,pendingEntry:j,status:E,liveSend:D,backends:l,sessionCan:s.sessionCan,sessionRepoName:_,repoForCwd:g,setActiveId:v,setOverlay:y,removeQueued:R,closeSession:T,chrome:c,hdrShown:l_(t.id)?[]:ue.shown,headerCmds:ae,runHeaderCmd:o.runHeaderCmd,refreshTerminal:i.refreshTerminal,toolbar:de}),(0,Q.jsx)(EC,{activeId:t.id}),(0,Q.jsx)(rl,{httpsUrl:r.info.httpsUrl}),(0,Q.jsx)(La,{update:d,liveAsk:O,liveSend:D}),!n&&(0,Q.jsx)(Bs,{active:t,update:d,relaunch:s.relaunch}),(0,Q.jsx)(nT,{active:t,pending:n,conn:r,term:i,q:a,compose:o,launch:s,chrome:c,backends:l,readerShown:f,hiddenSlash:ue.hiddenSlash,activeRepoId:ie,transportKnown:m,setActiveId:v,closeSession:T,openOutline:(oe.pinned??[]).includes(`outline`)?()=>b(`outline`):void 0}),(0,Q.jsx)(vS,{active:t,outbox:ee,outboxRef:M,online:E===`open`,holdWall:N,isPendingId:te,sendQueuedNow:P,editQueued:F,removeQueued:R,toggleHoldQueued:I,handToDesktop:L,liveSend:D,setOverlay:y,intents:e.intents}),(0,Q.jsx)(cv,{q:a,status:E,reconnectAsk:k,setReconnectAsk:A,autoSend:ce,confirmQueue:le,pullRecords:se,setOverlay:y,stripSessionId:t.id}),(0,Q.jsx)(dS,{api:o,active:t,sessions:u,outbox:ee,online:E===`open`,repoForCwd:g,uploads:{uploading:z,parking:B,upProg:V,uploadPending:ne,uploadRowLinger:H,cancelUploads:U},activeRepoId:ie,pickImageFor:jl,pickFileFor:Wl,visibleBacklogItems:h,setOverlay:y}),(0,Q.jsx)(Zx,{})]})})}function iT(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}=yw(_);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=()=>Sw(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}}var aT=`<?xml version="1.0" encoding="UTF-8"?>
|
|
22
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
23
|
+
<defs>
|
|
24
|
+
<clipPath id="aclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
25
|
+
<linearGradient id="asky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0A1B28"/><stop offset="1" stop-color="#10324A"/></linearGradient>
|
|
26
|
+
<linearGradient id="asea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0F5A66"/><stop offset="1" stop-color="#061219"/></linearGradient>
|
|
27
|
+
<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>
|
|
28
|
+
<radialGradient id="aglow" cx=".74" cy=".62" r=".42">
|
|
29
|
+
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.34"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
30
|
+
<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>
|
|
31
|
+
<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>
|
|
32
|
+
<mask id="arm"><rect y="330" width="512" height="182" fill="url(#afade)"/></mask>
|
|
33
|
+
</defs>
|
|
34
|
+
<g clip-path="url(#aclip)">
|
|
35
|
+
<rect width="512" height="512" fill="url(#asky)"/>
|
|
36
|
+
<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"/>
|
|
37
|
+
<rect width="512" height="512" fill="url(#aglow)"/>
|
|
38
|
+
<rect y="330" width="512" height="182" fill="url(#asea)"/>
|
|
39
|
+
<path d="M40,172 L4,168 M44,292 L10,296" stroke="#E9F4F2" stroke-width="4" stroke-linecap="round" opacity=".22"/>
|
|
40
|
+
|
|
41
|
+
<g transform="rotate(7 286 228)">
|
|
42
|
+
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#awarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
43
|
+
<path d="M272,228 L84,228" stroke="url(#awarm)" stroke-width="22" stroke-linecap="round"/>
|
|
44
|
+
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#awarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
45
|
+
<path d="M140,160 L270,228" stroke="#fff" stroke-opacity=".28" stroke-width="7" stroke-linecap="round"/>
|
|
46
|
+
<circle cx="250" cy="228" r="6.5" fill="#0A1B28" opacity=".5"/>
|
|
47
|
+
</g>
|
|
48
|
+
|
|
49
|
+
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
50
|
+
<animate attributeName="opacity" values="1;1;.12;.12" keyTimes="0;.5;.56;1" dur="1.1s" repeatCount="indefinite"/>
|
|
51
|
+
</rect>
|
|
52
|
+
<g mask="url(#arm)"><g clip-path="url(#arip)" opacity="0.4"><g transform="translate(0,660) scale(1,-1)">
|
|
53
|
+
|
|
54
|
+
<g transform="rotate(7 286 228)">
|
|
55
|
+
<path d="M128,146 L286,228 L128,310" fill="none" stroke="#F5A93F" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
56
|
+
<path d="M272,228 L84,228" stroke="#F5A93F" stroke-width="22" stroke-linecap="round"/>
|
|
57
|
+
<path d="M92,204 L104,228 L92,252" fill="none" stroke="#F5A93F" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
58
|
+
|
|
59
|
+
</g>
|
|
60
|
+
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
61
|
+
</rect></g></g></g>
|
|
62
|
+
<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"/>
|
|
63
|
+
</g></svg>
|
|
64
|
+
`,oT=`<?xml version="1.0" encoding="UTF-8"?>
|
|
65
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
66
|
+
<defs>
|
|
67
|
+
<clipPath id="sclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
68
|
+
<linearGradient id="ssky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0A1B28"/><stop offset="1" stop-color="#10324A"/></linearGradient>
|
|
69
|
+
<linearGradient id="ssea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0F5A66"/><stop offset="1" stop-color="#061219"/></linearGradient>
|
|
70
|
+
<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>
|
|
71
|
+
<radialGradient id="sglow" cx=".74" cy=".62" r=".42">
|
|
72
|
+
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.34"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
73
|
+
<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>
|
|
74
|
+
<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>
|
|
75
|
+
<mask id="srm"><rect y="330" width="512" height="182" fill="url(#sfade)"/></mask>
|
|
76
|
+
</defs>
|
|
77
|
+
<g clip-path="url(#sclip)">
|
|
78
|
+
<rect width="512" height="512" fill="url(#ssky)"/>
|
|
79
|
+
|
|
80
|
+
<rect width="512" height="512" fill="url(#sglow)"/>
|
|
81
|
+
<rect y="330" width="512" height="182" fill="url(#ssea)"/>
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
<g transform="rotate(7 286 228)">
|
|
85
|
+
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#swarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
86
|
+
<path d="M272,228 L84,228" stroke="url(#swarm)" stroke-width="22" stroke-linecap="round"/>
|
|
87
|
+
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#swarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
88
|
+
|
|
89
|
+
</g>
|
|
90
|
+
|
|
91
|
+
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
92
|
+
</rect>
|
|
93
|
+
|
|
94
|
+
</g></svg>
|
|
95
|
+
`,sT=`<?xml version="1.0" encoding="UTF-8"?>
|
|
96
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
97
|
+
<defs>
|
|
98
|
+
<clipPath id="lclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
99
|
+
<linearGradient id="lsky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#F4F8F7"/><stop offset="1" stop-color="#E3EFEE"/></linearGradient>
|
|
100
|
+
<linearGradient id="lsea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#BFDDDB"/><stop offset="1" stop-color="#93C1BF"/></linearGradient>
|
|
101
|
+
<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>
|
|
102
|
+
<radialGradient id="lglow" cx=".74" cy=".62" r=".42">
|
|
103
|
+
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.22"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
104
|
+
<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>
|
|
105
|
+
<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>
|
|
106
|
+
<mask id="lrm"><rect y="330" width="512" height="182" fill="url(#lfade)"/></mask>
|
|
107
|
+
</defs>
|
|
108
|
+
<g clip-path="url(#lclip)">
|
|
109
|
+
<rect width="512" height="512" fill="url(#lsky)"/>
|
|
110
|
+
|
|
111
|
+
<rect width="512" height="512" fill="url(#lglow)"/>
|
|
112
|
+
<rect y="330" width="512" height="182" fill="url(#lsea)"/>
|
|
113
|
+
<path d="M40,172 L4,168 M44,292 L10,296" stroke="#0A1620" stroke-width="4" stroke-linecap="round" opacity=".22"/>
|
|
114
|
+
|
|
115
|
+
<g transform="rotate(7 286 228)">
|
|
116
|
+
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#lwarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
117
|
+
<path d="M272,228 L84,228" stroke="url(#lwarm)" stroke-width="22" stroke-linecap="round"/>
|
|
118
|
+
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#lwarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
119
|
+
<path d="M140,160 L270,228" stroke="#fff" stroke-opacity=".28" stroke-width="7" stroke-linecap="round"/>
|
|
120
|
+
<circle cx="250" cy="228" r="6.5" fill="#0A1B28" opacity=".5"/>
|
|
121
|
+
</g>
|
|
122
|
+
|
|
123
|
+
<rect x="318" y="302" width="128" height="28" rx="9" fill="#EC6F55">
|
|
124
|
+
</rect>
|
|
125
|
+
<g mask="url(#lrm)"><g clip-path="url(#lrip)" opacity="0.45"><g transform="translate(0,660) scale(1,-1)">
|
|
126
|
+
|
|
127
|
+
<g transform="rotate(7 286 228)">
|
|
128
|
+
<path d="M128,146 L286,228 L128,310" fill="none" stroke="#F5A93F" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
129
|
+
<path d="M272,228 L84,228" stroke="#F5A93F" stroke-width="22" stroke-linecap="round"/>
|
|
130
|
+
<path d="M92,204 L104,228 L92,252" fill="none" stroke="#F5A93F" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
131
|
+
|
|
132
|
+
</g>
|
|
133
|
+
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
134
|
+
</rect></g></g></g>
|
|
135
|
+
<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"/>
|
|
136
|
+
</g></svg>
|
|
137
|
+
`,cT=`<?xml version="1.0" encoding="UTF-8"?>
|
|
138
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
139
|
+
<defs>
|
|
140
|
+
<clipPath id="slclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
141
|
+
<linearGradient id="slsky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#F4F8F7"/><stop offset="1" stop-color="#E3EFEE"/></linearGradient>
|
|
142
|
+
<linearGradient id="slsea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#BFDDDB"/><stop offset="1" stop-color="#93C1BF"/></linearGradient>
|
|
143
|
+
<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>
|
|
144
|
+
<radialGradient id="slglow" cx=".74" cy=".62" r=".42">
|
|
145
|
+
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.22"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
146
|
+
<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>
|
|
147
|
+
<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>
|
|
148
|
+
<mask id="slrm"><rect y="330" width="512" height="182" fill="url(#slfade)"/></mask>
|
|
149
|
+
</defs>
|
|
150
|
+
<g clip-path="url(#slclip)">
|
|
151
|
+
<rect width="512" height="512" fill="url(#slsky)"/>
|
|
152
|
+
|
|
153
|
+
<rect width="512" height="512" fill="url(#slglow)"/>
|
|
154
|
+
<rect y="330" width="512" height="182" fill="url(#slsea)"/>
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
<g transform="rotate(7 286 228)">
|
|
158
|
+
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#slwarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
159
|
+
<path d="M272,228 L84,228" stroke="url(#slwarm)" stroke-width="22" stroke-linecap="round"/>
|
|
160
|
+
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#slwarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
161
|
+
|
|
162
|
+
</g>
|
|
163
|
+
|
|
164
|
+
<rect x="318" y="302" width="128" height="28" rx="9" fill="#EC6F55">
|
|
165
|
+
</rect>
|
|
166
|
+
|
|
167
|
+
</g>
|
|
168
|
+
<rect x="6" y="6" width="500" height="500" rx="108" fill="none" stroke="#0A1B28" stroke-opacity=".14" stroke-width="12"/></svg>
|
|
169
|
+
`;function lT(e){return e<64}var uT=e=>e.replace(/<\?xml[^>]*\?>/,``).replace(/<animate\b[^>]*\/>/g,``).replace(/<(animate)\b[^>]*>[\s\S]*?<\/\1>/g,``),dT=e=>`data:image/svg+xml;charset=utf-8,${encodeURIComponent(uT(e))}`,fT={dark:{full:dT(aT),small:dT(oT)},light:{full:dT(sT),small:dT(cT)}};function pT(){let[e,t]=(0,Z.useState)(Or);return(0,Z.useEffect)(()=>Vo(e=>t(e)),[]),e}function mT({size:e=32,label:t=Sd()}){let n=fT[pT()];return(0,Q.jsx)(`img`,{className:`logo`,src:lT(e)?n.small:n.full,alt:t,width:e,height:e,style:{display:`block`,width:e,height:e,flex:`0 0 auto`}})}var hT=4,gT=20;function _T(e){let t=e.querySelector(`.topbar`);if(!t)return 0;let n=[...t.children].map(e=>e.getBoundingClientRect()).filter(e=>e.height>0);if(!n.length)return 0;let r=Math.min(...n.map(e=>e.top)),i=Math.max(...n.filter(e=>e.top<r+gT).map(e=>e.bottom)),a=getComputedStyle(t);return Math.ceil(i-e.getBoundingClientRect().top+parseFloat(a.paddingBottom)+parseFloat(a.borderBottomWidth))}function vT({off:e,children:t}){let n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)({natural:0,line:0});(0,Z.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=Math.ceil(e.getBoundingClientRect().height),n=_T(e);i(e=>e.natural===t&&e.line===n?e:{natural:t,line:n})};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);let{frame:a,cap:o,capped:s,cut:c,grip:l}=Np({key:G.launcherChromeH,off:e,floorPx:r.line,showAllEvent:`action:launcherChrome.showAll`,capEvent:`action:launcherChrome.cap`}),u=c?`top shortened — tap to show all of it, or drag down for more`:`drag up to hide what is under the first line`,d=r.natural>r.line+hT;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:a,className:`sess-chrome${s?` capped`:``}`,style:s?{maxHeight:`${Math.max(o??0,r.line)}px`}:void 0,children:(0,Q.jsx)(`div`,{ref:n,children:t})}),!e&&(d||c)&&(0,Q.jsx)(`div`,{className:`sess-chrome-grip${c?` capped worded`:``}`,role:`separator`,"aria-orientation":`horizontal`,tabIndex:0,"aria-label":u,title:u,...l,children:c&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ng,{size:12,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:`shortened · tap for all of it`})]})})]})}var yT=[`queued`,`blocked`,`starting`,`running`];function bT(e){return yT.includes(e.state)&&!e.archived}function xT(e){let t=new Map;for(let n of e){if(n.trigger.kind!==`at`||n.target.kind!==`session`||!bT(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 ST(e,t){return e.some(e=>t.has(e))}var CT=Mu(null),wT=Mu(``),TT=Mu(ts()),ET=Mu(Ts()),DT=Mu(`home`),OT=Mu([]),kT=Mu(null),AT=Mu(!1),jT=Mu(!1),MT=Mu(null);vt(G.closeCustomH),vt(G.closeBy);var NT=Mu(Ot(G.closeKeepStar,!0)),PT={top:0};function FT(e){return[$t(e),e.set]}function IT(e){let{sessions:t,recent:n,closed:i,repos:a,intents:o,outbox:s,nowTick:c}=e,{hiddenRepoPaths:l,cwdInFocus:u,visibleRepos:d,hiddenRepos:f}=e.view,{focusRepo:p,setFocusRepo:m}=e.route,[h,g]=FT(CT),[_,v]=FT(wT),y=_.trim()!==``,[b,x]=FT(TT),[S,C]=FT(ET),[w,T]=FT(DT),[E,D]=FT(OT),[O,k]=FT(kT),[A,ee]=FT(AT),[j,M]=FT(jT),[N,te]=FT(MT),[P,F]=FT(NT),[I,L]=(0,Z.useState)(null),R=e=>pb(a,e),z=e=>R(e.cwd),B=e=>mb(a,e),V=e=>_b(a,e),ne=e=>vb(a,e),H=e=>yb(a,e),U=(0,Z.useMemo)(()=>t.filter(e=>!l.has(e.cwd)&&u(e.cwd)),[t,l,p,a]),re=(0,Z.useMemo)(()=>t.filter(e=>l.has(e.cwd)&&u(e.cwd)),[t,l,p,a]),W=(0,Z.useMemo)(()=>Tb(U,S,B),[U,S,a]);function ie(e,t){g(n=>n&&n.status===e&&n.repo===t?null:(J(`action:session.filter.${e}`),{status:e,repo:t}))}let ae=(e,t)=>!!h&&h.status===e&&h.repo===t,oe=(0,Z.useMemo)(()=>Ob(W,h,(t,n)=>n===`worktrees`?R(t.cwd)?.isPrimary===!1:Jt(t,n,e.backends),B).filter(e=>!y||Kb(_,[e.tabTitle,e.title,e.firstPrompt,e.lastPrompt,e.pinnedPrompt,B(e),hb(a,e),ne(e)])),[W,h,a,_,e.backends]),se=(0,Z.useMemo)(()=>kb(W,t=>sn(t,e.backends),B),[W,a,e.backends]),ce=(0,Z.useMemo)(()=>wi(t,`wait`,e.backends,e.view.cwdVisible),[t,e.backends,e.view.cwdVisible]),le=(0,Z.useMemo)(()=>wi(t,`blocked`,e.backends,e.view.cwdVisible),[t,e.backends,e.view.cwdVisible]),ue=ce.shown.length,de=(0,Z.useMemo)(()=>xT(o),[o]),fe=(0,Z.useMemo)(()=>{let t=new Map;for(let n of W)sn(n,e.backends)===`wait`&&de.has(n.id)&&t.set(B(n),!0);return t},[W,de,a,e.backends]),me=(0,Z.useMemo)(()=>ST(W.filter(t=>sn(t,e.backends)===`wait`).map(e=>e.id),de),[W,de,e.backends]),he=le.shown.length,_e=(0,Z.useMemo)(()=>Ab(se,`coding`),[se]),ve=(0,Z.useMemo)(()=>jb(W,B),[W,a]),ye=(0,Z.useMemo)(()=>Mb(W,B),[W,a]),be=(0,Z.useMemo)(()=>[...ve.values()].reduce((e,t)=>e+t,0),[ve]),xe=(0,Z.useMemo)(()=>kr(W,B),[W,a]),Se=(0,Z.useMemo)(()=>es(xe),[xe]),Ce=(0,Z.useMemo)(()=>W.filter(e=>e.shellList?.length).length,[W]),we=Wr(),Te=sr(),Ee=(0,Z.useMemo)(()=>Rb(s,o,we,e=>{let t=R(e);return t?pt(t):Tp(e)}),[s,o,a,we]),De=(0,Z.useMemo)(()=>new Map(o.map(e=>[e.id,e])),[o]);function Oe(e){x(e),ht(em,[...e])}function ke(e){J(`action:repo.collapse`);let t=new Set(b);t.has(e)?t.delete(e):t.add(e),Oe(t)}let Ae=(0,Z.useMemo)(()=>{let e=new Map;for(let t of a)e.set(pt(t),r(t));return e},[a]),je=e=>Ae.get(e)??e,Me=e=>a.find(t=>pt(t)===e&&t.isPrimary)??null,Ne=e=>d.filter(t=>pt(t)===e&&!t.isPrimary),Pe=q(`repoSort`),Fe=(0,Z.useMemo)(()=>Pe===`sessions`?Fb(W,B):void 0,[Pe,W,a]),Ie=(0,Z.useMemo)(()=>Ib(oe,d,!!h||y,B,h?.status===`worktrees`&&h.repo?[h.repo]:y&&!h?d.filter(e=>Kb(_,[pt(e),e.displayName,e.branch])).map(e=>pt(e)):[],Fe),[oe,d,h,a,_,Fe]),Le=Ie.length>0&&Ie.every(e=>b.has(e.repoName)),Re=Ie.every(e=>!b.has(e.repoName)),ze=(0,Z.useRef)(!1);function Be(e){let n=Eb(ET.get(),e,new Set(t.map(e=>e.id)));C(n),ht(Ar,n)}function Ve(){C([]),vt(Ar)}function He(e,t){if(e.pointerType===`mouse`&&e.button!==0)return;ze.current=!1;let n=e.clientX,r=e.clientY,i=window.setTimeout(()=>{i=void 0,s(),ze.current=!0,L(t),navigator.vibrate?.(15),J(`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(!I)return;let e=e=>{let t=(document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-sid]`))?.getAttribute(`data-sid`),n=t?Db(W,I,t,B):null;n&&Be(n)},t=e=>e.preventDefault(),n=()=>L(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)}},[I,W]),(0,Z.useEffect)(()=>{w===`external`&&va.external().then(D).catch(()=>D([]))},[w,e.conn.status]);let Ue=(0,Z.useMemo)(()=>E.filter(e=>u(e.cwd)),[E,p,a]);function We(e){_n()?m(e):window.open(`${location.pathname}?repo=${encodeURIComponent(e)}`,`_blank`)}function Ge(){m(null)}let Ke=Ua(o,s,c),qe=Ke.horizon,Je=pe(qe),Ye=(0,Z.useMemo)(()=>an({cuts:Ke,repoOf:e=>{let t=R(e);return t?pt(t):Tp(e)||null},now:Date.now()}),[Ke,a,c]),Xe=ge(qe),Ze=qe.unarmed>0&&qe.unarmed===qe.total,$e=Ke.kinds,et=[$e.rules?`${$e.rules} rule${$e.rules===1?``:`s`}`:``,$e.timed?`${$e.timed} on a clock in a backlog`:``].filter(Boolean).join(` · `),tt=Je?`${Td.automation.toLowerCase()} · ${et} — ${Je}${qe.unarmed&&!Ze?` · ${qe.unarmed} not armed`:``} — tap to see the ${Xe?Qe[Xe]:``} ones`:`${Td.automation.toLowerCase()} — run a prompt on its own at a time you pick (once, every week, or around a usage window)`,nt=(0,Z.useMemo)(()=>zb(s,o,{has:e=>we.has(e)||Te.has(e)}),[s,o,we,Te]),rt=nt.length,it=Il(),at=Kd(bs(it,cs())),ot=new Set(t.map(e=>e.cwd)),st=new Set(t.map(Li).filter(Boolean)),ct=e=>{let t=Li(e);return t?st.has(t):ot.has(e.cwd)},lt=n.filter(e=>!ct(e)&&l.has(e.cwd)&&u(e.cwd));return{statusFilter:h,setStatusFilter:g,toggleStatusFilter:ie,statusFilterActive:ae,textQuery:_,setTextQuery:v,textOn:y,collapsedRepos:b,persistCollapsedRepos:Oe,toggleRepoCollapsed:ke,sessionOrder:S,saveSessionOrder:Be,resetSessionOrder:Ve,dragSid:I,dragRef:ze,armRowDrag:He,tab:w,setTab:T,repoMenu:O,setRepoMenu:k,navMenu:A,setNavMenu:ee,showHidden:j,setShowHidden:M,closeAllPick:N,setCloseAllPick:te,closeKeepStar:P,setCloseKeepStar:F,repoForCwd:R,sessionRepo:z,sessionRepoName:B,sessionRepoLabel:V,sessionRowBranch:ne,sessionRowTitle:H,visibleSessions:U,hiddenSessions:re,sortedSessions:W,shownSessions:oe,repoGroups:Ie,allReposCollapsed:Le,noRepoCollapsed:Re,primaryRepo:Me,worktreesOf:Ne,shownOf:je,attentionByRepo:se,waitingTotal:ue,repliesBySession:de,waitingRepliesByRepo:fe,waitingRepliesTotal:me,blockedTotal:he,codingTotal:_e,starredByRepo:ve,starredTotal:be,flaggedByRepo:xe,flaggedTotal:Se,sessionNumbers:ye,shellsTotal:Ce,queuedByRepo:Ee,intentById:De,visibleExternal:Ue,openFocusWindow:We,clearFocus:Ge,scheduleWords:Je,scheduleLead:Xe,scheduleTitle:tt,clocksPerRepo:Ye,activityBadge:rt,activityKeys:nt,dl:at,visibleRecent:n.filter(e=>!ct(e)&&!l.has(e.cwd)&&u(e.cwd)),hiddenRecent:lt,reopenable:i.filter(e=>!ct(e)&&u(e.cwd)),hiddenCount:f.length+re.length+lt.length}}var LT=16,RT=(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:()=>bo(e.id),children:[(0,Q.jsx)(mm,{size:14}),e.outboxCount]}),vi(e)&&(0,Q.jsxs)(`button`,{className:`row-act count`,title:Jp(e),onClick:()=>t(e.id),children:[(0,Q.jsx)(xm,{size:14}),e.changedCount>0&&e.changedCount,za(e)&&(0,Q.jsx)(`span`,{className:`git-ab`,children:za(e)})]})]}):null;function zT({p:e,m:t,s:n,repoName:r,headRepoId:i}){let a=Yg()(n),{backends:o,openGitFor:s}=e,{status:c,liveSend:l}=e.conn,{lastVisitedId:u}=e.route,{attach:d,openReader:f}=e.term,{sessionCan:p}=e.launchCore,{pendingStars:m,toggleStar:h,pendingFollowUps:g,toggleFollowUp:_,closeSession:v}=e.verbs,{dragSid:y,dragRef:b,armRowDrag:x,sessionRowBranch:S,sessionRepoName:C,sessionRepoLabel:w,sessionRowTitle:T,sessionRepo:E,repliesBySession:D,sessionNumbers:O}=t,k=Vi(),A={isOn:e=>t.statusFilterActive(e),toggle:e=>t.toggleStatusFilter(e)},ee=w(n),j=(()=>{let e=Jd(n);return!!(e.first||e.now)})(),M=j?``:n.title&&n.title!==ee&&n.title!==r?n.title:``;return(0,Q.jsxs)(`div`,{className:`row-wrap${n.id===u?` row-recent`:``}${n.id===y?` row-dragging`:``}`,style:Cu(r),"data-sid":n.id,children:[(0,Q.jsxs)(`button`,{className:`row grow${n.id===y?` dragging`:``}`,"data-nohint":!0,title:`tap to open · press and hold to drag into a new position`,onPointerDown:e=>x(e,n.id),onContextMenu:e=>e.preventDefault(),onClick:()=>{b.current||d(n)},children:[(0,Q.jsxs)(`span`,{className:`row-head`,children:[O.has(n.id)&&(0,Q.jsx)(`span`,{className:`row-num`,title:`open session ${O.get(n.id)} in ${t.shownOf(r)}`,children:O.get(n.id)}),S(n)&&(0,Q.jsx)(Jf,{children:S(n)}),z(n)?(0,Q.jsx)(Ei,{s:n}):!S(n)&&(0,Q.jsx)(Jf,{children:t.shownOf(C(n))}),(0,Q.jsxs)(`span`,{className:`row-meta`,children:[(0,Q.jsx)(Uu,{className:`row-launch${Yn(o,n.backend)?` row-foreign`:``}`,children:Du(Ho(n),Yn(o,n.backend),o)}),n.createdAt&&n.running&&(0,Q.jsxs)(Uu,{title:`session open for ${gn(n.createdAt)}`,children:[(0,Q.jsx)(Cg,{size:11}),` `,gn(n.createdAt)]})]})]}),(0,Q.jsxs)(`span`,{className:`row-gist`,children:[j?(0,Q.jsx)(fi,{firstPrompt:n.firstPrompt,lastPrompt:n.lastPrompt,pinnedPrompt:n.pinnedPrompt}):M&&(0,Q.jsx)(`span`,{className:`row-summary`,children:M}),n.followUp&&(0,Q.jsx)(XS,{f:n.followUp})]})]}),(0,Q.jsxs)(`div`,{className:`row-acts`,children:[(0,Q.jsx)(`span`,{className:`row-stat`,children:Ax(n,A,n.starred&&n.newActivity,o)}),(0,Q.jsxs)(`span`,{className:`row-tags`,children:[n.remoteControlled&&(0,Q.jsxs)(Jc,{className:`rc-tag`,title:`a desktop is driving this session`,children:[(0,Q.jsx)(oh,{size:12}),` RC`]}),(()=>{let e=D.get(n.id);if(!e)return null;let t=e.ids.length,r=e.nextAt==null?`when its window opens`:ue(e.nextAt),i=()=>{J(`action:session.scheduled.open`),ni(n.cwd,e.ids,`scheduled for ${n.title}`)};return(0,Q.jsxs)(Jc,{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)(tg,{size:12}),` `,t>1?`${t} · `:``,r]})})(),(0,Q.jsx)(sl,{s:n}),(0,Q.jsx)(Oa,{s:n}),Fx(n,()=>os(n)),jx(n,k),(0,Q.jsx)(Bu,{s:n}),(0,Q.jsx)(Pf,{sessionId:n.id}),E(n)?.id!==i&&RT(E(n),s)]}),(()=>{let e=Rx(n,()=>Zi(n.id)),t=Mx(n),r=p(n,`transcript`);return(e||t||r||n.contextSpark)&&(0,Q.jsxs)(`span`,{className:`row-side`,children:[r&&(()=>{let e=Ix(n);return(0,Q.jsxs)(`button`,{className:`row-act${e==null?``:` tally`}`,title:`outline — where this session got to, without opening the terminal${Lx(e)}`,onClick:()=>f(n),children:[(0,Q.jsx)(jg,{size:LT}),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 ${T(n)}`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),yi(n))},onClick:e=>{e.stopPropagation(),yi(n)},children:[Nx(n),Px(n),(0,Q.jsx)(To,{spark:n.contextSpark,value:!0}),(0,Q.jsx)(Yo,{spark:n.contextSpark,warn:a})]})]})})(),(0,Q.jsxs)(`span`,{className:`row-ctl`,children:[(0,Q.jsx)(`button`,{className:`row-act${n.starred?` starred`:``}${n.id in m?` star-pending`:``}`,"data-hint":`session.star`,title:n.id in m?c===`open`?`starred here — the desktop has not confirmed it yet`:`starred here — offline, so it is only on this device until the link is back`:n.starred?`unstar (prima interest)`:`star — mark as prima interest to come back to`,onClick:()=>h(n.id,!n.starred),children:(0,Q.jsx)(Qh,{size:LT,fill:n.starred?`currentColor`:`none`})}),(0,Q.jsx)(`button`,{className:`row-act fu-btn${qS(n.followUp)}${n.id in g?` star-pending`:``}`,"data-hint":`session.followup`,"aria-pressed":!!n.followUp,title:JS(n,n.id in g,c===`open`),onClick:()=>_(n.id,!n.followUp),children:(0,Q.jsx)(YS,{on:!!n.followUp,size:LT})}),(0,Q.jsx)(`button`,{className:`row-act`,title:`name this session`,onClick:()=>{AS(n,l)},children:(0,Q.jsx)(Dm,{size:LT})}),(0,Q.jsx)(`button`,{className:`row-act danger`,title:n.running?`close`:`remove`,onClick:()=>v(n),children:(0,Q.jsx)(Jh,{size:LT})})]})]})]})}var BT=new Map;function VT({repo:e,onSaved:t}){let[n,r]=(0,Z.useState)(BT.has(e.id)),[i,a]=(0,Z.useState)(()=>BT.get(e.id)??e.displayName??``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),u=e.repoName,d=e.displayName??null,f=t=>{a(t),l(null),t===(d??``)?BT.delete(e.id):BT.set(e.id,t)};async function p(n){J(n?`action:repo.shownas.save`:`action:repo.shownas.clear`);let i=H(n);if(!i.ok)l(i.error);else{s(!0);try{let n=await va.setRepoDisplayName(e.id,i.value);if(!n.ok){l(n.error);return}BT.delete(e.id),a(n.name??``),r(!1),X(n.name?`${u} is shown as “${n.name}” — the folder keeps its name`:`${u} is shown by its folder name again`),t()}catch{l(`The desktop did not answer, so nothing was changed. What you typed is still here.`)}finally{s(!1)}}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{className:`more-act${d?` names`:``}${n?` on`:``}`,"aria-expanded":n,title:d?`shown as “${d}” — change it, or go back to the folder name “${u}”`:`change the name this repo is shown under; the folder “${u}” keeps its name`,onClick:()=>{J(`action:repo.shownas`),r(e=>!e)},children:[(0,Q.jsx)(Vh,{size:16}),d?(0,Q.jsxs)(Q.Fragment,{children:[`shown as `,(0,Q.jsx)(`b`,{children:d})]}):`shown as…`]}),n&&(0,Q.jsxs)(`div`,{className:`shownas`,style:{flex:`0 0 100%`},children:[(0,Q.jsxs)(`div`,{className:`plugin-field`,children:[(0,Q.jsx)(`input`,{type:`text`,value:i,placeholder:u,"aria-label":`name to show for ${u}`,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!o&&p(i)}}),(0,Q.jsx)(Y,{variant:`primary`,onClick:()=>void p(i),children:o?`saving…`:`save`}),d&&(0,Q.jsxs)(Y,{onClick:()=>void p(null),children:[`use “`,u,`”`]})]}),(0,Q.jsxs)(yl,{children:[`Only what is shown changes, on every device. The folder is still “`,u,`”, and so are the repo’s colour and everything that finds it by name.`]}),c&&(0,Q.jsx)(yl,{tone:`warn`,children:c})]})]})}function HT({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:()=>{J(`action:repo.chip.${e.id}`),e.open(t,n.filter,Hi())},children:[(0,Q.jsx)(r,{size:12}),n.text??`${n.label?`${n.label} `:``}${n.n}`]})}function UT({kind:e,n:t,onClick:n,repo:r,on:i,replies:a,hint:o}){if(t<=0)return null;let s=e===`wait`?Lh:fh;return(0,Q.jsxs)(`button`,{className:`${r?e===`wait`?`repo-group-wait`:`repo-group-stat limit`:e===`wait`?`head-wait`:`head-wait limit`}${i?` on`:``}`,"data-hint":o,title:Ga(e,t,{repo:r,replies:a}),onClick:n,children:[(0,Q.jsx)(s,{size:13}),r?``:` `,t,r&&e===`blocked`?``:` ${Hr[e]}`,a&&(0,Q.jsx)(tg,{size:11,className:`wait-sched`})]})}function WT(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=new AbortController;n(new Map(e.map(e=>[e,{state:`loading`}])));for(let r of e)va.worktreeLeftover(r,t.signal).then(e=>{t.signal.aborted||n(t=>new Map(t).set(r,{state:`ok`,v:e}))},e=>{t.signal.aborted||n(t=>new Map(t).set(r,{state:`error`,error:e instanceof Error?e.message:String(e)}))});return()=>t.abort()},[a,r]),{readings:t,recheck:(0,Z.useCallback)(()=>i(e=>e+1),[])}}var GT=e=>e?.state===`ok`&&e.v.blockers.length===0;async function KT(e,t){let n=0,r=[],i=[];for(let t of e)try{let e=await va.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.`;X([a,...i,...r.length?[`Kept ${r.join(`; `)}`]:[]].join(` `)),t()}function qT({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=>GT(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)(Uu,{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 ${JT(o,t)}, and nothing is uncommitted — removing loses nothing.`:o.length?` ${o.length} hold nothing that is not on ${JT(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)(Uu,{children:`removing…`}):(0,Q.jsxs)(Of,{className:`key wt-leftover-go`,confirm:`remove ${o.length} for good?`,onConfirm:()=>{J(`action:repo.worktree.removeLeftovers`),i(!0),KT(o,()=>{i(!1),n()})},children:[(0,Q.jsx)(Mh,{size:14}),`remove `,o.length===a?a===1?`it`:`all ${a}`:`the ${o.length} safe`]}))]})}function JT(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 YT({r:e}){return!e||e.state===`loading`?(0,Q.jsx)(Uu,{className:`wt-leftover`,children:`checking what is in it…`}):e.state===`error`?(0,Q.jsxs)(Uu,{className:`wt-leftover warn`,children:[(0,Q.jsx)(Ch,{size:12}),`could not check it: `,e.error]}):e.v.blockers.length?(0,Q.jsxs)(Uu,{className:`wt-leftover warn`,children:[(0,Q.jsx)(Ch,{size:12}),`keep: `,e.v.blockers.join(` `)]}):(0,Q.jsxs)(Uu,{className:`wt-leftover ok`,children:[(0,Q.jsx)(ag,{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 XT({t:e,r:t,onChanged:n}){return GT(t)?(0,Q.jsxs)(Of,{className:`more-act`,confirm:`remove for good?`,onConfirm:()=>{J(`action:repo.worktree.remove`),KT([e],n)},children:[(0,Q.jsx)(Mh,{size:16}),`remove worktree`]}):null}var ZT=16;function QT({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=!!ri(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:O,intentById:k,clocksPerRepo:A,starredByRepo:ee,flaggedByRepo:j,repoMenu:M,setRepoMenu:N,setCloseAllPick:te}=t,P=r.length,F=t.shownOf(n),L=_(n),R=v(n),z=R.length,B=R.filter(e=>!e.ownerSessionId),{readings:V,recheck:ne}=WT(B.map(e=>e.id)),H=()=>{p(),ne()},U=y.get(n)??{wait:0,blocked:0,coding:0,done:0,exited:0},re=P+z===0,[W,ie]=(0,Z.useState)(!1),ae=re?!W:!b&&!x&&S.has(n),oe=(0,Z.useRef)(null),se=(0,Z.useRef)(null),ce=(0,Z.useRef)(!1);(0,Z.useLayoutEffect)(()=>{if(!ce.current)return;ce.current=!1;let e=oe.current,t=e?.closest(`.list`);if(!e||!t)return;let n=t.getBoundingClientRect().top,r=se.current;if(!ae&&r&&sf(`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`})},[ae]);let le=(0,Q.jsxs)(`div`,{className:`section repo-group${re?` idle`:``}`,style:Cu(n),children:[(0,Q.jsxs)(`div`,{className:`repo-group-line`,children:[(0,Q.jsxs)(`button`,{className:`repo-group-toggle`,title:re?`${ae?`show`:`hide`} — no session open in ${F}`:ae?`show ${P} session${P===1?``:`s`}${z>0?` and ${z} worktree${z===1?``:`s`}`:``}`:`hide ${P} session${P===1?``:`s`}${z>0?` and ${z} worktree${z===1?``:`s`}`:``}`,onClick:()=>{ce.current=!0,re?(J(`action:repo.collapse`),ie(e=>!e)):C(n)},children:[ae?(0,Q.jsx)(ih,{size:17}):(0,Q.jsx)(Ag,{size:17}),(0,Q.jsx)(`span`,{children:F})]}),(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 ${F}`,onClick:()=>{J(`action:repo.files.header`),L.outboxCount>0?bo(L.id):Sn(L.id)},children:[(0,Q.jsx)(mm,{size:15}),L.outboxCount>0&&L.outboxCount]}),L&&(0,Q.jsxs)(`button`,{className:`focus-btn${vi(L)?` count`:``}`,title:L.gitFailed?`the last ${L.gitFailed.verb} failed — open git to see why`:L.gitRunning?`${L.gitRunning===`push`?`a push`:L.gitRunning===`check`?`a check`:`a pull`} is running on the desktop — open git to follow it`:Jp(L),onClick:()=>a(L.id),children:[L.gitRunning?(0,Q.jsx)(ah,{size:13,className:`spin`}):(0,Q.jsx)(xm,{size:13}),L.changedCount>0&&L.changedCount,za(L)&&(0,Q.jsx)(`span`,{className:`git-ab`,children:za(L)}),en(L)&&(0,Q.jsxs)(`span`,{className:`git-ab no-origin`,children:[(0,Q.jsx)(um,{size:12}),`no remote`]}),L.gitFailed&&(0,Q.jsxs)(`span`,{className:`git-ab failed`,children:[(0,Q.jsx)(Hh,{size:12}),L.gitFailed.verb,` failed`]})]}),L&&(0,Q.jsx)($T,{repo:L,repoName:F})]})]}),(0,Q.jsxs)(`span`,{className:`repo-group-pin`,children:[(0,Q.jsx)(`button`,{className:`focus-btn${M===n?` on`:``}`,"aria-label":`more actions`,"aria-expanded":M===n,title:`more actions`,onClick:()=>{J(`action:repo.more`),N(e=>e===n?null:n)},children:(0,Q.jsx)(Nm,{size:17})}),P>0&&(0,Q.jsx)(`button`,{className:`focus-btn danger`,title:`close sessions in ${F} — review the ${P} here, cut by state, idle time, or what is still running underneath`,onClick:()=>te(n),children:(0,Q.jsx)(Jh,{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${re&&!ae?` lead`:``}`,title:e?`new session in ${F} · ${L.branch}, another one now — ${xb(e)}`:`new session in ${F} · ${L.branch}, opened now`,onClick:()=>{J(`action:repo.new.header`),u(L)},children:[(0,Q.jsx)(rg,{size:15}),`now`]}),(0,Q.jsxs)(`button`,{className:`repo-start-btn`,title:`words for a new session in ${F} — held until the repo is free, or on a clock you pick`,onClick:()=>{J(`action:repo.send`),g(L.worktreePath)},children:[(0,Q.jsx)(rg,{size:15}),`later`]})]})})(),P===0&&L&&Ge(L)&&(0,Q.jsx)(`span`,{className:`repo-group-branch`,title:`${I(de(L))} — nothing running`,children:Ge(L)}),z>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat wt${T(`worktrees`,n)?` on`:``}`,title:`${z} open worktree${z>1?`s`:``} in ${F} — tap to show only those`,onClick:()=>E(`worktrees`,n),children:[(0,Q.jsx)(Xh,{size:13}),z]}),(()=>{let e=L?ap(L.healthIndex,F,xe(new Date().toISOString().slice(0,10))):null;if(!L||!e)return null;let t=e.arrow===`down`?lm:e.arrow===`up`?fg:e.arrow===`flat`?sg:null;return(0,Q.jsxs)(`button`,{className:`repo-group-stat health${e.tone?` ${e.tone}`:``}`,title:e.title,onClick:()=>{J(`action:repo.healthindex`),si(L)},children:[(0,Q.jsx)(km,{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:Sb(L.setup),onClick:()=>{J(`action:repo.setup`),Ud(L.id,{focus:`findings`})},children:[(0,Q.jsx)(ng,{size:13}),L.setup.issues]}),(()=>{let e=L&&l.get(L.worktreePath);return e?(0,Q.jsxs)(`button`,{className:`repo-group-stat`,title:`${xb(e)} — open its screen`,onClick:()=>{J(`action:repo.pending.open`),h(L.worktreePath)},children:[(0,Q.jsx)(ah,{size:12,className:`spin`}),bb(e)]}):null})(),(0,Q.jsx)(UT,{kind:`blocked`,n:U.blocked,repo:F,on:T(`blocked`,n),onClick:()=>E(`blocked`,n)}),(0,Q.jsx)(UT,{kind:`wait`,n:U.wait,repo:F,on:T(`wait`,n),replies:!!D.get(n),onClick:()=>E(`wait`,n)}),U.coding>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat coding${T(`coding`,n)?` on`:``}`,title:`${U.coding} session${U.coding>1?`s`:``} in ${F} working — tap to show only those`,onClick:()=>E(`coding`,n),children:[(0,Q.jsx)(ah,{size:13,className:`spin`}),U.coding]}),U.done>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat done${T(`done`,n)?` on`:``}`,title:`${U.done} session${U.done>1?`s`:``} in ${F} idle — turn finished; tap to show only those`,onClick:()=>E(`done`,n),children:[(0,Q.jsx)(Sm,{size:13}),U.done]}),U.exited>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat exited${T(`exited`,n)?` on`:``}`,title:`${U.exited} exited session${U.exited>1?`s`:``} in ${F} — tap to show only those`,onClick:()=>E(`exited`,n),children:[(0,Q.jsx)(cg,{size:11}),U.exited]}),(O.get(n)?.length??0)>0&&(()=>{let e=O.get(n)??[],t=e.length,r=new Set(e),a=Date.now(),o=i.filter(e=>r.has(Oo(e.id))&&Nf(e,a,k)).length;return(0,Q.jsxs)(`button`,{className:`repo-group-stat queued`,title:`${t} command${t>1?`s`:``} waiting to run in ${F} — on this device or held by the desktop${o?`; ${o} held by the usage budget`:``}. Tap to show only those.`,onClick:()=>{let n=Bb(e,i);n.kind===`backlog`?(J(`action:repo.queued.backlog`),ni(n.cwd,n.ids,`the ${t} waiting in ${F}`)):(J(`action:repo.queued.open`),Qi({keys:e,label:`the ${t} waiting in ${F}`}))},children:[(0,Q.jsx)(lh,{size:12}),t,hp(t,o)]})})(),(A.get(n)?.ids.length??0)>0&&(()=>{let e=A.get(n),t=e.ids.length,r=pe(e.horizon);return(0,Q.jsxs)(`button`,{className:`repo-group-stat`,title:`${t} thing${t>1?`s`:``} on a clock in ${F}${r?` — ${r}`:``}. Tap to show only those.`,onClick:()=>{J(`action:repo.clocks.open`),Bp(e.ids,Bo(F,t),L?.worktreePath)},children:[(0,Q.jsx)(tg,{size:12}),t]})})(),L&&uo().map(e=>(0,Q.jsx)(ll,{feature:e.feature,what:`its ${e.def.id} chip`,children:(0,Q.jsx)(HT,{def:e.def,repo:L})},e.key)),(ee.get(n)??0)>0&&(()=>{let e=ee.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 ${F} — tap to show only those`,onClick:()=>E(`starred`,n),children:[(0,Q.jsx)(Qh,{size:12,fill:`currentColor`}),e]})})(),(()=>{let e=j.get(n);return e?(0,Q.jsxs)(`button`,{className:`repo-group-stat fu-${e.tone}${T(`followup`,n)?` on`:``}`,"data-hint":`session.followup`,title:Ao(e.n,F),onClick:()=>E(`followup`,n),children:[(0,Q.jsx)(Th,{size:12,fill:`currentColor`}),e.n]}):null})()]}),M===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:()=>{N(null),d(L)},children:[(0,Q.jsx)(qm,{size:ZT}),`open a shell here`]}),!o&&(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`repo.focus`,onClick:()=>{J(`action:repo.focus`),N(null),w(n)},children:[(0,Q.jsx)(Xm,{size:ZT}),_n()?`focus this repo`:`focus window`]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{J(`action:repo.browse`),N(null),oo(L.id)},children:[(0,Q.jsx)(Dg,{size:ZT}),`browse files`]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{J(`action:repo.backlog`),N(null),Es(L)},children:[(0,Q.jsx)(sh,{size:ZT}),`backlog`]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{J(`action:repo.assess`),N(null),Xd(L)},children:[(0,Q.jsx)(_g,{size:ZT}),`what is left`]}),L&&up(L).map(e=>(0,Q.jsx)(ll,{feature:e.feature,what:`its ${e.id} action`,children:(0,Q.jsxs)(`button`,{className:`more-act`,title:e.title,onClick:()=>{J(`action:repo.ext.${e.id}`),N(null),e.run()},children:[(0,Q.jsx)(e.icon,{size:ZT}),e.label]})},e.key)),L&&(0,Q.jsxs)(`button`,{className:`more-act`,title:wb(L.setup),onClick:()=>{J(`action:repo.setup`),N(null),Ud(L.id)},children:[(0,Q.jsx)(ng,{size:ZT}),Cb(L.setup)]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,title:`what this repo downloads to this device by itself`,onClick:()=>{J(`action:repo.pullrules`),N(null),Ma(L.worktreePath)},children:[(0,Q.jsx)(zm,{size:ZT}),`download rules`]}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{J(`action:repo.branch`),N(null),f(L),s(`branches`)},children:[(0,Q.jsx)(Xh,{size:ZT}),`branch`]}),L&&(0,Q.jsx)(VT,{repo:L,onSaved:()=>{N(null),p()}}),L&&(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`repo.hide`,onClick:()=>{J(`action:repo.hide`),N(null),c(L.id)},children:[(0,Q.jsx)(Km,{size:ZT}),`hide`]}),L&&(0,Q.jsx)(ed,{repo:L,onOpen:()=>{N(null),si(L)}}),L&&(0,Q.jsx)(ka,{onOpen:()=>{J(`action:repo.optins`),N(null),Ud(L.id,{region:`optins`})}})]})]}),ue=new Set(r.map(e=>e.id)),fe=e=>R.filter(t=>t.ownerSessionId===e),me=R.filter(e=>!e.ownerSessionId||!ue.has(e.ownerSessionId)),he=e=>(0,Q.jsxs)(`div`,{className:`row-wrap repo-row row-wt${e.ownerSessionId&&ue.has(e.ownerSessionId)?` row-wt-owned`:``}`,style:Cu(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)(Jf,{children:(0,Q.jsx)(`span`,{className:`wt-branch`,children:e.branch.replace(/^worktree-/,``)})}),(0,Q.jsxs)(Uu,{className:`repo-sub`,children:[(0,Q.jsxs)(`span`,{className:`repo-branch wt-of`,children:[(0,Q.jsx)(Xh,{size:12}),`worktree of `,(0,Q.jsx)(`b`,{children:F})]}),(()=>{let t=l.get(e.worktreePath);return t?(0,Q.jsxs)(`button`,{className:`row-chip`,title:`${xb(t)} — open its screen`,onClick:t=>{t.stopPropagation(),J(`action:repo.pending.open`),h(e.worktreePath)},children:[(0,Q.jsx)(ah,{size:12,className:`spin`}),bb(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(),J(`action:repo.inbox`),bo(e.id)},children:[(0,Q.jsx)(mm,{size:12}),e.outboxCount]}),e.gitFailed&&(0,Q.jsxs)(`button`,{className:`row-chip bad`,title:`the last ${e.gitFailed.verb} failed — open git to see why`,onClick:t=>{t.stopPropagation(),J(`action:repo.git`),a(e.id)},children:[(0,Q.jsx)(Hh,{size:12}),e.gitFailed.verb,` failed`]}),vi(e)&&(0,Q.jsxs)(`button`,{className:`row-chip`,title:Jp(e),onClick:t=>{t.stopPropagation(),J(`action:repo.git`),a(e.id)},children:[(0,Q.jsx)(xm,{size:12}),e.changedCount>0&&e.changedCount,za(e)&&(0,Q.jsx)(`span`,{className:`git-ab`,children:za(e)})]}),e.setup&&e.setup.issues>0&&(0,Q.jsxs)(`button`,{className:`row-chip ${e.setup.ok?`warn`:`bad`}`,title:Sb(e.setup),onClick:t=>{t.stopPropagation(),J(`action:repo.setup`),Ud(e.id,{focus:`findings`})},children:[(0,Q.jsx)(ng,{size:12}),e.setup.issues]})]}),!e.ownerSessionId&&(0,Q.jsx)(YT,{r:V.get(e.id)})]}),(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this worktree`,onClick:()=>jl(e.id),children:(0,Q.jsx)(Jm,{size:ZT})}),(0,Q.jsx)(`button`,{className:`row-act`,title:`send words to a new session here — works offline`,onClick:()=>{J(`action:repo.send`),g(e.worktreePath)},children:(0,Q.jsx)(Zh,{size:ZT})}),(0,Q.jsx)(`button`,{className:`row-act${M===e.id?` on`:``}`,"aria-label":`more actions`,"aria-expanded":M===e.id,title:`more actions`,onClick:()=>{J(`action:repo.more`),N(t=>t===e.id?null:e.id)},children:(0,Q.jsx)(Nm,{size:ZT})}),M===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:()=>{N(null),d(e)},children:[(0,Q.jsx)(qm,{size:ZT}),`open a shell here`]}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{J(`action:repo.build`),N(null),Dn(e)},children:[(0,Q.jsx)(vh,{size:ZT}),`build`]}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{J(`action:repo.capture`),N(null),Up(e)},children:[(0,Q.jsx)(Rh,{size:ZT}),`capture`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:wb(e.setup),onClick:()=>{J(`action:repo.setup`),N(null),Ud(e.id)},children:[(0,Q.jsx)(ng,{size:ZT}),Cb(e.setup)]}),(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`repo.hide`,onClick:()=>{J(`action:repo.hide`),N(null),c(e.id)},children:[(0,Q.jsx)(Km,{size:ZT}),`hide`]}),!e.ownerSessionId&&(0,Q.jsx)(XT,{t:e,r:V.get(e.id),onChanged:()=>{N(null),H()}})]})]},e.id);return(0,Q.jsxs)(`div`,{className:`repo-group-block`,children:[(0,Q.jsx)(`span`,{ref:oe,className:`repo-group-anchor`,"aria-hidden":!0}),le,re&&!ae&&(0,Q.jsx)(`div`,{className:`repo-group-empty`,style:Cu(n),children:L?(0,Q.jsxs)(Q.Fragment,{children:[`No active session — start one with `,(0,Q.jsx)(rg,{size:15,"aria-label":`plus`}),`now under the name above.`]}):`No active session.`}),!ae&&(0,Q.jsx)(qT,{wts:B,readings:V,onChanged:H}),!ae&&me.map(he),!ae&&r.map(r=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(zT,{p:e,m:t,s:r,repoName:n,headRepoId:L?.id}),fe(r.id).map(he)]},r.id)),(0,Q.jsx)(`span`,{ref:se,className:`repo-group-anchor`,"aria-hidden":!0})]})}function $T({repo:e,repoName:t}){let n=xu(e);return(0,Q.jsxs)(`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:()=>{J(`action:repo.build.header`),Dn(e)},children:[n?(0,Q.jsx)(ah,{size:17,className:`spin`}):(0,Q.jsx)(vh,{size:17}),e.buildFailed&&(0,Q.jsx)(`span`,{className:`git-ab failed`,title:`build “${e.buildFailed.name}” failed — open build to see why`,children:`failed`})]})}function eE(e){return e.itemLabel||e.tabTitle||C(e.title)||e.title}function tE(e){let t=C(e.title)||e.title;return t&&t!==eE(e)?t:void 0}var nE={hand:`by hand`,fork:`fork`,backlog:`backlog`,schedule:`scheduled`,agent:`agent`,fanout:`fan-out`,resurrect:`reopened after limit`};function rE(e){return e.kind&&e.kind in nE?nE[e.kind]:void 0}function iE(e){return e.closedBy===`auto-done`||e.closedBy===`auto-slot`}function aE(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 oE(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 sE(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 cE(e,t){let n=[];return typeof e.openedAt==`number`&&e.closedAt>=e.openedAt&&n.push(`open ${sE(e.closedAt-e.openedAt)}`),typeof e.lastActiveAt==`number`&&n.push(`last active ${sE(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 lE(e,t){return t===`auto`?e.filter(iE):[...e]}function uE(e,t){return`${e} of ${t} shown — closed automatically`}var dE=16;function fE({p:e,m:t}){let{backends:n,openGitFor:i}=e,{send:a,liveSend:o}=e.conn,{setOverlay:s}=e.route,{hiddenRepos:c,toggleHideRepo:l}=e.view,{openCwd:u,openRepo:d,reopenCant:f}=e.launchCore,{attach:p}=e.term,{closeSession:m}=e.verbs,{repoForCwd:h,sessionRepo:g,visibleRecent:_,hiddenRecent:v,hiddenSessions:y,hiddenCount:b,showHidden:x,setShowHidden:S}=t,w=e=>Gr(n,e.launch?.backend),T=e=>w(e)?`starts a new shell in this folder — a shell has no conversation to continue`:mu(!!Li(e)),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(!1),[A,ee]=(0,Z.useState)(``),j=A.trim()!==``,M=t.reopenable,N=j?M.filter(e=>Kb(A,[e.title,eE(e),tE(e),e.cwd,e.firstPrompt,e.lastPrompt])):M,te=j?_.filter(e=>Kb(A,[e.title,e.cwd])):_,P=M.length+_.length,F=N.length+te.length;return(0,Q.jsxs)(Q.Fragment,{children:[P>0&&(0,Q.jsx)(`button`,{className:`section section-head closed-fold`,"aria-expanded":O,title:O?`fold away recently closed and recent sessions`:`show recently closed and recent sessions, with a search`,onClick:()=>k(e=>!e),children:(0,Q.jsxs)(`span`,{children:[O?(0,Q.jsx)(Ag,{size:dE}):(0,Q.jsx)(ih,{size:dE}),` Closed & recent`,(0,Q.jsxs)(`span`,{className:`section-hint`,children:[` · `,M.length,` closed · `,_.length,` recent`]})]})}),O&&P>0&&(0,Q.jsxs)(`div`,{className:`section quick-filter`,children:[(0,Q.jsx)(jh,{size:14,className:`quick-filter-icon`}),(0,Q.jsx)(`input`,{type:`search`,value:A,placeholder:`search closed & recent`,"aria-label":`search recently closed and recent sessions by title, folder and prompts`,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Escape`&&A&&(e.preventDefault(),e.stopPropagation(),ee(``))}}),j&&(0,Q.jsxs)(`span`,{className:`quick-filter-n`,children:[F,` of `,P]}),j&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`clear the search`,title:`clear the search — every row again`,onClick:()=>ee(``),children:(0,Q.jsx)(Jh,{size:dE})})]}),O&&j&&F===0&&(0,Q.jsxs)(Cf,{children:[`No closed or recent session shows “`,A.trim(),`”.`]}),O&&(()=>{if(!N.length)return null;let e=N.filter(iE).length,r=E===`auto`&&e>0?`auto`:null,c=lE(N,r),l=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:()=>{J(`overlay:archive`),s(`archive`)},children:(0,Q.jsx)(gg,{size:dE})}),(0,Q.jsx)(Of,{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)(Mh,{size:dE}),` clear?`]}),onConfirm:()=>{a({t:`closed.clear`}),X(`shortlist cleared — conversations kept`)},children:(0,Q.jsx)(Mh,{size:dE})})]})]}),e>0&&(0,Q.jsx)(Gl,{className:`annot-tools closed-chips`,keys:[`auto`],bucket:()=>({count:e}),label:()=>`closed automatically`,active:r,onPick:e=>D(e)}),r&&(0,Q.jsx)(sp,{onClear:()=>D(null),clearLabel:`show all`,children:uE(c.length,N.length)}),c.map(e=>{let r=tE(e),a=rE(e),s=aE(e),c=oE(e),d=cE(e,l),p=e.contextSpark,m=()=>u(e.cwd,C(e.title)||e.title,!0,`continue`,e.launch,Li(e));return(0,Q.jsxs)(`div`,{className:`row-wrap closed-card${iE(e)?` closed-auto-row`:``}`,style:Cu(t.sessionRepoName(e)),children:[(0,Q.jsxs)(Fc,{as:`button`,kind:`grow`,title:`reopen ${C(e.title)} — ${T(e)}`,onClick:m,children:[(0,Q.jsxs)(`span`,{className:`row-head`,children:[(0,Q.jsxs)(Jf,{children:[e.bookmark&&!e.bookmark.note&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`bm-mark`,children:(0,Q.jsx)($s,{on:!0,size:12})}),` `]}),eE(e)]}),(0,Q.jsxs)(`span`,{className:`row-meta`,children:[r&&(0,Q.jsx)(Uu,{className:`closed-folder`,children:r}),(0,Q.jsx)(Uu,{className:`row-launch${Yn(n,e.launch?.backend)?` row-foreign`:``}`,children:Du(e.launch??{},Yn(n,e.launch?.backend),n)}),a&&(0,Q.jsx)(Jc,{className:`closed-kind`,children:a}),s&&s.tone!==`auto`&&(0,Q.jsx)(Uu,{className:s.tone===`note`?`closed-note`:void 0,children:s.text}),w(e)&&(0,Q.jsx)(Uu,{children:`new shell here`})]})]}),(0,Q.jsx)(`span`,{className:`row-stat`,children:(0,Q.jsxs)(Jc,{className:`closed-stat`,title:`closed ${new Date(e.closedAt).toLocaleString()}`,children:[`closed `,Rp(e.closedAt)]})}),(0,Q.jsxs)(`span`,{className:`row-gist`,children:[s?.tone===`auto`&&(0,Q.jsx)(`span`,{className:`closed-line`,children:(0,Q.jsxs)(Jc,{className:`closed-auto`,children:[(0,Q.jsx)(Wm,{size:12}),` `,s.text]})}),c&&(0,Q.jsxs)(Uu,{className:`closed-line closed-outcome ${c.tone}`,children:[c.tone===`ok`?(0,Q.jsx)(ag,{size:12}):c.tone===`bad`?(0,Q.jsx)(Oh,{size:12}):(0,Q.jsx)(ch,{size:12}),` `,c.text]}),(0,Q.jsx)(fi,{firstPrompt:e.firstPrompt,lastPrompt:e.lastPrompt,className:`closed-gist`}),d.length>0&&(0,Q.jsx)(Uu,{className:`closed-line closed-meta`,children:d.join(` · `)}),e.followUp&&(0,Q.jsx)(`span`,{className:`closed-line`,children:(0,Q.jsx)(XS,{f:e.followUp})}),e.bookmark?.note&&(0,Q.jsxs)(`span`,{className:`closed-line bm-mark`,children:[(0,Q.jsx)($s,{on:!0,size:12}),` `,e.bookmark.note]}),f(e)]}),p&&(0,Q.jsx)(`span`,{className:`row-side`,children:(0,Q.jsxs)(`span`,{className:`row-spark`,children:[(0,Q.jsx)(To,{spark:p,value:!0}),(0,Q.jsx)(Yo,{spark:p})]})})]}),(0,Q.jsxs)(`div`,{className:`row-acts`,children:[(0,Q.jsx)(`span`,{className:`row-tags`,children:RT(h(e.cwd),i)}),(0,Q.jsxs)(`span`,{className:`row-ctl`,children:[e.followUp&&(0,Q.jsx)(`button`,{className:`row-act fu-btn${qS(e.followUp)}`,"data-hint":`session.followup`,"aria-pressed":!0,title:`Done — clear flag — the conversation stays where it is`,onClick:()=>{J(`action:session.followup.closed`),o({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)(YS,{on:!0,size:dE})}),Ta(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:()=>u(e.cwd,e.title,!0,`pick`,e.launch),children:(0,Q.jsx)(Eh,{size:dE})}),(0,Q.jsx)(`button`,{className:`row-act`,title:`${w(e)?`start a new shell in this folder`:`reopen`} — ${T(e)}`,onClick:m,children:(0,Q.jsx)(qh,{size:dE})})]})]})]},e.id)})]})})(),O&&te.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)(Of,{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)(Mh,{size:dE}),` clear?`]}),onConfirm:()=>{a({t:`recent.clear`}),X(`recent cleared`)},children:(0,Q.jsx)(Mh,{size:dE})})})]}),O&&te.map(e=>(0,Q.jsxs)(Fc,{kind:`wrap`,style:Cu(t.sessionRepoName(e)),children:[(0,Q.jsxs)(Fc,{as:`button`,kind:`grow`,title:`${w(e)?`open a new shell in`:`resume`} ${e.title} — ${T(e)}`,onClick:()=>u(e.cwd,e.title,!0,`continue`,e.launch,Li(e)),children:[(0,Q.jsx)(Jf,{children:e.title}),(0,Q.jsxs)(Uu,{children:[(0,Q.jsx)(qh,{size:12}),` `,w(e)?`new shell here`:`resume`]}),f(e)]}),RT(h(e.cwd),i),h(e.cwd)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this repo`,onClick:()=>jl(h(e.cwd).id),children:(0,Q.jsx)(Jm,{size:dE})})]},Li(e)??e.cwd)),b>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{className:`section`,onClick:()=>S(e=>!e),style:{background:`none`,border:0,textAlign:`left`,cursor:`pointer`,width:`100%`},children:[`Hidden (`,b,`) `,x?`▾`:`▸`]}),x&&(0,Q.jsxs)(Q.Fragment,{children:[y.map(e=>(0,Q.jsxs)(Fc,{kind:`wrap`,children:[(0,Q.jsxs)(Fc,{as:`button`,kind:`grow`,onClick:()=>p(e),children:[(0,Q.jsxs)(Jf,{children:[e.title,(0,Q.jsxs)(Uu,{className:Yn(n,e.backend)?`row-foreign`:void 0,children:[` `,Du(e,Yn(n,e.backend),n)]})]}),(0,Q.jsx)(Ei,{s:e}),Ax(e,void 0,void 0,n)]}),RT(g(e),i),g(e)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this session`,onClick:()=>jl(g(e).id),children:(0,Q.jsx)(Jm,{size:dE})}),(0,Q.jsx)(`button`,{className:`row-act danger`,title:e.running?`close`:`remove`,onClick:()=>m(e),children:(0,Q.jsx)(Jh,{size:dE})})]},e.id)),v.map(e=>(0,Q.jsxs)(Fc,{kind:`wrap`,children:[(0,Q.jsxs)(Fc,{as:`button`,kind:`grow`,title:`${w(e)?`open a new shell in`:`resume`} ${e.title} — ${T(e)}`,onClick:()=>u(e.cwd,e.title,!0,`continue`,e.launch,Li(e)),children:[(0,Q.jsx)(Jf,{children:e.title}),(0,Q.jsxs)(Uu,{children:[(0,Q.jsx)(qh,{size:12}),` `,w(e)?`new shell here`:`resume`]})]}),RT(h(e.cwd),i),h(e.cwd)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this repo`,onClick:()=>jl(h(e.cwd).id),children:(0,Q.jsx)(Jm,{size:dE})})]},Li(e)??e.cwd)),c.map(e=>(0,Q.jsxs)(`div`,{className:`row-wrap ${e.isPrimary?``:`row-wt`}`,children:[(0,Q.jsxs)(Fc,{as:`button`,kind:`grow`,onClick:()=>d(e),children:[(0,Q.jsx)(Jf,{children:e.isPrimary?r(e):(0,Q.jsx)(`span`,{className:`wt-branch`,children:e.branch})}),(e.isPrimary?Ge(e):`worktree`)&&(0,Q.jsx)(Uu,{children:e.isPrimary?Ge(e):`worktree`})]}),(0,Q.jsx)(`button`,{className:`row-act`,title:`show repo`,onClick:()=>l(e.id),children:(0,Q.jsx)(Vm,{size:dE})})]},e.id))]})]})]})}var pE=[],mE=new Set;function hE(e){pE=e;for(let t of mE)t(e)}function gE(){return va.plainFolders().then(e=>(hE(e.folders??[]),pE.length)).catch(()=>null)}function _E({refreshRepos:e}){let[t,n]=(0,Z.useState)(pE),[r,i]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>(mE.add(n),()=>{mE.delete(n)}),[]),!t.length)return null;let a=t=>{i(t.path),va.initPlainFolder(t.path).then(n=>{n.error?X(`${t.name}: ${n.error}`):(hE(pE.filter(e=>e.path!==t.path)),e(),X(`${t.name} is a git repo now — listed below`))}).catch(()=>X(`${t.name}: the desktop did not answer — nothing changed`)).finally(()=>i(null))};return(0,Q.jsxs)(`div`,{className:`list`,children:[(0,Q.jsxs)(`div`,{className:`section section-head`,children:[(0,Q.jsxs)(`span`,{children:[t.length===1?`1 folder is`:`${t.length} folders are`,` not listed: no git in `,t.length===1?`it`:`them`]}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`dismiss`,title:`dismiss — the next rescan says it again`,onClick:()=>hE([]),children:(0,Q.jsx)(Jh,{size:13})})]}),t.map(e=>(0,Q.jsxs)(Fc,{kind:`wrap`,children:[(0,Q.jsxs)(Fc,{kind:`grow`,children:[(0,Q.jsx)(Jf,{className:`mono`,children:e.name}),(0,Q.jsx)(Uu,{children:`only folders with git are repos here`})]}),(0,Q.jsxs)(Y,{title:`run git init in ${e.name} — adds a .git folder, no commit, your files stay as they are`,onClick:()=>{r||a(e)},children:[(0,Q.jsx)(Bh,{size:14}),` `,r===e.path?`running…`:`git init`]})]},e.path))]})}var vE=[`wait`,`blocked`,`coding`,`done`,`exited`],yE={coding:`working`,wait:`waiting for your answer`,done:`idle`,blocked:`blocked`,exited:`exited`},bE=[`1h`,`6h`,`1d`,`3d`],xE={"1h":36e5,"6h":216e5,"1d":864e5,"3d":2592e5},SE={"1h":`> 1h`,"6h":`> 6h`,"1d":`> 1d`,"3d":`> 3d`},CE=[`agents`,`shellsLive`,`shellsQuiet`,`nothing`],wE={agents:`agents running`,shellsLive:`shells live`,shellsQuiet:`shells quiet`,nothing:`nothing running`};function TE(e,t,n){let r=!!e.agents?.length,i,a;if(e.shellList){let n=ie(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 EE=[`draft`,`queued`,`none`],DE={draft:`unsent draft on this device`,queued:`prompts queued for it`,none:`nothing waiting`};function OE(e,t,n){return t.has(e.id)?`draft`:n.some(t=>t.sessionId===e.id&&t.status!==`failed`)?`queued`:`none`}var kE=[`fresh`,`started`],AE={fresh:`never started`,started:`started`},jE={state:new Set,idleOver:new Set,openOver:new Set,under:new Set,stakes:new Set,convo:new Set,repo:new Set};function ME(e,t){return e.size===0||[...e].some(t)}function NE(e,t,n){return ME(t.state,t=>n.statusOf(e)===t)&&ME(t.idleOver,t=>kn(e)>=xE[t])&&ME(t.openOver,t=>n.now-e.createdAt>=xE[t])&&ME(t.under,t=>TE(e,n.now,t))&&ME(t.stakes,t=>OE(e,n.draftIds,n.outbox)===t)&&ME(t.convo,t=>eo(e)===t)&&ME(t.repo,t=>n.repoName(e)===t)}function PE(e,t,n){return e.filter(e=>NE(e,t,n))}function FE(e,t){return{...e,[t]:jE[t]}}function IE(e,t,n,r,i,a){let o=FE(t,r),s=e.filter(e=>NE(e,o,n)),c={};for(let e of i)c[e]=s.filter(t=>a(t,e)).length;return c}function LE(e,t,n,r){let i=FE(t,`idleOver`);return{state:IE(e,t,n,`state`,vE,(e,t)=>n.statusOf(e)===t),idleOver:IE(e,t,n,`idleOver`,bE,(e,t)=>kn(e)>=xE[t]),openOver:IE(e,t,n,`openOver`,bE,(e,t)=>n.now-e.createdAt>=xE[t]),under:IE(e,t,n,`under`,CE,(e,t)=>TE(e,n.now,t)),stakes:IE(e,t,n,`stakes`,EE,(e,t)=>OE(e,n.draftIds,n.outbox)===t),convo:IE(e,t,n,`convo`,kE,(e,t)=>eo(e)===t),repo:IE(e,t,n,`repo`,r,(e,t)=>n.repoName(e)===t),idleUnknown:e.filter(e=>NE(e,i,n)&&!aa(e)).length}}function RE(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 zE(e){let t=[];return e.state.size&&t.push([...e.state].map(e=>yE[e]).join(` or `)),e.idleOver.size&&t.push(`idle ${[...e.idleOver].map(e=>SE[e]).join(` or `)}`),e.openOver.size&&t.push(`open ${[...e.openOver].map(e=>SE[e]).join(` or `)}`),e.under.size&&t.push([...e.under].map(e=>wE[e]).join(` or `)),e.stakes.size&&t.push([...e.stakes].map(e=>DE[e]).join(` or `)),e.convo.size&&t.push([...e.convo].map(e=>AE[e]).join(` or `)),e.repo.size&&t.push([...e.repo].join(` or `)),t.join(` · `)}function BE(e,t,n){let r=zE(n);return`${e} of ${t} in scope${r?` · ${r}`:``}`}var VE=e=>e.state.size+e.idleOver.size+e.openOver.size+e.under.size+e.stakes.size+e.convo.size+e.repo.size>0;function HE(e,t,n=new Set){return n.has(e)?!t.has(e):t.has(e)}function UE(e,t,n){return e.filter(e=>!HE(e.id,t,n))}function WE(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 GE(e){return e.reduce((e,t)=>e+(t.shellList?.length??0),0)}function KE(e,t){return e.filter(e=>t.statusOf(e)===`wait`).length}function qE(e,t){return e?t>0?`close ${e} · stops ${t} background shell${t===1?``:`s`}`:`close ${e}`:``}function JE(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 YE=16;function XE({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)(Ml,{on:r.has(e),title:`${i[e]} — ${n[e]} session${n[e]===1?``:`s`}`,onClick:()=>a(e),children:Qs(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 ZE(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 QE(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function $E({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)(Fc,{kind:`wrap`,children:[(0,Q.jsxs)(Fc,{kind:`grow`,style:{cursor:`default`},children:[(0,Q.jsx)(Kn,{s:e,repoLabel:t,backends:s}),e.shellList?.length?(0,Q.jsxs)(Uu,{children:[(0,Q.jsx)(Um,{size:11}),` `,g(ie(e.shellList,a)),` — will stop`]}):null,o&&(0,Q.jsxs)(Uu,{children:[(0,Q.jsx)(Cg,{size:11}),` a prompt is timed into it · `,o,n?` — kept open`:` — its conversation is reopened then`]}),c&&(0,Q.jsxs)(Uu,{className:`warn`,children:[(0,Q.jsx)(Lh,{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)(bh,{size:YE})})]})}function eD({p:e,m:t}){let{send:n}=e.conn,{closeAllPick:r,setCloseAllPick:i,closeKeepStar:a,setCloseKeepStar:o,visibleSessions:s,sessionRepoName:c,shownOf:l}=t,u=r!==null;Pl(u,()=>i(null));let[d,f]=(0,Z.useState)(jE),[p,m]=(0,Z.useState)(new Set),{items:h}=Rs();if((0,Z.useEffect)(()=>{u||(f(jE),m(new Set))},[u]),!u)return null;let g=r===`*`?void 0:r,_=Date.now(),v=Hb(s,g,a,c),y=Wb(s,g,a,c),b=Ub(s,g,c),x=b.n,S=Gb(b),C={now:_,repoName:c,statusOf:t=>sn(t,e.backends),draftIds:as(),outbox:e.outbox},w=g?[]:[...new Set(v.map(c))].sort(),T=LE(v,d,C,w),E=PE(v,d,C),D=new Map;for(let e of h)e.status===`queued`&&e.at&&e.targetSessionId&&!D.has(e.targetSessionId)&&D.set(e.targetSessionId,e.at.nextAt==null?`when its rule comes round`:Hn(e.at.nextAt));let O=new Set(D.keys()),k=UE(E,p,O),A=WE(E.filter(e=>O.has(e.id)&&HE(e.id,p,O)).length),ee=GE(k),j=KE(k,C),M=qE(k.length,ee),[N,te]=ZE(RE(T.idleUnknown));function P(e,t){f(n=>({...n,[e]:t}))}function F(){f(jE)}function I(e){m(t=>QE(t,e))}function L(){if(k.length){J(`action:${g?`repo`:`session`}.close.facets`);for(let e of k)vs(e.id),n({t:`session.remove`,id:e.id});i(null),X(JE(k.length,ee,y>0?S:``,g&&l(g)))}}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:g?`Close sessions in ${l(g)}?`:`Close sessions?`,icon:(0,Q.jsx)(Jh,{size:YE}),onClose:()=>i(null),footer:(0,Q.jsxs)(Q.Fragment,{children:[M?(0,Q.jsxs)(Of,{className:`key danger`,confirm:`tap again to ${M}`,title:M,confirmTitle:`tap again to ${M}`,onConfirm:L,children:[(0,Q.jsx)(Jh,{size:YE}),` `,M]}):(0,Q.jsx)(yl,{children:v.length===0?y>0?`Nothing left to close — every session here is starred or flagged. "Close them too" below puts ${y===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)(yl,{children:`Conversations are kept — reopen under "Recently closed" or Archive.`})]}),children:(0,Q.jsxs)(`div`,{className:`sheet-body`,children:[x>0&&(0,Q.jsx)(`div`,{className:`section`,children:(0,Q.jsx)(`div`,{style:{padding:`10px 12px 0`},children:(0,Q.jsx)($a,{label:`what happens to the starred and flagged sessions`,value:a?`keep`:`close`,options:[{key:`keep`,label:`keep ${S}`,title:`leave the ${S} session(s) alone — out of every count and cut below`},{key:`close`,label:`close them too`,title:`treat the ${S} session(s) like any other`}],onChange:e=>o(e===`keep`)})})}),VE(d)&&(0,Q.jsxs)(`div`,{className:`filter-bar`,children:[(0,Q.jsx)(`span`,{className:`filter-bar-txt`,children:BE(E.length,v.length,d)}),(0,Q.jsxs)(`button`,{className:`filter-bar-clear`,onClick:F,children:[(0,Q.jsx)(Jh,{size:13}),` clear`]})]}),(0,Q.jsxs)(`div`,{className:`close-facets`,children:[(0,Q.jsx)(XE,{label:`State`,options:vE,counts:T.state,active:d.state,labels:yE,onToggle:e=>P(`state`,QE(d.state,e))}),(0,Q.jsx)(XE,{label:`Idle for`,options:bE,counts:T.idleOver,active:d.idleOver,labels:SE,onToggle:e=>P(`idleOver`,QE(d.idleOver,e)),hintId:`session.close.stale`}),N&&(0,Q.jsxs)(yl,{children:[N,`.`,` `,te&&(0,Q.jsx)(df,{of:`the idle-for reading`,label:`what does that change?`,children:te})]}),(0,Q.jsx)(XE,{label:`Open for`,options:bE,counts:T.openOver,active:d.openOver,labels:SE,onToggle:e=>P(`openOver`,QE(d.openOver,e))}),(0,Q.jsx)(XE,{label:`Underneath`,options:CE,counts:T.under,active:d.under,labels:wE,onToggle:e=>P(`under`,QE(d.under,e))}),(0,Q.jsx)(XE,{label:`Words at stake`,options:EE,counts:T.stakes,active:d.stakes,labels:DE,onToggle:e=>P(`stakes`,QE(d.stakes,e))}),(0,Q.jsx)(XE,{label:`Conversation`,options:kE,counts:T.convo,active:d.convo,labels:AE,onToggle:e=>P(`convo`,QE(d.convo,e))}),!g&&w.length>1&&(0,Q.jsx)(XE,{label:`Repo`,options:w,counts:T.repo,active:d.repo,labels:Object.fromEntries(w.map(e=>[e,l(e)])),onToggle:e=>P(`repo`,QE(d.repo,e))})]}),A&&(0,Q.jsx)(yl,{children:A}),(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`:``]})}),E.length===0?(0,Q.jsx)(Cf,{children:`Nothing here matches every facet ticked above.`}):E.map(t=>(0,Q.jsx)($E,{backends:e.backends,s:t,repoLabel:g?void 0:l(c(t)),kept:HE(t.id,p,O),onToggleKeep:()=>I(t.id),statusOf:C.statusOf,now:_,timedAt:D.get(t.id)},t.id))]})})})}var tD=16,nD=6e4;function rD(e){let t=IT(e),{sessions:n,recent:i,repos:a,reposAt:o,reposFailAt:s,launch:c}=e,l=Lb(Tr({rows:a,readAt:o})),{status:u,connVisible:d}=e.conn,{tailscaleIp:f}=e.conn.info,{focusRepo:p,setOverlay:m,lastVisitedId:h}=e.route,{openCwd:g,refreshRepos:_}=e.launchCore,{clearExited:v}=e.verbs,{tab:y,setTab:b,navMenu:x,setNavMenu:S,dl:C,activityBadge:w,activityKeys:T,visibleSessions:E,visibleExternal:D,clearFocus:O,repoGroups:k,sessionOrder:A,resetSessionOrder:ee,waitingTotal:j,waitingRepliesTotal:M,blockedTotal:N,codingTotal:te,starredTotal:P,flaggedTotal:F,shellsTotal:I,statusFilter:L,setStatusFilter:R,statusFilterActive:z,toggleStatusFilter:B,shownSessions:V,sortedSessions:ne,textQuery:H,setTextQuery:U,textOn:re,noRepoCollapsed:W,allReposCollapsed:ie,persistCollapsedRepos:ae,scheduleWords:oe,scheduleLead:se,scheduleTitle:ce,setCloseAllPick:le,repoForCwd:ue}=t,de=Su(),fe=rd(),pe=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let e=pe.current;if(!e||(e.scrollTop=PT.top,!h))return;let t=e.querySelector(`[data-sid="${CSS.escape(h)}"]`);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)(vT,{off:x,children:[(0,Q.jsxs)(`header`,{className:`topbar`,children:[p?(0,Q.jsxs)(`div`,{className:`brand brand-focus`,style:Cu(p),children:[(0,Q.jsx)(mT,{size:32,label:``}),(0,Q.jsx)(`span`,{children:t.shownOf(p)}),(0,Q.jsx)(`button`,{className:`focus-clear`,title:`exit repo focus — show all repos`,onClick:O,children:(0,Q.jsx)(Jh,{size:14})})]}):(0,Q.jsx)(`div`,{className:`brand`,children:(0,Q.jsx)(mT,{size:40})}),c.permissionMode&&lb.has(c.permissionMode)&&(0,Q.jsxs)(Y,{variant:`danger`,title:`New sessions launch with --permission-mode ${c.permissionMode}: every tool call runs without asking. Tap to change it.`,onClick:()=>m(`settings`),children:[(0,Q.jsx)(Zm,{size:tD}),` no approvals`]}),(0,Q.jsx)(Rc,{compact:!0}),(0,Q.jsxs)(Y,{className:`nav-key${x?` on`:``}`,"data-nohint":!0,"aria-label":`menu`,"aria-expanded":x,title:`menu — new, pad, activity, search, files, downloads, archive, logs, local/external${y===`external`?`
|
|
170
|
+
showing: external processes`:``}`,onClick:()=>{J(`action:nav.menu`),S(e=>!e)},children:[(0,Q.jsx)(ug,{size:tD}),y===`external`&&(0,Q.jsxs)(`span`,{className:`nav-tab`,children:[(0,Q.jsx)(qm,{size:12}),` external`]}),C.active>0&&(0,Q.jsxs)(`span`,{className:`nav-dl${C.stuck?` warn`:``}`,children:[(0,Q.jsx)(zm,{size:11}),` `,C.pct,`%`]}),(0,Q.jsx)(zS,{base:w})]}),x&&(0,Q.jsxs)(`div`,{className:`row-more nav-more`,children:[_n()&&(0,Q.jsx)(au,{size:tD,onOpen:()=>S(!1)}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{S(!1),m(`new`)},children:[(0,Q.jsx)(rg,{size:tD}),`new`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`prompt pad — write a thought now, decide where it goes later`,onClick:()=>{S(!1),m(`pad`)},children:[(0,Q.jsx)(Lm,{size:tD}),`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:()=>{J(`overlay:activity`),S(!1),Qi(T.length?{keys:T,label:`the ${T.length} ${T.length===1?`row`:`rows`} still open`}:null)},children:[(0,Q.jsx)(Ym,{size:tD}),`activity`,w>0&&(0,Q.jsx)(`span`,{className:`mic-badge`,children:w})]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`search words across all sessions`,onClick:()=>{S(!1),ju(null)},children:[(0,Q.jsx)(jh,{size:tD}),`search`]}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{S(!1),m(`gallery`)},children:[(0,Q.jsx)(mm,{size:tD}),`files`]}),(0,Q.jsxs)(`button`,{className:`more-act${C.active>0?` has-bar`:``}`,title:C.active>0?`downloads — ${C.active} in flight, ${C.pct}% of the bytes here${C.stuck?` (something is stopped)`:``}`:`downloads — files fetched to this device, and what each repo fetches on its own`,onClick:()=>{J(`overlay:pull`),S(!1),m(`pull`)},children:[(0,Q.jsx)(zm,{size:tD}),`downloads`,C.active>0?` ${C.active} · ${C.pct}%`:C.onPhone>0?` ${C.onPhone}`:``,C.active>0&&(0,Q.jsx)(`span`,{className:`more-dl-bar${C.stuck?` warn`:``}`,style:{width:`${C.pct}%`}})]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`archive — every conversation this repo ever had, resumable`,onClick:()=>{J(`overlay:archive`),S(!1),m(`archive`)},children:[(0,Q.jsx)(gg,{size:tD}),`archive`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`decision log — usage-limit auto-continues and what plugins suggested or answered`,onClick:()=>{S(!1),Gf(null)},children:[(0,Q.jsx)(xg,{size:tD}),`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:()=>{J(`overlay:sentlog`),S(!1),gs(null)},children:[(0,Q.jsx)(lg,{size:tD}),`sent`]}),(0,Q.jsxs)(`button`,{className:`more-act${y===`home`?` on`:``}`,title:`sessions this app started`,onClick:()=>{S(!1),b(`home`)},children:[(0,Q.jsx)(sh,{size:tD}),`local `,E.length?`(${E.length})`:``]}),(0,Q.jsxs)(`button`,{className:`more-act${y===`external`?` on`:``}`,title:"`claude` processes running outside this app — resumable from here",onClick:()=>{S(!1),b(`external`)},children:[(0,Q.jsx)(qm,{size:tD}),`external `,D.length?`(${D.length})`:``]}),(0,Q.jsx)(PS,{size:tD,onOpen:()=>S(!1)})]}),de.kind===`windows`?(0,Q.jsx)(OS,{sessions:n}):(0,Q.jsxs)(Y,{className:`usage-key ${de.kind===`usd`&&de.chip.hot?`danger`:``}`,"aria-label":de.kind===`usd`?de.chip.text:`token statistics`,title:`${de.kind===`usd`?de.chip.title:`Spend on this desktop`}\ntap for the token history`,onClick:()=>{J(`overlay:tokens`),m(`tokens`)},children:[(0,Q.jsx)(Ah,{size:tD}),de.kind===`usd`&&(0,Q.jsx)(`span`,{className:de.chip.hot?`usage-hot`:``,children:de.chip.text})]}),(0,Q.jsx)(Os,{}),(0,Q.jsx)(LS,{size:tD}),(0,Q.jsx)(Ea,{size:tD}),(0,Q.jsx)(Y,{className:fe===`insecure`?`danger`:``,"aria-label":`settings`,title:`settings — notifications, launch defaults, plugins, tools`,onClick:()=>m(`settings`),children:(0,Q.jsx)(wg,{size:tD})}),(0,Q.jsx)(If,{}),(0,Q.jsx)(gd,{})]}),e.banners]}),y===`home`&&(0,Q.jsxs)(`div`,{className:`list`,ref:pe,onScroll:e=>{PT.top=e.currentTarget.scrollTop},children:[n.length===0&&i.length===0&&a.length===0&&u!==`open`&&d&&(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)(um,{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 device?`}),(0,Q.jsxs)(`li`,{children:[`Is the desktop awake, with the `,et.name,` daemon running?`]}),f&&(0,Q.jsxs)(`li`,{children:[`Last known host address: `,(0,Q.jsx)(`span`,{className:`mono`,children:f})]})]})]}),[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)(qa,{repoName:e=>{let t=a.find(t=>t.worktreePath===e);return t?r(t):e.split(`/`).filter(Boolean).pop()||e}}),(0,Q.jsx)(Fr,{}),(0,Q.jsx)(gl,{repos:a.length,demo:yt(),onDemo:()=>Tt(`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`:``,o&&s>o&&Date.now()-o>nD?(0,Q.jsxs)(Q.Fragment,{children:[` — repos as of `,Rp(o),`, 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:[(0,Q.jsx)(UT,{kind:`wait`,n:j,replies:!!M,onClick:()=>{J(`overlay:questions`),m(`questions`)}}),(0,Q.jsx)(UT,{kind:`blocked`,n:N,hint:`limit.open`,onClick:()=>{J(`overlay:limits`),m(`limits`)}}),te>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat coding${z(`coding`)?` on`:``}`,title:`${te} session${te>1?`s`:``} working — tap to show only those`,onClick:()=>B(`coding`),children:[(0,Q.jsx)(ah,{size:13,className:`spin`}),te]}),P>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat starred${z(`starred`)?` on`:``}`,title:`${P} starred session${P>1?`s`:``} — tap to show only those`,onClick:()=>B(`starred`),children:[(0,Q.jsx)(Qh,{size:13,fill:`currentColor`}),P]}),F&&(0,Q.jsxs)(`button`,{className:`repo-group-stat fu-${F.tone}${z(`followup`)?` on`:``}`,"data-hint":`session.followup`,title:Ao(F.n),onClick:()=>B(`followup`),children:[(0,Q.jsx)(Th,{size:13,fill:`currentColor`}),F.n]}),I>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat coding${z(`shells`)?` on`:``}`,title:`${I} session${I>1?`s`:``} running background shells — tap to show only those`,onClick:()=>B(`shells`),children:[(0,Q.jsx)(Um,{size:13}),I]}),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:()=>{J(`action:session.order.reset`),ee(),X(`order reset to oldest-first`)},children:(0,Q.jsx)(bm,{size:tD})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`expand all repo groups`,title:W?`expand all — every repo group is already open`:`expand all — every repo group opens`,onClick:()=>{J(`action:repo.expand.all`),ae(new Set)},children:(0,Q.jsx)(Og,{size:tD})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`collapse all repo groups`,title:ie?`collapse all — every repo group is already folded`:`collapse all — headers stay, session and worktree rows hide`,onClick:()=>{J(`action:repo.collapse.all`),ae(new Set(k.map(e=>e.repoName)))},children:(0,Q.jsx)(Nh,{size:tD})}),(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:()=>{J(`overlay:fanout`),m(`fanout`)},children:(0,Q.jsx)($m,{size:tD})}),(0,Q.jsxs)(`button`,{className:`head-act${oe?` head-act-wide`:``}`,"aria-label":Td.automation.toLowerCase(),title:ce,onClick:()=>{J(`overlay:schedule`),vc(oe?se:null)},children:[(0,Q.jsx)(tg,{size:tD}),oe&&(0,Q.jsx)(`span`,{className:`head-act-n`,children:oe})]}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`sync repos`,title:`sync repos — pull, push or sync every repo at once`,onClick:()=>{J(`overlay:reposync`),m(`reposync`)},children:(0,Q.jsx)(Sg,{size:tD})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`rescan repos`,title:`rescan the host root for repos and worktrees`,onClick:()=>{_(),gE().then(e=>X(e?`repos rescanned — ${e} folder${e===1?``:`s`} without git, see above the list`:`repos rescanned`))},children:(0,Q.jsx)(qh,{size:tD})}),E.some(e=>!e.running&&!$p(e))&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`clear exited sessions`,title:`clear exited — drop the sessions that have already ended`,onClick:v,children:(0,Q.jsx)(Em,{size:tD})}),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:()=>le(`*`),children:(0,Q.jsx)(Jh,{size:tD})})]})]}),(k.length>0||re)&&(0,Q.jsxs)(`div`,{className:`section quick-filter`,children:[(0,Q.jsx)(jh,{size:14,className:`quick-filter-icon`}),(0,Q.jsx)(`input`,{type:`search`,value:H,placeholder:`filter sessions & repos`,"aria-label":`filter sessions and repos by the text on their rows`,onChange:e=>U(e.target.value),onKeyDown:e=>{e.key===`Escape`&&H&&(e.preventDefault(),e.stopPropagation(),U(``))}}),re&&(0,Q.jsxs)(`span`,{className:`quick-filter-n`,children:[V.length,` of `,ne.length]}),re&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`clear the filter`,title:`clear the filter — every row again`,onClick:()=>U(``),children:(0,Q.jsx)(Jh,{size:tD})}),(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:()=>{J(`action:launcher.search`),ju(null)},children:(0,Q.jsx)(xg,{size:tD})})]}),L&&(0,Q.jsxs)(`div`,{className:`section filter-bar`,children:[(0,Q.jsxs)(`span`,{className:`filter-bar-txt`,children:[`showing `,vo[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`,`, `,V.length,` of `,ne.length,` sessions`]}):(0,Q.jsxs)(Q.Fragment,{children:[` · `,V.length,` of `,ne.length]}),V.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)(Jh,{size:13}),` clear`]})]}),(0,Q.jsx)(_E,{refreshRepos:_}),k.map(({repoName:n,sessions:r})=>(0,Q.jsx)(QT,{p:e,m:t,repoName:n,sessions:r},`g:${n}`)),l&&(0,Q.jsx)(Cf,{children:l}),re&&k.length===0&&(0,Q.jsxs)(Cf,{children:[`No session or repo shows “`,H.trim(),`”. The search at the end of the filter looks through what sessions said.`]}),(0,Q.jsx)(fE,{p:e,m:t})]}),y===`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:()=>b(`home`),children:[(0,Q.jsx)(sh,{size:13}),` local`]})]}),D.length===0&&(0,Q.jsxs)(Cf,{children:["No `claude` running outside ",et.name,`. Started one in a terminal? It shows here.`]}),D.map(e=>(0,Q.jsxs)(Fc,{kind:`wrap`,children:[(0,Q.jsxs)(Fc,{as:`button`,kind:`grow`,onClick:()=>g(e.cwd,Tp(e.cwd),!0),children:[(0,Q.jsx)(Jf,{className:`mono`,children:Tp(e.cwd)}),(0,Q.jsxs)(Uu,{children:[`pid `,e.pid,` · `,(0,Q.jsx)(Fh,{size:12}),` resume here`]})]}),ue(e.cwd)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this repo`,onClick:()=>jl(ue(e.cwd).id),children:(0,Q.jsx)(Jm,{size:tD})})]},e.pid)),(0,Q.jsxs)(yl,{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)(eD,{p:e,m:t}),(0,Q.jsx)(Zx,{}),(0,Q.jsx)(oi,{})]})}function iD(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 aD(e,t,n){let r=r=>{r.key!==`Escape`||r.isComposing||iD(t(),r.target)===`back`&&e.setTimeout(()=>{!r.defaultPrevented&&t()>0&&n()},0)};return e.addEventListener(`keydown`,r),()=>e.removeEventListener(`keydown`,r)}var oD=`data-layout`,sD=Mu(`phone`);function cD(e,t){let n=()=>{let n=e?.matches?`wide`:`phone`;sD.set(n);try{t?.setAttribute(oD,n)}catch{}};return n(),e?e.addEventListener?(e.addEventListener(`change`,n),()=>e.removeEventListener?.(`change`,n)):(e.addListener?.(n),()=>e.removeListener?.(n)):()=>{}}function lD(){return $t(sD)}function uD(){return lD()===`wide`}if(typeof window<`u`&&typeof document<`u`){let e=null;try{e=window.matchMedia?.(`(min-width: 1024px)`)??null}catch{e=null}cD(e,document.documentElement)}function dD(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 fD=`--ws-side-w`;function pD(e){let t=dD(e,window.innerWidth);return document.documentElement.style.setProperty(fD,`${t}px`),t}function mD(){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(pD(mt(G.wideSideW,320))),()=>{document.documentElement.style.removeProperty(fD)}),[]);let r=e=>{e===320?vt(G.wideSideW):Et(G.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(pD(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=pD(e.current+i*16*(t.shiftKey?5:1));n(a),r(a)},onDoubleClick:()=>{let e=pD(320);n(e),r(e)}})}var hD={beside:{VAR:`--ws-beside-w`,key:G.wideBesideW,cls:`ws-beside-grip`,label:`Annotator width`},panel:{VAR:`--ws-panel-w`,key:G.widePanelW,cls:`ws-panel-grip`,label:`Panel width`}},gD=440,_D=360,vD=24;function yD(){return document.querySelector(`#root > .ws-side`)?.getBoundingClientRect().width??320}function bD(e){let t=Math.max(gD,window.innerWidth-yD()-_D);return Math.round(Math.min(t,Math.max(gD,e)))}function xD(e){return e?.parentElement?.getBoundingClientRect().width??gD}function SD({of:e=`beside`}){let t=(0,Z.useRef)(null),{VAR:n,key:r,cls:i,label:a}=hD[e],o=e=>{let t=bD(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=xD(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`),Et(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(),Et(r,String(o(xD(t.current)+n*vD*(e.shiftKey?5:1)))))},onDoubleClick:()=>{document.documentElement.style.removeProperty(n),vt(r)}})}function CD({sheet:e,overlay:t,launcher:n,session:r}){let i=uD(),a=e||null,o=uf()&&t===`image`&&!!a&&!!r,s=Sf()&&o;wD(o,s);let c=i&&!!a&&!ec(t);return TD(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)(mD,{})]}),r,(0,Q.jsxs)(`div`,{className:`ws-beside${s?` full`:``}`,children:[a,s?null:(0,Q.jsx)(SD,{})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`aside`,{className:`ws-side`,children:[n,(0,Q.jsx)(mD,{})]}),(c?null:a)??r??(0,Q.jsx)(`div`,{className:`screen ws-empty`,children:(0,Q.jsx)(Cf,{children:`Pick a session in the list, or start one.`})}),c?(0,Q.jsxs)(`div`,{className:`ws-panel`,children:[a,(0,Q.jsx)(SD,{of:`panel`})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[null,a??r??n,null]})}function wD(e,t){(0,Z.useEffect)(()=>{e||lc.set(!1)},[e]),(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),lc.set(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function TD(e,t){(0,Z.useEffect)(()=>e?aD(window,()=>Gu.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 ED=120;function DD(){(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>=ED?(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<ED&&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 OD(){let e=ay(),{connRef:t,status:n,send:r,liveSend:i,liveSendAll:a,liveAsk:o,reconnectAsk:s,setReconnectAsk:c}=e,{httpsUrl:l,root:u}=e.info,d=Ou(),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:ee,setUpdate:j,meter:M,setMeter:N,updateResultSeenRef:te}=Kx(),P=Ay(e,()=>Me.current),{pendingStars:F,pendingFollowUps:I,closeSession:L}=P,R=(0,Z.useMemo)(()=>ur(ur(h,F,Da),I,ta),[h,F,I]),{initRoute:z,activeId:B,setActiveId:V,overlay:ne,setOverlay:H,closeSheet:U,overlayRef:re,focusRepo:W,setFocusRepo:ie}=ly(),ae=Dy({conn:e,activeId:B,setActiveId:V,setOverlay:H,sessions:R,getActive:()=>_t,noteVisited:e=>Ve(e),onExit:()=>He.flushOutbox()});function oe(e){Re.current=!1,ae.focus(e)}let{termRef:se,geomRef:ce,buffers:le,exitedRef:ue,readMode:de,readModeRef:fe,setView:pe,fireReader:me,setOutlineJump:he,attach:ge}=ae,_e=Pv(),{compose:ve,setCompose:ye,composeNow:be,composeRef:xe,pushHistory:Se,insertCompose:Ce,composeFocused:we,setComposeFocused:Te}=_e,Ee=q(`enterSends`),De=q(`cliMode`);da(z,!!z.file&&Pn(z.file.relPath));let Oe=Qp(),ke=Il(),Ae=Wr(),je=sr(),Me=Sp(R),Ne=Sp(x),Pe=Ko()?.repoId??null,Fe=Rs();qn(),Sx({connRef:t,setLaunch:e=>bt(e),setHiddenRepoIds:e=>Jt(e)}),Qf(B);let Ie=ia(),Le=On(),Re=(0,Z.useRef)(!1),ze=(0,Z.useRef)(null),[Be,Ve]=(0,Z.useState)(null),He=Y_({conn:e,sessions:R,backends:k,repos:x,activeId:B,setActiveId:V,setLastVisitedId:e=>Ve(e),overlayRef:re,setOverlay:H,wantNavRef:Re,buffers:le,readModeRef:fe,exitedRef:ue,composeTextRef:be,setCompose:ye,pushHistory:Se,openSend:e=>Ft(e),sendTargetFor:(e,t)=>Rt(e,t),repoForCwd:e=>rn(e),focusSession:e=>oe(e)}),Ue=He.entries,{outboxRef:We,writeOutbox:Ge,flushOutbox:Ke,idleReason:qe,goneLanes:Je,submitInput:Ye,queueOp:Xe,queueBacklog:Ze,queueImageUpload:Qe,pendingSession:$e,answerPrompt:et,holdQueueRef:tt,laneLabel:nt,sendQueuedNow:rt,toggleHoldQueued:it,toggleSerialQueued:at,removeQueued:ot,editQueued:st,retargetQueued:ct,restoreQueued:lt,retryFailedQueued:ut,moveQueued:dt,addPromptToQueuedCreate:ft,scheduleQueueRows:pt,dropScheduleQueue:mt,repoIdOfEntry:ht}=He,{allBufsRef:gt}=He.uploads,_t=(0,Z.useMemo)(()=>R.find(e=>e.id===B)??$e,[R,B,$e]),vt=!!$e&&_t?.id===$e.id,yt=ov({backends:k,setOverlay:H,geomRef:ce,queue:He,setRepos:S,setReposAt:w,setReposFailAt:E,root:u,repos:x,active:_t,openingCwds:()=>$t,repoForCwd:e=>rn(e)}),{launch:G,setLaunch:bt,setLaunchOpt:xt,pickBackend:St,wireLaunch:Ct,sessionCan:wt,sessionCant:Tt,refreshRepos:Et,openRepo:Dt,openCwd:Ot,startSessionWithPrompt:kt,relaunch:At}=yt,jt=de&&!vt&&Ta(k,_t?bp(_t):void 0,`transcript`)&&!(_t?.cliSetup&&_t.running),Mt=_v({connRef:t,liveSend:i,liveSendAll:a,queue:He,sessions:R,getVisibleRepos:()=>Xt,intents:D,usage:Ie,launch:G,wireLaunch:Ct,geomRef:ce,repoForCwd:e=>rn(e),startSessionWithPrompt:kt,setOverlay:H,attach:ge}),{sendSeed:Nt,sendSeedRef:Pt,openSend:Ft,seedFromIntent:It,seedFromSchedule:Lt,sendTargetFor:Rt,renderRetime:zt}=Mt,Vt=Fv(_e,{conn:e,active:_t,pending:vt,activeId:B,sessions:R,readerShown:jt,enterSends:Ee,cliModeOn:De,setCliModeOn:e=>K(`cliMode`,e),showCli:()=>pe(!1),queue:He,sender:Mt,repoForCwd:e=>rn(e),leave:()=>V(null),cliInstalled:ee?.current,relaunch:At}),{cliMode:Ht,voice:Ut}=Vt,Wt=iT({activeId:B,active:_t,composeFocused:we,setComposeFocused:Te,composeRef:xe,cliMode:Ht}),Gt=(0,Z.useMemo)(()=>_t?pb(x,_t.cwd):null,[_t,x]),Kt=Gt?.id??null,qt=Hg(Kt,de),{setHiddenRepoIds:Jt,toggleHideRepo:Yt,visibleRepos:Xt,hiddenRepos:Zt,hiddenRepoPaths:Qt,openingCwds:$t,cwdInFocus:en,cwdVisible:tn,visibleBacklogItems:nn}=Cx({repos:x,focusRepo:W,outbox:Ue,bl:Fe}),rn=e=>pb(x,e),an=e=>pb(x,e.cwd),on=e=>mb(x,e),sn=e=>yb(x,e);(0,Z.useEffect)(()=>{Lu(W&&gb(x,W))},[W,x]),DD();let[cn,ln]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=setInterval(()=>{document.hidden||ln(e=>e+1)},3e4);return()=>clearInterval(e)},[]),(0,Z.useEffect)(()=>{ne&&J(`overlay:${ne}`)},[ne]);let un=e=>wx(e,{setOverlay:H,activeRepoId:Kt,active:_t,readMode:de,fireReader:me,send:r,geomRef:ce,submitInput:Ye,openCompanionShell:yt.openCompanionShell});$y({conn:e,term:ae,verbs:P,q:He,focusSession:oe},{connRef:t,setBackends:A,setSessions:g,setRecent:v,setClosed:b,setUpdate:j,setMeter:N,setIntents:O,updateResultSeenRef:te,wantNavRef:Re}),Ox({status:n,refreshRepos:Et,activeId:B,active:_t,wantNavRef:Re,firedIdRef:ze,bl:Fe,sessions:R,attach:ge,repos:x,overlay:ne}),Xg(_t);let{installEvt:dn,canInstall:mn,setCanInstall:gn,installed:_n}=kx();(0,Z.useEffect)(()=>{Ki()},[]),Bx({sessions:R,sessionRepoName:on,activeId:B,repos:x,attach:ge,closeSession:L,backends:k}),(0,Z.useEffect)(()=>{n===`open`&&(_t&&ne!==`settings`||r({t:`usage.refresh`}))},[ne,_t,n]),Wx({reposRef:Ne,initRoute:z,sessions:R,attach:ge,setOverlay:H});function vn(e){rm(e,()=>H(`git`))}if(Gx({outbox:Ue,activityFiled:Ae,activityConfirmedDone:je,allBufsRef:gt}),yu({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:Xe,submitInput:Ye,mintAckId:Bt,entries:He.entries,repoIdOf:ht,drop:e=>Ge(We.current.filter(t=>t.ackId!==e)),blocked:He.blocked,goneLanes:Je,laneLabel:nt,answerPrompt:et,queueBacklog:Ze,flush:Ke,idleReason:qe,serial:{on:p,set:e=>K(`serialSessions`,e)},verbs:{sendQueuedNow:rt,toggleHoldQueued:it,toggleSerialQueued:at,removeQueued:ot,editQueued:st,retargetQueued:ct,restoreQueued:lt,retryFailedQueued:ut,moveQueued:dt,addPromptToQueuedCreate:ft,scheduleQueueRows:pt,dropScheduleQueue:mt},uploads:He.uploads,queueImageUpload:Qe},nav:{overlay:ne,open:H,close:U,attach:ge,openRepo:Dt,openSend:Ft,startSessionWithPrompt:kt,openBacklogCut:ni,openScheduleCut:Bp,closeSession:L,openPlugin:e=>pn(e),openRepoHealth:si,openSetup:Ud,openContext:Ir,followFire:e=>{Re.current=!0,ze.current=e},openPadAt:zi,sendSeeded:()=>Pt.current!=null,openActivity:Qi,openGit:vn,openReader:ae.openReader,openCapture:Up,openBuild:Dn},launch:{setOpt:xt,wire:Ct,openCwd:Ot,relaunch:At,focusShell:yt.focusShell,shellCant:yt.shellCant,openCompanionShell:yt.openCompanionShell},term:{snapshot:ae.snapshot,geom:()=>ce.current},compose:{draft:ve,insert:Ce,seedDraft:Vt.seedDraft,typeOn:Vt.typeOn,send:Vt.sendNow,pushHistory:Se,removePadNotes:rf,loadSheetDraft:Ra,seedSheetDraft:_f,appendSheetDraft:fn,gridText:()=>se.current?.getText()??``},world:{sessions:R,repos:x,reposAt:C,visibleRepos:Xt,active:_t,activeRepo:Gt,backends:k,recent:_,closed:y,intents:D,launches:He.launches,budget:He.budget,billing:Le,meter:M,usage:Ie,get usageReadings(){return po()},get tokensOpenOn(){return Vn()},clearTokensOn:hn,launch:G,update:ee,sessionRepo:an,sessionRowTitle:sn,sessionCan:wt,sessionCant:Tt,repoForCwd:rn,refreshRepos:Et,schedules:Oe,pending:vt,backlog:Fe.items,backlogAuto:Fe.auto,cwdVisible:tn},files:{downloadArtifact:Wp,openArtifact:e=>Sc(e),viewImage:ku,attachForInbox:Rd,annotate:Hu,openSweep:Jn,editBacklogImage:td,annotateUrl:qf,attachFiles:Zs,browseTo:jp,openFileFrom:(e,t)=>Sc(e,t)},send:{renderRetime:zt,seedFromSchedule:Lt,seedFromIntent:It,targetFor:Rt},say:{toast:X,track:J,confirm:Xl}}),(0,Z.useEffect)(()=>zv(),[]),d)return(0,Q.jsx)(ua,{reconnect:()=>t.current.reconnect(),unlockSeal:xf});let yn=Wt.drawnSheet(xx({overlay:ne,setOverlay:H,closeSheet:U,connRef:t,status:n,setReconnectAsk:c,submitInput:Ye,holdQueueRef:tt,flushOutbox:Ke,removeQueued:ot,pendingSession:$e,insertCompose:Ce,setOutlineJump:he,setView:pe,active:_t,sessions:R,visibleRepos:Xt,outbox:Ue,usage:Ie,intents:D,launchCore:yt,sessionCant:Tt,pickBackend:St,refreshRepos:Et,sendCore:Mt,sendSeed:Nt,voice:Ut,installed:_n,canInstall:mn,installEvt:dn,setCanInstall:gn,gitRepoId:Pe,activeRepoId:Kt,repos:x,reposAt:C,backends:k}));return(0,Q.jsx)(CD,{sheet:yn,overlay:ne,session:_t?(0,Q.jsx)(rT,{active:_t,pending:vt,conn:e,term:ae,q:He,compose:Vt,launch:yt,chrome:Wt,backends:k,sessions:R,update:ee,readerShown:jt,activeRepo:Gt,transportKnown:qt,visibleBacklogItems:nn,intents:D,verbs:P,repoForCwd:rn,sessionRepoName:on,setActiveId:V,setOverlay:H,runToolbar:un}):null,launcher:(0,Q.jsx)(rD,{sessions:R,recent:_,closed:y,repos:x,reposAt:C,reposFailAt:T,backends:k,intents:D,outbox:Ue,nowTick:cn,launch:G,conn:e,route:{focusRepo:W,setFocusRepo:ie,setOverlay:H,lastVisitedId:Be},view:{visibleRepos:Xt,hiddenRepos:Zt,hiddenRepoPaths:Qt,cwdInFocus:en,cwdVisible:tn,toggleHideRepo:Yt,openingCwds:$t},launchCore:yt,term:ae,queue:He,openSend:Ft,verbs:P,openGitFor:vn,banners:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(cv,{q:He,status:n,reconnectAsk:s,setReconnectAsk:c,autoSend:f,confirmQueue:m,pullRecords:ke,setOverlay:H}),(0,Q.jsx)(rl,{httpsUrl:l}),(0,Q.jsx)(Mf,{onOpen:()=>H(`phonesetup`)}),(0,Q.jsx)(La,{update:ee,liveAsk:o,liveSend:i}),(0,Q.jsx)(fd,{})]})})})}var kD=`.bl-modal-backdrop, [role=dialog][aria-modal=true], [data-primary-key]`;function AD(e){return e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&!e.isComposing}function jD(e){let t=e.querySelectorAll(kD);return t[t.length-1]?.querySelector(`button.send:not(:disabled)`)??null}function MD(e){let t=(e??``).replace(/\s+/g,` `).trim();return t&&t.length<=24?`press “${t}”`:`press the dialog's button`}function ND(e=window){let t=wo({id:`primaryKey`,mods:[`ctrl`,`meta`],key:`Enter`,what:()=>MD(jD(e.document)?.textContent),when:()=>jD(e.document)!=null}),n=t=>{if(!AD(t))return;let n=jD(e.document);n&&(t.preventDefault(),t.stopPropagation(),n.click())};return e.addEventListener(`keydown`,n,!0),()=>{t(),e.removeEventListener(`keydown`,n,!0)}}function PD(e,t){return t||!e||!e.matches(`textarea[data-compose]:not(.pipe)`)?!1:(e.value??``).trim()!==``}function FD(e=document){return wo({id:`composeSend`,mods:[`ctrl`,`meta`],key:`Enter`,what:()=>`send`,when:()=>PD(e.activeElement,jD(e)!=null)})}var ID=[{ms:3e5,label:`5m`},{ms:36e5,label:`1h`},{ms:144e5,label:`4h`},{ms:864e5,label:`1d`}],LD=ID.reduce((e,t)=>Math.max(e,t.ms),0);function RD(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 zD(e,t,n){return{id:e,until:t+n}}function BD(e,t,n){return!e||!t||e.id!==t?!1:n<e.until&&e.until-n<=LD}function VD(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 HD=null;function UD(){let[e,t]=(0,Z.useState)(()=>od.get()),[,n]=(0,Z.useState)(0),[r,i]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>od.subscribe(t),[]),!Df()||e.phase!==`staged`||!e.stagedId||HD===e.stagedId||BD(RD(Dt(G.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)(Gh,{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 device.`}),!r&&(0,Q.jsx)(Y,{className:`staged-bar-go`,title:`restart into the new build — anything half-written in a box is lost`,onClick:()=>{J(`action:update.applyNow`),od.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)(Cg,{size:14})}),r&&ID.map(e=>(0,Q.jsx)(Y,{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:()=>{J(`action:update.snooze`),ht(G.webUpdateSnooze,zD(a,Date.now(),e.ms)),X(VD(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:()=>{HD=a,n(e=>e+1)},children:(0,Q.jsx)(Jh,{size:14})})]})}var WD=6e4;function GD({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)(()=>(Xr.start(),Xr.subscribe(n)),[]);let l=async()=>{let t=await dc.state();t?(o(`ok`),i(t.checkedAt),t.unlockedUntil&&t.unlockedUntil>Date.now()?e(t.unlockedUntil):(Xr.sync(t.items),Xr.pump())):o(`unreachable`)};(0,Z.useEffect)(()=>{l();let e=setInterval(()=>{document.visibilityState===`visible`&&l()},WD),t=()=>{document.visibilityState===`visible`&&l()};return document.addEventListener(`visibilitychange`,t),()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,t)}},[]);let u=yd(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)(hm,{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,` · `,nc(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 ${Hn(r)}`:``}`:r?`Last check ${Hn(r)}`:`Checking…`}),(0,Q.jsxs)(`button`,{className:`link-btn`,title:`check the desktop for new builds now`,onClick:()=>{l(),X(`checking for new builds`)},children:[(0,Q.jsx)(qh,{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)(Pg,{size:12}),` Unlock`]}),s&&(0,Q.jsx)(KD,{onCancel:()=>c(!1),onUnlocked:e})]})})}function KD({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 dc.unlock(n)}catch{e=null}a(!1),e?e.ok?t(e.unlockedUntil):(r(``),s(e.message||h(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)(Y,{variant:`primary`,type:`submit`,title:`unlock for 30 minutes`,children:i?`checking…`:`unlock`}),(0,Q.jsx)(Y,{type:`button`,onClick:e,children:`not now`}),o&&(0,Q.jsx)(`div`,{className:`set-note`,style:{color:`var(--dead)`},children:o})]})}function qD({until:e}){let[t,n]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let t=setTimeout(()=>window.location.reload(),hf(e));return()=>clearTimeout(t)},[e]);let r=A(e);if(!r)return null;let i=async()=>{n(!0);try{await dc.lock()}catch{}window.location.reload()};return(0,Q.jsxs)(`div`,{className:`passive-bar`,role:`status`,children:[(0,Q.jsx)(Ph,{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 JD=22,YD=36;function XD(){let e=yt(),t=Yr(),n=t===`static`?YD:JD;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`&&!ys();return(0,Q.jsxs)(`div`,{className:t===`static`?`demo-line static`:`demo-line`,role:`status`,style:{height:n},children:[(0,Q.jsx)(Kh,{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 `,et.name,` for real, open it from your own desktop host.`]}):`Demo — nothing runs on a computer`}),(0,Q.jsxs)(Y,{className:`demo-line-go`,onClick:js,children:[(0,Q.jsx)(pm,{size:11}),` More to try`]}),t!==`static`&&(0,Q.jsx)(Y,{className:`demo-line-go`,onClick:ss,children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($h,{size:11}),` Connect a real desktop`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wh,{size:11}),` Leave the demo`]})})]})}var ZD=3e5;ab(),zf(location,Date.now()),vf(),on();try{St()}catch(e){Ct(null,`The demo could not start: ${String(e?.message??e)}`)}to(),Ni(),kc(Rr),ws(),wu(),As(),Nl(),xc(),Ka(),Ms();for(let e of[Ne(`installLog`),...nt(`installLog`)])vt(e);Js(),ND(),Ku(),FD(),Cr();function QD(){let[e,t]=(0,Z.useState)(()=>!Ep()),n=Mc(),[r,i]=(0,Z.useState)(null);(0,Z.useEffect)(()=>e?Is(i):void 0,[e]);let[a,o]=(0,Z.useState)(()=>Ep()?tf(Yl(),null):`full`),s=(0,Z.useRef)(a===`full`),[c,l]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(e)return;let t=!0;return dc.status().then(e=>{if(!t||!e)return;Ec(e);let n=tf(Yl(),e);l(n===`full`&&e.scope===`passive`&&e.unlockedUntil?e.unlockedUntil:null),n===`passive`&&s.current?window.location.reload():o(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(!Df())return;od.markHealthy().then(()=>od.check());let e=setInterval(()=>{document.visibilityState===`visible`&&od.check()},ZD),t=Date.now(),n=()=>{document.visibilityState===`visible`&&(Date.now()-t<6e4||(t=Date.now(),od.check()))};document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n);let r=()=>{t=Date.now(),od.check()};window.addEventListener(ei,r);let i=od.watchAutoApply();return()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n),window.removeEventListener(ei,r),i()}},[]);let u=bt();return u?(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)(Kh,{size:16,style:{verticalAlign:`-3px`}}),` Demo not available`]}),(0,Q.jsx)(`div`,{className:`set-note`,children:u}),(0,Q.jsx)(`div`,{className:`set-row demo-problem`,children:(0,Q.jsx)(Y,{variant:`primary`,onClick:ss,children:`Leave the demo`})})]})}):e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ad,{}),Ep()&&(0,Q.jsx)(tu,{}),(0,Q.jsx)(Yf,{mode:`first`,pair:r,pairFromLink:!!r,onDone:()=>t(!Ep()),onCancel:Ep()?()=>t(!1):void 0})]}):a===`passive`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ad,{}),(0,Q.jsx)(UD,{}),(0,Q.jsx)(GD,{onUnlocked:e=>{l(e),s.current=!0,o(`full`)}})]}):n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ad,{}),(0,Q.jsx)(sc,{})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(OD,{}),(0,Q.jsx)($D,{}),(0,Q.jsx)(tc,{}),(0,Q.jsx)(Jl,{}),(0,Q.jsx)(ef,{}),(0,Q.jsx)(Rf,{}),(0,Q.jsx)(ad,{}),(0,Q.jsx)(Ef,{}),(0,Q.jsx)(sd,{}),(0,Q.jsx)(Od,{}),(0,Q.jsx)(Io,{}),(0,Q.jsx)(Ad,{}),(0,Q.jsx)(UD,{}),(0,Q.jsx)(zt,{}),(0,Q.jsx)(XD,{}),c&&(0,Q.jsx)(qD,{until:c}),(0,Q.jsx)(tu,{})]})}function $D(){return(0,Z.useEffect)(()=>{try{uu(ny())}catch{}try{Ci(ny())}catch{}try{Gd(ny(),xi)}catch{}try{Yc(ny())}catch{}},[]),null}if(Hc(),wd(),mp().finally(()=>(0,Bg.createRoot)(document.getElementById(`root`)).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(ib,{children:(0,Q.jsx)(QD,{})})}))),`serviceWorker`in navigator&&!_n()){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(()=>{})})}
|