clawpad 0.3.11 → 0.3.12
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +5 -4
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/routes-manifest.json +6 -0
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +2 -2
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/ai/write/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/changes/[id]/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/changes/record/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/changes/revert/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/changes/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/changes/run/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/abort/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/route.js +2 -2
- package/.next/standalone/.next/server/app/api/chat/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/files/pages/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/files/recent/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/files/search/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/files/spaces/[space]/pages/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/files/spaces/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/files/watch/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/gateway/detect/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/gateway/events/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/gateway/features/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/gateway/history/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/gateway/resolve/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/gateway/sessions/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/gateway/status/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/openclaw/commands/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/settings/search-status/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/setup/bootstrap/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/setup/bootstrap-workspace/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/setup/status/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/setup/trigger-onboarding/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/version/route.js +1 -0
- package/.next/standalone/.next/server/app/api/version/route.js.nft.json +1 -0
- package/.next/standalone/.next/server/app/api/version/route_client-reference-manifest.js +1 -0
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/connection/page.js +2 -2
- package/.next/standalone/.next/server/app/settings/connection/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/connection/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/connection.html +1 -1
- package/.next/standalone/.next/server/app/settings/connection.rsc +3 -3
- package/.next/standalone/.next/server/app/settings/connection.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/settings/connection.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings/connection.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings/connection.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings/connection.segments/settings/connection/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings/connection.segments/settings/connection.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings/connection.segments/settings.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings/page.js +2 -2
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/relay/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/relay.html +1 -1
- package/.next/standalone/.next/server/app/settings/relay.rsc +2 -2
- package/.next/standalone/.next/server/app/settings/relay.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings/relay.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings/relay.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings/relay.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings/relay.segments/settings/relay/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings/relay.segments/settings/relay.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings/relay.segments/settings.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings.html +1 -1
- package/.next/standalone/.next/server/app/settings.rsc +3 -3
- package/.next/standalone/.next/server/app/settings.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/setup/page.js +2 -2
- package/.next/standalone/.next/server/app/setup/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/setup.html +1 -1
- package/.next/standalone/.next/server/app/setup.rsc +3 -3
- package/.next/standalone/.next/server/app/setup.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/setup.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/setup.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/setup.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/setup.segments/setup/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/setup.segments/setup.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/waitlist/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/waitlist.html +1 -1
- package/.next/standalone/.next/server/app/waitlist.rsc +2 -2
- package/.next/standalone/.next/server/app/waitlist.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/waitlist.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/waitlist.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/waitlist.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/waitlist.segments/waitlist/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/waitlist.segments/waitlist.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/workspace/[...path]/page.js +1 -1
- package/.next/standalone/.next/server/app/workspace/[...path]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/workspace/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/workspace/page.js +2 -2
- package/.next/standalone/.next/server/app/workspace/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/workspace/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/workspace/search/page.js +1 -1
- package/.next/standalone/.next/server/app/workspace/search/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/workspace/search/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/workspace/search.html +2 -2
- package/.next/standalone/.next/server/app/workspace/search.rsc +3 -3
- package/.next/standalone/.next/server/app/workspace/search.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/workspace/search.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/workspace/search.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/workspace/search.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/workspace/search.segments/workspace/search/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/workspace/search.segments/workspace/search.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/workspace/search.segments/workspace.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/workspace.html +2 -2
- package/.next/standalone/.next/server/app/workspace.rsc +4 -4
- package/.next/standalone/.next/server/app/workspace.segments/_full.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/workspace.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/workspace.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/workspace.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/workspace.segments/workspace/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/workspace.segments/workspace.segment.rsc +2 -2
- package/.next/standalone/.next/server/app-paths-manifest.json +5 -4
- package/.next/standalone/.next/server/chunks/3251.js +2 -2
- package/.next/standalone/.next/server/chunks/5502.js +9 -0
- package/.next/standalone/.next/server/chunks/{4153.js → 7174.js} +1 -1
- package/.next/standalone/.next/server/chunks/869.js +1 -0
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +2 -2
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/package.json +1 -1
- package/.next/static/chunks/1285-513d0a20b39e5e47.js +9 -0
- package/.next/static/chunks/4774-0aba1d8f0894e065.js +1 -0
- package/.next/static/chunks/{4576-ccb386f24fa8bdc1.js → 7230-ae3fcfca93b2ad80.js} +2 -2
- package/.next/static/chunks/7715-382cb4e3101fa7b2.js +1 -0
- package/.next/static/chunks/app/_global-error/page-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/ai/write/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/changes/[id]/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/changes/record/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/changes/revert/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/changes/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/changes/run/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/chat/abort/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/chat/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/files/pages/[...path]/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/files/recent/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/files/search/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/files/spaces/[space]/pages/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/files/spaces/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/files/watch/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/gateway/detect/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/gateway/events/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/gateway/features/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/gateway/history/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/gateway/resolve/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/gateway/sessions/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/gateway/status/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/openclaw/commands/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/search/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/settings/search-status/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/setup/bootstrap/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/setup/bootstrap-workspace/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/setup/status/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/setup/trigger-onboarding/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/api/version/route-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/page-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/app/settings/connection/page-1a1e054213238670.js +1 -0
- package/.next/static/chunks/app/settings/page-4bd7d73b6e6cf2a1.js +1 -0
- package/.next/static/chunks/app/setup/page-54c94bddfa1931b9.js +1 -0
- package/.next/static/chunks/app/workspace/layout-9f33c59bd846f401.js +6 -0
- package/.next/static/chunks/app/workspace/page-e1500b07743ca666.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-1570b21ab640ec17.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-1570b21ab640ec17.js +1 -0
- package/.next/static/css/7328dda059c2e2c3.css +1 -0
- package/.next/static/dE2vgzBfR9CceWwVrnKdq/_buildManifest.js +1 -0
- package/package.json +1 -1
- package/.next/standalone/.next/server/chunks/3887.js +0 -9
- package/.next/static/chunks/4747-c8d07e5bd3f8e1e6.js +0 -9
- package/.next/static/chunks/app/_global-error/page-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/ai/write/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/changes/[id]/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/changes/record/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/changes/revert/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/changes/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/changes/run/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/chat/abort/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/chat/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/files/pages/[...path]/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/files/recent/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/files/search/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/files/spaces/[space]/pages/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/files/spaces/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/files/watch/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/gateway/detect/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/gateway/events/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/gateway/features/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/gateway/history/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/gateway/resolve/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/gateway/sessions/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/gateway/status/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/openclaw/commands/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/search/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/settings/search-status/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/setup/bootstrap/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/setup/bootstrap-workspace/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/setup/status/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/api/setup/trigger-onboarding/route-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/page-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/app/settings/connection/page-48795cc00b79bdb2.js +0 -1
- package/.next/static/chunks/app/settings/page-cf8ede3b399cd2ba.js +0 -1
- package/.next/static/chunks/app/setup/page-9e2117ba208823f3.js +0 -1
- package/.next/static/chunks/app/workspace/layout-da037c6e6a03fd07.js +0 -6
- package/.next/static/chunks/app/workspace/page-2f81f83f2248f181.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-961a312de2dcc334.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-961a312de2dcc334.js +0 -1
- package/.next/static/css/26ca2e105e2de17f.css +0 -1
- package/.next/static/goNHxoIsvvFw7X46QPSkk/_buildManifest.js +0 -1
- /package/.next/static/{goNHxoIsvvFw7X46QPSkk → dE2vgzBfR9CceWwVrnKdq}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[620],{7814:(e,t,s)=>{"use strict";function a(e){let t=e.replace(/\.md$/,"").split("/").filter(Boolean).map(e=>encodeURIComponent(e));return 0===t.length?"/workspace":`/workspace/${t.join("/")}`}s.d(t,{C:()=>a})},13545:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},39667:(e,t,s)=>{Promise.resolve().then(s.bind(s,69676))},48368:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},52799:(e,t,s)=>{"use strict";s.d(t,{cn:()=>n});var a=s(29722),r=s(622);function n(...e){return(0,r.QP)((0,a.$)(e))}},60529:(e,t,s)=>{"use strict";s.d(t,{p:()=>n});var a=s(95155);s(12115);var r=s(52799);function n({className:e,type:t,...s}){return(0,a.jsx)("input",{type:t,"data-slot":"input",className:(0,r.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...s})}},69676:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>C});var a=s(95155),r=s(12115),n=s(73321),i=s(80642),o=s(52159),l=s(89239),d=s(60529),c=s(70872),u=s(6296),x=s(94514),p=s(13545),m=s(21362),g=s(42129),h=s(86901),f=s(48368),y=s(49619);let b=(0,s(90425).A)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var j=s(93571),v=s(7814);let w={enter:e=>({x:e>0?80:-80,opacity:0}),center:{x:0,opacity:1},exit:e=>({x:e>0?-80:80,opacity:0})},N=[{id:"engineering-devops",icon:"\uD83C\uDFD7️",label:"Engineering & DevOps",description:"Infrastructure, runbooks, architecture, and delivery workflows."},{id:"research-academia",icon:"\uD83D\uDD2C",label:"Research & Academia",description:"Projects, literature reviews, experiments, and writing drafts."},{id:"business-consulting",icon:"\uD83C\uDFE2",label:"Business & Consulting",description:"Clients, strategy, meetings, and engagement tracking."},{id:"creative-writing",icon:"✍️",label:"Creative & Writing",description:"Drafts, research, world-building, and idea capture."},{id:"personal-knowledge",icon:"\uD83D\uDCDD",label:"Personal Knowledge (PARA)",description:"Projects, areas, resources, and archives."},{id:"other",icon:"✨",label:"Other",description:"General starter structure that your agent can customize."}],k={"engineering-devops":["infrastructure","devops","architecture","security","team","daily-notes"],"research-academia":["projects","literature","experiments","writing","notes"],"business-consulting":["clients","projects","meetings","strategy","templates","daily-notes"],"creative-writing":["projects","drafts","research","world-building","ideas","daily-notes"],"personal-knowledge":["projects","areas","resources","archive","daily-notes"],other:["projects","notes","resources","daily-notes"]};function C(){let[e,t]=(0,r.useState)(1),[s,l]=(0,r.useState)(1),d=(0,n.useRouter)(),[c,u]=(0,r.useState)(null),[x,p]=(0,r.useState)(!0),[m,g]=(0,r.useState)(""),[h,f]=(0,r.useState)(null),[y,b]=(0,r.useState)(!0),[j,N]=(0,r.useState)(!1),[C,O]=(0,r.useState)(!1),[$,E]=(0,r.useState)(null),[I,T]=(0,r.useState)(!1),[_,M]=(0,r.useState)("engineering-devops"),[F,U]=(0,r.useState)(""),[W,R]=(0,r.useState)(!1),[Y,B]=(0,r.useState)("both"),[D,L]=(0,r.useState)(""),[H,q]=(0,r.useState)([]),[K,V]=(0,r.useState)("welcome-to-clawpad.md");(0,r.useEffect)(()=>{fetch("/api/gateway/detect").then(e=>e.json()).then(e=>{u(e),p(!1)}).catch(()=>{u({found:!1}),p(!1)})},[]),(0,r.useEffect)(()=>{fetch("/api/setup/status?includeCounts=true").then(e=>e.json()).then(e=>{f(e),b(!1)}).catch(()=>b(!1))},[]),(0,r.useEffect)(()=>{let e=new Set(k[_]??[]);q(t=>t.filter(t=>e.has(t)))},[_]),(0,r.useEffect)(()=>{W&&q(e=>e.length>0?e:[...k[_]??[]])},[W,_]);let Z=(0,r.useCallback)(s=>{l(s>e?1:-1),t(s)},[e]),G=async()=>{N(!0),E(null),T(!1);try{let e=await fetch("/api/setup/trigger-onboarding",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceType:_,customUseCase:"other"===_?F:void 0,importEnabled:W,importMode:Y,importSourcePaths:D.split("\n").map(e=>e.trim()).filter(Boolean),importTargetSpaces:H})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Failed to set up workspace")}let t=await e.json().catch(()=>null);T(!!t?.onboardingTriggered);let s="string"==typeof t?.welcomePage?.path&&t.welcomePage.path.trim()?t.welcomePage.path.trim():null,a=Array.isArray(t?.scaffoldResult?.pages)?t.scaffoldResult.pages.find(e=>"object"==typeof e&&null!==e&&"string"==typeof e.path&&"error"!==e.status)?.path??null:null;V(s??a??"welcome-to-clawpad.md"),O(!0);let r=await fetch("/api/setup/status?includeCounts=true");r.ok&&f(await r.json())}catch(e){E(e?.message||"Could not create workspace. Please retry.")}finally{N(!1)}},J=(0,r.useCallback)(async()=>{let e=K.endsWith(".md")?K:`${K}.md`,t=encodeURIComponent(e),s=(0,v.C)(e);for(let e=0;e<3;e+=1){try{if((await fetch(`/api/files/pages/${t}`,{cache:"no-store"})).ok)return void d.push(s)}catch{}await new Promise(e=>setTimeout(e,200))}d.push("/workspace")},[d,K]);return(0,a.jsx)("div",{className:"flex min-h-screen items-center justify-center px-4 bg-background",children:(0,a.jsxs)("div",{className:"w-full max-w-md",children:[(0,a.jsx)(i.N,{mode:"wait",custom:s,children:(0,a.jsx)(o.P.div,{custom:s,variants:w,initial:"enter",animate:"center",exit:"exit",transition:{duration:.3,ease:"easeInOut"},children:(0,a.jsxs)("div",{className:"rounded-xl border bg-card p-8 shadow-lg",children:[1===e&&(0,a.jsx)(A,{gateway:c,detecting:x,manualUrl:m,onManualUrlChange:g,onNext:()=>Z(2)}),2===e&&(0,a.jsx)(P,{status:h,loading:y,bootstrapping:j,bootstrapped:C,bootstrapError:$,gatewayConnected:c?.found??!1,workspaceUseCase:_,customUseCase:F,importEnabled:W,importMode:Y,importSourcePathsText:D,importTargetSpaces:H,onWorkspaceUseCaseChange:M,onCustomUseCaseChange:U,onImportEnabledChange:R,onImportModeChange:B,onImportSourcePathsTextChange:L,onImportTargetSpacesChange:q,onBootstrap:G,onNext:()=>Z(3)}),3===e&&(0,a.jsx)(S,{onNext:()=>Z(4)}),4===e&&(0,a.jsx)(z,{onboardingTriggered:I,onOpen:J})]})},e)}),(0,a.jsx)("div",{className:"flex items-center justify-center gap-2 mt-6",children:[1,2,3,4].map(t=>(0,a.jsx)("div",{className:`h-1.5 rounded-full transition-all duration-300 ${t===e?"w-8 bg-primary":t<e?"w-4 bg-primary/40":"w-4 bg-muted"}`},t))})]})})}function A({gateway:e,detecting:t,manualUrl:s,onManualUrlChange:r,onNext:n}){return(0,a.jsxs)("div",{className:"space-y-6 text-center",children:[(0,a.jsx)(o.P.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},transition:{delay:.1,duration:.3},className:"mx-auto flex h-20 w-20 items-center justify-center rounded-2xl bg-muted/60 ring-1 ring-border/60",children:(0,a.jsx)(j.R,{variant:"icon",size:44,alt:""})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Welcome to ClawPad"}),(0,a.jsxs)("p",{className:"text-muted-foreground text-sm",children:["The workspace for"," ",(0,a.jsx)(O,{text:"OpenClaw is your local AI agent platform that runs on your machine.",children:"OpenClaw"})]})]}),(0,a.jsx)("div",{className:"rounded-lg border bg-muted/30 p-4 text-left",children:t?(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(u.A,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-sm font-medium",children:["Detecting"," ",(0,a.jsx)(O,{text:"The gateway is the local server that connects ClawPad to your AI agent. It usually runs at ws://127.0.0.1:18789.",children:"OpenClaw"}),"…"]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Looking for your local gateway"})]})]}):e?.found?(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/30",children:(0,a.jsx)(x.A,{className:"h-4 w-4 text-green-600 dark:text-green-400"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium text-green-700 dark:text-green-400",children:"OpenClaw Detected"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:e.agentName?`Agent: ${e.agentName}`:`Found via ${e.source}`})]})]}):(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-yellow-100 dark:bg-yellow-900/30",children:(0,a.jsx)(p.A,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium text-yellow-700 dark:text-yellow-400",children:"OpenClaw Not Detected"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"You can still use ClawPad as a local workspace"})]})]}),(0,a.jsx)(d.p,{placeholder:"ws://127.0.0.1:18789",value:s,onChange:e=>r(e.target.value),className:"text-sm"})]})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)(l.$,{size:"lg",className:"w-full",onClick:n,children:[e?.found?"Next":"Continue Without Agent",(0,a.jsx)(m.A,{className:"ml-1 h-4 w-4"})]}),!e?.found&&!t&&(0,a.jsx)("button",{onClick:n,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Skip for now"})]})]})}function P({status:e,loading:t,bootstrapping:s,bootstrapped:r,bootstrapError:n,gatewayConnected:i,workspaceUseCase:c,customUseCase:p,importEnabled:h,importMode:f,importSourcePathsText:y,importTargetSpaces:b,onWorkspaceUseCaseChange:j,onCustomUseCaseChange:v,onImportEnabledChange:w,onImportModeChange:C,onImportSourcePathsTextChange:A,onImportTargetSpacesChange:P,onBootstrap:S,onNext:z}){let $=e?.hasWorkspace||r,E=k[c]??[];return(0,a.jsxs)("div",{className:"space-y-6 text-center",children:[(0,a.jsx)(o.P.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},transition:{delay:.1,duration:.3},className:"mx-auto flex h-20 w-20 items-center justify-center rounded-2xl bg-muted",children:(0,a.jsx)(g.A,{className:"h-10 w-10 text-muted-foreground"})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h1",{className:"text-2xl font-semibold tracking-tight",children:["Set Up Your"," ",(0,a.jsx)(O,{text:"A workspace is a folder of markdown files that both you and your AI agent can read and edit.",children:"Workspace"})]}),(0,a.jsx)("p",{className:"text-muted-foreground text-sm",children:"ClawPad reads and writes markdown files on disk"})]}),(0,a.jsx)("div",{className:"rounded-lg border bg-muted/30 px-4 py-3 font-mono text-sm",children:"~/.openclaw/pages/"}),t?(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-muted-foreground py-2",children:[(0,a.jsx)(u.A,{className:"h-4 w-4 animate-spin"}),"Checking workspace…"]}):$?(0,a.jsxs)("div",{className:"rounded-lg border bg-green-50 dark:bg-green-900/20 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 mb-2",children:[(0,a.jsx)(x.A,{className:"h-5 w-5 text-green-600 dark:text-green-400"}),(0,a.jsx)("span",{className:"text-sm font-medium text-green-700 dark:text-green-400",children:"Your workspace is ready"})]}),e&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.totalSpaces," spaces \xb7 ",e.totalPages," pages"]})]}):(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"What will you mainly use ClawPad for?"}),(0,a.jsx)("div",{className:"space-y-2 text-left",children:N.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>j(e.id),className:`w-full rounded-lg border p-3 transition-colors ${c===e.id?"border-primary bg-primary/5":"hover:bg-muted/30"}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{children:e.icon}),(0,a.jsx)("span",{className:"text-sm font-medium",children:e.label})]}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.description})]},e.id))}),"other"===c&&(0,a.jsx)(d.p,{placeholder:"Describe your use case (optional)",value:p,onChange:e=>v(e.target.value),className:"text-sm"}),(0,a.jsxs)("div",{className:"rounded-lg border bg-muted/20 p-3 text-left space-y-3",children:[(0,a.jsxs)("label",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:h,onChange:e=>w(e.target.checked)}),(0,a.jsx)("span",{children:"Bring existing documents with OpenClaw during setup"})]}),h&&(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-foreground",children:"Import mode"}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-1.5",children:["copy","derive","both"].map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>C(e),className:`rounded-md border px-2 py-1 text-xs capitalize transition-colors ${f===e?"border-primary bg-primary/10 text-foreground":"hover:bg-muted/40"}`,children:e},e))})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-foreground",children:"Local source paths"}),(0,a.jsx)("textarea",{className:"min-h-20 w-full rounded-md border bg-background px-2 py-1.5 text-xs",placeholder:"/Users/you/Documents\n~/Desktop/project-notes",value:y,onChange:e=>A(e.target.value)}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"One path per line."})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-foreground",children:"Target spaces"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:E.map(e=>{let t=b.includes(e);return(0,a.jsx)("button",{type:"button",onClick:()=>{b.includes(e)?P(b.filter(t=>t!==e)):P([...b,e].sort((e,t)=>e.localeCompare(t)))},className:`rounded-md border px-2 py-1 text-[11px] transition-colors ${t?"border-primary bg-primary/10 text-foreground":"hover:bg-muted/40"}`,children:e},e)})})]})]})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:i?"ClawPad will scaffold this structure and trigger OpenClaw to continue setup.":"ClawPad will scaffold this structure locally. You can connect OpenClaw later."}),(0,a.jsx)(l.$,{size:"lg",className:"w-full",onClick:S,disabled:s,children:s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Setting Up Workspace…"]}):"Set Up Workspace"}),n&&(0,a.jsx)("div",{className:"rounded-lg border border-red-300/60 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/20 dark:text-red-300",children:n})]}),$&&(0,a.jsxs)(l.$,{size:"lg",className:"w-full",onClick:z,children:["Next",(0,a.jsx)(m.A,{className:"ml-1 h-4 w-4"})]})]})}function S({onNext:e}){return(0,a.jsxs)("div",{className:"space-y-6 text-center",children:[(0,a.jsxs)("div",{className:"relative mx-auto h-28 w-28",children:[$.map((e,t)=>(0,a.jsx)(o.P.div,{initial:{opacity:0,scale:0,x:0,y:0},animate:{opacity:[0,1,1,0],scale:[0,1,1,.5],x:e.x,y:e.y},transition:{duration:1.2,delay:.4+.05*t,ease:"easeOut"},className:"absolute left-1/2 top-1/2 h-2 w-2 rounded-full",style:{backgroundColor:e.color}},t)),(0,a.jsx)(o.P.div,{initial:{scale:0,opacity:.8},animate:{scale:2.5,opacity:0},transition:{duration:.8,delay:.2,ease:"easeOut"},className:"absolute inset-0 m-auto h-20 w-20 rounded-full border-2 border-green-400"}),(0,a.jsx)(o.P.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",stiffness:200,damping:15,delay:.1},className:"absolute inset-0 m-auto flex h-20 w-20 items-center justify-center rounded-2xl bg-green-100 dark:bg-green-900/30",children:(0,a.jsx)(o.P.div,{initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:1},transition:{delay:.4,duration:.4},children:(0,a.jsx)(x.A,{className:"h-10 w-10 text-green-600 dark:text-green-400"})})})]}),(0,a.jsxs)(o.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.5},className:"space-y-2",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"You're All Set! \uD83C\uDF89"}),(0,a.jsx)("p",{className:"text-muted-foreground text-sm",children:"Your workspace is ready. Let's see what you can do."})]}),(0,a.jsxs)(o.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.7},className:"rounded-lg border bg-muted/30 p-4 text-left space-y-2",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Keyboard Shortcuts"}),(0,a.jsxs)("div",{className:"space-y-1.5 text-sm text-muted-foreground",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("kbd",{className:"rounded border bg-muted px-1.5 py-0.5 text-xs font-mono",children:"⌘K"})," ","Search across all pages"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("kbd",{className:"rounded border bg-muted px-1.5 py-0.5 text-xs font-mono",children:"⌘N"})," ","Create a new page"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("kbd",{className:"rounded border bg-muted px-1.5 py-0.5 text-xs font-mono",children:"⌘⇧L"})," ","Open AI chat panel"]})]})]}),(0,a.jsx)(o.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.9},children:(0,a.jsxs)(l.$,{size:"lg",className:"w-full",onClick:e,children:["What's Next?",(0,a.jsx)(m.A,{className:"ml-1 h-4 w-4"})]})})]})}function z({onboardingTriggered:e,onOpen:t}){let s=e?[{icon:h.A,title:"Chat with your agent",desc:"Your agent is ready to help you set up. Check the chat panel!",color:"text-purple-500",bg:"bg-purple-100 dark:bg-purple-900/30"},{icon:f.A,title:"Create pages together",desc:"Ask your agent to create documents, plans, or notes.",color:"text-blue-500",bg:"bg-blue-100 dark:bg-blue-900/30"},{icon:y.A,title:"Organize your workspace",desc:"Your agent can help structure folders based on your needs.",color:"text-green-500",bg:"bg-green-100 dark:bg-green-900/30"}]:[{icon:f.A,title:"Create your first page",desc:"Hit ⌘N to start a new page in any space.",color:"text-blue-500",bg:"bg-blue-100 dark:bg-blue-900/30"},{icon:y.A,title:"Connect your agent",desc:"Your OpenClaw agent can read and edit pages in real-time.",color:"text-green-500",bg:"bg-green-100 dark:bg-green-900/30"},{icon:h.A,title:"Try AI writing",desc:"Press ⌘⇧L to chat with your agent and generate content.",color:"text-purple-500",bg:"bg-purple-100 dark:bg-purple-900/30"}];return(0,a.jsxs)("div",{className:"space-y-6 text-center",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:e?"Your Agent is Ready!":"What's Next?"}),(0,a.jsx)("p",{className:"text-muted-foreground text-sm",children:e?"Your agent has started setting up your workspace.":"Here are some things to try first."})]}),(0,a.jsx)("div",{className:"space-y-3 text-left",children:s.map((e,t)=>(0,a.jsxs)(o.P.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1+.15*t,duration:.3},className:"flex items-start gap-3 rounded-lg border p-3 hover:bg-muted/30 transition-colors",children:[(0,a.jsx)("div",{className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${e.bg}`,children:(0,a.jsx)(e.icon,{className:`h-4 w-4 ${e.color}`})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:e.title}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:e.desc})]})]},e.title))}),(0,a.jsx)(o.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.6},children:(0,a.jsxs)(l.$,{size:"lg",className:"w-full",onClick:t,children:["Open Welcome Page",(0,a.jsx)(m.A,{className:"ml-1 h-4 w-4"})]})})]})}function O({children:e,text:t}){return(0,a.jsxs)(c.m_,{children:[(0,a.jsx)(c.k$,{asChild:!0,children:(0,a.jsxs)("span",{className:"inline-flex items-center gap-0.5 underline decoration-dotted underline-offset-2 cursor-help",children:[e,(0,a.jsx)(b,{className:"inline h-3 w-3 text-muted-foreground"})]})}),(0,a.jsx)(c.ZI,{side:"top",className:"max-w-[220px]",children:t})]})}let $=[{x:-40,y:-35,color:"#4A9EFF"},{x:35,y:-40,color:"#00A67E"},{x:-35,y:25,color:"#9333EA"},{x:40,y:20,color:"#F59E0B"},{x:-15,y:-45,color:"#EF4444"},{x:20,y:-30,color:"#10B981"},{x:-45,y:5,color:"#6366F1"},{x:45,y:-10,color:"#F97316"},{x:0,y:40,color:"#EC4899"},{x:-25,y:35,color:"#14B8A6"},{x:30,y:35,color:"#8B5CF6"},{x:10,y:-50,color:"#F43F5E"}]},70872:(e,t,s)=>{"use strict";s.d(t,{Bc:()=>i,ZI:()=>d,k$:()=>l,m_:()=>o});var a=s(95155);s(12115);var r=s(28935),n=s(52799);function i({delayDuration:e=0,...t}){return(0,a.jsx)(r.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function o({...e}){return(0,a.jsx)(i,{children:(0,a.jsx)(r.Root,{"data-slot":"tooltip",...e})})}function l({...e}){return(0,a.jsx)(r.Trigger,{"data-slot":"tooltip-trigger",...e})}function d({className:e,sideOffset:t=0,children:s,...i}){return(0,a.jsx)(r.Portal,{children:(0,a.jsxs)(r.Content,{"data-slot":"tooltip-content",sideOffset:t,className:(0,n.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...i,children:[s,(0,a.jsx)(r.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}},86901:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]])},89239:(e,t,s)=>{"use strict";s.d(t,{$:()=>l});var a=s(95155);s(12115);var r=s(18460),n=s(42442),i=s(52799);let o=(0,r.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function l({className:e,variant:t="default",size:s="default",asChild:r=!1,...l}){let d=r?n.bL:"button";return(0,a.jsx)(d,{"data-slot":"button","data-variant":t,"data-size":s,className:(0,i.cn)(o({variant:t,size:s,className:e})),...l})}},93571:(e,t,s)=>{"use strict";s.d(t,{R:()=>l});var a=s(95155),r=s(5772),n=s(52799);let i=265/235,o=1152/235;function l({variant:e="icon",size:t=24,className:s,imageClassName:l,lightImageClassName:d,darkImageClassName:c,theme:u="auto",alt:x="ClawPad",priority:p=!1}){let m="icon"===e,g=Math.round(t*(m?i:o));return(0,a.jsx)("span",{className:(0,n.cn)("inline-flex items-center",s),children:(0,a.jsx)(r.default,{src:m?"/brand/icon.png":"/brand/logo.png",width:g,height:t,alt:x,priority:p,className:(0,n.cn)("block",l,"dark"===u?c:"light"===u?d:void 0)})})}}},e=>{e.O(0,[330,7300,5403,8935,4747,8441,3794,7358],()=>e(e.s=39667)),_N_E=e.O()}]);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1807],{3163:(e,t,n)=>{"use strict";n.d(t,{e:()=>a});var s=n(1934);let r=0,a=(0,s.v)(e=>({items:[],addItem:t=>e(e=>({items:[{...t,id:`activity-${Date.now()}-${++r}`},...e.items].slice(0,20)})),clear:()=>e({items:[]})}))},7814:(e,t,n)=>{"use strict";function s(e){let t=e.replace(/\.md$/,"").split("/").filter(Boolean).map(e=>encodeURIComponent(e));return 0===t.length?"/workspace":`/workspace/${t.join("/")}`}n.d(t,{C:()=>s})},24733:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>nA});var s=n(95155),r=n(12115),a=n(12710),l=n(61878),i=n(51914),o=n(6071),c=n(52799),d=n(89239),u=n(70872),m=n(33210),h=n(19324);function x({...e}){return(0,s.jsx)(h.Root,{"data-slot":"sheet",...e})}function p({...e}){return(0,s.jsx)(h.Portal,{"data-slot":"sheet-portal",...e})}function g({className:e,...t}){return(0,s.jsx)(h.Overlay,{"data-slot":"sheet-overlay",className:(0,c.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function f({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return(0,s.jsxs)(p,{children:[(0,s.jsx)(g,{}),(0,s.jsxs)(h.Content,{"data-slot":"sheet-content",className:(0,c.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===n&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===n&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===n&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===n&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...a,children:[t,r&&(0,s.jsxs)(h.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,s.jsx)(m.A,{className:"size-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function b({className:e,...t}){return(0,s.jsx)(h.Title,{"data-slot":"sheet-title",className:(0,c.cn)("text-foreground font-semibold",e),...t})}var v=n(98500),w=n.n(v),j=n(73321),y=n(63393),N=n(89363),k=n(21362),C=n(48368),S=n(51900),A=n(36999),E=n(35585);function $({className:e,children:t,...n}){return(0,s.jsxs)(E.Root,{"data-slot":"scroll-area",className:(0,c.cn)("relative",e),...n,children:[(0,s.jsx)(E.Viewport,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&>div]:!block [&>div]:!min-w-0",children:t}),(0,s.jsx)(z,{}),(0,s.jsx)(E.Corner,{})]})}function z({className:e,orientation:t="vertical",...n}){return(0,s.jsx)(E.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,c.cn)("flex touch-none p-px transition-colors select-none","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:(0,s.jsx)(E.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var R=n(97916),T=n(45160),_=n(86846),D=n(93571),L=n(70460),M=n(18496),K=n(31328),P=n(53536),I=n(60464);function F(e,t){let n={type:"folder",name:"",path:"",children:[]},s=new Map;for(let r of(s.set("",n),e)){let e=function(e,t){let n=e.replace(/\\/g,"/").replace(/\.md$/,"");if(t===I.Sz)return n;let s=`${t}/`;return n.startsWith(s)?n.slice(s.length):n}(r.path,t),a=e.split("/").filter(Boolean);if(0===a.length)continue;let l=a.pop(),i=n,o="";for(let e of a){let t=o?`${o}/${e}`:e,n=s.get(t);n||(n={type:"folder",name:e,path:t,children:[]},s.set(t,n),i.children.push(n)),i=n,o=t}i.children.push({type:"page",name:l,path:e,page:r})}return n.children}var W=n(7814);function O({onNavigate:e}){return(0,s.jsxs)(w(),{href:"/workspace",onClick:()=>e?.(),className:"flex items-center gap-2 text-[13px] font-semibold leading-none transition-colors hover:text-foreground/80",children:[(0,s.jsx)(D.R,{variant:"wordmark",size:26,theme:"light",alt:"ClawPad",className:"-translate-y-[2px]"}),(0,s.jsx)(G,{})]})}function U({onNavigate:e,isSheet:t,showHeader:n=!0}){let a=(0,j.usePathname)(),o=(0,j.useRouter)(),{spaces:c,expandedSpaces:d,expandedFolders:u,toggleSpace:m,toggleFolder:h,pagesBySpace:x,spacesStatus:p,pagesStatusBySpace:g,pagesErrorBySpace:f,recentPages:b,recentStatus:v,loadSpaces:w,loadRecentPages:k,loadPages:C,setActivePage:S}=(0,M.M)();(0,r.useEffect)(()=>{w(),k()},[w,k]),(0,r.useEffect)(()=>{for(let e of c){if(!d.has(e.path)||e.pageCount<=0)continue;let t=x.get(e.path);t&&!(t.length>0)&&"loading"!==(g.get(e.path)??"idle")&&C(e.path,{force:!0,silent:!0})}},[d,C,x,g,c]),(0,r.useEffect)(()=>{a.startsWith("/workspace/")?S(a.replace("/workspace/","")):S(null)},[a,S]);let A=(0,r.useCallback)(t=>{o.push((0,W.C)(t)),e?.()},[o,e]),E=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}})),e?.()},[e]),z=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"space"}})),e?.()},[e]),T=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette")),e?.()},[e]),D=(0,r.useCallback)(()=>{o.push("/settings"),e?.()},[e,o]);return(0,s.jsxs)("div",{className:"flex h-full w-full flex-col overflow-hidden",children:[n&&(0,s.jsx)("div",{className:"flex h-12 shrink-0 items-center justify-between px-3",children:(0,s.jsx)(O,{onNavigate:e})}),(0,s.jsxs)("div",{className:"shrink-0 space-y-0.5 px-2",children:[(0,s.jsx)(Z,{icon:(0,s.jsx)(l.A,{className:"h-4 w-4"}),label:"Search",shortcut:"⌘K",onClick:T,touchFriendly:t}),(0,s.jsx)(Z,{icon:(0,s.jsx)(i.A,{className:"h-4 w-4"}),label:"New Document",shortcut:"⌘N",onClick:E,touchFriendly:t}),(0,s.jsx)(Z,{icon:(0,s.jsx)(y.A,{className:"h-4 w-4"}),label:"New Space",onClick:z,touchFriendly:t})]}),(0,s.jsx)(R.w,{className:"my-2 shrink-0"}),(0,s.jsx)($,{className:"min-h-0 flex-1 w-full min-w-0 px-2",children:(0,s.jsxs)("div",{className:"w-full py-1",children:[(0,s.jsx)(J,{children:"Spaces"}),"loading"===p&&0===c.length?(0,s.jsxs)("div",{className:"space-y-1 px-2",children:[(0,s.jsx)(_.E,{className:"h-7 w-full"}),(0,s.jsx)(_.E,{className:"h-7 w-full"}),(0,s.jsx)(_.E,{className:"h-7 w-full"})]}):0===c.length?(0,s.jsx)("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No spaces yet"}):(0,s.jsx)("div",{className:"space-y-0.5",children:c.map(e=>(0,s.jsx)(q,{space:e,isExpanded:d.has(e.path),expandedFolders:u,pages:x.get(e.path)??[],pageLoadError:f.get(e.path)??null,isLoadingPages:(g.get(e.path)??"idle")==="loading"&&0===(x.get(e.path)??[]).length,pathname:a,touchFriendly:t,onToggle:()=>m(e.path),onToggleFolder:h,onRetryPages:()=>C(e.path,{force:!0}),onNavigate:A},e.path))}),b.length>0&&(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)(J,{children:"Recent"}),(0,s.jsx)("div",{className:"space-y-0.5",children:b.slice(0,5).map(e=>(0,s.jsx)(H,{page:e,isActive:a===(0,W.C)(e.path),touchFriendly:t,onNavigate:()=>A(e.path)},e.path))})]}),"loading"===v&&0===b.length&&(0,s.jsxs)("div",{className:"mt-4 space-y-1 px-2",children:[(0,s.jsx)(J,{children:"Recent"}),(0,s.jsx)(_.E,{className:"h-6 w-full"}),(0,s.jsx)(_.E,{className:"h-6 w-5/6"})]})]})}),(0,s.jsx)(R.w,{className:"shrink-0"}),(0,s.jsxs)("div",{className:"shrink-0 space-y-0.5 px-2 py-2",children:[(0,s.jsx)(X,{}),(0,s.jsx)(V,{touchFriendly:t}),(0,s.jsx)(Z,{icon:(0,s.jsx)(N.A,{className:"h-4 w-4"}),label:"Settings",onClick:D,touchFriendly:t})]})]})}let q=(0,r.memo)(function({space:e,isExpanded:t,expandedFolders:n,pages:r,pageLoadError:a,isLoadingPages:l,pathname:i,touchFriendly:o,onToggle:d,onToggleFolder:u,onRetryPages:m,onNavigate:h}){let x=F(r,e.path),p=t=>t.map(t=>{if("page"===t.type)return(0,s.jsx)(B,{page:t.page,isActive:i===(0,W.C)(t.page.path),touchFriendly:o,onNavigate:()=>h(t.page.path)},t.page.path);let r=`${e.path}/${t.path}`,a=n.has(r);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>u(r),className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[12px] transition-colors","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",o?"py-2 min-h-[44px]":"py-1",a&&"text-foreground"),children:[(0,s.jsx)(k.A,{className:(0,c.cn)("h-3 w-3 shrink-0 transition-transform duration-200",a&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 text-xs",children:"\uD83D\uDCC2"}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:t.name})]}),a&&(0,s.jsx)("div",{className:"ml-3 min-w-0 border-l border-border/50 pl-2 py-0.5",children:p(t.children)})]},r)});return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{type:"button",onClick:d,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] transition-colors","hover:bg-sidebar-accent",o?"py-2 min-h-[44px]":"py-1",t&&"font-medium"),children:[(0,s.jsx)(k.A,{className:(0,c.cn)("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",t&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 text-sm",children:e.icon??"\uD83D\uDCC1"}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:e.name}),(0,s.jsx)(T.E,{variant:"secondary",className:"h-4 shrink-0 px-1 text-[10px] font-normal",children:e.pageCount})]}),t&&(0,s.jsx)("div",{className:"ml-3 min-w-0 border-l border-border/50 pl-2 py-0.5",children:l?(0,s.jsxs)("div",{className:"space-y-1 py-1",children:[(0,s.jsx)(_.E,{className:"h-6 w-full"}),(0,s.jsx)(_.E,{className:"h-6 w-3/4"})]}):a&&0===x.length?(0,s.jsxs)("div",{className:"px-2 py-1.5",children:[(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Couldn't load pages."}),(0,s.jsx)("button",{type:"button",onClick:m,className:"mt-1 cursor-pointer text-[11px] text-primary hover:underline",children:"Retry"})]}):0===x.length?(0,s.jsx)("p",{className:"py-1.5 px-2 text-[11px] text-muted-foreground",children:"No pages yet. Create your first page."}):p(x)})]})}),B=(0,r.memo)(function({page:e,isActive:t,touchFriendly:n,onNavigate:r}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] transition-colors pointer-events-auto","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",n?"py-2 min-h-[44px]":"py-1",t&&"bg-accent-light text-accent-blue font-medium"),children:[e.icon?(0,s.jsx)("span",{className:"shrink-0 text-xs",children:e.icon}):(0,s.jsx)(C.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:e.title})]})}),H=(0,r.memo)(function({page:e,isActive:t,touchFriendly:n,onNavigate:r}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-[13px] transition-colors overflow-hidden pointer-events-auto","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",n?"py-2 min-h-[44px]":"py-1",t&&"bg-accent-light text-accent-blue font-medium"),children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[e.icon?(0,s.jsx)("span",{className:"shrink-0 text-xs",children:e.icon}):(0,s.jsx)(C.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{className:"truncate text-left",children:e.title})]}),(0,s.jsx)("span",{className:"shrink-0 whitespace-nowrap tabular-nums text-[11px] font-medium text-muted-foreground/85",children:(0,P.f)(e.modified)})]})});function Z({icon:e,label:t,shortcut:n,onClick:r,touchFriendly:a}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-[13px] transition-colors duration-200 pointer-events-auto","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",a?"py-2.5 min-h-[44px]":"py-1.5"),children:[(0,s.jsx)("span",{className:"shrink-0",children:e}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:t}),n&&(0,s.jsx)("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted/70 px-1.5 py-0.5 text-[11px] font-mono font-medium leading-none tracking-tight text-muted-foreground/85",children:n})]})}function J({children:e}){return(0,s.jsx)("h3",{className:"mb-1 px-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:e})}function V({touchFriendly:e}){let{resolvedTheme:t,setTheme:n}=(0,L.D)(),r="dark"===t;return(0,s.jsx)(Z,{icon:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(S.A,{className:"hidden h-4 w-4 dark:inline"}),(0,s.jsx)(A.A,{className:"inline h-4 w-4 dark:hidden"})]}),label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"hidden dark:inline",children:"Light Mode"}),(0,s.jsx)("span",{className:"inline dark:hidden",children:"Dark Mode"})]}),onClick:()=>n(r?"light":"dark"),touchFriendly:e})}function G(){let e=(0,K.z)(e=>e.wsStatus),t=(0,K.z)(e=>e.agentStatus),n=(0,K.z)(e=>e.agentName),r=(0,K.z)(e=>e.wsError),a="connected"===e?"thinking"===t||"active"===t?"bg-[color:var(--cp-brand-2)]":"bg-green-400":"connecting"===e||"reconnecting"===e?"bg-yellow-400":"bg-zinc-400",l="connected"===e?"thinking"===t?`${n??"Agent"}: thinking…`:"active"===t?`${n??"Agent"}: working…`:`${n??"Agent"}: online`:"connecting"===e?`Connecting to gateway…${r?` — ${r}`:""}`:"reconnecting"===e?`Reconnecting to gateway…${r?` — ${r}`:""}`:`Disconnected${r?` — ${r}`:""}`;return(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsxs)("span",{className:"relative flex h-2.5 w-2.5",children:[("connecting"===e||"reconnecting"===e||"thinking"===t||"active"===t)&&(0,s.jsx)("span",{className:(0,c.cn)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75",a)}),(0,s.jsx)("span",{className:(0,c.cn)("relative inline-flex h-2.5 w-2.5 rounded-full ring-1 ring-[color:var(--cp-brand-border)]",a)})]})}),(0,s.jsx)(u.ZI,{children:l})]})}function X(){let e=(0,K.z)(e=>e.wsStatus),t=(0,K.z)(e=>e.agentStatus),n=(0,K.z)(e=>e.agentName),r=(0,K.z)(e=>e.wsError),a=(0,K.z)(e=>e.detect),l=(0,K.z)(e=>e.connect),i="connected"===e?"bg-green-400":"connecting"===e||"reconnecting"===e?"bg-yellow-400":"bg-red-400",o="connected"===e?"thinking"===t?`${n??"Agent"} thinking…`:"active"===t?`${n??"Agent"} working…`:`${n??"Agent"} online`:"connecting"===e?`Connecting…${r?` — ${r}`:""}`:"reconnecting"===e?`Reconnecting…${r?` — ${r}`:""}`:`Disconnected${r?` — ${r}`:""}`;return(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px]",children:[(0,s.jsxs)("span",{className:"relative flex h-2 w-2",children:[("connecting"===e||"reconnecting"===e)&&(0,s.jsx)("span",{className:(0,c.cn)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75",i)}),(0,s.jsx)("span",{className:(0,c.cn)("relative inline-flex h-2 w-2 rounded-full",i)})]}),(0,s.jsx)("span",{className:"flex-1 text-[11px] text-muted-foreground",children:o}),"disconnected"===e&&(0,s.jsx)("button",{onClick:()=>{a().then(()=>l())},className:"text-[10px] text-blue-500 hover:text-blue-400 transition-colors",children:"Retry"})]})}function Q(){let e=window.innerWidth;return e<640?"mobile-sm":e<768?"mobile":e<1024?"tablet":"desktop"}function Y(){let[e,t]=(0,r.useState)(()=>Q());return(0,r.useEffect)(()=>{let e=window.matchMedia(`(max-width: ${639}px)`),n=window.matchMedia(`(min-width: 640px) and (max-width: ${767}px)`),s=window.matchMedia(`(min-width: 768px) and (max-width: ${1023}px)`);function r(){t(Q())}return e.addEventListener("change",r),n.addEventListener("change",r),s.addEventListener("change",r),()=>{e.removeEventListener("change",r),n.removeEventListener("change",r),s.removeEventListener("change",r)}},[]),{breakpoint:e,isMobileSm:"mobile-sm"===e,isMobile:"mobile-sm"===e||"mobile"===e,isTablet:"tablet"===e,isDesktop:"desktop"===e}}function ee({className:e,...t}){return(0,s.jsx)("span",{className:(0,c.cn)("absolute h-px w-px overflow-hidden whitespace-nowrap border-0 p-0","[clip:rect(0,0,0,0)]",e),...t})}function et(){let{sidebarOpen:e,sidebarWidth:t,toggleSidebar:n,setSidebarOpen:m,setSidebarWidth:h}=(0,M.M)(),{isMobile:p,isTablet:g}=Y(),[v,w]=(0,r.useState)(t),[j,y]=(0,r.useState)(!1),N=(0,r.useRef)(null),k=(0,r.useRef)(0),C=(0,r.useRef)(240),S=(0,r.useRef)(240),A=(0,r.useCallback)(e=>Math.max(208,Math.min(e,Math.round(.35*window.innerWidth))),[]);(0,r.useEffect)(()=>{w(t)},[t]),(0,r.useEffect)(()=>{if(p||g)return;let e=()=>{let e=A(S.current);S.current=e,w(e),h(e)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[A,p,g,h]),(0,r.useEffect)(()=>{S.current=v,N.current&&(N.current.style.width=`${v}px`)},[v]),(0,r.useEffect)(()=>{if(!j)return;let e=e=>{let t=e.clientX-k.current,n=A(C.current+t);S.current=n,N.current&&(N.current.style.width=`${n}px`)},t=()=>{y(!1);let e=S.current;w(e),h(e)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),document.body.style.cursor="",document.body.style.userSelect=""}},[A,j,h]);let E=(0,r.useCallback)(t=>{p||g||!e||(t.preventDefault(),k.current=t.clientX,C.current=S.current,y(!0))},[p,g,e]),$=(0,r.useCallback)(()=>{m(!1)},[m]),z=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette"))},[]),R=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},[]);return p?null:g?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex h-full w-12 flex-col items-center border-r bg-sidebar py-3 gap-2 shrink-0",children:[(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:n,children:(0,s.jsx)(a.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Open sidebar (⌘\\)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:z,children:(0,s.jsx)(l.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Search (⌘K)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,children:(0,s.jsx)(i.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"New Document (⌘N)"})]})]}),(0,s.jsx)(x,{open:e,onOpenChange:m,children:(0,s.jsxs)(f,{side:"left",className:"w-72 p-0",showCloseButton:!1,children:[(0,s.jsx)(ee,{children:(0,s.jsx)(b,{children:"Navigation"})}),(0,s.jsx)(U,{onNavigate:$,isSheet:!0})]})})]}):e?(0,s.jsxs)("div",{ref:N,className:"relative flex h-full shrink-0 flex-col border-r bg-sidebar",style:{width:v,minWidth:208,maxWidth:"35vw"},children:[(0,s.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between px-3",children:[(0,s.jsx)(O,{}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:n,children:(0,s.jsx)(o.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Close sidebar (⌘\\)"})]})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:(0,s.jsx)(U,{showHeader:!1})}),(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",onPointerDown:E,className:(0,c.cn)("absolute right-0 top-0 z-20 h-full w-2 cursor-col-resize","group"),children:(0,s.jsx)("div",{className:(0,c.cn)("absolute inset-y-0 right-0 w-px bg-border/70","transition-colors group-hover:bg-[color:var(--cp-brand-2)]",j&&"bg-[color:var(--cp-brand-2)]")})})]}):(0,s.jsxs)("div",{className:"flex h-full w-12 flex-col items-center border-r bg-sidebar py-3 gap-2 shrink-0",children:[(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:n,children:(0,s.jsx)(a.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Open sidebar (⌘\\)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:z,children:(0,s.jsx)(l.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Search (⌘K)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,children:(0,s.jsx)(i.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"New Document (⌘N)"})]})]})}var en=n(21628),es=n(93631),er=n(84980),ea=n(2647),el=n(86901),ei=n(49387),eo=n(34530),ec=n(42129),ed=n(96035),eu=n(92972),em=n(5810),eh=n(53961),ex=n(2467),ep=n(34738);function eg({...e}){return(0,s.jsx)(h.Root,{"data-slot":"dialog",...e})}function ef({...e}){return(0,s.jsx)(h.Portal,{"data-slot":"dialog-portal",...e})}function eb({className:e,...t}){return(0,s.jsx)(h.Overlay,{"data-slot":"dialog-overlay",className:(0,c.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function ev({className:e,children:t,showCloseButton:n=!0,...r}){return(0,s.jsxs)(ef,{"data-slot":"dialog-portal",children:[(0,s.jsx)(eb,{}),(0,s.jsxs)(h.Content,{"data-slot":"dialog-content",className:(0,c.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",e),...r,children:[t,n&&(0,s.jsxs)(h.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,s.jsx)(m.A,{}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function ew({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"dialog-header",className:(0,c.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function ej({className:e,showCloseButton:t=!1,children:n,...r}){return(0,s.jsxs)("div",{"data-slot":"dialog-footer",className:(0,c.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r,children:[n,t&&(0,s.jsx)(h.Close,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"outline",children:"Close"})})]})}function ey({className:e,...t}){return(0,s.jsx)(h.Title,{"data-slot":"dialog-title",className:(0,c.cn)("text-lg leading-none font-semibold",e),...t})}function eN({className:e,...t}){return(0,s.jsx)(h.Description,{"data-slot":"dialog-description",className:(0,c.cn)("text-muted-foreground text-sm",e),...t})}function ek({className:e,...t}){return(0,s.jsx)(ep.uB,{"data-slot":"command",className:(0,c.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function eC({title:e="Command Palette",description:t="Search for a command to run...",children:n,className:r,showCloseButton:a=!0,...l}){return(0,s.jsx)(eg,{...l,children:(0,s.jsxs)(ev,{className:(0,c.cn)("overflow-hidden p-0",r),showCloseButton:a,children:[(0,s.jsxs)(ew,{className:"sr-only",children:[(0,s.jsx)(ey,{children:e}),(0,s.jsx)(eN,{children:t})]}),(0,s.jsx)(ek,{className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:n})]})})}function eS({className:e,...t}){return(0,s.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,s.jsx)(l.A,{className:"size-4 shrink-0 opacity-50"}),(0,s.jsx)(ep.uB.Input,{"data-slot":"command-input",className:(0,c.cn)("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})}function eA({className:e,...t}){return(0,s.jsx)(ep.uB.List,{"data-slot":"command-list",className:(0,c.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function eE({...e}){return(0,s.jsx)(ep.uB.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function e$({className:e,...t}){return(0,s.jsx)(ep.uB.Group,{"data-slot":"command-group",className:(0,c.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}function ez({className:e,...t}){return(0,s.jsx)(ep.uB.Separator,{"data-slot":"command-separator",className:(0,c.cn)("bg-border -mx-1 h-px",e),...t})}function eR({className:e,...t}){return(0,s.jsx)(ep.uB.Item,{"data-slot":"command-item",className:(0,c.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function eT({className:e,...t}){return(0,s.jsx)("span",{"data-slot":"command-shortcut",className:(0,c.cn)("text-muted-foreground ml-auto text-xs tracking-widest",e),...t})}function e_(){let[e,t]=(0,r.useState)(!1),[n,o]=(0,r.useState)(""),[c,d]=(0,r.useState)([]),[u,m]=(0,r.useState)([]),[h,x]=(0,r.useState)(!1),p=(0,j.useRouter)(),{resolvedTheme:g,setTheme:f}=(0,L.D)(),{recentPages:b,spaces:v,toggleChatPanel:w,toggleSidebar:k,createPage:E}=(0,M.M)(),$=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=e=>{"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),t(!0))},n=()=>t(!0);return document.addEventListener("keydown",e),window.addEventListener("clawpad:open-command-palette",n),()=>{document.removeEventListener("keydown",e),window.removeEventListener("clawpad:open-command-palette",n)}},[]),(0,r.useEffect)(()=>{e&&fetch("/api/files/recent?limit=8").then(e=>e.ok?e.json():[]).then(e=>m(e)).catch(()=>{})},[e]),(0,r.useEffect)(()=>{if(!n.trim()){d([]),x(!1);return}x(!0);let e=setTimeout(async()=>{$.current?.abort();let e=new AbortController;$.current=e;try{let t=await fetch(`/api/files/search?q=${encodeURIComponent(n)}&limit=10`,{signal:e.signal});if(t.ok){let e=await t.json();d(Array.isArray(e)?e:e.results??[])}}catch(e){e.name}finally{e.signal.aborted||x(!1)}},200);return()=>{clearTimeout(e)}},[n]);let z=(0,r.useCallback)(e=>{p.push((0,W.C)(e)),t(!1),o("")},[p]),R=(0,r.useCallback)(async e=>{try{let t=await E(I.Sz,e);z(t)}catch{}},[E,z]),_=(0,r.useCallback)(()=>{t(!1),window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"space"}}))},[]),D=(0,r.useCallback)(()=>{t(!1),window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},[]),K=(0,r.useCallback)(e=>{t(e),e||(o(""),d([]))},[]),P=u.length>0?u:b.slice(0,8),F=n.trim().length>0,O=c.length>0;return(0,s.jsxs)(eC,{open:e,onOpenChange:K,children:[(0,s.jsx)(eS,{placeholder:"Search pages or type a command…",value:n,onValueChange:o}),(0,s.jsxs)(eA,{children:[(0,s.jsx)(eE,{children:h?(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2",children:[(0,s.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"}),(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"Searching…"})]}):F?"No results found.":null}),O&&(0,s.jsxs)(e$,{heading:"Pages",children:[c.map(e=>(0,s.jsxs)(eR,{value:`search-${e.path}`,onSelect:()=>z(e.path),className:"flex flex-col items-start gap-1 py-3",children:[(0,s.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,s.jsx)(C.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("span",{className:"truncate font-medium",children:[e.icon&&`${e.icon} `,e.title]}),(0,s.jsx)(T.E,{variant:"secondary",className:"ml-auto shrink-0 text-[10px] px-1.5 py-0",children:e.space}),e.modified&&(0,s.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground tabular-nums",children:function(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),s=Math.floor(n/6e4),r=Math.floor(n/36e5),a=Math.floor(n/864e5);if(s<1)return"just now";if(s<60)return`${s}m ago`;if(r<24)return`${r}h ago`;if(a<7)return`${a}d ago`;return t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return""}}(e.modified)})]}),e.snippet&&(0,s.jsx)("p",{className:"ml-6 text-xs text-muted-foreground line-clamp-1 max-w-full",children:e.snippet.replace(/^---[\s\S]*?---\s*/m,"").replace(/^#+\s/gm,"").replace(/\n+/g," ").trim()})]},e.path)),(0,s.jsxs)(eR,{value:`view-all-search-${n}`,onSelect:()=>{p.push(`/workspace/search?q=${encodeURIComponent(n.trim())}`),t(!1),o("")},className:"justify-center text-muted-foreground",children:[(0,s.jsx)(l.A,{className:"mr-2 h-3.5 w-3.5"}),(0,s.jsx)("span",{className:"text-xs",children:"View all results"}),(0,s.jsx)(en.A,{className:"ml-1 h-3 w-3"})]})]}),F&&!O&&!h&&(0,s.jsx)(e$,{heading:"Create",children:(0,s.jsxs)(eR,{value:`create-${n}`,onSelect:()=>R(n.trim()),children:[(0,s.jsx)(es.A,{className:"mr-2 h-4 w-4 text-primary"}),(0,s.jsxs)("span",{children:["Create document: ",(0,s.jsx)("strong",{children:n.trim()})]})]})}),!F&&P.length>0&&(0,s.jsx)(e$,{heading:"Recent Pages",children:P.map(e=>(0,s.jsxs)(eR,{value:`recent-${e.path}`,onSelect:()=>z(e.path),children:[(0,s.jsx)(er.A,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("div",{className:"flex flex-1 items-center gap-2 overflow-hidden",children:[e.icon&&(0,s.jsx)("span",{className:"shrink-0 text-sm",children:e.icon}),(0,s.jsx)("span",{className:"truncate",children:e.title}),(0,s.jsx)(T.E,{variant:"secondary",className:"ml-auto shrink-0 text-[10px] px-1.5 py-0",children:e.space===I.Sz?I.ke:e.space})]})]},e.path))}),(0,s.jsx)(ez,{}),(0,s.jsxs)(e$,{heading:"Create",children:[(0,s.jsxs)(eR,{value:"new-document",onSelect:D,children:[(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"New Document"}),(0,s.jsx)(eT,{children:"⌘N"})]}),(0,s.jsxs)(eR,{value:"new-space",onSelect:_,children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"New Space"})]}),(0,s.jsxs)(eR,{value:"new-daily-note",onSelect:()=>{t(!1),R(new Date().toISOString().slice(0,10))},children:[(0,s.jsx)(ea.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"New Daily Note"})]})]}),(0,s.jsxs)(e$,{heading:"AI",children:[(0,s.jsxs)(eR,{value:"ask-agent",onSelect:()=>{let e=M.M.getState();e.chatPanelOpen||e.toggleChatPanel(),t(!1)},children:[(0,s.jsx)(el.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Ask Agent"}),(0,s.jsx)(eT,{children:"⌘⇧L"})]}),(0,s.jsxs)(eR,{value:"summarize-page",onSelect:()=>{let e=M.M.getState();e.chatPanelOpen||e.toggleChatPanel(),t(!1),window.dispatchEvent(new CustomEvent("clawpad:ai-action",{detail:{action:"summarize"}}))},children:[(0,s.jsx)(C.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Summarize Page"})]}),(0,s.jsxs)(eR,{value:"improve-writing",onSelect:()=>{let e=M.M.getState();e.chatPanelOpen||e.toggleChatPanel(),t(!1),window.dispatchEvent(new CustomEvent("clawpad:ai-action",{detail:{action:"improve"}}))},children:[(0,s.jsx)(ei.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Improve Writing"})]})]}),(0,s.jsxs)(e$,{heading:"Navigation",children:[(0,s.jsxs)(eR,{value:"search-workspace",onSelect:()=>{let e=n.trim();p.push(e?`/workspace/search?q=${encodeURIComponent(e)}`:"/workspace/search"),t(!1),o("")},children:[(0,s.jsx)(l.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Search Workspace"})]}),(0,s.jsxs)(eR,{value:"go-to-settings",onSelect:()=>{p.push("/settings"),t(!1)},children:[(0,s.jsx)(N.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Go to Settings"})]}),(0,s.jsxs)(eR,{value:"go-to-setup",onSelect:()=>{p.push("/setup"),t(!1)},children:[(0,s.jsx)(eo.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Go to Setup"})]}),v.map(e=>(0,s.jsxs)(eR,{value:`space-${e.path}`,onSelect:()=>{M.M.getState().toggleSpace(e.path),t(!1)},children:[(0,s.jsx)(ec.A,{className:"mr-2 h-4 w-4 text-muted-foreground"}),(0,s.jsxs)("span",{children:[e.icon&&`${e.icon} `,e.name]})]},e.path))]}),(0,s.jsxs)(e$,{heading:"Actions",children:[(0,s.jsxs)(eR,{value:"toggle-chat",onSelect:()=>{w(),t(!1)},children:[(0,s.jsx)(ed.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Toggle Chat"}),(0,s.jsx)(eT,{children:"⌘⇧L"})]}),(0,s.jsxs)(eR,{value:"toggle-sidebar",onSelect:()=>{k(),t(!1)},children:[(0,s.jsx)(a.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Toggle Sidebar"}),(0,s.jsx)(eT,{children:"⌘\\"})]}),(0,s.jsxs)(eR,{value:"toggle-dark-mode",onSelect:()=>{f("dark"===g?"light":"dark"),t(!1)},children:["dark"===g?(0,s.jsx)(S.A,{className:"mr-2 h-4 w-4"}):(0,s.jsx)(A.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Toggle Dark Mode"}),(0,s.jsx)(eT,{children:"⌘⇧D"})]}),(0,s.jsxs)(eR,{value:"theme-light",onSelect:()=>{f("light"),t(!1)},children:[(0,s.jsx)(S.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Theme: Light"})]}),(0,s.jsxs)(eR,{value:"theme-dark",onSelect:()=>{f("dark"),t(!1)},children:[(0,s.jsx)(A.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Theme: Dark"})]}),(0,s.jsxs)(eR,{value:"theme-system",onSelect:()=>{f("system"),t(!1)},children:[(0,s.jsx)(eu.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Theme: System"})]}),(0,s.jsxs)(eR,{value:"focus-editor",onSelect:()=>{let e=document.querySelector(".clawpad-editor [contenteditable]")??document.querySelector(".clawpad-editor");e?.focus(),t(!1)},children:[(0,s.jsx)(em.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Focus Editor"}),(0,s.jsx)(eT,{children:"⌘⇧E"})]}),(0,s.jsxs)(eR,{value:"force-save",onSelect:()=>{window.dispatchEvent(new CustomEvent("clawpad:force-save")),t(!1)},children:[(0,s.jsx)(eh.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Save"}),(0,s.jsx)(eT,{children:"⌘S"})]}),(0,s.jsxs)(eR,{value:"keyboard-shortcuts",onSelect:()=>{window.dispatchEvent(new CustomEvent("clawpad:shortcuts-dialog")),t(!1)},children:[(0,s.jsx)(ex.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Keyboard Shortcuts"}),(0,s.jsx)(eT,{children:"⌘/"})]})]})]})]})}var eD=n(60529),eL=n(66609);let eM="clawpad-create-location-suggestions";function eK(){let[e,t]=(0,r.useState)(!1),[n,a]=(0,r.useState)("document"),[l,i]=(0,r.useState)(""),[o,c]=(0,r.useState)(""),[u,m]=(0,r.useState)(!1),h=(0,j.useRouter)(),{spaces:x,createPage:p,createSpace:g}=(0,M.M)(),f=(0,r.useMemo)(()=>new Set(x.map(e=>e.path)),[x]);(0,r.useEffect)(()=>{let e=e=>{let n=e?.detail;n?.mode==="space"||n?.mode==="folder"?a("space"):a("document"),"string"==typeof n?.title?i(n.title):i(""),"string"==typeof n?.location?c(n.location):"string"==typeof n?.space&&n.space.trim()?c(n.folderPath?`${n.space}/${n.folderPath}`.replace(/^\/+|\/+$/g,""):n.space):c(""),t(!0)};window.addEventListener("clawpad:open-new-page",e),window.addEventListener("clawpad:new-page",e);let n=e=>{"n"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a("document"),i(""),c(""),t(!0))};return document.addEventListener("keydown",n),()=>{window.removeEventListener("clawpad:open-new-page",e),window.removeEventListener("clawpad:new-page",e),document.removeEventListener("keydown",n)}},[]),(0,r.useEffect)(()=>{if(!e||"document"!==n||o.trim())return;let t=x.find(e=>e.path!==I.Sz)?.path??x[0]?.path??"";t&&c(t)},[o,n,e,x]);let b=()=>{a("document"),i(""),c(""),m(!1)},v=(0,r.useCallback)(async()=>{let e=l.trim();if(e){m(!0);try{if("space"===n){await g(e),t(!1),b(),eL.oR.success("Space created"),h.push("/workspace");return}let s=function(e,t){let n=e.trim();if(!n)return null;let s=n.replace(/^\/+|\/+$/g,"");if(!s)return null;if(s===I.Sz||"root"===s.toLowerCase()||s.toLowerCase()===I.ke.toLowerCase())return{space:I.Sz};let r=s.split("/").filter(Boolean);if(0===r.length)return null;let[a,...l]=r;return t.has(a)?{space:a,folderPath:l.length>0?l.join("/"):void 0}:null}(o,f);if(!s)throw Error("Choose a valid location (space or space/folder path).");let r=await p(s.space,e,{folderPath:s.folderPath});t(!1),b(),h.push((0,W.C)(r)),eL.oR.success("Document created")}catch(t){let e=t instanceof Error?t.message:"space"===n?"Failed to create space.":"Failed to create document.";eL.oR.error(e)}finally{m(!1)}}},[p,g,f,o,n,h,l]),w=(0,r.useCallback)(e=>{"Enter"!==e.key||u||(e.preventDefault(),v())},[u,v]);return(0,s.jsx)(eg,{open:e,onOpenChange:e=>{t(e),e||b()},children:(0,s.jsxs)(ev,{className:"sm:max-w-[440px]",children:[(0,s.jsxs)(ew,{children:[(0,s.jsx)(ey,{children:"space"===n?"New Space":"New Document"}),(0,s.jsx)(eN,{children:"space"===n?"Create a top-level space in your workspace.":"Create a document in a space or nested folder path."})]}),(0,s.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 rounded-lg border bg-muted/30 p-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>a("document"),className:`rounded-md px-2 py-1.5 text-xs ${"document"===n?"bg-background font-medium shadow-sm":"text-muted-foreground"}`,children:"Document"}),(0,s.jsx)("button",{type:"button",onClick:()=>a("space"),className:`rounded-md px-2 py-1.5 text-xs ${"space"===n?"bg-background font-medium shadow-sm":"text-muted-foreground"}`,children:"Space"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{htmlFor:"create-title",className:"text-sm font-medium leading-none",children:"space"===n?"Space Name":"Document Name"}),(0,s.jsx)(eD.p,{id:"create-title",placeholder:"space"===n?"e.g. client-work":"Document title…",value:l,onChange:e=>i(e.target.value),onKeyDown:w,autoFocus:!0})]}),"document"===n&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{htmlFor:"create-location",className:"text-sm font-medium leading-none",children:"Location"}),(0,s.jsx)(eD.p,{id:"create-location",list:eM,placeholder:"space or space/folder/path",value:o,onChange:e=>c(e.target.value),onKeyDown:w}),(0,s.jsx)("datalist",{id:eM,children:x.map(e=>(0,s.jsx)("option",{value:e.path,children:e.name},e.path))}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Example: ",(0,s.jsx)("code",{children:"projects/q1/roadmap"})]})]})]}),(0,s.jsxs)(ej,{children:[(0,s.jsx)(d.$,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),(0,s.jsx)(d.$,{onClick:()=>void v(),disabled:!l.trim()||u,children:u?"Creating…":"space"===n?"Create Space":"Create Document"})]})]})})}var eP=n(84577),eI=n(86726),eF=n(56558),eW=n(15411),eO=n(7915),eU=n(92018),eq=n(6296),eB=n(13545),eH=n(56842),eZ=n(99815),eJ=n(10762),eV=n(72055),eG=n(95672),eX=n(66088),eQ=n(94514),eY=n(38399),e0=n(41730),e1=n(92451),e5=n(17243),e2=n(74643),e4=n(69260),e3=n(6489),e6=n(65576),e9=n(32967),e8=n(13175),e7=n(76597),te=n(25262),tt=n(52159),tn=n(80642),ts=n(18310),tr=n(3163),ta=n(46794),tl=n(83099);let ti=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,to=/<\s*\/?\s*final\b[^<>]*>/gi,tc=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function td(e){let t=[];for(let n of e.matchAll(/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g)){let e=(n.index??0)+n[1].length;t.push({start:e,end:e+n[0].length-n[1].length})}for(let n of e.matchAll(/`+[^`]+`+/g)){let e=n.index??0,s=e+n[0].length;t.some(t=>e>=t.start&&s<=t.end)||t.push({start:e,end:s})}return t.sort((e,t)=>e.start-t.start),t}function tu(e,t){return t.some(t=>e>=t.start&&e<t.end)}var tm=n(9921);function th({status:e}){let t=(0,j.useRouter)(),n=(0,tl.W)(e=>e.activeRun),a=(0,tl.W)(e=>e.activeFiles),l=(0,tl.W)(e=>e.lastFileTouchAt),i=(0,tl.W)(e=>e.changeSets),o=(0,tl.W)(e=>e.openReview),d=(0,tl.W)(e=>e.closeReview),u=(0,K.z)(e=>e.agentStatus),m=i.find(e=>"completed"===e.status),[h,x]=(0,r.useState)(!1),p=a.size,g=!!m,f=e?"status":n&&p>0&&"number"==typeof l&&"idle"!==u?"editing":g?"summary":null,b="editing"===f?p:m?.totals.filesChanged??0,v=m?.totals.additions??0,w=m?.totals.deletions??0,y=0===b?"files":1===b?"1 file":`${b} files`,N="summary"===f&&!!m,k=N&&h;if(!f)return null;let C=e?.kind==="alert",S=e?.tone==="error",A=e?(0,c.cn)("flex w-full items-center gap-2 rounded-lg border px-3 py-1.5 text-xs transition-colors","thinking"===e.kind&&"border-[color:var(--cp-brand-border)] bg-[color:var(--cp-status-thinking-bg)] text-[color:var(--cp-status-thinking-text)]","writing"===e.kind&&"border-[color:var(--cp-brand-border)] bg-[color:var(--cp-status-thinking-bg)] text-[color:var(--cp-status-thinking-text)]","background"===e.kind&&"border-border/60 bg-[color:var(--cp-status-neutral-bg)] text-[color:var(--cp-status-neutral-text)]",C&&(S?"border-red-500/40 bg-[color:var(--cp-status-error-bg)] text-[color:var(--cp-status-error-text)]":"border-amber-500/40 bg-[color:var(--cp-status-alert-bg)] text-[color:var(--cp-status-alert-text)]")):"",E=e?(0,c.cn)("inline-flex h-2 w-2 rounded-full",("thinking"===e.kind||"background"===e.kind||"writing"===e.kind)&&"animate-pulse",("thinking"===e.kind||"writing"===e.kind)&&"bg-[color:var(--cp-status-thinking-text)]","background"===e.kind&&"bg-[color:var(--cp-status-neutral-text)]",C&&(S?"bg-[color:var(--cp-status-error-text)]":"bg-[color:var(--cp-status-alert-text)]")):"";return(0,s.jsxs)("div",{className:"mb-2",children:["status"===f&&e&&(0,s.jsxs)("div",{className:A,role:"status","aria-live":"polite",children:[(0,s.jsx)("span",{className:E}),(0,s.jsx)("span",{className:"text-[11px] font-medium",children:e.label}),e.detail&&(0,s.jsx)("span",{className:"max-w-[240px] truncate text-[10px] text-foreground/70",children:e.detail})]}),("editing"===f||"summary"===f)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{N&&x(e=>!e)},className:(0,c.cn)("flex w-full items-center gap-2 border border-border/60 bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground","rounded-lg",N&&"cursor-pointer hover:bg-muted/60"),children:[(0,s.jsx)("span",{className:"inline-flex h-2 w-2 rounded-full bg-[color:var(--cp-brand-2)] animate-pulse"}),(0,s.jsx)("span",{className:"flex-1 text-left",children:"editing"===f?(0,s.jsxs)(s.Fragment,{children:["Editing ",y,"…"]}):(0,s.jsxs)(s.Fragment,{children:[y," changed"," ",(0,s.jsxs)("span",{className:"text-emerald-600",children:["+",v]})," ",(0,s.jsxs)("span",{className:"text-rose-500",children:["-",w]})]})}),N&&(0,s.jsx)("span",{className:"text-muted-foreground/70",children:h?(0,s.jsx)(tm.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(eX.A,{className:"h-3.5 w-3.5"})})]}),k&&m&&(0,s.jsx)("div",{className:"rounded-b-lg border border-t-0 border-border/60 bg-background/95",children:(0,s.jsx)("div",{className:"divide-y divide-border/70",children:m.files.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 text-xs",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{var n;return n=e.path,void(m&&(o(m.id,n),t.push((0,W.C)(n))))},className:"rounded-md border border-border/70 px-2 py-0.5 text-[10px] font-medium text-muted-foreground hover:text-foreground",children:"Diff"}),(0,s.jsx)("button",{type:"button",onClick:()=>{var n;return n=e.path,void(d(),t.push((0,W.C)(n)))},className:"flex-1 truncate text-left text-foreground/80 hover:text-foreground",children:e.path}),(0,s.jsxs)("span",{className:"shrink-0 font-mono text-[11px]",children:[(0,s.jsxs)("span",{className:"text-emerald-600",children:["+",e.additions]})," ",(0,s.jsxs)("span",{className:"text-rose-500",children:["-",e.deletions]})]})]},e.path))})})]})]})}let tx={telegram:{icon:"\uD83D\uDCF1",label:"Telegram",color:"bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-300"},whatsapp:{icon:"\uD83D\uDCAC",label:"WhatsApp",color:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300"},discord:{icon:"\uD83C\uDFAE",label:"Discord",color:"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/40 dark:text-indigo-300"},slack:{icon:"\uD83D\uDCBC",label:"Slack",color:"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300"},webchat:{icon:"\uD83C\uDF10",label:"Web",color:"bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400"},clawpad:{icon:"\uD83C\uDF10",label:"ClawPad",color:"bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400"},system:{icon:"\uD83E\uDD16",label:"System",color:"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300"}},tp=(0,r.memo)(function({channel:e,sessionKey:t,className:n}){let r=e?e.toLowerCase():t?(t.split(":")[2]??"unknown").toLowerCase():"unknown",a=tx[r];return a&&"webchat"!==r&&"clawpad"!==r?(0,s.jsxs)("span",{className:(0,c.cn)("inline-flex items-center gap-0.5 rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none",a.color,n),children:[(0,s.jsx)("span",{className:"text-[10px]",children:a.icon}),a.label]}):null}),tg=["image/png","image/jpeg","image/gif","image/webp"],tf=[],tb=null,tv="main";function tw(e){return(e.split("/").pop()??e).replace(/\.md$/,"").replace(/[-_]+/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function tj(e){return{title:e.title?.trim()||tw(e.path),path:e.path,space:e.space,modified:e.modified,snippet:e.snippet}}async function ty(e){return new Promise((t,n)=>{let s=new FileReader;s.onload=()=>t(s.result),s.onerror=n,s.readAsDataURL(e)})}async function tN(e){let t=[];for(let n of e){if(!tg.includes(n.type))continue;if(n.size>5242880){console.warn(`[chat] Skipping ${n.name}: exceeds 5 MB`);continue}let e=await ty(n);t.push({id:crypto.randomUUID(),dataUrl:e,name:n.name})}return t}let tk=/^\[([^\]]+)\]\s*/,tC=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","Google Chat","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],tS=/^\s*\[message_id:\s*[^\]]+\]\s*$/i,tA=/^\s*\[message_id:\s*([^\]]+)\]\s*$/i;function tE(e){var t;let n=e.match(tk);return n?(t=n[1]??"",/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(t)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(t)||tC.some(e=>t.startsWith(`${e} `)))?tz(e.slice(n[0].length)):tz(e):tz(e)}function t$(e){return String(e.preview??e.reason??e.status??"Heartbeat").trim()}function tz(e){if(!e.includes("[message_id:"))return e;let t=e.split(/\r?\n/),n=t.filter(e=>!tS.test(e));return n.length===t.length?e:n.join("\n")}function tR(e){return function(e,t){var n;if(!e||!ti.test(e))return e;let s=t?.mode??"strict",r=t?.trim??"both",a=e;if(to.test(a)){to.lastIndex=0;let e=[],t=td(a);for(let n of a.matchAll(to)){let s=n.index??0;e.push({start:s,length:n[0].length,inCode:tu(s,t)})}for(let t=e.length-1;t>=0;t-=1){let n=e[t];n.inCode||(a=a.slice(0,n.start)+a.slice(n.start+n.length))}}else to.lastIndex=0;let l=td(a);tc.lastIndex=0;let i="",o=0,c=!1;for(let e of a.matchAll(tc)){let t=e.index??0,n="/"===e[1];tu(t,l)||(c?n&&(c=!1):(i+=a.slice(o,t),n||(c=!0)),o=t+e[0].length)}return c&&"preserve"!==s||(i+=a.slice(o)),n=i,"none"===r?n:"start"===r?n.trimStart():n.trim()}(e,{mode:"preserve",trim:"start"})}function tT(e){return e.replace(/^\s*\[Context\][\s\S]*?\[\/Context\]\s*/i,"")}function t_(e){return String(e??"").replace(/\s+/g," ").trim()}function tD(e){let t=e.role??"",n=e.content;if("string"==typeof n){let e="assistant"===t?tR(n):tE(n);return"user"===t||"User"===t?tT(e):e}if(Array.isArray(n)){let e=n.filter(e=>"text"===e.type&&"string"==typeof e.text).map(e=>e.text);if(e.length>0){let n=e.join("\n"),s="assistant"===t?tR(n):tE(n);return"user"===t||"User"===t?tT(s):s}}if("string"==typeof e.text){let n=e.text,s="assistant"===t?tR(n):tE(n);return"user"===t||"User"===t?tT(s):s}return null}function tL(e){let t=e.role??"",n=e.content;if("string"==typeof n)return"user"===t||"User"===t?tT(n):n;if(Array.isArray(n)){let e=n.filter(e=>"text"===e.type&&"string"==typeof e.text).map(e=>e.text);if(e.length>0){let n=e.join("\n");return"user"===t||"User"===t?tT(n):n}}if("string"==typeof e.text){let n=e.text;return"user"===t||"User"===t?tT(n):n}return null}function tM(e){var t;let n;if(null==e)return;if("number"==typeof e||"boolean"==typeof e)return String(e);if("string"==typeof e)n=e;else if("object"==typeof e)if("string"==typeof e.text)n=e.text;else if(Array.isArray(e.content)){let t=e.content.map(e=>e&&"object"==typeof e&&"text"===e.type&&"string"==typeof e.text?e.text:null).filter(e=>!!e);n=t.length>0?t.join("\n"):""}else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}else n=String(e);if(!n)return;let s=(t=tK(n)??n).length<=12e4?{text:t,truncated:!1,total:t.length}:{text:t.slice(0,12e4),truncated:!0,total:t.length};return s.truncated?`${s.text}
|
|
2
|
-
|
|
3
|
-
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function tK(e){let t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return null;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}}function tP(e){var t;let n,s,r=e.role??"unknown";(function(e){let t=(e.role??"").toLowerCase();if("toolresult"===t||"tool_result"===t||e.toolCallId||e.tool_call_id||e.toolName||e.tool_name)return!0;let n=Array.isArray(e.content)?e.content:null;return!!n?.some(e=>{let t=(e.type??"").toLowerCase();return"toolresult"===t||"tool_result"===t})})(e)&&(r="toolResult");let a=[];"string"==typeof e.content?a=[{type:"text",text:e.content}]:Array.isArray(e.content)?a=e.content.map(e=>({...e,type:e.type||"text",text:e.text})):"string"==typeof e.text&&(a=[{type:"text",text:e.text}]);let l=tL(e),i=!!l&&function(e,t){let n=e.trim();if(!n)return!1;if(/^HEARTBEAT_OK\b/i.test(n)||/^HEARTBEAT\b/i.test(n))return!0;let s=/^System:/i.test(n),r=/\[NETWORK\]/i.test(n),a=/\bRead HEARTBEAT\.md\b/i.test(n);return!!s&&(!!r||!!a)||"system"===(t??"").toLowerCase()}(l,r),o=i?"system":(n=((t=r)??"").toLowerCase(),"user"===t||"User"===t?"user":"assistant"===t?"assistant":"system"===t?"system":"toolresult"===n||"tool_result"===n||"tool"===n||"function"===n?"tool":"assistant");return"user"===o&&(s=!1,a=a.map(e=>{if(!s&&"text"===e.type&&"string"==typeof e.text){let t=tT(e.text);return(t!==e.text&&(s=!0),t.trim())?{...e,text:t}:null}return e}).filter(Boolean)),{role:o,content:a,timestamp:e.timestamp??Date.now(),id:e.id,channel:e.channel,sessionKey:e.sessionKey,raw:e,displayText:tD(e),toolCards:function(e){let t=[],n=Array.isArray(e.content)?e.content:[];for(let e of n)(["toolcall","tool_call","tooluse","tool_use"].includes((e.type??"").toLowerCase())||"string"==typeof e.name&&null!=e.arguments)&&t.push({kind:"call",name:e.name??"tool",args:function(e){if("string"!=typeof e)return e;let t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(t)}catch{return e}}(e.arguments??e.args??e.input)});for(let e of n){let n=(e.type??"").toLowerCase();if("toolresult"!==n&&"tool_result"!==n)continue;let s=e.text??e.content??void 0,r=e.name??"tool";t.push({kind:"result",name:r,text:s})}if(("toolresult"===(e.role??"").toLowerCase()||"tool_result"===(e.role??"").toLowerCase()||e.toolCallId||e.tool_call_id||e.toolName||e.tool_name)&&!t.some(e=>"result"===e.kind)){let n=e.toolName??e.tool_name??"tool",s=tD(e)??void 0;t.push({kind:"result",name:n,text:s})}return t}(e),internal:i}}function tI(){return new eI.rL({api:"/api/chat",body:()=>({sessionKey:tv,pageContext:tb?.activePage?.path??void 0,context:tb??void 0,images:tf.length>0?[...tf]:void 0})})}let tF=tI(),tW=new eP.ry({transport:tF});function tO({variant:e="default"}){let{chatPanelOpen:t,setChatPanelOpen:n,activePage:a}=(0,M.M)(),l=(0,K.z)(e=>e.connected),o=(0,K.z)(e=>e.wsStatus),u=(0,K.z)(e=>e.reason),h=(0,K.z)(e=>e.wsError),x=(0,K.z)(e=>e.error),p=(0,K.z)(e=>e.agentStatus),g=(0,tl.W)(e=>e.setSessionKey),f=(0,tl.W)(e=>e.loadChangeSets),b=t||"default"!==e,[v,w]=(0,r.useState)("main"),j=(0,r.useRef)("main"),y=(0,r.useRef)(!1),[N,k]=(0,r.useState)(600),[S,A]=(0,r.useState)(!1),E=(0,r.useRef)(0),$=(0,r.useRef)(600),z="default"===e,R=(0,r.useCallback)(e=>Math.max(400,Math.min(e,Math.round(.4*window.innerWidth))),[]);(0,r.useEffect)(()=>{if(!z)return;let e=()=>{k(e=>R(e))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[R,z]),(0,r.useEffect)(()=>{if(!S)return;let e=e=>{let t=E.current-e.clientX;k(R($.current+t))},t=()=>{A(!1)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),document.body.style.cursor="",document.body.style.userSelect=""}},[R,S]),(0,r.useEffect)(()=>{j.current=v,tv=v||"main"},[v]),(0,r.useEffect)(()=>{b&&(g(v),f())},[b,v,g,f]),(0,r.useEffect)(()=>{if(!b)return;let e=!1;return fetch("/api/gateway/resolve?key=main").then(e=>e.ok?e.json():null).then(t=>{if(e||!t)return;let n="string"==typeof t.resolved?t.resolved.trim():"";n&&(y.current=!0,n!==j.current&&w(n))}).catch(()=>{}),()=>{e=!0}},[b]);let T=(0,r.useRef)(0),{history:_,loading:D,loadingMore:L,hasMore:P,loadMore:I,refetchHistory:F}=function(e,t,n){let[s,a]=(0,r.useState)([]),[l,i]=(0,r.useState)(300),[o,c]=(0,r.useState)(!0),[d,u]=(0,r.useState)(!1),m=(0,r.useRef)(null),h=(0,r.useRef)(0),x=(0,r.useRef)(0),p=(0,r.useRef)(0),g=(0,r.useCallback)(async e=>{let t=n||"main",s=x.current+1;x.current=s;let r=e?.silent===!0;r||(p.current+=1,c(!0));try{let n=await fetch(`/api/gateway/history?limit=1000&sessionKey=${encodeURIComponent(t)}`,{cache:"no-store"}),r=n.ok?await n.json():{messages:[]};if(s!==x.current)return;let l=Array.isArray(r?.messages)?r.messages:[],i=e?.preserveExistingOnEmpty!==!1;a(e=>i&&0===l.length&&e.length>0?e:l)}catch{}finally{r||(p.current=Math.max(0,p.current-1),0===p.current&&c(!1))}},[n]),f=(0,r.useCallback)(e=>!e?.force&&Date.now()-t.current<5e3?Promise.resolve():g({silent:!0}),[g,t]),b=(0,r.useMemo)(()=>s.length<=l?s:s.slice(s.length-l),[s,l]),v=s.length>l,w=(0,r.useCallback)(()=>{u(!0),setTimeout(()=>{i(e=>Math.min(e+100,s.length)),u(!1)},100)},[s.length]);return(0,r.useEffect)(()=>{m.current!==n&&(m.current=n,h.current=0,i(300),g())},[n,g]),(0,r.useEffect)(()=>{if(e){if(s.length>0){h.current=0;return}o||h.current>=3||(h.current+=1,g())}},[e,s.length,o,g]),{history:b,allMessages:s,loading:o,loadingMore:d,hasMore:v,loadMore:w,refetchHistory:f}}(b,T,v),[W,O]=(0,r.useState)(tW),{messages:U,sendMessage:q,addToolApprovalResponse:B,status:H,stop:Z,error:J}=(0,eP.Y_)({chat:W}),V=(0,r.useRef)(null),G=(0,r.useRef)(null),X=(0,r.useRef)(null),Q=(0,r.useRef)(null),Y=(0,r.useRef)(null),ee=(0,r.useRef)(null),et=(0,r.useRef)(null),en="streaming"===H||"submitted"===H,es=(0,r.useRef)(null),[ea,ei]=(0,r.useState)(null),[eo,ec]=(0,r.useState)(!0),[ed,eu]=(0,r.useState)([]),[em,eh]=(0,r.useState)(!1),[ex,ep]=(0,r.useState)(""),[eg,ef]=(0,r.useState)([]),[eb,ev]=(0,r.useState)(!1),[ew,ej]=(0,r.useState)(0),[ey,eN]=(0,r.useState)([]),[ek,eC]=(0,r.useState)(!1),[eS,eA]=(0,r.useState)(""),[eE,e$]=(0,r.useState)([]),[ez,eR]=(0,r.useState)(!1),[eT,e_]=(0,r.useState)(0),eD="connected"!==o,[eL,eM]=(0,r.useState)(!1),eK=eL&&!1,eI=(0,ta.b)(e=>e.events),eG=(0,ta.b)(e=>e.lastEvent),eX=(0,tr.e)(e=>e.items),[eQ,eY]=(0,r.useState)(null),e0=(0,r.useRef)(null),e1=(0,r.useRef)(0),e5=(0,r.useRef)(0),[e2,e4]=(0,r.useState)(()=>Date.now());(0,r.useEffect)(()=>{if("idle"===p&&"submitted"!==H&&"streaming"!==H)return;let e=setInterval(()=>{e4(Date.now())},1e3);return()=>clearInterval(e)},[p,H]);let e3=(0,r.useMemo)(()=>{let e=[...U].reverse().find(e=>"assistant"===e.role);return!!e&&t1(e).trim().length>0},[U]),e6=(0,r.useMemo)(()=>{let e=eX.find(e=>"tool-used"===e.type||"sub-agent"===e.type);return e?.timestamp??null},[eX]),e9=(0,r.useMemo)(()=>{if("reconnecting"===o)return{kind:"background",label:"Reconnecting...",detail:h||"Trying to restore the gateway stream"};if("connecting"===o)return{kind:"background",label:"Connecting...",detail:h||"Connecting to the gateway"};if("disconnected"===o)return{kind:"alert",label:"server_unreachable"===u?"ClawPad server unreachable":"Gateway unavailable",detail:h||x||("server_unreachable"===u?"ClawPad is not reachable from this browser.":"OpenClaw gateway is not reachable."),tone:"warn"};let e=eG&&("alert"===eG.indicatorType||"error"===eG.indicatorType)&&!eG.silent?eG:null;if(e){let t=t$(e);return{kind:"alert",label:"error"===e.indicatorType?"Background error":"Background alert",detail:t||void 0,tone:"error"===e.indicatorType?"error":"warn"}}return"submitted"===H?{kind:"thinking",label:"Thinking..."}:"streaming"===H?e3?{kind:"writing",label:"Writing response..."}:{kind:"thinking",label:"Thinking..."}:"thinking"===p?{kind:"thinking",label:"Thinking..."}:"active"===p&&"number"==typeof e6&&e2-e6<=15e3?{kind:"background",label:"Working on a background task..."}:null},[p,x,u,e3,eG,e6,H,e2,h,o]);(0,r.useEffect)(()=>{e0.current&&(clearTimeout(e0.current),e0.current=null);let e=Date.now();if(e9){e5.current=e,eY(t=>!t&&!e9||t&&e9&&t.kind===e9.kind&&t.label===e9.label&&t.detail===e9.detail&&t.tone===e9.tone?t:(e1.current=e,e9));return}if(!eQ)return;let t="alert"===eQ.kind?5e3:"background"===eQ.kind?3e3:1500,n="alert"===eQ.kind?6e3:2500,s=Math.max(Math.max(e1.current+t,e5.current+n)-e,0);return 0===s?void eY(null):(e0.current=setTimeout(()=>{eY(null),e0.current=null},s),()=>{e0.current&&(clearTimeout(e0.current),e0.current=null)})},[e9,eQ]),(0,r.useEffect)(()=>{if(!a)return void ei(null);let e=!1;return ec(!0),(async()=>{try{let t=await fetch(`/api/files/pages/${encodeURIComponent(a)}`);if(!t.ok)throw Error("Failed to load page");let n=await t.json();if(e)return;let s=n?.meta;if(s?.path)return void ei(tj({title:s.title,path:s.path,space:s.space,modified:s.modified}))}catch{}e||ei(tj({title:tw(a),path:a}))})(),()=>{e=!0}},[a]);let e8=(0,r.useCallback)(()=>{let e={};eo&&ea&&(e.activePage=ea);let t=ed.filter(t=>!e.activePage||t.path!==e.activePage.path);return t.length>0?(e.attachedPages=t,e.scope="custom"):e.activePage&&(e.scope="current"),Object.keys(e).length>0?e:null},[ea,ed,eo]),e7=(0,r.useCallback)(()=>{let e=G.current;if(!e)return;let t=e.value,n=e.selectionStart??t.length,s=t.slice(0,n),r=s.lastIndexOf("@");if(-1===r){eh(!1),ep(""),Q.current=null;return}let a=s[r-1],l=!a||/[\s([{]/.test(a),i=s.slice(r+1);if(!l||/\s/.test(i)){eh(!1),ep(""),Q.current=null;return}Q.current={start:r,end:n},ep(i),eh(!0),eC(!1),eA(""),ee.current=null},[]),te=(0,r.useCallback)(async()=>{if(!ez&&!(eE.length>0)){eR(!0);try{let e=await fetch("/api/openclaw/commands"),t=e.ok?await e.json():null,n=Array.isArray(t?.commands)?t.commands.filter(e=>!!(e&&"string"==typeof e.name)).map(e=>({name:e.name,description:e.description??"",disabled:e.disabled})):[];e$(n),e_(0)}catch{e$([])}finally{eR(!1)}}},[eE.length,ez]),ts=(0,r.useCallback)(()=>{let e=G.current;if(!e)return;let t=e.value,n=e.selectionStart??t.length,s=t.slice(0,n),r=s.lastIndexOf("/");if(-1===r){eC(!1),eA(""),ee.current=null;return}let a=s[r-1],l=!a||/[\s([{]/.test(a),i=s.slice(r+1);if(!l||/\s/.test(i)){eC(!1),eA(""),ee.current=null;return}ee.current={start:r,end:n},eA(i),eC(!0),eh(!1),ep(""),Q.current=null,te()},[te]),ti=(0,r.useCallback)(e=>{let t=G.current,n=ee.current;if(!t||!n)return;let s=t.value,r=s.slice(0,n.start),a=s.slice(n.end),l=`/${e}`,i=a.startsWith(" ")?"":" ",o=`${r}${l}${i}${a}`,c=r.length+l.length+i.length;t.value=o,t.setSelectionRange(c,c),t.focus(),eC(!1),eA(""),ee.current=null,requestAnimationFrame(()=>{let e=G.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,150)}px`)})},[]),to=(0,r.useCallback)(e=>{let t=G.current,n=Q.current;if(!t||!n)return;let s=t.value,r=s.slice(0,n.start),a=s.slice(n.end),l=`@${e.title}`,i=a.startsWith(" ")?"":" ",o=`${r}${l}${i}${a}`,c=r.length+l.length+i.length;t.value=o,t.setSelectionRange(c,c),t.focus(),eu(t=>t.some(t=>t.path===e.path)?t:[...t,e]),eh(!1),ep(""),Q.current=null,requestAnimationFrame(()=>{let e=G.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,150)}px`)})},[]),tc=(0,r.useCallback)(()=>{let e=G.current;if(!e)return;let t=e.value,n=e.selectionStart??t.length,s=e.selectionEnd??n;e.value=`${t.slice(0,n)}@${t.slice(s)}`;let r=n+1;e.setSelectionRange(r,r),e.focus(),e7()},[e7]);(0,r.useEffect)(()=>{if(!em)return void ev(!1);let e=!1,t=ex.trim();!t&&ey.length>0&&ef(ey);let n=setTimeout(async()=>{if(!e){ev(!0);try{let n=t?`/api/files/search?q=${encodeURIComponent(t)}&limit=8`:"/api/files/recent?limit=8",s=await fetch(n),r=s.ok?await s.json():[];if(e)return;let a=Array.isArray(r)?r.map(e=>tj(e)):[];ef(a),t||eN(a),ej(0)}catch{e||ef([])}finally{e||ev(!1)}}},150);return()=>{e=!0,clearTimeout(n)}},[em,ex,ey]),(0,r.useEffect)(()=>{b&&te()},[b,te]),(0,r.useEffect)(()=>{if(!b)return;let e=!1;return(async()=>{try{let t=await fetch("/api/files/recent?limit=8");if(!t.ok)return;let n=await t.json();if(e)return;let s=Array.isArray(n)?n.map(e=>tj(e)):[];eN(s)}catch{}})(),()=>{e=!0}},[b]),(0,r.useEffect)(()=>{b||(eh(!1),ep(""),Q.current=null,eC(!1),eA(""),ee.current=null)},[b]),(0,r.useEffect)(()=>{if(!em)return;let e=e=>{let t=e.target;Y.current&&!Y.current.contains(t)&&(eh(!1),ep(""),Q.current=null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[em]),(0,r.useEffect)(()=>{if(!ek)return;let e=e=>{let t=e.target;et.current&&!et.current.contains(t)&&(eC(!1),eA(""),ee.current=null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ek]);let[td,tu]=(0,r.useState)([]),tm=(0,r.useRef)(null),tx=(0,r.useRef)([]),tp=(0,r.useRef)(null),ty=(0,r.useRef)(null),tk=(0,r.useRef)(""),tC=(0,r.useRef)(new Map),tS=(0,r.useRef)([]),tE=(0,r.useRef)(null),tz=(0,r.useRef)(null),[tR,tT]=(0,r.useState)([]),tD=(0,r.useCallback)(()=>{tT(tS.current.map(e=>tC.current.get(e)).filter(e=>!!e))},[]),tK=(0,r.useCallback)((e=!1)=>{if(e){tE.current&&(clearTimeout(tE.current),tE.current=null),tD();return}tE.current||(tE.current=setTimeout(()=>{tE.current=null,tD()},80))},[tD]),tF=(0,r.useCallback)(()=>{tC.current.clear(),tS.current=[],tz.current=null,tE.current&&(clearTimeout(tE.current),tE.current=null),tT([])},[]);(0,r.useEffect)(()=>{let e=tm.current;e&&("streaming"===H?tu(t=>t.map(t=>t.id===e&&"sending"===t.status?{...t,status:"sent"}:t)):"ready"===H&&(tu(t=>t.map(t=>t.id===e&&("sending"===t.status||"streaming"===t.status)?{...t,status:"sent"}:t)),tm.current=null))},[H]),(0,r.useEffect)(()=>{if(J&&tm.current){let e=tm.current;tu(t=>t.map(t=>t.id===e?{...t,status:"error"}:t)),tm.current=null}},[J]);let tO=(0,r.useRef)(!0),tH=(0,r.useRef)(0),[tV,tG]=(0,r.useState)(0),tX=(0,r.useCallback)((e="smooth")=>{let t=V.current;if(!t)return;let n=t.scrollHeight-t.clientHeight;t.scrollTo({top:n>0?n:0,behavior:e})},[]),tQ=(0,r.useCallback)(()=>{let e=V.current;!e||(tO.current=e.scrollHeight-e.scrollTop-e.clientHeight<100,tO.current&&tG(0))},[]),t0=(0,r.useCallback)(e=>{if("tool"!==e.stream)return;let t="string"==typeof e.sessionKey?e.sessionKey:void 0,n=j.current||"main";if(y.current&&t&&t!==n)return;let s="string"==typeof e.runId?e.runId:"unknown",r=e.data??{},a="string"==typeof r.toolCallId?r.toolCallId:"";if(!a)return;let l="string"==typeof r.name?r.name:"tool",i="string"==typeof r.phase?r.phase:"unknown",o="start"===i||"update"===i||"result"===i||"error"===i?i:"unknown",c="start"===o?r.args:void 0,d="update"===o?tM(r.partialResult):"result"===o?tM(r.result):"error"===o?tM(r.error??r.result):void 0,u=Date.now();tz.current&&tz.current!==s&&"start"===o&&tF(),tz.current=s;let m=tC.current.get(a);if(m?(m.name=l,m.phase=o,void 0!==c&&(m.args=c),void 0!==d&&(m.output=d),m.updatedAt=u):(m={toolCallId:a,runId:s,sessionKey:t,name:l,args:c,output:d,phase:o,startedAt:"number"==typeof e.ts?e.ts:u,updatedAt:u},tC.current.set(a,m),tS.current.push(a)),tS.current.length>50){let e=tS.current.length-50;for(let t of tS.current.splice(0,e))tC.current.delete(t)}tK("result"===o||"error"===o)},[tF,tK]),t2=(0,r.useMemo)(()=>{let e=[];for(let t of _){let n=tP(t);if(!n.internal)continue;let s=(n.displayText?.trim()??"").replace(/^System:\s*/i,"").trim();if(!s)continue;let{kind:r,tone:a}=function(e){let t=e.toLowerCase(),n=t.startsWith("heartbeat")||t.includes("heartbeat_ok")||t.includes("heartbeat"),s=/error|failed|denied|blocked|timeout|unavailable/i.test(t),r=/\[network\]|warning|alert/i.test(t);return s?{kind:"alert",tone:"error"}:r?{kind:"alert",tone:"warn"}:n?{kind:"heartbeat"}:{kind:"system"}}(s);e.push({id:`sys-${n.timestamp}-${e.length}`,kind:r,tone:a,text:s,timestamp:n.timestamp,source:"system"})}return e},[_]),t4=(0,r.useMemo)(()=>{let e=[];return eI.forEach((t,n)=>{let s=t$(t);if(!s)return;let r="alert"===t.indicatorType||"error"===t.indicatorType;e.push({id:`hb-${t.ts}-${n}`,kind:r?"alert":"heartbeat",tone:"error"===t.indicatorType?"error":r?"warn":void 0,text:s,timestamp:t.ts,source:"heartbeat"})}),e},[eI]),t3=(0,r.useMemo)(()=>{let e=[...t2,...t4].sort((e,t)=>t.timestamp-e.timestamp),t=new Set,n=[];for(let s of e){let e=`${s.source}-${s.timestamp}-${s.text}`;t.has(e)||(t.add(e),n.push(s))}return n},[t2,t4]),t6=(0,r.useMemo)(()=>{var e=function(e,t,n,s,r,a){let l=[],i=new Map;for(let n=0;n<e.length;n+=1){let s=e[n];i.set(s,n);let r=tP(s);!r.internal&&(t||"tool"!==r.role)&&l.push({kind:"message",normalized:r})}for(let t of n){let n=t_(t.text);l.some(s=>{var r;if("message"!==s.kind)return!1;let a=s.normalized;if(a.role!==t.role)return!1;let l=tL(a.raw),o=l?function(e){if(!e.includes("[message_id:"))return null;for(let t of e.split(/\r?\n/)){let e=t.match(tA);if(e)return(e[1]??"").trim()||null}return null}(l):null;if(o&&o===t.id)return!0;let c=t_(a.displayText);if(!c||!n||c!==n)return!1;let d="number"==typeof(r=a.raw.timestamp)&&Number.isFinite(r)?r<1e12?1e3*r:r:null;if(null!==d){let e=3e5>Math.abs(d-t.timestamp),n=d>=t.timestamp-5e3;return e&&n}let u=i.get(a.raw);return"number"==typeof u&&u>=e.length-5})||l.push({kind:"optimistic",message:t})}if(t)for(let e of s)l.push({kind:"tool-stream",entry:e});if(a&&r.length>0){let e=r[r.length-1];"assistant"===e.role&&l.push({kind:"stream",message:e,isStreaming:a})}return l}(_,eL,td,tR,U,en);let t=[],n=null;for(let s of e)if("message"===s.kind)n&&n.role===s.normalized.role?n.messages.push(s.normalized):(n&&t.push(n),n={kind:"group",role:s.normalized.role,messages:[s.normalized],timestamp:s.normalized.timestamp});else if(n&&(t.push(n),n=null),"optimistic"===s.kind)t.push({kind:"optimistic-group",messages:[s.message]});else if("tool-stream"===s.kind){let e=t[t.length-1];e&&"tool-stream-group"===e.kind?e.entries.push(s.entry):t.push({kind:"tool-stream-group",entries:[s.entry]})}else"stream"===s.kind?t.push({kind:"stream-group",message:s.message,isStreaming:s.isStreaming}):"indicator"===s.kind&&t.push({kind:"indicator-group",status:s.status});return n&&t.push(n),t},[_,eL,td,tR,U,en]),t9=t6.length>0||eL&&t3.length>0;(0,r.useEffect)(()=>{let e=t6.length;if(0===tH.current&&e>0){tH.current=e,tO.current=!0,b&&requestAnimationFrame(()=>tX("auto"));return}tO.current?requestAnimationFrame(()=>tX("smooth")):e>tH.current&&tH.current>0&&tG(t=>t+(e-tH.current)),tH.current=e},[t6.length,tX,b]);let t8=(0,r.useRef)(!1);(0,r.useEffect)(()=>{if(!b){t8.current=!1;return}!D&&(t8.current||(t8.current=!0,tO.current=!0,tG(0),requestAnimationFrame(()=>{tX("auto"),setTimeout(()=>tX("auto"),150)})))},[b,D,tX]);let t7=(0,r.useRef)(null),ne=(0,r.useCallback)(()=>{let e=V.current;e&&(t7.current={prevScrollHeight:e.scrollHeight,prevScrollTop:e.scrollTop}),I()},[I]);(0,r.useLayoutEffect)(()=>{let e=t7.current;if(!e)return;let t=V.current;if(!t)return;let n=t.scrollHeight-e.prevScrollHeight;0!==n&&(t.scrollTop=e.prevScrollTop+n),t7.current=null},[t6.length]),(0,r.useEffect)(()=>{en&&tO.current&&requestAnimationFrame(()=>tX("smooth"))},[en,U,tR,tX]),(0,r.useEffect)(()=>{if(!b)return;let e=null,t=null,n=!1,s=null;return!function r(){n||((e=new EventSource("/api/gateway/events")).addEventListener("gateway",e=>{try{let n=JSON.parse(e.data);if("number"==typeof n.seq&&(null!==s&&n.seq>s+1&&F({force:!0}),s=n.seq),"agent"===n.event&&n.payload&&t0(n.payload),"chat"===n.event&&n.payload){let e=n.payload,s=j.current||"main";if(y.current&&e.sessionKey&&e.sessionKey!==s)return;let r=e.state;("final"===r||"error"===r||"aborted"===r)&&(t&&(clearTimeout(t),t=null),F({force:!0}))}}catch{}}),e.onerror=()=>{e?.close(),e=null,n||setTimeout(r,5e3)})}(),()=>{n=!0,t&&clearTimeout(t),e?.close()}},[t0,b,F]);let[nt,nn]=(0,r.useState)([]),[ns,nr]=(0,r.useState)({}),[na,nl]=(0,r.useState)(!1),ni=(0,r.useCallback)(async e=>{let t=await tN(e);t.length>0&&(nn(e=>[...e,...t]),G.current?.focus())},[]),no=(0,r.useCallback)(e=>{nn(t=>t.filter(t=>t.id!==e))},[]),nc=(0,r.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of Array.from(t))if("file"===e.kind&&tg.includes(e.type)){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),ni(n))},[ni]),nd=(0,r.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer?.types.includes("Files")&&nl(!0)},[]),nu=(0,r.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),{clientX:n,clientY:s}=e;(n<=t.left||n>=t.right||s<=t.top||s>=t.bottom)&&nl(!1)},[]),nm=(0,r.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),nl(!1);let t=Array.from(e.dataTransfer?.files??[]).filter(e=>tg.includes(e.type));t.length>0&&ni(t)},[ni]),nh=(0,r.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length>0&&ni(t),e.target.value=""},[ni]),nx=(0,r.useCallback)(()=>{O(new eP.ry({transport:tI()})),nn([]),eu([]),ec(!0),eh(!1),ep(""),Q.current=null,tu([]),nr({}),tF(),tf=[],tb=null,tm.current=null,G.current&&(G.current.value="",G.current.style.height="auto",G.current.focus())},[tF]);(0,r.useEffect)(()=>{if("default"===e)return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t);function t(e){e.metaKey&&e.shiftKey&&"l"===e.key&&(e.preventDefault(),n(!0))}},[n,e]),(0,r.useEffect)(()=>{if(t||"default"!==e){let e=setTimeout(()=>{G.current?.focus()},100);return()=>clearTimeout(e)}},[t,e]);let np=(0,r.useCallback)(async(e,t)=>{if(eD)return;let n=nt.length>0;if(!e.trim()&&!n)return;let s=e.trim()||(n?"What's in this image?":"");if(!s)return;tF();let r=t?.messageId?.trim()||crypto.randomUUID(),a=nt.map(e=>e.dataUrl),l={id:r,role:"user",text:s,images:a.length>0?a:void 0,timestamp:Date.now(),status:"sending"};tu(e=>[...e,l]),a.length>0&&nr(e=>({...e,[r]:a})),tm.current=r,T.current=Date.now(),nn([]),G.current&&(G.current.value="",G.current.style.height="auto"),eh(!1),ep(""),Q.current=null,tf=a,tb=e8();try{await q({text:s}),setTimeout(()=>{tu(e=>e.map(e=>e.id===r&&"sending"===e.status?{...e,status:"sent"}:e))},2e3)}catch(e){console.error("[chat] sendMessage error:",e),t?.messageId&&(tx.current=tx.current.filter(e=>e!==t.messageId),ty.current===t.messageId&&(ty.current=null,tk.current="")),tu(e=>e.map(e=>e.id===r?{...e,status:"error"}:e))}tf=[],tb=null},[eD,q,nt,e8,tF]);(0,r.useEffect)(()=>{let e=e=>{let s=e.detail??{},r=s.messageId?.trim()||crypto.randomUUID(),l=function(e,t){if(e.message&&e.message.trim()){let t=[e.message.trim()];return e.messageId?.trim()&&t.push(`[message_id: ${e.messageId.trim()}]`),t.join("\n\n")}if(!e.action)return null;let n=e.selection?.trim()??"",s=(e.pagePath??t??"").trim(),r=n.length>0,a="continue"===e.action?r?"context below":"referenced page":r?"selected text":"referenced page",l=[function(e,t){switch(e){case"improve":return`Improve the writing of the ${t}. Return only the improved text.`;case"simplify":return`Simplify the ${t} while preserving meaning. Return only the simplified text.`;case"expand":return`Expand the ${t} with more detail while preserving meaning. Return only the expanded text.`;case"summarize":return`Summarize the ${t} concisely. Return only the summary.`;case"fix-grammar":return`Fix grammar, spelling, and punctuation in the ${t}. Return only the corrected text.`;case"continue":return`Continue writing from the ${t}. Return only the continuation.`;default:return`Please help with the ${t}.`}}(e.action,a)];return s&&l.push(`Reference: ${s}`),n&&l.push(`Selected text:
|
|
4
|
-
"""
|
|
5
|
-
${n}
|
|
6
|
-
"""`),e.messageId?.trim()&&l.push(`[message_id: ${e.messageId.trim()}]`),l.join("\n\n")}({...s,messageId:r},a);l&&(t||n(!0),s.selection?.trim()&&tx.current.push(r),np(l,{messageId:r}))};return window.addEventListener("clawpad:ai-action",e),()=>window.removeEventListener("clawpad:ai-action",e)},[np,a,t,n]),(0,r.useEffect)(()=>{if("ready"===H){ty.current=null,tk.current="";return}if("streaming"!==H)return;let e=tx.current[0];if(!e)return;ty.current||(ty.current=e);let t=[...U].reverse().find(e=>"assistant"===e.role);if(!t)return;let n=t1(t);n.trim()&&n!==tk.current&&(tk.current=n,window.dispatchEvent(new CustomEvent("clawpad:ai-stream",{detail:{messageId:ty.current,text:n}})))},[U,H]),(0,r.useEffect)(()=>{let e=es.current;if(es.current=H,"ready"!==H||"ready"===e||0===tx.current.length)return;let t=[...U].reverse().find(e=>"assistant"===e.role),n=tx.current[0];if(!t||!n)return void tx.current.shift();let s=t1(t);if(!s.trim())return void tx.current.shift();let r=tx.current.shift();r&&tp.current!==r&&(tp.current=r,ty.current=null,tk.current="",window.dispatchEvent(new CustomEvent("clawpad:ai-result",{detail:{messageId:r,text:s.trim()}})))},[U,H]);let ng=(0,r.useCallback)(async()=>{Z();try{await fetch("/api/chat/abort",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionKey:v})})}catch{}},[v,Z]),nf=(0,r.useCallback)(e=>{tu(t=>t.filter(t=>t.id!==e.id)),e.images&&e.images.length>0?(nn(e.images.map((e,t)=>({id:crypto.randomUUID(),dataUrl:e,name:`image-${t}`}))),setTimeout(()=>{np(e.text)},0)):np(e.text)},[np]),nb=(0,r.useCallback)(e=>{e.preventDefault(),!eD&&G.current&&np(G.current.value)},[eD,np]),nv=(0,r.useCallback)(e=>{if(ek){let t=eS.trim().toLowerCase(),n=0===t.length?eE:eE.filter(e=>e.name.toLowerCase().includes(t)),s=n.length>0?n:eE.slice(0,12);if("ArrowDown"===e.key){e.preventDefault(),e_(e=>0===s.length?0:(e+1)%s.length);return}if("ArrowUp"===e.key){e.preventDefault(),e_(e=>0===s.length?0:(e-1+s.length)%s.length);return}if("Enter"===e.key&&!e.shiftKey){e.preventDefault();let t=s[eT]??s[0];t?ti(t.name):(eC(!1),eA(""),ee.current=null);return}if("Escape"===e.key){e.preventDefault(),eC(!1),eA(""),ee.current=null;return}}if(em){let t=ex.trim()||eg.length>0?eg:ey;if("ArrowDown"===e.key){e.preventDefault(),ej(e=>0===t.length?0:(e+1)%t.length);return}if("ArrowUp"===e.key){e.preventDefault(),ej(e=>0===t.length?0:(e-1+t.length)%t.length);return}if("Enter"===e.key&&!e.shiftKey){e.preventDefault();let n=t[ew]??t[0];if(n)to(n);else{eh(!1),ep(""),Q.current=null;let t=e.target.value;(t||nt.length>0)&&np(t||"")}return}if("Escape"===e.key){e.preventDefault(),eh(!1),ep(""),Q.current=null;return}}if("Enter"===e.key&&!e.shiftKey){e.preventDefault();let t=e.target.value;(t||nt.length>0)&&np(t||"")}},[nt.length,to,ti,np,ew,em,ex,eg,ey,eE,eT,ek,eS]),nw=(0,r.useCallback)(()=>{let e=G.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,150)}px`,ts(),e7())},[e7,ts]),nj="default"===e&&!t,ny=ea?.title??(a?a.split("/").pop()?.replace(/\.md$/,"").replace(/-/g," ")??null:null),nN="fullscreen"===e,nk="sheet"===e,nC=(0,r.useMemo)(()=>{let e=[];for(let t of(eo&&ea&&e.push({key:`current-${ea.path}`,page:ea,kind:"current"}),ed))e.some(e=>e.page.path===t.path)||e.push({key:`attached-${t.path}`,page:t,kind:"attached"});return e},[ea,ed,eo]),nS=ex.trim()||eg.length>0?eg:ey,nA=eE.filter(e=>!!(e&&"string"==typeof e.name)),nE=eS.trim().toLowerCase(),n$=0===nE.length?nA:nA.filter(e=>e.name.toLowerCase().includes(nE)),nz=n$.length>0?n$.slice(0,12):nA.slice(0,12),nR=(0,r.useCallback)(e=>{z&&(e.preventDefault(),E.current=e.clientX,$.current=N,A(!0))},[z,N]);return(0,s.jsxs)("div",{onDragOver:nd,onDragLeave:nu,onDrop:nm,className:(0,c.cn)("relative flex flex-col bg-background",nj&&"hidden","default"===e&&"h-full shrink-0 border-l",nk&&"h-full w-full",nN&&"h-full w-full"),style:"default"===e?{width:N,minWidth:400,maxWidth:"40vw"}:void 0,children:[z&&(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize chat panel",onPointerDown:nR,className:(0,c.cn)("absolute left-0 top-0 z-20 h-full w-2 cursor-col-resize","group"),children:(0,s.jsx)("div",{className:(0,c.cn)("absolute inset-y-0 left-0 w-px bg-border/70","transition-colors group-hover:bg-[color:var(--cp-brand-2)]",S&&"bg-[color:var(--cp-brand-2)]")})}),na&&(0,s.jsx)("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-lg border-2 border-dashed border-blue-500 bg-blue-50/60 dark:bg-blue-950/40",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 text-blue-600 dark:text-blue-400",children:[(0,s.jsx)(eF.A,{className:"h-8 w-8"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),(0,s.jsxs)("div",{className:(0,c.cn)("flex shrink-0 items-center justify-between border-b px-4",nN?"h-14":"h-12"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)(el.A,{className:"h-4 w-4 shrink-0 text-[color:var(--cp-brand-2)]"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Chat"}),(0,s.jsx)(tU,{connected:l,wsStatus:o,agentStatus:p})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:(0,c.cn)("h-8 w-8 text-muted-foreground hover:text-foreground",eL&&"text-[color:var(--cp-brand-2)] hover:text-[color:var(--cp-brand-2)]"),onClick:()=>eM(!eL),title:eL?"Hide details":"Show details","aria-pressed":eL,"aria-label":eL?"Hide details":"Show details",children:eL?(0,s.jsx)(eW.A,{className:"h-4 w-4"}):(0,s.jsx)(eO.A,{className:"h-4 w-4"})}),(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:nx,title:"New chat",children:(0,s.jsx)(eU.A,{className:"h-4 w-4"})})]})]}),eD&&(0,s.jsx)("div",{className:"border-b border-amber-500/30 bg-amber-500/10 px-4 py-2 text-xs text-amber-700 dark:text-amber-300",children:"reconnecting"===o?"Reconnecting to OpenClaw gateway…":"server_unreachable"===u?"ClawPad server is unreachable from this browser.":"OpenClaw gateway is unavailable. Start or restart the gateway to resume chat."}),(0,s.jsx)("div",{ref:V,onScroll:tQ,className:"flex-1 min-h-0 min-w-0 overflow-y-auto",children:(0,s.jsxs)("div",{className:"relative flex min-h-full flex-col gap-4 p-4 pb-[calc(8rem+env(safe-area-inset-bottom,0px))] min-w-0 overflow-hidden",children:[!t9&&!D&&(0,s.jsx)(tq,{pageTitle:ny}),D&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[(0,s.jsx)(eq.A,{className:"h-3.5 w-3.5 animate-spin"}),(0,s.jsx)("span",{className:"text-xs",children:"Loading history…"})]}),P&&!D&&(0,s.jsx)("div",{className:"flex justify-center py-2",children:(0,s.jsxs)("button",{onClick:ne,disabled:L,className:"mx-auto flex items-center gap-2 rounded-full bg-muted/60 px-4 py-2 text-xs text-muted-foreground hover:bg-muted transition-colors",children:[L?(0,s.jsx)(eq.A,{className:"h-3 w-3 animate-spin"}):(0,s.jsx)(er.A,{className:"h-3 w-3"}),"Load earlier messages"]})}),eL&&t3.length>0&&(0,s.jsx)(tB,{events:t3}),t6.map((e,t)=>{if("group"===e.kind)return(0,s.jsx)(tJ,{group:e,showReasoning:eK,showTools:eL},`g-${t}-${e.timestamp}`);if("optimistic-group"===e.kind)return e.messages.map(e=>(0,s.jsx)(tY,{message:e,images:ns[e.id],onRetry:nf},e.id));if("tool-stream-group"===e.kind){let n=e.entries[e.entries.length-1],r=n?`tool-batch-${n.toolCallId}-${n.updatedAt}`:`tool-batch-${t}`;return(0,s.jsx)(tZ,{entries:e.entries},r)}return"stream-group"===e.kind?(0,s.jsx)(t5,{message:e.message,isLatest:!0,isStreaming:e.isStreaming,showThinking:eL,onToolApprove:e=>B({id:e,approved:!0}),onToolDeny:e=>B({id:e,approved:!1,reason:"Denied by user"})},`stream-${e.message.id}`):null}),J&&!td.some(e=>"error"===e.status)&&(0,s.jsxs)(tt.P.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"flex items-start gap-2 rounded-lg border border-destructive/20 bg-destructive/5 p-3 text-sm text-destructive",children:[(0,s.jsx)(eB.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("p",{className:"font-medium",children:"Something went wrong"}),(0,s.jsx)("p",{className:"text-xs opacity-80 mt-0.5",children:J.message.includes("API key")?"No API key configured. Check your environment settings.":J.message})]})]})]})}),(0,s.jsx)(tn.N,{children:tV>0&&(0,s.jsxs)(tt.P.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},onClick:()=>{tX("smooth"),tG(0)},className:"absolute bottom-[4.5rem] left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 rounded-full bg-blue-600 dark:bg-blue-500 px-3 py-1.5 text-xs font-medium text-white shadow-lg hover:bg-blue-700 dark:hover:bg-blue-600 transition-colors",children:[(0,s.jsx)(eH.A,{className:"h-3 w-3"}),tV," new message",1!==tV?"s":""]})}),!t9&&ny&&(0,s.jsx)("div",{className:"border-t px-4 py-2",children:(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:"Viewing:"}),(0,s.jsx)("span",{className:"font-medium capitalize text-foreground",children:ny})]})}),(0,s.jsxs)("div",{className:(0,c.cn)("shrink-0 border-t p-4",nN&&"pb-[calc(0.75rem+env(safe-area-inset-bottom,0px))]",nN&&"sticky bottom-0 bg-background"),children:[(0,s.jsx)(th,{status:eQ}),nt.length>0&&(0,s.jsx)("div",{className:"mb-2 flex flex-wrap gap-2",children:nt.map(e=>(0,s.jsxs)("div",{className:"group relative",children:[(0,s.jsx)("img",{src:e.dataUrl,alt:e.name,className:"h-16 w-16 rounded-lg border object-cover"}),(0,s.jsx)("button",{type:"button",onClick:()=>no(e.id),className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full bg-destructive text-white opacity-0 transition-opacity group-hover:opacity-100 hover:bg-destructive/90",title:"Remove image",children:(0,s.jsx)(m.A,{className:"h-3 w-3"})}),(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0 truncate rounded-b-lg bg-black/50 px-1 py-0.5 text-[9px] text-white",children:e.name})]},e.id))}),(0,s.jsxs)("form",{onSubmit:nb,className:"w-full",children:[(0,s.jsx)("input",{ref:X,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,className:"hidden",onChange:nh}),(0,s.jsxs)("div",{className:(0,c.cn)("relative flex w-full flex-col gap-2 rounded-2xl border bg-muted/30 px-4 py-3","shadow-[0_2px_5px_rgba(0,0,0,0.04)] transition-shadow duration-150","focus-within:shadow-[0_8px_14px_rgba(0,0,0,0.08)]",nN&&"min-h-[64px]"),ref:Y,children:[(nC.length>0||ea&&!eo)&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[(0,s.jsx)(d.$,{type:"button",size:"icon",variant:"ghost",className:(0,c.cn)("h-7 w-7 rounded-full text-muted-foreground/70 hover:text-foreground hover:bg-muted/60",em&&"bg-muted/60 text-foreground"),onClick:tc,title:"Mention a page","aria-label":"Mention a page",disabled:en||eD,children:(0,s.jsx)(eZ.A,{className:"h-4 w-4"})}),nC.map(e=>(0,s.jsxs)("span",{className:"group inline-flex items-center gap-1.5 rounded-full border border-border/70 bg-muted/30 px-2.5 py-1 text-muted-foreground",children:["current"===e.kind?(0,s.jsx)(C.A,{className:"h-3.5 w-3.5 text-muted-foreground/70"}):(0,s.jsx)(eZ.A,{className:"h-3.5 w-3.5 text-muted-foreground/70"}),(0,s.jsx)("span",{className:"max-w-[180px] truncate text-foreground/80",children:e.page.title}),(0,s.jsx)("button",{type:"button",onClick:()=>{"current"===e.kind?ec(!1):eu(t=>t.filter(t=>t.path!==e.page.path))},className:"ml-0.5 rounded-full p-0.5 text-muted-foreground/60 hover:text-foreground","aria-label":"Remove context",children:(0,s.jsx)(m.A,{className:"h-3 w-3"})})]},e.key)),!eo&&ea&&(0,s.jsx)("button",{type:"button",onClick:()=>ec(!0),className:"rounded-full border border-dashed border-border/70 px-2.5 py-1 text-[10px] text-muted-foreground hover:text-foreground",children:"Add current page"})]}),em&&(0,s.jsxs)("div",{className:"absolute bottom-full left-0 right-0 mb-2 rounded-xl border bg-popover shadow-lg",onMouseDown:e=>e.preventDefault(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/60",children:ex.trim()?"Pages":"Recent pages"}),eb&&(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/60",children:"Searching…"})]}),(0,s.jsxs)("div",{className:"max-h-56 overflow-y-auto pb-1",children:[!eb&&0===nS.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:ex.trim()?"No matching pages":"No recent pages"}),nS.map((e,t)=>(0,s.jsxs)("button",{type:"button",onClick:()=>to(e),className:(0,c.cn)("flex w-full items-start gap-2 px-3 py-2 text-left text-sm transition-colors",t===ew?"bg-muted/60":"hover:bg-muted/40"),children:[(0,s.jsx)(C.A,{className:"mt-0.5 h-4 w-4 text-muted-foreground/70"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate font-medium text-foreground",children:e.title}),(0,s.jsx)("div",{className:"truncate text-[11px] text-muted-foreground/70",children:e.path})]})]},e.path))]})]}),ek&&(0,s.jsxs)("div",{ref:et,className:"absolute bottom-full left-0 right-0 mb-2 rounded-xl border bg-popover shadow-lg",onMouseDown:e=>e.preventDefault(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/60",children:"OpenClaw commands"}),ez&&(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/60",children:"Loading…"})]}),(0,s.jsxs)("div",{className:"max-h-56 overflow-y-auto pb-1",children:[!ez&&0===nz.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No commands available"}),nz.map((e,t)=>(0,s.jsxs)("button",{type:"button",onClick:()=>ti(e.name),className:(0,c.cn)("flex w-full items-start gap-2 px-3 py-2 text-left text-sm transition-colors",t===eT?"bg-muted/60":"hover:bg-muted/40",e.disabled&&"opacity-60"),children:[(0,s.jsx)(eJ.A,{className:"mt-0.5 h-4 w-4 text-muted-foreground/70"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate font-medium text-foreground",children:e.name}),(0,s.jsxs)("div",{className:"truncate text-[11px] text-muted-foreground/70",children:["/",e.name," — ",e.description]})]})]},e.name))]})]}),(0,s.jsx)("textarea",{ref:G,onKeyDown:nv,onPaste:nc,onInput:nw,placeholder:nt.length>0?"Add a message or send…":"Ask your agent…",rows:nN?1:2,className:(0,c.cn)("w-full resize-none bg-transparent px-1 py-1 text-sm leading-relaxed","placeholder:text-muted-foreground/80","focus:outline-none focus:ring-0","min-h-[44px] max-h-[150px]",nN&&"text-base"),disabled:en}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsx)(d.$,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground/70 hover:text-foreground hover:bg-muted/60",onClick:()=>X.current?.click(),title:"Attach image","aria-label":"Attach image",disabled:en||eD,children:(0,s.jsx)(i.A,{className:"h-4 w-4"})})}),en?(0,s.jsx)(d.$,{type:"button",size:"icon",variant:"ghost",onClick:ng,className:"h-9 w-9 rounded-full bg-white text-black shadow-sm hover:bg-white/90","aria-label":"Stop generation",children:(0,s.jsx)("span",{className:"h-3.5 w-3.5 rounded-sm bg-black"})}):(0,s.jsx)(d.$,{type:"submit",size:"icon",className:"h-9 w-9 rounded-full bg-white text-black shadow-sm hover:bg-white/90","aria-label":"Send message",disabled:eD,children:(0,s.jsx)(eV.A,{className:"h-4 w-4"})})]})]})]})]})]})}function tU({connected:e,wsStatus:t,agentStatus:n}){let r="connecting"===t||"reconnecting"===t,a=e?"active"===n||"thinking"===n?"bg-violet-400":"bg-green-500":r?"bg-amber-400":"bg-zinc-300 dark:bg-zinc-600";return(0,s.jsxs)("span",{className:"relative flex h-2 w-2",title:e?n:r?t:"disconnected",children:[(r||e&&("active"===n||"thinking"===n))&&(0,s.jsx)("span",{className:(0,c.cn)("absolute inline-flex h-full w-full rounded-full opacity-75 animate-ping",a)}),(0,s.jsx)("span",{className:(0,c.cn)("relative inline-flex h-2 w-2 rounded-full",a)})]})}function tq({pageTitle:e}){return(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center py-16",children:(0,s.jsxs)("div",{className:"space-y-3 text-center",children:[(0,s.jsx)(el.A,{className:"mx-auto h-8 w-8 text-muted-foreground/40"}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-muted-foreground",children:"Chat with your OpenClaw agent"}),e&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground/60",children:["Viewing:"," ",(0,s.jsx)("span",{className:"capitalize font-medium",children:e})]})]})]})})}let tB=(0,r.memo)(function({events:e}){let[t,n]=(0,r.useState)(!1),[a,l]=(0,r.useState)(null),i=e.filter(e=>"alert"===e.kind).length;return(0,s.jsxs)("div",{className:"rounded-xl border border-border/60 bg-muted/20",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:(0,c.cn)("flex w-full items-center justify-between gap-2 px-3 py-2 text-left","text-[11px] text-muted-foreground hover:text-foreground"),"aria-expanded":t,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(eG.A,{className:"h-3.5 w-3.5 text-muted-foreground/70"}),(0,s.jsx)("span",{className:"font-medium text-foreground/80",children:"System events"}),(0,s.jsx)("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",children:e.length}),i>0&&(0,s.jsxs)("span",{className:"rounded-full border border-red-500/30 bg-red-500/10 px-2 py-0.5 text-[10px] text-red-500",children:[i," alert",1!==i?"s":""]})]}),(0,s.jsx)(eX.A,{className:(0,c.cn)("h-4 w-4 transition-transform",t?"rotate-180":"rotate-0")})]}),t&&(0,s.jsx)("div",{className:"border-t border-border/50",children:e.map(e=>{let t=a===e.id,n=e.text.length>140,r=n?`${e.text.slice(0,137)}…`:e.text;return(0,s.jsx)("div",{className:"border-t border-border/40 first:border-t-0",children:(0,s.jsxs)("button",{type:"button",onClick:()=>{n&&l(t=>t===e.id?null:e.id)},className:"flex w-full items-start gap-3 px-3 py-2 text-left",children:[(0,s.jsx)(tH,{kind:e.kind,tone:e.tone}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground/70",children:new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,s.jsx)("div",{className:"text-xs text-foreground/80 whitespace-pre-wrap",children:t?e.text:r})]}),n&&(0,s.jsx)(k.A,{className:(0,c.cn)("mt-1 h-3.5 w-3.5 text-muted-foreground/60 transition-transform",t&&"rotate-90")})]})},e.id)})})]})});function tH({kind:e,tone:t}){let n=(0,c.cn)("shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium","system"===e&&"border-border/60 bg-muted/40 text-muted-foreground","heartbeat"===e&&"border-blue-500/30 bg-[color:var(--cp-status-heartbeat-bg)] text-[color:var(--cp-status-heartbeat-text)]","alert"===e&&("error"===t?"border-red-500/30 bg-[color:var(--cp-status-error-bg)] text-[color:var(--cp-status-error-text)]":"border-amber-500/30 bg-[color:var(--cp-status-alert-bg)] text-[color:var(--cp-status-alert-text)]"));return(0,s.jsx)("span",{className:n,children:"system"===e?"System":"heartbeat"===e?"Heartbeat":"Alert"})}let tZ=(0,r.memo)(function({entries:e}){return(0,s.jsx)("div",{className:"flex flex-col gap-0.5 items-start max-w-[95%]",children:e.map(e=>(0,s.jsx)(t3,{entry:e},`${e.toolCallId}-${e.updatedAt}`))})}),tJ=(0,r.memo)(function({group:e,showReasoning:t,showTools:n}){return"user"===e.role?(0,s.jsx)("div",{className:"flex flex-col gap-2",children:e.messages.map((e,t)=>(0,s.jsx)(tV,{message:e},e.id??`u-${t}`))}):"assistant"===e.role?(0,s.jsx)("div",{className:"flex flex-col gap-1 items-start",children:e.messages.map((e,r)=>(0,s.jsx)(tG,{message:e,showReasoning:t,showTools:n},e.id??`a-${r}`))}):"tool"===e.role?(0,s.jsx)("div",{className:"flex flex-col gap-1",children:e.messages.map((e,t)=>(0,s.jsx)(tX,{message:e},e.id??`t-${t}`))}):"system"===e.role?(0,s.jsx)("div",{className:"flex flex-col gap-1",children:e.messages.map((e,t)=>{let n=e.displayText;return n?(0,s.jsx)("div",{className:"text-center text-xs text-muted-foreground/60 italic py-1",children:n},e.id??`s-${t}`):null})}):null}),tV=(0,r.memo)(function({message:e}){let t=e.displayText,[n,a]=(0,r.useState)(null),l=(0,r.useMemo)(()=>{let t=[];for(let n of e.content)if("input_image"===n.type||"image"===n.type){let e,s=n.source;if(s?.type==="base64"&&"string"==typeof s.data){let t=s.data,n=s.media_type||"image/png";e=t.startsWith("data:")?t:`data:${n};base64,${t}`}else e=n.image_url??n.url??("string"==typeof s?.url?s.url:void 0);e&&t.push(e)}return t},[e.content]);if((!t||t.trim().length<1)&&0===l.length)return null;let i=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null;return(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 items-end",children:[n&&(0,s.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 p-4 cursor-pointer",onClick:()=>a(null),children:[(0,s.jsx)("img",{src:n,alt:"Full size",className:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain shadow-2xl"}),(0,s.jsx)("button",{className:"absolute right-4 top-4 flex h-8 w-8 items-center justify-center rounded-full bg-black/50 text-white hover:bg-black/70",onClick:()=>a(null),children:(0,s.jsx)(m.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 pr-4",children:[(0,s.jsx)(tp,{channel:e.channel,sessionKey:e.sessionKey}),i&&(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:i})]}),(0,s.jsxs)("div",{className:"max-w-[85%] space-y-2",children:[l.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap justify-end gap-1.5",children:l.map((e,t)=>(0,s.jsx)("img",{src:e,alt:`Attached image ${t+1}`,className:"max-h-48 max-w-[200px] cursor-pointer rounded-xl border border-white/20 object-cover shadow-sm transition-transform hover:scale-[1.02]",onClick:()=>a(e)},t))}),t&&t.trim().length>0&&(0,s.jsx)("div",{className:"cp-user-bubble rounded-2xl px-4 py-2 text-sm leading-relaxed break-words overflow-hidden",children:t})]})]})}),tG=(0,r.memo)(function({message:e,showReasoning:t,showTools:n}){let r=e.displayText?.trim()||null,a=n?e.toolCards:[],l=a.length>0,i=t?function(e){let t=e.content,n=[];if(Array.isArray(t)){for(let e of t)if("thinking"===e.type&&"string"==typeof e.thinking){let t=e.thinking.trim();t&&n.push(t)}}if(n.length>0)return n.join("\n");let s=tL(e);if(!s)return null;let r=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(e=>(e[1]??"").trim()).filter(Boolean);return r.length>0?r.join("\n"):null}(e.raw):null,o=i?function(e){let t=e.trim();if(!t)return"";let n=t.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>`_${e}_`);return n.length?["_Reasoning:_",...n].join("\n"):""}(i):null,c=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null;return r||l?(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 items-start max-w-[95%] min-w-0",children:[r&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(tp,{channel:e.channel,sessionKey:e.sessionKey}),c&&(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:c})]}),r&&(0,s.jsx)("div",{className:"min-w-0 text-sm leading-relaxed opacity-90",children:(0,s.jsx)(t4,{text:r})}),o&&(0,s.jsx)("div",{className:"min-w-0 text-xs text-muted-foreground",children:(0,s.jsx)(t4,{text:o})}),l&&a.map((e,t)=>(0,s.jsx)(tQ,{card:e},`tc-${t}`))]}):null}),tX=(0,r.memo)(function({message:e}){let t=e.toolCards;return 0===t.length?null:(0,s.jsx)("div",{className:"flex flex-col gap-0.5",children:t.map((e,t)=>(0,s.jsx)(tQ,{card:e},`tr-${t}`))})}),tQ=(0,r.memo)(function({card:e}){let[t,n]=(0,r.useState)(!1),a=(0,r.useId)(),l=(0,ts.I)(),i=t9(e.name),o=i.icon,d=t7(e.text)??e.text??"",u=!!d.trim(),m=t8(e.args);return(0,s.jsxs)("div",{className:"my-0 max-w-full",children:[(0,s.jsxs)("button",{type:"button",onClick:u?()=>n(!t):void 0,className:(0,c.cn)("group flex w-full items-center gap-1 rounded-md px-0 py-px text-left text-[11px] leading-4 transition-colors","text-muted-foreground/60 hover:text-muted-foreground",u&&"hover:bg-muted/30 cursor-pointer",!u&&"cursor-default",t&&"bg-muted/40 text-foreground"),"aria-expanded":u?t:void 0,"aria-controls":u?a:void 0,children:[(0,s.jsx)("span",{className:(0,c.cn)("flex h-3.5 w-3.5 items-center justify-center",u?"text-muted-foreground/50 group-hover:text-muted-foreground":"opacity-0"),"aria-hidden":"true",children:u&&t?(0,s.jsx)(eX.A,{className:"h-3 w-3"}):(0,s.jsx)(k.A,{className:"h-3 w-3"})}),(0,s.jsx)("span",{className:"shrink-0 text-muted-foreground/70 group-hover:text-foreground",children:(0,s.jsx)(o,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("span",{className:"min-w-0 flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"font-medium text-foreground/75 group-hover:text-foreground",children:i.label}),m&&(0,s.jsx)("span",{className:"truncate max-w-[220px] text-[10px] font-mono text-muted-foreground/60 group-hover:text-muted-foreground",children:m})]}),(0,s.jsx)("span",{className:"ml-auto flex items-center gap-1 text-muted-foreground/50",children:"result"===e.kind&&!u&&(0,s.jsx)(eQ.A,{className:"h-3 w-3"})})]}),(0,s.jsx)(tn.N,{initial:!1,children:u&&t&&(0,s.jsx)(tt.P.div,{id:a,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18*!l},className:"overflow-hidden",children:(0,s.jsx)("div",{className:"pt-1 pl-6",children:(0,s.jsx)("pre",{className:"max-h-[200px] overflow-y-auto rounded bg-muted/30 p-2 text-[10px] font-mono text-muted-foreground whitespace-pre-wrap",children:d})})})})]})}),tY=(0,r.memo)(function({message:e,images:t,onRetry:n}){let[a,l]=(0,r.useState)(null),i=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 items-end",children:[a&&(0,s.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 p-4 cursor-pointer",onClick:()=>l(null),children:[(0,s.jsx)("img",{src:a,alt:"Full size",className:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain shadow-2xl"}),(0,s.jsx)("button",{className:"absolute right-4 top-4 flex h-8 w-8 items-center justify-center rounded-full bg-black/50 text-white hover:bg-black/70",onClick:()=>l(null),children:(0,s.jsx)(m.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-1",children:[(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:i}),"sending"===e.status&&(0,s.jsx)(er.A,{className:"h-3 w-3 text-muted-foreground/50"}),("streaming"===e.status||"sent"===e.status)&&(0,s.jsxs)("div",{className:"flex items-center text-blue-400",children:[(0,s.jsx)(eQ.A,{className:"h-3 w-3"}),(0,s.jsx)(eQ.A,{className:"-ml-1.5 h-3 w-3"})]}),"error"===e.status&&(0,s.jsxs)("button",{onClick:()=>n(e),className:"flex items-center gap-1 text-destructive hover:text-destructive/80 transition-colors",title:"Tap to retry",children:[(0,s.jsx)(eB.A,{className:"h-3 w-3"}),(0,s.jsx)("span",{className:"text-[10px] font-medium",children:"Retry"})]})]}),(0,s.jsxs)("div",{className:"max-w-[85%] space-y-2",children:[t&&t.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap justify-end gap-1.5",children:t.map((e,t)=>(0,s.jsx)("img",{src:e,alt:`Attached image ${t+1}`,className:"max-h-48 max-w-[200px] cursor-pointer rounded-xl border border-white/20 object-cover shadow-sm transition-transform hover:scale-[1.02]",onClick:()=>l(e)},t))}),(0,s.jsx)("div",{className:(0,c.cn)("rounded-2xl px-4 py-2.5 text-sm leading-relaxed shadow-sm break-words overflow-hidden","error"===e.status?"bg-red-500 text-white dark:bg-red-600":"cp-user-bubble"),children:(0,s.jsx)("span",{children:e.text})})]})]})});function t0(e){let t=[],n="",s=()=>{n.trim().length>0&&t.push({type:"text",text:n}),n=""};for(let r of e){if("text"===r.type&&"string"==typeof r.text){n&&(n+="\n"),n+=r.text;continue}s(),t.push(r)}return s(),t}function t1(e){return t0(e.parts??[]).filter(e=>"text"===e.type&&"string"==typeof e.text).map(e=>e.text).join("\n").trim()}let t5=(0,r.memo)(function({message:e,_images:t,isLatest:n,isStreaming:a,showThinking:l,onToolApprove:i,onToolDeny:o}){let[c,d]=(0,r.useState)(null),u=(0,r.useMemo)(()=>t0(e.parts??[]),[e.parts]);return"user"===e.role?null:(0,s.jsxs)("div",{className:"flex flex-col gap-1 items-start",children:[c&&(0,s.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 p-4 cursor-pointer",onClick:()=>d(null),children:[(0,s.jsx)("img",{src:c,alt:"Full size",className:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain shadow-2xl"}),(0,s.jsx)("button",{className:"absolute right-4 top-4 flex h-8 w-8 items-center justify-center rounded-full bg-black/50 text-white hover:bg-black/70",onClick:()=>d(null),children:(0,s.jsx)(m.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"max-w-[95%] min-w-0 text-sm leading-relaxed",children:[u.map((e,t)=>{if("text"===e.type)return(0,s.jsx)(t4,{text:e.text??""},t);if("dynamic-tool"===e.type||e.type?.startsWith("tool-")){let n="approval-requested"===e.state;if(!n&&!l)return null;let r=e.toolName??e.type.replace(/^tool-/,""),a=e.approval?.approvalId??e.toolCallId;return(0,s.jsx)(ne,{toolName:r,state:e.state??"",args:e.input,onApprove:n&&i?()=>i(a??""):void 0,onDeny:n&&o?()=>o(a??""):void 0},t)}return null}),a&&n&&(0,s.jsx)("span",{className:"inline-block h-4 w-0.5 animate-pulse bg-foreground/60 ml-0.5 align-text-bottom"})]})]})}),t2={code:({className:e,children:t,...n})=>e||"string"!=typeof t||t.includes("\n")?(0,s.jsx)("pre",{className:"my-2 overflow-x-auto rounded-lg bg-zinc-100 p-3 text-[13px] dark:bg-zinc-900",children:(0,s.jsx)("code",{className:e,...n,children:t})}):(0,s.jsx)("code",{className:"rounded bg-zinc-100 px-1.5 py-0.5 text-[13px] dark:bg-zinc-800",...n,children:t}),pre:({children:e})=>(0,s.jsx)(s.Fragment,{children:e}),p:({children:e})=>(0,s.jsx)("p",{className:"my-1",children:e}),a:({href:e,children:t})=>(0,s.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 underline dark:text-blue-400 break-all",children:t}),ul:({children:e})=>(0,s.jsx)("ul",{className:"my-1 list-disc pl-4",children:e}),ol:({children:e})=>(0,s.jsx)("ol",{className:"my-1 list-decimal pl-4",children:e}),li:({children:e})=>(0,s.jsx)("li",{className:"my-0",children:e}),blockquote:({children:e})=>(0,s.jsx)("blockquote",{className:"my-2 border-l-2 border-zinc-300 pl-3 italic text-muted-foreground dark:border-zinc-600",children:e}),table:({children:e})=>(0,s.jsx)("div",{className:"my-2 overflow-x-auto",children:(0,s.jsx)("table",{className:"min-w-full border-collapse text-sm",children:e})}),th:({children:e})=>(0,s.jsx)("th",{className:"border border-zinc-300 bg-zinc-100 px-2 py-1 text-left font-medium dark:border-zinc-600 dark:bg-zinc-800",children:e}),td:({children:e})=>(0,s.jsx)("td",{className:"border border-zinc-300 px-2 py-1 dark:border-zinc-600",children:e}),h1:({children:e})=>(0,s.jsx)("h1",{className:"my-2 text-base font-bold",children:e}),h2:({children:e})=>(0,s.jsx)("h2",{className:"my-1.5 text-sm font-bold",children:e}),h3:({children:e})=>(0,s.jsx)("h3",{className:"my-1 text-sm font-semibold",children:e}),img:({src:e,alt:t})=>(0,s.jsx)("img",{src:e,alt:t??"",className:"my-2 max-w-full rounded-lg"})},t4=(0,r.memo)(function({text:e}){return(0,s.jsx)("div",{className:"chat-message-content min-w-0 max-w-full overflow-hidden text-sm leading-relaxed [overflow-wrap:break-word]",children:(0,s.jsx)(e7.oz,{remarkPlugins:[te.A],components:t2,children:e})})}),t3=(0,r.memo)(function({entry:e}){let[t,n]=(0,r.useState)(!1),a=(0,r.useId)(),l=(0,ts.I)(),i=t9(e.name),o=i.icon,d=t8(e.args),u=function(e){if(null==e)return null;if("string"==typeof e)return e.trim()?e:null;try{return JSON.stringify(e,null,2)}catch{return String(e)}}(e.args),m=e.output?.trim()??"",h=t7(m)??m,x=!!m,p=!!(u||x),g="start"===e.phase||"update"===e.phase,f="result"===e.phase?"Completed":"error"===e.phase?"Error":"Running",b="result"===e.phase?eQ.A:"error"===e.phase?eB.A:eq.A;return(0,s.jsxs)("div",{className:(0,c.cn)("rounded-lg border border-transparent bg-transparent","transition-colors","hover:border-border/40 hover:bg-muted/20",t&&"border-border/50 bg-muted/30",g&&"bg-muted/30"),children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{p&&n(e=>!e)},className:(0,c.cn)("group flex w-full items-center justify-between gap-2 px-0 py-px text-left","text-[11px] leading-4 transition-colors","text-muted-foreground/60 hover:text-muted-foreground",p?"cursor-pointer":"cursor-default"),"aria-expanded":p?t:void 0,"aria-disabled":!p,"aria-controls":p?a:void 0,children:[(0,s.jsx)("span",{className:(0,c.cn)("flex h-3.5 w-3.5 items-center justify-center",p?"text-muted-foreground/50 group-hover:text-muted-foreground":"opacity-0"),"aria-hidden":"true",children:p&&t?(0,s.jsx)(eX.A,{className:"h-3 w-3"}):(0,s.jsx)(k.A,{className:"h-3 w-3"})}),(0,s.jsx)("span",{className:"shrink-0 text-muted-foreground/70 group-hover:text-foreground","aria-hidden":"true",children:(0,s.jsx)(o,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,s.jsx)("span",{className:"text-[11px] font-medium text-foreground/75 group-hover:text-foreground",children:i.label}),d&&(0,s.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground/60 truncate group-hover:text-muted-foreground",children:d})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[(0,s.jsx)(b,{className:(0,c.cn)("h-3.5 w-3.5","Running"===f&&"animate-spin motion-reduce:animate-none","Error"===f&&"text-destructive")}),(0,s.jsx)("span",{className:(0,c.cn)("Error"===f&&"text-destructive",g&&"animate-pulse motion-reduce:animate-none"),children:f})]})]}),(0,s.jsx)(tn.N,{initial:!1,children:t&&p&&(0,s.jsx)(tt.P.div,{id:a,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18*!l},className:"overflow-hidden",children:(0,s.jsxs)("div",{className:"px-2 pb-2 space-y-2",children:[u&&(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70",children:"Args"}),(0,s.jsx)("pre",{className:"max-h-60 overflow-auto rounded-md bg-background/60 px-2 py-1.5 text-[10px] font-mono whitespace-pre-wrap text-foreground",children:u})]}),x&&(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70",children:"Output"}),(0,s.jsx)("pre",{className:"max-h-60 overflow-auto rounded-md bg-background/60 px-2 py-1.5 text-[10px] font-mono whitespace-pre-wrap text-foreground",children:h})]})]})})})]})}),t6={Read:{icon:C.A,label:"Read file"},Edit:{icon:eY.A,label:"Edit file"},Write:{icon:e0.A,label:"Write file"},exec:{icon:eJ.A,label:"Run command"},web_search:{icon:l.A,label:"Web search"},web_fetch:{icon:e1.A,label:"Fetch page"},browser:{icon:e1.A,label:"Browser"},message:{icon:ed.A,label:"Send message"},image:{icon:e5.A,label:"Analyze image"},tts:{icon:e2.A,label:"Text to speech"},nodes:{icon:e4.A,label:"Node control"},canvas:{icon:e3.A,label:"Canvas"},process:{icon:e6.A,label:"Process"}};function t9(e){let t=e.trim(),n=t.replace(/[\s-]+/g,"_"),s=n.toLowerCase(),r=s.length>0?s[0].toUpperCase()+s.slice(1):"";for(let e of[t,n,s,t.toLowerCase(),r])if(e&&t6[e])return t6[e];return{icon:e9.A,label:t||"Tool"}}function t8(e){if(!e)return null;if("string"==typeof e){let t=e.trim();return t?t.length>60?t.slice(0,57)+"…":t:null}if("object"!=typeof e)return null;if(e.query)return`"${String(e.query)}"`;if(e.path)return String(e.path).replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~");if(e.file_path)return String(e.file_path).replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~");if(e.command){let t=String(e.command);return t.length>60?t.slice(0,57)+"…":t}return e.url?String(e.url):e.action?String(e.action):null}function t7(e){return e?tK(e)??e:null}let ne=(0,r.memo)(function({toolName:e,state:t,args:n,onApprove:r,onDeny:a}){let l=t9(e),i=l.icon,o=(()=>{if(!n||"object"!=typeof n)return null;if(n.query)return`"${String(n.query)}"`;if(n.path)return String(n.path).split("/").pop();if(n.file_path)return String(n.file_path).split("/").pop();if(n.command){let e=String(n.command);return e.length>50?e.slice(0,50)+"…":e}return n.url?String(n.url):null})();return"approval-requested"!==t?(0,s.jsxs)("div",{className:"my-1.5 flex items-center gap-2 rounded-md px-2 py-1 text-[11px] leading-4 text-muted-foreground/60 transition-colors hover:text-muted-foreground hover:bg-muted/30",children:["call"===t||"input-streaming"===t||"input-available"===t?(0,s.jsx)(eq.A,{className:"h-3 w-3 animate-spin motion-reduce:animate-none shrink-0"}):"output-available"===t||"result"===t?(0,s.jsx)(eQ.A,{className:"h-3 w-3 text-green-600 shrink-0"}):"output-error"===t?(0,s.jsx)(e8.A,{className:"h-3 w-3 text-destructive shrink-0"}):(0,s.jsx)("span",{className:"shrink-0 text-muted-foreground/70",children:(0,s.jsx)(i,{className:"h-3.5 w-3.5"})}),(0,s.jsx)("span",{className:"font-medium text-foreground/75",children:l.label}),o&&(0,s.jsx)("span",{className:"truncate max-w-[200px] text-[10px] font-mono text-muted-foreground/60",children:o})]}):(0,s.jsxs)("div",{className:"my-1.5 rounded-lg border border-amber-500/40 bg-amber-50/50 dark:bg-amber-950/20 p-2.5 text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,s.jsx)(eG.A,{className:"h-3.5 w-3.5 text-amber-600 dark:text-amber-400"}),(0,s.jsx)("span",{className:"font-medium font-mono",children:e}),(0,s.jsx)("span",{className:"text-muted-foreground/60",children:"Requires approval"})]}),null!=n&&"object"==typeof n&&Object.keys(n).length>0?(0,s.jsx)("pre",{className:"mt-1.5 overflow-x-auto rounded bg-background dark:bg-muted/50 p-1.5 text-[11px] font-mono text-muted-foreground",children:JSON.stringify(n,null,2)}):null,r&&a&&(0,s.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,s.jsxs)("button",{onClick:r,className:"inline-flex items-center gap-1 rounded-md bg-green-600 px-2.5 py-1 text-[11px] font-medium text-white transition-colors hover:bg-green-700",children:[(0,s.jsx)(eQ.A,{className:"h-3 w-3"}),"Approve"]}),(0,s.jsxs)("button",{onClick:a,className:"inline-flex items-center gap-1 rounded-md bg-red-600 px-2.5 py-1 text-[11px] font-medium text-white transition-colors hover:bg-red-700",children:[(0,s.jsx)(e8.A,{className:"h-3 w-3"}),"Deny"]})]})]})});var nt=n(37618),nn=n(92564),ns=n(93219);let nr=[{id:"pages",label:"Pages",icon:C.A},{id:"editor",label:"Editor",icon:nt.A},{id:"chat",label:"Chat",icon:nn.A},{id:"activity",label:"Activity",icon:ns.A}],na=(0,r.memo)(function({activeTab:e,onTabChange:t,hasUnreadChat:n=!1,onNewPage:r}){return(0,s.jsxs)(s.Fragment,{children:["pages"===e&&r&&(0,s.jsx)("button",{onClick:r,className:(0,c.cn)("fixed bottom-20 right-4 z-50 flex h-14 w-14 items-center justify-center","rounded-full bg-accent-blue text-white shadow-lg","active:scale-95 transition-transform","safe-area-bottom-fab"),"aria-label":"New Document",children:(0,s.jsx)(i.A,{className:"h-6 w-6"})}),(0,s.jsx)("nav",{className:"fixed bottom-0 left-0 right-0 z-50 flex h-14 items-stretch border-t border-border bg-background/95 backdrop-blur-sm safe-area-bottom",children:nr.map(({id:r,label:a,icon:l})=>{let i=e===r;return(0,s.jsxs)("button",{onClick:()=>t(r),className:(0,c.cn)("relative flex flex-1 flex-col items-center justify-center gap-0.5 transition-colors min-h-[44px]",i?"text-accent-blue":"text-muted-foreground active:text-foreground"),children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(l,{className:"h-5 w-5"}),"chat"===r&&n&&(0,s.jsxs)("span",{className:"absolute -right-1.5 -top-1 flex h-2.5 w-2.5",children:[(0,s.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-blue opacity-75"}),(0,s.jsx)("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-accent-blue"})]})]}),(0,s.jsx)("span",{className:"text-[10px] font-medium",children:a}),i&&(0,s.jsx)("span",{className:"absolute top-0 left-1/4 right-1/4 h-0.5 rounded-full bg-accent-blue"})]},r)})})]})});function nl({onNavigate:e}){let t=(0,j.usePathname)(),n=(0,j.useRouter)(),{spaces:a,expandedSpaces:i,expandedFolders:o,toggleSpace:d,toggleFolder:u,pagesBySpace:m,spacesStatus:h,pagesStatusBySpace:x,recentPages:p,recentStatus:g,loadSpaces:f,loadRecentPages:b}=(0,M.M)(),[v,w]=(0,r.useState)("");(0,r.useEffect)(()=>{f(),b()},[f,b]);let y=(0,r.useCallback)(t=>{n.push((0,W.C)(t)),e?.()},[n,e]),N=(0,K.z)(e=>e.agentName);return(0,s.jsxs)("div",{className:"flex h-full flex-col bg-background",children:[(0,s.jsx)("div",{className:"flex h-14 shrink-0 items-center justify-between border-b px-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-primary text-[11px] font-bold text-primary-foreground",children:"C"}),(0,s.jsx)("span",{className:"text-sm font-semibold",children:N??"ClawPad"})]})}),(0,s.jsx)("div",{className:"shrink-0 px-4 py-3",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(l.A,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,s.jsx)("input",{type:"text",placeholder:"Search pages…",value:v,onChange:e=>w(e.target.value),className:(0,c.cn)("w-full rounded-lg border bg-secondary/50 py-2.5 pl-9 pr-3 text-sm","placeholder:text-muted-foreground","focus:outline-none focus:ring-2 focus:ring-ring","min-h-[44px]")})]})}),(0,s.jsxs)($,{className:"flex-1 px-4",children:[!v&&p.length>0&&(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)(ni,{children:"Recent"}),(0,s.jsx)("div",{className:"space-y-0.5",children:p.slice(0,5).map(e=>(0,s.jsx)(nc,{page:e,isActive:t===(0,W.C)(e.path),onNavigate:()=>y(e.path),showTime:!0},e.path))})]}),(0,s.jsx)(R.w,{className:"my-2"}),(0,s.jsxs)("div",{className:"pb-4",children:[(0,s.jsx)(ni,{children:"Spaces"}),"loading"===h&&0===a.length?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(_.E,{className:"h-12 w-full rounded-lg"}),(0,s.jsx)(_.E,{className:"h-12 w-full rounded-lg"}),(0,s.jsx)(_.E,{className:"h-12 w-full rounded-lg"})]}):0===a.length?(0,s.jsx)("p",{className:"py-4 text-center text-sm text-muted-foreground",children:"No spaces yet"}):(0,s.jsx)("div",{className:"space-y-1",children:a.map(e=>(0,s.jsx)(no,{space:e,isExpanded:i.has(e.path),pages:m.get(e.path)??[],isLoadingPages:(x.get(e.path)??"idle")==="loading"&&0===(m.get(e.path)??[]).length,pathname:t,searchQuery:v,onToggle:()=>d(e.path),expandedFolders:o,onToggleFolder:u,onNavigate:y},e.path))}),"loading"===g&&0===p.length&&!v&&(0,s.jsxs)("div",{className:"mb-4 space-y-2",children:[(0,s.jsx)(ni,{children:"Recent"}),(0,s.jsx)(_.E,{className:"h-10 w-full rounded-lg"}),(0,s.jsx)(_.E,{className:"h-10 w-4/5 rounded-lg"})]})]})]})]})}function ni({children:e}){return(0,s.jsx)("h3",{className:"mb-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:e})}let no=(0,r.memo)(function({space:e,isExpanded:t,pages:n,isLoadingPages:r,pathname:a,searchQuery:l,onToggle:i,expandedFolders:o,onToggleFolder:d,onNavigate:u}){let m=F(l?n.filter(e=>e.title.toLowerCase().includes(l.toLowerCase())):n,e.path);if(l&&0===m.length)return null;let h=t=>t.map(t=>{if("page"===t.type)return(0,s.jsx)(nc,{page:t.page,isActive:a===(0,W.C)(t.page.path),onNavigate:()=>u(t.page.path)},t.page.path);let n=`${e.path}/${t.path}`,r=o.has(n);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{onClick:()=>d(n),className:(0,c.cn)("flex w-full items-center gap-2 rounded-lg px-3 py-2 text-[13px] transition-colors","text-muted-foreground hover:bg-secondary active:bg-secondary","min-h-[44px]"),children:[(0,s.jsx)(k.A,{className:(0,c.cn)("h-3.5 w-3.5 shrink-0 transition-transform duration-200",r&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 text-xs",children:"\uD83D\uDCC2"}),(0,s.jsx)("span",{className:"flex-1 truncate text-left",children:t.name})]}),r&&(0,s.jsx)("div",{className:"ml-3 border-l border-border/50 pl-3 py-0.5",children:h(t.children)})]},n)});return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{onClick:i,className:(0,c.cn)("flex w-full items-center gap-2 rounded-lg px-3 py-3 text-sm transition-colors","hover:bg-secondary active:bg-secondary","min-h-[48px]",t&&"font-medium"),children:[(0,s.jsx)(k.A,{className:(0,c.cn)("h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200",t&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 text-base",children:e.icon??"\uD83D\uDCC1"}),(0,s.jsx)("span",{className:"flex-1 truncate text-left",children:e.name}),(0,s.jsx)(T.E,{variant:"secondary",className:"h-5 shrink-0 px-1.5 text-[11px] font-normal",children:e.pageCount})]}),t&&(0,s.jsx)("div",{className:"ml-4 border-l border-border/50 pl-3 py-0.5",children:r?(0,s.jsxs)("div",{className:"space-y-1 py-1",children:[(0,s.jsx)(_.E,{className:"h-10 w-full rounded-lg"}),(0,s.jsx)(_.E,{className:"h-10 w-3/4 rounded-lg"})]}):0===m.length?(0,s.jsx)("p",{className:"py-3 px-2 text-xs text-muted-foreground",children:"No pages yet. Create your first page."}):h(m)})]})}),nc=(0,r.memo)(function({page:e,isActive:t,onNavigate:n,showTime:r}){return(0,s.jsxs)("button",{onClick:n,className:(0,c.cn)("flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-sm transition-colors","text-muted-foreground hover:bg-secondary active:bg-secondary","min-h-[44px]",t&&"bg-accent-light text-accent-blue font-medium"),children:[(0,s.jsx)(er.A,{className:"h-3.5 w-3.5 shrink-0 opacity-50"}),e.icon?(0,s.jsx)("span",{className:"shrink-0 text-sm",children:e.icon}):(0,s.jsx)(C.A,{className:"h-4 w-4 shrink-0"}),(0,s.jsx)("span",{className:"flex-1 truncate text-left",children:e.title}),r&&(0,s.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground/60",children:(0,P.f)(e.modified)})]})});var nd=n(3926),nu=n(34269),nm=n(49619),nh=n(90718);let nx={"file-changed":{icon:nd.A,className:"text-blue-500"},"file-added":{icon:es.A,className:"text-green-500"},"file-removed":{icon:nu.A,className:"text-red-400"},"chat-message":{icon:ed.A,className:"text-violet-500"},"tool-used":{icon:e9.A,className:"text-amber-500"},"sub-agent":{icon:nm.A,className:"text-cyan-500"}};function np(){let e=(0,K.z)(e=>e.agentStatus);return"thinking"!==e&&"active"!==e?null:(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-violet-500/10 px-2 py-1.5 mb-1",children:[(0,s.jsx)(nh.A,{className:(0,c.cn)("h-3.5 w-3.5 text-violet-500","thinking"===e&&"animate-pulse")}),(0,s.jsx)("span",{className:"text-[12px] text-violet-500 font-medium",children:"thinking"===e?"Agent thinking…":"Agent working…"}),(0,s.jsxs)("span",{className:"ml-auto flex gap-0.5",children:[(0,s.jsx)("span",{className:"h-1 w-1 rounded-full bg-violet-400 animate-bounce [animation-delay:0ms]"}),(0,s.jsx)("span",{className:"h-1 w-1 rounded-full bg-violet-400 animate-bounce [animation-delay:150ms]"}),(0,s.jsx)("span",{className:"h-1 w-1 rounded-full bg-violet-400 animate-bounce [animation-delay:300ms]"})]})]})}function ng({type:e,description:t,timestamp:n}){let r,a=nx[e]??nx["file-changed"],l=a.icon;return(0,s.jsxs)("div",{className:"flex items-start gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-sidebar-accent group",children:[(0,s.jsx)(l,{className:(0,c.cn)("mt-0.5 h-3.5 w-3.5 shrink-0",a.className)}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"truncate text-[12px] leading-snug text-foreground/80",children:t}),(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground/60",children:(r=Math.floor((Date.now()-n)/1e3))<5?"just now":r<60?`${r}s ago`:r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:`${Math.floor(r/86400)}d ago`})]})]})}function nf(){let e=(0,tr.e)(e=>e.items),t=(0,tr.e)(e=>e.clear);return(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-2 py-1",children:[(0,s.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:"Activity"}),e.length>0&&(0,s.jsx)("button",{onClick:t,className:"text-[10px] text-muted-foreground/60 hover:text-muted-foreground transition-colors",children:"Clear"})]}),(0,s.jsx)(np,{}),0===e.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,s.jsx)(ns.A,{className:"mb-3 h-8 w-8 text-muted-foreground/30"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No recent activity"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground/60",children:"File changes and agent events will appear here"})]}):(0,s.jsx)($,{className:"max-h-[400px]",children:(0,s.jsx)("div",{className:"space-y-0.5",children:e.map(e=>(0,s.jsx)(ng,{type:e.type,description:e.description,timestamp:e.timestamp},e.id))})})]})}function nb(){return(0,s.jsxs)("div",{className:"flex h-full flex-col bg-background",children:[(0,s.jsx)("div",{className:"flex h-14 shrink-0 items-center border-b px-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ns.A,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Activity"})]})}),(0,s.jsx)($,{className:"flex-1",children:(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(nf,{})})})]})}var nv=n(42317);let nw={navigation:"Navigation",panels:"Panels",editing:"Editing",ai:"AI",general:"General"},nj=["navigation","panels","editing","ai","general"];function ny({shortcuts:e}){let[t,n]=(0,r.useState)(!1);(0,r.useEffect)(()=>{function e(){n(!0)}return window.addEventListener("clawpad:shortcuts-dialog",e),()=>window.removeEventListener("clawpad:shortcuts-dialog",e)},[]);let a=(0,r.useCallback)(e=>{n(e)},[]),l=nj.map(t=>({category:t,label:nw[t]??t,items:e.filter(e=>e.category===t)})).filter(e=>e.items.length>0);return(0,s.jsx)(eg,{open:t,onOpenChange:a,children:(0,s.jsxs)(ev,{className:"sm:max-w-[480px]",children:[(0,s.jsxs)(ew,{children:[(0,s.jsxs)(ey,{className:"flex items-center gap-2",children:[(0,s.jsx)(ex.A,{className:"h-4 w-4 text-muted-foreground"}),"Keyboard Shortcuts"]}),(0,s.jsx)(eN,{children:"Quick actions to navigate your workspace"})]}),(0,s.jsxs)("div",{className:"grid gap-5 py-2",children:[l.map(e=>(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"mb-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:e.label}),(0,s.jsx)("div",{className:"space-y-1",children:e.items.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-muted/50",children:[(0,s.jsx)("span",{className:"text-foreground/80",children:e.label}),(0,s.jsx)(nk,{keys:e.keys})]},e.id))})]},e.category)),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"mb-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"Other"}),(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-muted/50",children:[(0,s.jsx)("span",{className:"text-foreground/80",children:"Close dialog / panel"}),(0,s.jsx)(nk,{keys:"Esc"})]})]})]})]})})}let nN={"⌘":"⌘","⇧":"⇧","⌥":"⌥","⌃":"⌃",Cmd:"⌘",Shift:"⇧",Alt:"⌥",Ctrl:"⌃",Esc:"Esc",Enter:"↵",Tab:"⇥",Backspace:"⌫",Delete:"⌦","\\":"\\"};function nk({keys:e,className:t}){let n=function(e){let t=new Set(["⌘","⇧","⌥","⌃"]),n=[],s=0;for(;s<e.length;){let r=e[s];if(t.has(r))n.push(r),s++;else if("+"===r)s++;else{n.push(e.slice(s));break}}return 0===n.length&&n.push(e),n}(e);return(0,s.jsx)("div",{className:`flex items-center gap-0.5 ${t??""}`,children:n.map((e,t)=>(0,s.jsx)("kbd",{className:"inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-muted/60 px-1 text-[11px] font-medium text-muted-foreground",children:nN[e]??e},t))})}function nC(){var e;let t,n,a=(0,M.M)(e=>e.toggleSidebar),l=(0,M.M)(e=>e.toggleChatPanel),{resolvedTheme:i,setTheme:o}=(0,L.D)(),c=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette"))},[]),d=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},[]),u=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:shortcuts-dialog"))},[]),m=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:save"))},[]),h=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:save"))},[]),x=(0,r.useCallback)(()=>{o("dark"===i?"light":"dark")},[i,o]),p=(0,r.useCallback)(()=>{let e=document.querySelector(".clawpad-editor [contenteditable]")??document.querySelector(".clawpad-editor .bn-editor")??document.querySelector(".clawpad-editor");e&&e.focus()},[]),g=(0,r.useMemo)(()=>{var e;return[{id:"search",label:"Search",keys:"⌘K",category:"navigation",match:e=>(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"k"===e.key,action:(e={openSearch:c,newPage:d,toggleChat:l,toggleSidebar:a,save:m,saveAll:h,openShortcuts:u,toggleDarkMode:x,focusEditor:p}).openSearch},{id:"quick-switcher",label:"Quick Document Switcher",keys:"⌘P",category:"navigation",match:e=>(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"p"===e.key,action:e.openSearch},{id:"new-page",label:"New Document",keys:"⌘N",category:"navigation",match:e=>(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"n"===e.key,action:e.newPage},{id:"toggle-sidebar",label:"Toggle Sidebar",keys:"⌘\\",category:"panels",match:e=>(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"\\"===e.key,action:e.toggleSidebar},{id:"toggle-chat",label:"Toggle Chat",keys:"⌘⇧L",category:"panels",match:e=>(e.metaKey||e.ctrlKey)&&e.shiftKey&&"l"===e.key.toLowerCase(),action:e.toggleChat},{id:"focus-editor",label:"Focus Editor",keys:"⌘⇧E",category:"panels",match:e=>(e.metaKey||e.ctrlKey)&&e.shiftKey&&"e"===e.key.toLowerCase(),action:e.focusEditor},{id:"save",label:"Save",keys:"⌘S",category:"editing",match:e=>(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"s"===e.key,action:e.save},{id:"save-all",label:"Save All",keys:"⌘⇧S",category:"editing",match:e=>(e.metaKey||e.ctrlKey)&&e.shiftKey&&"s"===e.key.toLowerCase(),action:e.saveAll},...e.aiOnSelection?[{id:"ai-selection",label:"AI on Selection",keys:"⌘J",category:"ai",match:e=>(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"j"===e.key,action:e.aiOnSelection}]:[{id:"ai-selection",label:"AI on Selection",keys:"⌘J",category:"ai",match:e=>(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"j"===e.key,action:()=>{}}],{id:"toggle-dark-mode",label:"Toggle Dark Mode",keys:"⌘⇧D",category:"general",match:e=>(e.metaKey||e.ctrlKey)&&e.shiftKey&&"d"===e.key.toLowerCase(),action:e.toggleDarkMode},{id:"shortcuts-help",label:"Keyboard Shortcuts",keys:"⌘/",category:"general",match:e=>(e.metaKey||e.ctrlKey)&&"/"===e.key,action:e.openShortcuts}]},[c,d,l,a,m,h,u,x,p]);return e=(0,r.useMemo)(()=>g.filter(e=>["toggle-sidebar","shortcuts-help","toggle-dark-mode","focus-editor","quick-switcher","save-all"].includes(e.id)),[g]),t=(0,r.useRef)(e),(0,r.useEffect)(()=>{t.current=e},[e]),n=(0,r.useCallback)(e=>{let n=e.target,s=!!n?.closest("input, textarea, select, [contenteditable='true']");for(let n of t.current)if(n.match(e)&&(!s||e.metaKey||e.ctrlKey)){e.preventDefault(),n.action();return}},[]),(0,r.useEffect)(()=>(window.addEventListener("keydown",n,{capture:!0}),()=>window.removeEventListener("keydown",n,{capture:!0})),[n]),(0,s.jsx)(ny,{shortcuts:g})}function nS(){return(0,s.jsxs)("div",{className:"flex h-full w-full flex-col p-4 gap-4",children:[(0,s.jsx)(_.E,{className:"h-8 w-32"}),(0,s.jsxs)("div",{className:"flex-1 space-y-3",children:[(0,s.jsx)(_.E,{className:"h-16 w-3/4 ml-auto"}),(0,s.jsx)(_.E,{className:"h-24 w-4/5"}),(0,s.jsx)(_.E,{className:"h-16 w-2/3 ml-auto"})]}),(0,s.jsx)(_.E,{className:"h-12 w-full"})]})}function nA({children:e}){let{isMobile:t,isTablet:n}=Y(),[a,l]=(0,r.useState)("editor"),{chatPanelOpen:i,setChatPanelOpen:o,setSidebarOpen:c,hydrateAppearance:d}=(0,M.M)(),u=(0,r.useRef)(new Map);(0,r.useEffect)(()=>{d()},[d]);let m=(0,r.useCallback)(e=>{let t=e.currentTarget;t.classList.add("is-scrolling");let n=u.current,s=n.get(t);s&&window.clearTimeout(s);let r=window.setTimeout(()=>{t.classList.remove("is-scrolling"),n.delete(t)},900);n.set(t,r)},[]);(0,r.useEffect)(()=>{let e=u.current;return()=>{e.forEach(e=>window.clearTimeout(e)),e.clear()}},[]);let h=(0,r.useCallback)(e=>{l(e),c(!1),"chat"===e?o(!0):o(!1)},[c,o]),p=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},[]);return t?(0,s.jsxs)("div",{className:"flex h-[100dvh] flex-col overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex-1 overflow-hidden",children:["pages"===a&&(0,s.jsx)("div",{className:"h-full pb-14",children:(0,s.jsx)(nl,{onNavigate:()=>l("editor")})}),"editor"===a&&(0,s.jsx)("main",{className:"workspace-scroll-area h-full overflow-y-auto pb-14",onScroll:m,children:(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)(nv.L,{}),children:e})}),"chat"===a&&(0,s.jsx)("div",{className:"h-full pb-14",children:(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)(nS,{}),children:(0,s.jsx)(tO,{variant:"fullscreen"})})}),"activity"===a&&(0,s.jsx)("div",{className:"h-full pb-14",children:(0,s.jsx)(nb,{})})]}),(0,s.jsx)(na,{activeTab:a,onTabChange:h,onNewPage:p}),(0,s.jsx)(e_,{}),(0,s.jsx)(eK,{}),(0,s.jsx)(nC,{})]}):n?(0,s.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,s.jsx)(et,{}),(0,s.jsx)("main",{className:"workspace-scroll-area relative z-0 flex-1 overflow-y-auto",onScroll:m,children:(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)(nv.L,{}),children:e})}),(0,s.jsx)(x,{open:i,onOpenChange:o,children:(0,s.jsxs)(f,{side:"right",className:"w-[400px] p-0",showCloseButton:!1,children:[(0,s.jsx)(ee,{children:(0,s.jsx)(b,{children:"Chat"})}),(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)(nS,{}),children:(0,s.jsx)(tO,{variant:"sheet"})})]})}),(0,s.jsx)(e_,{}),(0,s.jsx)(eK,{}),(0,s.jsx)(nC,{})]}):(0,s.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,s.jsx)(et,{}),(0,s.jsx)("main",{className:"workspace-scroll-area relative z-0 flex-1 overflow-y-auto",onScroll:m,children:(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)(nv.L,{}),children:e})}),(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)(nS,{}),children:(0,s.jsx)(tO,{})}),(0,s.jsx)(e_,{}),(0,s.jsx)(eK,{}),(0,s.jsx)(nC,{})]})}},31328:(e,t,n)=>{"use strict";n.d(t,{z:()=>a});var s=n(1934);let r="http://127.0.0.1:18789",a=(0,s.v)((e,t)=>({connected:!1,connecting:!1,wsStatus:"disconnected",wsError:void 0,reason:null,url:r,token:void 0,agentName:void 0,source:void 0,sessions:[],agentStatus:"idle",error:void 0,detect:async()=>{try{let t=await fetch("/api/gateway/detect");if(!t.ok)throw Error("Failed to detect gateway");let n=await t.json();n&&e({url:n.url||r,token:n.token||void 0,agentName:n.agentName||void 0,source:n.source||void 0})}catch(t){e({reason:"server_unreachable",error:`Detection failed: ${String(t)}`})}},connect:async()=>{let{url:n}=t();e({connecting:!0,error:void 0,reason:null});try{let s=await fetch("/api/gateway/status");if(!s.ok)throw Error("Failed to check gateway status");let r=await s.json();r.connected?(e({connected:!0,connecting:!1,agentName:r.agentName||t().agentName,reason:null,error:void 0}),t().loadSessions()):e({connected:!1,connecting:!1,reason:r.reason??"gateway_unreachable",error:r.error||`Cannot connect to ${n}`})}catch(t){e({connected:!1,connecting:!1,reason:"server_unreachable",error:`ClawPad server unreachable: ${String(t)}`})}},disconnect:()=>{e({connected:!1,connecting:!1,wsStatus:"disconnected",reason:null,sessions:[],agentStatus:"idle",error:void 0})},loadSessions:async()=>{try{let t=await fetch("/api/gateway/sessions");if(!t.ok)return;let n=(await t.json()).sessions??[],s=n.some(e=>"active"===e.status),r=n.some(e=>"thinking"===e.status);e({sessions:n,agentStatus:s?"active":r?"thinking":"idle"})}catch{}},setUrl:t=>e({url:t}),setToken:t=>e({token:t||void 0}),setWSStatus:(n,s)=>{e({wsStatus:n,wsError:"connected"===n?void 0:s?.error}),"connected"===n?e({connected:!0,connecting:!1,reason:null,error:void 0}):"connecting"===n||"reconnecting"===n?e({connected:!1,connecting:!0,reason:s?.reason??"gateway_unreachable"}):e({connected:!1,connecting:!1,reason:s?.reason??t().reason??"gateway_unreachable"})},setAgentStatus:t=>e({agentStatus:t})}))},35018:(e,t,n)=>{Promise.resolve().then(n.bind(n,24733))},42317:(e,t,n)=>{"use strict";n.d(t,{L:()=>a});var s=n(95155),r=n(86846);function a(){return(0,s.jsxs)("div",{className:"mx-auto w-full max-w-[720px] px-6",children:[(0,s.jsxs)("div",{className:"pt-20 pb-4",children:[(0,s.jsx)(r.E,{className:"h-10 w-2/3 mb-3"}),(0,s.jsx)(r.E,{className:"h-4 w-1/3"})]}),(0,s.jsxs)("div",{className:"space-y-3 pt-6",children:[(0,s.jsx)(r.E,{className:"h-4 w-full"}),(0,s.jsx)(r.E,{className:"h-4 w-[92%]"}),(0,s.jsx)(r.E,{className:"h-4 w-[78%]"}),(0,s.jsx)("div",{className:"h-3"}),(0,s.jsx)(r.E,{className:"h-4 w-full"}),(0,s.jsx)(r.E,{className:"h-4 w-[85%]"}),(0,s.jsx)(r.E,{className:"h-4 w-[65%]"}),(0,s.jsx)("div",{className:"h-3"}),(0,s.jsx)(r.E,{className:"h-4 w-[90%]"}),(0,s.jsx)(r.E,{className:"h-4 w-[70%]"})]})]})}},45160:(e,t,n)=>{"use strict";n.d(t,{E:()=>o});var s=n(95155);n(12115);var r=n(18460),a=n(42442),l=n(52799);let i=(0,r.F)("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function o({className:e,variant:t="default",asChild:n=!1,...r}){let o=n?a.bL:"span";return(0,s.jsx)(o,{"data-slot":"badge","data-variant":t,className:(0,l.cn)(i({variant:t}),e),...r})}},46794:(e,t,n)=>{"use strict";n.d(t,{b:()=>s});let s=(0,n(1934).v)(e=>({lastEvent:void 0,events:[],updatedAt:void 0,addEvent:t=>e(e=>{let n=function(e,t){if(t)return t;let n=(e??"").toLowerCase();if(n){if("failed"===n)return"error";if("sent"===n)return"alert";if(n.startsWith("ok"))return"ok"}}(t.status,t.indicatorType),s={...t,indicatorType:n,actionable:"alert"===n||"error"===n},r=[s,...e.events];return r.length>20&&(r.length=20),{lastEvent:s,events:r,updatedAt:Date.now()}}),clear:()=>e({lastEvent:void 0,events:[],updatedAt:void 0})}))},53536:(e,t,n)=>{"use strict";function s(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/1e3),s=Math.floor(n/60),r=Math.floor(s/60),a=Math.floor(r/24);return n<60?"just now":s<60?`${s}m`:r<24?`${r}h`:1===a?"Yesterday":a<7?`${a}d`:a<30?`${Math.floor(a/7)}w`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}n.d(t,{f:()=>s})},60529:(e,t,n)=>{"use strict";n.d(t,{p:()=>a});var s=n(95155);n(12115);var r=n(52799);function a({className:e,type:t,...n}){return(0,s.jsx)("input",{type:t,"data-slot":"input",className:(0,r.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}},70872:(e,t,n)=>{"use strict";n.d(t,{Bc:()=>l,ZI:()=>c,k$:()=>o,m_:()=>i});var s=n(95155);n(12115);var r=n(28935),a=n(52799);function l({delayDuration:e=0,...t}){return(0,s.jsx)(r.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function i({...e}){return(0,s.jsx)(l,{children:(0,s.jsx)(r.Root,{"data-slot":"tooltip",...e})})}function o({...e}){return(0,s.jsx)(r.Trigger,{"data-slot":"tooltip-trigger",...e})}function c({className:e,sideOffset:t=0,children:n,...l}){return(0,s.jsx)(r.Portal,{children:(0,s.jsxs)(r.Content,{"data-slot":"tooltip-content",sideOffset:t,className:(0,a.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...l,children:[n,(0,s.jsx)(r.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}},83099:(e,t,n)=>{"use strict";n.d(t,{W:()=>s});let s=(0,n(1934).v)((e,t)=>({sessionKey:null,activeRun:null,activeFiles:new Set,lastFileTouchAt:null,changeSets:[],review:{open:!1,changeSetId:null,filePath:null},dismissed:new Set,loading:!1,error:void 0,setSessionKey:t=>e({sessionKey:t}),setActiveRun:t=>e({activeRun:t,...t?{}:{lastFileTouchAt:null}}),touchFile:t=>e(e=>{let n=new Set(e.activeFiles);return n.add(t),{activeFiles:n,lastFileTouchAt:Date.now()}}),clearActiveFiles:()=>e({activeFiles:new Set,lastFileTouchAt:null}),loadChangeSets:async()=>{let n=t().sessionKey;if(n){e({loading:!0,error:void 0});try{let t=await fetch(`/api/changes?sessionKey=${encodeURIComponent(n)}`);if(!t.ok)throw Error("Failed to load change sets");let s=await t.json();e({changeSets:s,loading:!1})}catch(t){e({loading:!1,error:String(t)})}}},openReview:(t,n)=>e({review:{open:!0,changeSetId:t,filePath:n}}),closeReview:()=>e({review:{open:!1,changeSetId:null,filePath:null}}),dismissChangeSet:t=>e(e=>{let n=new Set(e.dismissed);return n.add(t),{dismissed:n}})}))},86846:(e,t,n)=>{"use strict";n.d(t,{E:()=>a});var s=n(95155),r=n(52799);function a({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"skeleton",className:(0,r.cn)("bg-accent animate-pulse rounded-md",e),...t})}},89239:(e,t,n)=>{"use strict";n.d(t,{$:()=>o});var s=n(95155);n(12115);var r=n(18460),a=n(42442),l=n(52799);let i=(0,r.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function o({className:e,variant:t="default",size:n="default",asChild:r=!1,...o}){let c=r?a.bL:"button";return(0,s.jsx)(c,{"data-slot":"button","data-variant":t,"data-size":n,className:(0,l.cn)(i({variant:t,size:n,className:e})),...o})}},93571:(e,t,n)=>{"use strict";n.d(t,{R:()=>o});var s=n(95155),r=n(5772),a=n(52799);let l=265/235,i=1152/235;function o({variant:e="icon",size:t=24,className:n,imageClassName:o,lightImageClassName:c,darkImageClassName:d,theme:u="auto",alt:m="ClawPad",priority:h=!1}){let x="icon"===e,p=Math.round(t*(x?l:i));return(0,s.jsx)("span",{className:(0,a.cn)("inline-flex items-center",n),children:(0,s.jsx)(r.default,{src:x?"/brand/icon.png":"/brand/logo.png",width:p,height:t,alt:m,priority:h,className:(0,a.cn)("block",o,"dark"===u?d:"light"===u?c:void 0)})})}},97916:(e,t,n)=>{"use strict";n.d(t,{w:()=>l});var s=n(95155);n(12115);var r=n(89803),a=n(52799);function l({className:e,orientation:t="horizontal",decorative:n=!0,...l}){return(0,s.jsx)(r.b,{"data-slot":"separator",decorative:n,orientation:t,className:(0,a.cn)("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...l})}}},e=>{e.O(0,[8803,330,7300,4559,6609,5403,8935,9352,4747,8550,9075,4576,1178,8441,3794,7358],()=>e(e.s=35018)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6364],{1934:(e,t,s)=>{"use strict";s.d(t,{v:()=>i});var a=s(12115);let r=e=>{let t,s=new Set,a=(e,a)=>{let r="function"==typeof e?e(t):e;if(!Object.is(r,t)){let e=t;t=(null!=a?a:"object"!=typeof r||null===r)?r:Object.assign({},t,r),s.forEach(s=>s(t,e))}},r=()=>t,n={setState:a,getState:r,getInitialState:()=>i,subscribe:e=>(s.add(e),()=>s.delete(e))},i=t=e(a,r,n);return n},n=e=>{let t=e?r(e):r,s=e=>(function(e,t=e=>e){let s=a.useSyncExternalStore(e.subscribe,a.useCallback(()=>t(e.getState()),[e,t]),a.useCallback(()=>t(e.getInitialState()),[e,t]));return a.useDebugValue(s),s})(t,e);return Object.assign(s,t),s},i=e=>e?n(e):n},7814:(e,t,s)=>{"use strict";function a(e){let t=e.replace(/\.md$/,"").split("/").filter(Boolean).map(e=>encodeURIComponent(e));return 0===t.length?"/workspace":`/workspace/${t.join("/")}`}s.d(t,{C:()=>a})},27027:(e,t,s)=>{Promise.resolve().then(s.bind(s,59176))},32967:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]])},51914:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},53536:(e,t,s)=>{"use strict";function a(e){let t=new Date(e),s=Math.floor((new Date().getTime()-t.getTime())/1e3),a=Math.floor(s/60),r=Math.floor(a/60),n=Math.floor(r/24);return s<60?"just now":a<60?`${a}m`:r<24?`${r}h`:1===n?"Yesterday":n<7?`${n}d`:n<30?`${Math.floor(n/7)}w`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}s.d(t,{f:()=>a})},59176:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var a=s(95155),r=s(12115),n=s(73321),i=s(51914),l=s(61878),c=s(32967),o=s(84980),d=s(89239),u=s(18496),m=s(53536),p=s(52799),h=s(93571),g=s(60464),x=s(7814);function f(){let e=(0,n.useSearchParams)(),t=(0,n.useRouter)(),s=(0,u.M)(e=>e.setChatPanelOpen);return(0,r.useEffect)(()=>{"open"===e.get("chat")&&(s(!0),t.replace("/workspace",{scroll:!1}))},[e,s,t]),null}function v(){let e=(0,n.useRouter)(),{recentPages:t,spaces:s,loadRecentPages:v,loadSpaces:w,spacesStatus:b,recentStatus:j}=(0,u.M)(),[k,y]=(0,r.useState)(!1),[N,C]=(0,r.useState)(!1),[S,z]=(0,r.useState)(null);if((0,r.useEffect)(()=>{let t=!1,s=new AbortController,a=setTimeout(()=>s.abort(),8e3);return fetch("/api/setup/status",{signal:s.signal}).then(e=>e.ok?e.json():null).then(s=>{t||(!s?.hasWorkspace||s?.needsSetupSignal?e.replace("/setup"):y(!0))}).catch(()=>{t||y(!0)}).finally(()=>{clearTimeout(a)}),()=>{t=!0,s.abort(),clearTimeout(a)}},[e]),(0,r.useEffect)(()=>{k&&(v(),w())},[v,w,k]),!k)return(0,a.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Loading workspace..."});let A=async()=>{C(!0),z(null);try{let e=await fetch("/api/setup/bootstrap",{method:"POST"});if(!e.ok){let t=await e.json();throw Error(t?.error||"Failed to bootstrap workspace")}await w(),await v()}catch(e){z(e.message)}finally{C(!1)}};return(0,a.jsxs)("div",{className:"flex h-full flex-col items-center justify-center px-4",children:[(0,a.jsx)(r.Suspense,{fallback:null,children:(0,a.jsx)(f,{})}),(0,a.jsxs)("div",{className:"max-w-lg w-full space-y-8 text-center",children:[(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-2xl bg-muted/60 ring-1 ring-border/50",children:(0,a.jsx)(h.R,{variant:"icon",size:36,alt:""})}),(0,a.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Welcome to ClawPad"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm mx-auto",children:"Your workspace for OpenClaw. Select a page from the sidebar or create a new one to get started."})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,a.jsxs)(d.$,{onClick:()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},children:[(0,a.jsx)(i.A,{className:"mr-2 h-4 w-4"}),"New Document"]}),(0,a.jsxs)(d.$,{variant:"outline",onClick:()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette"))},children:[(0,a.jsx)(l.A,{className:"mr-2 h-4 w-4"}),"Search"]}),(0,a.jsxs)(d.$,{variant:"secondary",onClick:()=>{let e=["Please update ClawPad and the OpenClaw CLI on this machine.","Run the following in a terminal, then confirm when done:","u">typeof navigator&&/windows/i.test(navigator.userAgent||navigator.platform||"")?"npm install -g clawpad@latest && npm install -g openclaw@latest":"npm install -g clawpad@latest && npm install -g openclaw@latest # or: brew upgrade clawpad openclaw"].join("\n\n");window.dispatchEvent(new CustomEvent("clawpad:ai-action",{detail:{message:e}}))},children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Ask Agent to Update"]})]}),0===s.length&&0===t.length&&"loading"!==b&&"loading"!==j&&(0,a.jsxs)("div",{className:"rounded-lg border border-border/60 bg-muted/20 p-4 text-sm text-muted-foreground",children:[(0,a.jsx)("div",{className:"mb-3 font-medium text-foreground",children:"No workspace yet"}),(0,a.jsx)("p",{className:"mb-4 text-xs",children:"Create a starter workspace with default spaces and a welcome page."}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,a.jsx)(d.$,{size:"sm",onClick:A,disabled:N,children:N?"Creating…":"Create starter workspace"}),(0,a.jsx)(d.$,{size:"sm",variant:"outline",onClick:()=>e.push("/setup"),children:"Open setup"})]}),S&&(0,a.jsx)("p",{className:"mt-3 text-xs text-rose-500",children:S})]}),t.length>0&&(0,a.jsxs)("div",{className:"space-y-3 pt-4",children:[(0,a.jsx)("h2",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Recent Pages"}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:t.slice(0,6).map(t=>(0,a.jsxs)("button",{onClick:()=>{var s;return s=t.path,void e.push((0,x.C)(s))},className:(0,p.cn)("flex items-center gap-3 rounded-lg border border-border/50 p-3 text-left","transition-colors duration-200 hover:bg-muted/50 hover:border-border"),children:[(0,a.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-muted text-sm",children:t.icon??"\uD83D\uDCC4"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"truncate text-sm font-medium",children:t.title}),(0,a.jsxs)("div",{className:"flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,a.jsx)(o.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:(0,m.f)(t.modified)}),(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,a.jsx)("span",{children:t.space===g.Sz?g.ke:t.space})]})]})]},t.path))})]})]})]})}},61878:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},84980:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},89239:(e,t,s)=>{"use strict";s.d(t,{$:()=>c});var a=s(95155);s(12115);var r=s(18460),n=s(42442),i=s(52799);let l=(0,r.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function c({className:e,variant:t="default",size:s="default",asChild:r=!1,...c}){let o=r?n.bL:"button";return(0,a.jsx)(o,{"data-slot":"button","data-variant":t,"data-size":s,className:(0,i.cn)(l({variant:t,size:s,className:e})),...c})}},93571:(e,t,s)=>{"use strict";s.d(t,{R:()=>c});var a=s(95155),r=s(5772),n=s(52799);let i=265/235,l=1152/235;function c({variant:e="icon",size:t=24,className:s,imageClassName:c,lightImageClassName:o,darkImageClassName:d,theme:u="auto",alt:m="ClawPad",priority:p=!1}){let h="icon"===e,g=Math.round(t*(h?i:l));return(0,a.jsx)("span",{className:(0,n.cn)("inline-flex items-center",s),children:(0,a.jsx)(r.default,{src:h?"/brand/icon.png":"/brand/logo.png",width:g,height:t,alt:m,priority:p,className:(0,n.cn)("block",c,"dark"===u?d:"light"===u?o:void 0)})})}}},e=>{e.O(0,[330,5403,1178,8441,3794,7358],()=>e(e.s=27027)),_N_E=e.O()}]);
|
package/.next/static/chunks/next/dist/client/components/builtin/app-error-961a312de2dcc334.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[276,1607,1738,1811,2596,2626,2752,2895,3487,3742,4380,4483,4896,5347,5362,5389,5402,6202,6244,6819,6967,6988,7244,7625,7851,7897,8167,8321,8455,8742,8974,9498,9861,9986],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
package/.next/static/chunks/next/dist/client/components/builtin/forbidden-961a312de2dcc334.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[276,1607,1738,1811,2596,2626,2752,2895,3487,3742,4380,4483,4896,5347,5362,5389,5402,6202,6244,6819,6967,6988,7244,7625,7851,7897,8167,8321,8455,8742,8974,9498,9861,9986],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
package/.next/static/chunks/next/dist/client/components/builtin/not-found-961a312de2dcc334.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[276,1607,1738,1811,2596,2626,2752,2895,3487,3742,4380,4483,4896,5347,5362,5389,5402,6202,6244,6819,6967,6988,7244,7625,7851,7897,8167,8321,8455,8742,8974,9498,9861,9986],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-961a312de2dcc334.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[276,1607,1738,1811,2596,2626,2752,2895,3487,3742,4380,4483,4896,5347,5362,5389,5402,6202,6244,6819,6967,6988,7244,7625,7851,7897,8167,8321,8455,8742,8974,9498,9861,9986],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|