libre-webui 0.29.0 → 0.31.0
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/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +24 -7
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts +9 -0
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.js +38 -0
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.js.map +1 -0
- package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
- package/backend/dist/persistence/postgresMigrationRegistry.js +4 -0
- package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.js +5 -0
- package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts +13 -0
- package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresWorkApprovalsMigration.js +69 -0
- package/backend/dist/persistence/postgresWorkApprovalsMigration.js.map +1 -0
- package/backend/dist/persistence/resourceTypes.d.ts +4 -0
- package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
- package/backend/dist/persistence/resourceTypes.js.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.d.ts +3 -0
- package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.js +156 -2
- package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.js +7 -0
- package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js +32 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts +10 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js +85 -5
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js.map +1 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts +10 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js +67 -7
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js.map +1 -1
- package/backend/dist/platform/workPersistence/types.d.ts +37 -0
- package/backend/dist/platform/workPersistence/types.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/types.js.map +1 -1
- package/backend/dist/routes/automations.d.ts.map +1 -1
- package/backend/dist/routes/automations.js +83 -1
- package/backend/dist/routes/automations.js.map +1 -1
- package/backend/dist/routes/ollama.d.ts.map +1 -1
- package/backend/dist/routes/ollama.js +64 -0
- package/backend/dist/routes/ollama.js.map +1 -1
- package/backend/dist/routes/plugins.d.ts.map +1 -1
- package/backend/dist/routes/plugins.js +90 -0
- package/backend/dist/routes/plugins.js.map +1 -1
- package/backend/dist/routes/work.d.ts.map +1 -1
- package/backend/dist/routes/work.js +83 -0
- package/backend/dist/routes/work.js.map +1 -1
- package/backend/dist/services/authService.d.ts +2 -0
- package/backend/dist/services/authService.d.ts.map +1 -1
- package/backend/dist/services/authService.js +2 -0
- package/backend/dist/services/authService.js.map +1 -1
- package/backend/dist/services/automationService.d.ts +13 -1
- package/backend/dist/services/automationService.d.ts.map +1 -1
- package/backend/dist/services/automationService.js +31 -0
- package/backend/dist/services/automationService.js.map +1 -1
- package/backend/dist/services/notificationService.d.ts.map +1 -1
- package/backend/dist/services/notificationService.js +1 -0
- package/backend/dist/services/notificationService.js.map +1 -1
- package/backend/dist/services/ollamaService.d.ts +12 -0
- package/backend/dist/services/ollamaService.d.ts.map +1 -1
- package/backend/dist/services/ollamaService.js +26 -0
- package/backend/dist/services/ollamaService.js.map +1 -1
- package/backend/dist/services/ollamaSettingsService.d.ts +10 -0
- package/backend/dist/services/ollamaSettingsService.d.ts.map +1 -0
- package/backend/dist/services/ollamaSettingsService.js +83 -0
- package/backend/dist/services/ollamaSettingsService.js.map +1 -0
- package/backend/dist/services/workAgentGuidance.d.ts +11 -0
- package/backend/dist/services/workAgentGuidance.d.ts.map +1 -1
- package/backend/dist/services/workAgentGuidance.js +16 -2
- package/backend/dist/services/workAgentGuidance.js.map +1 -1
- package/backend/dist/services/workAgentService.d.ts +56 -0
- package/backend/dist/services/workAgentService.d.ts.map +1 -1
- package/backend/dist/services/workAgentService.js +467 -17
- package/backend/dist/services/workAgentService.js.map +1 -1
- package/backend/dist/services/workApprovalService.d.ts +67 -0
- package/backend/dist/services/workApprovalService.d.ts.map +1 -0
- package/backend/dist/services/workApprovalService.js +273 -0
- package/backend/dist/services/workApprovalService.js.map +1 -0
- package/backend/dist/services/workEventService.d.ts.map +1 -1
- package/backend/dist/services/workEventService.js +25 -0
- package/backend/dist/services/workEventService.js.map +1 -1
- package/backend/dist/services/workPolicyService.d.ts +4 -0
- package/backend/dist/services/workPolicyService.d.ts.map +1 -1
- package/backend/dist/services/workPolicyService.js +19 -0
- package/backend/dist/services/workPolicyService.js.map +1 -1
- package/backend/dist/services/workRuntimeShared.d.ts +2 -0
- package/backend/dist/services/workRuntimeShared.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeShared.js.map +1 -1
- package/backend/dist/services/workTaskService.d.ts +3 -1
- package/backend/dist/services/workTaskService.d.ts.map +1 -1
- package/backend/dist/services/workTaskService.js +21 -4
- package/backend/dist/services/workTaskService.js.map +1 -1
- package/backend/dist/types/index.d.ts +3 -1
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/types/work.d.ts +32 -11
- package/backend/dist/types/work.d.ts.map +1 -1
- package/backend/dist/websocketServer.d.ts.map +1 -1
- package/backend/dist/websocketServer.js +14 -2
- package/backend/dist/websocketServer.js.map +1 -1
- package/backend/package.json +2 -2
- package/deploy/work-computer/Dockerfile +1 -0
- package/deploy/work-computer/tint2rc +1 -0
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
- package/frontend/dist/artifact-runtime/mermaid.js +8 -8
- package/frontend/dist/artifact-runtime/papaparse.js +2 -2
- package/frontend/dist/artifact-runtime/plotly.js +371 -652
- package/frontend/dist/assets/index-B6xMZpzA.js +76 -0
- package/frontend/dist/assets/index-BjipfsCP.css +1 -0
- package/frontend/dist/index.html +28 -28
- package/frontend/dist/js/{ArtifactContainer-CTXxnWRo.js → ArtifactContainer-Bn6iJtaJ.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-CEYuIhJA.js → ArtifactDemoPage-BLF8Ok-o.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-DLOy2VOm.js → ArtifactSandboxFrame-Cs1Gu1WB.js} +1 -1
- package/frontend/dist/js/{ArtifactSlideOutPanel-DnTTc1VY.js → ArtifactSlideOutPanel-CuKq5cL0.js} +1 -1
- package/frontend/dist/js/AutomationModal-Dha4KgLI.js +1 -0
- package/frontend/dist/js/AutomationsPage-HcMCRV-D.js +1 -0
- package/frontend/dist/js/{AvatarUpload-DzL00yOL.js → AvatarUpload-CFrlSszY.js} +1 -1
- package/frontend/dist/js/{Button--pDOakZx.js → Button-CgN11mgY.js} +1 -1
- package/frontend/dist/js/{CalendarPage-Bls3TBeZ.js → CalendarPage-D_K-XrG9.js} +1 -1
- package/frontend/dist/js/ChannelsPage-D3CoImOT.js +1 -0
- package/frontend/dist/js/ChatPage-C0iBDbOq.js +14 -0
- package/frontend/dist/js/ConnectModels-D_ZbZQub.js +1 -0
- package/frontend/dist/js/{EvaluationsPage-DSgj9dT5.js → EvaluationsPage-DOJLpauA.js} +2 -2
- package/frontend/dist/js/FirstTimeSetup-DDIP_4Dd.js +1 -0
- package/frontend/dist/js/GalleryPage-C8U_F7Ns.js +1 -0
- package/frontend/dist/js/{HomePage-BebX3v-x.js → HomePage-B_aotoDU.js} +1 -1
- package/frontend/dist/js/LibreClawPage-cr2N6W00.js +1 -0
- package/frontend/dist/js/{Logo-BE9SvCC5.js → Logo-B7o7eaPU.js} +1 -1
- package/frontend/dist/js/{LogoMark-C8x1yyP3.js → LogoMark-D9g6ls0h.js} +1 -1
- package/frontend/dist/js/{ModelManagerModals-CpWAltRA.js → ModelManagerModals-C-J1d7GL.js} +1 -1
- package/frontend/dist/js/NotesPage-Bgr7R_Vm.js +3 -0
- package/frontend/dist/js/{PasswordStrengthMeter-Cdq2oQbc.js → PasswordStrengthMeter-DR-mGbLF.js} +1 -1
- package/frontend/dist/js/PersonasPage-C3D_6lIx.js +13 -0
- package/frontend/dist/js/{PluginUsagePage-jMrpL2Jb.js → PluginUsagePage-DK7MgSiu.js} +1 -1
- package/frontend/dist/js/RichMessageContent-7FxrZ4A8.js +1 -0
- package/frontend/dist/js/{RichMessageContent-CC9QZQKd.js → RichMessageContent-CQkLI7Dt.js} +1 -1
- package/frontend/dist/js/SettingsModal-CIV_Bgsf.js +19 -0
- package/frontend/dist/js/{SettingsToggle-C16gtVyi.js → SettingsToggle-Cw4OhW7B.js} +1 -1
- package/frontend/dist/js/ShareDialog-BCEVgtbN.js +1 -0
- package/frontend/dist/js/{SystemPage-Drd1neLN.js → SystemPage-BNVZtLe9.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-CquciWKV.js → UserManagementPage-pPC_Svj9.js} +1 -1
- package/frontend/dist/js/WorkPage-Q33nIqkM.js +7 -0
- package/frontend/dist/js/{api-2DulPtq1.js → api-D-5hpGht.js} +3 -3
- package/frontend/dist/js/api-WR1CTYO5.js +1 -0
- package/frontend/dist/js/{appNavigation-DAGh98Yj.js → appNavigation-DfHbXBey.js} +1 -1
- package/frontend/dist/js/{appStore-Ci1X0yA-.js → appStore-B136FGdu.js} +2 -2
- package/frontend/dist/js/appVersion-Ck7dYiHe.js +1 -0
- package/frontend/dist/js/ar-Cq-nC6v9.js +2 -0
- package/frontend/dist/js/authStore-6AJLgQsD.js +1 -0
- package/frontend/dist/js/authStore-Ckz37pwu.js +4 -0
- package/frontend/dist/js/axios-CUerAKcc.js +1 -0
- package/frontend/dist/js/{babel-D7QYvEns.js → babel-8afoxhZ7.js} +1 -1
- package/frontend/dist/js/bn-BFSKytYs.js +2 -0
- package/frontend/dist/js/chatStore-Dpm3g_Ln.js +3 -0
- package/frontend/dist/js/classPrivateMethodInitSpec-DE0XIqc_.js +1 -0
- package/frontend/dist/js/config-DJwXAf8i.js +1 -0
- package/frontend/dist/js/cs-BKWXa629.js +2 -0
- package/frontend/dist/js/da-Cra_DJnV.js +2 -0
- package/frontend/dist/js/de-BQa6_UuE.js +2 -0
- package/frontend/dist/js/es-BBOHFrx1.js +2 -0
- package/frontend/dist/js/{estree-D7xT4AeP.js → estree-qxY7ACbu.js} +3 -3
- package/frontend/dist/js/{evaluationsApi-Cu5PH_qi.js → evaluationsApi-BKY-maUM.js} +1 -1
- package/frontend/dist/js/fr-C8kXs5c0.js +2 -0
- package/frontend/dist/js/hi-BEef4bjU.js +2 -0
- package/frontend/dist/js/{html-HvA9vEyn.js → html-B_cUU1Gi.js} +2 -2
- package/frontend/dist/js/id-Djipic7Y.js +2 -0
- package/frontend/dist/js/is-pazl6RLG.js +2 -0
- package/frontend/dist/js/it-DobPbTwl.js +2 -0
- package/frontend/dist/js/ja-DwYNaMNX.js +2 -0
- package/frontend/dist/js/ko-BQfXE7_o.js +2 -0
- package/frontend/dist/js/{markdown-DaF0SXNk.js → markdown-BAF0w-jL.js} +3 -3
- package/frontend/dist/js/{messageCodeStyles-DKq3DH1W.js → messageCodeStyles-CkxF6yil.js} +2 -2
- package/frontend/dist/js/ms-CkPQoE5T.js +2 -0
- package/frontend/dist/js/nl-X_QsDAtu.js +2 -0
- package/frontend/dist/js/pl-CK39gUsy.js +2 -0
- package/frontend/dist/js/{postcss-RCIJRrFm.js → postcss-B2vYq4-H.js} +1 -1
- package/frontend/dist/js/pt-C0dWyR_I.js +2 -0
- package/frontend/dist/js/{router-vendor-BGP0k6Y2.js → router-vendor-CIwPu612.js} +1 -1
- package/frontend/dist/js/ru-sNJkEz1G.js +2 -0
- package/frontend/dist/js/{standalone-BMD7E0jY.js → standalone-BqZmfuRy.js} +2 -2
- package/frontend/dist/js/sv-Bh-uxdF3.js +2 -0
- package/frontend/dist/js/{teamEventStream-C4u_py2D.js → teamEventStream-DUodK0-C.js} +1 -1
- package/frontend/dist/js/th-DPVtwZj2.js +2 -0
- package/frontend/dist/js/tr-BYNM_Tm7.js +2 -0
- package/frontend/dist/js/{ttsBatching-C9kQXFB1.js → ttsBatching-7_-p2nxR.js} +1 -1
- package/frontend/dist/js/{typescript-LOiqVRM1.js → typescript-DokwN-5Y.js} +1 -1
- package/frontend/dist/js/{ui-DUzqxWMk.js → ui-BK53RPmS.js} +2 -2
- package/frontend/dist/js/ui-vendor-CPdYrKhz.js +177 -0
- package/frontend/dist/js/uk-kvNBuYin.js +2 -0
- package/frontend/dist/js/{useChat-6yDWZSTz.js → useChat-Czg2p4Rr.js} +1 -1
- package/frontend/dist/js/useDictation-B2lYEYKn.js +1 -0
- package/frontend/dist/js/useQuery-ClAiNxQ7.js +1 -0
- package/frontend/dist/js/{useTranslation-DrnYb6Cx.js → useTranslation-C7GwbUQA.js} +1 -1
- package/frontend/dist/js/{utils-D9UstwTG.js → utils-nNyg0lfc.js} +1 -1
- package/frontend/dist/js/utils-vendor-CeUf_ngc.js +9 -0
- package/frontend/dist/js/vi-CmLoaP0K.js +2 -0
- package/frontend/dist/js/workApi-BoJb9aVF.js +1 -0
- package/frontend/dist/js/{workApi-BwDBwG62.js → workApi-CFH097y5.js} +3 -3
- package/frontend/dist/js/{yaml-CyhEdlt2.js → yaml-BXEpxPn2.js} +2 -2
- package/frontend/dist/js/zh-D2zvmvrj.js +2 -0
- package/frontend/dist/sw.js +7 -1
- package/package.json +5 -5
- package/frontend/dist/assets/index-O8rtJINp.css +0 -1
- package/frontend/dist/assets/index-f1s6QpC5.js +0 -93
- package/frontend/dist/js/AutomationModal-DB3lrK2K.js +0 -1
- package/frontend/dist/js/AutomationsPage-D3v0Cra1.js +0 -1
- package/frontend/dist/js/ChannelsPage-BnoCniNf.js +0 -1
- package/frontend/dist/js/ChatPage-BMcigJWr.js +0 -14
- package/frontend/dist/js/FirstTimeSetup-BRysXCjP.js +0 -1
- package/frontend/dist/js/GalleryPage-DUcM4dg0.js +0 -1
- package/frontend/dist/js/LibreClawPage-A37KF9_G.js +0 -1
- package/frontend/dist/js/ModelSelector-C1ipX-44.js +0 -1
- package/frontend/dist/js/NotesPage-CXSz7Hde.js +0 -3
- package/frontend/dist/js/PersonasPage-CiOBffF3.js +0 -13
- package/frontend/dist/js/RichMessageContent-CU6WTuOs.js +0 -1
- package/frontend/dist/js/SettingsModal-DP_wKehV.js +0 -19
- package/frontend/dist/js/ShareDialog-BW8iGd_i.js +0 -1
- package/frontend/dist/js/WorkPage-BgASwAGs.js +0 -6
- package/frontend/dist/js/api-BmIdrQfK.js +0 -1
- package/frontend/dist/js/appVersion-BRMnr50t.js +0 -1
- package/frontend/dist/js/ar-CpmN0TY8.js +0 -2
- package/frontend/dist/js/authStore-DIvsSaOt.js +0 -4
- package/frontend/dist/js/authStore-DoxafXFR.js +0 -1
- package/frontend/dist/js/axios-C8xWfUG8.js +0 -1
- package/frontend/dist/js/bn-BwrMg_Oh.js +0 -2
- package/frontend/dist/js/chatStore-DkpmZLOG.js +0 -3
- package/frontend/dist/js/classPrivateMethodInitSpec-DUpGnGHL.js +0 -1
- package/frontend/dist/js/config-Ckn9cand.js +0 -1
- package/frontend/dist/js/cs-f72Fnxz3.js +0 -2
- package/frontend/dist/js/da-qp8lOgkJ.js +0 -2
- package/frontend/dist/js/de-CpcLHr97.js +0 -2
- package/frontend/dist/js/es-gZHsxjG4.js +0 -2
- package/frontend/dist/js/fr-BY5aUofi.js +0 -2
- package/frontend/dist/js/hi-KCn9gIiT.js +0 -2
- package/frontend/dist/js/id-C7U6kS0J.js +0 -2
- package/frontend/dist/js/is-N9Ek-Usz.js +0 -2
- package/frontend/dist/js/it-CqaqWB8D.js +0 -2
- package/frontend/dist/js/ja-C5f9HAm1.js +0 -2
- package/frontend/dist/js/ko-BuoboDvb.js +0 -2
- package/frontend/dist/js/ms-Cu-UWc6j.js +0 -2
- package/frontend/dist/js/nl-nOUc4C_i.js +0 -2
- package/frontend/dist/js/pl-BKKwFhxj.js +0 -2
- package/frontend/dist/js/pt-B18-KYtS.js +0 -2
- package/frontend/dist/js/ru-DflEWNyb.js +0 -2
- package/frontend/dist/js/sv-CU-nPjr8.js +0 -2
- package/frontend/dist/js/th-dOxm2Hhl.js +0 -2
- package/frontend/dist/js/tr-7ThM4F8q.js +0 -2
- package/frontend/dist/js/ui-vendor-C0KwbTD4.js +0 -177
- package/frontend/dist/js/uk-Cl7Pk0Yf.js +0 -2
- package/frontend/dist/js/useQuery-CoWV2PmJ.js +0 -1
- package/frontend/dist/js/utils-vendor-DtsgPwcz.js +0 -9
- package/frontend/dist/js/vi-eljYUBOk.js +0 -2
- package/frontend/dist/js/workApi-uXUZSjsf.js +0 -1
- package/frontend/dist/js/zh-B0sinUfQ.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{t as r}from"./Button
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{t as r}from"./Button-CgN11mgY.js";import{o as i}from"./ui-BK53RPmS.js";import{t as a}from"./ArtifactContainer-Bn6iJtaJ.js";var o=e(t(),1),s=n(),c=[{id:`demo-html-1`,type:`html`,title:`Interactive Button Demo`,description:`A simple HTML page with interactive elements`,content:`<div style="text-align: center; padding: 20px;">
|
|
2
2
|
<h1 style="color: #333; font-family: Arial, sans-serif;">Welcome to Libre WebUI!</h1>
|
|
3
3
|
<p style="color: #666; font-size: 16px;">This is an interactive HTML artifact.</p>
|
|
4
4
|
<button
|
package/frontend/dist/js/{ArtifactSandboxFrame-DLOy2VOm.js → ArtifactSandboxFrame-Cs1Gu1WB.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{t as r}from"./logger-CpCQz3Vi.js";import{t as i}from"./config-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{t as r}from"./logger-CpCQz3Vi.js";import{t as i}from"./config-DJwXAf8i.js";import{a,l as o,n as s,o as c,r as l,t as u}from"./artifactHtml-DDmfpcB0.js";var d=e(t(),1),f=`${i.replace(/\/+$/,``)}/artifacts/sandbox`,p=window.location.protocol===`file:`?new URL(f).origin:window.location.origin,m=`/artifact-runtime`,h=`runtime`,g=`react`,_=`babel`,v=`tailwind`,y=`fonts`,b={react:g,"react-dom":g,"react-dom/client":g,"react/jsx-runtime":g,"react/jsx-dev-runtime":g,recharts:`recharts`,"lucide-react":`lucide-react`,d3:`d3`,three:`three`,papaparse:`papaparse`,lodash:`lodash`,"lodash-es":`lodash`,mermaid:`mermaid`,"chart.js":`chart`,"chart.js/auto":`chart`,tone:`tone`,mathjs:`mathjs`,"plotly.js":`plotly`,"plotly.js-dist-min":`plotly`,"framer-motion":`framer-motion`,"motion/react":`framer-motion`,motion:`framer-motion`,"three/addons/controls/OrbitControls.js":`three`,"three/examples/jsm/controls/OrbitControls.js":`three`},x=[h,g,_,v],S=[h,`mermaid`],C=[{pattern:/cdn\.tailwindcss\.com/i,bundle:v},{pattern:/(?:^|\/)tailwindcss(?:@[\d.]+)?(?:\/|$)/i,bundle:v},{pattern:/(?:^|\/)chart\.js(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:`chart`},{pattern:/(?:^|\/)chart(?:\.min)?\.js(?:$|\?)/i,bundle:`chart`},{pattern:/(?:^|\/)d3(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:`d3`},{pattern:/(?:^|\/)d3(?:\.min)?\.js(?:$|\?)/i,bundle:`d3`},{pattern:/(?:^|\/)three(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:`three`},{pattern:/(?:^|\/)three(?:\.min)?\.js(?:$|\?)/i,bundle:`three`},{pattern:/papaparse/i,bundle:`papaparse`},{pattern:/(?:^|\/)lodash(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:`lodash`},{pattern:/(?:^|\/)lodash(?:\.min)?\.js(?:$|\?)/i,bundle:`lodash`},{pattern:/fonts\.(?:googleapis|gstatic)\.com/i,bundle:y},{pattern:/mermaid/i,bundle:`mermaid`},{pattern:/(?:^|\/)tone(?:@[\d.]+)?(?:\/|$|\?)|tone(?:\.min)?\.js/i,bundle:`tone`},{pattern:/mathjs|math(?:\.min)?\.js/i,bundle:`mathjs`},{pattern:/plotly/i,bundle:`plotly`},{pattern:/framer-motion|(?:^|\/)motion(?:@[\d.]+)?(?:\/|$)/i,bundle:`framer-motion`},{pattern:/react-dom/i,bundle:g},{pattern:/(?:^|\/)react(?:@[\d.]+)?(?:\/|$|\?)/i,bundle:g},{pattern:/babel(?:-standalone|\/standalone)/i,bundle:_}],w=`__libreArtifactRuntime`;function T(e){if(b[e])return e;let t=C.find(({pattern:t})=>t.test(e))?.bundle??Object.values(b).find(t=>e.startsWith(`${t}/`));return t?Object.entries(b).find(([,e])=>e===t)?.[0]??null:null}function E(e){let t=new Set,n=e.matchAll(/(?:from|import|require)\s*\(?\s*['"`]([^'"`]+)['"`]/g);for(let[,e]of n){let n=T(e);n&&t.add(b[n])}return[...t]}var D=/\b(?:flex|grid|hidden|absolute|relative|(?:p|m|px|py|mx|my|mt|mb|ml|mr|gap|space)-\d|(?:w|h|max-w|min-h)-(?:\d|full|screen|auto)|text-(?:xs|sm|base|lg|xl|\dxl|center|left|right|white|black|gray-\d)|bg-(?:white|black|transparent|[a-z]+-\d)|rounded(?:-[a-z]+)?|shadow(?:-[a-z]+)?|border(?:-\d)?|items-(?:center|start|end)|justify-(?:center|between|around|end)|font-(?:bold|medium|semibold|light)|hover:[a-z-]+|(?:sm|md|lg|xl):[a-z-]+)\b/g;function O(e){let t=[...e.matchAll(/class\s*=\s*("|')(.*?)\1/gi)].map(e=>e[2]).join(` `);return new Set(t.match(D)??[]).size>=3}function k(e){let t=new Set;for(let[n,r]of Object.entries(b)){let i=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?:from|import|require)\\s*\\(?\\s*['"\`]${i}['"\`]`).test(e)&&t.add(r)}return[...t]}function A(e){return C.find(({pattern:t})=>t.test(e))?.bundle??null}function j(e){let t=new Set;for(let n of e.matchAll(/\b(?:src|href)\s*=\s*("|')(.*?)\1/gi))t.add(n[2]);for(let n of e.matchAll(/(?:from|import|require)\s*\(?\s*['"`]([^'"`]+)['"`]/g))t.add(n[1]);return[...t]}function M(e){let t=new Set;for(let n of j(e)){let e=A(n);e&&t.add(e)}return[...t]}var N=`d9a1958742b9ebde`,P=new Map;function F(e){let t=P.get(e);if(t)return t;let n=fetch(`${p}${m}/${e}.js?v=${N}`,{credentials:`same-origin`,cache:`no-cache`}).then(t=>{if(!t.ok)throw Error(`The artifact runtime bundle "${e}" is unavailable (HTTP ${t.status}).`);return t.text()});return n.catch(()=>P.delete(e)),P.set(e,n),n}async function I(e){let t=await Promise.all(e.map(F));return Object.fromEntries(e.map((e,n)=>[e,t[n]]))}var L=`
|
|
2
2
|
html, body { margin: 0; min-height: 100%; }
|
|
3
3
|
body {
|
|
4
4
|
background: #ffffff;
|
package/frontend/dist/js/{ArtifactSlideOutPanel-DnTTc1VY.js → ArtifactSlideOutPanel-CuKq5cL0.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{n as r}from"./react-vendor-BsJBHRYW.js";import{t as ee}from"./useTranslation-DrnYb6Cx.js";import{t as i}from"./utils-D9UstwTG.js";import{T as te,t as ne}from"./chatStore-DkpmZLOG.js";import{Gn as re,Hn as ie,Jt as ae,Kt as oe,On as a,Un as o,g as s,gn as se,kn as c,n as ce,un as l,wn as le,xn as ue}from"./ui-vendor-C0KwbTD4.js";import{t as u}from"./logger-CpCQz3Vi.js";import{t as de}from"./appStore-Ci1X0yA-.js";import{t as d}from"./Button--pDOakZx.js";import{i as fe,r as pe}from"./artifactHtml-DDmfpcB0.js";import{t as f}from"./OptimizedSyntaxHighlighter-BwKLuOu-.js";import{t as me}from"./ArtifactSandboxFrame-DLOy2VOm.js";var p=e(t(),1),he=r(),m=n(),h=u(`components:artifact-slide-out-panel`),g=320,ge=.9,_e=400,ve=`(min-width: 768px)`,ye=`(min-width: 1024px)`,_=e=>{let[t,n]=(0,p.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,p.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t},v=()=>{let{t:e,i18n:t}=ee(),n=te(t.language),{artifactPanelOpen:r,artifactPanelArtifact:u,openArtifactPanel:v,closeArtifactPanel:y,theme:b,artifactPanelWidth:x,setArtifactPanelWidth:S,artifactPanelResizing:C,setArtifactPanelResizing:w,sidebarOpen:T,sidebarCompact:E}=de(),D=_(ve),O=_(ye)?T?E?64:288:0:T&&E?64:0,k=(0,p.useCallback)(()=>D?Math.max(g,window.innerWidth-O-_e):window.innerWidth*ge,[D,O]),A=ne(e=>e.currentSession),j=p.useMemo(()=>{if(!u)return[];let e=u.title.trim().toLowerCase(),t=(A?.messages??[]).flatMap(e=>e.artifacts??[]).filter(t=>t.title.trim().toLowerCase()===e);return t.some(e=>e.id===u.id||e.content===u.content)?t:[...t,u]},[A,u]),M=j.findIndex(e=>e.id===u?.id);M===-1&&u&&(M=j.findIndex(e=>e.content===u.content));let[N,P]=(0,p.useState)(!1),[F,I]=(0,p.useState)(`preview`),L=(0,p.useRef)(null),R=(0,p.useRef)(null),z=(0,p.useRef)(0),B=(0,p.useRef)(0),V=(0,p.useRef)(null),H=(0,p.useRef)(null),U=(0,p.useRef)(x),W=u?.id??null;W!==R.current&&(R.current=W,F!==`preview`&&I(`preview`));let G=(0,p.useCallback)(e=>{U.current=e,H.current===null&&(H.current=window.requestAnimationFrame(()=>{H.current=null,S(U.current)}))},[S]),K=(0,p.useCallback)(()=>{V.current=null,w(!1),H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null,S(U.current))},[w,S]),be=(0,p.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),V.current=e.pointerId,B.current=x,z.current=e.clientX,U.current=x,e.currentTarget.setPointerCapture(e.pointerId),w(!0)},[x,w]),q=(0,p.useCallback)(e=>{if(!C||V.current!==null&&e.pointerId!==V.current)return;e.preventDefault();let t=(z.current-e.clientX)*(n?-1:1),r=Math.min(k(),Math.max(g,B.current+t));G(r)},[C,n,G,k]);if((0,p.useEffect)(()=>{if(!C){document.body.style.userSelect=``,document.body.style.cursor=``;return}let e=e=>{(V.current===null||e.pointerId===V.current)&&K()};return window.addEventListener(`pointermove`,q,{passive:!1}),window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,K),document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,()=>{window.removeEventListener(`pointermove`,q),window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,K),document.body.style.userSelect=``,document.body.style.cursor=``}},[C,q,K]),(0,p.useEffect)(()=>{let e=()=>{let e=k();x>e&&S(e)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[x,S,k]),(0,p.useEffect)(()=>{if(D)return;let e=e=>{e.key===`Escape`&&r&&y()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,y,D]),(0,p.useEffect)(()=>{if(D)return;let e=e=>{C||L.current&&!L.current.contains(e.target)&&r&&y()},t=setTimeout(()=>{window.addEventListener(`mousedown`,e)},100);return()=>{clearTimeout(t),window.removeEventListener(`mousedown`,e)}},[r,y,C,D]),!u)return null;let J=u,xe=async e=>{try{await navigator.clipboard.writeText(e),P(!0),setTimeout(()=>P(!1),2e3)}catch(e){h.error(`Failed to copy:`,e)}},Se=()=>{let e=J.type===`html`?pe(J.content,J.title):J.content,t=new Blob([e],{type:Ce(J.type)}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${J.title}.${we(J.type)}`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},Ce=e=>{switch(e){case`html`:return`text/html`;case`react`:return`text/javascript`;case`svg`:return`image/svg+xml`;case`css`:return`text/css`;case`json`:return`application/json`;default:return`text/plain`}},we=e=>{switch(e){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`svg`;case`css`:return`css`;case`json`:return`json`;default:return`txt`}},Y=()=>{switch(J.type){case`html`:return(0,m.jsx)(ae,{className:`h-5 w-5`});case`react`:return(0,m.jsx)(a,{className:`h-5 w-5`});case`svg`:return(0,m.jsx)(l,{className:`h-5 w-5`});case`code`:return(0,m.jsx)(a,{className:`h-5 w-5`});default:return(0,m.jsx)(l,{className:`h-5 w-5`})}},X=()=>(0,m.jsx)(`div`,{"data-testid":`artifact-html-fallback`,className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-200 p-4`,children:(0,m.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,m.jsx)(s,{className:`h-8 w-8 text-primary-500 mx-auto mb-3`}),(0,m.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`artifacts.previewUnavailable`)}),(0,m.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`artifacts.previewUnavailableDescription`)}),(0,m.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>I(`code`),className:`mt-4`,children:[(0,m.jsx)(c,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.code`)]})]})}),Z=e=>J.content.trim()?(0,m.jsx)(me,{content:J.content,title:J.title,kind:e,colorScheme:b.mode===`light`?`light`:`dark`,className:i(`w-full h-full border-0 rounded-lg bg-white`,C&&`pointer-events-none`),fallback:X()}):X(),Te=()=>(0,m.jsx)(`iframe`,{"data-testid":`artifact-svg-preview`,srcDoc:fe(J.content,J.title),className:`w-full h-full border-0 rounded-lg bg-white`,sandbox:``,title:J.title}),Q=()=>(0,m.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,m.jsx)(f,{language:(()=>{if(J.language)return J.language;switch(J.type){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`xml`;case`json`:return`json`;default:return`text`}})(),isDark:b.mode!==`light`,className:`!m-0 !rounded-lg !h-full`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:b.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:J.content})}),Ee=()=>{try{let e=JSON.parse(J.content),t=JSON.stringify(e,null,2);return(0,m.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,m.jsx)(f,{language:`json`,isDark:b.mode!==`light`,className:`!m-0 !rounded-lg !h-full`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:b.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:t})})}catch{return(0,m.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg`,children:(0,m.jsxs)(`div`,{className:`text-center`,children:[(0,m.jsx)(s,{className:`h-8 w-8 text-primary-500 mx-auto mb-2`}),(0,m.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:e(`artifacts.invalidJson`)})]})})}},De=()=>{if(F===`code`)return Q();switch(J.type){case`html`:return Z(`html`);case`react`:return Z(`react`);case`mermaid`:return Z(`mermaid`);case`svg`:return Te();case`json`:return Ee();default:return Q()}},Oe=()=>J.type===`html`||J.type===`svg`||J.type===`react`||J.type===`mermaid`,$=typeof window<`u`&&window.innerWidth<640,ke=$?`100%`:`${x}px`,Ae=(0,m.jsxs)(m.Fragment,{children:[!D&&(0,m.jsx)(`div`,{className:i(`fixed inset-0 bg-black/30 dark:bg-black/50 z-40 transition-opacity duration-300`,r?`opacity-100`:`opacity-0 pointer-events-none`)}),C&&(0,m.jsx)(`div`,{className:i(`fixed inset-0 cursor-col-resize select-none`,D?`z-40`:`z-[55]`),"aria-hidden":`true`}),(0,m.jsxs)(`div`,{ref:L,"data-testid":`artifact-slide-out-panel`,style:{width:ke},className:i(`fixed top-0 end-0 h-full`,D?`z-30`:`z-50`,`bg-white dark:bg-dark-25`,`shadow-2xl border-s border-gray-200 dark:border-dark-200`,`flex flex-col`,`transform transition-transform duration-300 ease-out`,r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`),children:[!$&&(0,m.jsxs)(`div`,{onPointerDown:be,"data-testid":`artifact-resize-handle`,title:e(`artifacts.dragEdgeToResize`),className:i(`absolute start-0 top-0 bottom-0 w-4 -ms-2 cursor-col-resize z-[56]`,`flex items-center justify-center`,`touch-none select-none group`),children:[(0,m.jsx)(`div`,{className:i(`w-1 h-16 rounded-full transition-all duration-200`,`bg-gray-300 dark:bg-dark-300`,`group-hover:bg-primary-500 group-hover:h-24`,C&&`bg-primary-500 h-24`)}),(0,m.jsx)(`div`,{className:i(`absolute left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity`,`text-gray-400 dark:text-dark-500`,C&&`opacity-100`),children:(0,m.jsx)(oe,{className:`h-4 w-4`})})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-gray-200 dark:border-dark-200 ps-3 pe-2 py-1.5`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,m.jsx)(`div`,{className:`text-gray-600 dark:text-gray-400 flex-shrink-0`,children:Y()}),(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate`,title:J.description||`${e(`artifacts.created`)}: ${new Date(J.createdAt).toLocaleString()}`,children:J.title}),(0,m.jsx)(`span`,{className:`hidden sm:inline text-[10px] bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300 px-1.5 py-0.5 rounded-full font-medium flex-shrink-0`,children:J.type.toUpperCase()})]}),j.length>1&&M!==-1&&(0,m.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,m.jsx)(d,{variant:`ghost`,size:`sm`,disabled:M===0,onClick:()=>v(j[M-1]),className:`h-7 w-7 p-0`,title:e(`artifacts.previousVersion`),children:(0,m.jsx)(ie,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,m.jsx)(`span`,{className:`whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-dark-600`,children:e(`artifacts.versionOf`,{current:M+1,total:j.length})}),(0,m.jsx)(d,{variant:`ghost`,size:`sm`,disabled:M===j.length-1,onClick:()=>v(j[M+1]),className:`h-7 w-7 p-0`,title:e(`artifacts.nextVersion`),children:(0,m.jsx)(o,{className:`h-3.5 w-3.5 rtl:rotate-180`})})]}),Oe()&&(0,m.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,m.jsxs)(d,{variant:F===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>I(`preview`),className:`h-7 px-2 text-xs`,title:e(`artifacts.previewMode`),children:[(0,m.jsx)(se,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.preview`)]}),(0,m.jsxs)(d,{variant:F===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>I(`code`),className:`h-7 px-2 text-xs`,title:e(`artifacts.codeMode`),children:[(0,m.jsx)(c,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.code`)]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,m.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>xe(J.content),className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.copyContent`),children:N?(0,m.jsx)(re,{className:`h-3.5 w-3.5 text-green-500`}):(0,m.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,m.jsx)(d,{variant:`ghost`,size:`sm`,onClick:Se,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.download`),children:(0,m.jsx)(ue,{className:`h-3.5 w-3.5`})}),(0,m.jsx)(d,{variant:`ghost`,size:`sm`,onClick:y,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(D?`common.close`:`artifacts.closePanelEsc`),children:(0,m.jsx)(ce,{className:`h-4 w-4`})})]})]}),(0,m.jsx)(`div`,{className:`flex-1 p-2 overflow-hidden`,children:De()})]})]});return(0,he.createPortal)(Ae,document.body)};export{v as ArtifactSlideOutPanel};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{n as r}from"./react-vendor-BsJBHRYW.js";import{t as ee}from"./useTranslation-C7GwbUQA.js";import{t as i}from"./utils-nNyg0lfc.js";import{T as te,t as ne}from"./chatStore-Dpm3g_Ln.js";import{An as a,Cn as re,En as ie,Gn as ae,Jt as oe,Wn as o,Xt as se,fn as s,g as c,jn as l,n as ce,qn as le,vn as ue}from"./ui-vendor-CPdYrKhz.js";import{t as u}from"./logger-CpCQz3Vi.js";import{t as de}from"./appStore-B136FGdu.js";import{t as d}from"./Button-CgN11mgY.js";import{i as fe,r as pe}from"./artifactHtml-DDmfpcB0.js";import{t as f}from"./OptimizedSyntaxHighlighter-BwKLuOu-.js";import{t as me}from"./ArtifactSandboxFrame-Cs1Gu1WB.js";var p=e(t(),1),he=r(),m=n(),h=u(`components:artifact-slide-out-panel`),g=320,ge=.9,_e=400,ve=`(min-width: 768px)`,ye=`(min-width: 1024px)`,_=e=>{let[t,n]=(0,p.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,p.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t},v=()=>{let{t:e,i18n:t}=ee(),n=te(t.language),{artifactPanelOpen:r,artifactPanelArtifact:u,openArtifactPanel:v,closeArtifactPanel:y,theme:b,artifactPanelWidth:x,setArtifactPanelWidth:S,artifactPanelResizing:C,setArtifactPanelResizing:w,sidebarOpen:T,sidebarCompact:E}=de(),D=_(ve),O=_(ye)?T?E?64:288:0:T&&E?64:0,k=(0,p.useCallback)(()=>D?Math.max(g,window.innerWidth-O-_e):window.innerWidth*ge,[D,O]),A=ne(e=>e.currentSession),j=p.useMemo(()=>{if(!u)return[];let e=u.title.trim().toLowerCase(),t=(A?.messages??[]).flatMap(e=>e.artifacts??[]).filter(t=>t.title.trim().toLowerCase()===e);return t.some(e=>e.id===u.id||e.content===u.content)?t:[...t,u]},[A,u]),M=j.findIndex(e=>e.id===u?.id);M===-1&&u&&(M=j.findIndex(e=>e.content===u.content));let[N,P]=(0,p.useState)(!1),[F,I]=(0,p.useState)(`preview`),L=(0,p.useRef)(null),R=(0,p.useRef)(null),z=(0,p.useRef)(0),B=(0,p.useRef)(0),V=(0,p.useRef)(null),H=(0,p.useRef)(null),U=(0,p.useRef)(x),W=u?.id??null;W!==R.current&&(R.current=W,F!==`preview`&&I(`preview`));let G=(0,p.useCallback)(e=>{U.current=e,H.current===null&&(H.current=window.requestAnimationFrame(()=>{H.current=null,S(U.current)}))},[S]),K=(0,p.useCallback)(()=>{V.current=null,w(!1),H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null,S(U.current))},[w,S]),be=(0,p.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),V.current=e.pointerId,B.current=x,z.current=e.clientX,U.current=x,e.currentTarget.setPointerCapture(e.pointerId),w(!0)},[x,w]),q=(0,p.useCallback)(e=>{if(!C||V.current!==null&&e.pointerId!==V.current)return;e.preventDefault();let t=(z.current-e.clientX)*(n?-1:1),r=Math.min(k(),Math.max(g,B.current+t));G(r)},[C,n,G,k]);if((0,p.useEffect)(()=>{if(!C){document.body.style.userSelect=``,document.body.style.cursor=``;return}let e=e=>{(V.current===null||e.pointerId===V.current)&&K()};return window.addEventListener(`pointermove`,q,{passive:!1}),window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,K),document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,()=>{window.removeEventListener(`pointermove`,q),window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,K),document.body.style.userSelect=``,document.body.style.cursor=``}},[C,q,K]),(0,p.useEffect)(()=>{let e=()=>{let e=k();x>e&&S(e)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[x,S,k]),(0,p.useEffect)(()=>{if(D)return;let e=e=>{e.key===`Escape`&&r&&y()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,y,D]),(0,p.useEffect)(()=>{if(D)return;let e=e=>{C||L.current&&!L.current.contains(e.target)&&r&&y()},t=setTimeout(()=>{window.addEventListener(`mousedown`,e)},100);return()=>{clearTimeout(t),window.removeEventListener(`mousedown`,e)}},[r,y,C,D]),!u)return null;let J=u,xe=async e=>{try{await navigator.clipboard.writeText(e),P(!0),setTimeout(()=>P(!1),2e3)}catch(e){h.error(`Failed to copy:`,e)}},Se=()=>{let e=J.type===`html`?pe(J.content,J.title):J.content,t=new Blob([e],{type:Ce(J.type)}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${J.title}.${we(J.type)}`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},Ce=e=>{switch(e){case`html`:return`text/html`;case`react`:return`text/javascript`;case`svg`:return`image/svg+xml`;case`css`:return`text/css`;case`json`:return`application/json`;default:return`text/plain`}},we=e=>{switch(e){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`svg`;case`css`:return`css`;case`json`:return`json`;default:return`txt`}},Y=()=>{switch(J.type){case`html`:return(0,m.jsx)(se,{className:`h-5 w-5`});case`react`:return(0,m.jsx)(a,{className:`h-5 w-5`});case`svg`:return(0,m.jsx)(s,{className:`h-5 w-5`});case`code`:return(0,m.jsx)(a,{className:`h-5 w-5`});default:return(0,m.jsx)(s,{className:`h-5 w-5`})}},X=()=>(0,m.jsx)(`div`,{"data-testid":`artifact-html-fallback`,className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-200 p-4`,children:(0,m.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,m.jsx)(c,{className:`h-8 w-8 text-primary-500 mx-auto mb-3`}),(0,m.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`artifacts.previewUnavailable`)}),(0,m.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`artifacts.previewUnavailableDescription`)}),(0,m.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>I(`code`),className:`mt-4`,children:[(0,m.jsx)(l,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.code`)]})]})}),Z=e=>J.content.trim()?(0,m.jsx)(me,{content:J.content,title:J.title,kind:e,colorScheme:b.mode===`light`?`light`:`dark`,className:i(`w-full h-full border-0 rounded-lg bg-white`,C&&`pointer-events-none`),fallback:X()}):X(),Te=()=>(0,m.jsx)(`iframe`,{"data-testid":`artifact-svg-preview`,srcDoc:fe(J.content,J.title),className:`w-full h-full border-0 rounded-lg bg-white`,sandbox:``,title:J.title}),Q=()=>(0,m.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,m.jsx)(f,{language:(()=>{if(J.language)return J.language;switch(J.type){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`xml`;case`json`:return`json`;default:return`text`}})(),isDark:b.mode!==`light`,className:`!m-0 !rounded-lg !h-full`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:b.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:J.content})}),Ee=()=>{try{let e=JSON.parse(J.content),t=JSON.stringify(e,null,2);return(0,m.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,m.jsx)(f,{language:`json`,isDark:b.mode!==`light`,className:`!m-0 !rounded-lg !h-full`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:b.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:t})})}catch{return(0,m.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg`,children:(0,m.jsxs)(`div`,{className:`text-center`,children:[(0,m.jsx)(c,{className:`h-8 w-8 text-primary-500 mx-auto mb-2`}),(0,m.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:e(`artifacts.invalidJson`)})]})})}},De=()=>{if(F===`code`)return Q();switch(J.type){case`html`:return Z(`html`);case`react`:return Z(`react`);case`mermaid`:return Z(`mermaid`);case`svg`:return Te();case`json`:return Ee();default:return Q()}},Oe=()=>J.type===`html`||J.type===`svg`||J.type===`react`||J.type===`mermaid`,$=typeof window<`u`&&window.innerWidth<640,ke=$?`100%`:`${x}px`,Ae=(0,m.jsxs)(m.Fragment,{children:[!D&&(0,m.jsx)(`div`,{className:i(`fixed inset-0 bg-black/30 dark:bg-black/50 z-40 transition-opacity duration-300`,r?`opacity-100`:`opacity-0 pointer-events-none`)}),C&&(0,m.jsx)(`div`,{className:i(`fixed inset-0 cursor-col-resize select-none`,D?`z-40`:`z-[55]`),"aria-hidden":`true`}),(0,m.jsxs)(`div`,{ref:L,"data-testid":`artifact-slide-out-panel`,style:{width:ke},className:i(`fixed top-0 end-0 h-full`,D?`z-30`:`z-50`,`bg-white dark:bg-dark-25`,`shadow-2xl border-s border-gray-200 dark:border-dark-200`,`flex flex-col`,`transform transition-transform duration-300 ease-out`,r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`),children:[!$&&(0,m.jsxs)(`div`,{onPointerDown:be,"data-testid":`artifact-resize-handle`,title:e(`artifacts.dragEdgeToResize`),className:i(`absolute start-0 top-0 bottom-0 w-4 -ms-2 cursor-col-resize z-[56]`,`flex items-center justify-center`,`touch-none select-none group`),children:[(0,m.jsx)(`div`,{className:i(`w-1 h-16 rounded-full transition-all duration-200`,`bg-gray-300 dark:bg-dark-300`,`group-hover:bg-primary-500 group-hover:h-24`,C&&`bg-primary-500 h-24`)}),(0,m.jsx)(`div`,{className:i(`absolute left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity`,`text-gray-400 dark:text-dark-500`,C&&`opacity-100`),children:(0,m.jsx)(oe,{className:`h-4 w-4`})})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-gray-200 dark:border-dark-200 ps-3 pe-2 py-1.5`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,m.jsx)(`div`,{className:`text-gray-600 dark:text-gray-400 flex-shrink-0`,children:Y()}),(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate`,title:J.description||`${e(`artifacts.created`)}: ${new Date(J.createdAt).toLocaleString()}`,children:J.title}),(0,m.jsx)(`span`,{className:`hidden sm:inline text-[10px] bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300 px-1.5 py-0.5 rounded-full font-medium flex-shrink-0`,children:J.type.toUpperCase()})]}),j.length>1&&M!==-1&&(0,m.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,m.jsx)(d,{variant:`ghost`,size:`sm`,disabled:M===0,onClick:()=>v(j[M-1]),className:`h-7 w-7 p-0`,title:e(`artifacts.previousVersion`),children:(0,m.jsx)(ae,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,m.jsx)(`span`,{className:`whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-dark-600`,children:e(`artifacts.versionOf`,{current:M+1,total:j.length})}),(0,m.jsx)(d,{variant:`ghost`,size:`sm`,disabled:M===j.length-1,onClick:()=>v(j[M+1]),className:`h-7 w-7 p-0`,title:e(`artifacts.nextVersion`),children:(0,m.jsx)(o,{className:`h-3.5 w-3.5 rtl:rotate-180`})})]}),Oe()&&(0,m.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,m.jsxs)(d,{variant:F===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>I(`preview`),className:`h-7 px-2 text-xs`,title:e(`artifacts.previewMode`),children:[(0,m.jsx)(ue,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.preview`)]}),(0,m.jsxs)(d,{variant:F===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>I(`code`),className:`h-7 px-2 text-xs`,title:e(`artifacts.codeMode`),children:[(0,m.jsx)(l,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.code`)]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:[(0,m.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>xe(J.content),className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.copyContent`),children:N?(0,m.jsx)(le,{className:`h-3.5 w-3.5 text-green-500`}):(0,m.jsx)(ie,{className:`h-3.5 w-3.5`})}),(0,m.jsx)(d,{variant:`ghost`,size:`sm`,onClick:Se,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.download`),children:(0,m.jsx)(re,{className:`h-3.5 w-3.5`})}),(0,m.jsx)(d,{variant:`ghost`,size:`sm`,onClick:y,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(D?`common.close`:`artifacts.closePanelEsc`),children:(0,m.jsx)(ce,{className:`h-4 w-4`})})]})]}),(0,m.jsx)(`div`,{className:`flex-1 p-2 overflow-hidden`,children:De()})]})]});return(0,he.createPortal)(Ae,document.body)};export{v as ArtifactSlideOutPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{n as r}from"./react-vendor-BsJBHRYW.js";import{t as i}from"./useTranslation-C7GwbUQA.js";import{t as a}from"./utils-nNyg0lfc.js";import{Nn as o,Q as s,n as c,v as l,yr as u}from"./ui-vendor-CPdYrKhz.js";import{t as d}from"./workApi-CFH097y5.js";import{T as f}from"./api-D-5hpGht.js";import{c as p,d as m,l as h,n as g}from"./calendarDates-Co3o_05Y.js";var _=e(t(),1),v=r(),y=(e,t,n)=>new Intl.DateTimeFormat(n,{hour:`numeric`,minute:`2-digit`}).format(new Date(2024,0,1,e,t)),b=(e,t)=>new Intl.DateTimeFormat(t,{weekday:`long`}).format(new Date(2024,0,7+e)),x=(e,t,n)=>new Intl.DateTimeFormat(n,{month:`long`,day:`numeric`}).format(new Date(2024,e-1,t));function S(e,t,n){switch(e.kind){case`once`:return n(`automations.trigger.once`,{when:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e.at))});case`hourly`:{let t=e.startHour!==void 0||e.endHour!==void 0?` (${e.startHour??0}–${e.endHour??23})`:``;return n(`automations.trigger.hourly`,{minute:String(e.minute).padStart(2,`0`)})+t}case`daily`:return n(`automations.trigger.daily`,{time:y(e.hour,e.minute,t)});case`weekly`:return n(`automations.trigger.weekly`,{day:b(e.dayOfWeek,t),time:y(e.hour,e.minute,t)});case`monthly`:return n(`automations.trigger.monthly`,{day:e.dayOfMonth,time:y(e.hour,e.minute,t)});case`yearly`:return n(`automations.trigger.yearly`,{date:x(e.month,e.dayOfMonth,t),time:y(e.hour,e.minute,t)})}}function C(e,t,n){return e.map(e=>S(e,t,n)).join(` · `)}function w(e){let t=(e,t,n)=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=t&&e<=n;switch(e.kind){case`once`:return t(e.at,0,864e13);case`hourly`:return t(e.minute,0,59)&&(e.startHour===void 0||t(e.startHour,0,23))&&(e.endHour===void 0||t(e.endHour,0,23))&&(e.startHour===void 0||e.endHour===void 0||e.endHour>=e.startHour);case`daily`:return t(e.hour,0,23)&&t(e.minute,0,59);case`weekly`:return t(e.dayOfWeek,0,6)&&t(e.hour,0,23)&&t(e.minute,0,59);case`monthly`:return t(e.dayOfMonth,1,31)&&t(e.hour,0,23)&&t(e.minute,0,59);case`yearly`:return t(e.month,1,12)&&t(e.dayOfMonth,1,31)&&t(e.hour,0,23)&&t(e.minute,0,59);default:return!1}}var T=n(),E=[`once`,`hourly`,`daily`,`weekly`,`monthly`,`yearly`],D=`rounded-lg border border-black/[0.08] bg-white px-2 py-1 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,O=(e,t)=>`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`,k=e=>{switch(e){case`once`:{let e=new Date;return e.setHours(e.getHours()+1,0,0,0),{kind:`once`,at:e.getTime()}}case`hourly`:return{kind:`hourly`,minute:0};case`daily`:return{kind:`daily`,hour:8,minute:0};case`weekly`:return{kind:`weekly`,dayOfWeek:1,hour:9,minute:0};case`monthly`:return{kind:`monthly`,dayOfMonth:1,hour:9,minute:0};case`yearly`:return{kind:`yearly`,month:1,dayOfMonth:1,hour:9,minute:0}}};function A({trigger:e,onChange:t,onRemove:n}){let{t:r,i18n:a}=i(),s=m(a.language,`short`),c=new Intl.DateTimeFormat(a.language,{month:`long`}),u=n=>{let[r,i]=(n||`00:00`).split(`:`).map(Number);e.kind!==`hourly`&&e.kind!==`once`&&t({...e,hour:r,minute:i})},d=e.kind!==`once`&&e.kind!==`hourly`?(0,T.jsx)(`input`,{type:`time`,"aria-label":r(`automations.form.time`),value:O(e.hour,e.minute),onChange:e=>u(e.target.value),className:D}):null;return(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-black/[0.06] bg-black/[0.02] px-2.5 py-2 dark:border-white/[0.06] dark:bg-white/[0.03]`,"data-testid":`automation-trigger`,children:[(0,T.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-dark-500`}),(0,T.jsx)(`select`,{"aria-label":r(`automations.form.frequency`),value:e.kind,onChange:e=>t(k(e.target.value)),className:D,"data-testid":`automation-trigger-kind`,children:E.map(e=>(0,T.jsx)(`option`,{value:e,children:r(`automations.kind.${e}`)},e))}),e.kind===`once`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`input`,{type:`date`,"aria-label":r(`calendar.date`),value:p(e.at),onChange:n=>t({...e,at:g(n.target.value,h(e.at))}),className:D}),(0,T.jsx)(`input`,{type:`time`,"aria-label":r(`automations.form.time`),value:h(e.at),onChange:n=>t({...e,at:g(p(e.at),n.target.value)}),className:D})]}),e.kind===`hourly`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.minute`),(0,T.jsx)(`input`,{type:`number`,min:0,max:59,value:e.minute,onChange:n=>t({...e,minute:Math.min(59,Math.max(0,Number(n.target.value)))}),className:`${D} w-16`})]}),(0,T.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.fromHour`),(0,T.jsx)(`input`,{type:`number`,min:0,max:23,value:e.startHour??0,onChange:n=>t({...e,startHour:Math.min(23,Math.max(0,Number(n.target.value)))}),className:`${D} w-16`})]}),(0,T.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.toHour`),(0,T.jsx)(`input`,{type:`number`,min:0,max:23,value:e.endHour??23,onChange:n=>t({...e,endHour:Math.min(23,Math.max(0,Number(n.target.value)))}),className:`${D} w-16`})]})]}),e.kind===`weekly`&&(0,T.jsx)(`select`,{"aria-label":r(`automations.form.weekday`),value:e.dayOfWeek,onChange:n=>t({...e,dayOfWeek:Number(n.target.value)}),className:D,children:s.map((e,t)=>(0,T.jsx)(`option`,{value:t,children:e},e))}),(e.kind===`monthly`||e.kind===`yearly`)&&(0,T.jsxs)(`label`,{className:`flex items-center gap-1 text-[12px] text-gray-500 dark:text-dark-500`,children:[r(`automations.form.dayOfMonth`),(0,T.jsx)(`input`,{type:`number`,min:1,max:31,value:e.dayOfMonth,onChange:n=>t({...e,dayOfMonth:Math.min(31,Math.max(1,Number(n.target.value)))}),className:`${D} w-16`})]}),e.kind===`yearly`&&(0,T.jsx)(`select`,{"aria-label":r(`automations.form.month`),value:e.month,onChange:n=>t({...e,month:Number(n.target.value)}),className:D,children:Array.from({length:12},(e,t)=>(0,T.jsx)(`option`,{value:t+1,children:c.format(new Date(2024,t,1))},t+1))}),d,n&&(0,T.jsx)(`button`,{type:`button`,onClick:n,"aria-label":r(`common.delete`),className:`ms-auto rounded-md p-1 text-red-500 transition-colors hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,T.jsx)(l,{className:`h-3.5 w-3.5`})})]})}var j=`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,M=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,N=e=>e.isPlugin&&e.pluginId?`plugin:${e.pluginId}`:e.isAgent&&e.agentId?`agent:${e.agentId}`:`ollama`;function P({open:e,automation:t,initial:n,fixedWorkTaskId:r,models:i,saving:a,onClose:o,onSave:s}){return e?(0,T.jsx)(F,{automation:t,initial:n,fixedWorkTaskId:r,models:i,saving:a,onClose:o,onSave:s},t?.id??n?.name??`new`):null}function F({automation:e,initial:t,fixedWorkTaskId:n,models:r,saving:o,onClose:l,onSave:p}){let{t:m}=i(),h=!!(n??e?.workTaskId),[g,y]=(0,_.useState)(e?.name??t?.name??``),[b,x]=(0,_.useState)(e?.instructions??t?.instructions??``),[S,C]=(0,_.useState)(e?.triggers??t?.triggers??[{kind:`daily`,hour:8,minute:0}]),[E,D]=(0,_.useState)(e?.model??``),[O,k]=(0,_.useState)(e?.notify??`app`),[P,F]=(0,_.useState)(e?.target??`chat`),[I,L]=(0,_.useState)(e?.workPolicyId??``),[R,z]=(0,_.useState)([]);(0,_.useEffect)(()=>{if(P!==`work`||h)return;let e=!1;return d.listPolicies().then(t=>{!e&&t.success&&Array.isArray(t.data)&&z(t.data)}).catch(()=>void 0),()=>{e=!0}},[P,h]);let[B,V]=(0,_.useState)(e?.webhookEnabled===!0),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(!1),K=async()=>{if(e){G(!0);try{let t=await f.rotateWebhookSecret(e.id);if(!t.success||!t.data)throw Error(t.error);V(!0),U(t.data)}catch{u.error(m(`automations.webhook.failed`,{defaultValue:`Could not update the webhook.`}))}finally{G(!1)}}},q=async()=>{if(e){G(!0);try{let t=await f.disableWebhook(e.id);if(!t.success)throw Error(t.error);V(!1),U(null)}catch{u.error(m(`automations.webhook.failed`,{defaultValue:`Could not update the webhook.`}))}finally{G(!1)}}},J=g.trim().length>0&&b.trim().length>0&&S.length>0&&S.every(w);return(0,v.createPortal)((0,T.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:l,children:(0,T.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`automation-modal-title`,"data-testid":`automation-modal`,className:`max-h-[90vh] w-full max-w-lg overflow-y-auto rounded-3xl border border-black/[0.07] bg-white p-6 shadow-[0_24px_80px_rgba(0,0,0,0.24)] animate-scale-in scrollbar-thin dark:border-white/[0.08] dark:bg-dark-25`,onClick:e=>e.stopPropagation(),children:[(0,T.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,T.jsx)(`h3`,{id:`automation-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:m(e?`automations.editAutomation`:`automations.newAutomation`)}),(0,T.jsx)(`button`,{onClick:l,"aria-label":m(`common.close`),className:`rounded-xl p-2 transition-colors hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,T.jsx)(c,{size:20,className:`text-gray-500`})})]}),(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`automation-name`,className:M,children:m(`automations.form.name`)}),(0,T.jsx)(`input`,{id:`automation-name`,"data-testid":`automation-name`,type:`text`,value:g,onChange:e=>y(e.target.value),placeholder:m(`automations.form.namePlaceholder`),className:j,maxLength:200,autoFocus:!0})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:M,children:m(`automations.form.triggers`)}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[S.map((e,t)=>(0,T.jsx)(A,{trigger:e,onChange:e=>C(n=>n.map((n,r)=>r===t?e:n)),onRemove:S.length>1?()=>C(e=>e.filter((e,n)=>n!==t)):void 0},t)),S.length<5&&(0,T.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>[...e,{kind:`daily`,hour:8,minute:0}]),"data-testid":`automation-add-trigger`,className:`flex items-center gap-1.5 rounded-lg px-2 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:[(0,T.jsx)(s,{className:`h-3.5 w-3.5`}),m(`automations.form.addTrigger`)]})]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`automation-instructions`,className:M,children:m(`automations.form.instructions`)}),(0,T.jsx)(`textarea`,{id:`automation-instructions`,"data-testid":`automation-instructions`,value:b,onChange:e=>x(e.target.value),placeholder:m(`automations.form.instructionsPlaceholder`),rows:5,className:j,maxLength:2e4})]}),h&&(0,T.jsx)(`p`,{"data-testid":`automation-task-bound-note`,className:`rounded-lg bg-primary-500/10 px-3 py-2 text-[12px] leading-relaxed text-primary-700 dark:text-primary-300`,children:m(`automations.form.taskBoundNote`,{defaultValue:`This routine runs inside the agent's own workspace and conversation, with the agent's model and runtime.`})}),(0,T.jsxs)(`div`,{className:a(`grid grid-cols-2 gap-3`,h&&`hidden`),children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`automation-target`,className:M,children:m(`automations.form.target`)}),(0,T.jsxs)(`select`,{id:`automation-target`,"data-testid":`automation-target`,value:P,onChange:e=>F(e.target.value),className:j,children:[(0,T.jsx)(`option`,{value:`chat`,children:m(`automations.form.targetChat`)}),(0,T.jsx)(`option`,{value:`work`,children:m(`automations.form.targetWork`)})]})]}),P===`work`&&R.length>0&&(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`automation-work-policy`,className:M,children:m(`automations.form.workPolicy`)}),(0,T.jsxs)(`select`,{id:`automation-work-policy`,"data-testid":`automation-work-policy`,value:I,onChange:e=>L(e.target.value),className:j,children:[(0,T.jsx)(`option`,{value:``,children:m(`automations.form.workPolicyDefault`)}),R.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),(0,T.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,T.jsxs)(`div`,{className:a(h&&`hidden`),children:[(0,T.jsx)(`label`,{htmlFor:`automation-model`,className:M,children:m(`automations.form.model`)}),(0,T.jsxs)(`select`,{id:`automation-model`,value:E,onChange:e=>D(e.target.value),className:j,children:[(0,T.jsx)(`option`,{value:``,children:m(`automations.form.modelAuto`)}),r.map(e=>(0,T.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`automation-notify`,className:M,children:m(`automations.form.notification`)}),(0,T.jsxs)(`select`,{id:`automation-notify`,value:O,onChange:e=>k(e.target.value),className:j,children:[(0,T.jsx)(`option`,{value:`app`,children:m(`automations.form.notifyApp`)}),(0,T.jsx)(`option`,{value:`off`,children:m(`automations.form.notifyOff`)})]})]})]}),e&&(0,T.jsxs)(`div`,{"data-testid":`automation-webhook`,className:`rounded-xl border border-gray-200 p-3 dark:border-dark-300`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`automations.webhook.title`,{defaultValue:`Webhook trigger`})}),(0,T.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-600`,children:B?m(`automations.webhook.enabledHint`,{defaultValue:`External systems can fire this automation with the secret. Rotating invalidates the previous secret.`}):m(`automations.webhook.disabledHint`,{defaultValue:`Let an external system (CI, cron, home automation) fire this automation with a POST and a secret.`})})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,T.jsx)(`button`,{type:`button`,"data-testid":`automation-webhook-rotate`,onClick:()=>void K(),disabled:W,className:`rounded-lg border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-100 disabled:opacity-50 dark:border-dark-300 dark:text-dark-700 dark:hover:bg-dark-200`,children:B?m(`automations.webhook.rotate`,{defaultValue:`Rotate secret`}):m(`automations.webhook.enable`,{defaultValue:`Enable`})}),B&&(0,T.jsx)(`button`,{type:`button`,"data-testid":`automation-webhook-disable`,onClick:()=>void q(),disabled:W,className:`rounded-lg border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-100 disabled:opacity-50 dark:border-dark-300 dark:text-dark-700 dark:hover:bg-dark-200`,children:m(`automations.webhook.disable`,{defaultValue:`Disable`})})]})]}),H&&(0,T.jsxs)(`div`,{"data-testid":`automation-webhook-secret`,className:`mt-2 space-y-1 rounded-lg bg-gray-50 p-2 dark:bg-dark-100`,children:[(0,T.jsx)(`p`,{className:`text-[11px] text-gray-500 dark:text-dark-600`,children:m(`automations.webhook.revealHint`,{defaultValue:`Shown once. Send it as a Bearer token or an X-Libre-Webhook-Secret header.`})}),(0,T.jsxs)(`code`,{dir:`ltr`,className:`block break-all font-mono text-xs text-gray-800 dark:text-gray-200`,children:[`POST `,H.path]}),(0,T.jsx)(`code`,{dir:`ltr`,className:`block break-all font-mono text-xs text-gray-800 dark:text-gray-200`,children:H.secret})]})]}),(0,T.jsxs)(`div`,{className:`flex justify-end gap-3 border-t border-gray-200 pt-4 dark:border-dark-300`,children:[(0,T.jsx)(`button`,{onClick:l,className:`rounded-xl px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:text-dark-700 dark:hover:bg-dark-200`,children:m(`common.cancel`)}),(0,T.jsx)(`button`,{onClick:()=>{if(!J)return;if(h){p({name:g.trim(),instructions:b.trim(),triggers:S,notify:O,target:`work`,workTaskId:n??e?.workTaskId});return}let t=r.find(e=>e.name===E);p({name:g.trim(),instructions:b.trim(),triggers:S,...t?{provider:N(t),model:t.name}:{},notify:O,target:P,...P===`work`&&I?{workPolicyId:I}:{}})},disabled:o||!J,"data-testid":`automation-save`,className:`rounded-xl bg-gray-950 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,children:m(o?`common.saving`:`common.save`)})]})]})]})}),document.body)}export{C as n,P as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{f as r}from"./router-vendor-CIwPu612.js";import{t as i}from"./useTranslation-C7GwbUQA.js";import{r as a,t as o}from"./utils-nNyg0lfc.js";import{t as s}from"./chatStore-Dpm3g_Ln.js";import{In as c,J as l,Ln as u,Nt as d,Q as f,Rn as p,Sn as m,it as h,ot as g,t as _,tt as ee,v as te,yr as v}from"./ui-vendor-CPdYrKhz.js";import{t as y}from"./logger-CpCQz3Vi.js";import{T as b}from"./api-D-5hpGht.js";import{t as x}from"./Button-CgN11mgY.js";import"./ui-BK53RPmS.js";import{n as S,t as C}from"./AutomationModal-Dha4KgLI.js";var w=e(t(),1),T=n();function E({days:e,locale:t}){let{t:n}=i(),r=e.reduce((e,t)=>e+t.succeeded,0),a=e.reduce((e,t)=>e+t.failed,0),o=Math.max(1,...e.map(e=>e.succeeded+e.failed)),s=new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}),c=new Date,l=e=>s.format(new Date(c.getFullYear(),c.getMonth(),c.getDate()-29+e));return(0,T.jsxs)(`div`,{className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,"data-testid":`automation-run-strip`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,T.jsx)(`p`,{className:`text-[12px] font-medium text-gray-700 dark:text-dark-700`,children:n(`automations.runHistory`)}),(0,T.jsxs)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:[(0,T.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[r,` `,n(`automations.succeeded`)]}),` · `,(0,T.jsxs)(`span`,{className:`text-red-500 dark:text-red-400`,children:[a,` `,n(`automations.failed`)]})]})]}),(0,T.jsx)(`div`,{className:`flex h-12 items-end gap-[3px]`,children:e.map((e,t)=>{let n=e.succeeded+e.failed;if(n===0)return(0,T.jsx)(`div`,{title:l(t),className:`h-[3px] flex-1 rounded-sm bg-black/[0.06] dark:bg-white/[0.08]`},t);let r=Math.max(6,Math.round(n/o*48)),i=Math.round(e.failed/n*r);return(0,T.jsxs)(`div`,{title:`${l(t)}: ${e.succeeded}✓ ${e.failed}✗`,className:`flex flex-1 flex-col justify-end overflow-hidden rounded-sm`,style:{height:r},children:[(0,T.jsx)(`div`,{className:`w-full bg-emerald-500/80`,style:{height:r-i}}),i>0&&(0,T.jsx)(`div`,{className:`w-full bg-red-500/80`,style:{height:i}})]},t)})})]})}var D=[{id:`morningBrief`,instructions:`Put together my morning brief: the top world, business, and tech headlines from the last 24 hours with one-line summaries, and one story worth reading in depth and why. Keep the whole thing scannable.`,triggers:[{kind:`daily`,hour:7,minute:30}]},{id:`newsDigest`,instructions:`Summarize the most important AI news from the last 24 hours: model releases, notable research papers, funding rounds, and policy changes. For each item add one sentence on why it matters. Skip minor product updates and rumors.`,triggers:[{kind:`daily`,hour:8,minute:0}]},{id:`weeklyReview`,instructions:`Help me wrap the week: prompt me to reflect on what I accomplished, what is still open, and what the top priorities for next week should be. Structure it as a short template I can fill in.`,triggers:[{kind:`weekly`,dayOfWeek:5,hour:16,minute:0}]},{id:`monthlyReport`,instructions:`Draft a monthly status report outline: key accomplishments, metrics to review, risks, and goals for the next month. Leave placeholders where my specifics belong.`,triggers:[{kind:`monthly`,dayOfMonth:1,hour:9,minute:0}]}],O=y(`pages:automations`),k=()=>{let{t:e,i18n:t}=i(),n=r(),y=s(e=>e.models),k=s(e=>e.loadModels),[j,M]=(0,w.useState)(`automations`),[N,P]=(0,w.useState)([]),[F,I]=(0,w.useState)([]),[L,R]=(0,w.useState)(null),[z,B]=(0,w.useState)(!0),[V,H]=(0,w.useState)(!1),[U,W]=(0,w.useState)(null),[G,K]=(0,w.useState)(null),[q,J]=(0,w.useState)(!1),[Y,X]=(0,w.useState)(null),[Z,ne]=(0,w.useState)(0),Q=(0,w.useCallback)(()=>ne(e=>e+1),[]);(0,w.useEffect)(()=>{let t=!1;return Promise.all([b.getAutomations(),b.getRuns(),b.getRunsSummary()]).then(([e,n,r])=>{t||(e.success&&e.data&&P(e.data),n.success&&n.data&&I(n.data),r.success&&r.data&&R(r.data))}).catch(n=>{t||(O.error(`Failed to load automations:`,n),v.error(e(`automations.loadFailed`)))}).finally(()=>{t||B(!1)}),()=>{t=!0}},[Z,e]),(0,w.useEffect)(()=>{y.length===0&&k({quiet:!0})},[y.length,k]),(0,w.useEffect)(()=>{j===`runs`&&b.markRunsSeen().then(()=>b.getRunsSummary()).then(e=>{e.success&&e.data&&R(e.data)}).catch(()=>void 0)},[j,F.length]);let re=()=>{W(null),K(null),H(!0)},ie=t=>{W(null),K({name:e(`automations.templates.${t.id}.name`),instructions:t.instructions,triggers:t.triggers}),H(!0)},ae=e=>{W(e),K(null),X(null),H(!0)},oe=async t=>{J(!0);try{let n=U?await b.updateAutomation(U.id,t):await b.createAutomation(t);n.success?(H(!1),Q()):v.error(n.error||e(`automations.saveFailed`))}catch(t){O.error(`Failed to save automation:`,t),v.error(e(`automations.saveFailed`))}finally{J(!1)}},$=async(t,n)=>{X(null);try{n===`pause`?await b.pauseAutomation(t.id):n===`resume`?await b.resumeAutomation(t.id):n===`run`?(await b.runAutomationNow(t.id),v.success(e(`automations.runQueued`))):await b.deleteAutomation(t.id),Q()}catch(t){O.error(`Automation ${n} failed:`,t),v.error(e(`automations.actionFailed`))}},se=e=>e.status===`succeeded`?(0,T.jsx)(p,{className:`h-4 w-4 text-emerald-500`}):e.status===`failed`?(0,T.jsx)(c,{className:`h-4 w-4 text-red-500`}):(0,T.jsx)(d,{className:`h-4 w-4 animate-spin text-gray-400`}),ce=t=>N.find(e=>e.id===t)?.name??e(`automations.deletedAutomation`);return(0,T.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`automations-page`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-black/[0.06] px-4 py-3 dark:border-white/[0.07]`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,T.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`automations.title`)}),(0,T.jsx)(`div`,{className:`flex items-center rounded-xl bg-black/[0.04] p-0.5 dark:bg-white/[0.06]`,children:[`automations`,`runs`].map(t=>(0,T.jsx)(`button`,{onClick:()=>M(t),"data-testid":`automations-tab-${t}`,className:o(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors`,j===t?`bg-white text-gray-900 shadow-sm dark:bg-dark-200 dark:text-dark-900`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),children:e(`automations.tab.${t}`)},t))})]}),(0,T.jsxs)(x,{size:`sm`,onClick:re,"data-testid":`automation-new`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,T.jsx)(f,{className:`h-3.5 w-3.5`}),e(`automations.newAutomation`)]})]}),(0,T.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-4 py-4 scrollbar-thin`,children:[j===`automations`?z?null:N.length===0?(0,T.jsxs)(`div`,{className:`px-3 py-16 text-center`,children:[(0,T.jsx)(_,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,T.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-dark-500`,children:e(`automations.empty`)})]}):(0,T.jsx)(`div`,{className:`mx-auto w-full max-w-3xl space-y-2`,children:N.map(n=>(0,T.jsx)(`div`,{"data-testid":`automation-row`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`p`,{className:`truncate text-[14px] font-medium text-gray-900 dark:text-dark-900`,children:n.name}),(0,T.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,n.status===`active`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:`bg-gray-500/10 text-gray-500 dark:text-dark-500`),children:e(`automations.status.${n.status}`)})]}),(0,T.jsxs)(`p`,{className:`mt-0.5 truncate text-[12px] text-gray-500 dark:text-dark-500`,children:[S(n.triggers,t.language,e),n.nextRunAt&&(0,T.jsxs)(T.Fragment,{children:[` · `,e(`automations.nextRun`,{when:new Intl.DateTimeFormat(t.language,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(n.nextRunAt)})]})]})]}),(0,T.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,T.jsx)(`button`,{onClick:()=>X(e=>e===n.id?null:n.id),"aria-label":e(`automations.actions`),"data-testid":`automation-menu`,className:`rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-black/[0.04] hover:text-gray-700 dark:hover:bg-white/[0.06] dark:hover:text-dark-800`,children:(0,T.jsx)(m,{className:`h-4 w-4`})}),Y===n.id&&(0,T.jsxs)(`div`,{className:`absolute end-0 top-8 z-20 w-44 rounded-xl border border-black/[0.07] bg-white p-1 shadow-lg dark:border-white/[0.08] dark:bg-dark-100`,children:[(0,T.jsx)(A,{icon:h,label:e(`common.edit`),onClick:()=>ae(n)}),n.status===`active`?(0,T.jsx)(A,{icon:g,label:e(`automations.pause`),onClick:()=>$(n,`pause`)}):(0,T.jsx)(A,{icon:ee,label:e(`automations.resume`),onClick:()=>$(n,`resume`)}),(0,T.jsx)(A,{icon:l,label:e(`automations.runNow`),onClick:()=>$(n,`run`)}),(0,T.jsx)(A,{icon:te,label:e(`common.delete`),destructive:!0,onClick:()=>$(n,`delete`)})]})]})]})},n.id))}):null,j===`automations`&&!z&&(0,T.jsxs)(`div`,{className:`mx-auto mt-8 w-full max-w-3xl`,children:[(0,T.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:e(`automations.templatesTitle`)}),(0,T.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:D.map(n=>(0,T.jsxs)(`button`,{type:`button`,onClick:()=>ie(n),"data-testid":`automation-template`,className:`rounded-2xl border border-black/[0.06] bg-white/40 px-4 py-3 text-start transition-colors hover:bg-white/80 dark:border-white/[0.07] dark:bg-dark-100/40 dark:hover:bg-dark-100/80`,children:[(0,T.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:e(`automations.templates.${n.id}.name`)}),(0,T.jsx)(`p`,{className:`mt-0.5 text-[12px] text-gray-500 dark:text-dark-500`,children:e(`automations.templates.${n.id}.description`)}),(0,T.jsx)(`p`,{className:`mt-1.5 text-[11px] text-gray-400 dark:text-dark-500`,children:S(n.triggers,t.language,e)})]},n.id))})]}),j===`runs`&&(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[L&&(0,T.jsx)(E,{days:L.days,locale:t.language}),F.length===0?(0,T.jsxs)(`div`,{className:`px-3 py-12 text-center`,children:[(0,T.jsx)(u,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,T.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-dark-500`,children:e(`automations.noRuns`)})]}):(0,T.jsx)(`div`,{className:`space-y-1`,"data-testid":`automation-run-list`,children:F.map(r=>(0,T.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-black/[0.05] bg-white/50 px-3 py-2 dark:border-white/[0.06] dark:bg-dark-100/50`,children:[se(r),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`p`,{className:`truncate text-[13px] text-gray-900 dark:text-dark-900`,children:ce(r.automationId)}),(0,T.jsxs)(`p`,{className:`truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[a(r.scheduledFor,t.language),r.error&&(0,T.jsxs)(T.Fragment,{children:[` · `,(0,T.jsx)(`span`,{className:`text-red-500`,children:r.error})]})]})]}),r.sessionId&&(0,T.jsx)(`button`,{onClick:()=>n(`/c/${r.sessionId}`),"data-testid":`automation-run-open`,className:`shrink-0 rounded-lg px-2.5 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:e(`automations.openChat`)}),r.workTaskId&&(0,T.jsx)(`button`,{onClick:()=>n(`/work/${r.workTaskId}`),"data-testid":`automation-run-open-task`,className:`shrink-0 rounded-lg px-2.5 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:e(`automations.openTask`)})]},r.id))})]})]}),(0,T.jsx)(C,{open:V,automation:U,initial:G,models:y,saving:q,onClose:()=>H(!1),onSave:e=>void oe(e)})]})};function A({icon:e,label:t,destructive:n,onClick:r}){return(0,T.jsxs)(`button`,{onClick:r,className:o(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-start text-[13px] transition-colors`,n?`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`:`text-gray-700 hover:bg-black/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.06]`),children:[(0,T.jsx)(e,{className:`h-3.5 w-3.5`}),t]})}export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{t as r}from"./useTranslation-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{t as r}from"./useTranslation-C7GwbUQA.js";import{c as i,n as a,p as o,yr as s}from"./ui-vendor-CPdYrKhz.js";import{t as c}from"./logger-CpCQz3Vi.js";import{t as l}from"./Button-CgN11mgY.js";import"./ui-BK53RPmS.js";var u=e(t(),1),d=n(),f=c(`components:avatar-upload`),p=({value:e,onChange:t,className:n=``})=>{let{t:c}=r(),p=(0,u.useRef)(null),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(!1),v=async e=>{if(!e.type.startsWith(`image/`)){s.error(c(`user.avatar.invalidFile`));return}if(e.size>2097152){s.error(c(`user.avatar.fileTooLarge`));return}h(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),s.success(c(`user.avatar.uploaded`))},n.onerror=()=>{s.error(c(`user.avatar.readFailed`))},n.readAsDataURL(e)}catch(e){f.error(`Failed to upload avatar:`,e),s.error(c(`user.avatar.uploadFailed`))}finally{h(!1)}},y=e=>{let t=e.target.files?.[0];t&&v(t)},b=e=>{e.preventDefault(),_(!0)},x=e=>{e.preventDefault(),_(!1)},S=e=>{e.preventDefault(),_(!1);let t=e.dataTransfer.files?.[0];t&&v(t)},C=()=>{t(``),s.success(c(`user.avatar.removed`))},w=()=>e||null;return(0,d.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:c(`user.avatar.label`)}),(0,d.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,d.jsx)(`div`,{className:`flex-shrink-0`,children:(0,d.jsx)(`div`,{className:`w-20 h-20 rounded-full overflow-hidden bg-gray-100 dark:bg-dark-200 border-2 border-gray-300 dark:border-dark-300 flex items-center justify-center`,children:w()?(0,d.jsx)(`img`,{src:w(),alt:`Avatar preview`,className:`w-full h-full object-cover`}):(0,d.jsx)(i,{className:`h-8 w-8 text-gray-400 dark:text-gray-500`})})}),(0,d.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[e?(0,d.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,d.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,d.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:c(`user.avatar.customAvatar`)}),(0,d.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c(`user.avatar.clickToChange`)})]}),(0,d.jsx)(l,{variant:`ghost`,size:`sm`,onClick:C,className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,d.jsx)(a,{className:`h-4 w-4`})})]}):(0,d.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors ${g?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:b,onDragLeave:x,onDrop:S,onClick:()=>p.current?.click(),children:[(0,d.jsx)(o,{className:`h-8 w-8 mx-auto text-gray-400 dark:text-gray-500 mb-2`}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:c(`user.avatar.uploadAvatarImage`)}),(0,d.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-2`,children:c(`user.avatar.dragAndDrop`)}),(0,d.jsxs)(l,{variant:`outline`,size:`sm`,disabled:m,className:`mx-auto`,children:[(0,d.jsx)(o,{className:`h-4 w-4 mr-2`}),c(m?`user.avatar.uploading`:`user.avatar.chooseImage`)]})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:c(`user.avatar.enterImageUrl`)}),(0,d.jsx)(`input`,{type:`url`,value:e,onChange:e=>t(e.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800`,placeholder:`https://example.com/avatar.jpg`})]})]})]}),(0,d.jsx)(`input`,{ref:p,type:`file`,accept:`image/*`,onChange:y,className:`hidden`}),(0,d.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:c(`user.avatar.supportedFormats`)})]})})};export{p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-hePW80VL.js";import{_ as e,g as t}from"./markdown-core-CsTEqgp1.js";import{t as n}from"./utils-
|
|
1
|
+
import"./rolldown-runtime-hePW80VL.js";import{_ as e,g as t}from"./markdown-core-CsTEqgp1.js";import{t as n}from"./utils-nNyg0lfc.js";e();var r=t(),i=({variant:e=`primary`,size:t=`md`,loading:i=!1,disabled:a,children:o,className:s,...c})=>(0,r.jsxs)(`button`,{className:n(`group relative inline-flex select-none items-center justify-center rounded-xl border font-medium tracking-[-0.01em] transition-[background-color,border-color,color,box-shadow,opacity] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas dark:focus-visible:ring-primary-400 disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,{primary:`border-transparent bg-ink text-ink-inverse shadow-subtle hover:opacity-90`,secondary:`border-line bg-surface-raised text-ink shadow-subtle hover:border-line-strong hover:bg-surface-subtle`,outline:`border-line bg-transparent text-ink hover:border-line-strong hover:bg-surface-subtle`,ghost:`border-transparent bg-transparent text-ink-muted shadow-none hover:bg-surface-subtle hover:text-ink`,danger:`border-transparent bg-error-600 text-white shadow-subtle hover:bg-error-700 dark:bg-error-500 dark:text-ink-inverse dark:hover:bg-error-400`}[e],{sm:`h-8 px-3 text-sm gap-1.5`,md:`h-10 px-4 text-sm gap-2`,lg:`h-11 px-5 text-base gap-2.5`}[t],s),disabled:a||i,"aria-busy":i||void 0,...c,children:[i&&(0,r.jsxs)(`svg`,{className:`mr-2 h-4 w-4 animate-spin`,"aria-hidden":`true`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,r.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,r.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),o]});export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{n as r}from"./react-vendor-BsJBHRYW.js";import{f as i}from"./router-vendor-BGP0k6Y2.js";import{t as a}from"./useTranslation-DrnYb6Cx.js";import{t as o}from"./utils-D9UstwTG.js";import{Hn as s,R as c,Un as l,Z as u,_r as d,n as f,p,v as m,xn as h}from"./ui-vendor-C0KwbTD4.js";import{t as g}from"./logger-CpCQz3Vi.js";import{O as _,T as v}from"./api-2DulPtq1.js";import{t as y}from"./Button--pDOakZx.js";import"./ui-DUzqxWMk.js";import{t as b}from"./ShareDialog-BW8iGd_i.js";import{a as x,c as S,d as C,i as w,l as T,n as E,o as D,r as O,s as k,t as A,u as j}from"./calendarDates-Co3o_05Y.js";var M=e(t(),1),N=n(),P={event:`bg-primary-500/15 text-primary-700 hover:bg-primary-500/25 dark:text-primary-300`,automation:`bg-amber-500/15 text-amber-700 hover:bg-amber-500/25 dark:text-amber-300`,runSucceeded:`bg-emerald-500/15 text-emerald-700 hover:bg-emerald-500/25 dark:text-emerald-300`,runFailed:`bg-red-500/15 text-red-700 hover:bg-red-500/25 dark:text-red-300`};function F({event:e,label:t,onClick:n}){return(0,N.jsx)(`button`,{type:`button`,"data-testid":`calendar-event-chip`,"data-variant":e.variant??`event`,title:e.title,onClick:e=>{e.stopPropagation(),n()},className:o(`w-full truncate rounded-md px-1.5 py-0.5 text-start text-[11px] leading-4 transition-colors`,P[e.variant??`event`],e.baseEventId&&`opacity-75`),children:t})}var I=3;function L({year:e,monthIndex:t,events:n,onDayClick:r,onEventClick:i}){let{t:s,i18n:c}=a(),l=(0,M.useMemo)(()=>O(e,t),[e,t]),u=new Date,d=(0,M.useMemo)(()=>{let e=new Map;for(let t of n){let n=new Date(t.startAt),r=`${n.getFullYear()}-${n.getMonth()}-${n.getDate()}`,i=e.get(r);i?i.push(t):e.set(r,[t])}return e},[n]),f=(0,M.useMemo)(()=>C(c.language),[c.language]);return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`calendar-month-grid`,children:[(0,N.jsx)(`div`,{className:`grid grid-cols-7 border-b border-black/[0.06] dark:border-white/[0.07]`,children:f.map(e=>(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-center text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:e},e))}),(0,N.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-7 grid-rows-6`,children:l.map(e=>{let n=e.getMonth()===t,a=w(e,u),l=`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`,f=d.get(l)??[],p=f.length-I;return(0,N.jsxs)(`div`,{role:`gridcell`,"data-testid":`calendar-day-cell`,onClick:()=>r(e),className:o(`flex min-h-0 cursor-pointer flex-col gap-0.5 border-b border-e border-black/[0.04] p-1 transition-colors hover:bg-black/[0.02] dark:border-white/[0.04] dark:hover:bg-white/[0.03]`,!n&&`opacity-40`),children:[(0,N.jsx)(`span`,{className:o(`flex h-6 w-6 items-center justify-center rounded-full text-[12px]`,a?`bg-primary-500 font-semibold text-white`:`text-gray-600 dark:text-dark-600`),children:e.getDate()}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-0.5 overflow-hidden`,children:[f.slice(0,I).map(e=>(0,N.jsx)(F,{event:e,label:e.allDay?e.title:`${k(e.startAt,c.language)} ${e.title}`,onClick:()=>i(e)},e.id)),p>0&&(0,N.jsx)(`span`,{className:`px-1 text-[10px] text-gray-400 dark:text-dark-500`,children:s(`calendar.more`,{n:p})})]})]},l)})})]})}var R=48;function ee({anchor:e,events:t,dayCount:n=7,onDayClick:r,onEventClick:i}){let{i18n:s}=a(),c=(0,M.useMemo)(()=>n===1?[new Date(e.getFullYear(),e.getMonth(),e.getDate())]:j(e),[e,n]),l=new Date,u=(0,M.useMemo)(()=>new Intl.DateTimeFormat(s.language,{hour:`numeric`}),[s.language]),d=(0,M.useMemo)(()=>new Intl.DateTimeFormat(s.language,{weekday:`short`,day:`numeric`}),[s.language]),f=e=>t.filter(t=>t.allDay&&w(new Date(t.startAt),e)),p=e=>t.filter(t=>!t.allDay&&w(new Date(t.startAt),e));return(0,N.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto scrollbar-thin`,"data-testid":`calendar-week-grid`,children:(0,N.jsxs)(`div`,{className:`grid grid-cols-[3.5rem_repeat(7,1fr)]`,children:[(0,N.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-black/[0.06] bg-surface dark:border-white/[0.07]`}),c.map(e=>(0,N.jsxs)(`div`,{className:`sticky top-0 z-10 border-b border-e border-black/[0.06] bg-surface px-1 py-1.5 dark:border-white/[0.07]`,children:[(0,N.jsx)(`span`,{className:o(`block truncate text-center text-[11px] font-medium`,w(e,l)?`text-primary-600 dark:text-primary-400`:`text-gray-500 dark:text-dark-500`),children:d.format(e)}),(0,N.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:f(e).map(e=>(0,N.jsx)(F,{event:e,label:e.title,onClick:()=>i(e)},e.id))})]},e.toISOString())),Array.from({length:24},(e,t)=>(0,N.jsxs)(M.Fragment,{children:[(0,N.jsx)(`div`,{className:`relative border-b border-black/[0.04] pe-1.5 text-end text-[10px] text-gray-400 dark:border-white/[0.04] dark:text-dark-500`,children:(0,N.jsx)(`span`,{className:`relative -top-1.5`,children:t>0?u.format(new Date(2024,0,1,t)):``})}),c.map(e=>{let n=p(e).filter(e=>new Date(e.startAt).getHours()===t);return(0,N.jsx)(`div`,{onClick:()=>r(e,t),style:{height:R},className:`cursor-pointer space-y-0.5 overflow-hidden border-b border-e border-black/[0.04] p-0.5 transition-colors hover:bg-black/[0.02] dark:border-white/[0.04] dark:hover:bg-white/[0.03]`,children:n.map(e=>(0,N.jsx)(F,{event:e,label:`${k(e.startAt,s.language)} ${e.title}`,onClick:()=>i(e)},e.id))},`${e.toISOString()}-${t}`)})]},t))]})})}var z=r(),B=e=>!e||e.kind===`once`||e.kind===`hourly`?`none`:e.kind,V=(e,t)=>{let n=new Date(t),r=n.getHours(),i=n.getMinutes();switch(e){case`daily`:return{kind:`daily`,hour:r,minute:i};case`weekly`:return{kind:`weekly`,dayOfWeek:n.getDay(),hour:r,minute:i};case`monthly`:return{kind:`monthly`,dayOfMonth:n.getDate(),hour:r,minute:i};case`yearly`:return{kind:`yearly`,month:n.getMonth()+1,dayOfMonth:n.getDate(),hour:r,minute:i};default:return null}},H=`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,U=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`;function te({open:e,event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s}){return e?(0,N.jsx)(W,{event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s},`${t?.id??`new`}:${n}`):null}function W({event:e,initialStartAt:t,calendars:n,saving:r,onClose:i,onSave:o,onDelete:s}){let{t:c}=a(),l=e?.startAt??t,[u,d]=(0,M.useState)(e?.title??``),[p,h]=(0,M.useState)(e?.notes??``),[g,_]=(0,M.useState)(S(l)),[v,y]=(0,M.useState)(e?T(l):`09:00`),[b,x]=(0,M.useState)(e?.endAt===void 0?``:T(e.endAt)),[C,w]=(0,M.useState)(e?.allDay??!1),[D,O]=(0,M.useState)(B(e?.recurrence)),[k,A]=(0,M.useState)(e?.calendarId??``),[j,P]=(0,M.useState)(e?.reminderMinutes===void 0?``:String(e.reminderMinutes)),F=()=>{if(!u.trim()||!g)return;let e=E(g,C?``:v),t=!C&&b?E(g,b):null;o({title:u.trim(),notes:p.trim()?p.trim():void 0,startAt:e,endAt:t!==null&&t>e?t:null,allDay:C,recurrence:V(D,e),calendarId:k||null,reminderMinutes:j?Number(j):null})},I=[{value:``,label:c(`calendar.reminderNone`)},{value:`5`,label:c(`calendar.reminderMinutes`,{minutes:5})},{value:`15`,label:c(`calendar.reminderMinutes`,{minutes:15})},{value:`30`,label:c(`calendar.reminderMinutes`,{minutes:30})},{value:`60`,label:c(`calendar.reminderHour`)},{value:`1440`,label:c(`calendar.reminderDay`)}],L=[{value:`none`,label:c(`calendar.repeatNone`)},{value:`daily`,label:c(`calendar.repeatDaily`)},{value:`weekly`,label:c(`calendar.repeatWeekly`)},{value:`monthly`,label:c(`calendar.repeatMonthly`)},{value:`yearly`,label:c(`calendar.repeatYearly`)}];return(0,z.createPortal)((0,N.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:i,children:(0,N.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`calendar-event-modal-title`,"data-testid":`calendar-event-modal`,className:`w-full max-w-md rounded-3xl border border-black/[0.07] bg-white p-6 shadow-[0_24px_80px_rgba(0,0,0,0.24)] animate-scale-in dark:border-white/[0.08] dark:bg-dark-25`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,N.jsx)(`h3`,{id:`calendar-event-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:c(e?`calendar.editEvent`:`calendar.newEvent`)}),(0,N.jsx)(`button`,{onClick:i,"aria-label":c(`common.close`),className:`rounded-xl p-2 transition-colors hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(f,{size:20,className:`text-gray-500`})})]}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-title`,className:U,children:c(`calendar.eventTitle`)}),(0,N.jsx)(`input`,{id:`calendar-event-title`,"data-testid":`calendar-event-title`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:c(`calendar.titlePlaceholder`),className:H,maxLength:200,autoFocus:!0})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-date`,className:U,children:c(`calendar.date`)}),(0,N.jsx)(`input`,{id:`calendar-event-date`,type:`date`,value:g,onChange:e=>_(e.target.value),className:H})]}),(0,N.jsx)(`div`,{className:`flex items-end pb-1.5`,children:(0,N.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] text-gray-700 dark:text-dark-700`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),className:`h-4 w-4 rounded accent-primary-500`}),c(`calendar.allDay`)]})})]}),!C&&(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-start`,className:U,children:c(`calendar.start`)}),(0,N.jsx)(`input`,{id:`calendar-event-start`,type:`time`,value:v,onChange:e=>y(e.target.value),className:H})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-end`,className:U,children:c(`calendar.end`)}),(0,N.jsx)(`input`,{id:`calendar-event-end`,type:`time`,value:b,onChange:e=>x(e.target.value),className:H})]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-repeat`,className:U,children:c(`calendar.repeat`)}),(0,N.jsx)(`select`,{id:`calendar-event-repeat`,value:D,onChange:e=>O(e.target.value),className:H,children:L.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-notes`,className:U,children:c(`calendar.notes`)}),(0,N.jsx)(`textarea`,{id:`calendar-event-notes`,value:p,onChange:e=>h(e.target.value),rows:3,className:H,maxLength:1e4})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:U,children:c(`calendar.calendarLabel`)}),(0,N.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),className:H,"data-testid":`calendar-event-calendar`,children:[(0,N.jsx)(`option`,{value:``,children:c(`calendar.personalCalendar`)}),n.map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:U,children:c(`calendar.reminderLabel`)}),(0,N.jsx)(`select`,{value:j,onChange:e=>P(e.target.value),className:H,"data-testid":`calendar-event-reminder`,children:I.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-200 pt-4 dark:border-dark-300`,children:[e&&s?(0,N.jsxs)(`button`,{onClick:s,"data-testid":`calendar-event-delete`,className:`flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:[(0,N.jsx)(m,{className:`h-4 w-4`}),c(`common.delete`)]}):(0,N.jsx)(`span`,{}),(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsx)(`button`,{onClick:i,className:`rounded-xl px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:text-dark-700 dark:hover:bg-dark-200`,children:c(`common.cancel`)}),(0,N.jsx)(`button`,{onClick:F,disabled:r||!u.trim(),"data-testid":`calendar-event-save`,className:`rounded-xl bg-gray-950 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,children:c(r?`common.saving`:`common.save`)})]})]})]})]})}),document.body)}var G=g(`pages:calendar`),K=()=>{let{t:e,i18n:t}=a(),n=i(),[r,m]=(0,M.useState)(`month`),[g,S]=(0,M.useState)(()=>new Date),[C,w]=(0,M.useState)([]),[T,E]=(0,M.useState)([]),[O,k]=(0,M.useState)(!1),[j,P]=(0,M.useState)(null),[F,I]=(0,M.useState)(()=>Date.now()),[R,z]=(0,M.useState)(!1),[B,V]=(0,M.useState)([]),[H,U]=(0,M.useState)(``),[W,K]=(0,M.useState)(null),q=M.useRef(null),J=(0,M.useMemo)(()=>{if(r===`month`){let e=new Date(g.getFullYear(),g.getMonth(),1),t=D(e);return{from:t.getTime(),to:A(t,42).getTime()}}if(r===`day`){let e=new Date(g.getFullYear(),g.getMonth(),g.getDate());return{from:e.getTime(),to:A(e,1).getTime()}}let e=D(g);return{from:e.getTime(),to:A(e,7).getTime()}},[g,r]),[Y,ne]=(0,M.useState)(0),X=(0,M.useCallback)(()=>ne(e=>e+1),[]);(0,M.useEffect)(()=>{_.getCalendars().then(e=>{e.success&&e.data&&V(e.data)}).catch(e=>G.error(`Failed to load calendars:`,e))},[Y]),(0,M.useEffect)(()=>{let t=!1;return _.getEvents(J.from,J.to).then(e=>{t||e.success&&e.data&&w(e.data)}).catch(n=>{t||(G.error(`Failed to load calendar events:`,n),d.error(e(`calendar.loadFailed`)))}),Promise.all([v.getOccurrences(J.from,J.to),v.getRuns({from:J.from,to:J.to}),v.getAutomations()]).then(([n,r,i])=>{if(t)return;let a=Date.now(),o=t=>i.data?.find(e=>e.id===t)?.name??e(`automations.deletedAutomation`),s=[];for(let e of n.data??[])e.at<=a||s.push({id:`automation:${e.automationId}:${e.at}`,title:e.name,startAt:e.at,allDay:!1,createdAt:e.at,updatedAt:e.at,variant:`automation`});for(let e of r.data??[])(e.status===`succeeded`||e.status===`failed`)&&s.push({id:`run:${e.id}`,title:o(e.automationId),startAt:e.scheduledFor,allDay:!1,createdAt:e.createdAt,updatedAt:e.createdAt,variant:e.status===`succeeded`?`runSucceeded`:`runFailed`,...e.sessionId?{sessionId:e.sessionId}:{}});E(s)}).catch(e=>{t||G.error(`Failed to project automations onto the calendar:`,e)}),()=>{t=!0}},[J.from,J.to,Y,e]);let Z=(0,M.useMemo)(()=>[...C,...T].sort((e,t)=>e.startAt-t.startAt),[C,T]),Q=e=>{S(t=>r===`month`?new Date(t.getFullYear(),t.getMonth()+e,1):A(t,e*(r===`day`?1:7)))},$=(e,t=9)=>{P(null),I(new Date(e.getFullYear(),e.getMonth(),e.getDate(),t,0).getTime()),k(!0)},re=t=>{if(t.variant===`runSucceeded`||t.variant===`runFailed`){t.sessionId?n(`/c/${t.sessionId}`):n(`/automations`);return}if(t.variant===`automation`){n(`/automations`);return}if(t.shared&&t.shared.permission!==`write`){d(e(`calendar.sharedReadOnly`));return}if(t.baseEventId){let e=C.find(e=>e.id===t.baseEventId);P(e??t)}else P(t);k(!0)},ie=async t=>{z(!0);try{let n=j?await _.updateEvent(j.id,t):await _.createEvent(t);n.success?(k(!1),X()):d.error(n.error||e(`calendar.saveFailed`))}catch(t){G.error(`Failed to save calendar event:`,t),d.error(e(`calendar.saveFailed`))}finally{z(!1)}},ae=async()=>{if(j){z(!0);try{let t=await _.deleteEvent(j.id);t.success?(k(!1),X()):d.error(t.error||e(`calendar.deleteFailed`))}catch(t){G.error(`Failed to delete calendar event:`,t),d.error(e(`calendar.deleteFailed`))}finally{z(!1)}}},oe=r===`month`?x(g.getFullYear(),g.getMonth(),t.language):new Intl.DateTimeFormat(t.language,{month:`long`,day:`numeric`,year:`numeric`}).format(r===`day`?g:D(g)),se=async()=>{let t=H.trim();t&&((await _.createCalendar({name:t}).catch(()=>void 0))?.success?(U(``),X()):d.error(e(`calendar.calendarSaveFailed`)))},ce=async t=>{try{let e=await _.exportIcs(t),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`calendar.ics`,r.click(),URL.revokeObjectURL(n)}catch(t){G.error(`Failed to export the calendar:`,t),d.error(e(`calendar.exportFailed`))}},le=async t=>{try{let n=await t.text(),r=await _.importIcs(n);r.success&&r.data?(d.success(e(`calendar.importResult`,{total:r.data.imported})),X()):d.error(r.error||e(`calendar.importFailed`))}catch(t){G.error(`Failed to import the calendar:`,t),d.error(e(`calendar.importFailed`))}};return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`calendar-page`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-black/[0.06] px-4 py-3 dark:border-white/[0.07]`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`calendar.title`)}),(0,N.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-dark-500`,"data-testid":`calendar-range-label`,children:oe})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`flex items-center rounded-xl bg-black/[0.04] p-0.5 dark:bg-white/[0.06]`,children:[`month`,`week`,`day`].map(t=>(0,N.jsx)(`button`,{onClick:()=>m(t),"data-testid":`calendar-view-${t}`,className:o(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors`,r===t?`bg-white text-gray-900 shadow-sm dark:bg-dark-200 dark:text-dark-900`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),children:e(`calendar.${t}`)},t))}),(0,N.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>Q(-1),className:`h-7 w-7 p-0`,title:e(`calendar.previous`),children:(0,N.jsx)(s,{className:`h-4 w-4`})}),(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>S(new Date),className:`h-7 px-2 text-[12px]`,children:e(`calendar.today`)}),(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>Q(1),className:`h-7 w-7 p-0`,title:e(`calendar.next`),children:(0,N.jsx)(l,{className:`h-4 w-4`})})]}),(0,N.jsxs)(y,{size:`sm`,onClick:()=>$(g),"data-testid":`calendar-new-event`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,N.jsx)(u,{className:`h-3.5 w-3.5`}),e(`calendar.newEvent`)]})]})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-black/[0.06] px-4 py-2 dark:border-white/[0.07]`,children:[B.map(t=>(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-black/[0.08] px-2.5 py-1 text-xs text-gray-700 dark:border-white/[0.1] dark:text-dark-800`,"data-testid":`calendar-chip`,children:[(0,N.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:t.color??`#8b8b8b`}}),t.name,t.shared?(0,N.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:e(`calendar.sharedBadge`)}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{onClick:()=>K(t),className:`text-gray-400 hover:text-primary-500 dark:text-dark-500`,title:e(`calendar.shareCalendar`),"data-testid":`calendar-share`,children:(0,N.jsx)(c,{className:`h-3 w-3`})}),(0,N.jsx)(`button`,{onClick:()=>void _.deleteCalendar(t.id).then(X),className:`text-gray-400 hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,N.jsx)(f,{className:`h-3 w-3`})})]})]},t.id)),(0,N.jsx)(`input`,{type:`text`,value:H,onChange:e=>U(e.target.value),onKeyDown:e=>{e.key===`Enter`&&se()},placeholder:e(`calendar.newCalendarPlaceholder`),className:`w-36 rounded-full border border-dashed border-black/[0.12] bg-transparent px-2.5 py-1 text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:border-white/[0.16] dark:text-dark-800`,"data-testid":`calendar-new-calendar`}),(0,N.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,N.jsx)(`input`,{ref:q,type:`file`,accept:`.ics,text/calendar`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&le(t),e.target.value=``}}),(0,N.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>q.current?.click(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-import`,children:[(0,N.jsx)(p,{className:`h-3.5 w-3.5`}),e(`calendar.importIcs`)]}),(0,N.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>void ce(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-export`,children:[(0,N.jsx)(h,{className:`h-3.5 w-3.5`}),e(`calendar.exportIcs`)]})]})]}),r===`month`?(0,N.jsx)(L,{year:g.getFullYear(),monthIndex:g.getMonth(),events:Z,onDayClick:e=>$(e),onEventClick:re}):(0,N.jsx)(ee,{anchor:g,events:Z,dayCount:r===`day`?1:7,onDayClick:(e,t)=>$(e,t),onEventClick:re}),W&&(0,N.jsx)(b,{resourceType:`calendar`,resourceId:W.id,resourceLabel:W.name,onClose:()=>K(null)}),(0,N.jsx)(te,{open:O,event:j,initialStartAt:F,calendars:B.filter(e=>!e.shared||e.shared.permission===`write`),saving:R,onClose:()=>k(!1),onSave:e=>void ie(e),onDelete:()=>void ae()})]})};export{K as default};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{n as r}from"./react-vendor-BsJBHRYW.js";import{f as i}from"./router-vendor-CIwPu612.js";import{t as a}from"./useTranslation-C7GwbUQA.js";import{t as o}from"./utils-nNyg0lfc.js";import{Cn as s,Gn as c,Q as l,R as u,Wn as d,n as f,p,v as m,yr as h}from"./ui-vendor-CPdYrKhz.js";import{t as g}from"./logger-CpCQz3Vi.js";import{O as _,T as v}from"./api-D-5hpGht.js";import{t as y}from"./Button-CgN11mgY.js";import"./ui-BK53RPmS.js";import{t as b}from"./ShareDialog-BCEVgtbN.js";import{a as x,c as S,d as C,i as w,l as T,n as E,o as D,r as O,s as k,t as A,u as j}from"./calendarDates-Co3o_05Y.js";var M=e(t(),1),N=n(),P={event:`bg-primary-500/15 text-primary-700 hover:bg-primary-500/25 dark:text-primary-300`,automation:`bg-amber-500/15 text-amber-700 hover:bg-amber-500/25 dark:text-amber-300`,runSucceeded:`bg-emerald-500/15 text-emerald-700 hover:bg-emerald-500/25 dark:text-emerald-300`,runFailed:`bg-red-500/15 text-red-700 hover:bg-red-500/25 dark:text-red-300`};function F({event:e,label:t,onClick:n}){return(0,N.jsx)(`button`,{type:`button`,"data-testid":`calendar-event-chip`,"data-variant":e.variant??`event`,title:e.title,onClick:e=>{e.stopPropagation(),n()},className:o(`w-full truncate rounded-md px-1.5 py-0.5 text-start text-[11px] leading-4 transition-colors`,P[e.variant??`event`],e.baseEventId&&`opacity-75`),children:t})}var I=3;function L({year:e,monthIndex:t,events:n,onDayClick:r,onEventClick:i}){let{t:s,i18n:c}=a(),l=(0,M.useMemo)(()=>O(e,t),[e,t]),u=new Date,d=(0,M.useMemo)(()=>{let e=new Map;for(let t of n){let n=new Date(t.startAt),r=`${n.getFullYear()}-${n.getMonth()}-${n.getDate()}`,i=e.get(r);i?i.push(t):e.set(r,[t])}return e},[n]),f=(0,M.useMemo)(()=>C(c.language),[c.language]);return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`calendar-month-grid`,children:[(0,N.jsx)(`div`,{className:`grid grid-cols-7 border-b border-black/[0.06] dark:border-white/[0.07]`,children:f.map(e=>(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-center text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:e},e))}),(0,N.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-7 grid-rows-6`,children:l.map(e=>{let n=e.getMonth()===t,a=w(e,u),l=`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`,f=d.get(l)??[],p=f.length-I;return(0,N.jsxs)(`div`,{role:`gridcell`,"data-testid":`calendar-day-cell`,onClick:()=>r(e),className:o(`flex min-h-0 cursor-pointer flex-col gap-0.5 border-b border-e border-black/[0.04] p-1 transition-colors hover:bg-black/[0.02] dark:border-white/[0.04] dark:hover:bg-white/[0.03]`,!n&&`opacity-40`),children:[(0,N.jsx)(`span`,{className:o(`flex h-6 w-6 items-center justify-center rounded-full text-[12px]`,a?`bg-primary-500 font-semibold text-white`:`text-gray-600 dark:text-dark-600`),children:e.getDate()}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-0.5 overflow-hidden`,children:[f.slice(0,I).map(e=>(0,N.jsx)(F,{event:e,label:e.allDay?e.title:`${k(e.startAt,c.language)} ${e.title}`,onClick:()=>i(e)},e.id)),p>0&&(0,N.jsx)(`span`,{className:`px-1 text-[10px] text-gray-400 dark:text-dark-500`,children:s(`calendar.more`,{n:p})})]})]},l)})})]})}var R=48;function ee({anchor:e,events:t,dayCount:n=7,onDayClick:r,onEventClick:i}){let{i18n:s}=a(),c=(0,M.useMemo)(()=>n===1?[new Date(e.getFullYear(),e.getMonth(),e.getDate())]:j(e),[e,n]),l=new Date,u=(0,M.useMemo)(()=>new Intl.DateTimeFormat(s.language,{hour:`numeric`}),[s.language]),d=(0,M.useMemo)(()=>new Intl.DateTimeFormat(s.language,{weekday:`short`,day:`numeric`}),[s.language]),f=e=>t.filter(t=>t.allDay&&w(new Date(t.startAt),e)),p=e=>t.filter(t=>!t.allDay&&w(new Date(t.startAt),e));return(0,N.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto scrollbar-thin`,"data-testid":`calendar-week-grid`,children:(0,N.jsxs)(`div`,{className:`grid grid-cols-[3.5rem_repeat(7,1fr)]`,children:[(0,N.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-black/[0.06] bg-surface dark:border-white/[0.07]`}),c.map(e=>(0,N.jsxs)(`div`,{className:`sticky top-0 z-10 border-b border-e border-black/[0.06] bg-surface px-1 py-1.5 dark:border-white/[0.07]`,children:[(0,N.jsx)(`span`,{className:o(`block truncate text-center text-[11px] font-medium`,w(e,l)?`text-primary-600 dark:text-primary-400`:`text-gray-500 dark:text-dark-500`),children:d.format(e)}),(0,N.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:f(e).map(e=>(0,N.jsx)(F,{event:e,label:e.title,onClick:()=>i(e)},e.id))})]},e.toISOString())),Array.from({length:24},(e,t)=>(0,N.jsxs)(M.Fragment,{children:[(0,N.jsx)(`div`,{className:`relative border-b border-black/[0.04] pe-1.5 text-end text-[10px] text-gray-400 dark:border-white/[0.04] dark:text-dark-500`,children:(0,N.jsx)(`span`,{className:`relative -top-1.5`,children:t>0?u.format(new Date(2024,0,1,t)):``})}),c.map(e=>{let n=p(e).filter(e=>new Date(e.startAt).getHours()===t);return(0,N.jsx)(`div`,{onClick:()=>r(e,t),style:{height:R},className:`cursor-pointer space-y-0.5 overflow-hidden border-b border-e border-black/[0.04] p-0.5 transition-colors hover:bg-black/[0.02] dark:border-white/[0.04] dark:hover:bg-white/[0.03]`,children:n.map(e=>(0,N.jsx)(F,{event:e,label:`${k(e.startAt,s.language)} ${e.title}`,onClick:()=>i(e)},e.id))},`${e.toISOString()}-${t}`)})]},t))]})})}var z=r(),B=e=>!e||e.kind===`once`||e.kind===`hourly`?`none`:e.kind,V=(e,t)=>{let n=new Date(t),r=n.getHours(),i=n.getMinutes();switch(e){case`daily`:return{kind:`daily`,hour:r,minute:i};case`weekly`:return{kind:`weekly`,dayOfWeek:n.getDay(),hour:r,minute:i};case`monthly`:return{kind:`monthly`,dayOfMonth:n.getDate(),hour:r,minute:i};case`yearly`:return{kind:`yearly`,month:n.getMonth()+1,dayOfMonth:n.getDate(),hour:r,minute:i};default:return null}},H=`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,U=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`;function te({open:e,event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s}){return e?(0,N.jsx)(W,{event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s},`${t?.id??`new`}:${n}`):null}function W({event:e,initialStartAt:t,calendars:n,saving:r,onClose:i,onSave:o,onDelete:s}){let{t:c}=a(),l=e?.startAt??t,[u,d]=(0,M.useState)(e?.title??``),[p,h]=(0,M.useState)(e?.notes??``),[g,_]=(0,M.useState)(S(l)),[v,y]=(0,M.useState)(e?T(l):`09:00`),[b,x]=(0,M.useState)(e?.endAt===void 0?``:T(e.endAt)),[C,w]=(0,M.useState)(e?.allDay??!1),[D,O]=(0,M.useState)(B(e?.recurrence)),[k,A]=(0,M.useState)(e?.calendarId??``),[j,P]=(0,M.useState)(e?.reminderMinutes===void 0?``:String(e.reminderMinutes)),F=()=>{if(!u.trim()||!g)return;let e=E(g,C?``:v),t=!C&&b?E(g,b):null;o({title:u.trim(),notes:p.trim()?p.trim():void 0,startAt:e,endAt:t!==null&&t>e?t:null,allDay:C,recurrence:V(D,e),calendarId:k||null,reminderMinutes:j?Number(j):null})},I=[{value:``,label:c(`calendar.reminderNone`)},{value:`5`,label:c(`calendar.reminderMinutes`,{minutes:5})},{value:`15`,label:c(`calendar.reminderMinutes`,{minutes:15})},{value:`30`,label:c(`calendar.reminderMinutes`,{minutes:30})},{value:`60`,label:c(`calendar.reminderHour`)},{value:`1440`,label:c(`calendar.reminderDay`)}],L=[{value:`none`,label:c(`calendar.repeatNone`)},{value:`daily`,label:c(`calendar.repeatDaily`)},{value:`weekly`,label:c(`calendar.repeatWeekly`)},{value:`monthly`,label:c(`calendar.repeatMonthly`)},{value:`yearly`,label:c(`calendar.repeatYearly`)}];return(0,z.createPortal)((0,N.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:i,children:(0,N.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`calendar-event-modal-title`,"data-testid":`calendar-event-modal`,className:`w-full max-w-md rounded-3xl border border-black/[0.07] bg-white p-6 shadow-[0_24px_80px_rgba(0,0,0,0.24)] animate-scale-in dark:border-white/[0.08] dark:bg-dark-25`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,N.jsx)(`h3`,{id:`calendar-event-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:c(e?`calendar.editEvent`:`calendar.newEvent`)}),(0,N.jsx)(`button`,{onClick:i,"aria-label":c(`common.close`),className:`rounded-xl p-2 transition-colors hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(f,{size:20,className:`text-gray-500`})})]}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-title`,className:U,children:c(`calendar.eventTitle`)}),(0,N.jsx)(`input`,{id:`calendar-event-title`,"data-testid":`calendar-event-title`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:c(`calendar.titlePlaceholder`),className:H,maxLength:200,autoFocus:!0})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-date`,className:U,children:c(`calendar.date`)}),(0,N.jsx)(`input`,{id:`calendar-event-date`,type:`date`,value:g,onChange:e=>_(e.target.value),className:H})]}),(0,N.jsx)(`div`,{className:`flex items-end pb-1.5`,children:(0,N.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] text-gray-700 dark:text-dark-700`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),className:`h-4 w-4 rounded accent-primary-500`}),c(`calendar.allDay`)]})})]}),!C&&(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-start`,className:U,children:c(`calendar.start`)}),(0,N.jsx)(`input`,{id:`calendar-event-start`,type:`time`,value:v,onChange:e=>y(e.target.value),className:H})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-end`,className:U,children:c(`calendar.end`)}),(0,N.jsx)(`input`,{id:`calendar-event-end`,type:`time`,value:b,onChange:e=>x(e.target.value),className:H})]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-repeat`,className:U,children:c(`calendar.repeat`)}),(0,N.jsx)(`select`,{id:`calendar-event-repeat`,value:D,onChange:e=>O(e.target.value),className:H,children:L.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-notes`,className:U,children:c(`calendar.notes`)}),(0,N.jsx)(`textarea`,{id:`calendar-event-notes`,value:p,onChange:e=>h(e.target.value),rows:3,className:H,maxLength:1e4})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:U,children:c(`calendar.calendarLabel`)}),(0,N.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),className:H,"data-testid":`calendar-event-calendar`,children:[(0,N.jsx)(`option`,{value:``,children:c(`calendar.personalCalendar`)}),n.map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:U,children:c(`calendar.reminderLabel`)}),(0,N.jsx)(`select`,{value:j,onChange:e=>P(e.target.value),className:H,"data-testid":`calendar-event-reminder`,children:I.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-200 pt-4 dark:border-dark-300`,children:[e&&s?(0,N.jsxs)(`button`,{onClick:s,"data-testid":`calendar-event-delete`,className:`flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:[(0,N.jsx)(m,{className:`h-4 w-4`}),c(`common.delete`)]}):(0,N.jsx)(`span`,{}),(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsx)(`button`,{onClick:i,className:`rounded-xl px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:text-dark-700 dark:hover:bg-dark-200`,children:c(`common.cancel`)}),(0,N.jsx)(`button`,{onClick:F,disabled:r||!u.trim(),"data-testid":`calendar-event-save`,className:`rounded-xl bg-gray-950 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,children:c(r?`common.saving`:`common.save`)})]})]})]})]})}),document.body)}var G=g(`pages:calendar`),K=()=>{let{t:e,i18n:t}=a(),n=i(),[r,m]=(0,M.useState)(`month`),[g,S]=(0,M.useState)(()=>new Date),[C,w]=(0,M.useState)([]),[T,E]=(0,M.useState)([]),[O,k]=(0,M.useState)(!1),[j,P]=(0,M.useState)(null),[F,I]=(0,M.useState)(()=>Date.now()),[R,z]=(0,M.useState)(!1),[B,V]=(0,M.useState)([]),[H,U]=(0,M.useState)(``),[W,K]=(0,M.useState)(null),q=M.useRef(null),J=(0,M.useMemo)(()=>{if(r===`month`){let e=new Date(g.getFullYear(),g.getMonth(),1),t=D(e);return{from:t.getTime(),to:A(t,42).getTime()}}if(r===`day`){let e=new Date(g.getFullYear(),g.getMonth(),g.getDate());return{from:e.getTime(),to:A(e,1).getTime()}}let e=D(g);return{from:e.getTime(),to:A(e,7).getTime()}},[g,r]),[Y,ne]=(0,M.useState)(0),X=(0,M.useCallback)(()=>ne(e=>e+1),[]);(0,M.useEffect)(()=>{_.getCalendars().then(e=>{e.success&&e.data&&V(e.data)}).catch(e=>G.error(`Failed to load calendars:`,e))},[Y]),(0,M.useEffect)(()=>{let t=!1;return _.getEvents(J.from,J.to).then(e=>{t||e.success&&e.data&&w(e.data)}).catch(n=>{t||(G.error(`Failed to load calendar events:`,n),h.error(e(`calendar.loadFailed`)))}),Promise.all([v.getOccurrences(J.from,J.to),v.getRuns({from:J.from,to:J.to}),v.getAutomations()]).then(([n,r,i])=>{if(t)return;let a=Date.now(),o=t=>i.data?.find(e=>e.id===t)?.name??e(`automations.deletedAutomation`),s=[];for(let e of n.data??[])e.at<=a||s.push({id:`automation:${e.automationId}:${e.at}`,title:e.name,startAt:e.at,allDay:!1,createdAt:e.at,updatedAt:e.at,variant:`automation`});for(let e of r.data??[])(e.status===`succeeded`||e.status===`failed`)&&s.push({id:`run:${e.id}`,title:o(e.automationId),startAt:e.scheduledFor,allDay:!1,createdAt:e.createdAt,updatedAt:e.createdAt,variant:e.status===`succeeded`?`runSucceeded`:`runFailed`,...e.sessionId?{sessionId:e.sessionId}:{}});E(s)}).catch(e=>{t||G.error(`Failed to project automations onto the calendar:`,e)}),()=>{t=!0}},[J.from,J.to,Y,e]);let Z=(0,M.useMemo)(()=>[...C,...T].sort((e,t)=>e.startAt-t.startAt),[C,T]),Q=e=>{S(t=>r===`month`?new Date(t.getFullYear(),t.getMonth()+e,1):A(t,e*(r===`day`?1:7)))},$=(e,t=9)=>{P(null),I(new Date(e.getFullYear(),e.getMonth(),e.getDate(),t,0).getTime()),k(!0)},re=t=>{if(t.variant===`runSucceeded`||t.variant===`runFailed`){t.sessionId?n(`/c/${t.sessionId}`):n(`/automations`);return}if(t.variant===`automation`){n(`/automations`);return}if(t.shared&&t.shared.permission!==`write`){h(e(`calendar.sharedReadOnly`));return}if(t.baseEventId){let e=C.find(e=>e.id===t.baseEventId);P(e??t)}else P(t);k(!0)},ie=async t=>{z(!0);try{let n=j?await _.updateEvent(j.id,t):await _.createEvent(t);n.success?(k(!1),X()):h.error(n.error||e(`calendar.saveFailed`))}catch(t){G.error(`Failed to save calendar event:`,t),h.error(e(`calendar.saveFailed`))}finally{z(!1)}},ae=async()=>{if(j){z(!0);try{let t=await _.deleteEvent(j.id);t.success?(k(!1),X()):h.error(t.error||e(`calendar.deleteFailed`))}catch(t){G.error(`Failed to delete calendar event:`,t),h.error(e(`calendar.deleteFailed`))}finally{z(!1)}}},oe=r===`month`?x(g.getFullYear(),g.getMonth(),t.language):new Intl.DateTimeFormat(t.language,{month:`long`,day:`numeric`,year:`numeric`}).format(r===`day`?g:D(g)),se=async()=>{let t=H.trim();t&&((await _.createCalendar({name:t}).catch(()=>void 0))?.success?(U(``),X()):h.error(e(`calendar.calendarSaveFailed`)))},ce=async t=>{try{let e=await _.exportIcs(t),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`calendar.ics`,r.click(),URL.revokeObjectURL(n)}catch(t){G.error(`Failed to export the calendar:`,t),h.error(e(`calendar.exportFailed`))}},le=async t=>{try{let n=await t.text(),r=await _.importIcs(n);r.success&&r.data?(h.success(e(`calendar.importResult`,{total:r.data.imported})),X()):h.error(r.error||e(`calendar.importFailed`))}catch(t){G.error(`Failed to import the calendar:`,t),h.error(e(`calendar.importFailed`))}};return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`calendar-page`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-black/[0.06] px-4 py-3 dark:border-white/[0.07]`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`calendar.title`)}),(0,N.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-dark-500`,"data-testid":`calendar-range-label`,children:oe})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`flex items-center rounded-xl bg-black/[0.04] p-0.5 dark:bg-white/[0.06]`,children:[`month`,`week`,`day`].map(t=>(0,N.jsx)(`button`,{onClick:()=>m(t),"data-testid":`calendar-view-${t}`,className:o(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors`,r===t?`bg-white text-gray-900 shadow-sm dark:bg-dark-200 dark:text-dark-900`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),children:e(`calendar.${t}`)},t))}),(0,N.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>Q(-1),className:`h-7 w-7 p-0`,title:e(`calendar.previous`),children:(0,N.jsx)(c,{className:`h-4 w-4`})}),(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>S(new Date),className:`h-7 px-2 text-[12px]`,children:e(`calendar.today`)}),(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>Q(1),className:`h-7 w-7 p-0`,title:e(`calendar.next`),children:(0,N.jsx)(d,{className:`h-4 w-4`})})]}),(0,N.jsxs)(y,{size:`sm`,onClick:()=>$(g),"data-testid":`calendar-new-event`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,N.jsx)(l,{className:`h-3.5 w-3.5`}),e(`calendar.newEvent`)]})]})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-black/[0.06] px-4 py-2 dark:border-white/[0.07]`,children:[B.map(t=>(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-black/[0.08] px-2.5 py-1 text-xs text-gray-700 dark:border-white/[0.1] dark:text-dark-800`,"data-testid":`calendar-chip`,children:[(0,N.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:t.color??`#8b8b8b`}}),t.name,t.shared?(0,N.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:e(`calendar.sharedBadge`)}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{onClick:()=>K(t),className:`text-gray-400 hover:text-primary-500 dark:text-dark-500`,title:e(`calendar.shareCalendar`),"data-testid":`calendar-share`,children:(0,N.jsx)(u,{className:`h-3 w-3`})}),(0,N.jsx)(`button`,{onClick:()=>void _.deleteCalendar(t.id).then(X),className:`text-gray-400 hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,N.jsx)(f,{className:`h-3 w-3`})})]})]},t.id)),(0,N.jsx)(`input`,{type:`text`,value:H,onChange:e=>U(e.target.value),onKeyDown:e=>{e.key===`Enter`&&se()},placeholder:e(`calendar.newCalendarPlaceholder`),className:`w-36 rounded-full border border-dashed border-black/[0.12] bg-transparent px-2.5 py-1 text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:border-white/[0.16] dark:text-dark-800`,"data-testid":`calendar-new-calendar`}),(0,N.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,N.jsx)(`input`,{ref:q,type:`file`,accept:`.ics,text/calendar`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&le(t),e.target.value=``}}),(0,N.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>q.current?.click(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-import`,children:[(0,N.jsx)(p,{className:`h-3.5 w-3.5`}),e(`calendar.importIcs`)]}),(0,N.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>void ce(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-export`,children:[(0,N.jsx)(s,{className:`h-3.5 w-3.5`}),e(`calendar.exportIcs`)]})]})]}),r===`month`?(0,N.jsx)(L,{year:g.getFullYear(),monthIndex:g.getMonth(),events:Z,onDayClick:e=>$(e),onEventClick:re}):(0,N.jsx)(ee,{anchor:g,events:Z,dayCount:r===`day`?1:7,onDayClick:(e,t)=>$(e,t),onEventClick:re}),W&&(0,N.jsx)(b,{resourceType:`calendar`,resourceId:W.id,resourceLabel:W.name,onClose:()=>K(null)}),(0,N.jsx)(te,{open:O,event:j,initialStartAt:F,calendars:B.filter(e=>!e.shared||e.shared.permission===`write`),saving:R,onClose:()=>k(!1),onSave:e=>void ie(e),onDelete:()=>void ae()})]})};export{K as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{i as r}from"./router-vendor-CIwPu612.js";import{t as i}from"./useTranslation-C7GwbUQA.js";import{r as a,t as o}from"./utils-nNyg0lfc.js";import{t as s}from"./chatStore-Dpm3g_Ln.js";import{B as c,Et as l,Gt as u,H as d,Nt as f,On as p,Q as m,Tt as ee,_n as te,fr as ne,ir as re,it as ie,jt as h,n as g,nt as ae,qn as _,s as v,st as y,v as oe,yr as b}from"./ui-vendor-CPdYrKhz.js";import{t as se}from"./logger-CpCQz3Vi.js";import{D as x}from"./api-D-5hpGht.js";import{t as ce}from"./authStore-Ckz37pwu.js";import{t as S}from"./Button-CgN11mgY.js";import{i as C,n as w,r as T}from"./ui-BK53RPmS.js";import{t as le}from"./teamEventStream-DUodK0-C.js";var E=e(t(),1),D=n(),O=[`👍`,`🎉`,`❤️`,`😄`,`👀`,`🚀`],k=({message:e,currentUserId:t,canModerate:n,actions:r,compact:s=!1})=>{let{t:c,i18n:l}=i(),[u,d]=(0,E.useState)(!1),[p,m]=(0,E.useState)(e.content),[ne,h]=(0,E.useState)(!1),v=e.authorKind===`model`,b=!v&&e.author?.userId===t&&!e.deleted,se=v?e.model??c(`channels.modelAuthor`):e.author?.username??c(`channels.unknownAuthor`);return(0,D.jsxs)(`div`,{className:o(`group relative rounded-xl px-2.5 py-1.5 hover:bg-black/[0.025] dark:hover:bg-white/[0.03]`,s&&`px-2 py-1`),"data-testid":`channel-message`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[v&&(0,D.jsx)(re,{className:`h-3.5 w-3.5 shrink-0 self-center text-primary-500`}),(0,D.jsx)(`span`,{className:o(`shrink-0 text-[13px] font-semibold`,v?`text-primary-600 dark:text-primary-400`:`text-gray-900 dark:text-dark-900`),children:se}),(0,D.jsx)(`span`,{className:`shrink-0 text-[11px] text-gray-400 dark:text-dark-500`,children:a(e.createdAt,l.language)}),e.editedAt&&!e.deleted&&(0,D.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400 dark:text-dark-500`,children:c(`channels.edited`)}),e.pinnedAt&&(0,D.jsx)(ae,{className:`h-3 w-3 shrink-0 text-amber-500`})]}),e.deleted?(0,D.jsx)(`p`,{className:`text-[13px] italic text-gray-400 dark:text-dark-500`,children:c(`channels.deletedMessage`)}):u?(0,D.jsxs)(`div`,{className:`mt-1 flex items-end gap-1.5`,children:[(0,D.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:2,className:`min-w-0 flex-1 resize-none rounded-lg border border-black/[0.08] bg-transparent px-2 py-1 text-[13px] focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`channel-message-edit`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>{r.onEdit(e,p),d(!1)},className:`rounded-md p-1.5 text-emerald-600 hover:bg-emerald-50 dark:hover:bg-emerald-900/20`,children:(0,D.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>d(!1),className:`rounded-md p-1.5 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,D.jsx)(g,{className:`h-3.5 w-3.5`})})]}):(0,D.jsxs)(D.Fragment,{children:[e.pending?(0,D.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[13px] text-gray-400 dark:text-dark-500`,children:[(0,D.jsx)(f,{className:`h-3.5 w-3.5 animate-spin`}),c(`channels.modelThinking`)]}):e.error?(0,D.jsx)(`p`,{className:`text-[13px] text-red-500`,children:e.error}):(0,D.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-[13px] leading-relaxed text-gray-800 dark:text-dark-800`,children:e.content}),(e.attachments?.length??0)>0&&(0,D.jsx)(`div`,{className:`mt-1 space-y-1`,children:e.attachments.map(e=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void r.onDownload(e.id,e.filename),className:`flex items-center gap-1.5 rounded-lg border border-black/[0.06] px-2 py-1 text-[12px] text-gray-600 hover:bg-black/[0.03] dark:border-white/[0.08] dark:text-dark-700 dark:hover:bg-white/[0.04]`,"data-testid":`channel-attachment`,children:[(0,D.jsx)(y,{className:`h-3 w-3`}),(0,D.jsx)(`span`,{className:`min-w-0 truncate`,children:e.filename})]},e.id))})]}),(e.reactions?.length??0)>0&&(0,D.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.reactions.map(t=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void r.onReact(e,t.emoji,t.mine),className:o(`rounded-full border px-1.5 py-0.5 text-[11px]`,t.mine?`border-primary-400/50 bg-primary-500/10 text-primary-600 dark:text-primary-400`:`border-black/[0.08] text-gray-600 hover:bg-black/[0.03] dark:border-white/[0.1] dark:text-dark-700`),"data-testid":`channel-reaction`,children:[t.emoji,` `,t.count]},t.emoji))}),!s&&(e.replyCount??0)>0&&r.onReply&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>r.onReply(e),className:`mt-1 flex items-center gap-1 text-[11px] font-medium text-primary-600 hover:underline dark:text-primary-400`,"data-testid":`channel-reply-count`,children:[(0,D.jsx)(ee,{className:`h-3 w-3`}),c(`channels.replyCount`,{total:e.replyCount})]}),!e.deleted&&!u&&(0,D.jsxs)(`div`,{className:`absolute -top-2.5 right-2 hidden items-center gap-0.5 rounded-lg border border-black/[0.08] bg-white px-1 py-0.5 shadow-sm group-hover:flex dark:border-white/[0.1] dark:bg-dark-50`,children:[(0,D.jsxs)(`div`,{className:`relative`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:c(`channels.react`),"data-testid":`channel-react`,children:(0,D.jsx)(te,{className:`h-3.5 w-3.5`})}),ne&&(0,D.jsx)(`div`,{className:`absolute right-0 top-6 z-10 flex gap-0.5 rounded-lg border border-black/[0.08] bg-white p-1 shadow-md dark:border-white/[0.1] dark:bg-dark-50`,children:O.map(t=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>{let n=!!e.reactions?.find(e=>e.emoji===t)?.mine;r.onReact(e,t,n),h(!1)},className:`rounded p-0.5 text-sm hover:bg-black/[0.05] dark:hover:bg-white/[0.08]`,children:t},t))})]}),r.onReply&&!e.parentId&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>r.onReply(e),className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:c(`channels.reply`),"data-testid":`channel-reply`,children:(0,D.jsx)(ee,{className:`h-3.5 w-3.5`})}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>void r.onPin(e),className:`rounded p-1 text-gray-400 hover:text-amber-500`,title:e.pinnedAt?c(`channels.unpin`):c(`channels.pin`),"data-testid":`channel-pin`,children:(0,D.jsx)(ae,{className:`h-3.5 w-3.5`})}),b&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>{m(e.content),d(!0)},className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:c(`channels.edit`),"data-testid":`channel-edit`,children:(0,D.jsx)(ie,{className:`h-3.5 w-3.5`})}),(b||n)&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>void r.onDelete(e),className:`rounded p-1 text-gray-400 hover:text-red-500`,title:c(`channels.deleteMessage`),"data-testid":`channel-delete-message`,children:(0,D.jsx)(oe,{className:`h-3.5 w-3.5`})})]})]})},A=se(`pages:channels`),ue=e=>e.type===`dm`?(0,D.jsx)(l,{className:`h-3.5 w-3.5 shrink-0`}):e.type===`private`?(0,D.jsx)(h,{className:`h-3.5 w-3.5 shrink-0`}):(0,D.jsx)(u,{className:`h-3.5 w-3.5 shrink-0`}),de=e=>e.type===`dm`?e.dmPeer?.username??`…`:e.name,fe=()=>{let{t:e}=i(),t=ce(e=>e.user),n=s(e=>e.models),[a,u]=(0,E.useState)([]),[te,ie]=(0,E.useState)(null),[h,_]=(0,E.useState)(!1),[oe,se]=(0,E.useState)(!0),[C,w]=(0,E.useState)(null),[T,O]=(0,E.useState)(null),[fe,j]=(0,E.useState)([]),[_e,ve]=(0,E.useState)([]),[M,N]=(0,E.useState)(null),[P,F]=(0,E.useState)(null),[ye,I]=(0,E.useState)([]),[L,R]=(0,E.useState)(``),[z,be]=(0,E.useState)(``),[B,xe]=(0,E.useState)(!1),[V,H]=(0,E.useState)(null),[Se,U]=(0,E.useState)(!1),[Ce,we]=(0,E.useState)(!1),[W,Te]=(0,E.useState)(``),[Ee,G]=(0,E.useState)(!1),De=(0,E.useRef)(null),Oe=(0,E.useRef)(null),[ke,Ae]=r(),K=(0,E.useMemo)(()=>a.find(e=>e.id===C)??null,[a,C]),[je,Me]=(0,E.useState)(null);C!==je&&(Me(C),O(null),F(null),N(null));let q=K?.role===`owner`,J=(0,E.useCallback)(()=>{x.listMine().then(e=>{e.success&&e.data&&u(e.data)}).catch(e=>A.error(`Failed to load channels:`,e)).finally(()=>se(!1))},[]);(0,E.useEffect)(()=>{J();let e=window.setInterval(J,3e4);return()=>window.clearInterval(e)},[J]);let Y=ke.get(`channel`);Y&&C!==Y&&w(Y),(0,E.useEffect)(()=>{Y&&Ae({},{replace:!0})},[Y,Ae]);let X=(0,E.useCallback)(e=>{x.listMessages(e,{limit:100}).then(e=>{e.success&&e.data&&O(e.data)}).catch(e=>A.error(`Failed to load messages:`,e))},[]),Ne=(0,E.useRef)(null);(0,E.useEffect)(()=>{Ne.current=P},[P]);let Pe=(0,E.useCallback)(e=>{X(e),x.markRead(e);let t=Ne.current;t&&x.thread(t).then(e=>{e.success&&e.data&&I(e.data)})},[X]);(0,E.useEffect)(()=>{if(!C)return;X(C),x.markRead(C).then(J);let e=new AbortController;return le({path:`/channels/${C}/events`,signal:e.signal,onEvent:()=>Pe(C)}),()=>e.abort()},[C,X,J,Pe]);let Fe=T?.length??0;(0,E.useEffect)(()=>{let e=Oe.current;e&&(e.scrollTop=e.scrollHeight)},[Fe,C]),(0,E.useEffect)(()=>{!C||!M||(M===`members`?x.listMembers(C).then(e=>{e.success&&e.data&&j(e.data)}):x.listPins(C).then(e=>{e.success&&e.data&&ve(e.data)}))},[C,M]),(0,E.useEffect)(()=>{P&&x.thread(P).then(e=>{e.success&&e.data&&I(e.data)})},[P]);let Ie=()=>{_(!0),x.listPublic().then(e=>{e.success&&e.data&&ie(e.data)})},Z=async t=>{if(!C||B)return;let n=L.trim();if(!(!n&&!V)){xe(!0);try{let r=await x.postMessage(C,{content:n,...t?{parentId:t}:{},...V?{attachmentIds:[V.id]}:{},...z?{mentionModel:z}:{}});if(r.success){if(R(``),H(null),be(``),X(C),t){let e=await x.thread(t);e.success&&e.data&&I(e.data)}}else b.error(r.error||e(`channels.sendFailed`))}catch(t){A.error(`Failed to send message:`,t),b.error(e(`channels.sendFailed`))}finally{xe(!1)}}},Le=async t=>{if(C)try{let n=await x.uploadAttachment(C,t);n.success&&n.data?H({id:n.data.id,filename:n.data.filename}):b.error(n.error||e(`channels.uploadFailed`))}catch(t){A.error(`Failed to upload attachment:`,t),b.error(e(`channels.uploadFailed`))}},Re=async()=>{if(!(!C||!W.trim())){if((await x.addMember(C,W.trim()).catch(()=>void 0))?.success){Te(``);let t=await x.listMembers(C);t.success&&t.data&&j(t.data),b.success(e(`channels.memberAdded`))}else b.error(e(`channels.memberAddFailed`))}},Q={onReply:e=>F(e.id),onEdit:async(e,t)=>{(await x.editMessage(e.id,t).catch(()=>void 0))?.success&&C&&X(C)},onDelete:async e=>{(await x.deleteMessage(e.id).catch(()=>void 0))?.success&&C&&X(C)},onPin:async e=>{await x.setPinned(e.id,!e.pinnedAt).catch(()=>void 0),C&&X(C)},onReact:async(e,t,n)=>{n?await x.removeReaction(e.id,t).catch(()=>void 0):await x.addReaction(e.id,t).catch(()=>void 0),C&&X(C)},onDownload:async(e,t)=>{try{let n=await x.downloadAttachment(e),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}catch(e){A.error(`Failed to download attachment:`,e)}}},$=ye[0];return(0,D.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,D.jsxs)(`aside`,{className:o(`flex w-64 shrink-0 flex-col border-r border-black/[0.06] dark:border-white/[0.06]`,C?`hidden md:flex`:`flex`),"data-testid":`channel-rail`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-2.5`,children:[(0,D.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`channels.title`)}),(0,D.jsx)(`button`,{type:`button`,onClick:Ie,title:e(`channels.browsePublic`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channels-browse`,children:(0,D.jsx)(p,{className:`h-4 w-4`})}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>we(!0),title:e(`channels.newDm`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channels-new-dm`,children:(0,D.jsx)(l,{className:`h-4 w-4`})}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>U(!0),title:e(`channels.newChannel`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channels-new`,children:(0,D.jsx)(m,{className:`h-4 w-4`})})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:oe?(0,D.jsx)(f,{className:`mx-auto mt-6 h-4 w-4 animate-spin text-gray-400`}):a.length===0?(0,D.jsx)(`p`,{className:`px-2 pt-6 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.empty`)}):a.map(e=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),className:o(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px]`,C===e.id?`bg-black/[0.05] text-gray-900 dark:bg-white/[0.08] dark:text-dark-900`:`text-gray-600 hover:bg-black/[0.03] dark:text-dark-700 dark:hover:bg-white/[0.04]`),"data-testid":`channel-item`,children:[ue(e),(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:de(e)}),(e.unreadCount??0)>0&&(0,D.jsx)(`span`,{className:`rounded-full bg-primary-500 px-1.5 text-[10px] font-semibold leading-4 text-white`,"data-testid":`channel-unread`,children:e.unreadCount})]},e.id))})]}),(0,D.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:K?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-4 py-2.5 dark:border-white/[0.06]`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`rounded-md p-1 text-gray-500 hover:bg-black/[0.04] md:hidden dark:text-dark-600`,children:(0,D.jsx)(ne,{className:`h-4 w-4`})}),ue(K),(0,D.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,"data-testid":`channel-title`,children:de(K)}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>N(M===`pins`?null:`pins`),title:e(`channels.pins`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-pins-toggle`,children:(0,D.jsx)(ae,{className:`h-4 w-4`})}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>N(M===`members`?null:`members`),title:e(`channels.members`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-members-toggle`,children:(0,D.jsx)(v,{className:`h-4 w-4`})}),q&&K.type!==`dm`&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>G(!0),title:e(`channels.settings`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-settings`,children:(0,D.jsx)(c,{className:`h-4 w-4`})})]}),(0,D.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,D.jsx)(`div`,{ref:Oe,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-4 py-3 scrollbar-thin`,"data-testid":`channel-timeline`,children:T===null?(0,D.jsx)(f,{className:`mx-auto mt-6 h-4 w-4 animate-spin text-gray-400`}):T.length===0?(0,D.jsx)(`p`,{className:`pt-8 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.noMessages`)}):T.map(e=>(0,D.jsx)(k,{message:e,currentUserId:t?.id,canModerate:q,actions:Q},e.id))}),(0,D.jsxs)(`div`,{className:`border-t border-black/[0.06] p-3 dark:border-white/[0.06]`,children:[V&&(0,D.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-lg border border-black/[0.06] px-2.5 py-1.5 text-xs text-gray-600 dark:border-white/[0.08] dark:text-dark-700`,children:[(0,D.jsx)(y,{className:`h-3.5 w-3.5`}),(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:V.filename}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>H(null),className:`text-gray-400 hover:text-red-500`,children:(0,D.jsx)(g,{className:`h-3.5 w-3.5`})})]}),(0,D.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,D.jsx)(`input`,{ref:De,type:`file`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&Le(t),e.target.value=``}}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>De.current?.click(),title:e(`channels.attach`),className:`rounded-md p-2 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-attach`,children:(0,D.jsx)(y,{className:`h-4 w-4`})}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(re,{className:o(`h-4 w-4`,z?`text-primary-500`:`text-gray-400 dark:text-dark-500`)}),(0,D.jsxs)(`select`,{value:z,onChange:e=>be(e.target.value),className:`max-w-[130px] rounded-md border border-black/[0.08] bg-transparent px-1 py-1 text-[11px] text-gray-600 focus:outline-none dark:border-white/[0.1] dark:bg-dark-100 dark:text-dark-700`,title:e(`channels.askModel`),"data-testid":`channel-mention-model`,children:[(0,D.jsx)(`option`,{value:``,children:e(`channels.noModel`)}),n.map(e=>(0,D.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,D.jsx)(`textarea`,{value:L,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Z())},rows:1,placeholder:e(`channels.composerPlaceholder`),className:`max-h-32 min-w-0 flex-1 resize-none rounded-xl border border-black/[0.08] bg-transparent px-3 py-2 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`channel-composer`}),(0,D.jsx)(S,{size:`sm`,disabled:B||!L.trim()&&!V,onClick:()=>void Z(),"data-testid":`channel-send`,children:B?(0,D.jsx)(f,{className:`h-4 w-4 animate-spin`}):(0,D.jsx)(d,{className:`h-4 w-4`})})]})]})]}),P&&(0,D.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col border-l border-black/[0.06] dark:border-white/[0.06]`,"data-testid":`channel-thread`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-3 py-2 dark:border-white/[0.06]`,children:[(0,D.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(`channels.thread`)}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>F(null),className:`rounded-md p-1 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,D.jsx)(g,{className:`h-3.5 w-3.5`})})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3 py-2 scrollbar-thin`,children:ye.map(e=>(0,D.jsx)(k,{message:e,currentUserId:t?.id,canModerate:q,actions:{...Q,onReply:void 0},compact:!0},e.id))}),(0,D.jsxs)(`div`,{className:`flex items-end gap-1.5 border-t border-black/[0.06] p-2 dark:border-white/[0.06]`,children:[(0,D.jsx)(`textarea`,{value:L,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),$&&Z($.id))},rows:1,placeholder:e(`channels.replyPlaceholder`),className:`min-w-0 flex-1 resize-none rounded-lg border border-black/[0.08] bg-transparent px-2.5 py-1.5 text-[13px] text-gray-900 focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`channel-thread-composer`}),(0,D.jsx)(S,{size:`sm`,disabled:B||!L.trim(),onClick:()=>$&&void Z($.id),children:(0,D.jsx)(d,{className:`h-3.5 w-3.5`})})]})]}),M&&(0,D.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-black/[0.06] dark:border-white/[0.06]`,"data-testid":`channel-${M}-panel`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-3 py-2 dark:border-white/[0.06]`,children:[(0,D.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(M===`members`?`channels.members`:`channels.pins`)}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>N(null),className:`rounded-md p-1 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,D.jsx)(g,{className:`h-3.5 w-3.5`})})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto px-3 py-2 scrollbar-thin`,children:M===`members`?(0,D.jsxs)(D.Fragment,{children:[q&&K.type===`private`&&(0,D.jsxs)(`div`,{className:`mb-2 flex gap-1.5`,children:[(0,D.jsx)(`input`,{type:`text`,value:W,onChange:e=>Te(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Re()},placeholder:e(`channels.invitePlaceholder`),className:`min-w-0 flex-1 rounded-lg border border-black/[0.08] bg-transparent px-2 py-1 text-xs focus:outline-none dark:border-white/[0.1] dark:text-dark-800`,"data-testid":`channel-invite-name`}),(0,D.jsx)(S,{size:`sm`,disabled:!W.trim(),onClick:()=>void Re(),"data-testid":`channel-invite-submit`,children:(0,D.jsx)(m,{className:`h-3.5 w-3.5`})})]}),fe.map(n=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] text-gray-700 dark:text-dark-800`,"data-testid":`channel-member`,children:[(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.username}),(0,D.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:n.role===`owner`?e(`channels.roleOwner`):``}),q&&n.userId!==t?.id&&K.type!==`dm`&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>void x.removeMember(K.id,n.userId).then(()=>j(e=>e.filter(e=>e.userId!==n.userId))),className:`rounded p-0.5 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,title:e(`channels.removeMember`),children:(0,D.jsx)(g,{className:`h-3 w-3`})})]},n.userId)),!q&&K.type!==`dm`&&(0,D.jsx)(S,{size:`sm`,variant:`ghost`,className:`mt-2 w-full text-red-500`,onClick:()=>void x.removeMember(K.id,t?.id??``).then(()=>{w(null),J()}),"data-testid":`channel-leave`,children:e(`channels.leave`)})]}):_e.length===0?(0,D.jsx)(`p`,{className:`pt-4 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.noPins`)}):_e.map(e=>(0,D.jsx)(k,{message:e,currentUserId:t?.id,canModerate:q,actions:Q,compact:!0},e.id))})]})]})]}):(0,D.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 text-gray-400 dark:text-dark-500`,children:[(0,D.jsx)(ee,{className:`h-8 w-8`}),(0,D.jsx)(`p`,{className:`text-sm`,children:e(`channels.selectPrompt`)})]})}),Se&&(0,D.jsx)(pe,{onClose:()=>U(!1),onCreated:e=>{U(!1),J(),w(e.id)}}),Ce&&(0,D.jsx)(me,{onClose:()=>we(!1),onOpened:e=>{we(!1),J(),w(e.id)}}),h&&(0,D.jsx)(he,{channels:te,onClose:()=>_(!1),onJoined:e=>{_(!1),J(),w(e)}}),Ee&&K&&(0,D.jsx)(ge,{channel:K,onClose:()=>G(!1),onChanged:()=>{G(!1),J()},onDeleted:()=>{G(!1),w(null),J()}})]})},pe=({onClose:e,onCreated:t})=>{let{t:n}=i(),[r,a]=(0,E.useState)(``),[o,s]=(0,E.useState)(`public`),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)(!1);return(0,D.jsxs)(w,{titleId:`create-channel-title`,title:n(`channels.newChannel`),onClose:e,testId:`create-channel-modal`,footer:(0,D.jsx)(S,{size:`sm`,disabled:u||!r.trim(),onClick:()=>{d(!0),x.create({type:o,name:r.trim(),...c.trim()?{description:c.trim()}:{}}).then(e=>{e.success&&e.data?t(e.data):b.error(e.error||n(`channels.createFailed`))}).catch(()=>b.error(n(`channels.createFailed`))).finally(()=>d(!1))},"data-testid":`create-channel-submit`,children:n(`channels.create`)}),children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:C,children:n(`channels.nameLabel`)}),(0,D.jsx)(`input`,{className:T,value:r,onChange:e=>a(e.target.value),"data-testid":`create-channel-name`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:C,children:n(`channels.typeLabel`)}),(0,D.jsxs)(`select`,{className:T,value:o,onChange:e=>s(e.target.value),"data-testid":`create-channel-type`,children:[(0,D.jsx)(`option`,{value:`public`,children:n(`channels.typePublic`)}),(0,D.jsx)(`option`,{value:`private`,children:n(`channels.typePrivate`)})]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:C,children:n(`channels.descriptionLabel`)}),(0,D.jsx)(`textarea`,{className:T,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})},me=({onClose:e,onOpened:t})=>{let{t:n}=i(),[r,a]=(0,E.useState)(``),[o,s]=(0,E.useState)(!1),c=()=>{r.trim()&&(s(!0),x.openDm(r.trim()).then(e=>{e.success&&e.data?t(e.data):b.error(e.error||n(`channels.dmFailed`))}).catch(()=>b.error(n(`channels.dmFailed`))).finally(()=>s(!1)))};return(0,D.jsx)(w,{titleId:`open-dm-title`,title:n(`channels.newDm`),subtitle:n(`channels.dmHint`),onClose:e,testId:`open-dm-modal`,footer:(0,D.jsx)(S,{size:`sm`,disabled:o||!r.trim(),onClick:c,"data-testid":`open-dm-submit`,children:n(`channels.openDm`)}),children:(0,D.jsx)(`input`,{className:T,value:r,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},placeholder:n(`channels.dmPlaceholder`),"data-testid":`open-dm-username`})})},he=({channels:e,onClose:t,onJoined:n})=>{let{t:r}=i();return(0,D.jsx)(w,{titleId:`browse-channels-title`,title:r(`channels.browsePublic`),onClose:t,testId:`browse-channels-modal`,children:e===null?(0,D.jsx)(f,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):e.length===0?(0,D.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:r(`channels.noPublic`)}):e.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-black/[0.06] px-3 py-2 dark:border-white/[0.08]`,"data-testid":`browse-channel-item`,children:[(0,D.jsx)(u,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.name}),e.isMember?(0,D.jsx)(`span`,{className:`text-[11px] text-gray-400`,children:r(`channels.joined`)}):(0,D.jsx)(S,{size:`sm`,onClick:()=>void x.join(e.id).then(()=>n(e.id)),"data-testid":`browse-channel-join`,children:r(`channels.join`)})]},e.id))})},ge=({channel:e,onClose:t,onChanged:n,onDeleted:r})=>{let{t:a}=i(),[o,s]=(0,E.useState)(e.name),[c,l]=(0,E.useState)(e.description??``),[u,d]=(0,E.useState)(!1);return(0,D.jsxs)(w,{titleId:`channel-settings-title`,title:a(`channels.settings`),onClose:t,testId:`channel-settings-modal`,footer:(0,D.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,D.jsx)(S,{size:`sm`,variant:`ghost`,className:`text-red-500`,onClick:()=>void x.delete(e.id).then(e=>{e.success&&r()}),"data-testid":`channel-delete`,children:a(`channels.delete`)}),(0,D.jsx)(S,{size:`sm`,disabled:u||!o.trim(),onClick:()=>{d(!0),x.update(e.id,{name:o.trim(),description:c.trim()}).then(e=>{e.success&&n()}).finally(()=>d(!1))},"data-testid":`channel-settings-save`,children:a(`channels.save`)})]}),children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:C,children:a(`channels.nameLabel`)}),(0,D.jsx)(`input`,{className:T,value:o,onChange:e=>s(e.target.value)})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:C,children:a(`channels.descriptionLabel`)}),(0,D.jsx)(`textarea`,{className:T,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})};export{fe as default};
|