@rubytech/create-maxy-code 0.1.551 → 0.1.553
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/package.json +1 -1
- package/payload/platform/lib/routine-templates/dist/index.d.ts +15 -2
- package/payload/platform/lib/routine-templates/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/routine-templates/dist/index.js +25 -1
- package/payload/platform/lib/routine-templates/dist/index.js.map +1 -1
- package/payload/platform/lib/routine-templates/dist/roster.d.ts +76 -1
- package/payload/platform/lib/routine-templates/dist/roster.d.ts.map +1 -1
- package/payload/platform/lib/routine-templates/dist/roster.js +60 -3
- package/payload/platform/lib/routine-templates/dist/roster.js.map +1 -1
- package/payload/platform/lib/routine-templates/src/__tests__/roster.test.ts +93 -1
- package/payload/platform/lib/routine-templates/src/__tests__/seed.test.ts +74 -0
- package/payload/platform/lib/routine-templates/src/index.ts +25 -1
- package/payload/platform/lib/routine-templates/src/roster.ts +111 -2
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +11 -0
- package/payload/platform/plugins/scheduling/PLUGIN.md +54 -4
- package/payload/platform/plugins/scheduling/mcp/dist/index.js +113 -6
- package/payload/platform/plugins/scheduling/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-freebusy.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-freebusy.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-freebusy.test.js +216 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-freebusy.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/fires-per-day.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/fires-per-day.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/fires-per-day.test.js +44 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/fires-per-day.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-audits.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-audits.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-audits.test.js +128 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-audits.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-classification.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-classification.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-classification.test.js +92 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-classification.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate.test.js +135 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/schedule-audit.test.js +210 -2
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/schedule-audit.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/update-summary.test.js +18 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/update-summary.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-freebusy.d.ts +86 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-freebusy.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-freebusy.js +240 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-freebusy.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/fires-per-day.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/fires-per-day.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/fires-per-day.js +47 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/fires-per-day.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.d.ts +92 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.js +193 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/routine-run.d.ts +8 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/routine-run.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/routine-run.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-audit.d.ts +152 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-audit.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-audit.js +472 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-audit.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/update-summary.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/update-summary.js +11 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/update-summary.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/gate-dispatch-wiring.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/gate-dispatch-wiring.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/gate-dispatch-wiring.test.js +146 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/gate-dispatch-wiring.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.d.ts +27 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.js +18 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js +146 -64
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.js +84 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-waiver.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-waiver.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-waiver.test.js +200 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-waiver.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-write.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-write.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-write.test.js +238 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-write.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-update-recurrence-record.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-update-recurrence-record.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-update-recurrence-record.test.js +208 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-update-recurrence-record.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/scheduling-gate.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/scheduling-gate.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/scheduling-gate.test.js +291 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/scheduling-gate.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.d.ts +26 -2
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.js +51 -2
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.d.ts +71 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.js +109 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.d.ts +3 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.js +124 -3
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.d.ts +148 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.js +410 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/package.json +1 -0
- package/payload/platform/plugins/workflows/skills/workflow-manager/SKILL.md +4 -0
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +1 -0
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-census.d.ts +51 -4
- package/payload/platform/services/claude-session-manager/dist/pty-census.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-census.js +60 -10
- package/payload/platform/services/claude-session-manager/dist/pty-census.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/slice-memory-policy.d.ts +64 -1
- package/payload/platform/services/claude-session-manager/dist/slice-memory-policy.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/slice-memory-policy.js +189 -6
- package/payload/platform/services/claude-session-manager/dist/slice-memory-policy.js.map +1 -1
- package/payload/server/public/activity.html +5 -5
- package/payload/server/public/agents.html +4 -4
- package/payload/server/public/assets/{AdminLoginScreens-Bjcs9ta9.js → AdminLoginScreens-Ca2QhL18.js} +1 -1
- package/payload/server/public/assets/AdminLoginScreens-Ca2QhL18.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-Ca2QhL18.js.gz +0 -0
- package/payload/server/public/assets/{AdminShell-DVBAMUCy.js → AdminShell-Dc5du5xX.js} +1 -1
- package/payload/server/public/assets/AdminShell-Dc5du5xX.js.br +0 -0
- package/payload/server/public/assets/AdminShell-Dc5du5xX.js.gz +0 -0
- package/payload/server/public/assets/{activity-C8E8-EwQ.js → activity-TSDKmIYb.js} +1 -1
- package/payload/server/public/assets/activity-TSDKmIYb.js.br +0 -0
- package/payload/server/public/assets/activity-TSDKmIYb.js.gz +0 -0
- package/payload/server/public/assets/{admin-CeWAlpRS.js → admin-Ba729Eyg.js} +1 -1
- package/payload/server/public/assets/admin-Ba729Eyg.js.br +0 -0
- package/payload/server/public/assets/admin-Ba729Eyg.js.gz +0 -0
- package/payload/server/public/assets/{agents-DuN92iFb.js → agents-9hlQHOS5.js} +1 -1
- package/payload/server/public/assets/agents-9hlQHOS5.js.br +0 -0
- package/payload/server/public/assets/agents-9hlQHOS5.js.gz +0 -0
- package/payload/server/public/assets/{browser-BxebdKbh.js → browser-BrqoCsqh.js} +1 -1
- package/payload/server/public/assets/browser-BrqoCsqh.js.br +0 -0
- package/payload/server/public/assets/browser-BrqoCsqh.js.gz +0 -0
- package/payload/server/public/assets/{calendar-BtFZQ5Np.js → calendar-DOObQ_m8.js} +1 -1
- package/payload/server/public/assets/calendar-DOObQ_m8.js.br +0 -0
- package/payload/server/public/assets/calendar-DOObQ_m8.js.gz +0 -0
- package/payload/server/public/assets/chat-Xaul2lLF.js +1 -0
- package/payload/server/public/assets/chat-Xaul2lLF.js.br +3 -0
- package/payload/server/public/assets/chat-Xaul2lLF.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-BYH5vH4S.js +1 -0
- package/payload/server/public/assets/chevron-left-BYH5vH4S.js.br +0 -0
- package/payload/server/public/assets/chevron-right-XxQPHfNH.js +1 -0
- package/payload/server/public/assets/chevron-right-XxQPHfNH.js.br +0 -0
- package/payload/server/public/assets/clock-BNp2JTKh.js +1 -0
- package/payload/server/public/assets/clock-BNp2JTKh.js.br +0 -0
- package/payload/server/public/assets/clock-BNp2JTKh.js.gz +0 -0
- package/payload/server/public/assets/{copy-DCDHXq3O.js → copy-BkbgmpJo.js} +1 -1
- package/payload/server/public/assets/copy-BkbgmpJo.js.br +0 -0
- package/payload/server/public/assets/copy-BkbgmpJo.js.gz +0 -0
- package/payload/server/public/assets/data-yuHj8g0C.js +1 -0
- package/payload/server/public/assets/data-yuHj8g0C.js.br +3 -0
- package/payload/server/public/assets/data-yuHj8g0C.js.gz +0 -0
- package/payload/server/public/assets/{file-text-zQgEQWCF.js → file-text-DDCrqbWB.js} +1 -1
- package/payload/server/public/assets/file-text-DDCrqbWB.js.br +0 -0
- package/payload/server/public/assets/file-text-DDCrqbWB.js.gz +0 -0
- package/payload/server/public/assets/{graph-CFCEh_YI.js → graph-BKPdL5ph.js} +1 -1
- package/payload/server/public/assets/graph-BKPdL5ph.js.br +0 -0
- package/payload/server/public/assets/graph-BKPdL5ph.js.gz +0 -0
- package/payload/server/public/assets/{graph-labels-CA1UcDuS.js → graph-labels-B2PrHK6O.js} +1 -1
- package/payload/server/public/assets/graph-labels-B2PrHK6O.js.br +0 -0
- package/payload/server/public/assets/graph-labels-B2PrHK6O.js.gz +0 -0
- package/payload/server/public/assets/{operator-hFXPDc2X.js → operator-BVULmN09.js} +1 -1
- package/payload/server/public/assets/operator-BVULmN09.js.br +0 -0
- package/payload/server/public/assets/operator-BVULmN09.js.gz +0 -0
- package/payload/server/public/assets/{page-ne7I_r9L.js → page-BbzdSxuU.js} +1 -1
- package/payload/server/public/assets/page-BbzdSxuU.js.br +0 -0
- package/payload/server/public/assets/page-BbzdSxuU.js.gz +0 -0
- package/payload/server/public/assets/{page-C8jyPH_3.js → page-baQ9FQIg.js} +1 -1
- package/payload/server/public/assets/page-baQ9FQIg.js.br +0 -0
- package/payload/server/public/assets/page-baQ9FQIg.js.gz +0 -0
- package/payload/server/public/assets/play-3hlqzxLI.js +1 -0
- package/payload/server/public/assets/play-3hlqzxLI.js.br +0 -0
- package/payload/server/public/assets/play-3hlqzxLI.js.gz +0 -0
- package/payload/server/public/assets/{public-BgnqjAal.js → public-B_SEBxWy.js} +1 -1
- package/payload/server/public/assets/public-B_SEBxWy.js.br +0 -0
- package/payload/server/public/assets/public-B_SEBxWy.js.gz +0 -0
- package/payload/server/public/assets/{rotate-ccw-DfJWjXAg.js → rotate-ccw-DzXTXh3g.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-DzXTXh3g.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-DzXTXh3g.js.gz +0 -0
- package/payload/server/public/assets/routines-BQzE0xzC.js +2 -0
- package/payload/server/public/assets/routines-BQzE0xzC.js.br +0 -0
- package/payload/server/public/assets/routines-BQzE0xzC.js.gz +0 -0
- package/payload/server/public/assets/{skills-D-6EbgfP.js → skills-yCZhYVIs.js} +1 -1
- package/payload/server/public/assets/skills-yCZhYVIs.js.br +0 -0
- package/payload/server/public/assets/skills-yCZhYVIs.js.gz +0 -0
- package/payload/server/public/assets/{tasks-DnN5Fyds.js → tasks-DxNFLsHv.js} +1 -1
- package/payload/server/public/assets/tasks-DxNFLsHv.js.br +0 -0
- package/payload/server/public/assets/tasks-DxNFLsHv.js.gz +0 -0
- package/payload/server/public/assets/{triangle-alert-eh9UOKDT.js → triangle-alert-CYwHTcvU.js} +1 -1
- package/payload/server/public/assets/triangle-alert-CYwHTcvU.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-CYwHTcvU.js.gz +0 -0
- package/payload/server/public/assets/{useCopyFeedback-Bz9OJHBb.js → useCopyFeedback-BCRjKc-H.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-BCRjKc-H.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-BCRjKc-H.js.gz +0 -0
- package/payload/server/public/assets/{useMediaQuery-CNxsjKZp.css → useMediaQuery-Vxpamxqq.css} +1 -1
- package/payload/server/public/assets/useMediaQuery-Vxpamxqq.css.br +0 -0
- package/payload/server/public/assets/{useMediaQuery-CNxsjKZp.css.gz → useMediaQuery-Vxpamxqq.css.gz} +0 -0
- package/payload/server/public/assets/{useVoiceRecorder-BaDpMYxX.js → useVoiceRecorder-BaAtMu9T.js} +1 -1
- package/payload/server/public/assets/useVoiceRecorder-BaAtMu9T.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-BaAtMu9T.js.gz +0 -0
- package/payload/server/public/assets/{wrench-BO-l46rF.js → wrench-iI-vx-g2.js} +1 -1
- package/payload/server/public/assets/wrench-iI-vx-g2.js.br +0 -0
- package/payload/server/public/assets/wrench-iI-vx-g2.js.gz +0 -0
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +8 -8
- package/payload/server/public/chat.html +13 -13
- package/payload/server/public/data.html +11 -11
- package/payload/server/public/graph.html +9 -9
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +13 -13
- package/payload/server/public/routines.html +6 -6
- package/payload/server/public/skills.html +5 -5
- package/payload/server/public/tasks.html +6 -6
- package/payload/server/server.js +36 -5
- package/payload/server/public/assets/AdminLoginScreens-Bjcs9ta9.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-Bjcs9ta9.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-DVBAMUCy.js.br +0 -0
- package/payload/server/public/assets/AdminShell-DVBAMUCy.js.gz +0 -0
- package/payload/server/public/assets/activity-C8E8-EwQ.js.br +0 -0
- package/payload/server/public/assets/activity-C8E8-EwQ.js.gz +0 -0
- package/payload/server/public/assets/admin-CeWAlpRS.js.br +0 -0
- package/payload/server/public/assets/admin-CeWAlpRS.js.gz +0 -0
- package/payload/server/public/assets/agents-DuN92iFb.js.br +0 -0
- package/payload/server/public/assets/agents-DuN92iFb.js.gz +0 -0
- package/payload/server/public/assets/browser-BxebdKbh.js.br +0 -0
- package/payload/server/public/assets/browser-BxebdKbh.js.gz +0 -0
- package/payload/server/public/assets/calendar-BtFZQ5Np.js.br +0 -0
- package/payload/server/public/assets/calendar-BtFZQ5Np.js.gz +0 -0
- package/payload/server/public/assets/chat-CGIwynaH.js +0 -1
- package/payload/server/public/assets/chat-CGIwynaH.js.br +0 -3
- package/payload/server/public/assets/chat-CGIwynaH.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-DaNP1zDb.js +0 -1
- package/payload/server/public/assets/chevron-left-DaNP1zDb.js.br +0 -0
- package/payload/server/public/assets/chevron-right-BbbuTUnt.js +0 -1
- package/payload/server/public/assets/chevron-right-BbbuTUnt.js.br +0 -0
- package/payload/server/public/assets/clock-CfDdatjp.js +0 -1
- package/payload/server/public/assets/clock-CfDdatjp.js.br +0 -0
- package/payload/server/public/assets/clock-CfDdatjp.js.gz +0 -0
- package/payload/server/public/assets/copy-DCDHXq3O.js.br +0 -0
- package/payload/server/public/assets/copy-DCDHXq3O.js.gz +0 -0
- package/payload/server/public/assets/data-BchSWOju.js +0 -1
- package/payload/server/public/assets/data-BchSWOju.js.br +0 -1
- package/payload/server/public/assets/data-BchSWOju.js.gz +0 -0
- package/payload/server/public/assets/file-text-zQgEQWCF.js.br +0 -0
- package/payload/server/public/assets/file-text-zQgEQWCF.js.gz +0 -0
- package/payload/server/public/assets/graph-CFCEh_YI.js.br +0 -0
- package/payload/server/public/assets/graph-CFCEh_YI.js.gz +0 -0
- package/payload/server/public/assets/graph-labels-CA1UcDuS.js.br +0 -0
- package/payload/server/public/assets/graph-labels-CA1UcDuS.js.gz +0 -0
- package/payload/server/public/assets/operator-hFXPDc2X.js.br +0 -0
- package/payload/server/public/assets/operator-hFXPDc2X.js.gz +0 -0
- package/payload/server/public/assets/page-C8jyPH_3.js.br +0 -0
- package/payload/server/public/assets/page-C8jyPH_3.js.gz +0 -0
- package/payload/server/public/assets/page-ne7I_r9L.js.br +0 -0
- package/payload/server/public/assets/page-ne7I_r9L.js.gz +0 -0
- package/payload/server/public/assets/play-Ep0SZTbr.js +0 -1
- package/payload/server/public/assets/play-Ep0SZTbr.js.br +0 -0
- package/payload/server/public/assets/play-Ep0SZTbr.js.gz +0 -0
- package/payload/server/public/assets/public-BgnqjAal.js.br +0 -0
- package/payload/server/public/assets/public-BgnqjAal.js.gz +0 -0
- package/payload/server/public/assets/rotate-ccw-DfJWjXAg.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-DfJWjXAg.js.gz +0 -0
- package/payload/server/public/assets/routines-OGFXwTFO.js +0 -2
- package/payload/server/public/assets/routines-OGFXwTFO.js.br +0 -0
- package/payload/server/public/assets/routines-OGFXwTFO.js.gz +0 -0
- package/payload/server/public/assets/skills-D-6EbgfP.js.br +0 -0
- package/payload/server/public/assets/skills-D-6EbgfP.js.gz +0 -0
- package/payload/server/public/assets/tasks-DnN5Fyds.js.br +0 -0
- package/payload/server/public/assets/tasks-DnN5Fyds.js.gz +0 -0
- package/payload/server/public/assets/triangle-alert-eh9UOKDT.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-eh9UOKDT.js.gz +0 -0
- package/payload/server/public/assets/useCopyFeedback-Bz9OJHBb.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-Bz9OJHBb.js.gz +0 -0
- package/payload/server/public/assets/useMediaQuery-CNxsjKZp.css.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-BaDpMYxX.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-BaDpMYxX.js.gz +0 -0
- package/payload/server/public/assets/wrench-BO-l46rF.js.br +0 -0
- package/payload/server/public/assets/wrench-BO-l46rF.js.gz +0 -0
- /package/payload/server/public/assets/{useMediaQuery-_mMln3Fu.js → useMediaQuery-Baf4Huvv.js} +0 -0
- /package/payload/server/public/assets/{useMediaQuery-_mMln3Fu.js.br → useMediaQuery-Baf4Huvv.js.br} +0 -0
- /package/payload/server/public/assets/{useMediaQuery-_mMln3Fu.js.gz → useMediaQuery-Baf4Huvv.js.gz} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{F as t,G as n,I as r,L as i,M as a,N as o,O as s,P as c,T as l,V as u,W as d,Y as f,Z as p,_ as m,at as h,ct as g,g as _,j as v,k as y,l as b,m as x,n as ee,nt as S,o as C,s as w,st as T,t as te,u as ne,v as re}from"./useMediaQuery-_mMln3Fu.js";import{E as ie,O as ae,T as oe,f as E,k as D,n as se,r as O,s as k}from"./useVoiceRecorder-BaDpMYxX.js";import{t as A}from"./chevron-left-DaNP1zDb.js";import{t as ce}from"./file-text-zQgEQWCF.js";import{i as le,t as ue}from"./graph-labels-CA1UcDuS.js";import{t as de}from"./triangle-alert-eh9UOKDT.js";import{i as fe,n as pe,t as me}from"./file-download-DbNIjWiK.js";var j=p(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),he=p(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ge=p(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),_e=p(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),ve=p(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),M=p(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),ye=p(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),be=p(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),N=e(g(),1);function P(){let[e,t]=(0,N.useState)([]),[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(null),o=(0,N.useRef)(null),s=(0,N.useCallback)(e=>{a(null);let n=e.find(e=>!O(e.type,D));if(n){a(`Unsupported file type: "${n.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, zip, voice notes.`);return}let r=e.find(e=>e.size>ae);if(r){a(`"${r.name}" exceeds the 50 MB limit.`);return}t(t=>[...t,...e].slice(0,5))},[]);return{pendingFiles:e,setPendingFiles:t,isDragOver:n,attachError:i,setAttachError:a,fileInputRef:o,addFiles:s,clearFiles:(0,N.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,N.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,N.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,N.useCallback)(()=>{r(!1)},[]),onDrop:(0,N.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var F=[[128512],[128515],[128516],[128513],[128518],[128517],[128514],[129315],[128578],[128579],[128521],[128522],[128519],[128525],[128536],[128535],[128540],[128541],[129303],[129300],[128528],[128566],[128564],[128526],[129395],[128546],[128557],[128548],[128544],[128533],[128556],[129393],[128077],[128078],[128076],[128591],[128079],[128588],[128170],[128075],[129309],[10084,65039],[128293],[11088],[127881],[10024],[128175],[128064]].map(e=>String.fromCodePoint(...e));function xe(e,t,n,r){let i=e.length,a=Math.max(0,Math.min(n??i,i)),o=Math.max(a,Math.min(r??a,i));return{value:e.slice(0,a)+t+e.slice(o),caret:a+t.length}}var I=S();function Se({onSelect:e}){return(0,I.jsx)(`div`,{className:`wa-emoji-popover`,role:`menu`,"aria-label":`Emoji picker`,children:F.map((t,n)=>(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`wa-emoji-item`,onClick:()=>e(t),children:t},n))})}function Ce({sessionKey:e,onPick:t,onClose:n}){let[r,i]=(0,N.useState)(``),[a,o]=(0,N.useState)(null),[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(!1),f=(0,N.useCallback)(t=>{u(!0),c(null),fetch(`/api/admin/files?path=${encodeURIComponent(t)}&session_key=${encodeURIComponent(e)}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not list files`);return t}).then(e=>{o(e),i(e.path===`.`?``:e.path)}).catch(e=>c(e instanceof Error?e.message:String(e))).finally(()=>u(!1))},[e]);(0,N.useEffect)(()=>{f(``)},[f]);let p=e=>f(r?`${r}/${e}`:e),m=()=>{let e=r.split(`/`).filter(Boolean);e.pop(),f(e.join(`/`))},h=e=>{let n=e.entryPath??e.name;t({path:r?`${r}/${n}`:n,name:e.displayName??e.name})};return(0,I.jsx)(`div`,{className:`wa-picker-backdrop`,role:`dialog`,"aria-label":`Choose a device file`,onClick:n,children:(0,I.jsxs)(`div`,{className:`wa-picker`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`wa-picker-head`,children:[r&&(0,I.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:m,"aria-label":`Up one folder`,children:(0,I.jsx)(A,{size:18})}),(0,I.jsx)(`span`,{className:`wa-picker-title`,children:r||`Device storage`}),(0,I.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:n,"aria-label":`Close file picker`,children:(0,I.jsx)(v,{size:18})})]}),s&&(0,I.jsx)(`p`,{className:`wa-picker-error`,role:`alert`,children:s}),l&&(0,I.jsx)(`p`,{className:`wa-picker-empty`,children:`Loading…`}),a&&!l&&(0,I.jsxs)(`ul`,{className:`wa-picker-list`,children:[a.entries.length===0&&(0,I.jsx)(`li`,{className:`wa-picker-empty`,children:`This folder is empty.`}),a.entries.map(e=>(0,I.jsx)(`li`,{children:e.kind===`directory`?(0,I.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>p(e.name),children:[(0,I.jsx)(d,{size:16,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):e.kind===`file`?(0,I.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>h(e),children:[(0,I.jsx)(ce,{size:16,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):null},e.name))]})]})})}var we=T();function Te(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function Ee({accountId:e,remoteJid:t,sessionKey:n,replyTo:i,onClearReply:s}){let[c,l]=(0,N.useState)(``),[u,d]=(0,N.useState)(!1),[f,p]=(0,N.useState)(null),[m,h]=(0,N.useState)(!1),[g,_]=(0,N.useState)(!1),[y,b]=(0,N.useState)(!1),[x,ee]=(0,N.useState)([]),S=(0,N.useRef)(null),{pendingFiles:C,attachError:w,addFiles:T,removeFile:ne,clearFiles:re}=P(),{state:ae,elapsedSeconds:E,errorMessage:D,start:O,send:k,discard:A}=se(),le=ae===`recording`||ae===`paused`,ue=(0,N.useCallback)(()=>{O()},[O]),de=(0,N.useCallback)(async()=>{let e=await k();if(e){let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`;T([new File([e],`voice-note${t}`,{type:e.type})])}},[E,k,T]),fe=(0,N.useCallback)(()=>{A()},[E,A]),pe=(0,N.useRef)(!1),me=()=>Math.round((typeof window>`u`?900:window.innerHeight)/3),[j,he]=(0,N.useState)(null),[_e,ve]=(0,N.useState)(null),be=(0,N.useRef)(null),F=(0,N.useCallback)(e=>{let t=be.current;t&&he(Math.min(me(),Math.max(44,t.startH+(t.startY-e.clientY))))},[]),Ee=(0,N.useCallback)(()=>{be.current=null,window.removeEventListener(`pointermove`,F),window.removeEventListener(`pointerup`,Ee)},[F]),L=(0,N.useCallback)(e=>{be.current={startY:e.clientY,startH:S.current?.offsetHeight??44},window.addEventListener(`pointermove`,F),window.addEventListener(`pointerup`,Ee),e.preventDefault()},[F,Ee]),De=(0,N.useCallback)(e=>{let t=j??S.current?.offsetHeight??44,n=null;e.key===`ArrowUp`?(e.preventDefault(),n=Math.min(me(),t+24)):e.key===`ArrowDown`&&(e.preventDefault(),n=Math.max(44,t-24)),n!==null&&he(n)},[j]),R=(0,N.useRef)(``);(0,N.useEffect)(()=>{let e=S.current;if(!e)return;let t=R.current!==``&&c===``;if(R.current=c,j!==null){t&&he(null);return}let n=e.style.height;e.style.height=`auto`;let r=Math.min(me(),Math.max(44,e.scrollHeight));e.style.height=n,ve(r)},[c,j]);let z=(c.trim().length>0||C.length>0||x.length>0)&&!u,B=(0,N.useCallback)(async()=>{if(!pe.current&&!(c.trim().length===0&&C.length===0&&x.length===0)){pe.current=!0,d(!0),p(null);try{let r=`/api/whatsapp-reader/reply?session_key=${encodeURIComponent(n)}`,a;if(C.length>0||x.length>0){let n=new FormData;n.append(`accountId`,e),n.append(`remoteJid`,t),c.trim()&&n.append(`text`,c);for(let e of C)n.append(`files`,e);for(let e of x)n.append(`fileRefs`,e.path);i&&n.append(`quotedId`,i.msgKeyId),a=await fetch(r,{method:`POST`,body:n})}else a=await fetch(r,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accountId:e,remoteJid:t,text:c,...i?{quotedId:i.msgKeyId}:{}})});let o=await a.json().catch(()=>({}));if(!a.ok){p(o.error??`Send failed.`),console.warn(`[operator-ui] op=reply-fail remoteJid=${t} error=${o.error??`unknown`}`);return}l(``),re(),ee([]),s?.()}catch(e){p(`Could not reach the server. Try again.`),console.warn(`[operator-ui] op=reply-fail remoteJid=${t} error=${String(e)}`)}finally{pe.current=!1,d(!1)}}},[c,C,x,i,s,e,t,n,re]),Oe=(0,N.useCallback)(e=>{let t=S.current,{value:n,caret:r}=xe(c,e,t?t.selectionStart:null,t?t.selectionEnd:null);l(n),h(!1),requestAnimationFrame(()=>{let e=S.current;e&&(e.focus(),e.setSelectionRange(r,r))})},[c]),V=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),z&&B())},ke=e=>e.dataTransfer.types.includes(`Files`),Ae=(0,N.useCallback)(e=>{ke(e)&&(e.preventDefault(),b(!0))},[]),je=(0,N.useCallback)(()=>b(!1),[]),Me=(0,N.useCallback)(e=>{if(!ke(e))return;e.preventDefault(),b(!1);let t=[...e.dataTransfer.files];t.length!==0&&(Math.max(0,C.length+t.length-5),T(t))},[C.length,T]),Ne=e=>e.startsWith(`image/`)?(0,I.jsx)(ge,{size:14}):e===`application/pdf`?(0,I.jsx)(ce,{size:14}):(0,I.jsx)(ie,{size:14}),Pe=te(`(max-width: 720px)`),[Fe,Ie]=(0,N.useState)(null);(0,N.useEffect)(()=>{Ie(Pe?document.querySelector(`.admin-footer`):null)},[Pe]);let Le=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-emoji`,onClick:()=>h(e=>!e),disabled:u,"aria-label":`Emoji`,"aria-expanded":m,children:(0,I.jsx)(ye,{size:22})}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:()=>_(!0),disabled:u,"aria-label":`Attach files`,children:(0,I.jsx)(r,{size:22})})]});return(0,I.jsxs)(`div`,{className:`wa-reply${y?` wa-reply-drag-over`:``}`,onDragOver:Ae,onDragLeave:je,onDrop:Me,children:[g&&(0,I.jsx)(Ce,{sessionKey:n,onPick:e=>{ee(t=>[...t,e].slice(0,5)),_(!1)},onClose:()=>_(!1)}),m&&(0,I.jsx)(Se,{onSelect:Oe}),f&&(0,I.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:f}),w&&(0,I.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:w}),ae===`error`&&D&&(0,I.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:D}),(C.length>0||x.length>0)&&(0,I.jsxs)(`div`,{className:`wa-reply-attachments`,children:[C.map((e,t)=>(0,I.jsxs)(`div`,{className:`wa-reply-chip`,children:[Ne(e.type),(0,I.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>ne(t),"aria-label":`Remove ${e.name}`,children:(0,I.jsx)(v,{size:12})})]},`f-${t}`)),x.map((e,t)=>(0,I.jsxs)(`div`,{className:`wa-reply-chip wa-reply-chip-ref`,children:[(0,I.jsx)(ce,{size:14}),(0,I.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>ee(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove ${e.name}`,children:(0,I.jsx)(v,{size:12})})]},`r-${t}`))]}),i&&(0,I.jsxs)(`div`,{className:`wa-reply-quote`,children:[(0,I.jsxs)(`div`,{className:`wa-reply-quote-body`,children:[(0,I.jsx)(`span`,{className:`wa-reply-quote-who`,children:i.fromMe?`You`:i.senderName??`Contact`}),(0,I.jsx)(`span`,{className:`wa-reply-quote-text`,children:i.body||`Message`})]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-quote-cancel`,onClick:()=>s?.(),"aria-label":`Cancel reply`,children:(0,I.jsx)(v,{size:14})})]}),!le&&(0,I.jsx)(`div`,{className:`wa-reply-resize-handle`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize input — drag up to enlarge`,tabIndex:0,onPointerDown:L,onKeyDown:De}),(0,I.jsx)(`div`,{className:`wa-reply-row`,children:le?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:fe,"aria-label":`Cancel recording`,children:(0,I.jsx)(a,{size:20})}),(0,I.jsxs)(`span`,{className:`wa-rec-live`,role:`status`,children:[(0,I.jsx)(`span`,{className:`wa-rec-dot`,"aria-hidden":!0}),Te(E)]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void de(),"aria-label":`Stop recording`,children:(0,I.jsx)(o,{size:20})})]}):(0,I.jsxs)(I.Fragment,{children:[Fe?(0,we.createPortal)((0,I.jsx)(`div`,{className:`wa-reply-footer-actions`,children:Le}),Fe):Le,(0,I.jsxs)(`div`,{className:`wa-reply-inputwrap`,children:[(0,I.jsx)(`textarea`,{ref:S,className:`wa-reply-input`,value:c,rows:1,style:{height:`${j??_e??44}px`},placeholder:`Type a message`,disabled:u,onChange:e=>l(e.target.value),onKeyDown:V}),c.length===0&&(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-mic`,onClick:()=>void ue(),disabled:u,"aria-label":`Record voice note`,children:(0,I.jsx)(oe,{size:22})})]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void B(),disabled:!z,"aria-label":`Send`,children:(0,I.jsx)(M,{size:20})})]})})]})}function L({accountId:e,remoteJid:t,contactName:n,sessionKey:r,onBack:i}){let a=ne(t),o=t.split(`@`)[0],s=a?`Group`:n===`+${o}`?void 0:`+${o}`,[c,l]=(0,N.useState)(!1),[u,d]=(0,N.useState)(``),f=()=>{l(!1),d(``)},[p,m]=(0,N.useState)(null);return(0,I.jsxs)(`div`,{className:`wa-web`,children:[(0,I.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,I.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,I.jsx)(A,{size:20})}),(0,I.jsx)(E,{accountId:e,jid:t,sessionKey:r}),c?(0,I.jsxs)(`div`,{className:`wa-web-search`,children:[(0,I.jsx)(le,{size:18,"aria-hidden":!0}),(0,I.jsx)(`input`,{className:`wa-web-search-input`,type:`text`,autoFocus:!0,placeholder:`Search messages`,"aria-label":`Search messages`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&f()}}),(0,I.jsx)(`button`,{type:`button`,className:`wa-web-search-close`,onClick:f,"aria-label":`Close search`,children:(0,I.jsx)(v,{size:18})})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,I.jsx)(`span`,{className:`wa-web-name`,children:n}),s&&(0,I.jsx)(`span`,{className:`wa-web-subtitle`,children:s})]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-web-search-toggle`,onClick:()=>l(!0),"aria-label":`Search messages`,children:(0,I.jsx)(le,{size:20})})]})]}),(0,I.jsx)(`div`,{className:`wa-web-body`,children:(0,I.jsx)(k,{sessionId:``,projectDir:``,sessionKey:r,forceDeliveredOnly:!0,suppressDirectives:!0,store:{accountId:e,remoteJid:t},search:c?u:void 0,onReplyTo:m,groupThread:a})}),(0,I.jsx)(Ee,{accountId:e,remoteJid:t,sessionKey:r,replyTo:p,onClearReply:()=>m(null)})]})}function De(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||ue.has(e)&&(t.add(e),n.push(e)));return n}function R(e,t){return m(e,t)}function z({conversations:e,sessionKey:t,onBack:n}){let{zone:r}=re(),[i,a]=(0,N.useState)(null),o=C(e);return i?i.source===`store`&&i.accountId&&i.remoteJid?(0,I.jsx)(L,{accountId:i.accountId,remoteJid:i.remoteJid,contactName:w(i),sessionKey:t,onBack:()=>a(null)},b(i)):(0,I.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,I.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>a(null),"aria-label":`Back to conversations`,children:[(0,I.jsx)(A,{size:16}),` Back`]}),(0,I.jsx)(`span`,{className:`op-conv-title`,children:w(i)})]}),(0,I.jsx)(k,{sessionId:i.sessionId,projectDir:i.projectDir,sessionKey:t,forceDeliveredOnly:!0,suppressDirectives:i.source===`store`,store:i.source===`store`?{accountId:i.accountId,remoteJid:i.remoteJid}:void 0},b(i))]}):(0,I.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,I.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,I.jsx)(A,{size:16}),` Chat`]}),(0,I.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),o.map(e=>(0,I.jsxs)(`div`,{className:`op-conv-group`,children:[(0,I.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,I.jsx)(x,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{a(e)},children:[e.source===`store`&&e.accountId&&e.remoteJid&&(0,I.jsx)(E,{accountId:e.accountId,jid:e.remoteJid,sessionKey:t,className:`op-conv-avatar`,size:16}),(0,I.jsx)(`span`,{className:`op-conv-name`,children:w(e)}),e.modelGated&&(0,I.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,I.jsx)(de,{size:13})}),(0,I.jsx)(`span`,{className:`op-conv-when`,children:R(e.lastMessageAt,r)})]},b(e)))]},e.channel))]})}var B=/\.(png|jpe?g|gif|webp|svg)$/i;function Oe(e){return B.test(e)}function V(e){return e.entryPath??e.name}var ke=`maxy-data-view`,Ae=95*1024*1024,je=48*1024*1024;function Me(){return typeof window>`u`?`list`:window.localStorage.getItem(ke)===`grid`?`grid`:`list`}function Ne(){let[e,t]=(0,N.useState)(null),[n,r]=(0,N.useState)(!1);return(0,N.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,I.jsx)(y,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,I.jsx)(_,{cacheKey:e,children:(0,I.jsx)(`div`,{className:`data-page data-page-full`,children:(0,I.jsx)(Pe,{cacheKey:e})})})}):(0,I.jsx)(`div`,{className:`data-page`,children:(0,I.jsxs)(`div`,{className:`data-empty`,children:[(0,I.jsx)(`p`,{children:`You are not signed in.`}),(0,I.jsxs)(`p`,{children:[`Open the `,(0,I.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,I.jsx)(s,{surface:`gate`})}function Pe({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=h({initialCacheKey:e,surface:`data`});return(0,I.jsx)(He,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Fe(){if(typeof window>`u`)return`@home`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`@home`}function Ie(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`||e===`@home`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function Le(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function Re(e){return new Promise((t,n)=>e.file(t,n))}async function ze(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await Re(r),relpath:e});else if(r.isDirectory){let t=await Le(r.createReader());n.push(...await ze(t,e))}}return n}function Be(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function Ve({adminFetch:e,cacheKey:r,sessionRefetchNonce:o}){let{zone:l}=re(),[p,m]=(0,N.useState)(``),h=(0,N.useRef)(null),[g,_]=(0,N.useState)(``),[y,b]=(0,N.useState)(null),[x,ee]=(0,N.useState)(`hybrid`),[S,C]=(0,N.useState)(!1),[w,T]=(0,N.useState)(null),[te,ne]=(0,N.useState)(null),[ie,ae]=(0,N.useState)(0),[oe,E]=(0,N.useState)(!1),[D,se]=(0,N.useState)(()=>Fe()),[O,k]=(0,N.useState)(null),[A,ue]=(0,N.useState)(()=>Me()),[de,ge]=(0,N.useState)(null),[M,ye]=(0,N.useState)([]),[P,F]=(0,N.useState)(null),[xe,Se]=(0,N.useState)(0),[Ce,we]=(0,N.useState)(null),Te=(0,N.useRef)(null),Ee=M.slice(0,-1).map(e=>e.name).join(`/`),L=(()=>{let e=M.map(e=>e.name);return e.length>=2&&e[0]===`accounts`?`${e[0]}/${e[1]}`:null})(),R=P?Ee:D,z=(0,N.useCallback)(e=>R===`.`||R===``?e:`${R}/${e}`,[R]),[B,Ne]=(0,N.useState)(!1),[Pe,Le]=(0,N.useState)(!1),[Re,Ve]=(0,N.useState)(null),[He,Ue]=(0,N.useState)(!1),[H,U]=(0,N.useState)(null),[Ke,Ye]=(0,N.useState)(null),[Xe,Ze]=(0,N.useState)(null),[Qe,$e]=(0,N.useState)(!1),[et,tt]=(0,N.useState)(null),nt=(0,N.useRef)(null),[rt,W]=(0,N.useState)(0),[it,at]=(0,N.useState)(!1),[ot,st]=(0,N.useState)(``),[ct,lt]=(0,N.useState)(null),[ut,dt]=(0,N.useState)(``),[ft,pt]=(0,N.useState)(null),G=(()=>{let e=D===`.`?[]:D.split(`/`).filter(Boolean);return e.some(e=>e.startsWith(`@`))?!1:e.length>=2&&e[0]===`accounts`})(),[mt,ht]=(0,N.useState)(!1),gt=(0,N.useRef)(null),[_t,K]=(0,N.useState)(!1),vt=(0,N.useRef)(null);(0,N.useEffect)(()=>{let e=p.trim();if(!e){_(``),b(null),T(null);return}E(!1);let t=setTimeout(()=>_(e),300);return()=>clearTimeout(t)},[p]),(0,N.useEffect)(()=>{if(!g){C(!1);return}let t=!1;return C(!0),T(null),e(`/api/admin/graph-search?q=${encodeURIComponent(g)}&labels=FileArtifact&limit=20${oe?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(b(e.results),ee(e.mode??`hybrid`),ae(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||T(e instanceof Error?e.message:String(e))}).finally(()=>{t||C(!1)}),()=>{t=!0}},[g,e,o,oe]);let yt=(0,N.useMemo)(()=>y?De(y):[],[y]),q=te&&yt.includes(te)?te:null,bt=(0,N.useMemo)(()=>y?q?y.filter(e=>e.labels.includes(q)):y:null,[y,q]),xt=(0,N.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=n,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[r]);(0,N.useEffect)(()=>{if(!y)return;let e=y.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[y]),(0,N.useEffect)(()=>{let t=!1;return Ne(!0),Ve(null),e(`/api/admin/files?path=${encodeURIComponent(D===`.`?``:D)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(k(e.entries),ye(e.displayPath??[]),F(e.view??null),Se(typeof e.systemCount==`number`?e.systemCount:0))}).catch(e=>{t||(k([]),ye([]),F(null),Se(0),Ve(e instanceof Error?e.message:String(e)))}).finally(()=>{t||(Ne(!1),Le(!0))}),()=>{t=!0}},[e,D,rt,o]),(0,N.useEffect)(()=>{if(P!==null||!L||Te.current===L)return;Te.current=L;let t=!1;return e(`/api/admin/files?path=${encodeURIComponent(`${L}/@home`)}`).then(e=>e.ok?e.json():null).then(e=>{t||!e||we((e.entries??[]).map(e=>e.name))}).catch(e=>{console.warn(`[data-ui] op=rail-buckets status=error reason="${e instanceof Error?e.message:String(e)}"`)}),()=>{t=!0}},[e,P,L]),(0,N.useEffect)(()=>{Ie(D)},[D]);let St=(0,N.useCallback)(()=>{W(e=>e+1)},[]),J=(0,N.useCallback)(e=>{ht(!1),se(e)},[]),Ct=(0,N.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);m(``),T(null),ne(null),J(r)},[J]),wt=(0,N.useCallback)(()=>{if(!D.split(`/`).some(e=>e.startsWith(`@`))){if(D===`.`||D===``)return;let e=D.split(`/`).filter(Boolean);e.pop(),se(e.length===0?`.`:e.join(`/`));return}M.length!==0&&se(M.length>=2?M.slice(0,M.length-1).map(e=>e.name).join(`/`):`.`)},[D,M]),Tt=(0,N.useCallback)(e=>{pe(r,z(V(e)))},[z,r]),[Y,Et]=(0,N.useState)(!1),[X,Dt]=(0,N.useState)(new Set),Ot=(0,N.useRef)(null),Z=(0,N.useRef)(!1),kt=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,At=(0,N.useCallback)(e=>{Et(!0),Dt(new Set([e]))},[]),Q=(0,N.useCallback)(e=>{Et(!1),Dt(new Set)},[]),jt=(0,N.useCallback)(e=>{Dt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Mt=(0,N.useCallback)(e=>{Z.current=!1,Ot.current=setTimeout(()=>{Z.current=!0,At(e)},500)},[At]),$=(0,N.useCallback)(()=>{Ot.current&&=(clearTimeout(Ot.current),null)},[]),Nt=(0,N.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}Tt(e)},[Y,jt,Tt]),Pt=(0,N.useCallback)(e=>{ue(e),typeof window<`u`&&window.localStorage.setItem(ke,e)},[]),Ft=(0,N.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}ge({src:me(r,z(V(e))),alt:e.displayName??e.name})},[Y,jt,z,r]),It=(0,N.useCallback)(()=>(O??[]).filter(e=>e.kind===`file`&&X.has(e.name)),[O,X]),Lt=(0,N.useCallback)(()=>{if(X.size!==1)return null;let e=(O??[]).find(e=>X.has(e.name));return e&&!e.entryPath?e:null},[O,X]),Rt=(0,N.useCallback)(()=>(O??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&X.has(e.name)),[O,X]),zt=(0,N.useCallback)(()=>{let e=Rt(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?Tt(e[0]):e.length>=1&&fe(r,e.map(e=>z(V(e)))),Q(`action`)},[Rt,Tt,z,r,Q]),Bt=(0,N.useCallback)(async()=>{let t=It(),n=t.filter(e=>!e.protected),r=t.length-n.length;tt(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=z(V(t));try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){tt(e instanceof Error?e.message:String(e))}}W(e=>e+1),Q(`action`)},[It,z,e,Q]),Vt=(0,N.useCallback)(async()=>{let e=It();if(kt)try{let t=await Promise.all(e.map(async e=>{let t=z(V(e)),n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=await(await fetch(n)).blob();return new File([i],e.displayName??e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:t})&&await navigator.share({files:t})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[It,kt,z,r]),Ht=(0,N.useCallback)(()=>{nt.current?.click()},[]),Ut=(0,N.useCallback)((e,t={})=>{let n=(n,i,a)=>{let o=new URLSearchParams({session_key:r,path:D===`.`?``:D,filename:e.name});t.relpath&&o.set(`relpath`,t.relpath),t.token&&o.set(`token`,t.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let r=new XMLHttpRequest;r.open(`POST`,`/api/admin/files/upload?${o.toString()}`),r.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(r.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),r.onload=()=>{let e={};try{e=JSON.parse(r.responseText)}catch{}t({status:r.status,data:e})},r.onerror=()=>t({status:0,data:{}}),r.onabort=()=>t({status:0,data:{error:`aborted`}}),r.send(n)})};if(e.size<=Ae)return n(e,{},n=>t.onProgress?.(n,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/je);return(async()=>{let r={status:0,data:{}};for(let o=0;o<a;o++){let s=o*je;if(r=await n(e.slice(s,Math.min(s+je,e.size)),{uploadId:i,seq:String(o),total:String(a)},n=>t.onProgress?.(s+n,e.size)),!(r.status>=200&&r.status<300))return r}return r})()},[r,D]),Wt=(0,N.useCallback)(async e=>{Ye(null),Ue(!0),U({loaded:0,total:e.size});try{let{status:t,data:n}=await Ut(e,{onProgress:(e,t)=>U({loaded:e,total:t})});t>=200&&t<300&&n.path?(se(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),W(e=>e+1)):Ye(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{Ue(!1),U(null),nt.current&&(nt.current.value=``)}},[Ut]),Gt=(0,N.useCallback)(e=>{G&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),$e(!0))},[G]),Kt=(0,N.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||$e(!1)},[]),qt=(0,N.useCallback)(async e=>{e.preventDefault(),$e(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(n.length===0)return;if(!G){Ye(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);Ue(!0),Ye(null),Ze(null);try{let e=await ze(r),n=0,i=[];for(let r=0;r<e.length;r++){let{file:a,relpath:o}=e[r];U({loaded:0,total:a.size});let{status:s,data:c}=await Ut(a,{relpath:o,token:t,onProgress:(e,t)=>U({loaded:e,total:t})});if(s>=200&&s<300)n++;else{let e=s===0?`http=0`:Be(s,c.error);i.push(`${o} (${e})`)}}Ze(`Uploaded ${n}, skipped ${i.length}${i.length?`: ${i.join(`, `)}`:``}`),W(e=>e+1)}catch(e){Ye(e instanceof Error?e.message:String(e))}finally{Ue(!1),U(null)}},[G,Ut]),Jt=(0,N.useCallback)(async()=>{let t=ot.trim();if(t){pt(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:D===`.`?``:D,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);at(!1),st(``),W(e=>e+1)}catch(e){pt(e instanceof Error?e.message:String(e))}}},[e,ot,D]),Yt=(0,N.useCallback)(async()=>{if(!ct)return;let t=ut.trim();if(!t)return;pt(null);let n=z(ct);try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);lt(null),dt(``),Q(`action`),W(e=>e+1)}catch(e){pt(e instanceof Error?e.message:String(e))}},[e,ut,ct,z,Q]);(0,N.useEffect)(()=>{if(!mt)return;let e=e=>{gt.current&&!gt.current.contains(e.target)&&ht(!1)},t=e=>{e.key===`Escape`&&ht(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[mt]),(0,N.useEffect)(()=>{if(!_t)return;let e=e=>{vt.current&&!vt.current.contains(e.target)&&K(!1)},t=e=>{e.key===`Escape`&&K(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_t]);let Xt=(0,N.useCallback)(e=>M.slice(0,e+1).map(e=>e.name).join(`/`),[M]),Zt=M.length>=2,Qt=Zt?[{name:`.`,label:`data`},...M.slice(0,M.length-2).map((e,t)=>({name:Xt(t),label:e.displayName??e.name}))]:[];return Pe?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`data-toolbar`,children:[Y?(0,I.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>Q(`cancel`),"aria-label":`Cancel selection`,children:[(0,I.jsx)(v,{size:14}),` Cancel`]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`data-search-input`,children:[p===``&&(0,I.jsx)(le,{size:14}),(0,I.jsx)(`input`,{ref:h,type:`text`,value:p,onChange:e=>m(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),S&&(0,I.jsx)(u,{size:14,className:`spin`}),p!==``&&(0,I.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{m(``),h.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,I.jsx)(v,{size:14})})]}),(0,I.jsxs)(`div`,{className:`data-toolbar-actions`,ref:vt,children:[(0,I.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>K(e=>!e),"aria-haspopup":`menu`,"aria-expanded":_t,"aria-label":`File actions`,title:`File actions`,children:(0,I.jsx)(j,{size:16})}),(0,I.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":_t?`true`:void 0,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{St(),K(!1)},disabled:B,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[B?(0,I.jsx)(u,{size:16,className:`spin`}):(0,I.jsx)(t,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn admin-btn-cta`,onClick:()=>{Ht(),K(!1)},disabled:He||!G,title:G?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[He?H&&H.total>0?(0,I.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(H.loaded/H.total*100),`%`]}):(0,I.jsx)(u,{size:16,className:`spin`}):(0,I.jsx)(be,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{at(e=>!e),st(``),pt(null),K(!1)},disabled:He||!G,title:G?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,I.jsx)(he,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Pt(A===`grid`?`list`:`grid`),K(!1)},title:A===`grid`?`List view`:`Grid view`,"aria-label":A===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":A===`grid`,children:[A===`grid`?(0,I.jsx)(ve,{size:16}):(0,I.jsx)(_e,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:A===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,I.jsxs)(`div`,{className:`data-breadcrumbs`,children:[D!==`.`&&(0,I.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:wt,title:`Up one level`,"aria-label":`Up one level`,children:(0,I.jsx)(f,{size:14})}),Zt?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`data-crumb-wrap`,ref:gt,children:[(0,I.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>ht(e=>!e),"aria-haspopup":`menu`,"aria-expanded":mt,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),mt&&(0,I.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Qt.map(e=>(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>J(e.name),title:e.label,children:e.label},e.name))})]}),[M.length-2,M.length-1].map(e=>{let t=M[e];return(0,I.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,I.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,I.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Xt(e)),title:t.name,children:t.displayName??t.name})]},Xt(e))})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(`.`),children:`data`}),M.map((e,t)=>(0,I.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,I.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,I.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Xt(t)),title:e.name,children:e.displayName??e.name})]},Xt(t)))]})]}),it&&(0,I.jsxs)(`div`,{className:`data-inline-form`,children:[(0,I.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:ot,autoFocus:!0,onChange:e=>st(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Jt(),e.key===`Escape`&&at(!1)}}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Jt,children:`Create`}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>at(!1),children:`Cancel`})]}),ct&&(0,I.jsxs)(`div`,{className:`data-inline-form`,children:[(0,I.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:ut,autoFocus:!0,onChange:e=>dt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Yt(),e.key===`Escape`&<(null)}}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Yt,children:`Rename`}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>lt(null),children:`Cancel`})]}),ft&&(0,I.jsx)(`div`,{className:`data-error`,children:ft}),(0,I.jsx)(`input`,{type:`file`,ref:nt,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Wt(t)}})]}),(0,I.jsxs)(`div`,{className:`data-body`,"data-drag-active":Qe?`true`:void 0,onDragEnter:Gt,onDragOver:Gt,onDragLeave:Kt,onDrop:qt,children:[P===null&&L&&Ce&&Ce.length>0&&(0,I.jsxs)(`aside`,{className:`data-rail`,"aria-label":`Folders`,children:[(0,I.jsx)(`span`,{className:`data-rail-label`,children:`Folders`}),(0,I.jsx)(`ul`,{className:`data-rail-list`,children:Ce.map(e=>{let t=`${L}/${e}`,n=D===t||D.startsWith(`${t}/`);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,className:`data-rail-item`,"aria-current":n?`true`:void 0,onClick:()=>J(t),children:[(0,I.jsx)(d,{size:13}),(0,I.jsx)(`span`,{className:`data-rail-item-name`,children:e})]})},e)})})]}),(0,I.jsxs)(`div`,{className:`data-content`,children:[(w!==null||y!==null)&&(0,I.jsxs)(`section`,{className:`data-panel admin-card`,children:[w&&(0,I.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,w]}),yt.length>0&&(0,I.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:yt.map(e=>{let t=e===q;return(0,I.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>ne(t?null:e),children:Ge([e])??e},e)})}),y&&!S&&(0,I.jsxs)(`div`,{className:`data-results-meta`,children:[bt.length,` of `,y.length,` result`,y.length===1?``:`s`]}),y&&!S&&!q&&ie>0&&!oe&&(0,I.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>E(!0),children:[ie,` low-confidence result`,ie===1?``:`s`,` hidden — show all`]}),y&&!S&&!q&&oe&&(0,I.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>E(!1),children:`Showing all results — hide low-confidence`}),y&&y.length===0&&!S&&(0,I.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),bt&&bt.length>0&&(0,I.jsx)(`ul`,{className:`data-results`,children:bt.map(e=>(0,I.jsx)(We,{hit:e,mode:x,onDownload:xt,onLocate:Ct},e.nodeId))})]}),(0,I.jsxs)(`section`,{className:`data-panel data-panel--wide admin-card`,children:[H&&(0,I.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":H.total>0?Math.round(H.loaded/H.total*100):void 0,children:[(0,I.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,I.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${H.total>0?Math.round(H.loaded/H.total*100):0}%`}})}),(0,I.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,H.total>0?`${Math.round(H.loaded/H.total*100)}%`:``]})]}),Ke&&(0,I.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,Ke]}),Xe&&(0,I.jsx)(`div`,{className:`data-status`,children:Xe}),et&&(0,I.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,et]}),Re&&(0,I.jsx)(`div`,{className:`data-error`,children:Re}),B&&(0,I.jsxs)(`div`,{className:`data-loading`,children:[(0,I.jsx)(u,{size:14,className:`spin`}),` Loading…`]}),!B&&P!==`home`&&O&&O.length===0&&!Re&&(0,I.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!B&&P===`home`&&O&&(0,I.jsxs)(`ul`,{className:`routine-list data-home-list`,children:[O.map(e=>(0,I.jsxs)(`li`,{className:`data-home-card`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(z(e.name)),children:[(0,I.jsx)(`span`,{className:`data-home-card-title`,children:e.name}),(0,I.jsx)(`span`,{className:`data-home-card-count`,children:e.childCount===null||e.childCount===void 0?`—`:`${e.childCount} ${e.childCount===1?`item`:`items`}`})]}),(0,I.jsxs)(`ul`,{className:`data-home-card-children`,children:[e.childCount===null&&(0,I.jsx)(`li`,{className:`data-home-card-error`,children:`Could not read this folder.`}),e.childCount===0&&(0,I.jsx)(`li`,{className:`data-home-card-empty`,children:`Empty.`}),(e.children??[]).map(e=>(0,I.jsxs)(`li`,{className:`data-home-card-child`,children:[e.kind===`directory`?(0,I.jsx)(d,{size:12}):(0,I.jsx)(ce,{size:12}),(0,I.jsx)(`span`,{className:`data-home-card-child-name`,children:e.name})]},e.name)),typeof e.childCount==`number`&&e.childCount>(e.children?.length??0)&&(0,I.jsxs)(`li`,{className:`data-home-card-more`,children:[`+`,e.childCount-(e.children?.length??0),` more`]})]})]},e.name)),(0,I.jsxs)(`li`,{className:`data-home-card`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(z(`@system`)),children:[(0,I.jsx)(`span`,{className:`data-home-card-title`,children:`system`}),(0,I.jsxs)(`span`,{className:`data-home-card-count`,children:[xe,` `,xe===1?`item`:`items`]})]}),(0,I.jsx)(`ul`,{className:`data-home-card-children`,children:(0,I.jsx)(`li`,{className:`data-home-card-empty`,children:`Platform and plugin folders.`})})]})]}),!B&&P!==`home`&&O&&O.length>0&&A===`grid`&&(0,I.jsx)(`ul`,{className:`data-grid`,children:O.map(e=>{let t=e.displayName??e.name,n=Y&&X.has(e.name);if(e.kind===`directory`)return(0,I.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}J(z(e.name))},children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,I.jsx)(d,{size:28,className:`data-grid-glyph`}),(0,I.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let i=Oe(V(e)),a=z(V(e));return(0,I.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>i?Ft(e):Nt(e),title:Y?void 0:i?`Preview ${t}`:`Download ${t}`,children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,I.jsx)(`img`,{className:`data-grid-thumb`,src:me(r,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,I.jsx)(ce,{size:28,className:`data-grid-glyph`}),(0,I.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!i&&(0,I.jsx)(`span`,{className:`data-grid-sub`,children:qe(e.sizeBytes)})]})},e.name)}return(0,I.jsx)(`li`,{className:`data-grid-cell`,children:(0,I.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,I.jsx)(ce,{size:28,className:`data-grid-glyph`}),(0,I.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,I.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!B&&P!==`home`&&O&&O.length>0&&A===`list`&&(0,I.jsx)(`ul`,{className:`data-entries`,children:O.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=Y&&X.has(e.name);return(0,I.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}J(z(e.name))},children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,I.jsx)(d,{size:14}),(0,I.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=Y&&X.has(e.name);return(0,I.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>Nt(e),title:Y?void 0:`Download ${t}`,children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`data-entry-text`,children:[(0,I.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,I.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Je(e.modifiedAt,l)}`,children:[qe(e.sizeBytes),` · `,Je(e.modifiedAt,l)]})]})]})},e.name)}return(0,I.jsx)(`li`,{className:`data-entry`,children:(0,I.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,I.jsxs)(`span`,{className:`data-entry-text`,children:[(0,I.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,I.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]})]}),Y&&(0,I.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,I.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Vt,disabled:!kt||X.size===0,title:kt?`Share selected files`:`Sharing is not supported on this device`,children:[(0,I.jsx)(c,{size:16}),` Share`]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:zt,disabled:X.size===0,children:[(0,I.jsx)(n,{size:16}),` Download`]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=Lt();e&&(lt(e.name),dt(e.name))},disabled:!Lt(),children:[(0,I.jsx)(i,{size:16}),` Rename`]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:Bt,disabled:X.size===0,children:[(0,I.jsx)(a,{size:16}),` Delete`]})]})}),de&&(0,I.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":de.alt,onClick:()=>ge(null),children:(0,I.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:de.src,alt:de.alt})})]}):(0,I.jsx)(s,{surface:`gate`})}function He({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){let r=(0,N.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),i=(0,N.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[a,o]=(0,N.useState)([]),[s,c]=(0,N.useState)(`files`),{subAccounts:u,activeAccountId:d,switching:f,switchAccount:p}=ee(t);return(0,N.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`/api/operator-conversations/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||o(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,I.jsxs)(`main`,{className:`data-main`,children:[(0,I.jsx)(l,{variant:`operator`,onNavigate:i,onOpenConversations:a.length>0?()=>c(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:u,activeAccountId:d,switchingAccount:f,onSwitchAccount:p}),s===`conversations`?(0,I.jsx)(z,{conversations:a,sessionKey:t,onBack:()=>c(`files`)}):(0,I.jsx)(Ve,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function Ue({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=h({initialCacheKey:e,surface:`data`});return(0,I.jsx)(`div`,{className:`data-page`,children:(0,I.jsx)(`main`,{className:`data-main`,children:(0,I.jsx)(Ve,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function We({hit:e,mode:t,onDownload:n,onLocate:r}){let{zone:i}=re(),a=H(e.properties),o=U(e.properties),s=Ge(e.labels),c=Ke(e.properties),[l,u]=(0,N.useState)(!1),f=o&&o.length>280,p=l||!f?o:o?.slice(0,280)+`…`,m=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,h=e.properties.relativePath,g=typeof h==`string`&&h.length>0,_=g?h.lastIndexOf(`/`):-1,v=g?_===-1?`data`:h.slice(0,_):null;return(0,I.jsxs)(`li`,{className:`data-result`,children:[(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${a??s??`file`}`,children:[s&&(0,I.jsx)(`div`,{className:`data-result-header`,children:(0,I.jsx)(`span`,{className:`data-result-labels`,children:s})}),a&&(0,I.jsx)(`div`,{className:`data-result-title`,children:a}),o&&(0,I.jsx)(`pre`,{className:`data-result-body`,children:p}),(0,I.jsxs)(`div`,{className:`data-result-scores`,children:[c&&(0,I.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Je(c,i),` · `]}),m]})]}),g&&(0,I.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${v}`,"aria-label":`Locate in ${v}`,children:[(0,I.jsx)(d,{size:12}),v]}),f&&(0,I.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>u(e=>!e),children:l?`Show less`:`Show more`})]})}function Ge(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function H(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function U(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function Ke(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function qe(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function Je(e,t){return m(e,t)||`—`}export{Ue as n,L as r,Ne as t};
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{F as t,G as n,I as r,L as i,M as a,N as o,O as s,P as c,T as l,V as u,W as d,Y as f,Z as p,_ as m,at as h,ct as g,g as _,j as v,k as y,l as b,m as x,n as ee,nt as S,o as C,s as w,st as T,t as te,u as ne,v as re}from"./useMediaQuery-Baf4Huvv.js";import{E as ie,O as ae,T as oe,f as E,k as D,n as se,r as O,s as k}from"./useVoiceRecorder-BaAtMu9T.js";import{t as A}from"./chevron-left-BYH5vH4S.js";import{t as ce}from"./file-text-DDCrqbWB.js";import{i as le,t as ue}from"./graph-labels-B2PrHK6O.js";import{t as de}from"./triangle-alert-CYwHTcvU.js";import{i as fe,n as pe,t as me}from"./file-download-DbNIjWiK.js";var j=p(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),he=p(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ge=p(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),_e=p(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),ve=p(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),M=p(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),ye=p(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),be=p(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),N=e(g(),1);function P(){let[e,t]=(0,N.useState)([]),[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(null),o=(0,N.useRef)(null),s=(0,N.useCallback)(e=>{a(null);let n=e.find(e=>!O(e.type,D));if(n){a(`Unsupported file type: "${n.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, zip, voice notes.`);return}let r=e.find(e=>e.size>ae);if(r){a(`"${r.name}" exceeds the 50 MB limit.`);return}t(t=>[...t,...e].slice(0,5))},[]);return{pendingFiles:e,setPendingFiles:t,isDragOver:n,attachError:i,setAttachError:a,fileInputRef:o,addFiles:s,clearFiles:(0,N.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,N.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,N.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,N.useCallback)(()=>{r(!1)},[]),onDrop:(0,N.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var F=[[128512],[128515],[128516],[128513],[128518],[128517],[128514],[129315],[128578],[128579],[128521],[128522],[128519],[128525],[128536],[128535],[128540],[128541],[129303],[129300],[128528],[128566],[128564],[128526],[129395],[128546],[128557],[128548],[128544],[128533],[128556],[129393],[128077],[128078],[128076],[128591],[128079],[128588],[128170],[128075],[129309],[10084,65039],[128293],[11088],[127881],[10024],[128175],[128064]].map(e=>String.fromCodePoint(...e));function xe(e,t,n,r){let i=e.length,a=Math.max(0,Math.min(n??i,i)),o=Math.max(a,Math.min(r??a,i));return{value:e.slice(0,a)+t+e.slice(o),caret:a+t.length}}var I=S();function Se({onSelect:e}){return(0,I.jsx)(`div`,{className:`wa-emoji-popover`,role:`menu`,"aria-label":`Emoji picker`,children:F.map((t,n)=>(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`wa-emoji-item`,onClick:()=>e(t),children:t},n))})}function Ce({sessionKey:e,onPick:t,onClose:n}){let[r,i]=(0,N.useState)(``),[a,o]=(0,N.useState)(null),[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(!1),f=(0,N.useCallback)(t=>{u(!0),c(null),fetch(`/api/admin/files?path=${encodeURIComponent(t)}&session_key=${encodeURIComponent(e)}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not list files`);return t}).then(e=>{o(e),i(e.path===`.`?``:e.path)}).catch(e=>c(e instanceof Error?e.message:String(e))).finally(()=>u(!1))},[e]);(0,N.useEffect)(()=>{f(``)},[f]);let p=e=>f(r?`${r}/${e}`:e),m=()=>{let e=r.split(`/`).filter(Boolean);e.pop(),f(e.join(`/`))},h=e=>{let n=e.entryPath??e.name;t({path:r?`${r}/${n}`:n,name:e.displayName??e.name})};return(0,I.jsx)(`div`,{className:`wa-picker-backdrop`,role:`dialog`,"aria-label":`Choose a device file`,onClick:n,children:(0,I.jsxs)(`div`,{className:`wa-picker`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`wa-picker-head`,children:[r&&(0,I.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:m,"aria-label":`Up one folder`,children:(0,I.jsx)(A,{size:18})}),(0,I.jsx)(`span`,{className:`wa-picker-title`,children:r||`Device storage`}),(0,I.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:n,"aria-label":`Close file picker`,children:(0,I.jsx)(v,{size:18})})]}),s&&(0,I.jsx)(`p`,{className:`wa-picker-error`,role:`alert`,children:s}),l&&(0,I.jsx)(`p`,{className:`wa-picker-empty`,children:`Loading…`}),a&&!l&&(0,I.jsxs)(`ul`,{className:`wa-picker-list`,children:[a.entries.length===0&&(0,I.jsx)(`li`,{className:`wa-picker-empty`,children:`This folder is empty.`}),a.entries.map(e=>(0,I.jsx)(`li`,{children:e.kind===`directory`?(0,I.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>p(e.name),children:[(0,I.jsx)(d,{size:16,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):e.kind===`file`?(0,I.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>h(e),children:[(0,I.jsx)(ce,{size:16,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):null},e.name))]})]})})}var we=T();function Te(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function Ee({accountId:e,remoteJid:t,sessionKey:n,replyTo:i,onClearReply:s}){let[c,l]=(0,N.useState)(``),[u,d]=(0,N.useState)(!1),[f,p]=(0,N.useState)(null),[m,h]=(0,N.useState)(!1),[g,_]=(0,N.useState)(!1),[y,b]=(0,N.useState)(!1),[x,ee]=(0,N.useState)([]),S=(0,N.useRef)(null),{pendingFiles:C,attachError:w,addFiles:T,removeFile:ne,clearFiles:re}=P(),{state:ae,elapsedSeconds:E,errorMessage:D,start:O,send:k,discard:A}=se(),le=ae===`recording`||ae===`paused`,ue=(0,N.useCallback)(()=>{O()},[O]),de=(0,N.useCallback)(async()=>{let e=await k();if(e){let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`;T([new File([e],`voice-note${t}`,{type:e.type})])}},[E,k,T]),fe=(0,N.useCallback)(()=>{A()},[E,A]),pe=(0,N.useRef)(!1),me=()=>Math.round((typeof window>`u`?900:window.innerHeight)/3),[j,he]=(0,N.useState)(null),[_e,ve]=(0,N.useState)(null),be=(0,N.useRef)(null),F=(0,N.useCallback)(e=>{let t=be.current;t&&he(Math.min(me(),Math.max(44,t.startH+(t.startY-e.clientY))))},[]),Ee=(0,N.useCallback)(()=>{be.current=null,window.removeEventListener(`pointermove`,F),window.removeEventListener(`pointerup`,Ee)},[F]),L=(0,N.useCallback)(e=>{be.current={startY:e.clientY,startH:S.current?.offsetHeight??44},window.addEventListener(`pointermove`,F),window.addEventListener(`pointerup`,Ee),e.preventDefault()},[F,Ee]),De=(0,N.useCallback)(e=>{let t=j??S.current?.offsetHeight??44,n=null;e.key===`ArrowUp`?(e.preventDefault(),n=Math.min(me(),t+24)):e.key===`ArrowDown`&&(e.preventDefault(),n=Math.max(44,t-24)),n!==null&&he(n)},[j]),R=(0,N.useRef)(``);(0,N.useEffect)(()=>{let e=S.current;if(!e)return;let t=R.current!==``&&c===``;if(R.current=c,j!==null){t&&he(null);return}let n=e.style.height;e.style.height=`auto`;let r=Math.min(me(),Math.max(44,e.scrollHeight));e.style.height=n,ve(r)},[c,j]);let z=(c.trim().length>0||C.length>0||x.length>0)&&!u,B=(0,N.useCallback)(async()=>{if(!pe.current&&!(c.trim().length===0&&C.length===0&&x.length===0)){pe.current=!0,d(!0),p(null);try{let r=`/api/whatsapp-reader/reply?session_key=${encodeURIComponent(n)}`,a;if(C.length>0||x.length>0){let n=new FormData;n.append(`accountId`,e),n.append(`remoteJid`,t),c.trim()&&n.append(`text`,c);for(let e of C)n.append(`files`,e);for(let e of x)n.append(`fileRefs`,e.path);i&&n.append(`quotedId`,i.msgKeyId),a=await fetch(r,{method:`POST`,body:n})}else a=await fetch(r,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accountId:e,remoteJid:t,text:c,...i?{quotedId:i.msgKeyId}:{}})});let o=await a.json().catch(()=>({}));if(!a.ok){p(o.error??`Send failed.`),console.warn(`[operator-ui] op=reply-fail remoteJid=${t} error=${o.error??`unknown`}`);return}l(``),re(),ee([]),s?.()}catch(e){p(`Could not reach the server. Try again.`),console.warn(`[operator-ui] op=reply-fail remoteJid=${t} error=${String(e)}`)}finally{pe.current=!1,d(!1)}}},[c,C,x,i,s,e,t,n,re]),Oe=(0,N.useCallback)(e=>{let t=S.current,{value:n,caret:r}=xe(c,e,t?t.selectionStart:null,t?t.selectionEnd:null);l(n),h(!1),requestAnimationFrame(()=>{let e=S.current;e&&(e.focus(),e.setSelectionRange(r,r))})},[c]),V=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),z&&B())},ke=e=>e.dataTransfer.types.includes(`Files`),Ae=(0,N.useCallback)(e=>{ke(e)&&(e.preventDefault(),b(!0))},[]),je=(0,N.useCallback)(()=>b(!1),[]),Me=(0,N.useCallback)(e=>{if(!ke(e))return;e.preventDefault(),b(!1);let t=[...e.dataTransfer.files];t.length!==0&&(Math.max(0,C.length+t.length-5),T(t))},[C.length,T]),Ne=e=>e.startsWith(`image/`)?(0,I.jsx)(ge,{size:14}):e===`application/pdf`?(0,I.jsx)(ce,{size:14}):(0,I.jsx)(ie,{size:14}),Pe=te(`(max-width: 720px)`),[Fe,Ie]=(0,N.useState)(null);(0,N.useEffect)(()=>{Ie(Pe?document.querySelector(`.admin-footer`):null)},[Pe]);let Le=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-emoji`,onClick:()=>h(e=>!e),disabled:u,"aria-label":`Emoji`,"aria-expanded":m,children:(0,I.jsx)(ye,{size:22})}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:()=>_(!0),disabled:u,"aria-label":`Attach files`,children:(0,I.jsx)(r,{size:22})})]});return(0,I.jsxs)(`div`,{className:`wa-reply${y?` wa-reply-drag-over`:``}`,onDragOver:Ae,onDragLeave:je,onDrop:Me,children:[g&&(0,I.jsx)(Ce,{sessionKey:n,onPick:e=>{ee(t=>[...t,e].slice(0,5)),_(!1)},onClose:()=>_(!1)}),m&&(0,I.jsx)(Se,{onSelect:Oe}),f&&(0,I.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:f}),w&&(0,I.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:w}),ae===`error`&&D&&(0,I.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:D}),(C.length>0||x.length>0)&&(0,I.jsxs)(`div`,{className:`wa-reply-attachments`,children:[C.map((e,t)=>(0,I.jsxs)(`div`,{className:`wa-reply-chip`,children:[Ne(e.type),(0,I.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>ne(t),"aria-label":`Remove ${e.name}`,children:(0,I.jsx)(v,{size:12})})]},`f-${t}`)),x.map((e,t)=>(0,I.jsxs)(`div`,{className:`wa-reply-chip wa-reply-chip-ref`,children:[(0,I.jsx)(ce,{size:14}),(0,I.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>ee(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove ${e.name}`,children:(0,I.jsx)(v,{size:12})})]},`r-${t}`))]}),i&&(0,I.jsxs)(`div`,{className:`wa-reply-quote`,children:[(0,I.jsxs)(`div`,{className:`wa-reply-quote-body`,children:[(0,I.jsx)(`span`,{className:`wa-reply-quote-who`,children:i.fromMe?`You`:i.senderName??`Contact`}),(0,I.jsx)(`span`,{className:`wa-reply-quote-text`,children:i.body||`Message`})]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-quote-cancel`,onClick:()=>s?.(),"aria-label":`Cancel reply`,children:(0,I.jsx)(v,{size:14})})]}),!le&&(0,I.jsx)(`div`,{className:`wa-reply-resize-handle`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize input — drag up to enlarge`,tabIndex:0,onPointerDown:L,onKeyDown:De}),(0,I.jsx)(`div`,{className:`wa-reply-row`,children:le?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:fe,"aria-label":`Cancel recording`,children:(0,I.jsx)(a,{size:20})}),(0,I.jsxs)(`span`,{className:`wa-rec-live`,role:`status`,children:[(0,I.jsx)(`span`,{className:`wa-rec-dot`,"aria-hidden":!0}),Te(E)]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void de(),"aria-label":`Stop recording`,children:(0,I.jsx)(o,{size:20})})]}):(0,I.jsxs)(I.Fragment,{children:[Fe?(0,we.createPortal)((0,I.jsx)(`div`,{className:`wa-reply-footer-actions`,children:Le}),Fe):Le,(0,I.jsxs)(`div`,{className:`wa-reply-inputwrap`,children:[(0,I.jsx)(`textarea`,{ref:S,className:`wa-reply-input`,value:c,rows:1,style:{height:`${j??_e??44}px`},placeholder:`Type a message`,disabled:u,onChange:e=>l(e.target.value),onKeyDown:V}),c.length===0&&(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-mic`,onClick:()=>void ue(),disabled:u,"aria-label":`Record voice note`,children:(0,I.jsx)(oe,{size:22})})]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void B(),disabled:!z,"aria-label":`Send`,children:(0,I.jsx)(M,{size:20})})]})})]})}function L({accountId:e,remoteJid:t,contactName:n,sessionKey:r,onBack:i}){let a=ne(t),o=t.split(`@`)[0],s=a?`Group`:n===`+${o}`?void 0:`+${o}`,[c,l]=(0,N.useState)(!1),[u,d]=(0,N.useState)(``),f=()=>{l(!1),d(``)},[p,m]=(0,N.useState)(null);return(0,I.jsxs)(`div`,{className:`wa-web`,children:[(0,I.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,I.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,I.jsx)(A,{size:20})}),(0,I.jsx)(E,{accountId:e,jid:t,sessionKey:r}),c?(0,I.jsxs)(`div`,{className:`wa-web-search`,children:[(0,I.jsx)(le,{size:18,"aria-hidden":!0}),(0,I.jsx)(`input`,{className:`wa-web-search-input`,type:`text`,autoFocus:!0,placeholder:`Search messages`,"aria-label":`Search messages`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&f()}}),(0,I.jsx)(`button`,{type:`button`,className:`wa-web-search-close`,onClick:f,"aria-label":`Close search`,children:(0,I.jsx)(v,{size:18})})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,I.jsx)(`span`,{className:`wa-web-name`,children:n}),s&&(0,I.jsx)(`span`,{className:`wa-web-subtitle`,children:s})]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-web-search-toggle`,onClick:()=>l(!0),"aria-label":`Search messages`,children:(0,I.jsx)(le,{size:20})})]})]}),(0,I.jsx)(`div`,{className:`wa-web-body`,children:(0,I.jsx)(k,{sessionId:``,projectDir:``,sessionKey:r,forceDeliveredOnly:!0,suppressDirectives:!0,store:{accountId:e,remoteJid:t},search:c?u:void 0,onReplyTo:m,groupThread:a})}),(0,I.jsx)(Ee,{accountId:e,remoteJid:t,sessionKey:r,replyTo:p,onClearReply:()=>m(null)})]})}function De(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||ue.has(e)&&(t.add(e),n.push(e)));return n}function R(e,t){return m(e,t)}function z({conversations:e,sessionKey:t,onBack:n}){let{zone:r}=re(),[i,a]=(0,N.useState)(null),o=C(e);return i?i.source===`store`&&i.accountId&&i.remoteJid?(0,I.jsx)(L,{accountId:i.accountId,remoteJid:i.remoteJid,contactName:w(i),sessionKey:t,onBack:()=>a(null)},b(i)):(0,I.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,I.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>a(null),"aria-label":`Back to conversations`,children:[(0,I.jsx)(A,{size:16}),` Back`]}),(0,I.jsx)(`span`,{className:`op-conv-title`,children:w(i)})]}),(0,I.jsx)(k,{sessionId:i.sessionId,projectDir:i.projectDir,sessionKey:t,forceDeliveredOnly:!0,suppressDirectives:i.source===`store`,store:i.source===`store`?{accountId:i.accountId,remoteJid:i.remoteJid}:void 0},b(i))]}):(0,I.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,I.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,I.jsx)(A,{size:16}),` Chat`]}),(0,I.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),o.map(e=>(0,I.jsxs)(`div`,{className:`op-conv-group`,children:[(0,I.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,I.jsx)(x,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{a(e)},children:[e.source===`store`&&e.accountId&&e.remoteJid&&(0,I.jsx)(E,{accountId:e.accountId,jid:e.remoteJid,sessionKey:t,className:`op-conv-avatar`,size:16}),(0,I.jsx)(`span`,{className:`op-conv-name`,children:w(e)}),e.modelGated&&(0,I.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,I.jsx)(de,{size:13})}),(0,I.jsx)(`span`,{className:`op-conv-when`,children:R(e.lastMessageAt,r)})]},b(e)))]},e.channel))]})}var B=/\.(png|jpe?g|gif|webp|svg)$/i;function Oe(e){return B.test(e)}function V(e){return e.entryPath??e.name}var ke=`maxy-data-view`,Ae=95*1024*1024,je=48*1024*1024;function Me(){return typeof window>`u`?`list`:window.localStorage.getItem(ke)===`grid`?`grid`:`list`}function Ne(){let[e,t]=(0,N.useState)(null),[n,r]=(0,N.useState)(!1);return(0,N.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,I.jsx)(y,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,I.jsx)(_,{cacheKey:e,children:(0,I.jsx)(`div`,{className:`data-page data-page-full`,children:(0,I.jsx)(Pe,{cacheKey:e})})})}):(0,I.jsx)(`div`,{className:`data-page`,children:(0,I.jsxs)(`div`,{className:`data-empty`,children:[(0,I.jsx)(`p`,{children:`You are not signed in.`}),(0,I.jsxs)(`p`,{children:[`Open the `,(0,I.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,I.jsx)(s,{surface:`gate`})}function Pe({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=h({initialCacheKey:e,surface:`data`});return(0,I.jsx)(He,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Fe(){if(typeof window>`u`)return`@home`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`@home`}function Ie(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`||e===`@home`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function Le(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function Re(e){return new Promise((t,n)=>e.file(t,n))}async function ze(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await Re(r),relpath:e});else if(r.isDirectory){let t=await Le(r.createReader());n.push(...await ze(t,e))}}return n}function Be(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function Ve({adminFetch:e,cacheKey:r,sessionRefetchNonce:o}){let{zone:l}=re(),[p,m]=(0,N.useState)(``),h=(0,N.useRef)(null),[g,_]=(0,N.useState)(``),[y,b]=(0,N.useState)(null),[x,ee]=(0,N.useState)(`hybrid`),[S,C]=(0,N.useState)(!1),[w,T]=(0,N.useState)(null),[te,ne]=(0,N.useState)(null),[ie,ae]=(0,N.useState)(0),[oe,E]=(0,N.useState)(!1),[D,se]=(0,N.useState)(()=>Fe()),[O,k]=(0,N.useState)(null),[A,ue]=(0,N.useState)(()=>Me()),[de,ge]=(0,N.useState)(null),[M,ye]=(0,N.useState)([]),[P,F]=(0,N.useState)(null),[xe,Se]=(0,N.useState)(0),[Ce,we]=(0,N.useState)(null),Te=(0,N.useRef)(null),Ee=M.slice(0,-1).map(e=>e.name).join(`/`),L=(()=>{let e=M.map(e=>e.name);return e.length>=2&&e[0]===`accounts`?`${e[0]}/${e[1]}`:null})(),R=P?Ee:D,z=(0,N.useCallback)(e=>R===`.`||R===``?e:`${R}/${e}`,[R]),[B,Ne]=(0,N.useState)(!1),[Pe,Le]=(0,N.useState)(!1),[Re,Ve]=(0,N.useState)(null),[He,Ue]=(0,N.useState)(!1),[H,U]=(0,N.useState)(null),[Ke,Ye]=(0,N.useState)(null),[Xe,Ze]=(0,N.useState)(null),[Qe,$e]=(0,N.useState)(!1),[et,tt]=(0,N.useState)(null),nt=(0,N.useRef)(null),[rt,W]=(0,N.useState)(0),[it,at]=(0,N.useState)(!1),[ot,st]=(0,N.useState)(``),[ct,lt]=(0,N.useState)(null),[ut,dt]=(0,N.useState)(``),[ft,pt]=(0,N.useState)(null),G=(()=>{let e=D===`.`?[]:D.split(`/`).filter(Boolean);return e.some(e=>e.startsWith(`@`))?!1:e.length>=2&&e[0]===`accounts`})(),[mt,ht]=(0,N.useState)(!1),gt=(0,N.useRef)(null),[_t,K]=(0,N.useState)(!1),vt=(0,N.useRef)(null);(0,N.useEffect)(()=>{let e=p.trim();if(!e){_(``),b(null),T(null);return}E(!1);let t=setTimeout(()=>_(e),300);return()=>clearTimeout(t)},[p]),(0,N.useEffect)(()=>{if(!g){C(!1);return}let t=!1;return C(!0),T(null),e(`/api/admin/graph-search?q=${encodeURIComponent(g)}&labels=FileArtifact&limit=20${oe?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(b(e.results),ee(e.mode??`hybrid`),ae(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||T(e instanceof Error?e.message:String(e))}).finally(()=>{t||C(!1)}),()=>{t=!0}},[g,e,o,oe]);let yt=(0,N.useMemo)(()=>y?De(y):[],[y]),q=te&&yt.includes(te)?te:null,bt=(0,N.useMemo)(()=>y?q?y.filter(e=>e.labels.includes(q)):y:null,[y,q]),xt=(0,N.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=n,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[r]);(0,N.useEffect)(()=>{if(!y)return;let e=y.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[y]),(0,N.useEffect)(()=>{let t=!1;return Ne(!0),Ve(null),e(`/api/admin/files?path=${encodeURIComponent(D===`.`?``:D)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(k(e.entries),ye(e.displayPath??[]),F(e.view??null),Se(typeof e.systemCount==`number`?e.systemCount:0))}).catch(e=>{t||(k([]),ye([]),F(null),Se(0),Ve(e instanceof Error?e.message:String(e)))}).finally(()=>{t||(Ne(!1),Le(!0))}),()=>{t=!0}},[e,D,rt,o]),(0,N.useEffect)(()=>{if(P!==null||!L||Te.current===L)return;Te.current=L;let t=!1;return e(`/api/admin/files?path=${encodeURIComponent(`${L}/@home`)}`).then(e=>e.ok?e.json():null).then(e=>{t||!e||we((e.entries??[]).map(e=>e.name))}).catch(e=>{console.warn(`[data-ui] op=rail-buckets status=error reason="${e instanceof Error?e.message:String(e)}"`)}),()=>{t=!0}},[e,P,L]),(0,N.useEffect)(()=>{Ie(D)},[D]);let St=(0,N.useCallback)(()=>{W(e=>e+1)},[]),J=(0,N.useCallback)(e=>{ht(!1),se(e)},[]),Ct=(0,N.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);m(``),T(null),ne(null),J(r)},[J]),wt=(0,N.useCallback)(()=>{if(!D.split(`/`).some(e=>e.startsWith(`@`))){if(D===`.`||D===``)return;let e=D.split(`/`).filter(Boolean);e.pop(),se(e.length===0?`.`:e.join(`/`));return}M.length!==0&&se(M.length>=2?M.slice(0,M.length-1).map(e=>e.name).join(`/`):`.`)},[D,M]),Tt=(0,N.useCallback)(e=>{pe(r,z(V(e)))},[z,r]),[Y,Et]=(0,N.useState)(!1),[X,Dt]=(0,N.useState)(new Set),Ot=(0,N.useRef)(null),Z=(0,N.useRef)(!1),kt=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,At=(0,N.useCallback)(e=>{Et(!0),Dt(new Set([e]))},[]),Q=(0,N.useCallback)(e=>{Et(!1),Dt(new Set)},[]),jt=(0,N.useCallback)(e=>{Dt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Mt=(0,N.useCallback)(e=>{Z.current=!1,Ot.current=setTimeout(()=>{Z.current=!0,At(e)},500)},[At]),$=(0,N.useCallback)(()=>{Ot.current&&=(clearTimeout(Ot.current),null)},[]),Nt=(0,N.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}Tt(e)},[Y,jt,Tt]),Pt=(0,N.useCallback)(e=>{ue(e),typeof window<`u`&&window.localStorage.setItem(ke,e)},[]),Ft=(0,N.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}ge({src:me(r,z(V(e))),alt:e.displayName??e.name})},[Y,jt,z,r]),It=(0,N.useCallback)(()=>(O??[]).filter(e=>e.kind===`file`&&X.has(e.name)),[O,X]),Lt=(0,N.useCallback)(()=>{if(X.size!==1)return null;let e=(O??[]).find(e=>X.has(e.name));return e&&!e.entryPath?e:null},[O,X]),Rt=(0,N.useCallback)(()=>(O??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&X.has(e.name)),[O,X]),zt=(0,N.useCallback)(()=>{let e=Rt(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?Tt(e[0]):e.length>=1&&fe(r,e.map(e=>z(V(e)))),Q(`action`)},[Rt,Tt,z,r,Q]),Bt=(0,N.useCallback)(async()=>{let t=It(),n=t.filter(e=>!e.protected),r=t.length-n.length;tt(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=z(V(t));try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){tt(e instanceof Error?e.message:String(e))}}W(e=>e+1),Q(`action`)},[It,z,e,Q]),Vt=(0,N.useCallback)(async()=>{let e=It();if(kt)try{let t=await Promise.all(e.map(async e=>{let t=z(V(e)),n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=await(await fetch(n)).blob();return new File([i],e.displayName??e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:t})&&await navigator.share({files:t})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[It,kt,z,r]),Ht=(0,N.useCallback)(()=>{nt.current?.click()},[]),Ut=(0,N.useCallback)((e,t={})=>{let n=(n,i,a)=>{let o=new URLSearchParams({session_key:r,path:D===`.`?``:D,filename:e.name});t.relpath&&o.set(`relpath`,t.relpath),t.token&&o.set(`token`,t.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let r=new XMLHttpRequest;r.open(`POST`,`/api/admin/files/upload?${o.toString()}`),r.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(r.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),r.onload=()=>{let e={};try{e=JSON.parse(r.responseText)}catch{}t({status:r.status,data:e})},r.onerror=()=>t({status:0,data:{}}),r.onabort=()=>t({status:0,data:{error:`aborted`}}),r.send(n)})};if(e.size<=Ae)return n(e,{},n=>t.onProgress?.(n,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/je);return(async()=>{let r={status:0,data:{}};for(let o=0;o<a;o++){let s=o*je;if(r=await n(e.slice(s,Math.min(s+je,e.size)),{uploadId:i,seq:String(o),total:String(a)},n=>t.onProgress?.(s+n,e.size)),!(r.status>=200&&r.status<300))return r}return r})()},[r,D]),Wt=(0,N.useCallback)(async e=>{Ye(null),Ue(!0),U({loaded:0,total:e.size});try{let{status:t,data:n}=await Ut(e,{onProgress:(e,t)=>U({loaded:e,total:t})});t>=200&&t<300&&n.path?(se(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),W(e=>e+1)):Ye(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{Ue(!1),U(null),nt.current&&(nt.current.value=``)}},[Ut]),Gt=(0,N.useCallback)(e=>{G&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),$e(!0))},[G]),Kt=(0,N.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||$e(!1)},[]),qt=(0,N.useCallback)(async e=>{e.preventDefault(),$e(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(n.length===0)return;if(!G){Ye(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);Ue(!0),Ye(null),Ze(null);try{let e=await ze(r),n=0,i=[];for(let r=0;r<e.length;r++){let{file:a,relpath:o}=e[r];U({loaded:0,total:a.size});let{status:s,data:c}=await Ut(a,{relpath:o,token:t,onProgress:(e,t)=>U({loaded:e,total:t})});if(s>=200&&s<300)n++;else{let e=s===0?`http=0`:Be(s,c.error);i.push(`${o} (${e})`)}}Ze(`Uploaded ${n}, skipped ${i.length}${i.length?`: ${i.join(`, `)}`:``}`),W(e=>e+1)}catch(e){Ye(e instanceof Error?e.message:String(e))}finally{Ue(!1),U(null)}},[G,Ut]),Jt=(0,N.useCallback)(async()=>{let t=ot.trim();if(t){pt(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:D===`.`?``:D,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);at(!1),st(``),W(e=>e+1)}catch(e){pt(e instanceof Error?e.message:String(e))}}},[e,ot,D]),Yt=(0,N.useCallback)(async()=>{if(!ct)return;let t=ut.trim();if(!t)return;pt(null);let n=z(ct);try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);lt(null),dt(``),Q(`action`),W(e=>e+1)}catch(e){pt(e instanceof Error?e.message:String(e))}},[e,ut,ct,z,Q]);(0,N.useEffect)(()=>{if(!mt)return;let e=e=>{gt.current&&!gt.current.contains(e.target)&&ht(!1)},t=e=>{e.key===`Escape`&&ht(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[mt]),(0,N.useEffect)(()=>{if(!_t)return;let e=e=>{vt.current&&!vt.current.contains(e.target)&&K(!1)},t=e=>{e.key===`Escape`&&K(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_t]);let Xt=(0,N.useCallback)(e=>M.slice(0,e+1).map(e=>e.name).join(`/`),[M]),Zt=M.length>=2,Qt=Zt?[{name:`.`,label:`data`},...M.slice(0,M.length-2).map((e,t)=>({name:Xt(t),label:e.displayName??e.name}))]:[];return Pe?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`data-toolbar`,children:[Y?(0,I.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>Q(`cancel`),"aria-label":`Cancel selection`,children:[(0,I.jsx)(v,{size:14}),` Cancel`]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`data-search-input`,children:[p===``&&(0,I.jsx)(le,{size:14}),(0,I.jsx)(`input`,{ref:h,type:`text`,value:p,onChange:e=>m(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),S&&(0,I.jsx)(u,{size:14,className:`spin`}),p!==``&&(0,I.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{m(``),h.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,I.jsx)(v,{size:14})})]}),(0,I.jsxs)(`div`,{className:`data-toolbar-actions`,ref:vt,children:[(0,I.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>K(e=>!e),"aria-haspopup":`menu`,"aria-expanded":_t,"aria-label":`File actions`,title:`File actions`,children:(0,I.jsx)(j,{size:16})}),(0,I.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":_t?`true`:void 0,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{St(),K(!1)},disabled:B,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[B?(0,I.jsx)(u,{size:16,className:`spin`}):(0,I.jsx)(t,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn admin-btn-cta`,onClick:()=>{Ht(),K(!1)},disabled:He||!G,title:G?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[He?H&&H.total>0?(0,I.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(H.loaded/H.total*100),`%`]}):(0,I.jsx)(u,{size:16,className:`spin`}):(0,I.jsx)(be,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{at(e=>!e),st(``),pt(null),K(!1)},disabled:He||!G,title:G?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,I.jsx)(he,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Pt(A===`grid`?`list`:`grid`),K(!1)},title:A===`grid`?`List view`:`Grid view`,"aria-label":A===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":A===`grid`,children:[A===`grid`?(0,I.jsx)(ve,{size:16}):(0,I.jsx)(_e,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:A===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,I.jsxs)(`div`,{className:`data-breadcrumbs`,children:[D!==`.`&&(0,I.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:wt,title:`Up one level`,"aria-label":`Up one level`,children:(0,I.jsx)(f,{size:14})}),Zt?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`data-crumb-wrap`,ref:gt,children:[(0,I.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>ht(e=>!e),"aria-haspopup":`menu`,"aria-expanded":mt,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),mt&&(0,I.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Qt.map(e=>(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>J(e.name),title:e.label,children:e.label},e.name))})]}),[M.length-2,M.length-1].map(e=>{let t=M[e];return(0,I.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,I.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,I.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Xt(e)),title:t.name,children:t.displayName??t.name})]},Xt(e))})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(`.`),children:`data`}),M.map((e,t)=>(0,I.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,I.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,I.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Xt(t)),title:e.name,children:e.displayName??e.name})]},Xt(t)))]})]}),it&&(0,I.jsxs)(`div`,{className:`data-inline-form`,children:[(0,I.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:ot,autoFocus:!0,onChange:e=>st(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Jt(),e.key===`Escape`&&at(!1)}}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Jt,children:`Create`}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>at(!1),children:`Cancel`})]}),ct&&(0,I.jsxs)(`div`,{className:`data-inline-form`,children:[(0,I.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:ut,autoFocus:!0,onChange:e=>dt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Yt(),e.key===`Escape`&<(null)}}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Yt,children:`Rename`}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>lt(null),children:`Cancel`})]}),ft&&(0,I.jsx)(`div`,{className:`data-error`,children:ft}),(0,I.jsx)(`input`,{type:`file`,ref:nt,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Wt(t)}})]}),(0,I.jsxs)(`div`,{className:`data-body`,"data-drag-active":Qe?`true`:void 0,onDragEnter:Gt,onDragOver:Gt,onDragLeave:Kt,onDrop:qt,children:[P===null&&L&&Ce&&Ce.length>0&&(0,I.jsxs)(`aside`,{className:`data-rail`,"aria-label":`Folders`,children:[(0,I.jsx)(`span`,{className:`data-rail-label`,children:`Folders`}),(0,I.jsx)(`ul`,{className:`data-rail-list`,children:Ce.map(e=>{let t=`${L}/${e}`,n=D===t||D.startsWith(`${t}/`);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,className:`data-rail-item`,"aria-current":n?`true`:void 0,onClick:()=>J(t),children:[(0,I.jsx)(d,{size:13}),(0,I.jsx)(`span`,{className:`data-rail-item-name`,children:e})]})},e)})})]}),(0,I.jsxs)(`div`,{className:`data-content`,children:[(w!==null||y!==null)&&(0,I.jsxs)(`section`,{className:`data-panel admin-card`,children:[w&&(0,I.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,w]}),yt.length>0&&(0,I.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:yt.map(e=>{let t=e===q;return(0,I.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>ne(t?null:e),children:Ge([e])??e},e)})}),y&&!S&&(0,I.jsxs)(`div`,{className:`data-results-meta`,children:[bt.length,` of `,y.length,` result`,y.length===1?``:`s`]}),y&&!S&&!q&&ie>0&&!oe&&(0,I.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>E(!0),children:[ie,` low-confidence result`,ie===1?``:`s`,` hidden — show all`]}),y&&!S&&!q&&oe&&(0,I.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>E(!1),children:`Showing all results — hide low-confidence`}),y&&y.length===0&&!S&&(0,I.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),bt&&bt.length>0&&(0,I.jsx)(`ul`,{className:`data-results`,children:bt.map(e=>(0,I.jsx)(We,{hit:e,mode:x,onDownload:xt,onLocate:Ct},e.nodeId))})]}),(0,I.jsxs)(`section`,{className:`data-panel data-panel--wide admin-card`,children:[H&&(0,I.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":H.total>0?Math.round(H.loaded/H.total*100):void 0,children:[(0,I.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,I.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${H.total>0?Math.round(H.loaded/H.total*100):0}%`}})}),(0,I.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,H.total>0?`${Math.round(H.loaded/H.total*100)}%`:``]})]}),Ke&&(0,I.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,Ke]}),Xe&&(0,I.jsx)(`div`,{className:`data-status`,children:Xe}),et&&(0,I.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,et]}),Re&&(0,I.jsx)(`div`,{className:`data-error`,children:Re}),B&&(0,I.jsxs)(`div`,{className:`data-loading`,children:[(0,I.jsx)(u,{size:14,className:`spin`}),` Loading…`]}),!B&&P!==`home`&&O&&O.length===0&&!Re&&(0,I.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!B&&P===`home`&&O&&(0,I.jsxs)(`ul`,{className:`routine-list data-home-list`,children:[O.map(e=>(0,I.jsxs)(`li`,{className:`data-home-card`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(z(e.name)),children:[(0,I.jsx)(`span`,{className:`data-home-card-title`,children:e.name}),(0,I.jsx)(`span`,{className:`data-home-card-count`,children:e.childCount===null||e.childCount===void 0?`—`:`${e.childCount} ${e.childCount===1?`item`:`items`}`})]}),(0,I.jsxs)(`ul`,{className:`data-home-card-children`,children:[e.childCount===null&&(0,I.jsx)(`li`,{className:`data-home-card-error`,children:`Could not read this folder.`}),e.childCount===0&&(0,I.jsx)(`li`,{className:`data-home-card-empty`,children:`Empty.`}),(e.children??[]).map(e=>(0,I.jsxs)(`li`,{className:`data-home-card-child`,children:[e.kind===`directory`?(0,I.jsx)(d,{size:12}):(0,I.jsx)(ce,{size:12}),(0,I.jsx)(`span`,{className:`data-home-card-child-name`,children:e.name})]},e.name)),typeof e.childCount==`number`&&e.childCount>(e.children?.length??0)&&(0,I.jsxs)(`li`,{className:`data-home-card-more`,children:[`+`,e.childCount-(e.children?.length??0),` more`]})]})]},e.name)),(0,I.jsxs)(`li`,{className:`data-home-card`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(z(`@system`)),children:[(0,I.jsx)(`span`,{className:`data-home-card-title`,children:`system`}),(0,I.jsxs)(`span`,{className:`data-home-card-count`,children:[xe,` `,xe===1?`item`:`items`]})]}),(0,I.jsx)(`ul`,{className:`data-home-card-children`,children:(0,I.jsx)(`li`,{className:`data-home-card-empty`,children:`Platform and plugin folders.`})})]})]}),!B&&P!==`home`&&O&&O.length>0&&A===`grid`&&(0,I.jsx)(`ul`,{className:`data-grid`,children:O.map(e=>{let t=e.displayName??e.name,n=Y&&X.has(e.name);if(e.kind===`directory`)return(0,I.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}J(z(e.name))},children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,I.jsx)(d,{size:28,className:`data-grid-glyph`}),(0,I.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let i=Oe(V(e)),a=z(V(e));return(0,I.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>i?Ft(e):Nt(e),title:Y?void 0:i?`Preview ${t}`:`Download ${t}`,children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,I.jsx)(`img`,{className:`data-grid-thumb`,src:me(r,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,I.jsx)(ce,{size:28,className:`data-grid-glyph`}),(0,I.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!i&&(0,I.jsx)(`span`,{className:`data-grid-sub`,children:qe(e.sizeBytes)})]})},e.name)}return(0,I.jsx)(`li`,{className:`data-grid-cell`,children:(0,I.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,I.jsx)(ce,{size:28,className:`data-grid-glyph`}),(0,I.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,I.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!B&&P!==`home`&&O&&O.length>0&&A===`list`&&(0,I.jsx)(`ul`,{className:`data-entries`,children:O.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=Y&&X.has(e.name);return(0,I.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}J(z(e.name))},children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,I.jsx)(d,{size:14}),(0,I.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=Y&&X.has(e.name);return(0,I.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>Nt(e),title:Y?void 0:`Download ${t}`,children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`data-entry-text`,children:[(0,I.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,I.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Je(e.modifiedAt,l)}`,children:[qe(e.sizeBytes),` · `,Je(e.modifiedAt,l)]})]})]})},e.name)}return(0,I.jsx)(`li`,{className:`data-entry`,children:(0,I.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,I.jsxs)(`span`,{className:`data-entry-text`,children:[(0,I.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,I.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]})]}),Y&&(0,I.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,I.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Vt,disabled:!kt||X.size===0,title:kt?`Share selected files`:`Sharing is not supported on this device`,children:[(0,I.jsx)(c,{size:16}),` Share`]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:zt,disabled:X.size===0,children:[(0,I.jsx)(n,{size:16}),` Download`]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=Lt();e&&(lt(e.name),dt(e.name))},disabled:!Lt(),children:[(0,I.jsx)(i,{size:16}),` Rename`]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:Bt,disabled:X.size===0,children:[(0,I.jsx)(a,{size:16}),` Delete`]})]})}),de&&(0,I.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":de.alt,onClick:()=>ge(null),children:(0,I.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:de.src,alt:de.alt})})]}):(0,I.jsx)(s,{surface:`gate`})}function He({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){let r=(0,N.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),i=(0,N.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[a,o]=(0,N.useState)([]),[s,c]=(0,N.useState)(`files`),{subAccounts:u,activeAccountId:d,switching:f,switchAccount:p}=ee(t);return(0,N.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`/api/operator-conversations/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||o(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,I.jsxs)(`main`,{className:`data-main`,children:[(0,I.jsx)(l,{variant:`operator`,onNavigate:i,onOpenConversations:a.length>0?()=>c(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:u,activeAccountId:d,switchingAccount:f,onSwitchAccount:p}),s===`conversations`?(0,I.jsx)(z,{conversations:a,sessionKey:t,onBack:()=>c(`files`)}):(0,I.jsx)(Ve,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function Ue({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=h({initialCacheKey:e,surface:`data`});return(0,I.jsx)(`div`,{className:`data-page`,children:(0,I.jsx)(`main`,{className:`data-main`,children:(0,I.jsx)(Ve,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function We({hit:e,mode:t,onDownload:n,onLocate:r}){let{zone:i}=re(),a=H(e.properties),o=U(e.properties),s=Ge(e.labels),c=Ke(e.properties),[l,u]=(0,N.useState)(!1),f=o&&o.length>280,p=l||!f?o:o?.slice(0,280)+`…`,m=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,h=e.properties.relativePath,g=typeof h==`string`&&h.length>0,_=g?h.lastIndexOf(`/`):-1,v=g?_===-1?`data`:h.slice(0,_):null;return(0,I.jsxs)(`li`,{className:`data-result`,children:[(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${a??s??`file`}`,children:[s&&(0,I.jsx)(`div`,{className:`data-result-header`,children:(0,I.jsx)(`span`,{className:`data-result-labels`,children:s})}),a&&(0,I.jsx)(`div`,{className:`data-result-title`,children:a}),o&&(0,I.jsx)(`pre`,{className:`data-result-body`,children:p}),(0,I.jsxs)(`div`,{className:`data-result-scores`,children:[c&&(0,I.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Je(c,i),` · `]}),m]})]}),g&&(0,I.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${v}`,"aria-label":`Locate in ${v}`,children:[(0,I.jsx)(d,{size:12}),v]}),f&&(0,I.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>u(e=>!e),children:l?`Show less`:`Show more`})]})}function Ge(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function H(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function U(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function Ke(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function qe(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function Je(e,t){return m(e,t)||`—`}export{Ue as n,L as r,Ne as t};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Z as e}from"./useMediaQuery-Baf4Huvv.js";var t=e(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{ct as t,nt as n,ot as r}from"./useMediaQuery-
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{ct as t,nt as n,ot as r}from"./useMediaQuery-Baf4Huvv.js";import"./useVoiceRecorder-BaAtMu9T.js";import{D as i}from"./AdminShell-Dc5du5xX.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./page-BbzdSxuU.js";import"./useCopyFeedback-BCRjKc-H.js";var d=r(),f=e(t(),1),p=n();function m({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:r}){let[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(null);async function d(e){e.preventDefault();let n=a.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:r.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,p.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Verifying your link…`}),(0,p.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`That link did not work`}),(0,p.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,p.jsxs)(`form`,{className:`access-gate-form`,onSubmit:d,children:[(0,p.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,p.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,p.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,p.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:a,onChange:e=>o(e.target.value),disabled:s}),l&&(0,p.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,p.jsx)(i,{type:`submit`,disabled:s||!a.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Check your email`}),(0,p.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}function h(){let[e,t]=(0,f.useState)(null),[n,r]=(0,f.useState)(null),[i,l]=(0,f.useState)(`loading`),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(null),[g,_]=(0,f.useState)(null),[v,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(null),S=(0,f.useMemo)(()=>a(),[]),C=(0,f.useRef)(S||``),w=(0,f.useRef)(null),T=(0,f.useRef)(null),E=(0,f.useRef)(!1),D=(0,f.useRef)(null),[O,k]=(0,f.useState)(`request-link`),[A,j]=(0,f.useState)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null);(0,f.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(N.current=e)}catch{}},[]),(0,f.useEffect)(()=>{try{let e=c();e&&sessionStorage.setItem(s,e)}catch{}},[]);let P=(0,f.useCallback)(e=>{w.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}l(`chat`)},[]),F=(0,f.useCallback)(()=>{w.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),l(`auth-required`),k(`request-link`)},[]),I=(0,f.useCallback)(async e=>{k(`verifying`);try{let t=C.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&j({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return k(`verify-failed`),!1}catch{return k(`verify-failed`),!1}},[]),L=(0,f.useCallback)(async()=>{if(w.current)return w.current;if(T.current)return T.current;let e=(async()=>{try{let e=N.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:u(),...S?{agent:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return o&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(C.current=i.agent_id),p(i.displayName||``),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await I(e)&&window.location.reload():k(`request-link`),null}w.current=i.session_key,t(i.session_key),i.displayName&&p(i.displayName),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`chat`),i.resumed&&i.messages&&(E.current=!0,D.current=i.messages);try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return o&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{T.current=null}})();return T.current=e,e},[S,I]);return{sessionId:e,cacheKeyRef:w,sessionError:n,pageState:i,setPageState:l,agentDisplayName:d,agentImage:m,agentImageShape:g,showAgentName:v,agentSlug:S,branding:b,resolvedSlugRef:C,ensureSession:L,startNewSession:(0,f.useCallback)(async()=>{w.current=null,T.current=null,N.current=null,E.current=!1,D.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await L()},[L]),enterChat:P,enterGate:F,resumedRef:E,resumeMessagesRef:D,gateState:O,setGateState:k,grantInfo:A,setGrantInfo:j,gateCacheKeyRef:M}}function g(){let{ensureSession:e,pageState:t,gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}=h();return(0,f.useEffect)(()=>{e()},[e]),t===`loading`?(0,p.jsx)(`div`,{className:`public-loading`,children:`Loading…`}):t===`auth-required`?(0,p.jsx)(m,{gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}):(0,p.jsx)(`div`,{className:`public-shell`,children:(0,p.jsx)(l,{cacheKey:``,variant:`public`})})}(0,d.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(g,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Z as e}from"./useMediaQuery-
|
|
1
|
+
import{Z as e}from"./useMediaQuery-Baf4Huvv.js";var t=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{F as t,G as n,L as r,M as i,O as a,V as o,Y as s,Z as c,_ as l,at as u,ct as d,f,j as p,k as m,m as h,nt as g,ot as _,v}from"./useMediaQuery-Baf4Huvv.js";import{k as y,m as b,t as x}from"./AdminShell-Dc5du5xX.js";import{t as S}from"./clock-BNp2JTKh.js";import{t as C}from"./wrench-iI-vx-g2.js";import{r as w}from"./file-download-DbNIjWiK.js";var ee=c(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),te=c(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),T=c(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),E=_(),D=e(d(),1),O=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function k(e,t){if(e===`*`)return{kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1};let n=e.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){let e=Number(n[2]);if(e<1)return null;if(n[1]===`*`)return{kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:e};let[r,i]=n[1].split(`-`).map(Number);return r>t||i>t||r>i?null:{kind:`step`,value:0,rangeStart:r,rangeEnd:i,step:e}}let r=e.match(/^(\d+)-(\d+)$/);if(r){let e=Number(r[1]),n=Number(r[2]);return e>t||n>t||e>n?null:{kind:`step`,value:0,rangeStart:e,rangeEnd:n,step:1}}if(/^\d+$/.test(e)){let n=Number(e);return n>t?null:{kind:`fixed`,value:n,rangeStart:null,rangeEnd:null,step:1}}return null}function A(e){return String(e).padStart(2,`0`)}function j(e){if(e===`*`)return null;let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);return e>7||n>7||e>n?`invalid`:`${O[e%7]} to ${O[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>O[Number(e)%7]).join(`, `):`invalid`}function ne(e){let t=e.trim().split(/\s+/);if(t.length!==5)return e;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i)||i!==`*`&&(Number(i)<1||Number(i)>31))return e;let s=k(n,59),c=k(r,23);if(!s||!c)return e;let l=j(o);if(l===`invalid`||s.kind===`step`&&s.rangeStart!==null||(s.kind===`any`&&(s={kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:1}),c.kind===`step`&&c.step===1&&c.rangeStart===null&&(c={kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1}),i!==`*`&&!(s.kind===`fixed`&&c.kind===`fixed`&&o===`*`))||s.kind===`step`&&c.kind===`step`&&c.step>1)return e;let u=l?`, ${l}`:``,d=e=>e.rangeStart+Math.floor((e.rangeEnd-e.rangeStart)/e.step)*e.step;if(s.kind===`step`){let e=s.step===1?`Every minute`:`Every ${s.step} minutes`;return c.kind===`any`?`${e}${u}`:c.kind===`fixed`?`${e}, ${A(c.value)}:00 to ${A(c.value)}:59${u}`:`${e}, ${A(c.rangeStart)}:00 to ${A(d(c))}:00${u}`}if(c.kind===`step`){let e=A(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${A(c.rangeStart)}:${e} to ${A(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${A(c.rangeStart)}:${e} to ${A(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${A(s.value)}`}${u}`;let f=`${A(c.value)}:${A(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var M={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function N(e){let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);if(e>7||n>7||e>n)return null;let r=[];for(let t=e;t<=n;t+=1)r.push(t%7);return[...new Set(r)].sort((e,t)=>e-t)}let n=e.split(`,`);return n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?[...new Set(n.map(e=>Number(e)%7))].sort((e,t)=>e-t):null}function P(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i))return null;let s=k(n,59),c=k(r,23);if(!s||!c||s.kind===`step`&&s.rangeStart!==null)return null;let l=`every`,u=[],d=1;if(i!==`*`){if(o!==`*`)return null;let e=Number(i);if(e<1||e>31||s.kind!==`fixed`||c.kind!==`fixed`)return null;l=`dayOfMonth`,d=e}else if(o!==`*`){let e=N(o);if(e===null)return null;l=`weekdays`,u=e}let f={dayMode:l,weekdays:u,dayOfMonth:d};if(s.kind===`any`||s.kind===`step`){if(c.kind===`step`&&c.step>1)return null;let e=s.kind===`any`?1:s.step,t=c.kind===`any`?null:c.kind===`fixed`?{start:c.value,end:c.value}:{start:c.rangeStart,end:c.rangeEnd};return{...M,...f,timeMode:`everyMinutes`,minute:0,interval:e,window:t}}return c.kind===`fixed`?{...M,...f,timeMode:`at`,minute:s.value,hour:c.value}:c.kind===`any`?{...M,...f,timeMode:`everyHours`,minute:s.value,interval:1,window:null}:{...M,...f,timeMode:`everyHours`,minute:s.value,interval:c.step,window:c.rangeStart===null?null:{start:c.rangeStart,end:c.rangeEnd}}}function F(e){return e.dayMode===`dayOfMonth`?[String(e.dayOfMonth),`*`]:e.dayMode===`weekdays`&&e.weekdays.length>0?[`*`,[...e.weekdays].sort((e,t)=>e-t).join(`,`)]:[`*`,`*`]}function I(e){let[t,n]=F(e);if(e.timeMode===`everyMinutes`){let r=e.window===null?`*`:e.window.start===e.window.end?String(e.window.start):`${e.window.start}-${e.window.end}`;return`*/${e.interval} ${r} ${t} * ${n}`}if(e.timeMode===`everyHours`){let r=e.window===null?e.interval===1?`*`:`*/${e.interval}`:e.interval===1?`${e.window.start}-${e.window.end}`:`${e.window.start}-${e.window.end}/${e.interval}`;return`${e.minute} ${r} ${t} * ${n}`}return`${e.minute} ${e.hour} ${t} * ${n}`}var L=g(),R=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}],z=Array.from({length:24},(e,t)=>t),B=e=>String(e).padStart(2,`0`),V={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function re({recurrence:e,onChange:t,disabled:n}){let r=e?P(e):V,[i,a]=(0,D.useState)(r??V),[o]=(0,D.useState)(e!=null&&r==null),[s,c]=(0,D.useState)(e??``);if((0,D.useEffect)(()=>{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`routines`,op:`schedule-editor`,mode:o?`raw`:`builder`}),keepalive:!0}).catch(()=>{})},[o]),o)return(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Schedule (advanced)`}),(0,L.jsx)(`input`,{type:`text`,className:`routine-raw-cron`,value:s,disabled:n,onChange:e=>{c(e.target.value),t(e.target.value)},"aria-label":`Cron expression`}),(0,L.jsx)(`span`,{className:`routine-raw-note`,children:`This routine uses an advanced schedule, edited as a raw cron expression.`})]});let l=e=>{a(e),t(I(e))},u=e=>{let t=e!==`at`&&i.dayMode===`dayOfMonth`?`every`:i.dayMode;l({...i,timeMode:e,dayMode:t})},d=e=>{let t=e===`weekdays`&&i.weekdays.length===0?[1]:i.weekdays;l({...i,dayMode:e,weekdays:t})},f=e=>{let[t,n]=e.split(`:`);l({...i,hour:Number(t)||0,minute:Number(n)||0})},p=e=>{let t=i.weekdays.includes(e);if(t&&i.weekdays.length===1)return;let n=t?i.weekdays.filter(t=>t!==e):[...i.weekdays,e];l({...i,weekdays:n})},m=e=>l({...i,window:e?{start:0,end:23}:null}),h=(e,t)=>{let n={...i.window??{start:0,end:23},[e]:Number(t)};n.start>n.end&&(e===`start`?n.end=n.start:n.start=n.end),l({...i,window:n})},g=(e,t,n)=>Math.min(n,Math.max(t,Number(e)||t));return(0,L.jsxs)(`div`,{className:`routine-sched`,children:[(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`How often`}),(0,L.jsxs)(`select`,{"aria-label":`How often`,value:i.timeMode,disabled:n,onChange:e=>u(e.target.value),children:[(0,L.jsx)(`option`,{value:`at`,children:`At a time of day`}),(0,L.jsx)(`option`,{value:`everyMinutes`,children:`Every few minutes`}),(0,L.jsx)(`option`,{value:`everyHours`,children:`Every few hours`})]})]}),i.timeMode===`at`&&(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Time of day`}),(0,L.jsx)(`input`,{type:`time`,"aria-label":`Time of day`,value:`${B(i.hour)}:${B(i.minute)}`,disabled:n,onChange:e=>f(e.target.value)})]}),i.timeMode===`everyMinutes`&&(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Minutes between runs`}),(0,L.jsx)(`input`,{type:`number`,min:1,max:59,"aria-label":`Minutes between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,59)})})]}),i.timeMode===`everyHours`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Hours between runs`}),(0,L.jsx)(`input`,{type:`number`,min:1,max:23,"aria-label":`Hours between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,23)})})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Minute of the hour`}),(0,L.jsx)(`input`,{type:`number`,min:0,max:59,"aria-label":`Minute of the hour`,value:i.minute,disabled:n,onChange:e=>l({...i,minute:g(e.target.value,0,59)})})]})]}),i.timeMode!==`at`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`label`,{className:`cal-modal-field routine-sched-check`,children:[(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`Only between certain hours`,checked:i.window!==null,disabled:n,onChange:e=>m(e.target.checked)}),(0,L.jsx)(`span`,{children:`Only between certain hours`})]}),i.window!==null&&(0,L.jsxs)(`div`,{className:`routine-sched-row`,children:[(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`From hour`}),(0,L.jsx)(`select`,{"aria-label":`From hour`,value:i.window.start,disabled:n,onChange:e=>h(`start`,e.target.value),children:z.map(e=>(0,L.jsxs)(`option`,{value:e,children:[B(e),`:00`]},e))})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`To hour`}),(0,L.jsx)(`select`,{"aria-label":`To hour`,value:i.window.end,disabled:n,onChange:e=>h(`end`,e.target.value),children:z.map(e=>(0,L.jsxs)(`option`,{value:e,children:[B(e),`:00`]},e))})]})]})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Which days`}),(0,L.jsxs)(`select`,{"aria-label":`Which days`,value:i.dayMode,disabled:n,onChange:e=>d(e.target.value),children:[(0,L.jsx)(`option`,{value:`every`,children:`Every day`}),(0,L.jsx)(`option`,{value:`weekdays`,children:`Specific days`}),i.timeMode===`at`&&(0,L.jsx)(`option`,{value:`dayOfMonth`,children:`A day of the month`})]})]}),i.dayMode===`weekdays`&&(0,L.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Days`}),(0,L.jsx)(`div`,{className:`routine-weekdays`,children:R.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`routine-weekday${i.weekdays.includes(e.value)?` routine-weekday-on`:``}`,"aria-pressed":i.weekdays.includes(e.value),disabled:n,onClick:()=>p(e.value),children:e.label},e.value))})]}),i.dayMode===`dayOfMonth`&&(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Day of month`}),(0,L.jsx)(`select`,{"aria-label":`Day of month`,value:i.dayOfMonth,disabled:n,onChange:e=>l({...i,dayOfMonth:Number(e.target.value)||1}),children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))})]})]})}function H(e){let t=e.trim().replace(/[\s\-().]/g,``).replace(/^\+/,``);return/^\d{11,15}$/.test(t)?`+${t.slice(0,2)} ${t.slice(2,6)} ${t.slice(6)}`:e}function ie(e){if(e.name)return`${e.name} · ${e.label}`;let t=e.channel===`whatsapp`?H(e.destination):e.destination;return`${e.label} · ${t}`}var U={scheduled:`live`,due:`live`,suspended:`stood-down`,cancelled:`inert`,completed:`inert`};function W(e){return e==null||!Object.hasOwn(U,e)?`unknown`:U[e]}var G={finished:`live`,gated:`live`,started:`in-flight`,accepted:`in-flight`,open:`in-flight`,failed:`error`,"no-destination":`warning`};function K(e){return e==null||!Object.hasOwn(G,e)?`unknown`:G[e]}function q(e){return e===`gated`?`skipped: no work`:e??`unknown`}function ae({eventStatus:e}){let t=W(e);return(0,L.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}function oe(e){return e.agentChannel==null?e.actionPlugin==null?`trigger`:`deterministic`:e.gateTool==null?`agent-every-fire`:`checked-agent`}var se={"checked-agent":`checks first, model only when there is work`,"agent-every-fire":`model every fire`,deterministic:`runs a tool, no model`,trigger:null};function ce(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}let n=t?.checks;return Array.isArray(n)?n.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return typeof t.type==`string`?[{kind:t.type,target:le(t.type,t)}]:[]}):[]}function le(e,t){let n=e=>typeof t[e]==`string`?t[e]:null;if(e===`mail`){let e=n(`mailbox`);if(e===null)return null;let t=n(`folder`);return t?`${e}/${t}`:e}return e===`d1`?n(`database`):e===`whatsapp`?n(`scope`):e===`calendar`?n(`connector`):null}function ue(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?l(new Date(n).toISOString(),t):e}function de(e){return e?e.split(`
|
|
2
|
+
`).filter(e=>e.trim()!==``).reverse():[]}function fe({routine:e,adminFetch:t,onClose:n,onSaved:a,onDeleted:s,onViewRuns:c}){let{zone:l}=v(),[u,d]=(0,D.useState)(!1),[m,g]=(0,D.useState)(!1),[_,y]=(0,D.useState)(null),[x,w]=(0,D.useState)(e),[E,O]=(0,D.useState)(!1),k=x.agentChannel!=null,A=oe(x),j=ce(x.gateArgs),M=x.eventStatus===`suspended`,[N,P]=(0,D.useState)(!1),[F,I]=(0,D.useState)(e.agentPrompt??``),[R,z]=(0,D.useState)(e.description??``),[B,V]=(0,D.useState)(e.recurrence),[H,U]=(0,D.useState)(e.agentChannel??``),[W,G]=(0,D.useState)(e.agentDestination??``),[K,q]=(0,D.useState)(null),[le,fe]=(0,D.useState)(null),J=k||x.actionPlugin==null,Y=de(x.notes);(0,D.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!m&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,n]),(0,D.useEffect)(()=>{if(!u||!J||K!==null)return;let e=!1;return t(`/api/admin/dispatch-destinations`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(t=>{e||q(t.destinations)}).catch(t=>{e||(q([]),fe(t instanceof Error?t.message:`Could not load destinations`))}),()=>{e=!0}},[u,J,K,t]);let X=(K??[]).filter(e=>e.channel===H),Z=H.length>0&&W.length>0,Q=H.length>0&&W.length===0||Z&&F.trim().length===0,pe=(0,D.useCallback)(()=>{let e={},t=H.length>0&&W.length>0;(k||t)&&F!==(x.agentPrompt??``)&&(e.agentPrompt=F);let n=R.trim().length>0?R:null;return n!==(x.description??null)&&(e.description=n),B!=null&&B!==(x.recurrence??null)&&(e.recurrence=B),t&&(H!==(x.agentChannel??``)||W!==(x.agentDestination??``))?(e.agentChannel=H,e.agentDestination=W):!t&&H===``&&(x.agentChannel??``)!==``&&(e.agentChannel=null,e.agentDestination=null),e},[k,F,R,B,H,W,x]),me=(0,D.useCallback)(async()=>{let n=pe();if(Object.keys(n).length===0){d(!1);return}g(!0),y(null);try{let r=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let i=await r.json();w(i.routine),I(i.routine.agentPrompt??``),z(i.routine.description??``),V(i.routine.recurrence),U(i.routine.agentChannel??``),G(i.routine.agentDestination??``),a(i.routine),d(!1)}catch(e){y(e instanceof Error?e.message:`Save failed`)}finally{g(!1)}},[t,pe,e.eventId,a]),he=(0,D.useCallback)(async()=>{if(m)return;if(!N){O(!1),P(!0);return}let n=M?`resume`:`suspend`;g(!0),y(null);try{let r=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}/${n}`,{method:`POST`});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let i=await r.json();w(i.routine),a(i.routine),P(!1)}catch(e){y(e instanceof Error?e.message:`${n} failed`),P(!1)}finally{g(!1)}},[t,m,N,M,e.eventId,a]),ge=(0,D.useCallback)(async()=>{if(!m){if(!E){P(!1),O(!0);return}g(!0),y(null);try{let n=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`DELETE`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}s(e.eventId)}catch(e){y(e instanceof Error?e.message:`Delete failed`),O(!1)}finally{g(!1)}}},[t,m,E,e.eventId,s]);return(0,L.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{m||n()},children:(0,L.jsxs)(`div`,{className:`cal-modal ${!u||k||Z?`cal-modal-wide`:`cal-modal-dispatch`}`,role:`dialog`,"aria-modal":`true`,"aria-label":u?`Edit routine`:`Routine detail`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,L.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,L.jsx)(b,{size:13}),` Routine`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:m,children:(0,L.jsx)(p,{size:16})})]}),!u&&(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,L.jsx)(`div`,{className:`cal-modal-title`,children:x.name??`Untitled routine`}),(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(S,{size:14}),(0,L.jsx)(`span`,{children:x.recurrence?ne(x.recurrence):`One-time`})]}),(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,L.jsx)(ae,{eventStatus:x.eventStatus}),(0,L.jsxs)(`span`,{children:[`Status: `,x.eventStatus??`unknown`]})]}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsxs)(`span`,{children:[`Next run: `,ue(x.nextRun,l)]})}),(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,L.jsx)(T,{size:14}),(0,L.jsxs)(`span`,{children:[`Last run: `,ue(x.lastTriggered,l),x.lastDispatchResult?` (${x.lastDispatchResult})`:``]})]}),x.description&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsx)(`span`,{children:`Description`})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,L.jsx)(`span`,{children:x.description})})]}),se[A]&&(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`routine-mode`,children:[(0,L.jsx)(b,{size:14}),(0,L.jsxs)(`span`,{children:[se[A],A===`agent-every-fire`&&x.gateWaived?`: ${x.gateWaived}`:``]})]}),k?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(h,{channel:x.agentChannel,size:14}),(0,L.jsxs)(`span`,{children:[f[x.agentChannel]??x.agentChannel,` to `,x.agentDestination??`—`]})]}),x.gateTool!=null&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsx)(`span`,{children:`Checks before the agent runs`})}),(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(C,{size:14}),(0,L.jsxs)(`span`,{children:[x.gatePlugin,`.`,x.gateTool]})]}),j.map((e,t)=>(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`gate-check`,children:(0,L.jsxs)(`span`,{children:[e.kind,e.target?` · ${e.target}`:``]})},t))]}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsx)(`span`,{children:`Instruction sent to the agent`})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,L.jsx)(`span`,{children:x.agentPrompt??`No instruction sent to the agent.`})})]}):x.actionPlugin?(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(C,{size:14}),(0,L.jsxs)(`span`,{children:[x.actionPlugin,`.`,x.actionTool,x.actionArgs?` ${x.actionArgs}`:``]})]}):(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(S,{size:14}),(0,L.jsx)(`span`,{children:`Scheduled trigger (no dispatch)`})]}),Y.length===0?(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,L.jsx)(T,{size:14}),(0,L.jsx)(`span`,{children:`No history recorded.`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,L.jsx)(T,{size:14}),(0,L.jsxs)(`span`,{children:[`History (`,Y.length,` `,Y.length===1?`entry`:`entries`,`)`]})]}),(0,L.jsx)(`div`,{className:`routine-history`,children:Y.map((e,t)=>(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:e},t))})]})]}),u&&(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[J&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Send to`}),(0,L.jsxs)(`div`,{className:`cal-modal-field-inline`,children:[(0,L.jsxs)(`select`,{value:H,disabled:m,onChange:e=>{U(e.target.value),G(``)},children:[(0,L.jsx)(`option`,{value:``,children:`None (no dispatch)`}),(0,L.jsx)(`option`,{value:`whatsapp`,children:`WhatsApp`}),(0,L.jsx)(`option`,{value:`telegram`,children:`Telegram`})]}),H!==``&&(0,L.jsx)(h,{channel:H,size:16})]})]}),H!==``&&(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Destination`}),(0,L.jsxs)(`select`,{value:W,disabled:m||K===null,onChange:e=>G(e.target.value),children:[(0,L.jsx)(`option`,{value:``,children:K===null?`Loading destinations`:X.length===0?`No registered destinations`:`Choose a destination`}),W!==``&&!X.some(e=>e.destination===W)&&(0,L.jsxs)(`option`,{value:W,children:[W,` (not in the current list)`]}),X.map(e=>(0,L.jsx)(`option`,{value:e.destination,children:ie(e)},e.destination))]})]}),le&&(0,L.jsxs)(`div`,{className:`cal-modal-error`,children:[`Could not load destinations: `,le]})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Description`}),(0,L.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),disabled:m,placeholder:`One line: what this routine is for`})]}),(k||Z)&&(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Instruction sent to the agent`}),(0,L.jsx)(`textarea`,{className:`cal-modal-textarea`,value:F,onChange:e=>I(e.target.value),disabled:m,rows:16,placeholder:`What should the agent do when this routine fires?`})]}),(0,L.jsx)(re,{recurrence:x.recurrence,onChange:V,disabled:m})]}),_&&(0,L.jsx)(`div`,{className:`cal-modal-error`,children:_}),(0,L.jsxs)(`div`,{className:`cal-modal-actions`,children:[!u&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{O(!1),P(!1),d(!0)},disabled:m,children:[(0,L.jsx)(r,{size:14}),` Edit`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>c(x),disabled:m,children:[(0,L.jsx)(T,{size:14}),` Runs`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:he,disabled:m,children:[m&&N?(0,L.jsx)(o,{size:14,className:`spin`}):M?(0,L.jsx)(te,{size:14}):(0,L.jsx)(ee,{size:14}),N?M?`Confirm resume`:`Confirm suspend`:M?`Resume`:`Suspend`]}),N&&(0,L.jsx)(`span`,{className:`cal-modal-confirm-text`,children:M?`This routine will run at its next scheduled time. It will not run for the times it missed.`:`This routine stops running until you resume it. Nothing is deleted.`}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:ge,disabled:m,children:[m&&E?(0,L.jsx)(o,{size:14,className:`spin`}):(0,L.jsx)(i,{size:14}),E?`Confirm delete`:`Delete`]})]}),u&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:me,disabled:m||Q,children:[m?(0,L.jsx)(o,{size:14,className:`spin`}):null,` Save`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),y(null)},disabled:m,children:`Cancel`})]})]})]})})}function J(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?l(new Date(n).toISOString(),t):e}function Y(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function X({run:e,routineName:t,onClose:n}){let{zone:r}=v();return(0,D.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,L.jsx)(`div`,{className:`cal-modal-overlay`,onClick:n,children:(0,L.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Run detail`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,L.jsx)(`span`,{className:`cal-modal-kind`,children:`Run`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,children:(0,L.jsx)(p,{size:16})})]}),(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,L.jsx)(`div`,{className:`cal-modal-title`,children:t??`Untitled routine`}),e.outputExcerpt!==null&&(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,"data-testid":`run-output`,children:(0,L.jsx)(`span`,{children:e.outputExcerpt})}),e.outputExcerpt===null&&e.status===`finished`&&(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`run-output-none`,children:(0,L.jsx)(`span`,{children:`This run finished without sending anything.`})}),(0,L.jsx)(`div`,{className:`cal-modal-row`,children:(0,L.jsx)(`span`,{children:q(e.status)})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsxs)(`span`,{children:[`Due: `,J(e.scheduledFor,r)]})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsxs)(`span`,{children:[`Started: `,J(e.startedAt,r)]})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsxs)(`span`,{children:[`Dispatch ended: `,J(e.endedAt,r),` (`,Y(e.ranMs),`)`]})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsxs)(`span`,{children:[`Output seen: `,J(e.finishedAt,r)]})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsxs)(`span`,{children:[`Sent to: `,e.target,` · `,e.mode,` · `,e.kind]})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsxs)(`span`,{children:[`Transport: `,e.dispatchResult??`—`,e.httpStatus===null?``:` (HTTP ${e.httpStatus})`]})}),e.error&&(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,L.jsx)(`span`,{children:e.error})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsxs)(`span`,{children:[`Conversation: `,e.sessionKey??`—`,e.transcriptOffset===null?``:` at byte ${e.transcriptOffset}`]})}),!e.bounded&&e.status!==`gated`&&(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsx)(`span`,{children:`This run shares its conversation with other traffic, so what it produced cannot be separated out. Its status stays at whatever the dispatch reported.`})}),(0,L.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,L.jsxs)(`span`,{children:[`Run `,e.runId]})})]})]})})}function Z({status:e}){let t=K(e);return(0,L.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}var Q=500;function pe(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?l(new Date(n).toISOString(),t):e}function me(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}var he={channel:`a channel`,destination:`a destination`,prompt:`an instruction`};function ge(e){if(e===`no-dispatch-configured`)return`This routine has no dispatch set up, so there was nothing to do.`;if(e===`no-action-plugin`)return`The tool action names no plugin, so nothing ran.`;if(e===`no-action-tool`)return`The tool action names no tool, so nothing ran.`;let t=e.startsWith(`no-`)?e.slice(3).split(`+`):[];if(t.length>0&&t.every(e=>e in he)){let e=t.map(e=>he[e]);return`This routine has no ${(e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`).replace(/^an? /,``)} set, so nothing was sent.`}return e}function _e(e){return e.status===`no-destination`?e.error?ge(e.error):`Nothing was dispatched, and no reason was recorded.`:e.status===`failed`?e.error??e.dispatchResult??`The dispatch failed.`:e.status===`open`?`Opened and never closed. The dispatch did not report back.`:null}function ve(e){let t=e.indexOf(`:`);return t<=0?{channel:null,destination:e}:{channel:e.slice(0,t),destination:e.slice(t+1)}}function ye(e){return e.outputExcerpt===null?e.status===`finished`?`Finished and sent nothing.`:null:e.outputExcerpt}function be({routine:e,adminFetch:r,cacheKey:i,from:a=`card`,onBack:c}){let{zone:l}=v(),[u,d]=(0,D.useState)([]),[p,m]=(0,D.useState)(!0),[g,_]=(0,D.useState)(null),[y,b]=(0,D.useState)(null),x=(0,D.useRef)(0),S=(0,D.useCallback)(()=>{let t=!1,n=++x.current,i=()=>t||n!==x.current;return m(!0),_(null),r(`/api/admin/routines/${encodeURIComponent(e.eventId)}/runs?limit=${Q}&from=${a}`).then(async e=>{if(i())return;if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();i()||d(Array.isArray(t.runs)?t.runs:[])}).catch(e=>{i()||(_(e instanceof Error?e.message:`Failed to load`),d([]))}).finally(()=>{i()||m(!1)}),()=>{t=!0}},[r,e.eventId,a]);(0,D.useEffect)(()=>S(),[S]);let C=(0,D.useCallback)(()=>{w(i,e.eventId)},[i,e.eventId]);return(0,L.jsxs)(`div`,{className:`cal-page`,children:[(0,L.jsx)(`header`,{className:`cal-header`,children:(0,L.jsxs)(`div`,{className:`cal-nav`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:c,children:[(0,L.jsx)(s,{size:14}),` Routines`]}),(0,L.jsx)(`span`,{className:`cal-range-label runs-title`,"data-testid":`runs-title`,title:e.name??`Untitled routine`,children:e.name??`Untitled routine`}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`runs-refresh`,onClick:S,disabled:p,title:`Refresh runs`,"aria-label":`Refresh runs`,children:[p?(0,L.jsx)(o,{size:14,className:`spin`}):(0,L.jsx)(t,{size:14}),` Refresh`]}),u.length>0&&(0,L.jsx)(`div`,{className:`routine-bulk-actions`,children:(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:C,children:[(0,L.jsx)(n,{size:14}),` Download all runs`]})})]})}),(0,L.jsxs)(`div`,{className:`cal-body`,children:[g&&(0,L.jsxs)(`div`,{className:`cal-error`,children:[`Could not load runs: `,g]}),!g&&!p&&u.length===0&&(0,L.jsxs)(`div`,{className:`cal-empty`,"data-testid":`runs-empty`,children:[(0,L.jsx)(`p`,{children:`Nothing to show for this routine.`}),(0,L.jsx)(`p`,{children:`That means one of three things, and this page cannot tell them apart: it has never run, it ran but no record was written, or every run it did have is older than the 30 days records are kept for.`}),(0,L.jsxs)(`p`,{children:[`For a repeating routine, the server log settles the middle one: a`,(0,L.jsx)(`code`,{children:` fires-without-records `}),` count above zero names a routine that fired and left no record. It does not distinguish the other two, and it does not cover a one-time routine.`]})]}),u.length>=Q&&(0,L.jsxs)(`div`,{className:`cal-modal-confirm-text`,"data-testid":`runs-capped`,children:[`Showing the most recent `,Q,` runs. There may be more; the download has everything still on record.`]}),(0,L.jsx)(`div`,{className:`routine-list`,children:u.map(e=>{let t=_e(e),n=ye(e),{channel:r,destination:i}=ve(e.target);return(0,L.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,"data-testid":`run-row-${e.runId}`,onClick:()=>b(e),children:[(0,L.jsxs)(`span`,{className:`admin-card-title routine-card-title run-card-title`,children:[(0,L.jsx)(Z,{status:e.status}),` `,q(e.status)]}),(0,L.jsx)(`span`,{className:`routine-card-sched`,children:me(e.ranMs)}),(0,L.jsx)(`span`,{className:`routine-card-target`,children:r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(h,{channel:r,size:13}),` `,f[r]??r,` to `,r===`whatsapp`?H(i):i]}):i}),(0,L.jsxs)(`span`,{className:`routine-card-meta`,children:[`Due `,pe(e.scheduledFor,l)]}),n&&(0,L.jsx)(`span`,{className:`routine-card-meta run-card-output`,children:n}),t&&(0,L.jsx)(`span`,{className:`routine-card-meta run-card-detail`,children:t})]},e.runId)})})]}),y&&(0,L.jsx)(X,{run:y,routineName:e.name,onClose:()=>b(null)})]})}var $=`maxy-admin-session-key`;function xe(e){return e?ne(e):`One-time`}function Se(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?l(new Date(n).toISOString(),t):e}function Ce(){let[e,t]=(0,D.useState)(null),[n,r]=(0,D.useState)(!1),[i,o]=(0,D.useState)(void 0),[s,c]=(0,D.useState)(null),[l,u]=(0,D.useState)(void 0),[d,f]=(0,D.useState)(null),[p,h]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),h(e.role??null),u(e.userName===void 0?null:e.userName),f(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let g=(0,D.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[_,v]=(0,D.useState)(!1),b=(0,D.useCallback)(async()=>{v(!0);try{let e=await y();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{v(!1)}},[]);return n?e?(0,L.jsx)(m,{cacheKey:e,surface:`routines`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=routines`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,L.jsx)(x,{cacheKey:e,businessName:i,sessionId:s,onLogout:g,onDisconnect:b,disconnecting:_,userName:l,userAvatar:d,role:p,children:(0,L.jsx)(we,{cacheKey:e})})}):(0,L.jsx)(`div`,{className:`cal-page`,children:(0,L.jsxs)(`div`,{className:`cal-empty`,children:[(0,L.jsx)(`p`,{children:`You are not signed in.`}),(0,L.jsxs)(`p`,{children:[`Open the `,(0,L.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,L.jsx)(a,{surface:`gate`})}function we({cacheKey:e}){let{zone:n}=v(),{adminFetch:r,cacheKey:i,sessionRefetchNonce:s}=u({initialCacheKey:e,surface:`routines`}),[c,l]=(0,D.useState)([]),[d,p]=(0,D.useState)(!1),[m,g]=(0,D.useState)(!1),[_,y]=(0,D.useState)(null),[x,w]=(0,D.useState)(null),[E,O]=(0,D.useState)(null),[k,A]=(0,D.useState)(`card`),j=(0,D.useCallback)(()=>{let e=!1;return p(!0),y(null),r(`/api/admin/routines`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();l(Array.isArray(n.routines)?n.routines:[])}).catch(t=>{e||(y(t instanceof Error?t.message:`Failed to load`),l([]))}).finally(()=>{e||(p(!1),g(!0))}),()=>{e=!0}},[r]);(0,D.useEffect)(()=>j(),[j,s]);let ne=(0,D.useCallback)(e=>{l(t=>t.map(t=>t.eventId===e.eventId?e:t)),w(e)},[]),M=(0,D.useCallback)(e=>{l(t=>t.filter(t=>t.eventId!==e)),w(null)},[]),[N,P]=(0,D.useState)(!1),[F,I]=(0,D.useState)(null),R=c.filter(e=>e.eventStatus===`scheduled`).length,z=c.filter(e=>e.suspendedInBulk).length,B=(0,D.useCallback)(async e=>{P(!0),I(null);try{let t=await r(`/api/admin/routines/${e}`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}let n=await t.json(),i=n.refused?.length??0;I(e===`suspend-all`?`Suspended ${n.suspended??0}. Nothing runs on its own until you resume it.`:`Resumed ${n.restored??0}${i>0?`. ${i} could not be resumed and stayed suspended`:``}. Routines you suspended one at a time are still suspended.`),j()}catch(e){I(e instanceof Error?e.message:`Failed`)}finally{P(!1)}},[r,j]);return m?E?(0,L.jsx)(be,{routine:E,adminFetch:r,cacheKey:i,from:k,onBack:()=>O(null)}):(0,L.jsxs)(`div`,{className:`cal-page`,children:[(0,L.jsx)(`header`,{className:`cal-header`,children:(0,L.jsxs)(`div`,{className:`cal-nav`,children:[(0,L.jsxs)(`span`,{className:`cal-range-label`,children:[(0,L.jsx)(b,{size:16}),` Routines`]}),(0,L.jsxs)(`div`,{className:`routine-bulk-actions`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`routines-refresh`,onClick:j,disabled:d,title:`Refresh routines`,"aria-label":`Refresh routines`,children:[d?(0,L.jsx)(o,{size:14,className:`spin`}):(0,L.jsx)(t,{size:14}),` Refresh`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>B(`suspend-all`),disabled:N||R===0,children:[(0,L.jsx)(ee,{size:14}),` Suspend all (`,R,`)`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>B(`resume-all`),disabled:N||z===0,children:[(0,L.jsx)(te,{size:14}),` Resume all (`,z,`)`]})]})]})}),(0,L.jsxs)(`div`,{className:`cal-body`,children:[F&&(0,L.jsx)(`div`,{className:`cal-modal-confirm-text`,children:F}),_&&(0,L.jsxs)(`div`,{className:`cal-error`,children:[`Could not load routines: `,_]}),!_&&!d&&c.length===0&&(0,L.jsx)(`div`,{className:`cal-empty`,children:(0,L.jsx)(`p`,{children:`No routines yet.`})}),(0,L.jsx)(`div`,{className:`routine-list`,children:c.map(e=>(0,L.jsxs)(`div`,{className:`admin-card admin-card--padded routine-card-shell`,children:[(0,L.jsxs)(`div`,{role:`button`,tabIndex:0,className:`routine-card`,"data-testid":`routine-card-${e.eventId}`,onClick:()=>w(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),w(e))},children:[(0,L.jsx)(`span`,{className:`admin-card-title routine-card-title`,children:e.name??`Untitled routine`}),e.description&&(0,L.jsx)(`span`,{className:`routine-card-desc`,children:e.description}),(0,L.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,L.jsx)(S,{size:13}),` `,xe(e.recurrence)]}),(0,L.jsx)(`span`,{className:`routine-card-target`,children:e.agentChannel?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(h,{channel:e.agentChannel,size:13}),` `,f[e.agentChannel]??e.agentChannel,` to `,e.agentDestination??`—`]}):e.actionPlugin?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{size:13}),` `,e.actionPlugin,`.`,e.actionTool]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(S,{size:13}),` Scheduled trigger`]})}),(()=>{let t=[],n=se[oe(e)];return n&&t.push(n),e.runs24h>0&&t.push(`24h: ${e.runs24h} ${e.runs24h===1?`fire`:`fires`}, ${e.gated24h} skipped`),t.length===0?null:(0,L.jsx)(`span`,{className:`routine-card-gate`,"data-testid":`routine-gate-${e.eventId}`,children:t.join(` · `)})})(),(0,L.jsxs)(`span`,{className:`routine-card-meta`,children:[(0,L.jsx)(ae,{eventStatus:e.eventStatus}),`Next: `,Se(e.nextRun,n),` · `,e.eventStatus??`unknown`]})]}),(0,L.jsx)(`button`,{type:`button`,className:`routine-card-runs`,"data-testid":`routine-runs-${e.eventId}`,title:`View runs`,"aria-label":`View runs for ${e.name??`this routine`}`,onClick:()=>{A(`card`),O(e)},children:(0,L.jsx)(T,{size:14})})]},e.eventId))})]}),x&&(0,L.jsx)(fe,{routine:x,adminFetch:r,onClose:()=>w(null),onSaved:ne,onDeleted:M,onViewRuns:e=>{A(`modal`),w(null),O(e)}})]}):(0,L.jsx)(a,{surface:`gate`})}(0,E.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(Ce,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{M as t,O as n,U as r,V as i,at as a,ct as o,j as s,k as c,nt as l,ot as u}from"./useMediaQuery-
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{M as t,O as n,U as r,V as i,at as a,ct as o,j as s,k as c,nt as l,ot as u}from"./useMediaQuery-Baf4Huvv.js";import{h as d,k as f,t as p}from"./AdminShell-Dc5du5xX.js";import{t as m}from"./file-text-DDCrqbWB.js";var h=u(),g=e(o(),1),_=l();function v({summary:e,adminFetch:n,onClose:a,onDeleted:o}){let[c,l]=(0,g.useState)(null),[u,f]=(0,g.useState)(!0),[p,h]=(0,g.useState)(null),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let t=!1;return f(!0),h(null),n(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`).then(async e=>{if(!t){if(!e.ok)throw Error(`HTTP ${e.status}`);l((await e.json()).skill)}}).catch(e=>{t||h(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||f(!1)}),()=>{t=!0}},[n,e.plugin,e.skill]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!b&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,a]);let S=(0,g.useCallback)(async()=>{x(!0),h(null);try{let t=await n(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}o(e)}catch(e){h(e instanceof Error?e.message:`Delete failed`),x(!1),y(!1)}},[n,e,o]);return(0,_.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{b||a()},children:(0,_.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Skill detail`,onClick:e=>e.stopPropagation(),children:[(0,_.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,_.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,_.jsx)(d,{size:13}),` Skill`]}),(0,_.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:a,"aria-label":`Close`,autoFocus:!0,disabled:b,children:(0,_.jsx)(s,{size:16})})]}),(0,_.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,_.jsx)(`div`,{className:`cal-modal-title`,children:e.skill}),(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(m,{size:14}),(0,_.jsx)(`span`,{children:e.plugin})]}),u&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(i,{size:14,className:`spin`}),(0,_.jsx)(`span`,{children:`Loading…`})]}),c&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,_.jsx)(`span`,{children:c.frontmatter.description||`No description.`})}),c.frontmatter.publicEmbed&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(r,{size:14}),(0,_.jsx)(`span`,{children:`Public embed`})]}),(0,_.jsx)(`pre`,{className:`skill-body`,children:c.body.trim()||`No body content.`}),c.references.length>0&&(0,_.jsxs)(`div`,{className:`skill-refs`,children:[(0,_.jsx)(`span`,{className:`skill-refs-label`,children:`References`}),c.references.map(e=>(0,_.jsxs)(`span`,{className:`skill-ref`,children:[(0,_.jsx)(m,{size:13}),` `,e]},e))]})]})]}),p&&(0,_.jsx)(`div`,{className:`cal-modal-error`,children:p}),(0,_.jsxs)(`div`,{className:`cal-modal-actions`,children:[!v&&(0,_.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>y(!0),disabled:b||u,children:[(0,_.jsx)(t,{size:14}),` Delete`]}),v&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this skill?`}),(0,_.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:S,disabled:b,children:[b?(0,_.jsx)(i,{size:14,className:`spin`}):(0,_.jsx)(t,{size:14}),` Delete`]}),(0,_.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>y(!1),disabled:b,children:`Cancel`})]})]})]})})}var y=`maxy-admin-session-key`;function b(){let[e,t]=(0,g.useState)(null),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(void 0),[s,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(void 0),[m,h]=(0,g.useState)(null),[v,b]=(0,g.useState)(null);(0,g.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(y)}catch{}if(!n){i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&l(e.sessionId??null),b(e.role??null),d(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let S=(0,g.useCallback)(()=>{try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},[]),[C,w]=(0,g.useState)(!1),T=(0,g.useCallback)(async()=>{w(!0);try{let e=await f();if(e){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return r?e?(0,_.jsx)(c,{cacheKey:e,surface:`skills`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=skills`);try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},children:(0,_.jsx)(p,{cacheKey:e,businessName:a,sessionId:s,onLogout:S,onDisconnect:T,disconnecting:C,userName:u,userAvatar:m,role:v,children:(0,_.jsx)(x,{cacheKey:e})})}):(0,_.jsx)(`div`,{className:`cal-page`,children:(0,_.jsxs)(`div`,{className:`cal-empty`,children:[(0,_.jsx)(`p`,{children:`You are not signed in.`}),(0,_.jsxs)(`p`,{children:[`Open the `,(0,_.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,_.jsx)(n,{surface:`gate`})}function x({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:r}=a({initialCacheKey:e,surface:`skills`}),[o,s]=(0,g.useState)([]),[c,l]=(0,g.useState)(!1),[u,f]=(0,g.useState)(!1),[p,h]=(0,g.useState)(null),[y,b]=(0,g.useState)(null),x=(0,g.useCallback)(()=>{let e=!1;return l(!0),h(null),t(`/api/admin/skills`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();s(Array.isArray(n.skills)?n.skills:[])}).catch(t=>{e||(h(t instanceof Error?t.message:`Failed to load`),s([]))}).finally(()=>{e||(l(!1),f(!0))}),()=>{e=!0}},[t]);(0,g.useEffect)(()=>x(),[x,r]);let S=(0,g.useCallback)(e=>{s(t=>t.filter(t=>!(t.plugin===e.plugin&&t.skill===e.skill))),b(null),x()},[x]);return u?(0,_.jsxs)(`div`,{className:`cal-page`,children:[(0,_.jsx)(`header`,{className:`cal-header`,children:(0,_.jsxs)(`div`,{className:`cal-nav`,children:[(0,_.jsxs)(`span`,{className:`cal-range-label`,children:[(0,_.jsx)(d,{size:16}),` Skills`]}),c&&(0,_.jsx)(i,{size:16,className:`spin`})]})}),(0,_.jsxs)(`div`,{className:`cal-body`,children:[p&&(0,_.jsxs)(`div`,{className:`cal-error`,children:[`Could not load skills: `,p]}),!p&&!c&&o.length===0&&(0,_.jsx)(`div`,{className:`cal-empty`,children:(0,_.jsx)(`p`,{children:`No skills yet. Ask in chat to create one.`})}),o.length>0&&(0,_.jsx)(`div`,{className:`routine-list`,children:o.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>b(e),children:[(0,_.jsx)(`span`,{className:`admin-card-title routine-card-title`,children:e.skill}),(0,_.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,_.jsx)(m,{size:13}),` `,e.plugin]}),(0,_.jsx)(`span`,{className:`skill-card-desc`,children:e.description||`No description.`}),(0,_.jsx)(`span`,{className:`routine-card-meta`,children:e.refCount===0?`No references`:`${e.refCount} reference${e.refCount===1?``:`s`}`})]},`${e.plugin}/${e.skill}`))})]}),y&&(0,_.jsx)(v,{summary:y,adminFetch:t,onClose:()=>b(null),onDeleted:S})]}):(0,_.jsx)(n,{surface:`gate`})}(0,h.createRoot)(document.getElementById(`root`)).render((0,_.jsx)(b,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{L as t,M as n,N as r,O as i,a,at as o,ct as s,j as c,k as l,nt as u,ot as d,q as f}from"./useMediaQuery-
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{L as t,M as n,N as r,O as i,a,at as o,ct as s,j as c,k as l,nt as u,ot as d,q as f}from"./useMediaQuery-Baf4Huvv.js";import{a as p,f as m,k as h,n as g,t as _,v as ee}from"./AdminShell-Dc5du5xX.js";import{t as te}from"./play-3hlqzxLI.js";import{t as v}from"./rotate-ccw-DzXTXh3g.js";var y=d(),b=e(s(),1);function ne(e=3e4){let[t,n]=(0,b.useState)(()=>Date.now());return(0,b.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function re(e,t){let n=new Map,r=(e,t,r)=>{let i=n.get(e)??{openCount:0,totalSeconds:0};i.totalSeconds+=t,r&&(i.openCount+=1),n.set(e,i)};for(let t of e)t.clientName&&r(t.clientName,t.secondsLogged,!0);for(let e of t)e.clientName&&r(e.clientName,e.secondsLogged,!1);let i=[...n.entries()].map(([e,t])=>({name:e,openCount:t.openCount,totalSeconds:t.totalSeconds}));return i.sort((e,t)=>t.openCount-e.openCount||e.name.localeCompare(t.name)),x(e,i),i}function x(e,t){let n=t.reduce((e,t)=>e+t.openCount,0),r=e.filter(e=>!e.clientName).length,i=n+r===e.length;return i||console.warn(`[tasks-clients] reconcile-mismatch assigned=${n} unassigned=${r} openTotal=${e.length}`),i}var S=`__unassigned__`;function C(e,t){return e===`__unassigned__`?`Unassigned`:t||e.slice(0,8)}function w(e){return e===null||e===``?S:e}function ie(e,t){let n=new Map,r=(e,t)=>{let r=w(e.assigneeUserId),i=n.get(r)??{name:null,openCount:0,totalCount:0};i.name===null&&e.assigneeName&&(i.name=e.assigneeName),i.totalCount+=1,t&&(i.openCount+=1),n.set(r,i)};for(let t of e)r(t,!0);for(let e of t)r(e,!1);let i=[...n.entries()].map(([e,t])=>({userId:e,label:C(e,t.name),openCount:t.openCount,totalCount:t.totalCount}));return i.sort((e,t)=>t.openCount-e.openCount||e.label.localeCompare(t.label)),i}function T(e,t){return t===null?!0:w(e.assigneeUserId)===t}var E=u();function D(e){let t=e.name??e.userId.slice(0,8);return e.kind===`owner`?`${t} (owner)`:t}var O=`maxy-admin-session-key`;function k(e){let t=[];return e.clientName&&t.push(e.clientName),e.propertyAddress&&t.push(e.propertyAddress),e.fee!=null&&t.push(`£${e.fee}`),t.join(` · `)}function A(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=new Date(t);return`${n.getUTCDate()} ${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][n.getUTCMonth()]} ${n.getUTCFullYear()}`}function j(e){return e.assigneeName?e.assigneeName:e.assigneeUserId?e.assigneeUserId.slice(0,8):`Unassigned`}function M(e,t){return[t,A(e.createdAt),j(e)].filter(Boolean).join(` · `)}function ae(e,t){if(e.running&&e.runningStartedAt){let n=Date.parse(e.runningStartedAt);if(Number.isFinite(n))return e.secondsLogged+Math.max(0,(t-n)/1e3)}return e.secondsLogged}function oe(e){let t=[`Task: ${e.title}\nTask id: ${e.taskId}`],n=e.description.trim();n.length>0&&t.push(n);let r=e.notes.trim();return r.length>0&&t.push(`Notes:\n${r}`),t.join(`
|
|
2
2
|
|
|
3
3
|
`).slice(0,2e3)}function se({clients:e,onSelect:t}){return(0,E.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,E.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,E.jsx)(`span`,{className:`tasks-card-title`,children:`Clients`}),(0,E.jsxs)(`span`,{className:`tasks-card-count`,children:[e.length,` total`]})]}),e.length===0&&(0,E.jsx)(`div`,{className:`tasks-empty`,children:`No clients yet.`}),e.map(e=>(0,E.jsx)(`button`,{className:`tasks-row tasks-client-row`,onClick:()=>t(e.name),children:(0,E.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,E.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,E.jsxs)(`div`,{className:`tasks-row-sub`,children:[e.openCount,` open · `,a(e.totalSeconds),` logged`]})]})},e.name))]})}function ce({task:e,roster:t,busy:n,onAssign:r,onClose:i}){return(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,E.jsx)(`div`,{className:`tasks-detail-backdrop`,onClick:i,children:(0,E.jsxs)(`div`,{className:`tasks-detail`,role:`dialog`,"aria-modal":`true`,"aria-label":`Task detail`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`tasks-detail-head`,children:[(0,E.jsx)(`h2`,{className:`tasks-detail-title`,children:e?e.name:`Task no longer available`}),(0,E.jsx)(`button`,{className:`tasks-detail-close`,"aria-label":`Close`,onClick:i,children:(0,E.jsx)(c,{size:16})})]}),e===null?(0,E.jsx)(`p`,{className:`tasks-detail-gone`,children:`This task is no longer in the list. It may have been completed, cancelled or removed. Close this and reload to see the current list.`}):(0,E.jsxs)(`dl`,{className:`tasks-detail-fields`,children:[(0,E.jsx)(`dt`,{children:`Status`}),(0,E.jsx)(`dd`,{children:e.status}),(0,E.jsx)(`dt`,{children:`Logged`}),(0,E.jsx)(`dd`,{children:a(e.secondsLogged)}),(0,E.jsx)(`dt`,{children:`Created`}),(0,E.jsx)(`dd`,{children:A(e.createdAt)||`Not recorded`}),(0,E.jsx)(`dt`,{children:`Assignee`}),(0,E.jsx)(`dd`,{children:e.taskId===null?j(e):(0,E.jsxs)(`select`,{className:`tasks-assign-select`,"aria-label":`Assignee`,disabled:n,value:e.assigneeUserId??``,onChange:t=>r(e.taskId,t.target.value===``?null:t.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`Unassigned`}),e.assigneeUserId&&!t.some(t=>t.userId===e.assigneeUserId)&&(0,E.jsxs)(`option`,{value:e.assigneeUserId,children:[j(e),` (not in roster)`]}),t.map(e=>(0,E.jsx)(`option`,{value:e.userId,children:D(e)},e.userId))]})}),e.clientName&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`dt`,{children:`Client`}),(0,E.jsx)(`dd`,{children:e.clientName})]}),e.propertyAddress&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`dt`,{children:`Property`}),(0,E.jsx)(`dd`,{children:e.propertyAddress})]}),e.fee!=null&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`dt`,{children:`Fee`}),(0,E.jsxs)(`dd`,{children:[`£`,e.fee]})]})]})]})})}function N({adminFetch:e}){let[o,s]=(0,b.useState)({open:[],completed:[]}),[l,u]=(0,b.useState)(!1),[d,h]=(0,b.useState)(!1),_=(0,b.useRef)(!1),y=(0,b.useRef)(``),x=ne(1e3),[S,C]=(0,b.useState)(`open`),[w,D]=(0,b.useState)(null),[O,A]=(0,b.useState)(null),[j,N]=(0,b.useState)(null),[P,F]=(0,b.useState)(``),[I,L]=(0,b.useState)(null),[le,R]=(0,b.useState)(null),[z,B]=(0,b.useState)(null),V=(0,b.useRef)(new Map),H=(0,b.useRef)(new Set),[ue,U]=(0,b.useState)(new Set),W=(0,b.useMemo)(()=>{if(I!==null)return[...o.open,...o.completed].find(e=>e.rowKey===I)??null},[o,I]),G=(0,b.useMemo)(()=>z===null?null:[...o.open,...o.completed].find(e=>e.rowKey===z)??null,[o,z]);(0,b.useEffect)(()=>{I!==null&&W===null&&console.error(`[tasks-ui] op=detail-failed rowKey=${I} reason=not-in-list`)},[I,W]);let K=(0,b.useMemo)(()=>re(o.open,o.completed),[o]),q=(0,b.useMemo)(()=>w===null?{open:o.open,completed:o.completed}:{open:o.open.filter(e=>e.clientName===w),completed:o.completed.filter(e=>e.clientName===w)},[o,w]),J=(0,b.useMemo)(()=>ie(q.open,q.completed),[q]),de=(0,b.useCallback)(e=>{D(e),C(`open`)},[]);(0,b.useEffect)(()=>{w&&!K.some(e=>e.name===w)&&D(null)},[K,w]),(0,b.useEffect)(()=>{O&&!J.some(e=>e.userId===O)&&A(null)},[J,O]),(0,b.useEffect)(()=>{R(null),B(null)},[S,w,O]);let Y=o.open.filter(e=>e.running||(w===null||e.clientName===w)&&T(e,O)),X=(w?o.completed.filter(e=>e.clientName===w):o.completed).filter(e=>T(e,O)),[fe,pe]=(0,b.useState)([]),Z=(0,b.useCallback)(async()=>{let t=await e(`/api/admin/tasks-list`);t.ok&&s(await t.json()),u(!0)},[e]);(0,b.useEffect)(()=>{Z()},[Z]),(0,b.useEffect)(()=>{(async()=>{let t=await e(`/api/admin/admin-users-list`);if(t.ok){let e=await t.json();e.ok&&Array.isArray(e.users)&&pe(e.users)}})()},[e]);let Q=(0,b.useCallback)(async(t,n,r)=>{if(_.current)return!1;_.current=!0,h(!0);try{return await e(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:n,...r})}),await Z(),!0}finally{_.current=!1,h(!1)}},[e,Z]),me=(0,b.useCallback)(async e=>{await Q(`/api/admin/task-complete`,e)},[Q]),he=(0,b.useCallback)(async e=>{await Q(`/api/admin/task-delete`,e,{confirmed:!0})},[Q]),ge=(0,b.useCallback)((e,t)=>{let n=String(Math.round(e.secondsLogged/60));y.current=n,N(t),F(n)},[]),$=(0,b.useCallback)(()=>{N(null),F(``)},[]),_e=(0,b.useCallback)(async e=>{let t=P.trim(),n=Number(t);if(!(t===``||!Number.isInteger(n)||n<0)){if(t===y.current){$();return}N(null),F(``),await Q(`/api/admin/task-time-adjust`,e,{newSeconds:n*60})}},[P,Q,$]),ve=(0,b.useCallback)(e=>{Q(`/api/admin/task-time-adjust`,e,{newSeconds:0})},[Q]),ye=(0,b.useCallback)((e,t)=>{Q(`/api/admin/task-assign`,e,{assigneeUserId:t})},[Q]),be=(0,b.useCallback)(async t=>{if(!H.current.has(t)){H.current.add(t),U(new Set(H.current));try{let n=await e(`/api/admin/task-session-open`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:t})});if(!n.ok){console.error(`[admin-ui] task-session op=open-failed taskId=${t} status=${n.status}`);return}let{sessionId:r,title:i,description:a,notes:o}=await n.json();if(r!==null){let e=`/chat?session=${r}`;window.location.assign(e);return}let s=oe({title:i,taskId:t,description:a??``,notes:o??``}),c=await e(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:i,initialMessage:s})}),l=await c.json().catch(()=>({})),u=g(c.ok,c.status,l),d=l.sessionId??null;if(u.kind!==`navigate`){console.error(`[admin-ui] task-session op=spawn-failed taskId=${t} reason=${u.reason}`);return}if(d!==null){let n=await e(`/api/admin/task-session-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:t,sessionId:d})});n.ok&&(await n.json().catch(()=>({}))).linked}else console.error(`[admin-ui] task-session op=link-skipped taskId=${t} reason=no-landed-session-id`);window.location.assign(u.url)}catch(e){console.error(`[admin-ui] task-session op=failed taskId=${t} error=${e instanceof Error?e.message:String(e)}`)}finally{H.current.delete(t),U(new Set(H.current))}}},[e]);if(!l)return(0,E.jsx)(i,{surface:`gate`});let xe=e=>e.taskId!==null&&j===e.taskId,Se=e=>(0,E.jsxs)(`div`,{className:`tasks-edit`,children:[(0,E.jsx)(`input`,{className:`tasks-edit-input`,type:`number`,min:0,step:1,"aria-label":`Logged minutes`,value:P,onChange:e=>F(e.target.value)}),(0,E.jsx)(`span`,{className:`tasks-edit-unit`,children:`min`}),(0,E.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:d,onClick:()=>void _e(e),children:[(0,E.jsx)(f,{size:14}),` Save`]}),(0,E.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:$,children:[(0,E.jsx)(c,{size:14}),` Cancel`]})]}),Ce=(e,r)=>[{key:`edit-time`,label:`Edit logged time for task: ${e.name}`,menuLabel:`Edit time`,title:e.running?`Stop the timer before editing time`:`Set the logged time for this task`,icon:(0,E.jsx)(t,{size:12}),disabled:d||e.running,onClick:()=>ge(e,r)},{key:`reset-time`,label:`Reset logged time for task: ${e.name}`,menuLabel:`Reset logged time to 0:00`,title:e.running?`Stop the timer before resetting time`:`Set the logged time back to zero`,icon:(0,E.jsx)(v,{size:12}),disabled:d||e.running,onClick:()=>ve(r)},{key:`session`,label:`Open session for task: ${e.name}`,menuLabel:`Session`,title:e.sessionId?`Resume this task’s session`:`Start a session for this task`,icon:(0,E.jsx)(ee,{size:12}),disabled:ue.has(r),onClick:()=>{be(r)}},{key:`delete`,label:`Delete task: ${e.name}`,menuLabel:`Delete`,title:e.running?`Stop the timer before deleting`:`Delete this task and its time records`,icon:(0,E.jsx)(n,{size:12}),danger:!0,disabled:d||e.running,onClick:()=>B(e.rowKey)}];return(0,E.jsxs)(`div`,{className:`ui-page ui-page--full tasks-body`,children:[I!==null&&(0,E.jsx)(ce,{task:W??null,roster:fe,busy:d,onAssign:ye,onClose:()=>L(null)}),(0,E.jsx)(p,{target:G?{name:G.name,secondsLogged:G.secondsLogged}:null,anchorEl:z?V.current.get(z)??null:null,onCancel:()=>B(null),onConfirm:()=>{let e=G;B(null),e?.taskId&&he(e.taskId)}},z??`none`),(0,E.jsxs)(`div`,{className:`tasks-tabs`,children:[(0,E.jsxs)(`button`,{className:`admin-chip ${S===`open`?`is-active`:``}`,onClick:()=>C(`open`),children:[`Open `,(0,E.jsx)(`span`,{className:`tasks-tab-badge`,children:o.open.length})]}),(0,E.jsxs)(`button`,{className:`admin-chip ${S===`completed`?`is-active`:``}`,onClick:()=>C(`completed`),children:[`Completed `,(0,E.jsx)(`span`,{className:`tasks-tab-badge`,children:o.completed.length})]}),(0,E.jsxs)(`button`,{className:`admin-chip ${S===`clients`?`is-active`:``}`,onClick:()=>C(`clients`),children:[`Clients `,(0,E.jsx)(`span`,{className:`tasks-tab-badge`,children:K.length})]})]}),S===`clients`?(0,E.jsx)(se,{clients:K,onSelect:de}):(0,E.jsxs)(E.Fragment,{children:[w&&(0,E.jsxs)(`div`,{className:`tasks-filter-banner`,children:[(0,E.jsxs)(`span`,{children:[`Showing `,w]}),(0,E.jsx)(`button`,{className:`tasks-filter-clear`,onClick:()=>D(null),children:`Clear`})]}),J.length>0&&(0,E.jsxs)(`div`,{className:`tasks-assignee-bar`,children:[(0,E.jsxs)(`button`,{className:`admin-chip ${O===null?`is-active`:``}`,"aria-pressed":O===null,onClick:()=>A(null),children:[`All `,(0,E.jsx)(`span`,{className:`tasks-assignee-count`,children:q.open.length})]}),J.map(e=>(0,E.jsxs)(`button`,{className:`admin-chip ${O===e.userId?`is-active`:``}`,"aria-pressed":O===e.userId,"aria-label":`Assignee ${e.label}`,title:e.userId===`__unassigned__`?`Tasks with no assigned admin`:`AdminUser ${e.userId}`,onClick:()=>A(O===e.userId?null:e.userId),children:[e.label,` `,(0,E.jsx)(`span`,{className:`tasks-assignee-count`,children:e.openCount})]},e.userId))]}),S===`open`?(0,E.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,E.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,E.jsx)(`span`,{className:`tasks-card-title`,children:`Open tasks`}),(0,E.jsxs)(`span`,{className:`tasks-card-count`,children:[Y.length,` to do`]})]}),Y.length===0&&(0,E.jsx)(`div`,{className:`tasks-empty`,children:`No open tasks.`}),Y.map(e=>(0,E.jsxs)(`div`,{className:`tasks-row`,ref:t=>{t?V.current.set(e.rowKey,t):V.current.delete(e.rowKey)},children:[(0,E.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>L(e.rowKey),children:(0,E.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,E.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,E.jsx)(`div`,{className:`tasks-row-sub`,children:M(e,k(e))})]})}),(0,E.jsx)(`div`,{className:`tasks-row-elapsed ${e.running?`tasks-row-elapsed-running`:``}`,children:a(ae(e,x))}),(0,E.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId!==null&&le===e.taskId?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`tasks-confirm-label`,children:`Complete?`}),(0,E.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:d,onClick:()=>{R(null),me(e.taskId)},children:[(0,E.jsx)(f,{size:14}),` Confirm complete`]}),(0,E.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:()=>R(null),children:[(0,E.jsx)(c,{size:14}),` Keep open`]})]}):e.taskId===null?(0,E.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so it cannot be started, edited or completed. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):xe(e)?Se(e.taskId):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m,{actions:Ce(e,e.taskId),disabled:!1,label:`Task actions`}),(0,E.jsx)(`button`,{className:`tasks-btn-secondary tasks-btn-action tasks-btn-icon`,"aria-label":`Complete task: ${e.name}`,disabled:d||e.running,title:e.running?`Stop the timer before completing`:`Complete task`,onClick:()=>R(e.taskId),children:(0,E.jsx)(f,{size:14})}),e.running?(0,E.jsxs)(`button`,{className:`admin-btn-danger tasks-btn-action`,disabled:d,title:`Stop the timer`,onClick:()=>void Q(`/api/admin/task-timer-stop`,e.taskId),children:[(0,E.jsx)(r,{size:14}),` Stop`]}):(0,E.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:d,title:`Start the timer`,onClick:()=>void Q(`/api/admin/task-timer-start`,e.taskId),children:[(0,E.jsx)(te,{size:14}),` Start`]})]})})]},e.rowKey))]}):(0,E.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,E.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,E.jsx)(`span`,{className:`tasks-card-title`,children:`Completed`}),(0,E.jsxs)(`span`,{className:`tasks-card-count`,children:[X.length,` done`]})]}),X.length===0&&(0,E.jsx)(`div`,{className:`tasks-empty`,children:`Nothing completed yet.`}),X.map(e=>(0,E.jsxs)(`div`,{className:`tasks-row tasks-row-done`,ref:t=>{t?V.current.set(e.rowKey,t):V.current.delete(e.rowKey)},children:[(0,E.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>L(e.rowKey),children:(0,E.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,E.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,E.jsx)(`div`,{className:`tasks-row-sub`,children:M(e,k(e))})]})}),(0,E.jsx)(`div`,{className:`tasks-row-elapsed`,children:a(e.secondsLogged)}),(0,E.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId===null?(0,E.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so its logged time cannot be edited. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):xe(e)?Se(e.taskId):(0,E.jsx)(m,{actions:Ce(e,e.taskId),disabled:!1,label:`Task actions`})})]},e.rowKey))]})]})]})}function P({cacheKey:e}){let{adminFetch:t}=o({initialCacheKey:e,surface:`tasks`});return(0,E.jsx)(N,{adminFetch:t})}function F(){let[e,t]=(0,b.useState)(null),[n,r]=(0,b.useState)(!1),[a,o]=(0,b.useState)(void 0),[s,c]=(0,b.useState)(null),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)(null),[m,g]=(0,b.useState)(null);(0,b.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(O)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(O)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),d(e.role??null),p(e.userName===void 0?null:e.userName),g(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let ee=(0,b.useCallback)(()=>{try{sessionStorage.removeItem(O)}catch{}window.location.href=`/`},[]),[te,v]=(0,b.useState)(!1),y=(0,b.useCallback)(async()=>{v(!0);try{let e=await h();if(e){try{sessionStorage.removeItem(O)}catch{}window.location.href=`/`}return e}finally{v(!1)}},[]);return n?e?(0,E.jsx)(l,{cacheKey:e,surface:`tasks`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=tasks`);try{sessionStorage.removeItem(O)}catch{}window.location.href=`/`},children:(0,E.jsx)(_,{cacheKey:e,businessName:a,sessionId:s,onLogout:ee,onDisconnect:y,disconnecting:te,userName:f,userAvatar:m,role:u,children:(0,E.jsx)(P,{cacheKey:e})})}):(0,E.jsx)(`div`,{className:`tasks-page`,children:(0,E.jsxs)(`div`,{className:`tasks-empty`,children:[(0,E.jsx)(`p`,{children:`You are not signed in.`}),(0,E.jsxs)(`p`,{children:[`Open the `,(0,E.jsx)(`a`,{href:`/`,className:`tasks-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,E.jsx)(i,{surface:`gate`})}(0,y.createRoot)(document.getElementById(`root`)).render((0,E.jsx)(F,{}));
|
|
Binary file
|
|
Binary file
|
package/payload/server/public/assets/{triangle-alert-eh9UOKDT.js → triangle-alert-CYwHTcvU.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Z as e}from"./useMediaQuery-
|
|
1
|
+
import{Z as e}from"./useMediaQuery-Baf4Huvv.js";var t=e(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
package/payload/server/public/assets/{useCopyFeedback-Bz9OJHBb.js → useCopyFeedback-BCRjKc-H.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{ct as t,i as n}from"./useMediaQuery-
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{ct as t,i as n}from"./useMediaQuery-Baf4Huvv.js";var r=e(t(),1);function i(e){let[t,i]=(0,r.useState)(`idle`),a=(0,r.useRef)(null),o=(0,r.useRef)(e?.onResult);return o.current=e?.onResult,(0,r.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),{status:t,copy:(0,r.useCallback)(async e=>{let t=await n(e);i(t?`ok`:`fail`),o.current?.(t),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(`idle`),1500)},[])}}export{i as t};
|
|
Binary file
|
|
Binary file
|