@rubytech/create-maxy-code 0.1.537 → 0.1.538
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/plugins/admin/skills/platform-architecture/SKILL.md +95 -7
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +5 -0
- package/payload/platform/plugins/docs/PLUGIN.md +2 -0
- package/payload/platform/plugins/docs/references/admin-ui.md +14 -6
- package/payload/platform/plugins/docs/references/channel-wake-and-prompt.md +75 -0
- package/payload/platform/plugins/whatsapp/PLUGIN.md +2 -0
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js +17 -2
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +16 -0
- package/payload/platform/plugins/whatsapp/skills/connect-whatsapp/SKILL.md +1 -1
- package/payload/platform/plugins/whatsapp/skills/manage-whatsapp-config/SKILL.md +19 -3
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +15 -2
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.d.ts +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.js +5 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.js.map +1 -1
- package/payload/server/{chunk-44Z4ZFYS.js → chunk-FQO5RDWZ.js} +2 -0
- package/payload/server/{manager-AJSPM6X2.js → manager-EBZQRV5V.js} +1 -1
- package/payload/server/public/activity.html +5 -5
- package/payload/server/public/agents.html +4 -4
- package/payload/server/public/assets/{AdminLoginScreens-CYFf2awh.js → AdminLoginScreens-CfXQwKIY.js} +1 -1
- package/payload/server/public/assets/AdminLoginScreens-CfXQwKIY.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-CfXQwKIY.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-y0_mzlDF.js +2 -0
- package/payload/server/public/assets/AdminShell-y0_mzlDF.js.br +0 -0
- package/payload/server/public/assets/AdminShell-y0_mzlDF.js.gz +0 -0
- package/payload/server/public/assets/{activity-BH65sm9Q.js → activity-h8-sjHz9.js} +1 -1
- package/payload/server/public/assets/activity-h8-sjHz9.js.br +0 -0
- package/payload/server/public/assets/activity-h8-sjHz9.js.gz +0 -0
- package/payload/server/public/assets/{admin-CQtEjRGU.js → admin-BzhhLC7C.js} +1 -1
- package/payload/server/public/assets/admin-BzhhLC7C.js.br +0 -0
- package/payload/server/public/assets/admin-BzhhLC7C.js.gz +0 -0
- package/payload/server/public/assets/{agents-CjhOWwl5.js → agents-DLuhIIgn.js} +1 -1
- package/payload/server/public/assets/agents-DLuhIIgn.js.br +0 -0
- package/payload/server/public/assets/agents-DLuhIIgn.js.gz +0 -0
- package/payload/server/public/assets/{browser-DGXpfL99.js → browser-FAnTY27n.js} +1 -1
- package/payload/server/public/assets/browser-FAnTY27n.js.br +0 -0
- package/payload/server/public/assets/browser-FAnTY27n.js.gz +0 -0
- package/payload/server/public/assets/{calendar-Cu4yjEuX.js → calendar-C_PkqlkQ.js} +1 -1
- package/payload/server/public/assets/calendar-C_PkqlkQ.js.br +0 -0
- package/payload/server/public/assets/calendar-C_PkqlkQ.js.gz +0 -0
- package/payload/server/public/assets/chat-DW81Ra89.js +1 -0
- package/payload/server/public/assets/chat-DW81Ra89.js.br +0 -0
- package/payload/server/public/assets/chat-DW81Ra89.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-zV-WRzHb.js +1 -0
- package/payload/server/public/assets/chevron-left-zV-WRzHb.js.br +0 -0
- package/payload/server/public/assets/chevron-right-fnINU4bx.js +1 -0
- package/payload/server/public/assets/chevron-right-fnINU4bx.js.br +0 -0
- package/payload/server/public/assets/clock-2fSxBl6d.js +1 -0
- package/payload/server/public/assets/clock-2fSxBl6d.js.br +0 -0
- package/payload/server/public/assets/copy-Rde_TL9Q.js +1 -0
- package/payload/server/public/assets/copy-Rde_TL9Q.js.br +0 -0
- package/payload/server/public/assets/copy-Rde_TL9Q.js.gz +0 -0
- package/payload/server/public/assets/data-S5g4wIDe.js +1 -0
- package/payload/server/public/assets/data-S5g4wIDe.js.br +0 -0
- package/payload/server/public/assets/data-S5g4wIDe.js.gz +0 -0
- package/payload/server/public/assets/{file-text-CbQoZfJD.js → file-text-DMCUVg80.js} +1 -1
- package/payload/server/public/assets/file-text-DMCUVg80.js.br +0 -0
- package/payload/server/public/assets/file-text-DMCUVg80.js.gz +0 -0
- package/payload/server/public/assets/graph-Bo-WcsKS.js +51 -0
- package/payload/server/public/assets/graph-Bo-WcsKS.js.br +0 -0
- package/payload/server/public/assets/graph-Bo-WcsKS.js.gz +0 -0
- package/payload/server/public/assets/{graph-labels-D695CsC9.js → graph-labels-g-JodMWQ.js} +1 -1
- package/payload/server/public/assets/graph-labels-g-JodMWQ.js.br +0 -0
- package/payload/server/public/assets/graph-labels-g-JodMWQ.js.gz +0 -0
- package/payload/server/public/assets/operator-X_LcOnAI.js +1 -0
- package/payload/server/public/assets/operator-X_LcOnAI.js.br +0 -0
- package/payload/server/public/assets/operator-X_LcOnAI.js.gz +0 -0
- package/payload/server/public/assets/page-Cz0p1mBf.js +1 -0
- package/payload/server/public/assets/page-Cz0p1mBf.js.br +0 -0
- package/payload/server/public/assets/page-Cz0p1mBf.js.gz +0 -0
- package/payload/server/public/assets/page-Dzs3MsFL.js +32 -0
- package/payload/server/public/assets/page-Dzs3MsFL.js.br +0 -0
- package/payload/server/public/assets/page-Dzs3MsFL.js.gz +0 -0
- package/payload/server/public/assets/{play-CbRU6q0T.js → play-CraN5kUU.js} +1 -1
- package/payload/server/public/assets/play-CraN5kUU.js.br +0 -0
- package/payload/server/public/assets/play-CraN5kUU.js.gz +0 -0
- package/payload/server/public/assets/{public-CqbKJ-Q3.js → public--NUjaJ-q.js} +1 -1
- package/payload/server/public/assets/public--NUjaJ-q.js.br +0 -0
- package/payload/server/public/assets/public--NUjaJ-q.js.gz +0 -0
- package/payload/server/public/assets/{rotate-ccw-CjliWBou.js → rotate-ccw-DshFgg2T.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-DshFgg2T.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-DshFgg2T.js.gz +0 -0
- package/payload/server/public/assets/routines-CfAS4gri.js +2 -0
- package/payload/server/public/assets/routines-CfAS4gri.js.br +0 -0
- package/payload/server/public/assets/routines-CfAS4gri.js.gz +0 -0
- package/payload/server/public/assets/{skills-ipK9BJFb.js → skills-CM6ryWpx.js} +1 -1
- package/payload/server/public/assets/skills-CM6ryWpx.js.br +0 -0
- package/payload/server/public/assets/skills-CM6ryWpx.js.gz +0 -0
- package/payload/server/public/assets/{tasks-CGcJHQ3X.js → tasks-B07m9LIA.js} +2 -2
- package/payload/server/public/assets/tasks-B07m9LIA.js.br +0 -0
- package/payload/server/public/assets/tasks-B07m9LIA.js.gz +0 -0
- package/payload/server/public/assets/{triangle-alert-CjsLPsBD.js → triangle-alert-CKHyS_gC.js} +1 -1
- package/payload/server/public/assets/triangle-alert-CKHyS_gC.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-CKHyS_gC.js.gz +0 -0
- package/payload/server/public/assets/{useCopyFeedback-umIgCxI_.js → useCopyFeedback-CmawEsVi.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-CmawEsVi.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-CmawEsVi.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-CVHqKsqK.js +14 -0
- package/payload/server/public/assets/useSubAccountSwitcher-CVHqKsqK.js.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-CVHqKsqK.js.gz +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-D8jXV7R5.css → useSubAccountSwitcher-yN4lhH2x.css} +1 -1
- package/payload/server/public/assets/useSubAccountSwitcher-yN4lhH2x.css.br +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-D8jXV7R5.css.gz → useSubAccountSwitcher-yN4lhH2x.css.gz} +0 -0
- package/payload/server/public/assets/useVoiceRecorder-DpQTvvqD.js +2 -0
- package/payload/server/public/assets/useVoiceRecorder-DpQTvvqD.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-DpQTvvqD.js.gz +0 -0
- package/payload/server/public/assets/{wrench-DtfKfR4s.js → wrench-BPOEUNJB.js} +1 -1
- package/payload/server/public/assets/wrench-BPOEUNJB.js.br +0 -0
- package/payload/server/public/assets/wrench-BPOEUNJB.js.gz +0 -0
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +7 -7
- 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 +299 -74
- package/payload/server/public/assets/AdminLoginScreens-CYFf2awh.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-CYFf2awh.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js +0 -2
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js.br +0 -0
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js.gz +0 -0
- package/payload/server/public/assets/activity-BH65sm9Q.js.br +0 -0
- package/payload/server/public/assets/activity-BH65sm9Q.js.gz +0 -0
- package/payload/server/public/assets/admin-CQtEjRGU.js.br +0 -0
- package/payload/server/public/assets/admin-CQtEjRGU.js.gz +0 -0
- package/payload/server/public/assets/agents-CjhOWwl5.js.br +0 -0
- package/payload/server/public/assets/agents-CjhOWwl5.js.gz +0 -0
- package/payload/server/public/assets/browser-DGXpfL99.js.br +0 -0
- package/payload/server/public/assets/browser-DGXpfL99.js.gz +0 -0
- package/payload/server/public/assets/calendar-Cu4yjEuX.js.br +0 -0
- package/payload/server/public/assets/calendar-Cu4yjEuX.js.gz +0 -0
- package/payload/server/public/assets/chat-0na4XVZC.js +0 -1
- package/payload/server/public/assets/chat-0na4XVZC.js.br +0 -0
- package/payload/server/public/assets/chat-0na4XVZC.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-DHzJobWp.js +0 -1
- package/payload/server/public/assets/chevron-left-DHzJobWp.js.br +0 -0
- package/payload/server/public/assets/chevron-right-yg4DMfLT.js +0 -1
- package/payload/server/public/assets/chevron-right-yg4DMfLT.js.br +0 -0
- package/payload/server/public/assets/clock-BIDzihvp.js +0 -1
- package/payload/server/public/assets/clock-BIDzihvp.js.br +0 -0
- package/payload/server/public/assets/clock-BIDzihvp.js.gz +0 -0
- package/payload/server/public/assets/data-Ql9qG3YO.js +0 -1
- package/payload/server/public/assets/data-Ql9qG3YO.js.br +0 -0
- package/payload/server/public/assets/data-Ql9qG3YO.js.gz +0 -0
- package/payload/server/public/assets/file-text-CbQoZfJD.js.br +0 -0
- package/payload/server/public/assets/file-text-CbQoZfJD.js.gz +0 -0
- package/payload/server/public/assets/graph-7414Kjn9.js +0 -51
- package/payload/server/public/assets/graph-7414Kjn9.js.br +0 -0
- package/payload/server/public/assets/graph-7414Kjn9.js.gz +0 -0
- package/payload/server/public/assets/graph-labels-D695CsC9.js.br +0 -0
- package/payload/server/public/assets/graph-labels-D695CsC9.js.gz +0 -0
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js +0 -1
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js.br +0 -0
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js.gz +0 -0
- package/payload/server/public/assets/operator-CLw4PZs5.js +0 -1
- package/payload/server/public/assets/operator-CLw4PZs5.js.br +0 -0
- package/payload/server/public/assets/operator-CLw4PZs5.js.gz +0 -0
- package/payload/server/public/assets/page-BNRFmFc-.js +0 -32
- package/payload/server/public/assets/page-BNRFmFc-.js.br +0 -0
- package/payload/server/public/assets/page-BNRFmFc-.js.gz +0 -0
- package/payload/server/public/assets/page-BRr295G2.js +0 -1
- package/payload/server/public/assets/page-BRr295G2.js.br +0 -0
- package/payload/server/public/assets/page-BRr295G2.js.gz +0 -0
- package/payload/server/public/assets/play-CbRU6q0T.js.br +0 -0
- package/payload/server/public/assets/play-CbRU6q0T.js.gz +0 -0
- package/payload/server/public/assets/public-CqbKJ-Q3.js.br +0 -0
- package/payload/server/public/assets/public-CqbKJ-Q3.js.gz +0 -0
- package/payload/server/public/assets/rotate-ccw-CjliWBou.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-CjliWBou.js.gz +0 -0
- package/payload/server/public/assets/routines-yJuRuBfn.js +0 -2
- package/payload/server/public/assets/routines-yJuRuBfn.js.br +0 -0
- package/payload/server/public/assets/routines-yJuRuBfn.js.gz +0 -0
- package/payload/server/public/assets/skills-ipK9BJFb.js.br +0 -0
- package/payload/server/public/assets/skills-ipK9BJFb.js.gz +0 -0
- package/payload/server/public/assets/tasks-CGcJHQ3X.js.br +0 -0
- package/payload/server/public/assets/tasks-CGcJHQ3X.js.gz +0 -0
- package/payload/server/public/assets/triangle-alert-CjsLPsBD.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-CjsLPsBD.js.gz +0 -0
- package/payload/server/public/assets/useCopyFeedback-umIgCxI_.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-umIgCxI_.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-D8jXV7R5.css.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js +0 -14
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js.gz +0 -0
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js +0 -2
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js.gz +0 -0
- package/payload/server/public/assets/wrench-DtfKfR4s.js.br +0 -0
- package/payload/server/public/assets/wrench-DtfKfR4s.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,Y as n,Z as r}from"./useSubAccountSwitcher-CVHqKsqK.js";import"./useVoiceRecorder-DpQTvvqD.js";import{O as i}from"./AdminShell-y0_mzlDF.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./page-Dzs3MsFL.js";import"./useCopyFeedback-CmawEsVi.js";var d=n(),f=e(r(),1),p=t();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{
|
|
1
|
+
import{B as e}from"./useSubAccountSwitcher-CVHqKsqK.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{A as t,B as n,E as r,G as i,J as a,P as o,R as s,Y as c,Z as l,_ as u,b as d,d as f,p,v as m,x as h}from"./useSubAccountSwitcher-CVHqKsqK.js";import{A as g,h as _,t as v}from"./AdminShell-y0_mzlDF.js";import{t as y}from"./clock-2fSxBl6d.js";import{t as b}from"./wrench-BPOEUNJB.js";import{r as x}from"./file-download-DbNIjWiK.js";var ee=n(`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`}]]),S=n(`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`}]]),C=n(`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`}]]),w=c(),T=e(l(),1),E=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function D(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 O(e){return String(e).padStart(2,`0`)}function k(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`:`${E[e%7]} to ${E[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>E[Number(e)%7]).join(`, `):`invalid`}function A(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=D(n,59),c=D(r,23);if(!s||!c)return e;let l=k(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}, ${O(c.value)}:00 to ${O(c.value)}:59${u}`:`${e}, ${O(c.rangeStart)}:00 to ${O(d(c))}:00${u}`}if(c.kind===`step`){let e=O(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${O(c.rangeStart)}:${e} to ${O(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${O(c.rangeStart)}:${e} to ${O(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${O(s.value)}`}${u}`;let f=`${O(c.value)}:${O(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var j={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function M(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 N(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=D(n,59),c=D(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=M(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{...j,...f,timeMode:`everyMinutes`,minute:0,interval:e,window:t}}return c.kind===`fixed`?{...j,...f,timeMode:`at`,minute:s.value,hour:c.value}:c.kind===`any`?{...j,...f,timeMode:`everyHours`,minute:s.value,interval:1,window:null}:{...j,...f,timeMode:`everyHours`,minute:s.value,interval:c.step,window:c.rangeStart===null?null:{start:c.rangeStart,end:c.rangeEnd}}}function P(e){return e.dayMode===`dayOfMonth`?[String(e.dayOfMonth),`*`]:e.dayMode===`weekdays`&&e.weekdays.length>0?[`*`,[...e.weekdays].sort((e,t)=>e-t).join(`,`)]:[`*`,`*`]}function F(e){let[t,n]=P(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 I=i(),L=[{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`}],R=Array.from({length:24},(e,t)=>t),z=e=>String(e).padStart(2,`0`),B={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function te({recurrence:e,onChange:t,disabled:n}){let r=e?N(e):B,[i,a]=(0,T.useState)(r??B),[o]=(0,T.useState)(e!=null&&r==null),[s,c]=(0,T.useState)(e??``);if((0,T.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,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Schedule (advanced)`}),(0,I.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,I.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(F(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,I.jsxs)(`div`,{className:`routine-sched`,children:[(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`How often`}),(0,I.jsxs)(`select`,{"aria-label":`How often`,value:i.timeMode,disabled:n,onChange:e=>u(e.target.value),children:[(0,I.jsx)(`option`,{value:`at`,children:`At a time of day`}),(0,I.jsx)(`option`,{value:`everyMinutes`,children:`Every few minutes`}),(0,I.jsx)(`option`,{value:`everyHours`,children:`Every few hours`})]})]}),i.timeMode===`at`&&(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Time of day`}),(0,I.jsx)(`input`,{type:`time`,"aria-label":`Time of day`,value:`${z(i.hour)}:${z(i.minute)}`,disabled:n,onChange:e=>f(e.target.value)})]}),i.timeMode===`everyMinutes`&&(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Minutes between runs`}),(0,I.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,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Hours between runs`}),(0,I.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,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Minute of the hour`}),(0,I.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,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`label`,{className:`cal-modal-field routine-sched-check`,children:[(0,I.jsx)(`input`,{type:`checkbox`,"aria-label":`Only between certain hours`,checked:i.window!==null,disabled:n,onChange:e=>m(e.target.checked)}),(0,I.jsx)(`span`,{children:`Only between certain hours`})]}),i.window!==null&&(0,I.jsxs)(`div`,{className:`routine-sched-row`,children:[(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`From hour`}),(0,I.jsx)(`select`,{"aria-label":`From hour`,value:i.window.start,disabled:n,onChange:e=>h(`start`,e.target.value),children:R.map(e=>(0,I.jsxs)(`option`,{value:e,children:[z(e),`:00`]},e))})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`To hour`}),(0,I.jsx)(`select`,{"aria-label":`To hour`,value:i.window.end,disabled:n,onChange:e=>h(`end`,e.target.value),children:R.map(e=>(0,I.jsxs)(`option`,{value:e,children:[z(e),`:00`]},e))})]})]})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Which days`}),(0,I.jsxs)(`select`,{"aria-label":`Which days`,value:i.dayMode,disabled:n,onChange:e=>d(e.target.value),children:[(0,I.jsx)(`option`,{value:`every`,children:`Every day`}),(0,I.jsx)(`option`,{value:`weekdays`,children:`Specific days`}),i.timeMode===`at`&&(0,I.jsx)(`option`,{value:`dayOfMonth`,children:`A day of the month`})]})]}),i.dayMode===`weekdays`&&(0,I.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Days`}),(0,I.jsx)(`div`,{className:`routine-weekdays`,children:L.map(e=>(0,I.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,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Day of month`}),(0,I.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,I.jsx)(`option`,{value:e,children:e},e))})]})]})}function V(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 ne(e){if(e.name)return`${e.name} · ${e.label}`;let t=e.channel===`whatsapp`?V(e.destination):e.destination;return`${e.label} · ${t}`}var H={scheduled:`live`,due:`live`,suspended:`stood-down`,cancelled:`inert`,completed:`inert`};function U(e){return e==null||!Object.hasOwn(H,e)?`unknown`:H[e]}function W({eventStatus:e}){let t=U(e);return(0,I.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}function G(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function re(e){return e?e.split(`
|
|
2
|
+
`).filter(e=>e.trim()!==``).reverse():[]}function K({routine:e,adminFetch:n,onClose:i,onSaved:a,onDeleted:o,onViewRuns:s}){let[c,l]=(0,T.useState)(!1),[u,m]=(0,T.useState)(!1),[g,v]=(0,T.useState)(null),[x,w]=(0,T.useState)(e),[E,D]=(0,T.useState)(!1),O=x.agentChannel!=null,k=x.eventStatus===`suspended`,[j,M]=(0,T.useState)(!1),[N,P]=(0,T.useState)(e.agentPrompt??``),[F,L]=(0,T.useState)(e.recurrence),[R,z]=(0,T.useState)(e.agentChannel??``),[B,V]=(0,T.useState)(e.agentDestination??``),[H,U]=(0,T.useState)(null),[K,q]=(0,T.useState)(null),J=O||x.actionPlugin==null,Y=re(x.notes);(0,T.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!u&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,i]),(0,T.useEffect)(()=>{if(!c||!J||H!==null)return;let e=!1;return n(`/api/admin/dispatch-destinations`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(t=>{e||U(t.destinations)}).catch(t=>{e||(U([]),q(t instanceof Error?t.message:`Could not load destinations`))}),()=>{e=!0}},[c,J,H,n]);let X=(H??[]).filter(e=>e.channel===R),Z=R.length>0&&B.length>0,ie=R.length>0&&B.length===0||Z&&N.trim().length===0,Q=(0,T.useCallback)(()=>{let e={},t=R.length>0&&B.length>0;return(O||t)&&N!==(x.agentPrompt??``)&&(e.agentPrompt=N),F!=null&&F!==(x.recurrence??null)&&(e.recurrence=F),t&&(R!==(x.agentChannel??``)||B!==(x.agentDestination??``))?(e.agentChannel=R,e.agentDestination=B):!t&&R===``&&(x.agentChannel??``)!==``&&(e.agentChannel=null,e.agentDestination=null),e},[O,N,F,R,B,x]),ae=(0,T.useCallback)(async()=>{let t=Q();if(Object.keys(t).length===0){l(!1);return}m(!0),v(null);try{let r=await n(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let i=await r.json();w(i.routine),P(i.routine.agentPrompt??``),L(i.routine.recurrence),z(i.routine.agentChannel??``),V(i.routine.agentDestination??``),a(i.routine),l(!1)}catch(e){v(e instanceof Error?e.message:`Save failed`)}finally{m(!1)}},[n,Q,e.eventId,a]),oe=(0,T.useCallback)(async()=>{if(u)return;if(!j){D(!1),M(!0);return}let t=k?`resume`:`suspend`;m(!0),v(null);try{let r=await n(`/api/admin/routines/${encodeURIComponent(e.eventId)}/${t}`,{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),M(!1)}catch(e){v(e instanceof Error?e.message:`${t} failed`),M(!1)}finally{m(!1)}},[n,u,j,k,e.eventId,a]),se=(0,T.useCallback)(async()=>{if(!u){if(!E){M(!1),D(!0);return}m(!0),v(null);try{let t=await n(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}o(e.eventId)}catch(e){v(e instanceof Error?e.message:`Delete failed`),D(!1)}finally{m(!1)}}},[n,u,E,e.eventId,o]);return(0,I.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{u||i()},children:(0,I.jsxs)(`div`,{className:`cal-modal ${!c||O||Z?`cal-modal-wide`:`cal-modal-dispatch`}`,role:`dialog`,"aria-modal":`true`,"aria-label":c?`Edit routine`:`Routine detail`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,I.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,I.jsx)(_,{size:13}),` Routine`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:u,children:(0,I.jsx)(d,{size:16})})]}),!c&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsx)(`div`,{className:`cal-modal-title`,children:x.name??`Untitled routine`}),(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(y,{size:14}),(0,I.jsx)(`span`,{children:x.recurrence?A(x.recurrence):`One-time`})]}),(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,I.jsx)(W,{eventStatus:x.eventStatus}),(0,I.jsxs)(`span`,{children:[`Status: `,x.eventStatus??`unknown`]})]}),(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.jsxs)(`span`,{children:[`Next run: `,G(x.nextRun)]})}),(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,I.jsx)(C,{size:14}),(0,I.jsxs)(`span`,{children:[`Last run: `,G(x.lastTriggered),x.lastDispatchResult?` (${x.lastDispatchResult})`:``]})]}),O?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(p,{channel:x.agentChannel,size:14}),(0,I.jsxs)(`span`,{children:[f[x.agentChannel]??x.agentChannel,` to `,x.agentDestination??`—`]})]}),(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,I.jsx)(`span`,{children:x.agentPrompt??`No instruction set.`})})]}):x.actionPlugin?(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(b,{size:14}),(0,I.jsxs)(`span`,{children:[x.actionPlugin,`.`,x.actionTool,x.actionArgs?` ${x.actionArgs}`:``]})]}):(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(y,{size:14}),(0,I.jsx)(`span`,{children:`Scheduled trigger (no dispatch)`})]}),Y.length===0?(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,I.jsx)(C,{size:14}),(0,I.jsx)(`span`,{children:`No history recorded.`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,I.jsx)(C,{size:14}),(0,I.jsxs)(`span`,{children:[`History (`,Y.length,` `,Y.length===1?`entry`:`entries`,`)`]})]}),(0,I.jsx)(`div`,{className:`routine-history`,children:Y.map((e,t)=>(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:e},t))})]})]}),c&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[J&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Send to`}),(0,I.jsxs)(`div`,{className:`cal-modal-field-inline`,children:[(0,I.jsxs)(`select`,{value:R,disabled:u,onChange:e=>{z(e.target.value),V(``)},children:[(0,I.jsx)(`option`,{value:``,children:`None (no dispatch)`}),(0,I.jsx)(`option`,{value:`whatsapp`,children:`WhatsApp`}),(0,I.jsx)(`option`,{value:`telegram`,children:`Telegram`})]}),R!==``&&(0,I.jsx)(p,{channel:R,size:16})]})]}),R!==``&&(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Destination`}),(0,I.jsxs)(`select`,{value:B,disabled:u||H===null,onChange:e=>V(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:H===null?`Loading destinations`:X.length===0?`No registered destinations`:`Choose a destination`}),B!==``&&!X.some(e=>e.destination===B)&&(0,I.jsxs)(`option`,{value:B,children:[B,` (not in the current list)`]}),X.map(e=>(0,I.jsx)(`option`,{value:e.destination,children:ne(e)},e.destination))]})]}),K&&(0,I.jsxs)(`div`,{className:`cal-modal-error`,children:[`Could not load destinations: `,K]})]}),(O||Z)&&(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Instruction`}),(0,I.jsx)(`textarea`,{className:`cal-modal-textarea`,value:N,onChange:e=>P(e.target.value),disabled:u,rows:16,placeholder:`What should the agent do when this routine fires?`})]}),(0,I.jsx)(te,{recurrence:x.recurrence,onChange:L,disabled:u})]}),g&&(0,I.jsx)(`div`,{className:`cal-modal-error`,children:g}),(0,I.jsxs)(`div`,{className:`cal-modal-actions`,children:[!c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{D(!1),M(!1),l(!0)},disabled:u,children:[(0,I.jsx)(r,{size:14}),` Edit`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>s(x),disabled:u,children:[(0,I.jsx)(C,{size:14}),` Runs`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:oe,disabled:u,children:[u&&j?(0,I.jsx)(t,{size:14,className:`spin`}):k?(0,I.jsx)(S,{size:14}):(0,I.jsx)(ee,{size:14}),j?k?`Confirm resume`:`Confirm suspend`:k?`Resume`:`Suspend`]}),j&&(0,I.jsx)(`span`,{className:`cal-modal-confirm-text`,children:k?`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,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:se,disabled:u,children:[u&&E?(0,I.jsx)(t,{size:14,className:`spin`}):(0,I.jsx)(h,{size:14}),E?`Confirm delete`:`Delete`]})]}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:ae,disabled:u||ie,children:[u?(0,I.jsx)(t,{size:14,className:`spin`}):null,` Save`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{l(!1),v(null)},disabled:u,children:`Cancel`})]})]})]})})}function q(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function J(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function Y({run:e,routineName:t,onClose:n}){return(0,T.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,I.jsx)(`div`,{className:`cal-modal-overlay`,onClick:n,children:(0,I.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Run detail`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,I.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,I.jsx)(C,{size:13}),` Run`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,children:(0,I.jsx)(d,{size:16})})]}),(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsx)(`div`,{className:`cal-modal-title`,children:t??`Untitled routine`}),(0,I.jsx)(`div`,{className:`cal-modal-row`,children:(0,I.jsx)(`span`,{children:e.status})}),(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.jsxs)(`span`,{children:[`Due: `,q(e.scheduledFor)]})}),(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.jsxs)(`span`,{children:[`Started: `,q(e.startedAt)]})}),(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.jsxs)(`span`,{children:[`Dispatch ended: `,q(e.endedAt),` (`,J(e.ranMs),`)`]})}),(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.jsxs)(`span`,{children:[`Output seen: `,q(e.finishedAt)]})}),(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.jsxs)(`span`,{children:[`Sent to: `,e.target,` · `,e.mode,` · `,e.kind]})}),(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.jsxs)(`span`,{children:[`Transport: `,e.dispatchResult??`—`,e.httpStatus===null?``:` (HTTP ${e.httpStatus})`]})}),e.error&&(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,I.jsx)(`span`,{children:e.error})}),(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.jsxs)(`span`,{children:[`Conversation: `,e.sessionKey??`—`,e.transcriptOffset===null?``:` at byte ${e.transcriptOffset}`]})}),!e.bounded&&(0,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.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,I.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,I.jsxs)(`span`,{children:[`Run `,e.runId]})})]})]})})}var X=500;function Z(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function ie(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}var Q={channel:`a channel`,destination:`a destination`,prompt:`an instruction`};function ae(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 Q)){let e=t.map(e=>Q[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 oe(e){return e.status===`no-destination`?e.error?ae(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 se({routine:e,adminFetch:n,cacheKey:r,onBack:i}){let[a,c]=(0,T.useState)([]),[l,u]=(0,T.useState)(!0),[d,f]=(0,T.useState)(null),[p,m]=(0,T.useState)(null);(0,T.useEffect)(()=>{let t=!1;return u(!0),f(null),n(`/api/admin/routines/${encodeURIComponent(e.eventId)}/runs?limit=${X}`).then(async e=>{if(t)return;if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json();c(Array.isArray(n.runs)?n.runs:[])}).catch(e=>{t||(f(e instanceof Error?e.message:`Failed to load`),c([]))}).finally(()=>{t||u(!1)}),()=>{t=!0}},[n,e.eventId]);let h=(0,T.useCallback)(()=>{x(r,e.eventId)},[r,e.eventId]);return(0,I.jsxs)(`div`,{className:`cal-page`,children:[(0,I.jsx)(`header`,{className:`cal-header`,children:(0,I.jsxs)(`div`,{className:`cal-nav`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:i,children:[(0,I.jsx)(s,{size:14}),` Routines`]}),(0,I.jsxs)(`span`,{className:`cal-range-label`,children:[(0,I.jsx)(C,{size:16}),` `,e.name??`Untitled routine`]}),l&&(0,I.jsx)(t,{size:16,className:`spin`}),a.length>0&&(0,I.jsx)(`div`,{className:`routine-bulk-actions`,children:(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:h,children:[(0,I.jsx)(o,{size:14}),` Download all runs`]})})]})}),(0,I.jsxs)(`div`,{className:`cal-body`,children:[d&&(0,I.jsxs)(`div`,{className:`cal-error`,children:[`Could not load runs: `,d]}),!d&&!l&&a.length===0&&(0,I.jsxs)(`div`,{className:`cal-empty`,"data-testid":`runs-empty`,children:[(0,I.jsx)(`p`,{children:`Nothing to show for this routine.`}),(0,I.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,I.jsxs)(`p`,{children:[`For a repeating routine, the server log settles the middle one: a`,(0,I.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.`]})]}),a.length>=X&&(0,I.jsxs)(`div`,{className:`cal-modal-confirm-text`,"data-testid":`runs-capped`,children:[`Showing the most recent `,X,` runs. There may be more; the download has everything still on record.`]}),(0,I.jsx)(`div`,{className:`routine-list`,children:a.map(e=>{let t=oe(e);return(0,I.jsxs)(`button`,{type:`button`,className:`routine-card`,"data-testid":`run-row-${e.runId}`,onClick:()=>m(e),children:[(0,I.jsx)(`span`,{className:`routine-card-title`,children:e.status}),(0,I.jsx)(`span`,{className:`routine-card-sched`,children:ie(e.ranMs)}),(0,I.jsx)(`span`,{className:`routine-card-target`,children:e.target}),(0,I.jsxs)(`span`,{className:`routine-card-meta`,children:[`Due `,Z(e.scheduledFor)]}),t&&(0,I.jsx)(`span`,{className:`routine-card-meta run-card-detail`,children:t})]},e.runId)})})]}),p&&(0,I.jsx)(Y,{run:p,routineName:e.name,onClose:()=>m(null)})]})}var $=`maxy-admin-session-key`;function ce(e){return e?A(e):`One-time`}function le(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function ue(){let[e,t]=(0,T.useState)(null),[n,r]=(0,T.useState)(!1),[i,a]=(0,T.useState)(void 0),[o,s]=(0,T.useState)(null),[c,l]=(0,T.useState)(void 0),[d,f]=(0,T.useState)(null),[p,h]=(0,T.useState)(null);(0,T.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`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),h(e.role??null),l(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 _=(0,T.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,T.useState)(!1),x=(0,T.useCallback)(async()=>{b(!0);try{let e=await g();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,I.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,I.jsx)(v,{cacheKey:e,businessName:i,sessionId:o,onLogout:_,onDisconnect:x,disconnecting:y,userName:c,userAvatar:d,role:p,children:(0,I.jsx)(de,{cacheKey:e})})}):(0,I.jsx)(`div`,{className:`cal-page`,children:(0,I.jsxs)(`div`,{className:`cal-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:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,I.jsx)(u,{surface:`gate`})}function de({cacheKey:e}){let{adminFetch:n,cacheKey:r,sessionRefetchNonce:i}=a({initialCacheKey:e,surface:`routines`}),[o,s]=(0,T.useState)([]),[c,l]=(0,T.useState)(!1),[d,m]=(0,T.useState)(!1),[h,g]=(0,T.useState)(null),[v,x]=(0,T.useState)(null),[C,w]=(0,T.useState)(null),E=(0,T.useCallback)(()=>{let e=!1;return l(!0),g(null),n(`/api/admin/routines`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();s(Array.isArray(n.routines)?n.routines:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),s([]))}).finally(()=>{e||(l(!1),m(!0))}),()=>{e=!0}},[n]);(0,T.useEffect)(()=>E(),[E,i]);let D=(0,T.useCallback)(e=>{s(t=>t.map(t=>t.eventId===e.eventId?e:t)),x(e)},[]),O=(0,T.useCallback)(e=>{s(t=>t.filter(t=>t.eventId!==e)),x(null)},[]),[k,A]=(0,T.useState)(!1),[j,M]=(0,T.useState)(null),N=o.filter(e=>e.eventStatus===`scheduled`).length,P=o.filter(e=>e.suspendedInBulk).length,F=(0,T.useCallback)(async e=>{A(!0),M(null);try{let t=await n(`/api/admin/routines/${e}`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}let r=await t.json(),i=r.refused?.length??0;M(e===`suspend-all`?`Suspended ${r.suspended??0}. Nothing runs on its own until you resume it.`:`Resumed ${r.restored??0}${i>0?`. ${i} could not be resumed and stayed suspended`:``}. Routines you suspended one at a time are still suspended.`),E()}catch(e){M(e instanceof Error?e.message:`Failed`)}finally{A(!1)}},[n,E]);return d?C?(0,I.jsx)(se,{routine:C,adminFetch:n,cacheKey:r,onBack:()=>w(null)}):(0,I.jsxs)(`div`,{className:`cal-page`,children:[(0,I.jsx)(`header`,{className:`cal-header`,children:(0,I.jsxs)(`div`,{className:`cal-nav`,children:[(0,I.jsxs)(`span`,{className:`cal-range-label`,children:[(0,I.jsx)(_,{size:16}),` Routines`]}),c&&(0,I.jsx)(t,{size:16,className:`spin`}),(0,I.jsxs)(`div`,{className:`routine-bulk-actions`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>F(`suspend-all`),disabled:k||N===0,children:[(0,I.jsx)(ee,{size:14}),` Suspend all (`,N,`)`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>F(`resume-all`),disabled:k||P===0,children:[(0,I.jsx)(S,{size:14}),` Resume all (`,P,`)`]})]})]})}),(0,I.jsxs)(`div`,{className:`cal-body`,children:[j&&(0,I.jsx)(`div`,{className:`cal-modal-confirm-text`,children:j}),h&&(0,I.jsxs)(`div`,{className:`cal-error`,children:[`Could not load routines: `,h]}),!h&&!c&&o.length===0&&(0,I.jsx)(`div`,{className:`cal-empty`,children:(0,I.jsx)(`p`,{children:`No routines yet.`})}),(0,I.jsx)(`div`,{className:`routine-list`,children:o.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>x(e),children:[(0,I.jsx)(`span`,{className:`admin-card-title routine-card-title`,children:e.name??`Untitled routine`}),e.routineDescription&&(0,I.jsx)(`span`,{className:`routine-card-desc`,children:e.routineDescription}),(0,I.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,I.jsx)(y,{size:13}),` `,ce(e.recurrence)]}),(0,I.jsx)(`span`,{className:`routine-card-target`,children:e.agentChannel?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(p,{channel:e.agentChannel,size:13}),` `,f[e.agentChannel]??e.agentChannel,` to `,e.agentDestination??`—`]}):e.actionPlugin?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(b,{size:13}),` `,e.actionPlugin,`.`,e.actionTool]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(y,{size:13}),` Scheduled trigger`]})}),(0,I.jsxs)(`span`,{className:`routine-card-meta`,children:[(0,I.jsx)(W,{eventStatus:e.eventStatus}),`Next: `,le(e.nextRun),` · `,e.eventStatus??`unknown`]})]},e.eventId))})]}),v&&(0,I.jsx)(K,{routine:v,adminFetch:n,onClose:()=>x(null),onSaved:D,onDeleted:O,onViewRuns:e=>{x(null),w(e)}})]}):(0,I.jsx)(u,{surface:`gate`})}(0,w.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(ue,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,G as n,J as r,M as i,Y as a,Z as o,_ as s,b as c,v as l,x as u}from"./useSubAccountSwitcher-CVHqKsqK.js";import{A as d,g as f,t as p}from"./AdminShell-y0_mzlDF.js";import{t as m}from"./file-text-DMCUVg80.js";var h=a(),g=e(o(),1),_=n();function v({summary:e,adminFetch:n,onClose:r,onDeleted:a}){let[o,s]=(0,g.useState)(null),[l,d]=(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 d(!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}`);s((await e.json()).skill)}}).catch(e=>{t||h(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||d(!1)}),()=>{t=!0}},[n,e.plugin,e.skill]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!b&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,r]);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}`)}a(e)}catch(e){h(e instanceof Error?e.message:`Delete failed`),x(!1),y(!1)}},[n,e,a]);return(0,_.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{b||r()},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)(f,{size:13}),` Skill`]}),(0,_.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:b,children:(0,_.jsx)(c,{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})]}),l&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(t,{size:14,className:`spin`}),(0,_.jsx)(`span`,{children:`Loading…`})]}),o&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,_.jsx)(`span`,{children:o.frontmatter.description||`No description.`})}),o.frontmatter.publicEmbed&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(i,{size:14}),(0,_.jsx)(`span`,{children:`Public embed`})]}),(0,_.jsx)(`pre`,{className:`skill-body`,children:o.body.trim()||`No body content.`}),o.references.length>0&&(0,_.jsxs)(`div`,{className:`skill-refs`,children:[(0,_.jsx)(`span`,{className:`skill-refs-label`,children:`References`}),o.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||l,children:[(0,_.jsx)(u,{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)(t,{size:14,className:`spin`}):(0,_.jsx)(u,{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),[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(void 0),[o,c]=(0,g.useState)(null),[u,f]=(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){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),b(e.role??null),f(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!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 d();if(e){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,_.jsx)(l,{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:i,sessionId:o,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)(s,{surface:`gate`})}function x({cacheKey:e}){let{adminFetch:n,sessionRefetchNonce:i}=r({initialCacheKey:e,surface:`skills`}),[a,o]=(0,g.useState)([]),[c,l]=(0,g.useState)(!1),[u,d]=(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),n(`/api/admin/skills`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();o(Array.isArray(n.skills)?n.skills:[])}).catch(t=>{e||(h(t instanceof Error?t.message:`Failed to load`),o([]))}).finally(()=>{e||(l(!1),d(!0))}),()=>{e=!0}},[n]);(0,g.useEffect)(()=>x(),[x,i]);let S=(0,g.useCallback)(e=>{o(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)(f,{size:16}),` Skills`]}),c&&(0,_.jsx)(t,{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&&a.length===0&&(0,_.jsx)(`div`,{className:`cal-empty`,children:(0,_.jsx)(`p`,{children:`No skills yet. Ask in chat to create one.`})}),a.length>0&&(0,_.jsx)(`div`,{className:`routine-list`,children:a.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:n,onClose:()=>b(null),onDeleted:S})]}):(0,_.jsx)(s,{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{E as t,
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{E as t,G as n,I as r,J as i,S as a,Y as o,Z as s,_ as c,b as l,i as u,v as d,x as f}from"./useSubAccountSwitcher-CVHqKsqK.js";import{A as p,o as ee,p as m,r as h,t as g,y as _}from"./AdminShell-y0_mzlDF.js";import{t as v}from"./play-CraN5kUU.js";import{t as y}from"./rotate-ccw-DshFgg2T.js";var b=o(),x=e(s(),1);function te(e=3e4){let[t,n]=(0,x.useState)(()=>Date.now());return(0,x.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ne(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)),S(e,i),i}function S(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 C=`__unassigned__`;function w(e,t){return e===`__unassigned__`?`Unassigned`:t||e.slice(0,8)}function T(e){return e===null||e===``?C:e}function re(e,t){let n=new Map,r=(e,t)=>{let r=T(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:w(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 E(e,t){return t===null?!0:T(e.assigneeUserId)===t}var D=n();function O(e){let t=e.name??e.userId.slice(0,8);return e.kind===`owner`?`${t} (owner)`:t}var k=`maxy-admin-session-key`;function ie(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
|
-
`).slice(0,2e3)}function se({clients:e,onSelect:t}){return(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Clients`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[e.length,` total`]})]}),e.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`No clients yet.`}),e.map(e=>(0,D.jsx)(`button`,{className:`tasks-row tasks-client-row`,onClick:()=>t(e.name),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsxs)(`div`,{className:`tasks-row-sub`,children:[e.openCount,` open · `,l(e.totalSeconds),` logged`]})]})},e.name))]})}function ce({task:e,roster:t,busy:n,onAssign:r,onClose:i}){return(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,D.jsx)(`div`,{className:`tasks-detail-backdrop`,onClick:i,children:(0,D.jsxs)(`div`,{className:`tasks-detail`,role:`dialog`,"aria-modal":`true`,"aria-label":`Task detail`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`tasks-detail-head`,children:[(0,D.jsx)(`h2`,{className:`tasks-detail-title`,children:e?e.name:`Task no longer available`}),(0,D.jsx)(`button`,{className:`tasks-detail-close`,"aria-label":`Close`,onClick:i,children:(0,D.jsx)(c,{size:16})})]}),e===null?(0,D.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,D.jsxs)(`dl`,{className:`tasks-detail-fields`,children:[(0,D.jsx)(`dt`,{children:`Status`}),(0,D.jsx)(`dd`,{children:e.status}),(0,D.jsx)(`dt`,{children:`Logged`}),(0,D.jsx)(`dd`,{children:l(e.secondsLogged)}),(0,D.jsx)(`dt`,{children:`Created`}),(0,D.jsx)(`dd`,{children:A(e.createdAt)||`Not recorded`}),(0,D.jsx)(`dt`,{children:`Assignee`}),(0,D.jsx)(`dd`,{children:e.taskId===null?j(e):(0,D.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,D.jsx)(`option`,{value:``,children:`Unassigned`}),e.assigneeUserId&&!t.some(t=>t.userId===e.assigneeUserId)&&(0,D.jsxs)(`option`,{value:e.assigneeUserId,children:[j(e),` (not in roster)`]}),t.map(e=>(0,D.jsx)(`option`,{value:e.userId,children:O(e)},e.userId))]})}),e.clientName&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Client`}),(0,D.jsx)(`dd`,{children:e.clientName})]}),e.propertyAddress&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Property`}),(0,D.jsx)(`dd`,{children:e.propertyAddress})]}),e.fee!=null&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Fee`}),(0,D.jsxs)(`dd`,{children:[`£`,e.fee]})]})]})]})})}function N({adminFetch:e}){let[r,a]=(0,x.useState)({open:[],completed:[]}),[o,u]=(0,x.useState)(!1),[d,p]=(0,x.useState)(!1),g=(0,x.useRef)(!1),b=(0,x.useRef)(``),S=te(1e3),[C,w]=(0,x.useState)(`open`),[T,O]=(0,x.useState)(null),[k,A]=(0,x.useState)(null),[j,N]=(0,x.useState)(null),[P,F]=(0,x.useState)(``),[I,L]=(0,x.useState)(null),[le,R]=(0,x.useState)(null),[z,B]=(0,x.useState)(null),V=(0,x.useRef)(new Map),H=(0,x.useRef)(new Set),[ue,de]=(0,x.useState)(new Set),U=(0,x.useMemo)(()=>{if(I!==null)return[...r.open,...r.completed].find(e=>e.rowKey===I)??null},[r,I]),W=(0,x.useMemo)(()=>z===null?null:[...r.open,...r.completed].find(e=>e.rowKey===z)??null,[r,z]);(0,x.useEffect)(()=>{I!==null&&U===null&&console.error(`[tasks-ui] op=detail-failed rowKey=${I} reason=not-in-list`)},[I,U]);let G=(0,x.useMemo)(()=>ne(r.open,r.completed),[r]),K=(0,x.useMemo)(()=>T===null?{open:r.open,completed:r.completed}:{open:r.open.filter(e=>e.clientName===T),completed:r.completed.filter(e=>e.clientName===T)},[r,T]),q=(0,x.useMemo)(()=>re(K.open,K.completed),[K]),fe=(0,x.useCallback)(e=>{O(e),w(`open`)},[]);(0,x.useEffect)(()=>{T&&!G.some(e=>e.name===T)&&O(null)},[G,T]),(0,x.useEffect)(()=>{k&&!q.some(e=>e.userId===k)&&A(null)},[q,k]),(0,x.useEffect)(()=>{R(null),B(null)},[C,T,k]);let J=r.open.filter(e=>e.running||(T===null||e.clientName===T)&&E(e,k)),Y=(T?r.completed.filter(e=>e.clientName===T):r.completed).filter(e=>E(e,k)),[pe,me]=(0,x.useState)([]),X=(0,x.useCallback)(async()=>{let t=await e(`/api/admin/tasks-list`);t.ok&&a(await t.json()),u(!0)},[e]);(0,x.useEffect)(()=>{X()},[X]),(0,x.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)&&me(e.users)}})()},[e]);let Z=(0,x.useCallback)(async(t,n,r)=>{if(g.current)return!1;g.current=!0,p(!0);try{return await e(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:n,...r})}),await X(),!0}finally{g.current=!1,p(!1)}},[e,X]),he=(0,x.useCallback)(async e=>{await Z(`/api/admin/task-complete`,e)},[Z]),ge=(0,x.useCallback)(async e=>{await Z(`/api/admin/task-delete`,e,{confirmed:!0})},[Z]),_e=(0,x.useCallback)((e,t)=>{let n=String(Math.round(e.secondsLogged/60));b.current=n,N(t),F(n)},[]),Q=(0,x.useCallback)(()=>{N(null),F(``)},[]),ve=(0,x.useCallback)(async e=>{let t=P.trim(),n=Number(t);if(!(t===``||!Number.isInteger(n)||n<0)){if(t===b.current){Q();return}N(null),F(``),await Z(`/api/admin/task-time-adjust`,e,{newSeconds:n*60})}},[P,Z,Q]),ye=(0,x.useCallback)(e=>{Z(`/api/admin/task-time-adjust`,e,{newSeconds:0})},[Z]),be=(0,x.useCallback)((e,t)=>{Z(`/api/admin/task-assign`,e,{assigneeUserId:t})},[Z]),xe=(0,x.useCallback)(async t=>{if(!H.current.has(t)){H.current.add(t),de(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=h(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),de(new Set(H.current))}}},[e]);if(!o)return(0,D.jsx)(s,{surface:`gate`});let Se=e=>e.taskId!==null&&j===e.taskId,Ce=e=>(0,D.jsxs)(`div`,{className:`tasks-edit`,children:[(0,D.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,D.jsx)(`span`,{className:`tasks-edit-unit`,children:`min`}),(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:d,onClick:()=>void ve(e),children:[(0,D.jsx)(n,{size:14}),` Save`]}),(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:Q,children:[(0,D.jsx)(c,{size:14}),` Cancel`]})]}),$=(e,n)=>[{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,D.jsx)(t,{size:12}),disabled:d||e.running,onClick:()=>_e(e,n)},{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,D.jsx)(y,{size:12}),disabled:d||e.running,onClick:()=>ye(n)},{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,D.jsx)(_,{size:12}),disabled:ue.has(n),onClick:()=>{xe(n)}},{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,D.jsx)(f,{size:12}),danger:!0,disabled:d||e.running,onClick:()=>B(e.rowKey)}];return(0,D.jsxs)(`div`,{className:`ui-page ui-page--full tasks-body`,children:[I!==null&&(0,D.jsx)(ce,{task:U??null,roster:pe,busy:d,onAssign:be,onClose:()=>L(null)}),(0,D.jsx)(ee,{target:W?{name:W.name,secondsLogged:W.secondsLogged}:null,anchorEl:z?V.current.get(z)??null:null,onCancel:()=>B(null),onConfirm:()=>{let e=W;B(null),e?.taskId&&ge(e.taskId)}},z??`none`),(0,D.jsxs)(`div`,{className:`tasks-tabs`,children:[(0,D.jsxs)(`button`,{className:`admin-chip ${C===`open`?`is-active`:``}`,onClick:()=>w(`open`),children:[`Open `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:r.open.length})]}),(0,D.jsxs)(`button`,{className:`admin-chip ${C===`completed`?`is-active`:``}`,onClick:()=>w(`completed`),children:[`Completed `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:r.completed.length})]}),(0,D.jsxs)(`button`,{className:`admin-chip ${C===`clients`?`is-active`:``}`,onClick:()=>w(`clients`),children:[`Clients `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:G.length})]})]}),C===`clients`?(0,D.jsx)(se,{clients:G,onSelect:fe}):(0,D.jsxs)(D.Fragment,{children:[T&&(0,D.jsxs)(`div`,{className:`tasks-filter-banner`,children:[(0,D.jsxs)(`span`,{children:[`Showing `,T]}),(0,D.jsx)(`button`,{className:`tasks-filter-clear`,onClick:()=>O(null),children:`Clear`})]}),q.length>0&&(0,D.jsxs)(`div`,{className:`tasks-assignee-bar`,children:[(0,D.jsxs)(`button`,{className:`admin-chip ${k===null?`is-active`:``}`,"aria-pressed":k===null,onClick:()=>A(null),children:[`All `,(0,D.jsx)(`span`,{className:`tasks-assignee-count`,children:K.open.length})]}),q.map(e=>(0,D.jsxs)(`button`,{className:`admin-chip ${k===e.userId?`is-active`:``}`,"aria-pressed":k===e.userId,"aria-label":`Assignee ${e.label}`,title:e.userId===`__unassigned__`?`Tasks with no assigned admin`:`AdminUser ${e.userId}`,onClick:()=>A(k===e.userId?null:e.userId),children:[e.label,` `,(0,D.jsx)(`span`,{className:`tasks-assignee-count`,children:e.openCount})]},e.userId))]}),C===`open`?(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Open tasks`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[J.length,` to do`]})]}),J.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`No open tasks.`}),J.map(e=>(0,D.jsxs)(`div`,{className:`tasks-row`,ref:t=>{t?V.current.set(e.rowKey,t):V.current.delete(e.rowKey)},children:[(0,D.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>L(e.rowKey),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsx)(`div`,{className:`tasks-row-sub`,children:M(e,ie(e))})]})}),(0,D.jsx)(`div`,{className:`tasks-row-elapsed ${e.running?`tasks-row-elapsed-running`:``}`,children:l(ae(e,S))}),(0,D.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId!==null&&le===e.taskId?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`tasks-confirm-label`,children:`Complete?`}),(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:d,onClick:()=>{R(null),he(e.taskId)},children:[(0,D.jsx)(n,{size:14}),` Confirm complete`]}),(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:()=>R(null),children:[(0,D.jsx)(c,{size:14}),` Keep open`]})]}):e.taskId===null?(0,D.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`}):Se(e)?Ce(e.taskId):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(m,{actions:$(e,e.taskId),disabled:!1,label:`Task actions`}),(0,D.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,D.jsx)(n,{size:14})}),e.running?(0,D.jsxs)(`button`,{className:`admin-btn-danger tasks-btn-action`,disabled:d,title:`Stop the timer`,onClick:()=>void Z(`/api/admin/task-timer-stop`,e.taskId),children:[(0,D.jsx)(i,{size:14}),` Stop`]}):(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:d,title:`Start the timer`,onClick:()=>void Z(`/api/admin/task-timer-start`,e.taskId),children:[(0,D.jsx)(v,{size:14}),` Start`]})]})})]},e.rowKey))]}):(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Completed`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[Y.length,` done`]})]}),Y.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`Nothing completed yet.`}),Y.map(e=>(0,D.jsxs)(`div`,{className:`tasks-row tasks-row-done`,ref:t=>{t?V.current.set(e.rowKey,t):V.current.delete(e.rowKey)},children:[(0,D.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>L(e.rowKey),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsx)(`div`,{className:`tasks-row-sub`,children:M(e,ie(e))})]})}),(0,D.jsx)(`div`,{className:`tasks-row-elapsed`,children:l(e.secondsLogged)}),(0,D.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId===null?(0,D.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`}):Se(e)?Ce(e.taskId):(0,D.jsx)(m,{actions:$(e,e.taskId),disabled:!1,label:`Task actions`})})]},e.rowKey))]})]})]})}function P({cacheKey:e}){let{adminFetch:t}=u({initialCacheKey:e,surface:`tasks`});return(0,D.jsx)(N,{adminFetch:t})}function F(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(void 0),[o,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(null),[f,ee]=(0,x.useState)(null),[m,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(k)}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(k)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),u(e.role??null),ee(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let _=(0,x.useCallback)(()=>{try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`},[]),[v,y]=(0,x.useState)(!1),b=(0,x.useCallback)(async()=>{y(!0);try{let e=await p();if(e){try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`}return e}finally{y(!1)}},[]);return n?e?(0,D.jsx)(d,{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(k)}catch{}window.location.href=`/`},children:(0,D.jsx)(g,{cacheKey:e,businessName:i,sessionId:o,onLogout:_,onDisconnect:b,disconnecting:v,userName:f,userAvatar:m,role:l,children:(0,D.jsx)(P,{cacheKey:e})})}):(0,D.jsx)(`div`,{className:`tasks-page`,children:(0,D.jsxs)(`div`,{className:`tasks-empty`,children:[(0,D.jsx)(`p`,{children:`You are not signed in.`}),(0,D.jsxs)(`p`,{children:[`Open the `,(0,D.jsx)(`a`,{href:`/`,className:`tasks-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,D.jsx)(s,{surface:`gate`})}(0,b.createRoot)(document.getElementById(`root`)).render((0,D.jsx)(F,{}));
|
|
3
|
+
`).slice(0,2e3)}function se({clients:e,onSelect:t}){return(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Clients`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[e.length,` total`]})]}),e.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`No clients yet.`}),e.map(e=>(0,D.jsx)(`button`,{className:`tasks-row tasks-client-row`,onClick:()=>t(e.name),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsxs)(`div`,{className:`tasks-row-sub`,children:[e.openCount,` open · `,u(e.totalSeconds),` logged`]})]})},e.name))]})}function ce({task:e,roster:t,busy:n,onAssign:r,onClose:i}){return(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,D.jsx)(`div`,{className:`tasks-detail-backdrop`,onClick:i,children:(0,D.jsxs)(`div`,{className:`tasks-detail`,role:`dialog`,"aria-modal":`true`,"aria-label":`Task detail`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`tasks-detail-head`,children:[(0,D.jsx)(`h2`,{className:`tasks-detail-title`,children:e?e.name:`Task no longer available`}),(0,D.jsx)(`button`,{className:`tasks-detail-close`,"aria-label":`Close`,onClick:i,children:(0,D.jsx)(l,{size:16})})]}),e===null?(0,D.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,D.jsxs)(`dl`,{className:`tasks-detail-fields`,children:[(0,D.jsx)(`dt`,{children:`Status`}),(0,D.jsx)(`dd`,{children:e.status}),(0,D.jsx)(`dt`,{children:`Logged`}),(0,D.jsx)(`dd`,{children:u(e.secondsLogged)}),(0,D.jsx)(`dt`,{children:`Created`}),(0,D.jsx)(`dd`,{children:A(e.createdAt)||`Not recorded`}),(0,D.jsx)(`dt`,{children:`Assignee`}),(0,D.jsx)(`dd`,{children:e.taskId===null?j(e):(0,D.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,D.jsx)(`option`,{value:``,children:`Unassigned`}),e.assigneeUserId&&!t.some(t=>t.userId===e.assigneeUserId)&&(0,D.jsxs)(`option`,{value:e.assigneeUserId,children:[j(e),` (not in roster)`]}),t.map(e=>(0,D.jsx)(`option`,{value:e.userId,children:O(e)},e.userId))]})}),e.clientName&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Client`}),(0,D.jsx)(`dd`,{children:e.clientName})]}),e.propertyAddress&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Property`}),(0,D.jsx)(`dd`,{children:e.propertyAddress})]}),e.fee!=null&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Fee`}),(0,D.jsxs)(`dd`,{children:[`£`,e.fee]})]})]})]})})}function N({adminFetch:e}){let[n,i]=(0,x.useState)({open:[],completed:[]}),[o,s]=(0,x.useState)(!1),[d,p]=(0,x.useState)(!1),g=(0,x.useRef)(!1),b=(0,x.useRef)(``),S=te(1e3),[C,w]=(0,x.useState)(`open`),[T,O]=(0,x.useState)(null),[k,A]=(0,x.useState)(null),[j,N]=(0,x.useState)(null),[P,F]=(0,x.useState)(``),[I,L]=(0,x.useState)(null),[le,R]=(0,x.useState)(null),[z,B]=(0,x.useState)(null),V=(0,x.useRef)(new Map),H=(0,x.useRef)(new Set),[ue,de]=(0,x.useState)(new Set),U=(0,x.useMemo)(()=>{if(I!==null)return[...n.open,...n.completed].find(e=>e.rowKey===I)??null},[n,I]),W=(0,x.useMemo)(()=>z===null?null:[...n.open,...n.completed].find(e=>e.rowKey===z)??null,[n,z]);(0,x.useEffect)(()=>{I!==null&&U===null&&console.error(`[tasks-ui] op=detail-failed rowKey=${I} reason=not-in-list`)},[I,U]);let G=(0,x.useMemo)(()=>ne(n.open,n.completed),[n]),K=(0,x.useMemo)(()=>T===null?{open:n.open,completed:n.completed}:{open:n.open.filter(e=>e.clientName===T),completed:n.completed.filter(e=>e.clientName===T)},[n,T]),q=(0,x.useMemo)(()=>re(K.open,K.completed),[K]),fe=(0,x.useCallback)(e=>{O(e),w(`open`)},[]);(0,x.useEffect)(()=>{T&&!G.some(e=>e.name===T)&&O(null)},[G,T]),(0,x.useEffect)(()=>{k&&!q.some(e=>e.userId===k)&&A(null)},[q,k]),(0,x.useEffect)(()=>{R(null),B(null)},[C,T,k]);let J=n.open.filter(e=>e.running||(T===null||e.clientName===T)&&E(e,k)),Y=(T?n.completed.filter(e=>e.clientName===T):n.completed).filter(e=>E(e,k)),[pe,me]=(0,x.useState)([]),X=(0,x.useCallback)(async()=>{let t=await e(`/api/admin/tasks-list`);t.ok&&i(await t.json()),s(!0)},[e]);(0,x.useEffect)(()=>{X()},[X]),(0,x.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)&&me(e.users)}})()},[e]);let Z=(0,x.useCallback)(async(t,n,r)=>{if(g.current)return!1;g.current=!0,p(!0);try{return await e(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:n,...r})}),await X(),!0}finally{g.current=!1,p(!1)}},[e,X]),he=(0,x.useCallback)(async e=>{await Z(`/api/admin/task-complete`,e)},[Z]),ge=(0,x.useCallback)(async e=>{await Z(`/api/admin/task-delete`,e,{confirmed:!0})},[Z]),_e=(0,x.useCallback)((e,t)=>{let n=String(Math.round(e.secondsLogged/60));b.current=n,N(t),F(n)},[]),Q=(0,x.useCallback)(()=>{N(null),F(``)},[]),ve=(0,x.useCallback)(async e=>{let t=P.trim(),n=Number(t);if(!(t===``||!Number.isInteger(n)||n<0)){if(t===b.current){Q();return}N(null),F(``),await Z(`/api/admin/task-time-adjust`,e,{newSeconds:n*60})}},[P,Z,Q]),ye=(0,x.useCallback)(e=>{Z(`/api/admin/task-time-adjust`,e,{newSeconds:0})},[Z]),be=(0,x.useCallback)((e,t)=>{Z(`/api/admin/task-assign`,e,{assigneeUserId:t})},[Z]),xe=(0,x.useCallback)(async t=>{if(!H.current.has(t)){H.current.add(t),de(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=h(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),de(new Set(H.current))}}},[e]);if(!o)return(0,D.jsx)(c,{surface:`gate`});let Se=e=>e.taskId!==null&&j===e.taskId,Ce=e=>(0,D.jsxs)(`div`,{className:`tasks-edit`,children:[(0,D.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,D.jsx)(`span`,{className:`tasks-edit-unit`,children:`min`}),(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:d,onClick:()=>void ve(e),children:[(0,D.jsx)(r,{size:14}),` Save`]}),(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:Q,children:[(0,D.jsx)(l,{size:14}),` Cancel`]})]}),$=(e,n)=>[{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,D.jsx)(t,{size:12}),disabled:d||e.running,onClick:()=>_e(e,n)},{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,D.jsx)(y,{size:12}),disabled:d||e.running,onClick:()=>ye(n)},{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,D.jsx)(_,{size:12}),disabled:ue.has(n),onClick:()=>{xe(n)}},{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,D.jsx)(f,{size:12}),danger:!0,disabled:d||e.running,onClick:()=>B(e.rowKey)}];return(0,D.jsxs)(`div`,{className:`ui-page ui-page--full tasks-body`,children:[I!==null&&(0,D.jsx)(ce,{task:U??null,roster:pe,busy:d,onAssign:be,onClose:()=>L(null)}),(0,D.jsx)(ee,{target:W?{name:W.name,secondsLogged:W.secondsLogged}:null,anchorEl:z?V.current.get(z)??null:null,onCancel:()=>B(null),onConfirm:()=>{let e=W;B(null),e?.taskId&&ge(e.taskId)}},z??`none`),(0,D.jsxs)(`div`,{className:`tasks-tabs`,children:[(0,D.jsxs)(`button`,{className:`admin-chip ${C===`open`?`is-active`:``}`,onClick:()=>w(`open`),children:[`Open `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:n.open.length})]}),(0,D.jsxs)(`button`,{className:`admin-chip ${C===`completed`?`is-active`:``}`,onClick:()=>w(`completed`),children:[`Completed `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:n.completed.length})]}),(0,D.jsxs)(`button`,{className:`admin-chip ${C===`clients`?`is-active`:``}`,onClick:()=>w(`clients`),children:[`Clients `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:G.length})]})]}),C===`clients`?(0,D.jsx)(se,{clients:G,onSelect:fe}):(0,D.jsxs)(D.Fragment,{children:[T&&(0,D.jsxs)(`div`,{className:`tasks-filter-banner`,children:[(0,D.jsxs)(`span`,{children:[`Showing `,T]}),(0,D.jsx)(`button`,{className:`tasks-filter-clear`,onClick:()=>O(null),children:`Clear`})]}),q.length>0&&(0,D.jsxs)(`div`,{className:`tasks-assignee-bar`,children:[(0,D.jsxs)(`button`,{className:`admin-chip ${k===null?`is-active`:``}`,"aria-pressed":k===null,onClick:()=>A(null),children:[`All `,(0,D.jsx)(`span`,{className:`tasks-assignee-count`,children:K.open.length})]}),q.map(e=>(0,D.jsxs)(`button`,{className:`admin-chip ${k===e.userId?`is-active`:``}`,"aria-pressed":k===e.userId,"aria-label":`Assignee ${e.label}`,title:e.userId===`__unassigned__`?`Tasks with no assigned admin`:`AdminUser ${e.userId}`,onClick:()=>A(k===e.userId?null:e.userId),children:[e.label,` `,(0,D.jsx)(`span`,{className:`tasks-assignee-count`,children:e.openCount})]},e.userId))]}),C===`open`?(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Open tasks`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[J.length,` to do`]})]}),J.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`No open tasks.`}),J.map(e=>(0,D.jsxs)(`div`,{className:`tasks-row`,ref:t=>{t?V.current.set(e.rowKey,t):V.current.delete(e.rowKey)},children:[(0,D.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>L(e.rowKey),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsx)(`div`,{className:`tasks-row-sub`,children:M(e,ie(e))})]})}),(0,D.jsx)(`div`,{className:`tasks-row-elapsed ${e.running?`tasks-row-elapsed-running`:``}`,children:u(ae(e,S))}),(0,D.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId!==null&&le===e.taskId?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`tasks-confirm-label`,children:`Complete?`}),(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:d,onClick:()=>{R(null),he(e.taskId)},children:[(0,D.jsx)(r,{size:14}),` Confirm complete`]}),(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:()=>R(null),children:[(0,D.jsx)(l,{size:14}),` Keep open`]})]}):e.taskId===null?(0,D.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`}):Se(e)?Ce(e.taskId):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(m,{actions:$(e,e.taskId),disabled:!1,label:`Task actions`}),(0,D.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,D.jsx)(r,{size:14})}),e.running?(0,D.jsxs)(`button`,{className:`admin-btn-danger tasks-btn-action`,disabled:d,title:`Stop the timer`,onClick:()=>void Z(`/api/admin/task-timer-stop`,e.taskId),children:[(0,D.jsx)(a,{size:14}),` Stop`]}):(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:d,title:`Start the timer`,onClick:()=>void Z(`/api/admin/task-timer-start`,e.taskId),children:[(0,D.jsx)(v,{size:14}),` Start`]})]})})]},e.rowKey))]}):(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Completed`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[Y.length,` done`]})]}),Y.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`Nothing completed yet.`}),Y.map(e=>(0,D.jsxs)(`div`,{className:`tasks-row tasks-row-done`,ref:t=>{t?V.current.set(e.rowKey,t):V.current.delete(e.rowKey)},children:[(0,D.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>L(e.rowKey),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsx)(`div`,{className:`tasks-row-sub`,children:M(e,ie(e))})]})}),(0,D.jsx)(`div`,{className:`tasks-row-elapsed`,children:u(e.secondsLogged)}),(0,D.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId===null?(0,D.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`}):Se(e)?Ce(e.taskId):(0,D.jsx)(m,{actions:$(e,e.taskId),disabled:!1,label:`Task actions`})})]},e.rowKey))]})]})]})}function P({cacheKey:e}){let{adminFetch:t}=i({initialCacheKey:e,surface:`tasks`});return(0,D.jsx)(N,{adminFetch:t})}function F(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(void 0),[o,s]=(0,x.useState)(null),[l,u]=(0,x.useState)(null),[f,ee]=(0,x.useState)(null),[m,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(k)}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(k)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),u(e.role??null),ee(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let _=(0,x.useCallback)(()=>{try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`},[]),[v,y]=(0,x.useState)(!1),b=(0,x.useCallback)(async()=>{y(!0);try{let e=await p();if(e){try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`}return e}finally{y(!1)}},[]);return n?e?(0,D.jsx)(d,{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(k)}catch{}window.location.href=`/`},children:(0,D.jsx)(g,{cacheKey:e,businessName:i,sessionId:o,onLogout:_,onDisconnect:b,disconnecting:v,userName:f,userAvatar:m,role:l,children:(0,D.jsx)(P,{cacheKey:e})})}):(0,D.jsx)(`div`,{className:`tasks-page`,children:(0,D.jsxs)(`div`,{className:`tasks-empty`,children:[(0,D.jsx)(`p`,{children:`You are not signed in.`}),(0,D.jsxs)(`p`,{children:[`Open the `,(0,D.jsx)(`a`,{href:`/`,className:`tasks-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,D.jsx)(c,{surface:`gate`})}(0,b.createRoot)(document.getElementById(`root`)).render((0,D.jsx)(F,{}));
|
|
Binary file
|
|
Binary file
|
package/payload/server/public/assets/{triangle-alert-CjsLPsBD.js → triangle-alert-CKHyS_gC.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{B as e}from"./useSubAccountSwitcher-CVHqKsqK.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-umIgCxI_.js → useCopyFeedback-CmawEsVi.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{Z as t,r as n}from"./useSubAccountSwitcher-CVHqKsqK.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
|