libre-webui 0.43.0 → 0.44.1

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.
Files changed (154) hide show
  1. package/README.md +2 -0
  2. package/backend/dist/services/agentCliService.d.ts.map +1 -1
  3. package/backend/dist/services/agentCliService.js +3 -0
  4. package/backend/dist/services/agentCliService.js.map +1 -1
  5. package/backend/dist/services/pluginService.d.ts.map +1 -1
  6. package/backend/dist/services/pluginService.js +12 -9
  7. package/backend/dist/services/pluginService.js.map +1 -1
  8. package/backend/dist/services/workAgentHostLogins.d.ts.map +1 -1
  9. package/backend/dist/services/workAgentHostLogins.js +4 -0
  10. package/backend/dist/services/workAgentHostLogins.js.map +1 -1
  11. package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
  12. package/backend/dist/services/workModelProviderService.js +13 -1
  13. package/backend/dist/services/workModelProviderService.js.map +1 -1
  14. package/backend/dist/utils/pluginChatAdapter.d.ts +15 -1
  15. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
  16. package/backend/dist/utils/pluginChatAdapter.js +84 -14
  17. package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
  18. package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
  19. package/backend/dist/utils/pluginDefinitionTrust.js +7 -5
  20. package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
  21. package/backend/dist/utils/pluginModelCatalog.d.ts +10 -0
  22. package/backend/dist/utils/pluginModelCatalog.d.ts.map +1 -1
  23. package/backend/dist/utils/pluginModelCatalog.js +24 -0
  24. package/backend/dist/utils/pluginModelCatalog.js.map +1 -1
  25. package/backend/package.json +2 -2
  26. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  27. package/frontend/dist/artifact-runtime/babel.js +179 -173
  28. package/frontend/dist/artifact-runtime/chart.js +1 -1
  29. package/frontend/dist/artifact-runtime/d3.js +4 -4
  30. package/frontend/dist/artifact-runtime/framer-motion.js +2 -10
  31. package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
  32. package/frontend/dist/artifact-runtime/mathjs.js +1 -1
  33. package/frontend/dist/artifact-runtime/mermaid.js +368 -368
  34. package/frontend/dist/artifact-runtime/plotly.js +59 -59
  35. package/frontend/dist/artifact-runtime/recharts.js +45 -45
  36. package/frontend/dist/artifact-runtime/tailwind.js +18 -18
  37. package/frontend/dist/artifact-runtime/three.js +419 -397
  38. package/frontend/dist/artifact-runtime/tone.js +1 -1
  39. package/frontend/dist/assets/index-BM0txgxR.css +2 -0
  40. package/frontend/dist/assets/index-CYJjXpq5.js +34 -0
  41. package/frontend/dist/assets/{markdown-math-Ngnvt50Q.css → markdown-math-Bv5fr4tV.css} +1 -1
  42. package/frontend/dist/index.html +30 -30
  43. package/frontend/dist/js/{ArtifactContainer-C0R4kYVM.js → ArtifactContainer-C2PgJwen.js} +1 -1
  44. package/frontend/dist/js/{ArtifactDemoPage-BQmbCyat.js → ArtifactDemoPage-Dcy-lVrh.js} +2 -2
  45. package/frontend/dist/js/{ArtifactSandboxFrame-CkDkrHpg.js → ArtifactSandboxFrame-C7gLjHfY.js} +6 -6
  46. package/frontend/dist/js/ArtifactSlideOutPanel-BKZQ7VwV.js +1 -0
  47. package/frontend/dist/js/{AutomationModal-Cx1e_4df.js → AutomationModal-zImHyodn.js} +1 -1
  48. package/frontend/dist/js/AutomationsPage-BuJ1Y810.js +1 -0
  49. package/frontend/dist/js/{AvatarUpload-DGRQC20B.js → AvatarUpload-BECcVNWc.js} +1 -1
  50. package/frontend/dist/js/{Button-DwZ26Lqc.js → Button-BGE6ZJv5.js} +1 -1
  51. package/frontend/dist/js/CalendarPage-hF8Gk80e.js +1 -0
  52. package/frontend/dist/js/ChannelsPage-Bb7qgmXS.js +1 -0
  53. package/frontend/dist/js/ChatPage-BkMm-S6C.js +14 -0
  54. package/frontend/dist/js/ConnectModels-DVd2RDUM.js +1 -0
  55. package/frontend/dist/js/EvaluationsPage-D_R88N9b.js +2 -0
  56. package/frontend/dist/js/FirstTimeSetup-CQQUhpPj.js +1 -0
  57. package/frontend/dist/js/GalleryPage-BYyAx84l.js +1 -0
  58. package/frontend/dist/js/HomePage-BRjiDJZa.js +1 -0
  59. package/frontend/dist/js/{LanguageSwitcher-CASJ8p5d.js → LanguageSwitcher-0vFsK1v-.js} +1 -1
  60. package/frontend/dist/js/{Logo-C-qwuy58.js → Logo-GlNrhpKp.js} +1 -1
  61. package/frontend/dist/js/{LogoMark-zP-mitdI.js → LogoMark-rgOHhWo-.js} +1 -1
  62. package/frontend/dist/js/{ModelManagerModals-BYhFWv22.js → ModelManagerModals-BK0iqnHd.js} +1 -1
  63. package/frontend/dist/js/NotesPage-DD6EntAT.js +3 -0
  64. package/frontend/dist/js/{PasswordStrengthMeter-Dow8ZeTs.js → PasswordStrengthMeter-DrXjBWiT.js} +1 -1
  65. package/frontend/dist/js/PersonasPage-CkGtixCB.js +13 -0
  66. package/frontend/dist/js/PluginUsagePage-BBfqotzy.js +1 -0
  67. package/frontend/dist/js/{RichMessageContent-DJTLGpws.js → RichMessageContent-BcBbr-Q2.js} +1 -1
  68. package/frontend/dist/js/{RichMessageContent-Bwpg3rfV.js → RichMessageContent-Cdz4MI7q.js} +3 -3
  69. package/frontend/dist/js/SettingsModal-CKtlOet9.js +19 -0
  70. package/frontend/dist/js/SettingsToggle-BT6cbOnw.js +1 -0
  71. package/frontend/dist/js/{ShareDialog-DYwyeyaI.js → ShareDialog-CTZp6YtI.js} +1 -1
  72. package/frontend/dist/js/StrandsPage-BYY6YV5N.js +1 -0
  73. package/frontend/dist/js/{SystemPage-B4qFsAsb.js → SystemPage-DaDG0V07.js} +1 -1
  74. package/frontend/dist/js/{TurnstileWidget-xx9lQV0b.js → TurnstileWidget-B_dl1YjT.js} +1 -1
  75. package/frontend/dist/js/{UserManagementPage-DhMRuhqj.js → UserManagementPage-BrogyZDQ.js} +1 -1
  76. package/frontend/dist/js/UserManagementPanel-B7SuWPQg.js +1 -0
  77. package/frontend/dist/js/{WhatsNewModal-DfR7W93-.js → WhatsNewModal-DgMfeACt.js} +1 -1
  78. package/frontend/dist/js/WorkPage-CVcyA61Q.js +7 -0
  79. package/frontend/dist/js/api-BSMl2Tok.js +1 -0
  80. package/frontend/dist/js/api-Bje32kcr.js +16 -0
  81. package/frontend/dist/js/{appNavigation-BifMRN3D.js → appNavigation-6Vs8h0Iv.js} +1 -1
  82. package/frontend/dist/js/{appStore-B6pAGo3p.js → appStore-DmeFFzzj.js} +2 -2
  83. package/frontend/dist/js/appVersion-DWwbhdm2.js +1 -0
  84. package/frontend/dist/js/authStore-DQ-PhUey.js +1 -0
  85. package/frontend/dist/js/{authStore-DdIb6km_.js → authStore-DUmjkugT.js} +3 -3
  86. package/frontend/dist/js/chatStore-Di86sm3T.js +3 -0
  87. package/frontend/dist/js/{client-D_F_0LqX.js → client-DIxMEDnJ.js} +2 -2
  88. package/frontend/dist/js/{config-CHUQTU6j.js → config-HBTc75oS.js} +1 -1
  89. package/frontend/dist/js/{evaluationsApi-C0FKNJua.js → evaluationsApi-CJ9eIoSl.js} +1 -1
  90. package/frontend/dist/js/logger-DAQsBb8I.js +1 -0
  91. package/frontend/dist/js/markdown-html-DRL6swKb.js +2 -0
  92. package/frontend/dist/js/{markdown-math-BzLEmswF.js → markdown-math-CCWDDhWR.js} +3 -3
  93. package/frontend/dist/js/{markdownHtml-B1Ll_Qgp.js → markdownHtml-DpKMtcCu.js} +1 -1
  94. package/frontend/dist/js/markdownMath-CKB9Q-yN.js +1 -0
  95. package/frontend/dist/js/{messageCodeStyles-DVYyK8wm.js → messageCodeStyles-C0H1Lad5.js} +1 -1
  96. package/frontend/dist/js/rfb-xHgMEWMb.js +5 -0
  97. package/frontend/dist/js/router-vendor-DLHZHk4K.js +1 -0
  98. package/frontend/dist/js/{strandsApi-CeJLezXW.js → strandsApi-Cuqp8JZv.js} +1 -1
  99. package/frontend/dist/js/{teamEventStream-DOMyufrH.js → teamEventStream-DHeJw2eu.js} +1 -1
  100. package/frontend/dist/js/ui-BPtWIxXL.js +2 -0
  101. package/frontend/dist/js/ui-vendor-Bac5e8jE.js +1 -0
  102. package/frontend/dist/js/useChat-DjRbGblw.js +13 -0
  103. package/frontend/dist/js/useDictation-C31FhomS.js +1 -0
  104. package/frontend/dist/js/useQuery-DCqz3UJt.js +1 -0
  105. package/frontend/dist/js/{useTranslation-D9EScZXH.js → useTranslation-D-_KTORQ.js} +1 -1
  106. package/frontend/dist/js/utils-DsCVr_wG.js +1 -0
  107. package/frontend/dist/js/workApi-D4JbAtE2.js +1 -0
  108. package/frontend/dist/js/workApi-Dkf48LjA.js +5 -0
  109. package/package.json +3 -3
  110. package/plugins/anthropic.json +1 -0
  111. package/plugins/baseten.json +68 -0
  112. package/plugins/codex-oauth.json +1 -0
  113. package/plugins/meta.json +1 -0
  114. package/plugins/modal.json +82 -0
  115. package/plugins/openai.json +2 -1
  116. package/plugins/openrouter.json +1 -0
  117. package/frontend/dist/assets/index-BnbO3eTY.js +0 -83
  118. package/frontend/dist/assets/index-CYKYBgsy.css +0 -2
  119. package/frontend/dist/js/ArtifactSlideOutPanel-DZnVzC0c.js +0 -1
  120. package/frontend/dist/js/AutomationsPage-D7UtYZ_0.js +0 -1
  121. package/frontend/dist/js/CalendarPage-WmA1i7MQ.js +0 -1
  122. package/frontend/dist/js/ChannelsPage-Bq4JQPR_.js +0 -1
  123. package/frontend/dist/js/ChatPage-Cd3fxx-N.js +0 -14
  124. package/frontend/dist/js/ConnectModels-BYul-veF.js +0 -1
  125. package/frontend/dist/js/EvaluationsPage-CV_Terzn.js +0 -2
  126. package/frontend/dist/js/FirstTimeSetup-CFhGy9a8.js +0 -1
  127. package/frontend/dist/js/GalleryPage-BRKZyq1w.js +0 -1
  128. package/frontend/dist/js/HomePage-DdpnBu-Z.js +0 -1
  129. package/frontend/dist/js/NotesPage-CmvVoWcH.js +0 -3
  130. package/frontend/dist/js/PersonasPage-BYKtoKWl.js +0 -13
  131. package/frontend/dist/js/PluginUsagePage-BVTOCxoE.js +0 -1
  132. package/frontend/dist/js/SettingsModal-CGyVfxOz.js +0 -19
  133. package/frontend/dist/js/SettingsToggle-BpD6NSri.js +0 -1
  134. package/frontend/dist/js/StrandsPage-CvXeYOYR.js +0 -1
  135. package/frontend/dist/js/UserManagementPanel-BVLSvRwa.js +0 -1
  136. package/frontend/dist/js/WorkPage-DSKBQEW0.js +0 -7
  137. package/frontend/dist/js/api-C5ps_CWQ.js +0 -1
  138. package/frontend/dist/js/api-D6IF0v9_.js +0 -16
  139. package/frontend/dist/js/appVersion-9UMn7b1T.js +0 -1
  140. package/frontend/dist/js/authStore-CDo5Co2D.js +0 -1
  141. package/frontend/dist/js/chatStore-hzQyRM9H.js +0 -3
  142. package/frontend/dist/js/logger-rEW7uQ8m.js +0 -1
  143. package/frontend/dist/js/markdown-html-BdYVneHE.js +0 -2
  144. package/frontend/dist/js/markdownMath-aI8uDQmz.js +0 -1
  145. package/frontend/dist/js/rfb-IV07oQgM.js +0 -5
  146. package/frontend/dist/js/router-vendor-qltZAWoz.js +0 -1
  147. package/frontend/dist/js/ui-D4Ytvr6d.js +0 -2
  148. package/frontend/dist/js/ui-vendor-BTcw5yZ6.js +0 -1
  149. package/frontend/dist/js/useChat-BEbNywiP.js +0 -13
  150. package/frontend/dist/js/useDictation-jTaorrHm.js +0 -1
  151. package/frontend/dist/js/useQuery-2_pQiHbl.js +0 -1
  152. package/frontend/dist/js/utils-BvvV-Cka.js +0 -1
  153. package/frontend/dist/js/workApi-CGvfDTRY.js +0 -1
  154. package/frontend/dist/js/workApi-_0oxRyak.js +0 -5
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n,t as r}from"./react-vendor-C1iE8mnY.js";import{t as i}from"./utils-BvvV-Cka.js";import{t as ee}from"./useTranslation-D9EScZXH.js";import{T as te,t as ne}from"./chatStore-hzQyRM9H.js";import{t as a}from"./logger-rEW7uQ8m.js";import{t as o}from"./appStore-B6pAGo3p.js";import{An as re,Ln as s,Nn as ie,Or as ae,Qn as oe,Rn as c,Tn as l,Zn as u,g as d,n as se,rn as ce,tn as le,tr as ue,yn as f}from"./ui-vendor-BTcw5yZ6.js";import{t as p}from"./Button-DwZ26Lqc.js";import{i as de,r as fe}from"./artifactHtml-DDmfpcB0.js";import{t as m}from"./OptimizedSyntaxHighlighter-B8vbflQA.js";import{t as pe}from"./ArtifactSandboxFrame-CkDkrHpg.js";var h=e(t(),1),me=n(),g=r(),he=a(`components:artifact-slide-out-panel`),_=320,ge=.9,_e=400,ve=`(min-width: 768px)`,ye=`(min-width: 1024px)`,v=e=>{let[t,n]=(0,h.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,h.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t},y=()=>{let{t:e,i18n:t}=ee(),n=te(t.language),{artifactPanelOpen:r,artifactPanelArtifact:a,openArtifactPanel:y,closeArtifactPanel:b,theme:x,artifactPanelWidth:S,setArtifactPanelWidth:C,artifactPanelResizing:w,setArtifactPanelResizing:T,sidebarOpen:E,sidebarCompact:D}=o(),O=v(ve),k=v(ye)?E?D?64:288:0:E&&D?64:0,A=(0,h.useCallback)(()=>O?Math.max(_,window.innerWidth-k-_e):window.innerWidth*ge,[O,k]),j=ne(e=>e.currentSession),M=h.useMemo(()=>{if(!a)return[];let e=a.title.trim().toLowerCase(),t=(j?.messages??[]).flatMap(e=>e.artifacts??[]).filter(t=>t.title.trim().toLowerCase()===e);return t.some(e=>e.id===a.id||e.content===a.content)?t:[...t,a]},[j,a]),N=M.findIndex(e=>e.id===a?.id);N===-1&&a&&(N=M.findIndex(e=>e.content===a.content));let[P,F]=(0,h.useState)(!1),[I,L]=(0,h.useState)(`preview`),R=(0,h.useRef)(null),z=(0,h.useRef)(null),B=(0,h.useRef)(0),V=(0,h.useRef)(0),H=(0,h.useRef)(null),U=(0,h.useRef)(null),W=(0,h.useRef)(S),G=a?.id??null;G!==z.current&&(z.current=G,I!==`preview`&&L(`preview`));let K=(0,h.useCallback)(e=>{W.current=e,U.current===null&&(U.current=window.requestAnimationFrame(()=>{U.current=null,C(W.current)}))},[C]),q=(0,h.useCallback)(()=>{H.current=null,T(!1),U.current!==null&&(window.cancelAnimationFrame(U.current),U.current=null,C(W.current))},[T,C]),be=(0,h.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),H.current=e.pointerId,V.current=S,B.current=e.clientX,W.current=S,e.currentTarget.setPointerCapture(e.pointerId),T(!0)},[S,T]),xe=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=n?e.key===`ArrowRight`:e.key===`ArrowLeft`,r=e.shiftKey?96:24;C(Math.min(A(),Math.max(_,S+(t?r:-r))))},J=(0,h.useCallback)(e=>{if(!w||H.current!==null&&e.pointerId!==H.current)return;e.preventDefault();let t=(B.current-e.clientX)*(n?-1:1),r=Math.min(A(),Math.max(_,V.current+t));K(r)},[w,n,K,A]);if((0,h.useEffect)(()=>{if(!w){document.body.style.userSelect=``,document.body.style.cursor=``;return}let e=e=>{(H.current===null||e.pointerId===H.current)&&q()};return window.addEventListener(`pointermove`,J,{passive:!1}),window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,q),document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,()=>{window.removeEventListener(`pointermove`,J),window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,q),document.body.style.userSelect=``,document.body.style.cursor=``}},[w,J,q]),(0,h.useEffect)(()=>{let e=()=>{let e=A();S>e&&C(e)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[S,C,A]),(0,h.useEffect)(()=>{if(O)return;let e=e=>{e.key===`Escape`&&r&&b()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,b,O]),(0,h.useEffect)(()=>{if(O)return;let e=e=>{w||R.current&&!R.current.contains(e.target)&&r&&b()},t=setTimeout(()=>{window.addEventListener(`mousedown`,e)},100);return()=>{clearTimeout(t),window.removeEventListener(`mousedown`,e)}},[r,b,w,O]),!a)return null;let Y=a,Se=async t=>{try{await navigator.clipboard.writeText(t),F(!0),setTimeout(()=>F(!1),2e3)}catch(t){he.error(`Failed to copy:`,t),ae.error(e(`chat.message.copyFailed`))}},Ce=()=>{let e=Y.type===`html`?fe(Y.content,Y.title):Y.content,t=new Blob([e],{type:we(Y.type)}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${Y.title}.${Te(Y.type)}`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},we=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`}},Te=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`}},Ee=()=>{switch(Y.type){case`html`:return(0,g.jsx)(ce,{className:`h-5 w-5`});case`react`:return(0,g.jsx)(s,{className:`h-5 w-5`});case`svg`:return(0,g.jsx)(f,{className:`h-5 w-5`});case`code`:return(0,g.jsx)(s,{className:`h-5 w-5`});default:return(0,g.jsx)(f,{className:`h-5 w-5`})}},X=()=>(0,g.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,g.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,g.jsx)(d,{className:`h-8 w-8 text-primary-500 mx-auto mb-3`}),(0,g.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`artifacts.previewUnavailable`)}),(0,g.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`artifacts.previewUnavailableDescription`)}),(0,g.jsxs)(p,{variant:`outline`,size:`sm`,onClick:()=>L(`code`),className:`mt-4`,children:[(0,g.jsx)(c,{className:`h-3.5 w-3.5 me-1.5`}),e(`artifacts.code`)]})]})}),Z=e=>Y.content.trim()?(0,g.jsx)(pe,{content:Y.content,title:Y.title,kind:e,colorScheme:x.mode===`light`?`light`:`dark`,className:i(`w-full h-full border-0 rounded-lg bg-white`,w&&`pointer-events-none`),fallback:X()}):X(),De=()=>(0,g.jsx)(`iframe`,{"data-testid":`artifact-svg-preview`,srcDoc:de(Y.content,Y.title),className:`w-full h-full border-0 rounded-lg bg-white`,sandbox:``,title:Y.title}),Q=()=>(0,g.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,g.jsx)(m,{language:(()=>{if(Y.language)return Y.language;switch(Y.type){case`html`:return`html`;case`react`:return`jsx`;case`svg`:return`xml`;case`json`:return`json`;default:return`text`}})(),isDark:x.mode!==`light`,className:`m-0! rounded-lg! h-full!`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:x.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:Y.content})}),Oe=()=>{try{let e=JSON.parse(Y.content),t=JSON.stringify(e,null,2);return(0,g.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,g.jsx)(m,{language:`json`,isDark:x.mode!==`light`,className:`m-0! rounded-lg! h-full!`,codeTheme:`night`,showLineNumbers:!0,backgroundColor:x.mode===`light`?void 0:`rgb(var(--color-dark-50))`,children:t})})}catch{return(0,g.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-gray-50 dark:bg-dark-100 rounded-lg`,children:(0,g.jsxs)(`div`,{className:`text-center`,children:[(0,g.jsx)(d,{className:`h-8 w-8 text-primary-500 mx-auto mb-2`}),(0,g.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:e(`artifacts.invalidJson`)})]})})}},ke=()=>{if(I===`code`)return Q();switch(Y.type){case`html`:return Z(`html`);case`react`:return Z(`react`);case`mermaid`:return Z(`mermaid`);case`svg`:return De();case`json`:return Oe();default:return Q()}},Ae=()=>Y.type===`html`||Y.type===`svg`||Y.type===`react`||Y.type===`mermaid`,$=typeof window<`u`&&window.innerWidth<640,je=$?`100%`:`${S}px`,Me=(0,g.jsxs)(g.Fragment,{children:[!O&&(0,g.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`)}),w&&(0,g.jsx)(`div`,{className:i(`fixed inset-0 cursor-col-resize select-none`,O?`z-40`:`z-55`),"aria-hidden":`true`}),(0,g.jsxs)(`div`,{ref:R,"data-testid":`artifact-slide-out-panel`,style:{width:je},className:i(`fixed top-0 inset-e-0 h-full`,O?`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,g.jsxs)(`div`,{onPointerDown:be,onKeyDown:xe,role:`separator`,"aria-orientation":`vertical`,tabIndex:0,"aria-label":e(`artifacts.resizePanel`),"aria-valuenow":Math.round(S),"aria-valuemin":_,"aria-valuemax":Math.round(A()),"data-testid":`artifact-resize-handle`,title:e(`artifacts.dragEdgeToResize`),className:i(`focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500`,`absolute inset-s-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,g.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 group-focus-visible:bg-primary-500`,w&&`bg-primary-500 h-24`)}),(0,g.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`,w&&`opacity-100`),children:(0,g.jsx)(le,{className:`h-4 w-4`})})]}),(0,g.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,g.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`text-gray-600 dark:text-gray-400 shrink-0`,children:Ee()}),(0,g.jsx)(`h2`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate`,title:Y.description||`${e(`artifacts.created`)}: ${new Date(Y.createdAt).toLocaleString(t.language)}`,children:Y.title}),(0,g.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 shrink-0`,children:Y.type.toUpperCase()})]}),M.length>1&&N!==-1&&(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,g.jsx)(p,{variant:`ghost`,size:`sm`,disabled:N===0,onClick:()=>y(M[N-1]),className:`h-7 w-7 p-0`,title:e(`artifacts.previousVersion`),"aria-label":e(`artifacts.previousVersion`),children:(0,g.jsx)(oe,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,g.jsx)(`span`,{className:`whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-dark-600`,children:e(`artifacts.versionOf`,{current:N+1,total:M.length})}),(0,g.jsx)(p,{variant:`ghost`,size:`sm`,disabled:N===M.length-1,onClick:()=>y(M[N+1]),className:`h-7 w-7 p-0`,title:e(`artifacts.nextVersion`),"aria-label":e(`artifacts.nextVersion`),children:(0,g.jsx)(u,{className:`h-3.5 w-3.5 rtl:rotate-180`})})]}),Ae()&&(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,g.jsxs)(p,{variant:I===`preview`?`primary`:`ghost`,size:`sm`,onClick:()=>L(`preview`),className:`h-7 px-2 text-xs`,title:e(`artifacts.previewMode`),"aria-pressed":I===`preview`,children:[(0,g.jsx)(l,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.preview`)]}),(0,g.jsxs)(p,{variant:I===`code`?`primary`:`ghost`,size:`sm`,onClick:()=>L(`code`),className:`h-7 px-2 text-xs`,title:e(`artifacts.codeMode`),"aria-pressed":I===`code`,children:[(0,g.jsx)(c,{className:`h-3.5 w-3.5 me-1`}),e(`artifacts.code`)]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,g.jsx)(p,{variant:`ghost`,size:`sm`,onClick:()=>Se(Y.content),className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.copyContent`),"aria-label":e(`artifacts.copyContent`),children:P?(0,g.jsx)(ue,{className:`h-3.5 w-3.5 text-green-500`}):(0,g.jsx)(ie,{className:`h-3.5 w-3.5`})}),(0,g.jsx)(p,{variant:`ghost`,size:`sm`,onClick:Ce,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(`artifacts.download`),"aria-label":e(`artifacts.download`),children:(0,g.jsx)(re,{className:`h-3.5 w-3.5`})}),(0,g.jsx)(p,{variant:`ghost`,size:`sm`,onClick:b,className:`h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,title:e(O?`common.close`:`artifacts.closePanelEsc`),"aria-label":e(O?`common.close`:`artifacts.closePanelEsc`),children:(0,g.jsx)(se,{className:`h-4 w-4`})})]})]}),(0,g.jsx)(`div`,{className:`flex-1 p-2 overflow-hidden`,children:ke()})]})]});return(0,me.createPortal)(Me,document.body)};export{y as ArtifactSlideOutPanel};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-vendor-C1iE8mnY.js";import{d as r}from"./router-vendor-qltZAWoz.js";import{i,t as a}from"./utils-BvvV-Cka.js";import{t as o}from"./useTranslation-D9EScZXH.js";import{t as s}from"./chatStore-hzQyRM9H.js";import{t as c}from"./logger-rEW7uQ8m.js";import{Gn as l,Or as u,Un as ee,Wn as te,Z as d,it as f,kn as ne,lt as re,st as ie,t as ae,tt as p,v as m,zt as h}from"./ui-vendor-BTcw5yZ6.js";import{t as g}from"./Button-DwZ26Lqc.js";import{i as _,n as v,r as y}from"./ui-D4Ytvr6d.js";import{t as oe}from"./confirmStore-CKkUtP9c.js";import{T as b}from"./api-D6IF0v9_.js";import{n as x,r as S,t as C}from"./AutomationModal-Cx1e_4df.js";var w=e(t(),1),T=n();function E({days:e,locale:t}){let{t:n}=o(),r=e.reduce((e,t)=>e+t.succeeded,0),i=e.reduce((e,t)=>e+t.failed,0),a=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/6 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:[i,` `,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-xs bg-black/6 dark:bg-white/8`},t);let r=Math.max(6,Math.round(n/a*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-xs`,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=c(`pages:automations`),k=()=>{let{t:e,i18n:t}=o(),n=r(),c=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=(0,w.useRef)(null),[se,ce]=(0,w.useState)(0),Q=(0,w.useCallback)(()=>ce(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),u.error(e(`automations.loadFailed`)))}).finally(()=>{t||B(!1)}),()=>{t=!0}},[se,e]),(0,w.useEffect)(()=>{c.length===0&&k({quiet:!0})},[c.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]),(0,w.useEffect)(()=>{if(!Y)return;Z.current?.querySelector(`[role="menuitem"]`)?.focus();let e=e=>{Z.current?.contains(e.target)||X(null)},t=e=>{e.key===`Escape`&&(Z.current?.querySelector(`[aria-haspopup="menu"]`)?.focus(),X(null))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[Y]);let le=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(e.currentTarget.querySelectorAll(`[role="menuitem"]`));if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`ArrowDown`?(n+1)%t.length:(n-1+t.length)%t.length]?.focus()},ue=()=>{W(null),K(null),H(!0)},de=t=>{W(null),K({name:e(`automations.templates.${t.id}.name`),instructions:t.instructions,triggers:t.triggers}),H(!0)},fe=e=>{W(e),K(null),X(null),H(!0)},pe=async t=>{J(!0);try{let n=U?await b.updateAutomation(U.id,t):await b.createAutomation(t);n.success?(H(!1),Q()):u.error(n.error||e(`automations.saveFailed`))}catch(t){O.error(`Failed to save automation:`,t),u.error(e(`automations.saveFailed`))}finally{J(!1)}},$=async(t,n)=>{if(Z.current?.querySelector(`[aria-haspopup="menu"]`)?.focus(),X(null),n!==`delete`||await oe({title:e(`automations.deleteConfirmTitle`,{name:t.name}),description:e(`automations.deleteConfirmDescription`),destructive:!0}))try{n===`pause`?await b.pauseAutomation(t.id):n===`resume`?await b.resumeAutomation(t.id):n===`run`?(await b.runAutomationNow(t.id),u.success(e(`automations.runQueued`))):await b.deleteAutomation(t.id),Q()}catch(t){O.error(`Automation ${n} failed:`,t),u.error(e(`automations.actionFailed`))}},me=e=>e.status===`succeeded`?(0,T.jsx)(l,{className:`h-4 w-4 text-emerald-500`}):e.status===`failed`?(0,T.jsx)(ee,{className:`h-4 w-4 text-red-500`}):(0,T.jsx)(h,{className:`h-4 w-4 animate-spin text-gray-400`}),he=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.jsx)(_,{title:e(`automations.title`),actions:(0,T.jsxs)(g,{size:`sm`,onClick:ue,"data-testid":`automation-new`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,T.jsx)(p,{className:`h-3.5 w-3.5`}),e(`automations.newAutomation`)]}),children:(0,T.jsx)(`div`,{role:`tablist`,"aria-label":e(`automations.title`),className:`flex items-center rounded-xl bg-black/4 p-0.5 dark:bg-white/6`,onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=j===`automations`?`runs`:`automations`;e.preventDefault(),M(t),document.getElementById(`automations-tab-${t}`)?.focus()},children:[`automations`,`runs`].map(t=>(0,T.jsx)(`button`,{id:`automations-tab-${t}`,type:`button`,role:`tab`,"aria-selected":j===t,tabIndex:j===t?0:-1,onClick:()=>M(t),"data-testid":`automations-tab-${t}`,className:a(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors`,j===t?`bg-white text-gray-900 shadow-xs 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)(`div`,{role:`tabpanel`,"aria-labelledby":`automations-tab-${j}`,className:`scroll-region min-h-0 flex-1 overflow-y-auto px-4 py-4 scrollbar-thin`,children:[j===`automations`?z?(0,T.jsx)(v,{srOnly:!0}):N.length===0?(0,T.jsx)(y,{icon:ae,title: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/6 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:a(`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:[x(n.triggers,t.language,e),!S(n.triggers)&&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`,{ref:Y===n.id?Z:void 0,className:`relative shrink-0`,children:[(0,T.jsx)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":Y===n.id,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/4 hover:text-gray-700 dark:hover:bg-white/6 dark:hover:text-dark-800`,children:(0,T.jsx)(ne,{className:`h-4 w-4`})}),Y===n.id&&(0,T.jsxs)(`div`,{role:`menu`,onKeyDown:le,className:`absolute inset-e-0 top-8 z-20 w-44 rounded-xl border border-black/[0.07] bg-white p-1 shadow-lg dark:border-white/8 dark:bg-dark-100`,children:[(0,T.jsx)(A,{icon:ie,label:e(`common.edit`),onClick:()=>fe(n)}),n.status===`active`?(0,T.jsx)(A,{icon:re,label:e(`automations.pause`),onClick:()=>$(n,`pause`)}):(0,T.jsx)(A,{icon:f,label:e(`automations.resume`),onClick:()=>$(n,`resume`)}),(0,T.jsx)(A,{icon:d,label:e(`automations.runNow`),onClick:()=>$(n,`run`)}),(0,T.jsx)(A,{icon:m,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:()=>de(n),"data-testid":`automation-template`,className:`rounded-2xl border border-black/6 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:x(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.jsx)(y,{icon:te,size:`sm`,title: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/5 bg-white/50 px-3 py-2 dark:border-white/6 dark:bg-dark-100/50`,children:[me(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:he(r.automationId)}),(0,T.jsxs)(`p`,{className:`truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[i(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:c,saving:q,onClose:()=>H(!1),onSave:e=>void pe(e)})]})};function A({icon:e,label:t,destructive:n,onClick:r}){return(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:r,className:a(`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/4 dark:text-dark-700 dark:hover:bg-white/6`),children:[(0,T.jsx)(e,{className:`h-3.5 w-3.5`}),t]})}export{k as default};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n,t as r}from"./react-vendor-C1iE8mnY.js";import{d as i}from"./router-vendor-qltZAWoz.js";import{t as a}from"./utils-BvvV-Cka.js";import{t as o}from"./useTranslation-D9EScZXH.js";import{t as s}from"./logger-rEW7uQ8m.js";import{An as c,B as l,Bn as u,Gn as d,Or as f,Qn as p,Zn as m,g as h,n as g,p as _,tt as v,v as y}from"./ui-vendor-BTcw5yZ6.js";import{t as b}from"./Button-DwZ26Lqc.js";import{t as x}from"./useDialogFocus-DpTun-ZV.js";import{i as S}from"./ui-D4Ytvr6d.js";import{t as ee}from"./confirmStore-CKkUtP9c.js";import{O as C,T as w}from"./api-D6IF0v9_.js";import{t as T}from"./ShareDialog-DYwyeyaI.js";import{a as E,c as D,d as O,i as k,l as A,n as j,o as M,r as N,s as P,t as F,u as I}from"./calendarDates-Co3o_05Y.js";var L=e(t(),1),R=r(),z={event:`bg-primary-500/15 text-primary-700 hover:bg-primary-500/25 dark:text-primary-300`,automation:`bg-warning-500/15 text-ink hover:bg-warning-500/25`,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 B({event:e,label:t,onClick:n}){let{t:r}=o(),i=e.variant===`automation`?{Icon:u,label:r(`calendar.chipStatus.automation`)}:e.variant===`runSucceeded`?{Icon:d,label:r(`calendar.chipStatus.runSucceeded`)}:e.variant===`runFailed`?{Icon:h,label:r(`calendar.chipStatus.runFailed`)}:null;return(0,R.jsxs)(`button`,{type:`button`,"data-testid":`calendar-event-chip`,"data-variant":e.variant??`event`,title:e.title,onClick:e=>{e.stopPropagation(),n()},className:a(`flex w-full items-center gap-1 rounded-md px-1.5 py-0.5 text-start text-[11px] leading-4 transition-colors`,z[e.variant??`event`],e.baseEventId&&`opacity-75`),children:[i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(i.Icon,{className:`h-3 w-3 shrink-0`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`sr-only`,children:i.label})]}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]})}var V=3;function te({year:e,monthIndex:t,events:n,onDayClick:r,onEventClick:i,onShowDay:s}){let{t:c,i18n:l}=o(),u=(0,L.useMemo)(()=>N(e,t),[e,t]),d=new Date,f=(0,L.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]),p=(0,L.useMemo)(()=>O(l.language),[l.language]),m=(0,L.useMemo)(()=>new Intl.DateTimeFormat(l.language,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`}),[l.language]);return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`calendar-month-grid`,children:[(0,R.jsx)(`div`,{className:`grid grid-cols-7 border-b border-black/6 dark:border-white/[0.07]`,children:p.map(e=>(0,R.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,R.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-7 grid-rows-6`,children:u.map(e=>{let n=e.getMonth()===t,o=k(e,d),u=`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`,p=f.get(u)??[],h=p.length-V;return(0,R.jsxs)(`div`,{role:`gridcell`,"data-testid":`calendar-day-cell`,onClick:()=>r(e),className:a(`flex min-h-0 cursor-pointer flex-col gap-0.5 border-b border-e border-black/4 p-1 transition-colors hover:bg-black/2 dark:border-white/4 dark:hover:bg-white/3`,!n&&`opacity-40`),children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":c(`calendar.newEventOn`,{date:m.format(e)}),"aria-current":o?`date`:void 0,className:a(`flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[12px]`,o?`bg-ink font-semibold text-ink-inverse`:`text-ink-muted`),children:e.getDate()}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-0.5 overflow-hidden`,children:[p.slice(0,V).map(e=>(0,R.jsx)(B,{event:e,label:e.allDay?e.title:`${P(e.startAt,l.language)} ${e.title}`,onClick:()=>i(e)},e.id)),h>0&&(0,R.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s?.(e)},title:c(`calendar.showDay`,{date:m.format(e)}),className:`rounded-sm px-1 text-start text-[10px] text-ink-muted hover:text-ink`,children:c(`calendar.more`,{n:h})})]})]},u)})})]})}var H=48;function ne({anchor:e,events:t,dayCount:n=7,onDayClick:r,onEventClick:i}){let{t:s,i18n:c}=o(),l=(0,L.useMemo)(()=>n===1?[new Date(e.getFullYear(),e.getMonth(),e.getDate())]:I(e),[e,n]),u=new Date,d=(0,L.useMemo)(()=>new Intl.DateTimeFormat(c.language,{hour:`numeric`}),[c.language]),f=(0,L.useMemo)(()=>new Intl.DateTimeFormat(c.language,{weekday:`long`,month:`long`,day:`numeric`,hour:`numeric`}),[c.language]),p=(0,L.useRef)(null),[m,h]=(0,L.useState)(`0-9`),g=(e,t,n)=>{let r=c.dir()===`rtl`?-1:1,i={ArrowRight:[r,0],ArrowLeft:[-r,0],ArrowDown:[0,1],ArrowUp:[0,-1]}[e.key];if(!i)return;let a=Math.min(l.length-1,Math.max(0,t+i[0])),o=Math.min(23,Math.max(0,n+i[1]));e.preventDefault();let s=`${a}-${o}`;h(s),p.current?.querySelector(`[data-slot="${s}"]`)?.focus()},_=(0,L.useMemo)(()=>new Intl.DateTimeFormat(c.language,{weekday:`short`,day:`numeric`}),[c.language]),v=e=>t.filter(t=>t.allDay&&k(new Date(t.startAt),e)),y=e=>t.filter(t=>!t.allDay&&k(new Date(t.startAt),e));return(0,R.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto scrollbar-thin`,"data-testid":`calendar-week-grid`,children:(0,R.jsxs)(`div`,{ref:p,className:`grid grid-cols-[3.5rem_repeat(7,1fr)]`,children:[(0,R.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-black/6 bg-surface dark:border-white/[0.07]`}),l.map(e=>(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 border-b border-e border-black/6 bg-surface px-1 py-1.5 dark:border-white/[0.07]`,children:[(0,R.jsx)(`span`,{className:a(`block truncate text-center text-[11px] font-medium`,k(e,u)?`text-primary-600 dark:text-primary-400`:`text-gray-500 dark:text-dark-500`),children:_.format(e)}),(0,R.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:v(e).map(e=>(0,R.jsx)(B,{event:e,label:e.title,onClick:()=>i(e)},e.id))})]},e.toISOString())),Array.from({length:24},(e,t)=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(`div`,{className:`relative border-b border-black/4 pe-1.5 text-end text-[10px] text-gray-400 dark:border-white/4 dark:text-dark-500`,children:(0,R.jsx)(`span`,{className:`relative -top-1.5`,children:t>0?d.format(new Date(2024,0,1,t)):``})}),l.map((e,n)=>{let a=`${n}-${t}`,o=y(e).filter(e=>new Date(e.startAt).getHours()===t);return(0,R.jsxs)(`div`,{onClick:()=>r(e,t),style:{height:H},className:`relative cursor-pointer space-y-0.5 overflow-hidden border-b border-e border-black/4 p-0.5 transition-colors hover:bg-black/2 dark:border-white/4 dark:hover:bg-white/3`,children:[(0,R.jsx)(`button`,{type:`button`,"data-slot":a,tabIndex:m===a?0:-1,"aria-label":s(`calendar.newEventOn`,{date:f.format(new Date(e.getFullYear(),e.getMonth(),e.getDate(),t))}),onFocus:()=>h(a),onKeyDown:e=>g(e,n,t),className:`absolute inset-0 focus-visible:-outline-offset-2`}),o.map(e=>(0,R.jsx)(`div`,{className:`relative`,children:(0,R.jsx)(B,{event:e,label:`${P(e.startAt,c.language)} ${e.title}`,onClick:()=>i(e)})},e.id))]},`${e.toISOString()}-${t}`)})]},t))]})})}var U=n(),W=e=>!e||e.kind===`once`||e.kind===`hourly`||e.kind===`event`?`none`:e.kind,G=(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}},K=`w-full rounded-lg border border-black/8 bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500 focus:outline-hidden focus:ring-2 focus:ring-primary-500/30 dark:border-white/8 dark:bg-dark-100 dark:text-dark-900`,q=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`;function re({open:e,event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s}){return e?(0,R.jsx)(J,{event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s},`${t?.id??`new`}:${n}`):null}function J({event:e,initialStartAt:t,calendars:n,saving:r,onClose:i,onSave:a,onDelete:s}){let{t:c}=o(),l=(0,L.useRef)(null);x(l,{onClose:i});let u=e?.startAt??t,[d,f]=(0,L.useState)(e?.title??``),[p,m]=(0,L.useState)(e?.notes??``),[h,_]=(0,L.useState)(D(u)),[v,b]=(0,L.useState)(e?A(u):`09:00`),[S,C]=(0,L.useState)(e?.endAt===void 0?``:A(e.endAt)),[w,T]=(0,L.useState)(e?.allDay??!1),[E,O]=(0,L.useState)(W(e?.recurrence)),[k,M]=(0,L.useState)(e?.calendarId??``),[N,P]=(0,L.useState)(e?.reminderMinutes===void 0?``:String(e.reminderMinutes)),F=()=>{if(!d.trim()||!h)return;let e=j(h,w?``:v),t=!w&&S?j(h,S):null;a({title:d.trim(),notes:p.trim()?p.trim():void 0,startAt:e,endAt:t!==null&&t>e?t:null,allDay:w,recurrence:G(E,e),calendarId:k||null,reminderMinutes:N?Number(N):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`)}],z=[{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,U.createPortal)((0,R.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,R.jsxs)(`div`,{ref:l,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/8 dark:bg-dark-25`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,R.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,R.jsx)(`button`,{type:`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,R.jsx)(g,{size:20,className:`text-gray-500`})})]}),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`calendar-event-title`,className:q,children:c(`calendar.eventTitle`)}),(0,R.jsx)(`input`,{id:`calendar-event-title`,"data-testid":`calendar-event-title`,type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:c(`calendar.titlePlaceholder`),className:K,maxLength:200,autoFocus:!0})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`calendar-event-date`,className:q,children:c(`calendar.date`)}),(0,R.jsx)(`input`,{id:`calendar-event-date`,type:`date`,value:h,onChange:e=>_(e.target.value),className:K})]}),(0,R.jsx)(`div`,{className:`flex items-end pb-1.5`,children:(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] text-gray-700 dark:text-dark-700`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),className:`h-4 w-4 rounded-sm accent-primary-500`}),c(`calendar.allDay`)]})})]}),!w&&(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`calendar-event-start`,className:q,children:c(`calendar.start`)}),(0,R.jsx)(`input`,{id:`calendar-event-start`,type:`time`,value:v,onChange:e=>b(e.target.value),className:K})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`calendar-event-end`,className:q,children:c(`calendar.end`)}),(0,R.jsx)(`input`,{id:`calendar-event-end`,type:`time`,value:S,onChange:e=>C(e.target.value),className:K})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`calendar-event-repeat`,className:q,children:c(`calendar.repeat`)}),(0,R.jsx)(`select`,{id:`calendar-event-repeat`,value:E,onChange:e=>O(e.target.value),className:K,children:z.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`calendar-event-notes`,className:q,children:c(`calendar.notes`)}),(0,R.jsx)(`textarea`,{id:`calendar-event-notes`,value:p,onChange:e=>m(e.target.value),rows:3,className:K,maxLength:1e4})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`calendar-event-calendar`,className:q,children:c(`calendar.calendarLabel`)}),(0,R.jsxs)(`select`,{id:`calendar-event-calendar`,value:k,onChange:e=>M(e.target.value),className:K,"data-testid":`calendar-event-calendar`,children:[(0,R.jsx)(`option`,{value:``,children:c(`calendar.personalCalendar`)}),n.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`calendar-event-reminder`,className:q,children:c(`calendar.reminderLabel`)}),(0,R.jsx)(`select`,{id:`calendar-event-reminder`,value:N,onChange:e=>P(e.target.value),className:K,"data-testid":`calendar-event-reminder`,children:I.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,R.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,R.jsxs)(`button`,{type:`button`,onClick:async()=>{await ee({title:c(`calendar.deleteEventConfirmTitle`,{title:e.title}),description:e.recurrence?c(`calendar.deleteRecurringEventConfirmDescription`):c(`calendar.deleteEventConfirmDescription`),destructive:!0})&&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,R.jsx)(y,{className:`h-4 w-4`}),c(`common.delete`)]}):(0,R.jsx)(`span`,{}),(0,R.jsxs)(`div`,{className:`flex gap-3`,children:[(0,R.jsx)(`button`,{type:`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,R.jsx)(`button`,{type:`button`,onClick:F,disabled:r||!d.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 Y=s(`pages:calendar`),X=()=>{let{t:e,i18n:t}=o(),n=i(),[r,s]=(0,L.useState)(`month`),[u,d]=(0,L.useState)(()=>new Date),[h,y]=(0,L.useState)([]),[x,D]=(0,L.useState)([]),[O,k]=(0,L.useState)(!1),[A,j]=(0,L.useState)(null),[N,P]=(0,L.useState)(()=>Date.now()),[I,z]=(0,L.useState)(!1),[B,V]=(0,L.useState)([]),[H,U]=(0,L.useState)(``),[W,G]=(0,L.useState)(!1),[K,q]=(0,L.useState)(null),J=L.useRef(null),X=(0,L.useMemo)(()=>{if(r===`month`){let e=new Date(u.getFullYear(),u.getMonth(),1),t=M(e);return{from:t.getTime(),to:F(t,42).getTime()}}if(r===`day`){let e=new Date(u.getFullYear(),u.getMonth(),u.getDate());return{from:e.getTime(),to:F(e,1).getTime()}}let e=M(u);return{from:e.getTime(),to:F(e,7).getTime()}},[u,r]),[Z,ie]=(0,L.useState)(0),Q=(0,L.useCallback)(()=>ie(e=>e+1),[]);(0,L.useEffect)(()=>{C.getCalendars().then(t=>{t.success&&t.data?V(t.data):f.error(e(`calendar.loadFailed`))}).catch(t=>{Y.error(`Failed to load calendars:`,t),f.error(e(`calendar.loadFailed`))})},[Z,e]),(0,L.useEffect)(()=>{let t=!1;return C.getEvents(X.from,X.to).then(e=>{t||e.success&&e.data&&y(e.data)}).catch(n=>{t||(Y.error(`Failed to load calendar events:`,n),f.error(e(`calendar.loadFailed`)))}),Promise.all([w.getOccurrences(X.from,X.to),w.getRuns({from:X.from,to:X.to}),w.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}:{}});D(s)}).catch(e=>{t||Y.error(`Failed to project automations onto the calendar:`,e)}),()=>{t=!0}},[X.from,X.to,Z,e]);let ae=(0,L.useMemo)(()=>[...h,...x].sort((e,t)=>e.startAt-t.startAt),[h,x]),oe=e=>{d(t=>r===`month`?new Date(t.getFullYear(),t.getMonth()+e,1):F(t,e*(r===`day`?1:7)))},$=(e,t=9)=>{j(null),P(new Date(e.getFullYear(),e.getMonth(),e.getDate(),t,0).getTime()),k(!0)},se=t=>{if(t.variant===`runSucceeded`||t.variant===`runFailed`)t.sessionId?n(`/c/${t.sessionId}`):n(`/automations`);else if(t.variant===`automation`)n(`/automations`);else if(t.shared&&t.shared.permission!==`write`)f(e(`calendar.sharedReadOnly`));else{if(t.baseEventId){let e=h.find(e=>e.id===t.baseEventId);j(e??t)}else j(t);k(!0)}},ce=async t=>{z(!0);try{let n=A?await C.updateEvent(A.id,t):await C.createEvent(t);n.success?(k(!1),Q()):f.error(n.error||e(`calendar.saveFailed`))}catch(t){Y.error(`Failed to save calendar event:`,t),f.error(e(`calendar.saveFailed`))}finally{z(!1)}},le=async()=>{if(A){z(!0);try{let t=await C.deleteEvent(A.id);t.success?(k(!1),Q()):f.error(t.error||e(`calendar.deleteFailed`))}catch(t){Y.error(`Failed to delete calendar event:`,t),f.error(e(`calendar.deleteFailed`))}finally{z(!1)}}},ue=r===`month`?E(u.getFullYear(),u.getMonth(),t.language):new Intl.DateTimeFormat(t.language,{month:`long`,day:`numeric`,year:`numeric`}).format(r===`day`?u:M(u)),de=async()=>{let t=H.trim();if(!t||W)return;G(!0);let n=await C.createCalendar({name:t}).catch(()=>void 0);G(!1),n?.success?(U(``),Q()):f.error(e(`calendar.calendarSaveFailed`))},fe=async t=>{if(await ee({title:e(`calendar.deleteCalendarConfirmTitle`,{name:t.name}),description:e(`calendar.deleteCalendarConfirmDescription`),destructive:!0}))try{let e=await C.deleteCalendar(t.id);if(!e.success)throw Error(e.error);Q()}catch(t){Y.error(`Failed to delete calendar:`,t),f.error(e(`calendar.calendarDeleteFailed`))}},pe=async t=>{try{let e=await C.exportIcs(t),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`calendar.ics`,r.click(),URL.revokeObjectURL(n)}catch(t){Y.error(`Failed to export the calendar:`,t),f.error(e(`calendar.exportFailed`))}},me=async t=>{try{let n=await t.text(),r=await C.importIcs(n);r.success&&r.data?(f.success(e(`calendar.importResult`,{total:r.data.imported})),Q()):f.error(r.error||e(`calendar.importFailed`))}catch(t){Y.error(`Failed to import the calendar:`,t),f.error(e(`calendar.importFailed`))}};return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`calendar-page`,children:[(0,R.jsx)(S,{title:e(`calendar.title`),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`flex items-center rounded-xl bg-black/4 p-0.5 dark:bg-white/6`,children:[`month`,`week`,`day`].map(t=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>s(t),"aria-pressed":r===t,"data-testid":`calendar-view-${t}`,className:a(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas`,r===t?`bg-white text-gray-900 shadow-xs 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,R.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,R.jsx)(b,{size:`sm`,variant:`ghost`,onClick:()=>oe(-1),className:`h-7 w-7 p-0`,title:e(`calendar.previous`),"aria-label":e(`calendar.previous`),children:(0,R.jsx)(p,{className:`h-4 w-4 rtl:rotate-180`})}),(0,R.jsx)(b,{size:`sm`,variant:`ghost`,onClick:()=>d(new Date),className:`h-7 px-2 text-[12px]`,children:e(`calendar.today`)}),(0,R.jsx)(b,{size:`sm`,variant:`ghost`,onClick:()=>oe(1),className:`h-7 w-7 p-0`,title:e(`calendar.next`),"aria-label":e(`calendar.next`),children:(0,R.jsx)(m,{className:`h-4 w-4 rtl:rotate-180`})})]}),(0,R.jsxs)(b,{size:`sm`,onClick:()=>$(u),"data-testid":`calendar-new-event`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,R.jsx)(v,{className:`h-3.5 w-3.5`}),e(`calendar.newEvent`)]})]}),children:(0,R.jsx)(`span`,{className:`text-sm text-ink-muted`,"data-testid":`calendar-range-label`,children:ue})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-black/6 px-4 py-2 dark:border-white/[0.07]`,children:[B.map(t=>(0,R.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-black/8 px-2.5 py-1 text-xs text-gray-700 dark:border-white/10 dark:text-dark-800`,"data-testid":`calendar-chip`,children:[(0,R.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:t.color??`#8b8b8b`}}),(0,R.jsx)(`span`,{className:`truncate`,title:t.name,children:t.name}),t.shared?(0,R.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:e(`calendar.sharedBadge`)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>q(t),className:`-my-1.5 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-ink-muted hover:text-ink`,title:e(`calendar.shareCalendar`),"aria-label":e(`calendar.shareCalendarNamed`,{name:t.name}),"data-testid":`calendar-share`,children:(0,R.jsx)(l,{className:`h-3 w-3`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void fe(t),className:`-my-1.5 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-ink-muted hover:text-error-700`,title:e(`common.delete`),"aria-label":e(`calendar.deleteCalendarNamed`,{name:t.name}),children:(0,R.jsx)(g,{className:`h-3 w-3`})})]})]},t.id)),(0,R.jsxs)(`form`,{className:`flex min-w-0 max-w-full items-center gap-1`,onSubmit:e=>{e.preventDefault(),de()},children:[(0,R.jsx)(`input`,{type:`text`,value:H,disabled:W,onChange:e=>U(e.target.value),placeholder:e(`calendar.newCalendarPlaceholder`),"aria-label":e(`calendar.newCalendarPlaceholder`),className:`min-w-0 w-36 rounded-full border border-dashed border-black/12 bg-transparent px-2.5 py-1 text-base text-gray-700 placeholder:text-gray-400 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas dark:border-white/16 dark:text-dark-800 sm:text-xs`,"data-testid":`calendar-new-calendar`}),(0,R.jsx)(b,{type:`submit`,size:`sm`,variant:`ghost`,disabled:!H.trim(),loading:W,className:`h-7 shrink-0 px-2 text-xs`,"data-testid":`calendar-create-calendar`,children:e(`common.save`)})]}),(0,R.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,R.jsx)(`input`,{ref:J,type:`file`,accept:`.ics,text/calendar`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&me(t),e.target.value=``}}),(0,R.jsxs)(b,{size:`sm`,variant:`ghost`,onClick:()=>J.current?.click(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-import`,children:[(0,R.jsx)(_,{className:`h-3.5 w-3.5`}),e(`calendar.importIcs`)]}),(0,R.jsxs)(b,{size:`sm`,variant:`ghost`,onClick:()=>void pe(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-export`,children:[(0,R.jsx)(c,{className:`h-3.5 w-3.5`}),e(`calendar.exportIcs`)]})]})]}),r===`month`?(0,R.jsx)(te,{year:u.getFullYear(),monthIndex:u.getMonth(),events:ae,onDayClick:e=>$(e),onEventClick:se,onShowDay:e=>{d(e),s(`day`)}}):(0,R.jsx)(ne,{anchor:u,events:ae,dayCount:r===`day`?1:7,onDayClick:(e,t)=>$(e,t),onEventClick:se}),K&&(0,R.jsx)(T,{resourceType:`calendar`,resourceId:K.id,resourceLabel:K.name,onClose:()=>q(null)}),(0,R.jsx)(re,{open:O,event:A,initialStartAt:N,calendars:B.filter(e=>!e.shared||e.shared.permission===`write`),saving:I,onClose:()=>k(!1),onSave:e=>void ce(e),onDelete:()=>void le()})]})};export{X as default};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-vendor-C1iE8mnY.js";import{i as r}from"./router-vendor-qltZAWoz.js";import{i,t as a}from"./utils-BvvV-Cka.js";import{t as o}from"./useTranslation-D9EScZXH.js";import{t as s}from"./chatStore-hzQyRM9H.js";import{t as c}from"./logger-rEW7uQ8m.js";import{$n as l,At as u,Fn as d,It as f,Or as p,Ot as m,Qt as h,V as g,W as _,Zn as v,at as y,dr as ee,n as b,r as x,s as te,st as ne,tr as S,tt as re,ut as ie,v as ae,wn as oe,yr as se,zt as ce}from"./ui-vendor-BTcw5yZ6.js";import{t as C}from"./Button-DwZ26Lqc.js";import{_ as w,g as T,i as le,n as ue,r as E,t as D,v as O}from"./ui-D4Ytvr6d.js";import{t as k}from"./confirmStore-CKkUtP9c.js";import{D as A}from"./api-D6IF0v9_.js";import{t as de}from"./authStore-DdIb6km_.js";import{t as fe}from"./teamEventStream-DOMyufrH.js";var j=e(t(),1),M=n(),pe=[`👍`,`🎉`,`❤️`,`😄`,`👀`,`🚀`],N=180,me=({calls:e})=>{let{t}=o(),[n,r]=(0,j.useState)(!1),i=e.some(e=>e.status===`denied`);return(0,M.jsxs)(`div`,{className:`mt-1`,"data-testid":`channel-tool-calls`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`flex items-center gap-1 text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-dark-600 dark:hover:text-dark-800`,"data-testid":`channel-tool-calls-toggle`,children:[n?(0,M.jsx)(l,{className:`h-3 w-3`}):(0,M.jsx)(v,{className:`h-3 w-3`}),(0,M.jsx)(x,{className:`h-3 w-3`}),t(`channels.toolCalls.summary`,{total:e.length})]}),n&&(0,M.jsxs)(`div`,{className:`mt-1 space-y-1`,children:[e.map(e=>(0,M.jsxs)(`div`,{className:`rounded-lg border border-black/6 px-2 py-1 dark:border-white/8`,"data-testid":`channel-tool-call`,children:[(0,M.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,M.jsx)(`span`,{dir:`ltr`,className:`min-w-0 truncate text-[11px] font-medium text-gray-700 dark:text-dark-800`,children:e.name}),(0,M.jsx)(`span`,{className:a(`shrink-0 text-[10px]`,e.status===`succeeded`?`text-emerald-600 dark:text-emerald-400`:e.status===`denied`?`text-amber-600 dark:text-amber-400`:e.status===`failed`?`text-red-500`:`text-gray-400 dark:text-dark-500`),children:t(`tools.callStatus.${e.status}`)})]}),e.resultPreview&&(0,M.jsx)(`p`,{dir:`ltr`,className:`mt-0.5 whitespace-pre-wrap wrap-break-word font-mono text-[10px] leading-snug text-gray-500 dark:text-dark-600`,children:e.resultPreview.slice(0,N)})]},e.id)),i&&(0,M.jsx)(`p`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`channels.toolCalls.deniedHint`)})]})]})},he=({message:e,currentUserId:t,canModerate:n,actions:r,compact:s=!1})=>{let{t:c,i18n:l}=o(),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(e.content),[h,g]=(0,j.useState)(!1),_=e.authorKind===`model`,v=!_&&e.author?.userId===t&&!e.deleted,x=_?e.model??c(`channels.modelAuthor`):e.author?.username??c(`channels.unknownAuthor`);return(0,M.jsxs)(`div`,{className:a(`group relative rounded-xl px-2.5 py-1.5 hover:bg-black/2.5 dark:hover:bg-white/3`,s&&`px-2 py-1`),"data-testid":`channel-message`,children:[(0,M.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[_&&(0,M.jsx)(ee,{className:`h-3.5 w-3.5 shrink-0 self-center text-primary-500`}),(0,M.jsx)(`span`,{className:a(`shrink-0 text-[13px] font-semibold`,_?`text-primary-600 dark:text-primary-400`:`text-gray-900 dark:text-dark-900`),children:x}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] text-gray-400 dark:text-dark-500`,children:i(e.createdAt,l.language)}),e.editedAt&&!e.deleted&&(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400 dark:text-dark-500`,children:c(`channels.edited`)}),e.pinnedAt&&(0,M.jsx)(y,{role:`img`,"aria-label":c(`channels.pins`),className:`h-3 w-3 shrink-0 text-amber-500`})]}),e.deleted?(0,M.jsx)(`p`,{className:`text-[13px] italic text-gray-400 dark:text-dark-500`,children:c(`channels.deletedMessage`)}):u?(0,M.jsxs)(`div`,{className:`mt-1 flex items-end gap-1.5`,children:[(0,M.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),rows:2,"aria-label":c(`channels.edit`),className:`min-w-0 flex-1 resize-none rounded-lg border border-black/8 bg-transparent px-2 py-1 text-[13px] focus:border-primary-500 focus:outline-hidden focus:ring-2 focus:ring-primary-500/30 dark:border-white/10 dark:text-dark-900`,"data-testid":`channel-message-edit`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>{r.onEdit(e,f),d(!1)},"aria-label":c(`channels.confirmEdit`),title:c(`channels.confirmEdit`),className:`rounded-md p-1.5 text-emerald-600 hover:bg-emerald-50 dark:hover:bg-emerald-900/20`,children:(0,M.jsx)(S,{className:`h-3.5 w-3.5`})}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>d(!1),"aria-label":c(`channels.cancelEdit`),title:c(`channels.cancelEdit`),className:`rounded-md p-1.5 text-gray-400 hover:bg-black/4 dark:hover:bg-white/6`,children:(0,M.jsx)(b,{className:`h-3.5 w-3.5`})})]}):(0,M.jsxs)(M.Fragment,{children:[e.pending?(0,M.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[13px] text-gray-400 dark:text-dark-500`,children:[(0,M.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),c(`channels.modelThinking`)]}):e.error?(0,M.jsx)(`p`,{className:`text-[13px] text-red-500`,children:e.error}):(0,M.jsx)(`p`,{className:`whitespace-pre-wrap wrap-break-word text-[13px] leading-relaxed text-gray-800 dark:text-dark-800`,children:e.content}),_&&(e.toolCalls?.length??0)>0&&(0,M.jsx)(me,{calls:e.toolCalls}),(e.attachments?.length??0)>0&&(0,M.jsx)(`div`,{className:`mt-1 space-y-1`,children:e.attachments.map(e=>(0,M.jsxs)(`button`,{type:`button`,onClick:()=>void r.onDownload(e.id,e.filename),className:`flex items-center gap-1.5 rounded-lg border border-black/6 px-2 py-1 text-[12px] text-gray-600 hover:bg-black/3 dark:border-white/8 dark:text-dark-700 dark:hover:bg-white/4`,"data-testid":`channel-attachment`,children:[(0,M.jsx)(ie,{className:`h-3 w-3`}),(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:e.filename})]},e.id))})]}),(e.reactions?.length??0)>0&&(0,M.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.reactions.map(t=>(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":t.mine,onClick:()=>void r.onReact(e,t.emoji,t.mine),className:a(`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/8 text-gray-600 hover:bg-black/3 dark:border-white/10 dark:text-dark-700`),"data-testid":`channel-reaction`,children:[t.emoji,` `,t.count]},t.emoji))}),!s&&(e.replyCount??0)>0&&r.onReply&&(0,M.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,M.jsx)(m,{className:`h-3 w-3`}),c(`channels.replyCount`,{total:e.replyCount})]}),!e.deleted&&!u&&(0,M.jsxs)(`div`,{className:`absolute -top-2.5 inset-e-2 hidden items-center gap-0.5 rounded-lg border border-black/8 bg-white px-1 py-0.5 shadow-xs group-focus-within:flex group-hover:flex [@media(hover:none)]:flex dark:border-white/10 dark:bg-dark-50`,children:[(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`rounded-sm p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:c(`channels.react`),"aria-label":c(`channels.react`),"aria-haspopup":`true`,"aria-expanded":h,"data-testid":`channel-react`,children:(0,M.jsx)(oe,{className:`h-3.5 w-3.5`})}),h&&(0,M.jsx)(`div`,{className:`absolute inset-e-0 top-6 z-10 flex gap-0.5 rounded-lg border border-black/8 bg-white p-1 shadow-md dark:border-white/10 dark:bg-dark-50`,children:pe.map(t=>(0,M.jsx)(`button`,{type:`button`,onClick:()=>{let n=!!e.reactions?.find(e=>e.emoji===t)?.mine;r.onReact(e,t,n),g(!1)},"aria-label":c(`channels.reactWith`,{emoji:t}),className:`rounded-sm p-0.5 text-sm hover:bg-black/5 dark:hover:bg-white/8`,children:t},t))})]}),r.onReply&&!e.parentId&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>r.onReply(e),className:`rounded-sm p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:c(`channels.reply`),"aria-label":c(`channels.reply`),"data-testid":`channel-reply`,children:(0,M.jsx)(m,{className:`h-3.5 w-3.5`})}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>void r.onPin(e),className:`rounded-sm p-1 text-gray-400 hover:text-amber-500`,title:e.pinnedAt?c(`channels.unpin`):c(`channels.pin`),"aria-label":e.pinnedAt?c(`channels.unpin`):c(`channels.pin`),"data-testid":`channel-pin`,children:(0,M.jsx)(y,{className:`h-3.5 w-3.5`})}),v&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>{p(e.content),d(!0)},className:`rounded-sm p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:c(`channels.edit`),"aria-label":c(`channels.edit`),"data-testid":`channel-edit`,children:(0,M.jsx)(ne,{className:`h-3.5 w-3.5`})}),(v||n)&&(0,M.jsx)(`button`,{type:`button`,onClick:async()=>{await k({title:c(`channels.deleteMessageConfirmTitle`),description:c(`channels.deleteMessageConfirmDescription`),destructive:!0})&&await r.onDelete(e)},className:`rounded-sm p-1 text-gray-400 hover:text-red-500`,title:c(`channels.deleteMessage`),"aria-label":c(`channels.deleteMessage`),"data-testid":`channel-delete-message`,children:(0,M.jsx)(ae,{className:`h-3.5 w-3.5`})})]})]})},P=c(`pages:channels`),ge=e=>e.type===`dm`?(0,M.jsx)(u,{className:`h-3.5 w-3.5 shrink-0`}):e.type===`private`?(0,M.jsx)(f,{className:`h-3.5 w-3.5 shrink-0`}):(0,M.jsx)(h,{className:`h-3.5 w-3.5 shrink-0`}),_e=e=>e.type===`dm`?e.dmPeer?.username??`…`:e.name,ve=()=>{let{t:e}=o(),t=de(e=>e.user),n=s(e=>e.models),[i,c]=(0,j.useState)([]),[l,f]=(0,j.useState)(null),[v,x]=(0,j.useState)(!1),[ne,S]=(0,j.useState)(!1),[ae,oe]=(0,j.useState)(!0),[w,T]=(0,j.useState)(null),[D,O]=(0,j.useState)(null),[pe,N]=(0,j.useState)([]),[me,ve]=(0,j.useState)([]),[F,I]=(0,j.useState)(null),[L,R]=(0,j.useState)(null),[Ce,we]=(0,j.useState)([]),[z,Te]=(0,j.useState)(``),[B,Ee]=(0,j.useState)(``),[V,De]=(0,j.useState)(!1),[H,Oe]=(0,j.useState)(null),[ke,Ae]=(0,j.useState)(!1),[je,U]=(0,j.useState)(!1),[W,Me]=(0,j.useState)(``),[Ne,G]=(0,j.useState)(!1),Pe=(0,j.useRef)(null),Fe=(0,j.useRef)(null),[Ie,Le]=r(),K=(0,j.useMemo)(()=>i.find(e=>e.id===w)??null,[i,w]),[Re,ze]=(0,j.useState)(null);w!==Re&&(ze(w),O(null),R(null),I(null));let q=K?.role===`owner`,J=(0,j.useCallback)(()=>{A.listMine().then(e=>{e.success&&e.data&&c(e.data)}).catch(e=>P.error(`Failed to load channels:`,e)).finally(()=>oe(!1))},[]);(0,j.useEffect)(()=>{J();let e=window.setInterval(J,3e4);return()=>window.clearInterval(e)},[J]);let Y=Ie.get(`channel`);Y&&w!==Y&&T(Y),(0,j.useEffect)(()=>{Y&&Le({},{replace:!0})},[Y,Le]);let X=(0,j.useRef)(null);(0,j.useLayoutEffect)(()=>(X.current=w?{channelId:w,requestId:0}:null,()=>{X.current=null}),[w]);let Z=(0,j.useCallback)(t=>{let n=X.current;if(!n||n.channelId!==t)return;let r=++n.requestId;A.listMessages(t,{limit:100}).then(e=>{X.current===n&&n.requestId===r&&e.success&&e.data&&O(e.data)}).catch(t=>{P.error(`Failed to load messages:`,t),p.error(e(`channels.loadFailed`),{id:`channels-load-failed`})})},[e]),Be=(0,j.useRef)(null);(0,j.useEffect)(()=>{Be.current=L},[L]);let Ve=(0,j.useCallback)(e=>{Z(e),A.markRead(e);let t=Be.current;t&&A.thread(t).then(e=>{e.success&&e.data&&we(e.data)}).catch(e=>P.error(`Failed to refresh thread:`,e))},[Z]);(0,j.useEffect)(()=>{if(!w)return;Z(w),A.markRead(w).then(J);let e=new AbortController;return fe({path:`/channels/${w}/events`,signal:e.signal,onEvent:()=>Ve(w)}),()=>e.abort()},[w,Z,J,Ve]);let He=D?.length??0;(0,j.useEffect)(()=>{let e=Fe.current;e&&(e.scrollTop=e.scrollHeight)},[He,w]),(0,j.useEffect)(()=>{if(!w||!F)return;let t=t=>{P.error(`Failed to load channel panel:`,t),p.error(e(`channels.loadFailed`))};F===`members`?A.listMembers(w).then(e=>{e.success&&e.data?N(e.data):t(e.error)}).catch(t):A.listPins(w).then(e=>{e.success&&e.data?ve(e.data):t(e.error)}).catch(t)},[w,F,e]),(0,j.useEffect)(()=>{L&&A.thread(L).then(t=>{t.success&&t.data?we(t.data):p.error(e(`channels.loadFailed`))}).catch(t=>{P.error(`Failed to load thread:`,t),p.error(e(`channels.loadFailed`))})},[L,e]);let Ue=()=>{x(!0),S(!1),A.listPublic().then(e=>{e.success&&e.data?f(e.data):S(!0)}).catch(e=>{P.error(`Failed to load public channels:`,e),S(!0)})},Q=async t=>{if(!w||V)return;let n=z.trim();if(n||H){De(!0);try{let r=await A.postMessage(w,{content:n,...t?{parentId:t}:{},...H?{attachmentIds:[H.id]}:{},...B?{mentionModel:B}:{}});if(r.success){if(Te(``),Oe(null),Ee(``),Z(w),t){let e=await A.thread(t);e.success&&e.data&&we(e.data)}}else p.error(r.error||e(`channels.sendFailed`))}catch(t){P.error(`Failed to send message:`,t),p.error(e(`channels.sendFailed`))}finally{De(!1)}}},We=async t=>{if(w)try{let n=await A.uploadAttachment(w,t);n.success&&n.data?Oe({id:n.data.id,filename:n.data.filename}):p.error(n.error||e(`channels.uploadFailed`))}catch(t){P.error(`Failed to upload attachment:`,t),p.error(e(`channels.uploadFailed`))}},Ge=async()=>{if(w&&W.trim()){if((await A.addMember(w,W.trim()).catch(()=>void 0))?.success){Me(``);let t=await A.listMembers(w).catch(()=>void 0);t?.success&&t.data&&N(t.data),p.success(e(`channels.memberAdded`))}else p.error(e(`channels.memberAddFailed`))}},Ke={onReply:e=>R(e.id),onEdit:async(t,n)=>{(await A.editMessage(t.id,n).catch(()=>void 0))?.success?w&&Z(w):p.error(e(`channels.editFailed`))},onDelete:async t=>{(await A.deleteMessage(t.id).catch(()=>void 0))?.success?w&&Z(w):p.error(e(`channels.deleteMessageFailed`))},onPin:async t=>{(await A.setPinned(t.id,!t.pinnedAt).catch(()=>void 0))?.success||p.error(e(`channels.pinFailed`)),w&&Z(w)},onReact:async(t,n,r)=>{(await(r?A.removeReaction(t.id,n):A.addReaction(t.id,n)).catch(()=>void 0))?.success||p.error(e(`channels.reactFailed`)),w&&Z(w)},onDownload:async(t,n)=>{try{let e=await A.downloadAttachment(t),r=URL.createObjectURL(e),i=document.createElement(`a`);i.href=r,i.download=n,i.click(),URL.revokeObjectURL(r)}catch(t){P.error(`Failed to download attachment:`,t),p.error(e(`channels.downloadFailed`))}}},$=Ce[0];return(0,M.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,M.jsxs)(`aside`,{className:a(`flex w-64 shrink-0 flex-col border-e border-black/6 dark:border-white/6`,w?`hidden md:flex`:`flex`),"data-testid":`channel-rail`,children:[(0,M.jsx)(le,{title:e(`channels.title`),className:`gap-y-1 px-3`,actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,onClick:Ue,title:e(`channels.browsePublic`),"aria-label":e(`channels.browsePublic`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/4 dark:text-dark-600 dark:hover:bg-white/6`,"data-testid":`channels-browse`,children:(0,M.jsx)(d,{className:`h-4 w-4`})}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>U(!0),title:e(`channels.newDm`),"aria-label":e(`channels.newDm`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/4 dark:text-dark-600 dark:hover:bg-white/6`,"data-testid":`channels-new-dm`,children:(0,M.jsx)(u,{className:`h-4 w-4`})}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Ae(!0),title:e(`channels.newChannel`),"aria-label":e(`channels.newChannel`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/4 dark:text-dark-600 dark:hover:bg-white/6`,"data-testid":`channels-new`,children:(0,M.jsx)(re,{className:`h-4 w-4`})})]})}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:ae?(0,M.jsx)(ue,{size:`sm`,srOnly:!0}):i.length===0?(0,M.jsx)(E,{icon:h,size:`sm`,title:e(`channels.empty`)}):i.map(t=>(0,M.jsxs)(`button`,{type:`button`,onClick:()=>T(t.id),className:a(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-[13px]`,w===t.id?`bg-black/5 text-gray-900 dark:bg-white/8 dark:text-dark-900`:`text-gray-600 hover:bg-black/3 dark:text-dark-700 dark:hover:bg-white/4`),"data-testid":`channel-item`,children:[ge(t),(0,M.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:_e(t)}),(t.unreadCount??0)>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`rounded-full bg-primary-600 px-1.5 text-[10px] font-semibold leading-4 text-white`,"data-testid":`channel-unread`,"aria-hidden":`true`,children:t.unreadCount}),(0,M.jsx)(`span`,{className:`sr-only`,children:e(`channels.unreadCount`,{total:t.unreadCount})})]})]},t.id))})]}),(0,M.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:K?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-black/6 px-4 py-2.5 dark:border-white/6`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>T(null),"aria-label":e(`common.back`),title:e(`common.back`),className:`rounded-md p-1 text-gray-500 hover:bg-black/4 md:hidden dark:text-dark-600`,children:(0,M.jsx)(se,{className:`h-4 w-4 rtl:rotate-180`})}),ge(K),(0,M.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:_e(K)}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>I(F===`pins`?null:`pins`),title:e(`channels.pins`),"aria-label":e(`channels.pins`),"aria-pressed":F===`pins`,className:`rounded-md p-1.5 text-gray-500 hover:bg-black/4 dark:text-dark-600 dark:hover:bg-white/6`,"data-testid":`channel-pins-toggle`,children:(0,M.jsx)(y,{className:`h-4 w-4`})}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>I(F===`members`?null:`members`),title:e(`channels.members`),"aria-label":e(`channels.members`),"aria-pressed":F===`members`,className:`rounded-md p-1.5 text-gray-500 hover:bg-black/4 dark:text-dark-600 dark:hover:bg-white/6`,"data-testid":`channel-members-toggle`,children:(0,M.jsx)(te,{className:`h-4 w-4`})}),q&&K.type!==`dm`&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>G(!0),title:e(`channels.settings`),"aria-label":e(`channels.settings`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/4 dark:text-dark-600 dark:hover:bg-white/6`,"data-testid":`channel-settings`,children:(0,M.jsx)(g,{className:`h-4 w-4`})})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,M.jsx)(`div`,{ref:Fe,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-4 py-3 scrollbar-thin`,"data-testid":`channel-timeline`,children:D===null?(0,M.jsx)(ue,{size:`sm`,srOnly:!0}):D.length===0?(0,M.jsx)(E,{icon:m,size:`sm`,title:e(`channels.noMessages`)}):D.map(e=>(0,M.jsx)(he,{message:e,currentUserId:t?.id,canModerate:q,actions:Ke},e.id))}),(0,M.jsxs)(`div`,{className:`border-t border-black/6 p-3 dark:border-white/6`,children:[H&&(0,M.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-lg border border-black/6 px-2.5 py-1.5 text-xs text-gray-600 dark:border-white/8 dark:text-dark-700`,children:[(0,M.jsx)(ie,{className:`h-3.5 w-3.5`}),(0,M.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:H.filename}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Oe(null),"aria-label":e(`channels.removeAttachment`),title:e(`channels.removeAttachment`),className:`rounded-sm p-0.5 text-gray-500 hover:text-red-500`,children:(0,M.jsx)(b,{className:`h-3.5 w-3.5`})})]}),(0,M.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,M.jsx)(`input`,{ref:Pe,type:`file`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&We(t),e.target.value=``}}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Pe.current?.click(),title:e(`channels.attach`),"aria-label":e(`channels.attach`),className:`rounded-md p-2 text-gray-500 hover:bg-black/4 dark:text-dark-600 dark:hover:bg-white/6`,"data-testid":`channel-attach`,children:(0,M.jsx)(ie,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(ee,{className:a(`h-4 w-4`,B?`text-primary-500`:`text-gray-400 dark:text-dark-500`)}),(0,M.jsxs)(`select`,{value:B,onChange:e=>Ee(e.target.value),className:`max-w-[130px] rounded-md border border-black/8 bg-transparent px-1 py-1 text-[11px] text-gray-600 focus:border-primary-500 focus:outline-hidden focus:ring-2 focus:ring-primary-500/30 dark:border-white/10 dark:bg-dark-100 dark:text-dark-700`,title:e(`channels.askModel`),"aria-label":e(`channels.askModel`),"data-testid":`channel-mention-model`,children:[(0,M.jsx)(`option`,{value:``,children:e(`channels.noModel`)}),n.map(e=>(0,M.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,M.jsx)(`textarea`,{value:z,onChange:e=>Te(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),Q())},rows:1,placeholder:e(`channels.composerPlaceholder`),"aria-label":e(`channels.composerPlaceholder`),className:`max-h-32 min-w-0 flex-1 resize-none rounded-xl border border-black/8 bg-transparent px-3 py-2 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500 focus:outline-hidden focus:ring-2 focus:ring-primary-500/30 dark:border-white/10 dark:text-dark-900`,"data-testid":`channel-composer`}),(0,M.jsx)(C,{size:`sm`,disabled:V||!z.trim()&&!H,onClick:()=>void Q(),"aria-label":e(`channels.send`),title:e(`channels.send`),"data-testid":`channel-send`,children:V?(0,M.jsx)(ce,{className:`h-4 w-4 animate-spin`}):(0,M.jsx)(_,{className:`h-4 w-4`})})]})]})]}),L&&(0,M.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col border-s border-black/6 dark:border-white/6`,"data-testid":`channel-thread`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/6 px-3 py-2 dark:border-white/6`,children:[(0,M.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(`channels.thread`)}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>R(null),"aria-label":e(`channels.closeThread`),title:e(`channels.closeThread`),className:`rounded-md p-1 text-gray-400 hover:bg-black/4 dark:hover:bg-white/6`,children:(0,M.jsx)(b,{className:`h-3.5 w-3.5`})})]}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3 py-2 scrollbar-thin`,children:Ce.map(e=>(0,M.jsx)(he,{message:e,currentUserId:t?.id,canModerate:q,actions:{...Ke,onReply:void 0},compact:!0},e.id))}),(0,M.jsxs)(`div`,{className:`flex items-end gap-1.5 border-t border-black/6 p-2 dark:border-white/6`,children:[(0,M.jsx)(`textarea`,{value:z,onChange:e=>Te(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),$&&Q($.id))},rows:1,placeholder:e(`channels.replyPlaceholder`),"aria-label":e(`channels.replyPlaceholder`),className:`min-w-0 flex-1 resize-none rounded-lg border border-black/8 bg-transparent px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500 focus:outline-hidden focus:ring-2 focus:ring-primary-500/30 dark:border-white/10 dark:text-dark-900`,"data-testid":`channel-thread-composer`}),(0,M.jsx)(C,{size:`sm`,disabled:V||!z.trim(),onClick:()=>$&&void Q($.id),"aria-label":e(`channels.send`),title:e(`channels.send`),children:(0,M.jsx)(_,{className:`h-3.5 w-3.5`})})]})]}),F&&(0,M.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-s border-black/6 dark:border-white/6`,"data-testid":`channel-${F}-panel`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/6 px-3 py-2 dark:border-white/6`,children:[(0,M.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(F===`members`?`channels.members`:`channels.pins`)}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>I(null),"aria-label":e(`common.close`),title:e(`common.close`),className:`rounded-md p-1 text-gray-400 hover:bg-black/4 dark:hover:bg-white/6`,children:(0,M.jsx)(b,{className:`h-3.5 w-3.5`})})]}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto px-3 py-2 scrollbar-thin`,children:F===`members`?(0,M.jsxs)(M.Fragment,{children:[q&&K.type===`private`&&(0,M.jsxs)(`div`,{className:`mb-2 flex gap-1.5`,children:[(0,M.jsx)(`input`,{type:`text`,value:W,onChange:e=>Me(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&Ge()},placeholder:e(`channels.invitePlaceholder`),"aria-label":e(`channels.invitePlaceholder`),className:`min-w-0 flex-1 rounded-lg border border-black/8 bg-transparent px-2 py-1 text-xs focus:border-primary-500 focus:outline-hidden focus:ring-2 focus:ring-primary-500/30 dark:border-white/10 dark:text-dark-800`,"data-testid":`channel-invite-name`}),(0,M.jsx)(C,{size:`sm`,disabled:!W.trim(),onClick:()=>void Ge(),"aria-label":e(`channels.invite`),title:e(`channels.invite`),"data-testid":`channel-invite-submit`,children:(0,M.jsx)(re,{className:`h-3.5 w-3.5`})})]}),pe.map(n=>(0,M.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,M.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.username}),(0,M.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,M.jsx)(`button`,{type:`button`,onClick:async()=>{await k({title:e(`channels.removeMemberConfirm`,{name:n.username}),description:e(`channels.removeMemberConfirmDescription`),confirmLabel:e(`common.remove`),destructive:!0})&&((await A.removeMember(K.id,n.userId).catch(()=>void 0))?.success?N(e=>e.filter(e=>e.userId!==n.userId)):p.error(e(`channels.removeMemberFailed`)))},className:`rounded-sm p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,title:e(`channels.removeMember`),"aria-label":e(`channels.removeMemberNamed`,{name:n.username}),children:(0,M.jsx)(b,{className:`h-3 w-3`})})]},n.userId)),!q&&K.type!==`dm`&&(0,M.jsx)(C,{size:`sm`,variant:`ghost`,className:`mt-2 w-full text-red-500`,onClick:async()=>{await k({title:e(`channels.leaveConfirm`,{name:_e(K)}),description:e(`channels.leaveConfirmDescription`),confirmLabel:e(`channels.leave`),destructive:!0})&&((await A.removeMember(K.id,t?.id??``).catch(()=>void 0))?.success?(T(null),J()):p.error(e(`channels.leaveFailed`)))},"data-testid":`channel-leave`,children:e(`channels.leave`)})]}):me.length===0?(0,M.jsx)(`p`,{className:`pt-4 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.noPins`)}):me.map(e=>(0,M.jsx)(he,{message:e,currentUserId:t?.id,canModerate:q,actions:Ke,compact:!0},e.id))})]})]})]}):(0,M.jsx)(E,{icon:m,title:e(`channels.selectPrompt`),className:`flex-1 justify-center`})}),ke&&(0,M.jsx)(ye,{onClose:()=>Ae(!1),onCreated:e=>{Ae(!1),J(),T(e.id)}}),je&&(0,M.jsx)(be,{onClose:()=>U(!1),onOpened:e=>{U(!1),J(),T(e.id)}}),v&&(0,M.jsx)(xe,{channels:l,failed:ne,onRetry:Ue,onClose:()=>x(!1),onJoined:e=>{x(!1),J(),T(e)}}),Ne&&K&&(0,M.jsx)(Se,{channel:K,onClose:()=>G(!1),onChanged:()=>{G(!1),J()},onDeleted:()=>{G(!1),T(null),J()}})]})},ye=({onClose:e,onCreated:t})=>{let{t:n}=o(),[r,i]=(0,j.useState)(``),[a,s]=(0,j.useState)(`public`),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(!1);return(0,M.jsxs)(T,{titleId:`create-channel-title`,title:n(`channels.newChannel`),onClose:e,testId:`create-channel-modal`,footer:(0,M.jsx)(C,{size:`sm`,disabled:u||!r.trim(),onClick:()=>{d(!0),A.create({type:a,name:r.trim(),...c.trim()?{description:c.trim()}:{}}).then(e=>{e.success&&e.data?t(e.data):p.error(e.error||n(`channels.createFailed`))}).catch(()=>p.error(n(`channels.createFailed`))).finally(()=>d(!1))},"data-testid":`create-channel-submit`,children:n(`channels.create`)}),children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`label`,{htmlFor:`create-channel-name`,className:O,children:n(`channels.nameLabel`)}),(0,M.jsx)(`input`,{id:`create-channel-name`,className:w,value:r,onChange:e=>i(e.target.value),"data-testid":`create-channel-name`})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`label`,{htmlFor:`create-channel-type`,className:O,children:n(`channels.typeLabel`)}),(0,M.jsxs)(`select`,{id:`create-channel-type`,className:w,value:a,onChange:e=>s(e.target.value),"data-testid":`create-channel-type`,children:[(0,M.jsx)(`option`,{value:`public`,children:n(`channels.typePublic`)}),(0,M.jsx)(`option`,{value:`private`,children:n(`channels.typePrivate`)})]})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`label`,{htmlFor:`create-channel-description`,className:O,children:n(`channels.descriptionLabel`)}),(0,M.jsx)(`textarea`,{id:`create-channel-description`,className:w,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})},be=({onClose:e,onOpened:t})=>{let{t:n}=o(),[r,i]=(0,j.useState)(``),[a,s]=(0,j.useState)(!1),c=()=>{r.trim()&&(s(!0),A.openDm(r.trim()).then(e=>{e.success&&e.data?t(e.data):p.error(e.error||n(`channels.dmFailed`))}).catch(()=>p.error(n(`channels.dmFailed`))).finally(()=>s(!1)))};return(0,M.jsx)(T,{titleId:`open-dm-title`,title:n(`channels.newDm`),subtitle:n(`channels.dmHint`),onClose:e,testId:`open-dm-modal`,footer:(0,M.jsx)(C,{size:`sm`,disabled:a||!r.trim(),onClick:c,"data-testid":`open-dm-submit`,children:n(`channels.openDm`)}),children:(0,M.jsx)(`input`,{className:w,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},placeholder:n(`channels.dmPlaceholder`),"aria-label":n(`channels.dmPlaceholder`),"data-testid":`open-dm-username`})})},xe=({channels:e,failed:t,onRetry:n,onClose:r,onJoined:i})=>{let{t:a}=o();return(0,M.jsx)(T,{titleId:`browse-channels-title`,title:a(`channels.browsePublic`),onClose:r,testId:`browse-channels-modal`,children:t&&e===null?(0,M.jsx)(D,{size:`sm`,message:a(`channels.loadFailed`),onRetry:n}):e===null?(0,M.jsx)(ue,{size:`sm`,srOnly:!0}):e.length===0?(0,M.jsx)(E,{icon:d,size:`sm`,title:a(`channels.noPublic`)}):e.map(e=>(0,M.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-black/6 px-3 py-2 dark:border-white/8`,"data-testid":`browse-channel-item`,children:[(0,M.jsx)(h,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,M.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.name}),e.isMember?(0,M.jsx)(`span`,{className:`text-[11px] text-gray-400`,children:a(`channels.joined`)}):(0,M.jsx)(C,{size:`sm`,onClick:()=>void A.join(e.id).then(t=>{t.success?i(e.id):p.error(a(`channels.joinFailed`))}).catch(()=>p.error(a(`channels.joinFailed`))),"data-testid":`browse-channel-join`,children:a(`channels.join`)})]},e.id))})},Se=({channel:e,onClose:t,onChanged:n,onDeleted:r})=>{let{t:i}=o(),[a,s]=(0,j.useState)(e.name),[c,l]=(0,j.useState)(e.description??``),[u,d]=(0,j.useState)(!1);return(0,M.jsxs)(T,{titleId:`channel-settings-title`,title:i(`channels.settings`),onClose:t,testId:`channel-settings-modal`,footer:(0,M.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,M.jsx)(C,{size:`sm`,variant:`ghost`,className:`text-red-500`,onClick:async()=>{await k({title:i(`channels.deleteConfirm`,{name:e.name}),description:i(`channels.deleteConfirmDescription`),confirmLabel:i(`channels.delete`),destructive:!0})&&((await A.delete(e.id).catch(()=>void 0))?.success?r():p.error(i(`channels.deleteFailed`)))},"data-testid":`channel-delete`,children:i(`channels.delete`)}),(0,M.jsx)(C,{size:`sm`,disabled:u||!a.trim(),onClick:()=>{d(!0),A.update(e.id,{name:a.trim(),description:c.trim()}).then(e=>{e.success?n():p.error(i(`channels.saveFailed`))}).catch(()=>p.error(i(`channels.saveFailed`))).finally(()=>d(!1))},"data-testid":`channel-settings-save`,children:i(`channels.save`)})]}),children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`label`,{htmlFor:`channel-settings-name`,className:O,children:i(`channels.nameLabel`)}),(0,M.jsx)(`input`,{id:`channel-settings-name`,className:w,value:a,onChange:e=>s(e.target.value)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`label`,{htmlFor:`channel-settings-description`,className:O,children:i(`channels.descriptionLabel`)}),(0,M.jsx)(`textarea`,{id:`channel-settings-description`,className:w,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})};export{ve as default};