@xopcai/xopc 0.0.457 → 0.0.460

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 (47) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/automation-display-DaVDNZz8.js +2 -0
  4. package/dist/gateway/static/root/assets/automation-task-card-CiJmJ7_h.js +2 -0
  5. package/dist/gateway/static/root/assets/{automations-page-BSnPWyYd.js → automations-page-CVjgENMO.js} +1 -1
  6. package/dist/gateway/static/root/assets/automations-workspace-CGPWyL0P.js +9 -0
  7. package/dist/gateway/static/root/assets/capabilities-page-D2hq4cgE.js +2 -0
  8. package/dist/gateway/static/root/assets/{chat-page-Bx_A__qB.js → chat-page-BhPw56Vc.js} +5 -5
  9. package/dist/gateway/static/root/assets/connectors-page-DyzDVVfz.js +1 -0
  10. package/dist/gateway/static/root/assets/home-page-BPPe4JXB.js +7 -0
  11. package/dist/gateway/static/root/assets/index-DjzrnmBA.js +11 -0
  12. package/dist/gateway/static/root/assets/index-YQxumvaS.css +1 -0
  13. package/dist/gateway/static/root/assets/note-detail-panel-BbHlfAju.js +7 -0
  14. package/dist/gateway/static/root/assets/{notes-page-Do0l5Ddr.js → notes-page-8w2Stfak.js} +1 -1
  15. package/dist/gateway/static/root/assets/personal-page-BwfyW7Hx.js +1 -0
  16. package/dist/gateway/static/root/assets/personal-profile-settings-CQhZjoK6.js +1 -0
  17. package/dist/gateway/static/root/assets/{personal-settings-panel-BppxtWBl.js → personal-settings-panel-peD05ktj.js} +1 -1
  18. package/dist/gateway/static/root/assets/product-preview-content-WkF2j_c-.js +1 -0
  19. package/dist/gateway/static/root/assets/{product-preview-modal-BUeyRD5W.js → product-preview-modal-DMHOKocl.js} +2 -2
  20. package/dist/gateway/static/root/assets/{project-detail-page-D3k1NzXQ.js → project-detail-page-CNFuzmRr.js} +1 -1
  21. package/dist/gateway/static/root/assets/route-preload-CuxNu-LB.js +2 -0
  22. package/dist/gateway/static/root/assets/routine-panel-CXs4PjW0.js +2 -0
  23. package/dist/gateway/static/root/assets/service-recommendation-list-DDlMyPvC.js +1 -0
  24. package/dist/gateway/static/root/assets/{settings-page-CGiZCF8z.js → settings-page-BHImcF1q.js} +1 -1
  25. package/dist/gateway/static/root/assets/task-detail-page-_5TEldtl.js +3 -0
  26. package/dist/gateway/static/root/assets/{work-discovery-overlay-BNZK4hQ4.js → work-discovery-overlay-UvWbDUXi.js} +1 -1
  27. package/dist/gateway/static/root/assets/{work-discovery-page-KwSPhukU.js → work-discovery-page-BM1HsYz6.js} +1 -1
  28. package/dist/gateway/static/root/index.html +10 -10
  29. package/dist/package.js +1 -1
  30. package/dist/src/storage/sqlite/conversation-repository.js +4 -1
  31. package/package.json +1 -1
  32. package/dist/gateway/static/root/assets/automation-task-card-BjqxvYqc.js +0 -3
  33. package/dist/gateway/static/root/assets/automations-workspace-DIaCdxtX.js +0 -9
  34. package/dist/gateway/static/root/assets/calendar-clock-D-quYVPe.js +0 -1
  35. package/dist/gateway/static/root/assets/capabilities-page-dXDa0i5o.js +0 -2
  36. package/dist/gateway/static/root/assets/connectors-page-BwJHhyRb.js +0 -1
  37. package/dist/gateway/static/root/assets/home-page-D1sTZYAY.js +0 -3
  38. package/dist/gateway/static/root/assets/index-CHAVhyVb.js +0 -11
  39. package/dist/gateway/static/root/assets/index-CQABygtM.css +0 -1
  40. package/dist/gateway/static/root/assets/note-detail-panel-B1cq9sU2.js +0 -7
  41. package/dist/gateway/static/root/assets/personal-page-DrYh0NPE.js +0 -1
  42. package/dist/gateway/static/root/assets/personal-profile-settings-HMQY9lz9.js +0 -1
  43. package/dist/gateway/static/root/assets/product-preview-content-CUaHxyiE.js +0 -1
  44. package/dist/gateway/static/root/assets/route-preload-CTuS4GFj.js +0 -2
  45. package/dist/gateway/static/root/assets/routine-panel-9UC3NU5V.js +0 -2
  46. package/dist/gateway/static/root/assets/service-recommendation-list-8mVIWB38.js +0 -1
  47. package/dist/gateway/static/root/assets/task-detail-page-CWwwumsy.js +0 -3
@@ -0,0 +1,7 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-CmnkluMF.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/locale-store-Dy1EByeG.js","assets/messages-BAnhwALN.js","assets/unlink-BEuthaaq.js","assets/createLucideIcon-DPHK1VkS.js","assets/check-DUBLcKHA.js","assets/copy-Dv6d4Dvw.js","assets/external-link-DjqjBmc3.js","assets/notes-api-CdXA-g9r.js","assets/dist-CY7CS_D3.js","assets/es2015-DBLcMg5B.js","assets/dist-CxGUk8J-.js","assets/download-Dk-ZjtO6.js","assets/markdown-view-BlxIaCCQ.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/preload-helper-Czpn1I53.js","assets/file-image-CDUPkZvG.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/app-link-DImAfVs5.js","assets/product-delivery-BFfqdKLe.js","assets/schemas-CCWMleym.js","assets/local-apps-DeqzkJiF.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/xml-_d7dTN2Q.js","assets/mermaid-render-oOellPHt.js","assets/markdown-view-DG8DDkEA.css","assets/chat-chart-block-stPJEZ90.js","assets/skeleton-DzdOeGYz.js","assets/list-todo-CTVRto8O.js","assets/loader-circle-CifKLtgG.js","assets/mic-CuUb7zc-.js","assets/pause-DuPxgSxk.js","assets/pencil-DmIY3Oa-.js","assets/play-kxZvpBg8.js","assets/vendor-swr-CdRzEUwF.js","assets/floating-ui.dom-seOukHzT.js","assets/linkify-it-BkqEorO0.js","assets/vendor-codemirror-aCQ0FcJT.js","assets/with-selector-xonYxPoM.js","assets/note-image-lightbox-CqK_uJ6Y.js","assets/block-editor-Cvy3D_4T.css","assets/markdown-editor-CjQJ-Nho.js","assets/languages-kF11aUYU.js","assets/chat-page-BhPw56Vc.js","assets/app-window-DXFNqt_0.js","assets/archive-Dz0hferG.js","assets/arrow-left-D880xG-P.js","assets/arrow-up-right-T72JbQ1Q.js","assets/arrow-up-D5ZtR1QT.js","assets/product-automation-feedback-D51I7Lg3.js","assets/activity-YogQEteU.js","assets/bot-DjLkhyZL.js","assets/circle-check-C23XjkUj.js","assets/circle-pause-CN9jYH2s.js","assets/clock-3-DnrAnuyZ.js","assets/message-square-fVE7Ghj1.js","assets/rotate-ccw-JM1TBLpp.js","assets/rotate-cw-LIg3Am9S.js","assets/sparkles-DHlfQFAF.js","assets/triangle-alert-2JXFNNKU.js","assets/volume-2-BSJhAY97.js","assets/zap-dximCGjy.js","assets/button-Cc4hUNTt.js","assets/automation-api-DxBmyzp0.js","assets/earth-C9Z4bTTG.js","assets/chevron-down-ccbiQQz_.js","assets/chevron-right-BweFrslA.js","assets/working-directory-picker-modal-BGZduAXV.js","assets/file-archive-DanfQJNe.js","assets/interaction-BdhHBbYa.js","assets/form-field-width-DJw_jULe.js","assets/settings-form-draft-Dy10ldo8.js","assets/popover-select-CLsphyzA.js","assets/dist-GJ8-1PAx.js","assets/dist-BuHnPloF.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/circle-alert-BEjgurr2.js","assets/new-chat-navigation-B6NPQ4h4.js","assets/circle-x-DFsCKeya.js","assets/circle-BoO4YvTx.js","assets/file-tree-utils-DJs1faGv.js","assets/database-CjjeZfRG.js","assets/ellipsis-0k4rZLoy.js","assets/file-BqMS_3DT.js","assets/file-text-D12HbeVy.js","assets/folder-kanban-CpLlFI1o.js","assets/folder-open-CyzJ19I9.js","assets/folder-CN-pC3XL.js","assets/use-file-preview-expanded-BXXeXnT0.js","assets/eye-CABVeTq0.js","assets/link-2-D_ZKYUW7.js","assets/message-square-plus-XP0tGdlV.js","assets/minimize-2-DtOGrlpo.js","assets/paperclip-f1HujQY1.js","assets/refresh-cw-BRlGaq2w.js","assets/save-DRDABU--.js","assets/search-DA7gz22f.js","assets/constants-DpkUgykJ.js","assets/session-api-BFiIYodK.js","assets/gateway-startup-retry-D6WPS0RW.js","assets/attachment-utils-core-BIOUBrpT.js","assets/composer-notifications-CqV6Xj-H.js","assets/activity-store-CQHh48Zf.js","assets/app-chrome-BeB4KgOf.js","assets/electron-env-DHOGevH3.js","assets/use-async-resource-BHFGZCY2.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/workspace-api-LghfbP5g.js","assets/files-BNL4kkSB.js","assets/index.module-Cd9ENXfk.js","assets/dist-ZrL34Ps4.js","assets/git-branch-Dh9uxTot.js","assets/globe-DSSGFWFn.js","assets/history-DXH_9jsE.js","assets/key-round-DWbpyU2U.js","assets/laptop-CI3hBVrl.js","assets/list-checks-BbsExAoq.js","assets/messages-square-BckAJrEW.js","assets/monitor-Af5eAvF7.js","assets/install-connector-dialog-DxSv1wS2.js","assets/secret-input-DsjfQmDn.js","assets/is-masked-secret-DOkL5b_X.js","assets/connectors-api-CTuVWwBf.js","assets/gateway-config-swr-1Rk0LeEM.js","assets/oauth-provider-connect-D63M8Iv7.js","assets/cloud-C4-yfnnk.js","assets/models-hub-cache-Bgh3Gfgl.js","assets/registry-api-DuDIthjL.js","assets/oauth-api-B560CHeD.js","assets/connection-usage-guide-Cibh2lrV.js","assets/connection-usage-BhdQRWgQ.js","assets/settings-2-D-csvaET.js","assets/settings-uiTATseT.js","assets/shield-check-BU58siTV.js","assets/smartphone-DSSsQFqA.js","assets/square-DMK_fB-3.js","assets/trash-2-DusmjVPV.js","assets/share-link-dialog-C1t_HB6f.js","assets/copy-text-row-CpiRzq4G.js","assets/wrench-DFb4r8bH.js","assets/tasks-BTLabOMp.js","assets/specialists-xbB3xL9e.js","assets/api-B4FJ51EC.js","assets/session-manager-D2LaQymu.js","assets/local-session-drafts-BIBHRkpM.js","assets/tool-activity-BtJkgjFf.js","assets/gateway-realtime-DIs1pjkQ.js","assets/gateway-realtime-store-sx7B8kdC.js","assets/agents-admin-api-D0N09mqJ.js","assets/new-session-preferences-gb411vZP.js","assets/composer-model-config-control-DAagrRx_.js","assets/model-selector-C-CqPBao.js","assets/open-capability-settings-DQsmJxI7.js","assets/model-sort-_Tz8s_4N.js","assets/workspace-preview-store-Do31QQH5.js","assets/capabilities-DB713nRi.js","assets/capabilities-DDqDvCBs.js","assets/right-workspace-store-HPw7Gw0n.js","assets/phone-workspace-store-Ltrevdsx.js","assets/workspace-editor-agent-store-DVPJcbuE.js","assets/chat-agents-api-CjlzCSmC.js","assets/middleware-Pd0e8Igk.js","assets/composer-payload-handoff-Dc43dgSg.js","assets/voice-input-shortcut-events-CEeFBhp3.js","assets/chunk-D32TOXHM-DQIy-Baq.js","assets/tool-friendly-title-CP35P4VA.js","assets/use-realtime-voice-C7iWQuUv.js","assets/voice-CDlC6XMH.js","assets/voice-call-context-BM2A4bLz.js","assets/page-header-store-Bm8oxpFR.js","assets/loopi-CNtmi9FU.js","assets/loopi-C09I2mNj.css","assets/extension-provider-BPIoHw4r.js","assets/theme-store-BaWep_o7.js","assets/extension-message-router-C9JDpo_7.js","assets/agent-avatar-display-loBdGw_i.js","assets/skill-wire-pattern-BPpeIcCi.js","assets/use-composer-attachments-CO7XLI4x.js","assets/chevron-left-DqFhpbvK.js","assets/file-preview-surface-i5UOFnQF.js","assets/shares-api-Dm07CnXw.js","assets/use-directory-picker-C4p7AgWY.js","assets/confirm-dialog-DrA5mTQp.js","assets/command-palette-api-CP0F6sIm.js","assets/skill-list-api-1o_YRCu9.js","assets/skill-api-utils-C7V4JVXM.js","assets/automation-task-card-CiJmJ7_h.js","assets/automation-display-DaVDNZz8.js","assets/message-circle-Badhj-4D.js","assets/date-picker-XnE3iFhG.js","assets/calendar-days-hw_Y-g-s.js","assets/time-picker-C1PXAXZF.js","assets/dev-view-store-B8fGILny.js","assets/extension-iframe-host-DIH4TcdH.js","assets/extension-authoritative-grants-BfL8dMBf.js","assets/runtime-health-zDkHcOZO.js","assets/api-B1J5ajiP.js","assets/terminal-panel-store-Du53Upr2.js","assets/agents-app-path-ciChvpCS.js","assets/agent-display-names-Bje7vfSn.js","assets/use-media-query-ady-FgjK.js","assets/oauth-authorization-window-o6URRos4.js","assets/page-context-draft-Cr5GqS2D.js","assets/management-api-B5w5DdXH.js","assets/side-chat-shortcut-BIw-1TTD.js","assets/chat-page-zQeUaawJ.css"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{l as o,t as s,u as c}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{f as l,i as u,l as d,n as f,o as p,p as m}from"./locale-store-Dy1EByeG.js";import{t as h}from"./messages-BAnhwALN.js";import{a as g,c as _,i as v,n as y,o as b,r as x,s as S,t as C}from"./dist-CY7CS_D3.js";import{E as w,b as T,d as E,h as D,i as O,n as k,o as A,r as j,t as M,w as N,x as P}from"./discussion-annotation-sync-fwPPMPv9.js";import{t as F}from"./arrow-left-D880xG-P.js";import{a as I,c as L,d as ee,i as R,l as z,n as B,o as V,r as te,s as ne,t as re,u as ie}from"./product-automation-feedback-D51I7Lg3.js";import{t as ae}from"./check-DUBLcKHA.js";import{t as oe}from"./chevron-down-ccbiQQz_.js";import{n as se,r as H}from"./popover-select-CLsphyzA.js";import{t as ce}from"./circle-check-C23XjkUj.js";import{t as le}from"./code-xml-DJtYhZUF.js";import{t as U}from"./copy-Dv6d4Dvw.js";import{t as ue}from"./download-Dk-ZjtO6.js";import{t as de}from"./ellipsis-0k4rZLoy.js";import{t as fe}from"./external-link-DjqjBmc3.js";import{t as pe}from"./eye-CABVeTq0.js";import{t as me}from"./file-text-D12HbeVy.js";import{t as he}from"./history-DXH_9jsE.js";import{C as ge,E as W,F as _e,O as ve,P as ye,S as be,T as xe,_ as Se,a as Ce,c as we,d as Te,f as Ee,h as De,l as G,m as Oe,n as ke,r as Ae,s as je,u as Me,w as Ne,x as Pe}from"./notes-api-CdXA-g9r.js";import{t as Fe}from"./loader-circle-CifKLtgG.js";import{P as Ie}from"./markdown-view-BlxIaCCQ.js";import{t as Le}from"./message-circle-Badhj-4D.js";import{t as Re}from"./pencil-DmIY3Oa-.js";import{t as ze}from"./play-kxZvpBg8.js";import{t as Be}from"./refresh-cw-BRlGaq2w.js";import{t as Ve}from"./search-DA7gz22f.js";import{t as He}from"./sliders-horizontal-DqsYor6I.js";import{t as Ue}from"./sparkles-DHlfQFAF.js";import{t as We}from"./square-pen-B8FsvqNu.js";import{t as Ge}from"./square-DMK_fB-3.js";import{t as Ke}from"./trash-2-DusmjVPV.js";import{t as qe}from"./x-B_N4OPjy.js";import{t as K}from"./cn-0WouolD0.js";import{t as q}from"./skeleton-DzdOeGYz.js";import{t as Je}from"./session-manager-D2LaQymu.js";import{i as Ye}from"./vendor-swr-CdRzEUwF.js";import{t as J}from"./button-Cc4hUNTt.js";import{t as Xe}from"./copy-to-clipboard-HOJ79TWv.js";import{r as Y}from"./app-chrome-BeB4KgOf.js";import{i as Ze}from"./theme-store-BaWep_o7.js";import{t as Qe}from"./page-header-store-Bm8oxpFR.js";import{t as X}from"./automation-api-DxBmyzp0.js";import{t as $e}from"./confirm-dialog-DrA5mTQp.js";import{b as et,d as tt,o as nt,s as rt,v as it}from"./shares-api-Dm07CnXw.js";import{l as at,m as ot,o as st,r as ct,t as lt,u as ut}from"./dist-ZrL34Ps4.js";import{t as Z}from"./oauth-provider-connect-D63M8Iv7.js";import{n as dt,t as ft}from"./page-context-draft-Cr5GqS2D.js";import"./note-image-lightbox-CqK_uJ6Y.js";import{t as pt}from"./page-context-capture-button-Dibmspef.js";var Q=e(t(),1),mt=r(),$=i(),ht=6e4,gt=36e5,_t=864e5;function vt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function yt(e,t,n){let r=t-e;if(r<ht)return n.justNow;if(r<gt){let e=Math.floor(r/ht);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=vt(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(e>=i-_t)return n.yesterday+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(r<7*_t){let e=Math.floor(r/_t);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(n.locale,{month:`short`,day:`numeric`})}function bt(e,t,n){let r=vt(t);if(e>=r)return n.today;if(e>=r-_t)return n.yesterday;let i=new Date(e),a=new Date(t);return i.getFullYear()===a.getFullYear()?i.toLocaleDateString(n.locale,{month:`long`,day:`numeric`}):i.toLocaleDateString(n.locale,{year:`numeric`,month:`long`,day:`numeric`})}function xt(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function St(e){let t=(0,mt.c)(45),{title:n,description:r,prompt:i,coverage:a,className:o,variant:s}=e,l=s===void 0?`card`:s,u=f(Tt),d=h(u).automations.suggestions,p=h(u).automations,m=c(),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=g):g=t[0];let{data:_}=Ye(a?`automation-suggestion-coverage`:null,wt,g),v=a?_?.automations.find(e=>R(e,a)):void 0,y=v?B(v,p):[];if(l===`titleAction`){if(v){let e;t[1]===o?e=t[2]:(e=K(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,o),t[1]=o,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(ce,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=t[3];let r;return t[4]===m?r=t[5]:(r=()=>m(`/automations`),t[4]=m,t[5]=r),(0,$.jsxs)(`section`,{className:e,children:[n,(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:d.coveredTitle}),(0,$.jsx)(J,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:r,children:d.manage})]})}let e;t[6]===o?e=t[7]:(e=K(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,o),t[6]=o,t[7]=e);let a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(N,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=a):a=t[8];let s;t[9]!==r||t[10]!==n?(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:r,children:n}),t[9]=r,t[10]=n,t[11]=s):s=t[11];let c;t[12]!==m||t[13]!==i?(c=()=>{let e=new URLSearchParams({draft:i,autogenerate:`1`});m(`/automations?${e.toString()}`)},t[12]=m,t[13]=i,t[14]=c):c=t[14];let l;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0}),t[15]=l):l=t[15],(0,$.jsxs)(`section`,{className:e,children:[a,s,(0,$.jsxs)(J,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:c,children:[l,d.setup]})]})}if(v){let e;t[16]===o?e=t[17]:(e=K(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,o),t[16]=o,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(ce,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=t[18];let r;t[19]===m?r=t[20]:(r=()=>m(`/automations`),t[19]=m,t[20]=r);let i;return t[21]!==d||t[22]!==r?(i=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsx)(J,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:r,children:d.manage})}),t[21]=d,t[22]=r,t[23]=i):i=t[23],(0,$.jsxs)(`section`,{className:e,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:d.coveredTitle}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:te(d.coveredDescription,{name:v.name})})]})]}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:p.explain.whyCovered}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:y.map(Ct)})]}),i]})}let b;t[24]===o?b=t[25]:(b=K(`rounded-lg bg-surface-panel p-3 shadow-surface`,o),t[24]=o,t[25]=b);let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=x):x=t[26];let S;t[27]===n?S=t[28]:(S=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[27]=n,t[28]=S);let C;t[29]===r?C=t[30]:(C=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:r}),t[29]=r,t[30]=C);let w;t[31]!==S||t[32]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[x,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]})]}),t[31]=S,t[32]=C,t[33]=w):w=t[33];let T;t[34]!==m||t[35]!==i?(T=()=>{let e=new URLSearchParams({draft:i,autogenerate:`1`});m(`/automations?${e.toString()}`)},t[34]=m,t[35]=i,t[36]=T):T=t[36];let E;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0}),t[37]=E):E=t[37];let D;t[38]!==d.create||t[39]!==T?(D=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(J,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:T,children:[E,d.create]})}),t[38]=d.create,t[39]=T,t[40]=D):D=t[40];let O;return t[41]!==D||t[42]!==b||t[43]!==w?(O=(0,$.jsxs)(`section`,{className:b,children:[w,D]}),t[41]=D,t[42]=b,t[43]=w,t[44]=O):O=t[44],O}function Ct(e){return(0,$.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function wt(){return X.list()}function Tt(e){return e.language}var Et=`z-[140] min-w-44 rounded-lg border border-edge bg-surface-overlay p-1 text-sm text-fg shadow-popover`,Dt=`flex min-h-11 cursor-pointer items-center gap-2 rounded-md px-3 outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-40`;function Ot(e){let t=(0,mt.c)(54),{detail:n,zh:r,busy:i,processing:a,pageText:o,editing:s,noteActions:c}=e,l=`/api/discussions/${encodeURIComponent(n.discussion.id)}`,d=!!n.discussion.audioAttachmentId&&!n.discussion.audioDeletedAt,f;t[0]!==n.note.id||t[1]!==c||t[2]!==r?(f=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent aria-expanded:bg-accent-soft aria-expanded:text-accent-fg aria-expanded:hover:bg-accent-soft`,"aria-expanded":c.chatOpen??!1,"aria-controls":`note-assistant-${n.note.id}`,disabled:c.busy,onClick:c.onChat,children:[(0,$.jsx)(Le,{className:`size-4`,"aria-hidden":!0}),r?`AI 对话`:`AI chat`]}),(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r?`分享笔记`:`Share note`,disabled:c.busy,onClick:c.onShare,children:[(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:r?`分享`:`Share`})]})]}):null,t[0]=n.note.id,t[1]=c,t[2]=r,t[3]=f):f=t[3];let p=r?`导出笔记`:`Export note`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),t[4]=m):m=t[4];let h=r?`导出`:`Export`,g;t[5]===h?g=t[6]:(g=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h}),t[5]=h,t[6]=g);let _;t[7]!==p||t[8]!==g?(_=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":p,children:[m,g]})}),t[7]=p,t[8]=g,t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=[`md`,`txt`,`srt`],t[10]=v):v=t[10];let y;t[11]!==l||t[12]!==r?(y=v.map(e=>(0,$.jsx)(ct,{asChild:!0,children:(0,$.jsx)(`a`,{className:Dt,href:u(`${l}/export?format=${e}`),download:!0,children:e===`srt`?r?`字幕 · SRT`:`Subtitles · SRT`:e===`md`?`Markdown · MD`:r?`纯文本 · TXT`:`Plain text · TXT`})},e)),t[11]=l,t[12]=r,t[13]=y):y=t[13];let b;t[14]!==d||t[15]!==l||t[16]!==r?(b=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsx)(ct,{asChild:!0,children:(0,$.jsxs)(`a`,{className:Dt,href:u(`${l}/audio`),download:!0,children:[(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),r?`下载录音`:`Download recording`]})})]}):null,t[14]=d,t[15]=l,t[16]=r,t[17]=b):b=t[17];let x;t[18]!==y||t[19]!==b?(x=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{align:`end`,sideOffset:6,collisionPadding:12,className:Et,children:[y,b]})}),t[18]=y,t[19]=b,t[20]=x):x=t[20];let S;t[21]!==x||t[22]!==_?(S=(0,$.jsxs)(at,{children:[_,x]}),t[21]=x,t[22]=_,t[23]=S):S=t[23];let C=r?`更多笔记操作`:`More note actions`,w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(de,{className:`size-5`,"aria-hidden":!0}),t[24]=w):w=t[24];let T;t[25]===C?T=t[26]:(T=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":C,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:w})}),t[25]=C,t[26]=T);let E;t[27]!==c||t[28]!==r?(E=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ct,{className:Dt,disabled:c.busy,onSelect:c.onAnalyze,children:[(0,$.jsx)(Ue,{className:`size-4`,"aria-hidden":!0}),r?`进一步分析`:`Analyze this note`]}),(0,$.jsxs)(ct,{className:Dt,onSelect:c.onHistory,children:[(0,$.jsx)(he,{className:`size-4`,"aria-hidden":!0}),r?`版本历史`:`Version history`]})]}):null,t[27]=c,t[28]=r,t[29]=E):E=t[29];let D=n.note.id,O=String(n.note.remoteVersion??1),k;t[30]!==n.note.id||t[31]!==O?(k={kind:`note`,id:D,revision:O},t[30]=n.note.id,t[31]=O,t[32]=k):k=t[32];let A;t[33]===o?A=t[34]:(A={text:o,draft:!1},t[33]=o,t[34]=A);let j=r?`带到新对话`:`Use in a new chat`,M=i||a||s||!o||o.length>16e3,N;t[35]!==k||t[36]!==A||t[37]!==j||t[38]!==M?(N=(0,$.jsx)(`div`,{children:(0,$.jsx)(pt,{presentation:`menu`,resource:k,selection:A,label:j,disabled:M})}),t[35]=k,t[36]=A,t[37]=j,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==c||t[41]!==r?(P=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsxs)(ct,{className:`${Dt} text-danger`,disabled:c.busy,onSelect:c.onDelete,children:[(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),r?`删除笔记`:`Delete note`]})]}):null,t[40]=c,t[41]=r,t[42]=P):P=t[42];let F;t[43]!==E||t[44]!==N||t[45]!==P?(F=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{align:`end`,sideOffset:6,collisionPadding:12,className:Et,children:[E,N,P]})}),t[43]=E,t[44]=N,t[45]=P,t[46]=F):F=t[46];let I;t[47]!==T||t[48]!==F?(I=(0,$.jsxs)(at,{children:[T,F]}),t[47]=T,t[48]=F,t[49]=I):I=t[49];let L;return t[50]!==f||t[51]!==S||t[52]!==I?(L=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[f,S,I]}),t[50]=f,t[51]=S,t[52]=I,t[53]=L):L=t[53],L}function kt(e){let t=(0,mt.c)(68),{detail:n,template:r,onTemplate:i,zh:a,busy:o,processing:s,onOrganize:c,onRegenerate:l}=e,[u,d]=(0,Q.useState)(!1),f=!!n.discussion.audioAttachmentId&&!n.discussion.audioDeletedAt,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(He,{className:`size-3.5`,"aria-hidden":!0}),t[0]=p):p=t[0];let m=a?`整理方式`:`Summary settings`,h;t[1]===m?h=t[2]:(h=(0,$.jsx)(_,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[p,m]})}),t[1]=m,t[2]=h);let w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(g,{className:`fixed inset-0 z-[150] bg-scrim`}),t[3]=w):w=t[3];let T=a?`整理方式`:`Summary settings`,E;t[4]===T?E=t[5]:(E=(0,$.jsx)(S,{className:`font-medium`,children:T}),t[4]=T,t[5]=E);let D=a?`关闭整理设置`:`Close summary settings`,O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(qe,{className:`size-4`}),t[6]=O):O=t[6];let k;t[7]===D?k=t[8]:(k=(0,$.jsx)(y,{className:`inline-flex size-11 items-center justify-center rounded-lg hover:bg-surface-hover`,"aria-label":D,children:O}),t[7]=D,t[8]=k);let A;t[9]!==E||t[10]!==k?(A=(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-5 py-3`,children:[E,k]}),t[9]=E,t[10]=k,t[11]=A):A=t[11];let j=a?`根据已有原文重新整理纪要。你已手动编辑的内容会保留。`:`Reorganize the existing transcript. Your manual edits are preserved.`,M;t[12]===j?M=t[13]:(M=(0,$.jsx)(v,{className:`text-sm leading-6 text-fg-muted`,children:j}),t[12]=j,t[13]=M);let N=a?`纪要模板`:`Summary template`,P;t[14]===N?P=t[15]:(P=(0,$.jsx)(`span`,{children:N}),t[14]=N,t[15]=P);let F=a?`纪要模板`:`Summary template`,I;t[16]===i?I=t[17]:(I=e=>i(e.target.value),t[16]=i,t[17]=I);let L=a?`通用会议`:`General`,ee;t[18]===L?ee=t[19]:(ee=(0,$.jsx)(H,{value:`general`,children:L}),t[18]=L,t[19]=ee);let R=a?`项目例会`:`Project`,z;t[20]===R?z=t[21]:(z=(0,$.jsx)(H,{value:`project`,children:R}),t[20]=R,t[21]=z);let B=a?`需求评审`:`Review`,V;t[22]===B?V=t[23]:(V=(0,$.jsx)(H,{value:`review`,children:B}),t[22]=B,t[23]=V);let te=a?`客户访谈`:`Interview`,ne;t[24]===te?ne=t[25]:(ne=(0,$.jsx)(H,{value:`interview`,children:te}),t[24]=te,t[25]=ne);let re;t[26]!==F||t[27]!==I||t[28]!==ee||t[29]!==z||t[30]!==V||t[31]!==ne||t[32]!==r?(re=(0,$.jsxs)(se,{value:r,"aria-label":F,onChange:I,children:[ee,z,V,ne]}),t[26]=F,t[27]=I,t[28]=ee,t[29]=z,t[30]=V,t[31]=ne,t[32]=r,t[33]=re):re=t[33];let ie;t[34]!==P||t[35]!==re?(ie=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[P,re]}),t[34]=P,t[35]=re,t[36]=ie):ie=t[36];let ae;t[37]!==f||t[38]!==o||t[39]!==n.discussion.status||t[40]!==l||t[41]!==s||t[42]!==a?(ae=f&&[`completed`,`needs_attention`].includes(n.discussion.status)?(0,$.jsxs)(`details`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-11 cursor-pointer text-sm text-fg-muted`,children:a?`高级选项:重新识别录音`:`Advanced: transcribe again`}),(0,$.jsx)(`p`,{className:`mb-3 text-xs leading-5 text-fg-muted`,children:a?`重新处理原音,可能耗时较长。适用于原文缺失或识别不完整。`:`Process the original recording again when text is missing or incomplete. This may take longer.`}),(0,$.jsx)(J,{disabled:o||s,onClick:()=>{d(!1),l()},children:a?`从原音重新生成`:`Regenerate from audio`})]}):null,t[37]=f,t[38]=o,t[39]=n.discussion.status,t[40]=l,t[41]=s,t[42]=a,t[43]=ae):ae=t[43];let oe;t[44]!==M||t[45]!==ie||t[46]!==ae?(oe=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[M,ie,ae]}),t[44]=M,t[45]=ie,t[46]=ae,t[47]=oe):oe=t[47];let ce=a?`取消`:`Cancel`,le;t[48]===ce?le=t[49]:(le=(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(J,{children:ce})}),t[48]=ce,t[49]=le);let U=o||s||!n.discussion.canonicalTranscript,ue;t[50]===c?ue=t[51]:(ue=()=>{d(!1),c()},t[50]=c,t[51]=ue);let de;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(Be,{className:`size-4`,"aria-hidden":!0}),t[52]=de):de=t[52];let fe=a?`重新整理纪要`:`Regenerate summary`,pe;t[53]!==U||t[54]!==ue||t[55]!==fe?(pe=(0,$.jsxs)(J,{variant:`primary`,disabled:U,onClick:ue,children:[de,fe]}),t[53]=U,t[54]=ue,t[55]=fe,t[56]=pe):pe=t[56];let me;t[57]!==le||t[58]!==pe?(me=(0,$.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle p-4`,children:[le,pe]}),t[57]=le,t[58]=pe,t[59]=me):me=t[59];let he;t[60]!==A||t[61]!==oe||t[62]!==me?(he=(0,$.jsxs)(b,{children:[w,(0,$.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-[151] flex h-[min(28rem,90dvh)] w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-fg`,children:[A,oe,me]})]}),t[60]=A,t[61]=oe,t[62]=me,t[63]=he):he=t[63];let ge;return t[64]!==u||t[65]!==h||t[66]!==he?(ge=(0,$.jsxs)(C,{open:u,onOpenChange:d,children:[h,he]}),t[64]=u,t[65]=h,t[66]=he,t[67]=ge):ge=t[67],ge}function At(e){return JSON.stringify([e.transcript.revision,e.transcript.segments.map(e=>[e.sequence,e.revision,e.status]),e.organization?.revision])}function jt(e,t,n,r){let i=(0,mt.c)(27),a=r!==void 0&&r,[o,s]=(0,Q.useState)(),c;i[0]!==n||i[1]!==a||i[2]!==t||i[3]!==e||i[4]!==o?(c=()=>{!a&&t&&(o?.noteId!==e||o.version!==At(t))&&(o?.noteId===e&&n(),s({noteId:e,version:At(t),value:t}))},i[0]=n,i[1]=a,i[2]=t,i[3]=e,i[4]=o,i[5]=c):c=i[5];let l=o?.noteId,u=o?.version,d;i[6]!==n||i[7]!==a||i[8]!==t||i[9]!==e||i[10]!==l||i[11]!==u?(d=[e,t,l,u,n,a],i[6]=n,i[7]=a,i[8]=t,i[9]=e,i[10]=l,i[11]=u,i[12]=d):d=i[12],(0,Q.useLayoutEffect)(c,d);let f;i[13]!==n||i[14]!==t||i[15]!==e?(f=r=>{let i=r===void 0?t:r;i&&(n(),s({noteId:e,version:At(i),value:i}))},i[13]=n,i[14]=t,i[15]=e,i[16]=f):f=i[16];let p=f,m=o?.noteId===e?o:void 0,h;i[17]!==m||i[18]!==t?(h=!!t&&!!m&&m.version!==At(t),i[17]=m,i[18]=t,i[19]=h):h=i[19];let g=h,_;i[20]!==m||i[21]!==t?(_=t&&m?{...t,transcript:m.value.transcript,organization:m.value.organization}:t,i[20]=m,i[21]=t,i[22]=_):_=i[22];let v=_,y;return i[23]!==v||i[24]!==g||i[25]!==p?(y={detail:v,hasUpdates:g,publish:p},i[23]=v,i[24]=g,i[25]=p,i[26]=y):y=i[26],y}function Mt(e){let t=(0,Q.useRef)(null),n=(0,Q.useCallback)(()=>{let n=e.current;if(!n||t.current)return;let r=n.getBoundingClientRect().top;t.current={scrollTop:n.scrollTop,anchors:n.scrollTop<=0?[]:Array.from(n.querySelectorAll(`[data-reading-anchor]`)).filter(e=>e.getBoundingClientRect().bottom>r).map(e=>({key:e.dataset.readingAnchor,top:e.getBoundingClientRect().top-r}))}},[e]);return(0,Q.useLayoutEffect)(()=>{let n=t.current,r=e.current;if(t.current=null,!n||!r)return;let i=new Map(Array.from(r.querySelectorAll(`[data-reading-anchor]`)).map(e=>[e.dataset.readingAnchor,e])),a=n.anchors.find(e=>i.has(e.key));r.scrollTop=a?r.scrollTop+i.get(a.key).getBoundingClientRect().top-r.getBoundingClientRect().top-a.top:n.scrollTop}),n}var Nt=e=>`${Math.floor(e/6e4)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function Pt({id:e,query:t,zh:n,refreshKey:r,sourceKey:i,active:a,tab:o,onEvidence:s,onPlay:c}){let[l,d]=(0,Q.useState)(),f=(0,Q.useRef)(null),m=Mt(f),h=(0,Q.useRef)(null),g=(0,Q.useRef)(!1),[_,v]=(0,Q.useState)(!0),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(!1),C=(0,Q.useRef)(0),[w,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(0),M=JSON.stringify([e,i,t]),N=t?``:r;(0,Q.useEffect)(()=>{if(!a||t)return;let e=window.setInterval(()=>j(e=>e+1),3e3);return()=>window.clearInterval(e)},[a,t]),(0,Q.useEffect)(()=>{D(void 0)},[e,t]),(0,Q.useEffect)(()=>{let n=++C.current,r=new AbortController;v(!0),S(!1),b(``);let i=g.current;g.current=!1;let a=window.setTimeout(()=>{p(u(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}`),{signal:r.signal}).then(async a=>{if(C.current!==n)return;let o=h.current;if(!i&&o?.key===M){if(o.value.version===a.version)return;let i=o.value.hits.length;for(;a.hasMore&&a.hits.length<i;){let i=await p(u(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}&offset=${a.hits.length}&version=${encodeURIComponent(a.version)}`),{signal:r.signal});if(C.current!==n)return;if(i.version!==a.version||!i.hits.length)throw Error(`Review changed during refresh`);a={...i,offset:0,hits:[...a.hits,...i.hits]}}m()}h.current={key:M,value:a},d(a),T(M),k(t)}).catch(e=>{C.current===n&&!r.signal.aborted&&b(String(e))}).finally(()=>{C.current===n&&v(!1)})},t?200:0);return()=>{C.current++,r.abort(),window.clearTimeout(a)}},[e,t,N,i,M,A,m]);function P(){g.current=!0,j(e=>e+1)}async function F(){if(!l||x)return;let r=C.current;S(!0);try{let n=await p(u(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}&offset=${l.hits.length}&version=${l.version}`));if(r===C.current){let e={...n,hits:[...l.hits,...n.hits]};h.current={key:M,value:e},d(e)}}catch(e){r===C.current&&b(n?`内容已变化,请重新搜索。${String(e)}`:`Content changed; search again. ${String(e)}`)}finally{r===C.current&&S(!1)}}function I(e){D(e),(!e.provisional||e.kind===`chapter`)&&e.transcriptRevision!==void 0&&e.segments.length&&s({transcriptRevision:e.transcriptRevision,stale:e.stale,audioAvailable:l?.coverage.audioAvailable??!1,timingVerified:e.segments.some(e=>e.playback.length>0),segments:e.segments})}let L=e=>e.kind===`chapter`?n?`章节`:`Chapter`:e.kind===`annotation`?n?`我的标记`:`My mark`:e.kind===`analysis`?n?`分析`:`Analysis`:n?`原文`:`Transcript`,ee=e=>(0,$.jsxs)(`article`,{"data-reading-anchor":`review:${e.id}`,className:`space-y-2 rounded-xl bg-surface-inset p-4`,children:[(0,$.jsxs)(`button`,{className:`text-left text-sm text-accent-fg`,onClick:()=>I(e),children:[e.startedAtMs===void 0?``:`${Nt(e.startedAtMs)}${e.endedAtMs===void 0?``:`–${Nt(e.endedAtMs)}`} · `,e.title||L(e)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm`,children:e.kind===`chapter`&&!t&&e.text.length>300?`${e.text.slice(0,300)}…`:e.text}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[L(e),e.provisional?n?` · 阶段性结果`:` · Partial result`:``,e.stale?n?` · 原文已更新,保留旧版依据`:` · Earlier transcript revision`:``,e.kind===`chapter`?` · ${e.highlightCount??0} ${n?`个重点`:`marks`} · ${e.actionCount??0} ${n?`个候选行动`:`candidate actions`}`:``]}),e.kind!==`chapter`||t||E?.id===e.id?e.segments.map(e=>(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[Nt(e.startedAtMs),` · `,e.text.length>500?`${e.text.slice(0,500)}…`:e.text]},`${e.sequence}:${e.startedAtMs}`)):null,e.playback.slice(0,3).map((e,t)=>(0,$.jsxs)(J,{onClick:()=>c(e.startedAtMs,e.endedAtMs),children:[n?`回听上下文`:`Play context`,` `,Nt(e.startedAtMs),`–`,Nt(e.endedAtMs)]},t)),e.segments.length?(0,$.jsx)(J,{onClick:()=>I(e),children:n?`查看对应原文`:`View transcript`}):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`暂无可核实的原文定位`:`No verified transcript reference`})]},e.id);return(0,$.jsxs)(`section`,{ref:e=>{f.current=e?.closest(`main`)??e},"aria-label":n?`长录音回顾`:`Recording review`,className:`flex flex-col gap-3`,children:[y?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:y}),(0,$.jsx)(J,{onClick:P,children:n?`刷新结果`:`Refresh results`})]}):null,_&&(!l||w!==M||O!==t)?(0,$.jsx)(q,{className:`h-20 w-full`}):null,l&&w===M&&(!t||O===t)?(0,$.jsxs)($.Fragment,{children:[t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`搜索结果 · ${l.total}`:`Search results · ${l.total}`}),(0,$.jsx)(J,{onClick:P,children:n?`刷新结果`:`Refresh results`}),(0,$.jsx)(`div`,{"aria-label":n?`命中位置`:`Match positions`,className:`relative my-3 h-5 rounded bg-surface-inset`,children:l.hits.filter(e=>e.startedAtMs!==void 0).map(e=>(0,$.jsx)(`button`,{className:`absolute top-0 h-5 w-1.5 rounded bg-accent`,style:{left:`${Math.min(99,100*e.startedAtMs/Math.max(1,l.coverage.durationMs))}%`},"aria-label":`${Nt(e.startedAtMs)} ${e.title||L(e)}`,onClick:()=>I(e)},e.id))}),l.total?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`未找到关键词;尚未转写的内容无法搜索。`:`No matches. Untranscribed audio is not searchable yet.`}),l.hits.map(ee)]}):(0,$.jsxs)($.Fragment,{children:[o===`summary`&&l.chapters.length?(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-inset px-4`,children:[(0,$.jsxs)(`summary`,{className:`min-h-11 cursor-pointer py-3 text-sm font-medium focus-visible:ring-2 focus-visible:ring-accent`,children:[n?`章节目录`:`Chapters`,` · `,l.chapters.length]}),(0,$.jsx)(`div`,{className:`space-y-3 pb-4`,children:l.chapters.map(ee)})]}):null,l.hits.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`本轮已完成转写(阶段性)`:`Available transcription from this run`}),l.hits.map(ee)]}):null]}),l.hasMore?(0,$.jsx)(J,{disabled:x,onClick:()=>void F(),children:n?`加载更多结果`:`More results`}):null,(0,$.jsxs)(`details`,{className:`rounded-lg text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-3 focus-visible:ring-2 focus-visible:ring-accent`,children:n?`处理范围`:`Processing coverage`}),(0,$.jsxs)(`div`,{role:`status`,className:`space-y-2 pb-3 leading-5`,children:[(0,$.jsxs)(`p`,{children:[n?`原音`:`Audio`,` · `,l.coverage.audioAvailable?n?`已保存,可回听`:`Saved, ready to play`:n?`尚不可用`:`Unavailable`]}),(0,$.jsxs)(`p`,{children:[n?`本轮转写已处理`:`Processed this run`,` `,Nt(l.coverage.processedMs),` / `,Nt(l.coverage.durationMs),` · `,n?`连续处理至`:`Continuous through`,` `,Nt(l.coverage.continuousThroughMs)]}),(0,$.jsxs)(`p`,{children:[n?`分析覆盖`:`Analysis coverage`,` · `,l.coverage.analysisRanges.length?l.coverage.analysisRanges.map(e=>`${Nt(e.startedAtMs)}–${Nt(e.endedAtMs)}`).join(`、`):n?`暂无本版已完成章节`:`No completed chapters for this revision`,l.coverage.analysisStale?n?`;已发布分析基于旧版原文`:`; published analysis uses an earlier transcript`:``,` · `,l.coverage.complete?n?`本轮处理完成`:`Run complete`:n?`阶段性内容,其余仍待处理`:`Partial content; remaining work pending`]})]})]}),E?.provisional?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`以上是本轮已保存的阶段性原文;正式发布后才能校对和标记具体段落。`:`Saved partial text; segment editing and highlighting become available after publication.`}):null]}):null]})}function Ft({recordingId:e,discussionId:t,zh:n,onEvidence:r,onPlay:i}){let{data:a=[],mutate:o}=Ye(`/api/discussions/${t}/annotations`,e=>p(u(e))),[s,c]=(0,Q.useState)([]),[l,d]=(0,Q.useState)(null),[f,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),_=(0,Q.useCallback)(async()=>{c(await j(e))},[e]),v=(0,Q.useCallback)(async()=>{try{await M(e,t),await _(),await o()}catch(e){await o(),g(e instanceof Error?e.message:String(e))}},[e,t,_,o]);(0,Q.useEffect)(()=>{_().catch(e=>g(String(e))),v();let e=()=>{_().catch(e=>g(String(e)))};window.addEventListener(`discussion-annotations-changed`,e),window.addEventListener(`online`,v);let t=window.setInterval(()=>{navigator.onLine&&v()},15e3);return()=>{window.removeEventListener(`discussion-annotations-changed`,e),window.removeEventListener(`online`,v),window.clearInterval(t)}},[_,v]);let y=new Map(a.map(e=>[e.annotation.id,{...e,localState:`synced`}]));for(let e of s)if(e.state!==`synced`||!y.has(e.annotation.id)){let t=y.get(e.annotation.id);y.set(e.annotation.id,{annotation:e.annotation,state:t?.state??`pending`,playback:t?.playback??[],evidence:t?.evidence,localState:e.state})}let b=async(t,n=s.find(e=>e.annotation.id===t.id)?.nonce??null)=>{try{await A(e,{...t,updatedAt:Date.now()},n),m(null),g(``),await _(),v()}catch(e){g(e instanceof Error?e.message:String(e))}};return(0,$.jsxs)(`section`,{className:`space-y-4`,"aria-label":n?`我的标记`:`My highlights`,children:[h?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[h,(0,$.jsx)(J,{onClick:()=>void v(),children:n?`重试同步`:`Retry sync`})]}):null,y.size?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`录音时标重点,或在原文中标记整段。标记先保存在本机。`:`Highlight while recording or mark a transcript segment. Highlights save locally first.`}),[...y.values()].sort((e,t)=>e.annotation.anchor.capturedAt-t.annotation.anchor.capturedAt).filter(e=>!e.annotation.deleted||e.localState===`conflict`).map(e=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.annotation.kind===`highlight`?n?`重点`:`Highlight`:e.annotation.kind===`question`?n?`问题`:`Question`:n?`我的补充`:`My note`,` · `,new Date(e.annotation.anchor.capturedAt).toLocaleString(),` · `,e.localState===`synced`?n?`已同步`:`Synced`:e.localState===`conflict`?n?`同步冲突,保留了本机修改`:`Conflict; local edits retained`:n?`本机已保存,待同步`:`Saved locally; sync pending`]}),e.evidence?.segments.map(e=>(0,$.jsx)(`blockquote`,{className:`text-sm`,children:e.text},e.sequence)),e.positionMs===void 0?null:(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n?`标记位置`:`Marked position`,` · `,Math.floor(e.positionMs/6e4),`:`,String(Math.floor(e.positionMs/1e3)%60).padStart(2,`0`)]}),e.annotation.text?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap text-sm`,children:[n?`我的说明:`:`My context: `,e.annotation.text]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(J,{disabled:!e.evidence,onClick:()=>e.evidence&&r(e.evidence),children:n?`查看原文`:`View transcript`}),e.playback.map((e,t)=>(0,$.jsxs)(J,{onClick:()=>i(e),children:[n?`回听`:`Play`,` `,Math.floor(e.startedAtMs/6e4),`:`,String(Math.floor(e.startedAtMs/1e3)%60).padStart(2,`0`)]},t)),(0,$.jsx)(J,{onClick:()=>{d(s.find(t=>t.annotation.id===e.annotation.id)?.nonce??null),m({...e.annotation,revision:a.find(t=>t.annotation.id===e.annotation.id)?.annotation.revision??e.annotation.revision})},children:e.localState===`conflict`?n?`合并修改`:`Merge changes`:n?`添加说明/类型`:`Edit context/type`}),(0,$.jsx)(J,{onClick:()=>void b({...e.annotation,deleted:!0}),children:n?`移除标记`:`Remove`})]}),e.state===`located`&&!e.evidence?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原文尚未生成,可先回听原音。`:`Transcript for this position is pending; audio is usable.`}):null,e.state===`unavailable`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原音未保存、已删除或时间尚无法核实;保留原始标记,不自动移动。`:`Audio at this position is missing, deleted or unverified. The original anchor has been retained.`}):e.state===`pending`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`等待原音/原文完成定位`:`Awaiting audio/transcript positioning`}):null,e.localState===`conflict`?(0,$.jsx)(J,{onClick:()=>{let t=s.find(t=>t.annotation.id===e.annotation.id),n=a.find(t=>t.annotation.id===e.annotation.id);t&&n&&k(t,n.annotation).then(_)},children:n?`使用服务端版本`:`Use server version`}):null]},e.annotation.id)),f?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":n?`编辑标记`:`Edit highlight`,className:`rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(se,{value:f.kind,"aria-label":n?`标记类型`:`Highlight type`,onChange:e=>m({...f,kind:e.target.value}),children:[(0,$.jsx)(H,{value:`highlight`,children:n?`重点`:`Highlight`}),(0,$.jsx)(H,{value:`question`,children:n?`问题`:`Question`}),(0,$.jsx)(H,{value:`note`,children:n?`补充`:`Context`})]}),(0,$.jsx)(`textarea`,{"aria-label":n?`我的说明`:`My context`,maxLength:4e3,value:f.text,onChange:e=>m({...f,text:e.target.value}),className:`my-2 min-h-24 w-full rounded border border-edge bg-surface-inset p-2`}),(0,$.jsx)(J,{onClick:()=>void b(f,l),children:n?`保存到本机并同步`:`Save locally and sync`}),(0,$.jsx)(J,{onClick:()=>m(null),children:n?`取消`:`Cancel`})]}):null]})}var It={tab:`summary`,query:``,page:1,positionMs:0},Lt=m((e,t)=>({notes:{},update:(n,r)=>{let i={...zt(n,t().notes[n]),...r};e(e=>({notes:{...e.notes,[n]:i}}));try{localStorage.setItem(`discussion-review:${n}`,JSON.stringify(i))}catch{}}})),Rt=new Map;function zt(e,t){if(t)return t;if(Rt.has(e))return Rt.get(e);let n=It;try{let t=JSON.parse(localStorage.getItem(`discussion-review:${e}`)??`null`);t&&[`summary`,`transcript`,`marks`].includes(t.tab)&&typeof t.query==`string`&&Number.isSafeInteger(t.page)&&t.page>0&&t.page<=1e4&&Number.isFinite(t.positionMs)&&t.positionMs>=0&&(n={...It,...t})}catch{}return Rt.set(e,n),n}function Bt(e){let t=(0,mt.c)(51),{initial:n,zh:r,busy:i,onClose:a,onSave:o}=e,[s,c]=(0,Q.useState)(n),l;t[0]!==i||t[1]!==a?(l=e=>{!e&&!i&&a()},t[0]=i,t[1]=a,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[3]=u):u=t[3];let d=r?`编辑纪要内容`:`Edit meeting content`,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`header`,{className:`border-b border-edge p-4`,children:(0,$.jsx)(S,{children:d})}),t[4]=d,t[5]=f);let p=r?`人工修改会保留,重新整理不会覆盖。已创建任务保持不变。`:`Your changes survive regeneration. Existing tasks remain unchanged.`,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[6]=p,t[7]=m);let h=r?`内容`:`Content`,_;t[8]===s?_=t[9]:(_=e=>c({...s,text:e.target.value}),t[8]=s,t[9]=_);let v;t[10]!==s.text||t[11]!==_?(v=(0,$.jsx)(`textarea`,{className:`mt-1 min-h-32 w-full rounded border border-edge bg-transparent p-2`,value:s.text,onChange:_}),t[10]=s.text,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==h||t[14]!==v?(y=(0,$.jsxs)(`label`,{className:`block text-sm`,children:[h,v]}),t[13]=h,t[14]=v,t[15]=y):y=t[15];let w;t[16]!==s||t[17]!==r?(w=s.kind===`actionItems`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`负责人原话`:`Owner as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.owner??``,onChange:e=>c({...s,owner:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`期限原话`:`Date as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.dueDate??``,onChange:e=>c({...s,dueDate:e.target.value})})]})]}):null,t[16]=s,t[17]=r,t[18]=w):w=t[18];let T;t[19]!==s||t[20]!==r?(T=s.kind===`summary`?null:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!s.ignored,onChange:e=>c({...s,ignored:e.target.checked})}),r?`忽略此项`:`Ignore this item`]}),t[19]=s,t[20]=r,t[21]=T):T=t[21];let E;t[22]!==y||t[23]!==w||t[24]!==T||t[25]!==m?(E=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[m,y,w,T]}),t[22]=y,t[23]=w,t[24]=T,t[25]=m,t[26]=E):E=t[26];let D=r?`取消`:`Cancel`,O;t[27]!==i||t[28]!==a||t[29]!==D?(O=(0,$.jsx)(J,{disabled:i,onClick:a,children:D}),t[27]=i,t[28]=a,t[29]=D,t[30]=O):O=t[30];let k;t[31]!==i||t[32]!==s.text?(k=i||!s.text.trim(),t[31]=i,t[32]=s.text,t[33]=k):k=t[33];let A;t[34]!==s||t[35]!==o?(A=()=>void o(s),t[34]=s,t[35]=o,t[36]=A):A=t[36];let j=r?`保存修改`:`Save changes`,M;t[37]!==k||t[38]!==A||t[39]!==j?(M=(0,$.jsx)(J,{variant:`primary`,disabled:k,onClick:A,children:j}),t[37]=k,t[38]=A,t[39]=j,t[40]=M):M=t[40];let N;t[41]!==O||t[42]!==M?(N=(0,$.jsxs)(`footer`,{className:`flex justify-end gap-2 border-t border-edge p-3`,children:[O,M]}),t[41]=O,t[42]=M,t[43]=N):N=t[43];let P;t[44]!==E||t[45]!==N||t[46]!==f?(P=(0,$.jsxs)(b,{children:[u,(0,$.jsxs)(x,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(32rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[f,E,N]})]}),t[44]=E,t[45]=N,t[46]=f,t[47]=P):P=t[47];let F;return t[48]!==l||t[49]!==P?(F=(0,$.jsx)(C,{open:!0,onOpenChange:l,children:P}),t[48]=l,t[49]=P,t[50]=F):F=t[50],F}function Vt(e,t,n){if(t===`summary`){let r=e.organization;if(!r)return``;let i=r.organization;if(!i)return``;let a=e=>e.filter(e=>n.showIgnored||!e.ignored);return JSON.stringify({discussionId:e.discussion.id,view:t,revision:r.revision,transcriptRevision:r.transcriptRevision,summary:i.summary,decisions:a(i.decisions),actionItems:a(i.actionItems),risks:a(i.risks),openQuestions:a(i.openQuestions),chapters:i.chapters},null,2)}let r=n.query.toLocaleLowerCase(),i=e.transcript.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(r)||e.speakerLabel?.toLocaleLowerCase().includes(r)).slice(0,n.page*50);return i.length?JSON.stringify({discussionId:e.discussion.id,view:t,revision:e.transcript.revision,scope:`loaded filtered segments only`,segments:i.map(e=>({sequence:e.sequence,startedAtMs:e.startedAtMs,speaker:e.speakerLabel,text:e.displayText??e.rawText??``}))},null,2):``}var Ht=e=>`${String(Math.floor(e/6e4)).padStart(2,`0`)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function Ut({noteId:e,onPersonalNotes:t,onMeetingContent:n,personalNotes:r,personalNotesActive:i=!1,noteActions:a}){let c=o(),l=f(e=>e.language)===`zh`,{data:d,mutate:m,isLoading:h}=Ye([`note-discussion-document`,e],()=>E(e),{refreshInterval:e=>e&&([`recording`,`stopping`,`sealing`,`organizing`].includes(e.discussion.status)||e.recordingJob?.state===`queued`||e.recordingJob?.state===`running`)?3e3:0}),[_,v]=(0,Q.useState)(null),[y,w]=(0,Q.useState)(null),k=(0,Q.useRef)(null),{detail:j,hasUpdates:N,publish:F}=jt(e,d,Mt(k),!!_||!!y),I=j?.discussion.id,L=`/api/discussions/${encodeURIComponent(I??``)}`,{data:ee=[],mutate:R}=Ye(I?`${L}/actions`:null,e=>p(u(e)),{refreshInterval:1e4}),z=Lt(t=>zt(e,t.notes[e])),B=Lt(e=>e.update),V=z.tab,te=t=>B(e,{tab:t}),ne=z.query,re=t=>B(e,{query:t}),[ie,oe]=(0,Q.useState)(!1),se=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{ie&&se.current?.focus()},[ie]);let[H,ce]=(0,Q.useState)(`general`),le=(0,Q.useRef)(null),U=(0,Q.useRef)(null),[ue,de]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)(!1),me=(0,Q.useRef)(!1),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),[W,_e]=(0,Q.useState)(null),[ve,ye]=(0,Q.useState)(!1),[be,xe]=(0,Q.useState)([]),[Se,Ce]=(0,Q.useState)(null),[we,Te]=(0,Q.useState)(!1),Ee=z.page,De=t=>B(e,{page:t}),G=(0,Q.useRef)(null),[Oe,ke]=(0,Q.useState)([]),Ae=(0,Q.useRef)(0),je=(0,Q.useRef)(0),Me=(0,Q.useRef)(d?.transcript.revision);Me.current=d?.transcript.revision;let Ne=(0,Q.useRef)(null),Pe=(0,Q.useRef)(d?.discussion.audioDeletedAt);Pe.current=d?.discussion.audioDeletedAt;let Fe=(0,Q.useRef)(null),[,Le]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let t=()=>{m(),R()},n=n=>{n.detail?.noteId===e&&t()};return window.addEventListener(`note-updated`,n),window.addEventListener(`discussion-updated`,t),window.addEventListener(`discussion-segment-updated`,t),()=>{window.removeEventListener(`note-updated`,n),window.removeEventListener(`discussion-updated`,t),window.removeEventListener(`discussion-segment-updated`,t)}},[m,R,e]),(0,Q.useEffect)(()=>{j?.discussion.template&&ce(j.discussion.template)},[j?.discussion.template]);async function Re(e){if(!we){Te(!0),Ce(null);try{await e();let t=await m();F(t),await R()}catch(e){Ce(e instanceof Error?e.message:String(e))}finally{Te(!1)}}}function Be(e,t){Ne.current&&(G.current=t??null,Ne.current.readyState===0?(Fe.current=e/1e3,Ne.current.load()):(Ne.current.currentTime=e/1e3,Ne.current.play().catch(()=>void 0)))}function He(){if(U.current)return;let e=ge.current??(document.activeElement instanceof HTMLElement?document.activeElement:null);U.current={element:e,triggerIndex:Array.from(k.current?.querySelectorAll(`button`)??[]).findIndex(t=>t===e),scrollTop:k.current?.scrollTop??0,review:z}}function Ue(){je.current++,de(!1),_e(null),he.current=U.current?.element??null,fe||(U.current=null)}function Ge(){let t=U.current;if(!t)return;let{tab:n,query:r,page:i,anchor:a,anchorRevision:o}=t.review;B(e,{tab:n,query:r,page:i,anchor:a,anchorRevision:o}),ke([]),_e(null),pe(!1),me.current=!0}(0,Q.useLayoutEffect)(()=>{if(!W&&!ue&&he.current&&(he.current.focus({preventScroll:!0}),he.current=null),!me.current)return;me.current=!1;let e=U.current;e&&k.current&&(k.current.scrollTop=e.scrollTop),(e?.element?.isConnected?e.element:e&&e.triggerIndex>=0?k.current?.querySelectorAll(`button`)[e.triggerIndex]:null)?.focus({preventScroll:!0}),U.current=null}),(0,Q.useEffect)(()=>{(W||ue)&&le.current?.focus({preventScroll:!0})},[W,ue]);function Ke(e){He();let t=e.stale||e.transcriptRevision!==Me.current,n=Pe.current?{...e,audioAvailable:!1,timingVerified:!1,segments:e.segments.map(e=>({...e,playback:[]}))}:e;_e({...n,stale:t}),t||ke(e.segments.map(e=>e.sequence))}async function K(e,t,n=!1){if(!j)return;let r=Ae.current,i=++je.current;He(),de(!0),_e(null),Ce(null);try{let a=await p(u(`${L}/evidence?revision=${t??j.organization?.transcriptRevision??j.transcript.revision}&segments=${e.join(`,`)}`));if(r!==Ae.current||i!==je.current)return;if(Ke(a),n&&!Pe.current&&a.segments[0]?.playback[0]){let e=a.segments[0].playback[0];Be(e.startedAtMs,e.endedAtMs)}}catch(e){r===Ae.current&&i===je.current&&(Ce(e instanceof Error?e.message:String(e)),Ue())}finally{i===je.current&&de(!1)}}async function Je(e){j&&await Re(async()=>{await A(j.discussion.clientRequestId,O({type:`transcript`,capturedAt:Date.now(),transcriptRevision:j.transcript.revision,segmentIds:[e.sequence]})),te(`marks`),M(j.discussion.clientRequestId,j.discussion.id).catch(e=>Ce(String(e)))})}(0,Q.useEffect)(()=>(Ae.current++,je.current++,U.current=null,pe(!1),de(!1),_e(null),ke([]),v(null),w(null),xe([]),Ce(null),G.current=null,()=>{Ae.current++}),[e]),(0,Q.useEffect)(()=>{let t=j?.discussion.audioSha256??j?.discussion.audioAttachmentId;if(!t)return;let n=zt(e,Lt.getState().notes[e]);n.source&&n.source!==t?(Ae.current++,je.current++,de(!1),_e(null),ke([]),Ne.current?.pause(),B(e,{positionMs:0,source:t}),Fe.current=0,G.current=null):B(e,{source:t})},[e,j?.discussion.audioSha256,j?.discussion.audioAttachmentId,B]),(0,Q.useEffect)(()=>{j?.discussion.audioDeletedAt&&(Ne.current?.pause(),Fe.current=null,G.current=null,_e(e=>e?{...e,audioAvailable:!1,timingVerified:!1,segments:e.segments.map(e=>({...e,playback:[]}))}:null))},[j?.discussion.audioDeletedAt]),(0,Q.useEffect)(()=>{z.tab===`transcript`&&z.anchor!==void 0&&z.anchorRevision===j?.transcript.revision&&window.setTimeout(()=>document.getElementById(`discussion-segment-${z.anchor}`)?.scrollIntoView?.({block:`center`}),0)},[z.tab,z.anchor,z.anchorRevision,j?.transcript.revision]),(0,Q.useEffect)(()=>{ke([]),_e(e=>e&&e.transcriptRevision!==d?.transcript.revision?{...e,stale:!0}:e)},[d?.transcript.revision]);let Xe=(e,t,n)=>t.some(e=>ve||!e.ignored)?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`font-semibold text-fg`,children:e}),t.filter(e=>ve||!e.ignored).map(e=>(0,$.jsxs)(`div`,{"data-reading-anchor":`fact:${e.id}`,className:`flex items-start gap-3 text-sm`,children:[(0,$.jsxs)(`p`,{className:`flex-1 whitespace-pre-wrap`,children:[e.text,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?`有后续变更`:`Later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:we||N,onClick:()=>w({kind:n,itemId:e.id,text:e.text,ignored:e.ignored}),children:l?`编辑`:`Edit`}),e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:we,className:`shrink-0 text-accent-fg`,onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:l?`原话`:`Source`}):(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:l?`暂无定位`:`No source timing`})]},e.id))]}):null;if(h)return(0,$.jsx)(q,{className:`h-48 w-full`});if(!j)return null;let{discussion:Y,transcript:Ze,organization:Qe}=j,X=Qe?.organization,$e=[`stopping`,`sealing`,`organizing`].includes(Y.status),et=!N&&[`recording`,`completed`,`needs_attention`].includes(Y.status),tt=Ze.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(ne.toLocaleLowerCase())||e.speakerLabel?.toLocaleLowerCase().includes(ne.toLocaleLowerCase())),nt=i?j.note.markdown:V===`marks`||ne.trim()?``:Vt(j,V,{query:ne,page:Ee,showIgnored:ve});return(0,$.jsxs)(`section`,{className:`@container/discussion relative flex h-full min-h-0 min-w-0 w-full flex-col text-fg`,onClickCapture:e=>{ge.current=e.target instanceof Element?e.target.closest(`button`):null},onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`f`&&(e.preventDefault(),oe(!0))},children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-start gap-x-3 gap-y-1 px-5 pb-2 pt-5 sm:px-7`,children:[(0,$.jsxs)(`div`,{className:`min-w-40 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-2xl font-semibold leading-snug tracking-tight`,children:!j.note.title||/^Discussion · \d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(j.note.title)?l?`语音笔记`:`Voice note`:j.note.title}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[l?`录音`:`Recording`,` · `,Ht(Y.durationMs??0)]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":l?`搜索此 Note`:`Search this Note`,"aria-expanded":ie||!!ne,onClick:()=>{oe(e=>!e),ie&&re(``)},className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(Ve,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(Ot,{noteActions:a,detail:j,zh:l,busy:we,processing:$e,pageText:nt,editing:!!y||!!_})]}),(0,$.jsx)(`nav`,{"aria-label":l?`笔记内容`:`Note content`,className:`mx-5 mb-2 flex shrink-0 gap-6 border-b border-edge-subtle sm:mx-7`,children:[`summary`,`transcript`,`personal`].map(e=>{let r=e===`personal`?i:!i&&(e===`transcript`?V===`transcript`||V===`marks`:V===e);return(0,$.jsx)(`button`,{type:`button`,"aria-pressed":r,className:`min-h-11 border-b-2 px-1 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${r?`border-accent font-medium text-fg`:`border-transparent text-fg-muted hover:text-fg`}`,onClick:()=>{e===`personal`?(Ue(),t?.()):(n?.(),te(e))},children:e===`summary`?l?`纪要`:`Summary`:e===`personal`?l?`我的笔记`:`My notes`:l?`原文`:`Transcript`},e)})}),Se?(0,$.jsxs)(`details`,{role:`alert`,className:`px-4 py-2 text-sm text-danger`,children:[(0,$.jsx)(`summary`,{children:l?`操作未完成,可以稍后重试`:`Action incomplete. Try again later`}),(0,$.jsx)(`p`,{className:`mt-2 break-words text-xs text-fg-muted`,children:Se})]}):null,!i&&(ie||ne)?(0,$.jsxs)(`label`,{className:`mx-5 mb-2 flex shrink-0 items-center gap-2 rounded-xl bg-surface-inset px-3 sm:mx-7`,children:[(0,$.jsx)(Ve,{className:`size-4 text-fg-muted`}),(0,$.jsx)(`input`,{ref:se,"aria-label":l?`搜索此 Note`:`Search this Note`,className:`min-h-11 min-w-0 w-full bg-transparent text-sm outline-none`,maxLength:200,placeholder:l?`搜索这篇笔记`:`Search this note`,value:ne,onChange:e=>{re(e.target.value),De(1)}}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l?`关闭搜索`:`Close search`,onClick:()=>{re(``),oe(!1)},children:(0,$.jsx)(qe,{className:`size-4`})})]}):null,fe?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-5 pb-2 text-xs text-fg-muted sm:px-7`,children:[(0,$.jsx)(`span`,{children:U.current?.review.tab===`summary`?l?`正在查看结论依据`:`Viewing supporting transcript`:l?`正在查看原文依据`:`Viewing source transcript`}),(0,$.jsx)(J,{variant:`ghost`,onClick:Ge,children:U.current?.review.tab===`summary`?l?`返回结论`:`Back to conclusion`:l?`返回阅读位置`:`Back to reading`})]}):null,(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,$.jsxs)(`main`,{ref:k,className:`min-h-0 min-w-0 flex-1 flex-col gap-5 overflow-y-auto px-5 pb-6 pt-1 sm:px-7 ${i||W||ue?`hidden`:`flex`} ${!i&&(W||ue)?`@min-[58rem]/discussion:flex`:``}`,children:[V===`summary`?(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[46rem] items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:l?`会议纪要`:`Meeting summary`}),(0,$.jsx)(kt,{detail:j,template:H,onTemplate:ce,zh:l,busy:we,processing:$e,onOrganize:()=>void Re(()=>p(u(`${L}/organize`),{method:`POST`,body:JSON.stringify({template:H})})),onRegenerate:()=>void Re(()=>D(Y.id,`from_audio`))})]}):(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[46rem] gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,"aria-pressed":V===`transcript`,onClick:()=>te(`transcript`),children:l?`全部原文`:`All transcript`}),(0,$.jsx)(J,{variant:`ghost`,"aria-pressed":V===`marks`,onClick:()=>te(`marks`),children:l?`我的标记`:`My highlights`})]}),(Y.status!==`completed`||!X||Qe?.transcriptRevision!==Ze.revision)&&(Y.status!==`recording`||j.recordingJob)?(0,$.jsx)(T,{context:`note`,nextAttemptAt:j.processing?.nextAttemptAt,input:P(j),zh:l,busy:we,onRetry:e=>void Re(()=>e===`analyze`?p(u(`${L}/organize`),{method:`POST`,body:JSON.stringify({template:H})}):D(Y.id,e===`regenerate`?`from_audio`:`resume`))}):null,(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-[46rem]`,hidden:!!ne.trim(),children:V===`marks`?(0,$.jsx)(Ft,{recordingId:Y.clientRequestId,discussionId:Y.id,zh:l,onEvidence:Ke,onPlay:e=>Be(e.startedAtMs,e.endedAtMs)},Y.id):V===`summary`?X?(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[46rem] space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:l?`摘要`:`Summary`}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l?`编辑概要`:`Edit overview`,title:l?`编辑概要`:`Edit overview`,disabled:we||$e||N,onClick:()=>w({kind:`summary`,itemId:`summary`,text:X.summary}),children:(0,$.jsx)(We,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{"data-reading-anchor":`summary`,className:`whitespace-pre-wrap text-[15px] leading-7`,children:X.summary}),X.summaryEditedByUser?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`已由你编辑`:`Edited by you`}):null,X.summaryEvidenceSegmentIds?.length?Array.from({length:Math.ceil(X.summaryEvidenceSegmentIds.length/100)},(e,t)=>(0,$.jsxs)(J,{onClick:()=>void K(X.summaryEvidenceSegmentIds.slice(t*100,(t+1)*100)),children:[l?`查看原话`:`View source`,X.summaryEvidenceSegmentIds.length>100?` · ${t+1}`:``]},t)):null,X.keyPointEvidence?.length?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{children:l?`重点结论`:`Key points`}),X.keyPointEvidence.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1`,children:e.text}),(0,$.jsx)(J,{onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:l?`原话`:`Source`})]},e.id))]}):X.keyPoints.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:l?`重点结论`:`Key points`}),(0,$.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-[15px] leading-7`,children:X.keyPoints.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}:${e}`))})]}):null,[...X.decisions,...X.actionItems,...X.risks,...X.openQuestions].some(e=>e.ignored)?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ve,onChange:e=>ye(e.target.checked)}),l?`显示已忽略项`:`Show ignored items`]}):null,be.length?(0,$.jsx)(J,{disabled:we||N,onClick:()=>void Re(async()=>{for(let e of be)await p(u(`${L}/actions/${encodeURIComponent(e)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Qe.revision})});xe([])}),children:l?`加入所选 ${be.length} 项任务`:`Add ${be.length} selected tasks`}):null,Xe(l?`已决定事项`:`Decisions`,X.decisions,`decisions`),X.actionItems.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:l?`下一步行动`:`Next actions`}),X.actionItems.filter(e=>ve||!e.ignored).map(e=>{let t=ee.find(t=>t.actionId===e.id);return(0,$.jsxs)(`article`,{"data-reading-anchor":`action:${e.id}`,className:`rounded-lg border border-edge-subtle p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!t&&!e.ignored&&(!(e.supersededBy||e.disputedBy)||e.reviewedChangeId===(e.supersededBy??e.disputedBy))?(0,$.jsx)(`input`,{type:`checkbox`,"aria-label":`${l?`选择行动`:`Select action`}: ${e.title}`,className:`ui-checkbox`,checked:be.includes(e.id),onChange:t=>xe(t.target.checked?[...be,e.id]:be.filter(t=>t!==e.id))}):null,(0,$.jsxs)(`p`,{className:`flex-1 text-sm font-medium`,children:[e.title,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?`有后续变更,请复核`:`Review later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:we||$e||N,onClick:()=>w({kind:`actionItems`,itemId:e.id,text:e.title,owner:e.owner,dueDate:e.dueDate,ignored:e.ignored}),children:l?`编辑`:`Edit`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[e.owner??(l?`负责人未明确`:`Owner unspecified`),` · `,e.dueDate??(l?`期限未明确`:`Date unspecified`)]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-xs`,children:[e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:we,className:`text-accent-fg`,onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:l?`查看原话`:`Source`}):null,t?t.deleted?(0,$.jsx)(`span`,{children:l?`关联任务已删除`:`Linked task deleted`}):(0,$.jsx)(s,{className:`text-accent-fg`,to:Ie(`${c.pathname}${c.search}`,t.taskId),children:t.resolution===`done`?l?`已完成 · 查看任务`:`Done · View task`:l?`查看任务 / 交给助手`:`View task / Delegate`}):e.ignored?null:(0,$.jsx)(J,{disabled:we||N||!!(e.supersededBy||e.disputedBy)&&e.reviewedChangeId!==(e.supersededBy??e.disputedBy),onClick:()=>void Re(()=>p(u(`${L}/actions/${encodeURIComponent(e.id)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Qe.revision})})),children:l?`加入我的任务`:`Add to my tasks`})]})]},e.id)})]}):null,Xe(l?`风险`:`Risks`,X.risks,`risks`),Xe(l?`尚未确定`:`Open questions`,X.openQuestions,`openQuestions`),X.changes?.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:l?`前后变更`:`Changes during the meeting`}),X.changes.map(e=>{let t=[...X.decisions,...X.actionItems,...X.risks,...X.openQuestions],n=t.find(t=>t.id===e.fromId),r=t.find(t=>t.id===e.toId);return!n||!r?null:(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.relation===`supersedes`?l?`后续撤销或替代`:`Later superseded`:l?`存在冲突,尚未明确解决`:`Unresolved conflict`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void K(n.evidenceSegmentIds,n.evidenceRevision),children:`title`in n?n.title:n.text}),(0,$.jsx)(`span`,{children:`↓`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void K(r.evidenceSegmentIds,r.evidenceRevision),children:`title`in r?r.title:r.text})]},`${e.fromId}:${e.toId}`)})]}):null]}):(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[46rem] space-y-4 py-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:Ze.text?l?`录音摘录`:`From your recording`:Y.status===`needs_attention`?l?`纪要暂未生成`:`Summary unavailable`:l?`笔记正在整理`:`Preparing your note`}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7 ${Ze.text?`text-fg`:`text-fg-muted`}`,children:Ze.text?Ze.text.slice(0,400)+(Ze.text.length>400?`…`:``):l?`文字整理完成后,重点和行动会出现在这里。`:`Highlights and actions will appear as processing completes.`}),Ze.text?(0,$.jsx)(J,{className:`min-h-11`,onClick:()=>te(`transcript`),children:l?`查看原文`:`Read transcript`}):null]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[tt.slice(0,Ee*50).map(e=>(0,$.jsxs)(`article`,{"data-reading-anchor":`segment:${e.sequence}`,id:`discussion-segment-${e.sequence}`,className:`rounded-md border p-3 ${Oe.includes(e.sequence)||z.anchor===e.sequence&&z.anchorRevision===Ze.revision?`border-accent`:`border-edge-subtle`}`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 text-xs text-fg-muted`,children:[(0,$.jsxs)(`button`,{className:`inline-flex items-center gap-1 text-accent-fg`,disabled:!Y.audioAttachmentId||!!Y.audioDeletedAt,onClick:()=>void K([e.sequence],Ze.revision,!0),children:[(0,$.jsx)(ze,{className:`size-3`}),Ht(e.startedAtMs)]}),e.status===`confirmed`&&!N?(0,$.jsx)(`button`,{onClick:()=>void Je(e),children:l?`标记此段`:`Highlight segment`}):null,(0,$.jsx)(`span`,{children:e.speakerLabel??(l?`未区分说话人`:`Speaker unknown`)}),et&&e.status===`confirmed`?(0,$.jsx)(`button`,{className:`ml-auto`,onClick:()=>v({segment:e,text:e.displayText??e.rawText??``,speaker:e.speakerLabel??``}),children:l?`校对`:`Edit`}):null]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6`,children:e.displayText??e.rawText??(l?`等待转写`:`Awaiting transcription`)})]},e.sequence)),tt.length>Ee*50?(0,$.jsx)(J,{onClick:()=>De(Ee+1),children:l?`加载更多`:`More`}):null]})}),(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-[46rem]`,children:(0,$.jsx)(Pt,{id:Y.id,query:ne.trim(),zh:l,sourceKey:`${Y.audioSha256}:${Y.audioDeletedAt}`,active:$e||Y.status===`recording`,tab:V,refreshKey:`${Y.updatedAt}:${Ze.revision}:${Qe?.revision}`,onEvidence:Ke,onPlay:Be},Y.id)})]}),(0,$.jsx)(`div`,{className:i?`min-h-0 min-w-0 flex-1 overflow-hidden`:`hidden`,children:r}),W||ue?(0,$.jsxs)(`aside`,{ref:le,tabIndex:-1,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),Ue())},"aria-label":l?`原话证据`:`Source evidence`,className:`flex min-h-0 w-full min-w-0 flex-col border-edge bg-surface-panel outline-none @min-[58rem]/discussion:w-[22rem] @min-[58rem]/discussion:shrink-0 @min-[58rem]/discussion:border-l`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,$.jsxs)(`h3`,{children:[l?`原话证据`:`Source evidence`,` `,W?`· v${W.transcriptRevision}`:``]}),(0,$.jsx)(`button`,{"aria-label":l?`关闭`:`Close`,className:`inline-flex size-11 items-center justify-center rounded-lg hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,onClick:Ue,children:(0,$.jsx)(qe,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[ue?(0,$.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-3`,children:[(0,$.jsx)(q,{className:`h-4 w-1/3`}),(0,$.jsx)(q,{className:`h-24 w-full`})]}):null,W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`按整段定位,不代表词句级时间。`:`Segment timing; not word-level alignment.`}),W.stale?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`原文已更新,以下保留当时版本的依据。`:`Transcript updated; showing the original evidence revision.`}):null,!W.audioAvailable||!W.timingVerified?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`原文仍可查看;原音不可用或时间定位待核实。`:`Text remains available; audio is missing or timing is unverified.`}):null,W.segments.map(t=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[Ht(t.startedAtMs),`–`,Ht(t.endedAtMs),` · `,t.speakerLabel??(l?`说话人未明确`:`Unknown speaker`)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-7`,children:t.text}),t.playback.map((e,t)=>(0,$.jsxs)(J,{onClick:()=>Be(e.startedAtMs,e.endedAtMs),children:[l?`播放原话`:`Play source`,` `,Ht(e.startedAtMs),`–`,Ht(e.endedAtMs)]},t)),!W.stale&&W.transcriptRevision===d?.transcript.revision&&W.transcriptRevision!==Ze.revision?(0,$.jsx)(J,{onClick:()=>F(),children:l?`查看最新原文`:`View latest transcript`}):null,!W.stale&&W.transcriptRevision===d?.transcript.revision&&W.transcriptRevision===Ze.revision?(0,$.jsx)(J,{onClick:()=>{re(``),De(Math.max(Ee,Math.ceil((Ze.segments.findIndex(e=>e.sequence===t.sequence)+1)/50))),te(`transcript`),ke([t.sequence]),_e(null),pe(!0),B(e,{anchor:t.sequence,anchorRevision:Ze.revision}),window.setTimeout(()=>document.getElementById(`discussion-segment-${t.sequence}`)?.scrollIntoView?.({block:`center`}),0)},children:l?`定位原文`:`Locate transcript`}):null]},t.sequence))]}):null]})]}):null]}),Y.audioAttachmentId&&!Y.audioDeletedAt?(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)(`audio`,{ref:Ne,controls:!0,preload:`metadata`,className:`h-10 w-full`,src:u(`${L}/audio`),onTimeUpdate:()=>{let t=(Ne.current?.currentTime??0)*1e3;Le(t),B(e,{positionMs:t}),G.current!==null&&t>=G.current&&(Ne.current?.pause(),G.current=null)},onLoadedMetadata:()=>{Fe.current!==null&&Ne.current?(Ne.current.currentTime=Fe.current,Fe.current=null,Ne.current.play().catch(()=>void 0)):Ne.current&&(Ne.current.currentTime=z.positionMs/1e3)},onError:()=>Ce(l?`录音暂不可播放`:`Recording unavailable`)})}):null,y&&Qe?(0,$.jsx)(Bt,{initial:y,zh:l,busy:we,onClose:()=>w(null),onSave:e=>Re(async()=>{await p(u(`${L}/summary`),{method:`PATCH`,body:JSON.stringify({...e,expectedRevision:Qe.revision})}),w(null)})},`${y.kind}:${y.itemId}:${Qe.revision}`):null,_?(0,$.jsx)(C,{open:!0,onOpenChange:e=>{e||v(null)},children:(0,$.jsxs)(b,{children:[(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(x,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(28rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`header`,{className:`flex items-center justify-between border-b border-edge p-4`,children:[(0,$.jsx)(S,{children:l?`校对逐字稿`:`Edit transcript`}),(0,$.jsx)(`button`,{"aria-label":l?`关闭校对`:`Close editor`,onClick:()=>v(null),children:(0,$.jsx)(qe,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[(0,$.jsxs)(`label`,{className:`block text-xs`,children:[l?`本段说话人`:`Speaker for this segment`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:_.speaker,onChange:e=>v({..._,speaker:e.target.value})})]}),_.segment.speakerLabel?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!_.applyToSpeakerGroup,onChange:e=>v({..._,applyToSpeakerGroup:e.target.checked})}),l?`同时更名所有同标签片段;输入已有标签可合并说话人`:`Rename all segments with this label; use an existing label to merge speakers`]}):null,(0,$.jsx)(`textarea`,{className:`min-h-32 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:_.text,onChange:e=>v({..._,text:e.target.value})})]}),(0,$.jsx)(`footer`,{className:`border-t border-edge p-3`,children:(0,$.jsxs)(J,{variant:`primary`,disabled:we||!_.text.trim(),onClick:()=>void Re(async()=>{await p(u(`${L}/segments/${_.segment.sequence}`),{method:`PATCH`,body:JSON.stringify({displayText:_.text,speakerLabel:_.speaker,expectedRevision:_.segment.revision,applyToSpeakerGroup:_.applyToSpeakerGroup,expectedTranscriptRevision:Ze.revision})}),v(null)}),children:[(0,$.jsx)(ae,{className:`size-4`}),l?`保存修订`:`Save revision`]})})]})]})}):null]})}var Wt={edit:Re,ai_edit:Ue,sync:Be,restore:w};function Gt(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function Kt({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let a=f(e=>e.language),o=h(a).notes,s={justNow:o.justNow,minutesAgo:o.minutesAgo,today:o.today,yesterday:o.yesterday,daysAgo:o.daysAgo,locale:l(a)},{data:c}=Ye(e?[`note-history`,e]:null,()=>Ee(e)),[u,d]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=(0,Q.useCallback)(async t=>{d(!0),_(null);try{await xe(e,t),m(null),i()}catch{_(o.restoreFailed)}finally{d(!1)}},[e,o.restoreSuccess,o.restoreFailed,i]),y=Date.now();return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(he,{className:`size-4`,"aria-hidden":!0}),o.history]}),(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(qe,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[g?(0,$.jsx)(`p`,{className:`border-b border-danger/20 bg-danger-soft px-4 py-2 text-xs text-danger`,role:`alert`,children:g}):null,c?.length?(0,$.jsx)(`ul`,{className:`divide-y divide-edge`,children:c.map(e=>{let r=Wt[e.trigger]??Re,i=t===e.timestamp,a=p===e.timestamp;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:K(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(r,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:Gt(e.trigger,o)}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:yt(e.timestamp,y,s)})]}),e.snippet&&(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,$.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:a?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:o.restoreConfirm}),(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),v(e.timestamp)},disabled:u,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:u?`...`:o.restore}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),m(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:o.restore})})]},e.timestamp)})}):(0,$.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:o.historyEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:o.historyEmptyDescription})]})]})]})}function qt({noteId:e,note:t,catalyzing:n,onCatalyze:r,onClose:i,noteThreads:a,openingChat:o,onOpenChat:s,onOpenNewChat:l}){let u=h(f(e=>e.language)).notes,d=c(),p=t?.aiDeep?.catalysis,m=p?.report??null,[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),{data:b,mutate:x,isLoading:S}=Ye(e?[`note-agent-context-status`,e]:null,()=>G(e),{revalidateOnFocus:!1}),C=(0,Q.useCallback)(async()=>{if(!v){y(!0),_(null);try{await x(()=>Pe(e),{revalidate:!1})}catch(e){_(`${u.contextRebuildFailed}: ${e instanceof Error?e.message:u.quickCaptureFailedHint}`)}finally{y(!1)}}},[v,x,u.contextRebuildFailed,u.quickCaptureFailedHint,e]),w=(0,Q.useCallback)(async t=>{try{await be(e,t)}catch{}},[e]);return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ue,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:u.catalysisSectionTitle})]}),(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":u.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(F,{className:`size-4 rotate-180`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,$.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:u.catalysisSectionDescription}),b?(0,$.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.contextStatusTitle}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:S||v,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:v?u.processing:u.contextRebuild}),(0,$.jsx)(`span`,{className:K(`rounded-full px-2 py-0.5 text-[11px] font-medium`,b.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:b.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:b.status})]}),(0,$.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:u.contextStatusDetail.replace(`{{attachments}}`,String(b.attachments.length)).replace(`{{tokens}}`,String(b.tokenEstimate??0))}),g?(0,$.jsx)(`p`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:g}):null,b.attachments.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:b.attachments.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId))}):null]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:n?u.processing:m?u.recatalyze:u.catalyzeAction}),m?(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.valueHypothesis}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:m.valueHypothesis})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.targetUsers}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:m.targetUsers.slice(0,5).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.keyQuestions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.keyQuestions.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.mvpPathLabel}),(0,$.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.mvpPath.slice(0,3).map((e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.risks}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.risks.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-fg-muted`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.nextActions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.nextActions.slice(0,4).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,$.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:u.confidenceLabel.replace(`{{percent}}`,String(Math.round(m.confidence*100)))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(`helpful`),className:K(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackHelpfulAria,children:(0,$.jsx)(z,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(`not_helpful`),className:K(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackNotHelpfulAria,children:(0,$.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})})]})]})]}):(0,$.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:u.noCatalysisReportHint}),(0,$.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Le,{className:`size-4 text-accent`,"aria-hidden":!0}),u.relatedThreadsTitle]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.relatedThreadsDescription})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:s,disabled:o,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:o?u.openingChat:u.openThread}),(0,$.jsx)(`button`,{type:`button`,onClick:l,disabled:o,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:u.newThread})]})]}),a.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:a.slice(0,5).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||u.noteDiscussionFallback}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:u.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:u.noThreads})]})]})]})}var Jt=[{value:`86400000`,zh:`24 小时`,en:`24 hours`},{value:`604800000`,zh:`7 天`,en:`7 days`},{value:`2592000000`,zh:`30 天`,en:`30 days`}];function Yt({open:e,onOpenChange:t,note:n}){let r=f(e=>e.language)===`zh`,i=r?$t:en,{data:a,mutate:o}=Ye(e?[`note-shares`,n.id]:null,()=>Oe(n.id)),s=Ye(e?`hosted-share-auth-status`:null,tt),c=s.data===!0,l=Ye(e&&c?`hosted-publication-capabilities`:null,rt),u=l.data?.publishing.allowed===!0,d=Ye(e&&c?[`hosted-note-publications`,n.id]:null,()=>Te(n.id)),[p,m]=(0,Q.useState)(new Set),[h,_]=(0,Q.useState)(`86400000`),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[O,k]=(0,Q.useState)(`hosted`),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(null),B=(0,Q.useMemo)(()=>{let e=new Set;return n.markdown.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^\s)]+)/gi,(t,r,i)=>{try{decodeURIComponent(r)===n.id&&e.add(decodeURIComponent(i))}catch{}return t}),(n.attachments??[]).filter(t=>e.has(t.id))},[n.attachments,n.id,n.markdown]);(0,Q.useEffect)(()=>{e&&(m(new Set(B.map(e=>e.id))),F(null),L(!1),z(null))},[e,B]);let V=async()=>{j(!0),z(null);try{let e={expectedNoteVersion:n.updatedAt,attachmentIds:[...p],ttlMs:Number(h),maxViews:w.trim()?Number(w):null,description:E.trim()||void 0};if(O===`hosted`){let t=await Ae(n.id,e);F(t.shareUrl),await d.mutate()}else{let t=await Ce(n.id,e);F(t.payload.shareUrl),await o()}}catch(e){z(e instanceof Error?e.message:String(e))}finally{j(!1)}},te=async(e,t)=>{N(e.id),z(null);try{t===`refresh`?await ge(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...p]}):await it(e.id),await d.mutate()}catch(e){z(e instanceof Error?e.message:String(e))}finally{N(null)}},ne=async(e,t)=>{N(e.id),z(null);try{t===`refresh`?await Ne(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...p]}):t===`extend`?await nt(e.id,864e5):await et(e.id),await o()}catch(e){z(e instanceof Error?e.message:String(e))}finally{N(null)}},re=async e=>{z(null);try{if(!await Xe(e)){L(!1),z(i.copyFailed);return}L(!0),window.setTimeout(()=>L(!1),1500)}catch{L(!1),z(i.copyFailed)}};return(0,$.jsx)(C,{open:e,onOpenChange:t,children:(0,$.jsxs)(b,{children:[(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(x,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(S,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,$.jsx)(ee,{className:`size-4`}),i.title]}),(0,$.jsx)(v,{className:`mt-1 text-xs text-fg-muted`,children:i.description})]}),(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-fg-muted hover:bg-surface-hover`,"aria-label":i.close,children:(0,$.jsx)(qe,{className:`size-4`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-inset p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.title||i.untitled}),(0,$.jsx)(`p`,{className:`mt-2 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,children:n.markdown||i.empty}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:i.privateExcluded})]}),B.length>0?(0,$.jsxs)(`section`,{className:`mt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.attachments}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:B.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:p.has(e.id),onChange:()=>m(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),className:`accent-accent`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:Qt(e.size)})]},e.id))})]}):null,(0,$.jsxs)(`section`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.delivery,(0,$.jsxs)(se,{value:O,onChange:e=>k(e.target.value),children:[(0,$.jsx)(H,{value:`hosted`,children:i.deliveryHosted}),(0,$.jsx)(H,{value:`local`,children:i.deliveryLocal})]})]}),O===`hosted`&&s.data===!1?(0,$.jsx)(`div`,{className:`sm:col-span-2`,children:(0,$.jsx)(Z,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:()=>void s.mutate(!0,{revalidate:!1})})}):null,O===`hosted`&&c&&l.data&&!u?(0,$.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning sm:col-span-2`,children:i.hostedDisabled}):null,(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.expires,(0,$.jsx)(se,{value:h,onChange:e=>_(e.target.value),children:Jt.map(e=>(0,$.jsx)(H,{value:e.value,children:r?e.zh:e.en},e.value))})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.maxViews,(0,$.jsx)(`input`,{type:`number`,min:1,max:1e3,value:w,onChange:e=>T(e.target.value),placeholder:i.unlimited,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.publicDescription,(0,$.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]})]}),P?(0,$.jsx)(`div`,{className:`mt-5 rounded-lg border border-success/25 bg-success-soft p-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{readOnly:!0,value:P,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,$.jsxs)(J,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void re(P),children:[I?(0,$.jsx)(ae,{className:`size-4`}):(0,$.jsx)(U,{className:`size-4`}),I?i.copied:i.copy]}),(0,$.jsxs)(J,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>window.open(P,`_blank`,`noopener,noreferrer`),children:[(0,$.jsx)(fe,{className:`size-4`}),i.open]})]})}):null,R?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,children:R}):null,(a?.items.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.activeLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:a.items.map(e=>(0,$.jsx)(Zt,{share:e,busy:M===e.id,t:i,onCopy:re,onAction:ne},e.id))})]}):null,(d.data?.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.hostedLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:d.data.map(e=>(0,$.jsx)(Xt,{publication:e,stale:e.source?.version!==String(n.updatedAt),busy:M===e.id,publishingAllowed:u,t:i,onCopy:re,onAction:te},e.id))})]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-3`,children:[(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,children:i.close})}),(0,$.jsxs)(J,{type:`button`,onClick:()=>void V(),disabled:A||O===`hosted`&&(!c||!u),children:[A?(0,$.jsx)(Fe,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),A?i.creating:i.create]})]})]})]})})}function Xt(e){let t=(0,mt.c)(64),{publication:n,stale:r,busy:i,publishingAllowed:a,t:o,onCopy:s,onAction:c}=e,l=n.revoked||n.expired,u=l&&`opacity-60`,d;t[0]===u?d=t[1]:(d=K(`rounded-lg border border-edge-subtle p-3`,u),t[0]=u,t[1]=d);let f=r&&!l?o.stale:l?o.inactive:o.active,p;t[2]===f?p=t[3]:(p=(0,$.jsx)(`span`,{children:f}),t[2]=f,t[3]=p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`span`,{children:`·`}),t[4]=m):m=t[4];let h=n.maxViews===null?``:` / ${n.maxViews}`,g;t[5]!==n.viewCount||t[6]!==o.views||t[7]!==h?(g=(0,$.jsxs)(`span`,{children:[o.views,` `,n.viewCount,h]}),t[5]=n.viewCount,t[6]=o.views,t[7]=h,t[8]=g):g=t[8];let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{children:`·`}),t[9]=_):_=t[9];let v;t[10]!==n.revision||t[11]!==o.revision?(v=(0,$.jsxs)(`span`,{children:[o.revision,` `,n.revision]}),t[10]=n.revision,t[11]=o.revision,t[12]=v):v=t[12];let y;t[13]!==p||t[14]!==g||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,g,_,v]}),t[13]=p,t[14]=g,t[15]=v,t[16]=y):y=t[16];let b;t[17]===n.shareUrl?b=t[18]:(b=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[17]=n.shareUrl,t[18]=b);let x;t[19]!==y||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[y,b]}),t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;t[22]===i?S=t[23]:(S=i?(0,$.jsx)(Fe,{className:`size-4 animate-spin text-fg-muted`}):null,t[22]=i,t[23]=S);let C;t[24]!==x||t[25]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[x,S]}),t[24]=x,t[25]=S,t[26]=C):C=t[26];let w=!a,T;t[27]!==s||t[28]!==n.shareUrl?(T=()=>void s(n.shareUrl),t[27]=s,t[28]=n.shareUrl,t[29]=T):T=t[29];let E;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(U,{className:`size-3.5`}),t[30]=E):E=t[30];let D;t[31]!==o.copy||t[32]!==w||t[33]!==T?(D=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:w,onClick:T,children:[E,o.copy]}),t[31]=o.copy,t[32]=w,t[33]=T,t[34]=D):D=t[34];let O=!a,k;t[35]===n.shareUrl?k=t[36]:(k=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=k);let A;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(fe,{className:`size-3.5`}),t[37]=A):A=t[37];let j;t[38]!==o.open||t[39]!==O||t[40]!==k?(j=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:O,onClick:k,children:[A,o.open]}),t[38]=o.open,t[39]=O,t[40]=k,t[41]=j):j=t[41];let M;t[42]!==i||t[43]!==l||t[44]!==c||t[45]!==n||t[46]!==a||t[47]!==r||t[48]!==o.refresh?(M=r&&!l?(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i||!a,onClick:()=>void c(n,`refresh`),children:[(0,$.jsx)(Be,{className:`size-3.5`}),o.refresh]}):null,t[42]=i,t[43]=l,t[44]=c,t[45]=n,t[46]=a,t[47]=r,t[48]=o.refresh,t[49]=M):M=t[49];let N;t[50]!==i||t[51]!==c||t[52]!==n||t[53]!==o.revoke?(N=n.revoked?null:(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i,onClick:()=>void c(n,`revoke`),children:[(0,$.jsx)(Ke,{className:`size-3.5`}),o.revoke]}),t[50]=i,t[51]=c,t[52]=n,t[53]=o.revoke,t[54]=N):N=t[54];let P;t[55]!==D||t[56]!==j||t[57]!==M||t[58]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[D,j,M,N]}),t[55]=D,t[56]=j,t[57]=M,t[58]=N,t[59]=P):P=t[59];let F;return t[60]!==C||t[61]!==d||t[62]!==P?(F=(0,$.jsxs)(`div`,{className:d,children:[C,P]}),t[60]=C,t[61]=d,t[62]=P,t[63]=F):F=t[63],F}function Zt(e){let t=(0,mt.c)(68),{share:n,busy:r,t:i,onCopy:a,onAction:o}=e,s=n.revoked||n.expired,c=s&&`opacity-60`,l;t[0]===c?l=t[1]:(l=K(`rounded-lg border border-edge-subtle p-3`,c),t[0]=c,t[1]=l);let u=n.stale&&!s?i.stale:s?i.inactive:i.active,d;t[2]===u?d=t[3]:(d=(0,$.jsx)(`span`,{children:u}),t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{children:`·`}),t[4]=f):f=t[4];let p=n.maxViews===null?``:` / ${n.maxViews}`,m;t[5]!==n.viewCount||t[6]!==i.views||t[7]!==p?(m=(0,$.jsxs)(`span`,{children:[i.views,` `,n.viewCount,p]}),t[5]=n.viewCount,t[6]=i.views,t[7]=p,t[8]=m):m=t[8];let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`span`,{children:`·`}),t[9]=h):h=t[9];let g;t[10]===n.expiresAt?g=t[11]:(g=new Date(n.expiresAt).toLocaleDateString(),t[10]=n.expiresAt,t[11]=g);let _;t[12]===g?_=t[13]:(_=(0,$.jsx)(`span`,{children:g}),t[12]=g,t[13]=_);let v;t[14]!==_||t[15]!==d||t[16]!==m?(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[d,f,m,h,_]}),t[14]=_,t[15]=d,t[16]=m,t[17]=v):v=t[17];let y;t[18]===n.shareUrl?y=t[19]:(y=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[18]=n.shareUrl,t[19]=y);let b;t[20]!==v||t[21]!==y?(b=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[v,y]}),t[20]=v,t[21]=y,t[22]=b):b=t[22];let x;t[23]===r?x=t[24]:(x=r?(0,$.jsx)(Fe,{className:`size-4 animate-spin text-fg-muted`}):null,t[23]=r,t[24]=x);let S;t[25]!==b||t[26]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,x]}),t[25]=b,t[26]=x,t[27]=S):S=t[27];let C;t[28]!==a||t[29]!==n.shareUrl?(C=()=>void a(n.shareUrl),t[28]=a,t[29]=n.shareUrl,t[30]=C):C=t[30];let w;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(U,{className:`size-3.5`}),t[31]=w):w=t[31];let T;t[32]!==i.copy||t[33]!==C?(T=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:C,children:[w,i.copy]}),t[32]=i.copy,t[33]=C,t[34]=T):T=t[34];let E;t[35]===n.shareUrl?E=t[36]:(E=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=E);let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(fe,{className:`size-3.5`}),t[37]=D):D=t[37];let O;t[38]!==i.open||t[39]!==E?(O=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:E,children:[D,i.open]}),t[38]=i.open,t[39]=E,t[40]=O):O=t[40];let k;t[41]!==r||t[42]!==s||t[43]!==o||t[44]!==n||t[45]!==i.refresh?(k=n.stale&&!s?(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`refresh`),children:[(0,$.jsx)(Be,{className:`size-3.5`}),i.refresh]}):null,t[41]=r,t[42]=s,t[43]=o,t[44]=n,t[45]=i.refresh,t[46]=k):k=t[46];let A;t[47]!==r||t[48]!==s||t[49]!==o||t[50]!==n||t[51]!==i.extend?(A=s?null:(0,$.jsx)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`extend`),children:i.extend}),t[47]=r,t[48]=s,t[49]=o,t[50]=n,t[51]=i.extend,t[52]=A):A=t[52];let j;t[53]!==r||t[54]!==o||t[55]!==n||t[56]!==i.revoke?(j=n.revoked?null:(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`revoke`),children:[(0,$.jsx)(Ke,{className:`size-3.5`}),i.revoke]}),t[53]=r,t[54]=o,t[55]=n,t[56]=i.revoke,t[57]=j):j=t[57];let M;t[58]!==T||t[59]!==O||t[60]!==k||t[61]!==A||t[62]!==j?(M=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[T,O,k,A,j]}),t[58]=T,t[59]=O,t[60]=k,t[61]=A,t[62]=j,t[63]=M):M=t[63];let N;return t[64]!==S||t[65]!==l||t[66]!==M?(N=(0,$.jsxs)(`div`,{className:l,children:[S,M]}),t[64]=S,t[65]=l,t[66]=M,t[67]=N):N=t[67],N}function Qt(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var $t={title:`分享笔记`,description:`创建一个无需登录即可查看的只读快照。`,close:`关闭`,untitled:`无标题笔记`,empty:`空笔记`,privateExcluded:`不会分享标签、AI 元数据、项目、讨论、历史版本或未引用附件。`,attachments:`包含的附件`,expires:`有效期`,maxViews:`最多查看次数`,unlimited:`不限`,publicDescription:`公开说明(可选)`,create:`创建分享链接`,creating:`创建中…`,copy:`复制`,copied:`已复制`,open:`打开`,activeLinks:`这条笔记的分享`,copyFailed:`无法复制到剪贴板,请手动选择链接并复制。`,delivery:`发布方式`,deliveryHosted:`平台托管(外网稳定访问)`,deliveryLocal:`本机直连(需要隧道或公网部署)`,hostedLinks:`平台托管发布`,revision:`版本`,hostedDisabled:`管理员已暂停你的公网分享能力。已有托管链接当前不可访问,但仍可撤销。`,stale:`旧版本`,inactive:`已失效`,active:`有效`,views:`查看`,refresh:`更新快照`,extend:`延长 24 小时`,revoke:`撤销`},en={title:`Share Note`,description:`Create a read-only snapshot that opens without sign-in.`,close:`Close`,untitled:`Untitled Note`,empty:`Empty Note`,privateExcluded:`Tags, AI metadata, projects, discussions, history, and unreferenced attachments are excluded.`,attachments:`Included attachments`,expires:`Expires`,maxViews:`Maximum views`,unlimited:`Unlimited`,publicDescription:`Public description (optional)`,create:`Create share link`,creating:`Creating…`,copy:`Copy`,copied:`Copied`,open:`Open`,activeLinks:`Shares for this Note`,copyFailed:`Could not copy to the clipboard. Select the link and copy it manually.`,delivery:`Publishing method`,deliveryHosted:`Hosted platform (stable public access)`,deliveryLocal:`Direct from this device (requires public access)`,hostedLinks:`Hosted publications`,revision:`Revision`,hostedDisabled:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but can still be revoked.`,stale:`Older version`,inactive:`Inactive`,active:`Active`,views:`Views`,refresh:`Update snapshot`,extend:`Extend 24 hours`,revoke:`Revoke`},tn=e(n(),1);function nn({noteId:e,selection:t,zh:n,onDismiss:r,onAsk:i}){let[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(``),[f,m]=(0,Q.useState)(!1),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),[_,v]=(0,Q.useState)({left:8,top:8}),y=s||a!==null||!!l,b=t.text.length>16e3;function x(){h.current?.abort(),r(),t.restore()}(0,Q.useEffect)(()=>{o(null),c(!1),d(``),m(!1);let e=e=>{g.current?.contains(e.target)||r()},n=e=>{e.key===`Escape`&&(e.preventDefault(),r(),t.restore())},i=e=>{!g.current?.contains(e.target)&&!h.current&&!g.current?.contains(document.activeElement)&&r()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,n),window.addEventListener(`resize`,r),window.addEventListener(`scroll`,i,!0),()=>{h.current?.abort(),h.current=null,document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,r),window.removeEventListener(`scroll`,i,!0)}},[t,r]),(0,Q.useLayoutEffect)(()=>{let e=g.current?.getBoundingClientRect();if(!e)return;let n=Math.max(8,Math.min(t.rect.left,window.innerWidth-e.width-8)),r=t.rect.bottom+8,i=r+e.height<=window.innerHeight-8?r:Math.max(8,t.rect.top-e.height-8);v({left:n,top:i})},[t,y,a,l]);async function S(r){h.current?.abort();let i=new AbortController;h.current=i,c(!0),d(``),o(null),m(!1);try{let a=await p(u(`/api/notes/${encodeURIComponent(e)}/ai/edit`),{method:`POST`,signal:i.signal,body:JSON.stringify({instruction:r,markdown:t.text})});if(i.signal.aborted)return;let s=a.patch.operations.filter(e=>e.type===`replaceRange`).map(e=>e.markdown??``).join(`
3
+
4
+ `);if(!s.trim())throw Error(n?`没有可用结果,请重试。`:`No result available. Try again.`);o(s)}catch(e){i.signal.aborted||d(e instanceof Error?e.message:String(e))}finally{i.signal.aborted||(c(!1),h.current=null)}}return(0,tn.createPortal)((0,$.jsxs)(`div`,{ref:g,role:`region`,"data-note-selection-actions":!0,"aria-keyshortcuts":`Alt+Enter`,"aria-label":n?`笔记选段操作`:`Note selection actions`,className:`fixed z-[80] flex max-h-[calc(100dvh-1rem)] max-w-[calc(100vw-1rem)] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-fg shadow-popover ${y?`w-96`:``}`,style:_,onPointerDown:e=>{e.target.closest(`button`)&&e.preventDefault()},children:[(0,$.jsxs)(`div`,{role:`group`,"aria-label":n?`选段操作`:`Selection actions`,className:`flex shrink-0 flex-wrap items-center gap-1 p-1`,children:[(0,$.jsx)(J,{variant:`ghost`,className:`text-xs`,disabled:s||b,onClick:()=>void S(`summary`),children:n?`摘要预览`:`Summary`}),(0,$.jsx)(J,{variant:`ghost`,className:`text-xs`,disabled:s||b,onClick:()=>void S(`todo`),children:n?`提取待办`:`Extract to-dos`}),(0,$.jsx)(J,{variant:`ghost`,className:`text-xs`,disabled:s||b,onClick:()=>i(t.text),children:n?`引用提问`:`Ask about selection`}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 items-center justify-center rounded-lg hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭选段操作`:`Close selection actions`,onClick:x,children:(0,$.jsx)(qe,{className:`size-4`})})]}),b?(0,$.jsx)(`p`,{className:`px-3 pb-3 text-xs text-fg-muted`,children:n?`请选择不超过 16000 字的片段。`:`Select up to 16,000 characters.`}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto border-t border-edge-subtle p-3`,children:[(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,children:n?`按选段生成的本地整理预览,尚未写入笔记。`:`Local preview of the selection. Your note is unchanged.`}),s?(0,$.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-2`,children:[(0,$.jsx)(q,{className:`h-4 w-full`}),(0,$.jsx)(q,{className:`h-4 w-2/3`})]}):null,a===null?null:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-sans text-sm leading-6`,children:a}),l?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:l}):null]}),a===null?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle p-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:()=>void Xe(a).then(e=>{m(e),e||d(n?`复制失败,请重试。`:`Copy failed. Try again.`)}),children:f?n?`已复制`:`Copied`:n?`复制结果`:`Copy`}),(0,$.jsx)(J,{variant:`primary`,onClick:()=>{t.insertAfter(a)?r():d(n?`正文已变化,请重新选择片段后再整理。`:`The note changed. Select the passage again.`)},children:n?`插入选段后`:`Insert after selection`})]})]}):null]}),document.body)}function rn(e){let t=(0,mt.c)(18),{input:n,labels:r,showLabel:i}=e,a=i===void 0||i,o;t[0]===n?o=t[1]:(o=n(),t[0]=n,t[1]=o);let s=o.source.id,c;t[2]===s?c=t[3]:(c=e=>e.source?.type===`note`&&e.source.id===s&&e.status!==`idle`,t[2]=s,t[3]=c);let l=V(c),u;t[4]===s?u=t[5]:(u=e=>e.source?.type===`note`&&e.source.id===s&&e.status===`preparing`,t[4]=s,t[5]=u);let d=V(u),f=V(an),p;t[6]!==n||t[7]!==r||t[8]!==d||t[9]!==a?(p=(0,$.jsx)(I,{input:n,labels:r,disabled:d,showLabel:a}),t[6]=n,t[7]=r,t[8]=d,t[9]=a,t[10]=p):p=t[10];let m;t[11]!==l||t[12]!==r||t[13]!==f?(m=l?(0,$.jsx)(`button`,{type:`button`,onClick:f,title:r.stop,"aria-label":r.stop,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(Ge,{className:`size-3.5`,"aria-hidden":!0})}):null,t[11]=l,t[12]=r,t[13]=f,t[14]=m):m=t[14];let h;return t[15]!==p||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[p,m]}),t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function an(e){return e.stop}function on(e,t){let n=ne(t.replace(/^\s*(`{3,}|~{3,})[^\n]*$/gm,``).replace(/xopc-attachment:\/\/[^\s)]+/g,``).replace(/^(\s*[-*+]\s+)\[[ xX]\]\s*/gm,`$1`)),r=ne(e);return!r||n.split(`
5
+ `)[0]===r?n:[r,n].filter(Boolean).join(`
6
+
7
+ `)}var sn=()=>a(()=>import(`./block-editor-CmnkluMF.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),cn=()=>a(()=>import(`./markdown-editor-CjQJ-Nho.js`),__vite__mapDeps([46,1,2,42,47,17])),ln=(0,Q.lazy)(()=>a(()=>import(`./chat-page-BhPw56Vc.js`).then(e=>e.n).then(e=>({default:e.ChatPage})),__vite__mapDeps([48,1,2,17,16,3,4,11,12,13,6,49,50,51,52,53,54,55,56,57,58,59,9,10,14,15,18,19,20,21,22,23,24,25,26,27,28,29,30,31,7,8,32,34,60,36,38,61,62,63,64,65,66,39,67,68,69,70,71,72,73,74,75,76,77,78,79,40,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,37,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,33,123,35,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,41,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211]))),un=(0,Q.lazy)(()=>sn().then(e=>({default:e.BlockEditor}))),dn=(0,Q.lazy)(()=>cn().then(e=>({default:e.MarkdownEditor})));function fn(){let e=(0,mt.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function pn(e){let t=(0,mt.c)(29),{mode:n,onModeChange:r,labels:i}=e,a;t[0]===i.edit?a=t[1]:(a={id:`wysiwyg`,label:i.edit,Icon:me},t[0]=i.edit,t[1]=a);let o;t[2]===i.source?o=t[3]:(o={id:`source`,label:i.source,Icon:le},t[2]=i.source,t[3]=o);let s;t[4]===i.preview?s=t[5]:(s={id:`preview`,label:i.preview,Icon:pe},t[4]=i.preview,t[5]=s);let c;t[6]!==a||t[7]!==o||t[8]!==s?(c=[a,o,s],t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9];let l=c,u;t[10]!==n||t[11]!==l?(u=l.find(e=>e.id===n)??l[0],t[10]=n,t[11]=l,t[12]=u):u=t[12];let d=u,f=d.Icon,p=mn,m;t[13]===f?m=t[14]:(m=(0,$.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[13]=f,t[14]=m);let h;t[15]===d.label?h=t[16]:(h=(0,$.jsx)(`span`,{children:d.label}),t[15]=d.label,t[16]=h);let g;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(oe,{className:`size-3 text-fg-subtle`,"aria-hidden":!0}),t[17]=g):g=t[17];let _;t[18]!==d.label||t[19]!==m||t[20]!==h?(_=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":d.label,className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-edge px-2.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[m,h,g]})}),t[18]=d.label,t[19]=m,t[20]=h,t[21]=_):_=t[21];let v;t[22]!==n||t[23]!==l||t[24]!==r?(v=(0,$.jsx)(st,{children:(0,$.jsx)(lt,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:l.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,$.jsxs)(ct,{onSelect:()=>r(t),onPointerMove:()=>p(t),onFocus:()=>p(t),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(a,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:i}),n===t?(0,$.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}):null]},t)})})}),t[22]=n,t[23]=l,t[24]=r,t[25]=v):v=t[25];let y;return t[26]!==v||t[27]!==_?(y=(0,$.jsxs)(at,{modal:!1,children:[_,v]}),t[26]=v,t[27]=_,t[28]=y):y=t[28],y}function mn(e){e===`wysiwyg`&&sn(),e===`source`&&cn()}function hn(e){let t=(0,mt.c)(16),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:o,clearHeaderOnCleanup:s,onOpenSearch:c,autoFocus:l,initialMode:u,onAutoFocusConsumed:d}=e,p=a===void 0||a,m=s===void 0||s,g=l!==void 0&&l,_=f(gn),v;t[0]===_?v=t[1]:(v=h(_),t[0]=_,t[1]=v);let y=v.notes.lightboxClose,b;t[2]!==g||t[3]!==o||t[4]!==m||t[5]!==u||t[6]!==n||t[7]!==d||t[8]!==r||t[9]!==c||t[10]!==i||t[11]!==p?(b=(0,$.jsx)(_n,{noteId:n,onBack:r,onSaved:i,showBackButton:p,backButtonClassName:o,clearHeaderOnCleanup:m,onOpenSearch:c,autoFocus:g,initialMode:u,onAutoFocusConsumed:d}),t[2]=g,t[3]=o,t[4]=m,t[5]=u,t[6]=n,t[7]=d,t[8]=r,t[9]=c,t[10]=i,t[11]=p,t[12]=b):b=t[12];let x;return t[13]!==y||t[14]!==b?(x=(0,$.jsx)(ye,{closeLabel:y,children:b}),t[13]=y,t[14]=b,t[15]=x):x=t[15],x}function gn(e){return e.language}function _n({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:a=!0,onOpenSearch:o,autoFocus:s=!1,initialMode:l=`wysiwyg`,onAutoFocusConsumed:u}){let p=f(e=>e.language),m=h(p).notes,g=h(p).chat.pageContext,_=h(p).automations.suggestions,{data:v}=Ye([`note-discussion-document`,e],()=>E(e)),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(null),C=(0,Q.useCallback)(()=>S(null),[]);(0,Q.useEffect)(()=>{S(null)},[e]);let w=c(),T=Ze(e=>e.resolved)===`dark`,{openImage:D}=_e(),[O,k]=(0,Q.useState)(l);(0,Q.useEffect)(()=>{S(null)},[O,y]);let[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(null),[P,I]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(``),[B,te]=(0,Q.useState)(360),[ne,ie]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),[H,ce]=(0,Q.useState)(!1),[le,U]=(0,Q.useState)(!1),[ue,fe]=(0,Q.useState)(null),pe=(0,Q.useRef)(0),[ge,ye]=(0,Q.useState)(null),be=d(e=>e.baseUrl),xe=d(e=>e.conversationId),Ce=ue?.noteId===e&&ue.gatewayUrl===be&&ue.gatewayToken===xe?ue.conversationId:null;(0,Q.useEffect)(()=>(pe.current++,U(!1),fe(null),ce(!1),ye(null),b(!0),()=>{pe.current++}),[e,be,xe]);let Te=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{Te.current+=1},[e]);let[Ee,G]=(0,Q.useState)(null),[Oe,Ae]=(0,Q.useState)(!1),[Ne,Pe]=(0,Q.useState)(null),[Fe,Ie]=(0,Q.useState)(!1),[Re,ze]=(0,Q.useState)(!1),Be=(0,Q.useRef)(!1),He=(0,Q.useRef)(null),We=(0,Q.useRef)(null),Ge=(0,Q.useRef)(null),q=(0,Q.useRef)(null),J=(0,Q.useRef)(void 0),Xe=(0,Q.useRef)(null),X=(0,Q.useRef)(null),et=(0,Q.useRef)(null),tt=(0,Q.useRef)(null),nt=(0,Q.useRef)(null),rt=Qe(e=>e.setPageHeader),it=Qe(e=>e.clearPageHeader),{data:Z,mutate:pt,error:mt}=Ye(e?[`note-detail`,e]:null,()=>we(e)),{data:ht=[],mutate:gt}=Ye(e?[`note-threads`,e]:null,()=>De(e),{revalidateOnFocus:!1}),_t=M!==null,vt=(0,Q.useCallback)(e=>{G(`${m.refreshFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)},[m.quickCaptureFailedHint,m.refreshFailed]);(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&pt().catch(vt)};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[pt,e,vt]),(0,Q.useEffect)(()=>{z(``),N(null),j(null),Be.current=!1,nt.current=null},[e]),(0,Q.useEffect)(()=>{!Z||P||q.current!==null||Be.current||z(Z.title??``)},[Z,P]),(0,Q.useEffect)(()=>{if(!s||!Z||_t||nt.current===e)return;let t=window.requestAnimationFrame(()=>{tt.current?.focus(),u?.()});return nt.current=e,()=>window.cancelAnimationFrame(t)},[s,_t,Z,e,u]);let yt=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,bt=(0,Q.useMemo)(()=>r?(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":m.back,className:K(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,Y,i),children:(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0})}):null,[i,m.back,t,r]),xt=(0,Q.useCallback)(()=>{let t=V.getState();t.source?.type===`note`&&t.source.id===e&&t.stop()},[e]),Ct=(0,Q.useCallback)(e=>{e!==`preview`&&xt(),k(e)},[xt]);(0,Q.useEffect)(()=>{!P&&Ge.current===null&&q.current===null&&(J.current=Z?.remoteVersion??1)},[e,Z?.remoteVersion,P]);let wt=(0,Q.useCallback)(async t=>{let n=J.current??Z?.remoteVersion??1,r=await W(e,t,n);return J.current===n&&(J.current=r.remoteVersion??n+1),r},[e,Z?.remoteVersion]),Tt=(0,Q.useCallback)(t=>{xt(),z(t),e&&(q.current=t,We.current&&clearTimeout(We.current),We.current=setTimeout(async()=>{let e=q.current;if(q.current=null,e!==null){I(!0);try{await wt({title:e}),await pt(),n?.()}catch(t){q.current===null&&(q.current=e),G(`${m.saveFailed}: ${t instanceof Error?t.message:m.saveFailedHint}`)}finally{I(!1)}}},600))},[xt,e,pt,n,wt,m.saveFailed,m.saveFailedHint]),Et=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-2`,Y),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:R||yt||void 0,children:R||yt}),P?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:m.saving}):null]}),[m.saving,P,yt,R]),Dt=(0,Q.useCallback)(async()=>{se(!0),G(null);try{await ke(e),await pt()}catch(e){G(`${m.catalysisFailed}: ${e instanceof Error?e.message:m.chatOpenFailedMessage}`)}finally{se(!1)}},[pt,e]),Ot=(0,Q.useCallback)(()=>{U(!1),j(A===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!oe&&Dt()},[A,oe,Dt,Z?.aiDeep?.catalysis?.report]),kt=(0,Q.useCallback)(()=>{let t=M?M.markdown??``:Ge.current??Z?.markdown??``,n=M?M.title??``:R,r=on(n,t);return{source:{type:`note`,id:e,title:n||m.titlePlaceholder},text:r,language:L(r,p)}},[p,m.titlePlaceholder,Z?.markdown,e,M,R]),At=(0,Q.useCallback)(async()=>{He.current&&clearTimeout(He.current),We.current&&clearTimeout(We.current),He.current=null,We.current=null;let e=Ge.current,t=q.current;Ge.current=null,q.current=null;let r={};if(e!==null&&(r.markdown=e),t!==null&&(r.title=t),Object.keys(r).length===0)return Z??null;I(!0);try{let e=await wt(r);return await pt(e,{revalidate:!1}),n?.(),e}catch(n){return Ge.current===null&&(Ge.current=e),q.current===null&&(q.current=t),G(`${m.saveFailed}: ${n instanceof Error?n.message:m.saveFailedHint}`),null}finally{I(!1)}},[pt,m.saveFailed,m.saveFailedHint,Z,n,wt]),jt=(0,Q.useCallback)(async()=>P?(G(p===`zh`?`笔记正在保存,请稍后发送。`:`The note is saving. Please send again shortly.`),!1):!!await At()&&Ge.current===null&&q.current===null,[P,p,At]),Mt=(0,Q.useCallback)(async(t=!1)=>{if(j(null),U(!0),H||!t&&Ce)return;let n=++pe.current;ce(!0),G(null);try{if(!await jt())return;let r=await Se(e,{forceNew:t});if(n!==pe.current)return;fe({noteId:e,gatewayUrl:be,gatewayToken:xe,conversationId:r.conversationId}),await pt(),await gt()}catch(e){n===pe.current&&G(`${m.chatOpenFailedTitle}: ${e instanceof Error?e.message:m.chatOpenFailedMessage}`)}finally{n===pe.current&&ce(!1)}},[H,Ce,jt,pt,gt,e,be,xe,m.chatOpenFailedMessage,m.chatOpenFailedTitle]),Nt=(0,Q.useCallback)(async e=>{if(!Z||H||P)return;ce(!0),G(null);let t=d.getState(),n=++Te.current,r=()=>Te.current===n&&d.getState().baseUrl===t.baseUrl&&d.getState().conversationId===t.conversationId;try{let n=window.getSelection(),i=e??(n?.anchorNode&&n.focusNode&&Xe.current?.contains(n.anchorNode)&&Xe.current.contains(n.focusNode)?n.toString():``),a=await At();if(!a||!r())return;if(Ge.current!==null||q.current!==null)throw Error(g.unavailable);let o=dt.capture({title:a.title||a.id,text:a.markdown,resourceRefs:[{kind:`note`,id:a.id,revision:String(a.remoteVersion??1)}],selection:i?{text:i,draft:!1}:void 0}),s=await new Je().createSession();if(!r())return;if(Ge.current!==null||q.current!==null)throw Error(g.unavailable);let c=ft(t.baseUrl,t.conversationId,s.key);if(!dt.put(c,o))throw Error(g.unavailable);w(`/chat/${encodeURIComponent(s.key)}`)}catch{r()&&G(g.unavailable)}finally{Te.current===n&&ce(!1)}},[Z,H,P,At,w,g.unavailable]),Pt=(0,Q.useCallback)(async()=>{G(null);let e=await At();e&&(Pe(e),Ae(!0))},[At]),Ft=(0,Q.useCallback)(async()=>{if(!(Re||P)){Ie(!1),ze(!0),G(null),xt(),He.current&&clearTimeout(He.current),We.current&&clearTimeout(We.current),He.current=null,We.current=null,Ge.current=null,q.current=null;try{await je(e),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e}})),n?.(),t()}catch(e){G(`${m.deleteFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)}finally{ze(!1)}}},[Re,m.deleteFailed,m.quickCaptureFailedHint,e,t,n,P,xt]),It=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-1 sm:gap-2`,Y),children:[o?(0,$.jsx)(`button`,{type:`button`,onClick:o,"aria-label":m.searchDialogTitle,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(Ve,{className:`size-4`,"aria-hidden":!0})}):null,(0,$.jsx)(rn,{input:kt,showLabel:!1,labels:{read:m.readAloud,preparing:m.readAloudPreparing,pause:m.readAloudPause,resume:m.readAloudResume,retry:m.readAloudRetry,stop:m.readAloudStop}}),(0,$.jsxs)(`button`,{type:`button`,onClick:Ot,disabled:oe,"aria-label":m.catalysisSectionTitle,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,A===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,$.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:oe?m.catalyzing:m.catalyzeButton})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Mt(!1),"aria-label":m.openChatButton,disabled:H,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,$.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:H?m.openingChat:m.openChatButton})]}),(0,$.jsx)(pn,{mode:O,onModeChange:Ct,labels:{edit:m.modeEdit,source:m.modeSource,preview:m.modePreview}}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Nt(),disabled:H||P||!Z||!!M,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(me,{className:`size-3.5`,"aria-hidden":!0}),g.capture]}),(0,$.jsxs)(at,{modal:!1,children:[(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":m.noteActions,title:m.noteActions,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(de,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{align:`end`,sideOffset:6,className:`z-50 min-w-40 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,$.jsxs)(ct,{onSelect:()=>void Pt(),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(ee,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),p===`zh`?`分享`:`Share`]}),(0,$.jsxs)(ct,{onSelect:()=>{U(!1),j(A===`history`?null:`history`)},className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(he,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:m.history}),A===`history`?(0,$.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}):null]}),(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsxs)(ct,{disabled:Re||P,onSelect:()=>Ie(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none hover:bg-danger-soft focus:bg-danger-soft data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),m.delete]})]})})]})]}),[oe,Ot,Mt,Nt,g.capture,Z,M,O,m.history,m.modeEdit,m.modePreview,m.modeSource,H,A,o,m.searchDialogTitle,m.readAloud,m.readAloudPause,m.readAloudPreparing,m.readAloudResume,m.readAloudRetry,m.readAloudStop,Ct,kt,Pt,Re,P,p,m.delete,Ie]);(0,Q.useLayoutEffect)(()=>(rt({startExtra:bt,main:Z&&!v?Et:null,end:Z&&!v?It:null}),()=>{a&&it()}),[a,it,It,Et,bt,v,y,Z,rt]);let Lt=(0,Q.useCallback)(t=>{e&&(xt(),Ge.current=t,He.current&&clearTimeout(He.current),He.current=setTimeout(async()=>{let e=Ge.current;if(Ge.current=null,e!==null){I(!0),G(null);try{await wt({markdown:e}),await pt(),n?.()}catch(t){Ge.current===null&&(Ge.current=e),G(`${m.saveFailed}: ${t instanceof Error?t.message:m.saveFailedHint}`)}finally{I(!1)}}},600))},[xt,e,pt,m.saveFailed,m.saveFailedHint,n,wt]),Rt=(0,Q.useCallback)(t=>{Me(e,t.timestamp).then(e=>{e&&(xt(),N(e))})},[e,xt]),zt=(0,Q.useCallback)(()=>{xt(),j(null),N(null)},[xt]),Bt=(0,Q.useCallback)(()=>{xt(),j(null),N(null),pt().catch(vt),n?.()},[pt,n,vt,xt]);if((0,Q.useEffect)(()=>()=>{He.current&&clearTimeout(He.current),We.current&&clearTimeout(We.current);let t=Ge.current,n=q.current;Ge.current=null,q.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&W(e,r,J.current).catch(()=>void 0)},[e]),Z===void 0)return mt?(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,role:`alert`,children:[(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:m.home.loadFailed}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void pt().catch(vt),className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-hover`,children:m.home.retry}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-fg-muted hover:text-fg`,children:m.back})]}):(0,$.jsx)(fn,{});if(Z===null)return(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:m.notFoundTitle}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m.notFoundDescription}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:m.back})]});let Vt=_t?M.title??``:R,Ht=_t?M.markdown??``:Ge.current??Z.markdown??``,Wt=new Date(Z.createdAt).getTime(),Gt=Number.isFinite(Wt)&&Date.now()-Wt<3600*1e3?(0,$.jsx)(St,{title:_.noteCreatedTitle,description:_.noteCreatedDescription,prompt:_.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},variant:`titleAction`,className:`ml-3 hidden max-w-[18rem] shrink-0 md:flex`}):null,Jt=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[v?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center justify-end px-4 py-1`,children:(0,$.jsx)(pn,{mode:O,onModeChange:Ct,labels:{edit:m.modeEdit,source:m.modeSource,preview:m.modePreview}})}):null,(0,$.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1`,children:_t?(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,children:[Vt&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Vt}),Ht?(0,$.jsx)(ve,{noteId:e,content:Ht,className:`opacity-80`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:m.emptyPreview})]}):(0,$.jsxs)($.Fragment,{children:[O===`wysiwyg`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:tt,type:`text`,value:R,onChange:e=>Tt(e.target.value),onCompositionStart:()=>{Be.current=!0},onCompositionEnd:()=>{Be.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!Be.current&&!t.isComposing&&(e.preventDefault(),(Xe.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:m.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Gt]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(fn,{}),children:(0,$.jsx)(un,{initialContent:Z.markdown??``,onChange:Lt,noteId:e,onTextSelection:S},`wysiwyg-${e}`)})})]}),O===`source`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:tt,type:`text`,value:R,onChange:e=>Tt(e.target.value),placeholder:m.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Gt]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(fn,{}),children:(0,$.jsx)(dn,{initialContent:Z.markdown??``,onChange:Lt,isDark:T,onTextSelection:S},`source-${e}`)})})]}),O===`preview`&&(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&D(t.currentSrc||t.src,t.alt)},children:[R&&!Z.markdown.trimStart().startsWith(`# ${R.trim()}\n`)&&Z.markdown.trim()!==`# ${R.trim()}`&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:R}),Z.markdown?(0,$.jsx)(ve,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:m.emptyPreview})]})]})})]});return(0,$.jsxs)($.Fragment,{children:[x&&!_t&&!(v&&y)&&O!==`preview`?(0,$.jsx)(nn,{noteId:e,selection:x,zh:p===`zh`,onDismiss:C,onAsk:e=>{ye({id:Date.now(),text:p===`zh`?`请帮我分析或改写下面这段笔记:\n\n${e}`:`Help me analyze or rewrite this note selection:\n\n${e}`}),C(),Mt()}},`${e}:${O}`):null,(0,$.jsxs)(`div`,{className:`@container/note flex h-full min-h-0 min-w-0 gap-3 p-3 sm:p-4`,children:[(0,$.jsxs)(`div`,{className:K(`mx-auto min-h-0 min-w-0 w-full flex-1 flex-col`,le||A?`hidden @min-[56rem]/note:flex`:`flex`,!v&&`max-w-[60rem]`),children:[Ee?(0,$.jsx)(`p`,{className:`mb-3 shrink-0 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:Ee}):null,(0,$.jsx)(re,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(re,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsxs)(`div`,{ref:Xe,onKeyDown:e=>{x&&e.altKey&&e.key===`Enter`&&(e.preventDefault(),document.querySelector(`[data-note-selection-actions] button:not(:disabled)`)?.focus())},className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel xl:flex-row`,children:[v?(0,$.jsx)(Ut,{personalNotes:Jt,personalNotesActive:!y,onMeetingContent:()=>b(!0),noteId:e,noteActions:{onAnalyze:Ot,chatOpen:le,onChat:()=>{le?U(!1):Mt(!1)},onShare:()=>{Pt()},onHistory:()=>{U(!1),j(A===`history`?null:`history`)},onDelete:()=>Ie(!0),busy:Re||P||oe||H},onPersonalNotes:()=>{b(!1),window.setTimeout(()=>tt.current?.focus(),0)}}):null,v?null:Jt]})]}),le||Ce?(0,$.jsxs)(`aside`,{id:`note-assistant-${e}`,"aria-label":p===`zh`?`笔记 AI 对话`:`Note AI chat`,className:K(`min-h-0 min-w-0 shrink-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,le?`flex w-full @min-[56rem]/note:w-[22rem] @min-[76rem]/note:w-[24rem]`:`hidden`),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-edge-subtle px-4 py-2`,children:[(0,$.jsx)(Le,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`flex-1 text-sm font-medium`,children:p===`zh`?`AI 对话`:`AI chat`}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-11 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":p===`zh`?`收起 AI 对话`:`Close AI chat`,onClick:()=>{U(!1),window.requestAnimationFrame(()=>document.querySelector(`[aria-controls="note-assistant-${e}"]`)?.focus({preventScroll:!0}))},children:(0,$.jsx)(qe,{className:`size-4`})})]}),(0,$.jsx)(`p`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 text-xs leading-5 text-fg-muted`,children:p===`zh`?`已关联当前笔记。可提问、改写我的笔记,也可将回答保存回笔记。`:`Linked to this note. Ask questions, edit My notes, or save an answer to the note.`}),Ee&&Ce?(0,$.jsx)(`p`,{role:`alert`,className:`shrink-0 px-4 py-2 text-xs text-danger`,children:Ee}):null,(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:Ce?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(fn,{}),children:(0,$.jsx)(ln,{embedded:!0,sourceNoteInView:!0,conversationId:Ce,draftSeed:ge,beforeSend:jt},`${e}:${Ce}`)}):H?(0,$.jsx)(fn,{}):(0,$.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:Ee||(p===`zh`?`对话尚未打开,请重试。`:`Chat could not be opened. Try again.`)}),(0,$.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-lg px-3 text-accent-fg hover:bg-surface-hover`,onClick:()=>void Mt(),children:p===`zh`?`重新打开`:`Try again`})]})})]}):null,(0,$.jsx)(`div`,{ref:X,className:K(`relative min-h-0 max-w-full shrink-0 flex-col overflow-hidden`,A?`flex`:`hidden`,!ne&&`transition-[width] duration-300 ease-in-out`),style:{width:A?B:0},children:(0,$.jsxs)(`div`,{ref:et,className:`flex min-h-0 flex-1 flex-col`,style:{width:B},children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),ie(!0);let n=e.clientX,r=B,i=e.pointerId,a=0,o=B,s=B,c=()=>{a=0,s=o,A&&X.current?.style.setProperty(`width`,`${s}px`),et.current?.style.setProperty(`width`,`${s}px`)},l=e=>{let t=r-(e.clientX-n);o=Math.max(280,Math.min(600,Math.round(t))),a===0&&(a=window.requestAnimationFrame(c))},u=()=>{a!==0&&(window.cancelAnimationFrame(a),c());try{t.releasePointerCapture(i)}catch{}ie(!1),te(s),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u)},className:K(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,ne&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:A===`history`?(0,$.jsx)(Kt,{noteId:e,activeTimestamp:M?.timestamp??null,onSelect:Rt,onClose:zt,onRestored:Bt}):A===`breakdown`?(0,$.jsx)(qt,{noteId:e,note:Z??null,catalyzing:oe,onCatalyze:Dt,onClose:()=>j(null),noteThreads:ht,openingChat:H,onOpenChat:()=>Mt(!1),onOpenNewChat:()=>Mt(!0)}):null})]})})]}),Ne?(0,$.jsx)(Yt,{open:Oe,onOpenChange:Ae,note:Ne}):null,(0,$.jsx)($e,{open:Fe,title:m.deleteConfirmTitle,description:m.deleteConfirmDescription.replace(`{{title}}`,Z.title||m.titlePlaceholder),confirmLabel:m.deleteConfirmLabel,cancelLabel:m.deleteCancelLabel,destructive:!0,onConfirm:()=>void Ft(),onCancel:()=>Ie(!1)})]})}export{yt as i,xt as n,bt as r,hn as t};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,l as a,m as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{f as c,l,n as u}from"./locale-store-Dy1EByeG.js";import{t as d}from"./messages-BAnhwALN.js";import{t as f}from"./archive-Dz0hferG.js";import{C as p,T as m,c as h,s as g,u as _}from"./discussion-annotation-sync-fwPPMPv9.js";import{t as v}from"./arrow-left-D880xG-P.js";import{t as y}from"./arrow-right-DSSvoX71.js";import{t as ee}from"./arrow-up-D5ZtR1QT.js";import{f as b}from"./product-automation-feedback-D51I7Lg3.js";import{t as x}from"./calendar-days-hw_Y-g-s.js";import{t as te}from"./chevron-down-ccbiQQz_.js";import{t as ne}from"./popover-select-CLsphyzA.js";import{t as re}from"./ellipsis-0k4rZLoy.js";import{t as ie}from"./file-text-D12HbeVy.js";import{t as ae}from"./folder-CN-pC3XL.js";import{A as S,D as C,E as w,_ as T,g as E,i as D,p as oe,s as se}from"./notes-api-CdXA-g9r.js";import{b as ce,l as O,n as k,r as le,t as ue,v as de,x as fe,y as A}from"./recording-upload-CyZSl2DJ.js";import{t as pe}from"./loader-circle-CifKLtgG.js";import{z as me}from"./markdown-view-BlxIaCCQ.js";import{t as he}from"./mic-CuUb7zc-.js";import{t as ge}from"./paperclip-f1HujQY1.js";import{t as _e}from"./plus-Q2yW6OE7.js";import{t as ve}from"./search-DA7gz22f.js";import{t as ye}from"./sparkles-DHlfQFAF.js";import{t as be}from"./trash-2-DusmjVPV.js";import{t as xe}from"./upload-rrb46c3c.js";import{t as j}from"./x-B_N4OPjy.js";import{t as M}from"./cn-0WouolD0.js";import{t as N}from"./skeleton-DzdOeGYz.js";import{i as Se}from"./vendor-swr-CdRzEUwF.js";import{r as Ce}from"./app-chrome-BeB4KgOf.js";import{t as we}from"./page-header-store-Bm8oxpFR.js";import{t as Te}from"./sliding-tab-list-CmcrqRzN.js";import{t as Ee}from"./confirm-dialog-DrA5mTQp.js";import{n as De}from"./index.module-Cd9ENXfk.js";import{l as Oe,m as ke,o as Ae,r as je,t as Me}from"./dist-ZrL34Ps4.js";import{i as Ne,t as P}from"./note-detail-panel-B1cq9sU2.js";var F=n(),I=e(t(),1),L=r();function R({projectId:e}){let t=u(e=>e.language)===`zh`,n=s(),r=(0,I.useRef)(null),i=(0,I.useRef)(null),[a,o]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),[d,f]=(0,I.useState)(null);async function p(){let t=i.current;if(!(!t||a!==null)){o(0),l(null);try{let r=await _();if(r.consentAcknowledgedAt==null){f(r.consentPolicyVersion);return}let a=await ue(t.file,t.requestId),s=await h({clientRequestId:t.requestId,contextProjectId:e,source:`web`,consentPolicyVersion:r.consentPolicyVersion});t.discussionId=s.discussion.id,await O({...a,serverDiscussionId:s.discussion.id,projectId:e}),s.discussion.audioAttachmentId||await k(a,s.discussion.id,o),await le(t.requestId),i.current=null,n(`/notes/${encodeURIComponent(s.note.id)}`)}catch(e){l(e instanceof Error?e.message:String(e))}finally{o(null)}}}return(0,L.jsxs)(`div`,{className:`inline-flex flex-wrap items-center gap-2 text-xs`,children:[(0,L.jsx)(`input`,{ref:r,hidden:!0,type:`file`,accept:`audio/*,.m4a,.wav,.mp3,.webm,.ogg`,onChange:e=>{let n=e.target.files?.[0];if(e.target.value=``,n){if(!n.size||n.size>1073741824){l(t?`音频须为 1 字节至 1 GiB`:`Audio must be between 1 byte and 1 GiB`);return}i.current={file:n,requestId:crypto.randomUUID()},p()}}}),(0,L.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md p-2 hover:bg-surface-hover`,disabled:a!==null,onClick:()=>c&&i.current?void p():r.current?.click(),children:[(0,L.jsx)(xe,{className:`size-3.5`}),a===null?c&&i.current?t?`重试导入`:`Retry import`:t?`导入录音`:`Import recording`:`${a}%`]}),d===null?null:(0,L.jsxs)(`span`,{children:[t?`请确认你有权上传此录音,并允许配置的语音服务处理。`:`Confirm permission to upload this recording and process it with your configured speech service.`,(0,L.jsx)(`button`,{type:`button`,className:`p-2 text-accent`,onClick:()=>void g(d).then(()=>(f(null),p())).catch(e=>l(String(e))),children:t?`确认导入`:`Confirm import`})]}),c?(0,L.jsx)(`span`,{role:`alert`,className:`text-danger`,children:c}):null]})}async function Pe(e){e.note??=await D({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await C(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${S(t,e.id)})`);e.note=await w(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,l as a,m as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{f as c,l,n as u}from"./locale-store-Dy1EByeG.js";import{t as d}from"./messages-BAnhwALN.js";import{t as f}from"./archive-Dz0hferG.js";import{C as p,T as m,c as h,s as g,u as _}from"./discussion-annotation-sync-fwPPMPv9.js";import{t as v}from"./arrow-left-D880xG-P.js";import{t as y}from"./arrow-right-DSSvoX71.js";import{t as ee}from"./arrow-up-D5ZtR1QT.js";import{f as b}from"./product-automation-feedback-D51I7Lg3.js";import{t as x}from"./calendar-days-hw_Y-g-s.js";import{t as te}from"./chevron-down-ccbiQQz_.js";import{t as ne}from"./popover-select-CLsphyzA.js";import{t as re}from"./ellipsis-0k4rZLoy.js";import{t as ie}from"./file-text-D12HbeVy.js";import{t as ae}from"./folder-CN-pC3XL.js";import{A as S,D as C,E as w,_ as T,g as E,i as D,p as oe,s as se}from"./notes-api-CdXA-g9r.js";import{b as ce,l as O,n as k,r as le,t as ue,v as de,x as fe,y as A}from"./recording-upload-CyZSl2DJ.js";import{t as pe}from"./loader-circle-CifKLtgG.js";import{z as me}from"./markdown-view-BlxIaCCQ.js";import{t as he}from"./mic-CuUb7zc-.js";import{t as ge}from"./paperclip-f1HujQY1.js";import{t as _e}from"./plus-Q2yW6OE7.js";import{t as ve}from"./search-DA7gz22f.js";import{t as ye}from"./sparkles-DHlfQFAF.js";import{t as be}from"./trash-2-DusmjVPV.js";import{t as xe}from"./upload-rrb46c3c.js";import{t as j}from"./x-B_N4OPjy.js";import{t as M}from"./cn-0WouolD0.js";import{t as N}from"./skeleton-DzdOeGYz.js";import{i as Se}from"./vendor-swr-CdRzEUwF.js";import{r as Ce}from"./app-chrome-BeB4KgOf.js";import{t as we}from"./page-header-store-Bm8oxpFR.js";import{t as Te}from"./sliding-tab-list-CmcrqRzN.js";import{t as Ee}from"./confirm-dialog-DrA5mTQp.js";import{n as De}from"./index.module-Cd9ENXfk.js";import{l as Oe,m as ke,o as Ae,r as je,t as Me}from"./dist-ZrL34Ps4.js";import{i as Ne,t as P}from"./note-detail-panel-BbHlfAju.js";var F=n(),I=e(t(),1),L=r();function R({projectId:e}){let t=u(e=>e.language)===`zh`,n=s(),r=(0,I.useRef)(null),i=(0,I.useRef)(null),[a,o]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),[d,f]=(0,I.useState)(null);async function p(){let t=i.current;if(!(!t||a!==null)){o(0),l(null);try{let r=await _();if(r.consentAcknowledgedAt==null){f(r.consentPolicyVersion);return}let a=await ue(t.file,t.requestId),s=await h({clientRequestId:t.requestId,contextProjectId:e,source:`web`,consentPolicyVersion:r.consentPolicyVersion});t.discussionId=s.discussion.id,await O({...a,serverDiscussionId:s.discussion.id,projectId:e}),s.discussion.audioAttachmentId||await k(a,s.discussion.id,o),await le(t.requestId),i.current=null,n(`/notes/${encodeURIComponent(s.note.id)}`)}catch(e){l(e instanceof Error?e.message:String(e))}finally{o(null)}}}return(0,L.jsxs)(`div`,{className:`inline-flex flex-wrap items-center gap-2 text-xs`,children:[(0,L.jsx)(`input`,{ref:r,hidden:!0,type:`file`,accept:`audio/*,.m4a,.wav,.mp3,.webm,.ogg`,onChange:e=>{let n=e.target.files?.[0];if(e.target.value=``,n){if(!n.size||n.size>1073741824){l(t?`音频须为 1 字节至 1 GiB`:`Audio must be between 1 byte and 1 GiB`);return}i.current={file:n,requestId:crypto.randomUUID()},p()}}}),(0,L.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md p-2 hover:bg-surface-hover`,disabled:a!==null,onClick:()=>c&&i.current?void p():r.current?.click(),children:[(0,L.jsx)(xe,{className:`size-3.5`}),a===null?c&&i.current?t?`重试导入`:`Retry import`:t?`导入录音`:`Import recording`:`${a}%`]}),d===null?null:(0,L.jsxs)(`span`,{children:[t?`请确认你有权上传此录音,并允许配置的语音服务处理。`:`Confirm permission to upload this recording and process it with your configured speech service.`,(0,L.jsx)(`button`,{type:`button`,className:`p-2 text-accent`,onClick:()=>void g(d).then(()=>(f(null),p())).catch(e=>l(String(e))),children:t?`确认导入`:`Confirm import`})]}),c?(0,L.jsx)(`span`,{role:`alert`,className:`text-danger`,children:c}):null]})}async function Pe(e){e.note??=await D({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await C(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${S(t,e.id)})`);e.note=await w(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
2
2
 
3
3
  `)}`})}return{noteId:t,conversationId:(await T(t,{projectId:e.projectId})).conversationId}}function Fe(e,t,n){let r=new URLSearchParams({draft:n.replace(`{{id}}`,t),autoSend:`1`});return`/chat/${encodeURIComponent(e)}?${r}`}var z={meeting:b,requirements:ie,research:A,weekly:x};function Ie({projects:e,projectId:t,onProjectChange:n,onCreated:r,labels:i,projectsLoading:a,projectsError:o}){let c=i.home,l=s(),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)([]),[v,y]=(0,I.useState)(!1),[b,x]=(0,I.useState)(null),[re,ie]=(0,I.useState)(``),S=(0,I.useRef)(null),C=(0,I.useRef)(!1),w=(0,I.useRef)(null),T=(0,I.useRef)(null),E=v||!!S.current,D=f?c.templateOptions[f]:null,oe=!!(u.trim()||g.length);async function se(){if(!(C.current||!oe&&!S.current)){C.current=!0,y(!0),x(null),S.current??={requestId:crypto.randomUUID(),title:u.trim().split(`
4
4
  `)[0]?.slice(0,80)||D?.label||i.titlePlaceholder,markdown:`## ${c.requestHeading}\n\n${D?`${D.prompt}\n`:``}${u.trim()}`,projectId:t||void 0,files:[...g],attachments:[],materialHeading:c.materialsHeading};try{let e=await Pe(S.current);r(),l(Fe(e.conversationId,e.noteId,c.agentPrompt))}catch(e){S.current.note&&r(),x(e instanceof Error?e.message:i.quickCaptureFailedHint)}finally{C.current=!1,y(!1)}}}function ce(){S.current=null,x(null),d(``),_([]),p(null),h(!1),T.current?.focus()}return(0,L.jsxs)(`section`,{"aria-label":c.askLabel,children:[(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),se()},className:`relative rounded-xl border border-edge bg-surface-panel p-4 focus-within:border-accent/60 sm:p-5`,children:[(0,L.jsxs)(`fieldset`,{disabled:E,className:`min-w-0`,children:[(0,L.jsxs)(`label`,{htmlFor:`notes-home-prompt`,className:`flex items-center gap-2 text-xs font-medium text-accent-fg`,children:[(0,L.jsx)(ye,{className:`size-4`,"aria-hidden":!0}),c.askLabel]}),(0,L.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:c.agentResultHint}),D?(0,L.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft px-3 py-2 text-xs leading-5 text-accent-fg`,children:[(0,L.jsxs)(`p`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`span`,{className:`font-medium`,children:[D.label,` · `]}),D.prompt.split(`
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a,u as o}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as s,n as c,o as l}from"./locale-store-Dy1EByeG.js";import{t as u}from"./messages-BAnhwALN.js";import{t as d}from"./chat-page-BhPw56Vc.js";import{t as f}from"./arrow-left-D880xG-P.js";import{t as p}from"./arrow-right-DSSvoX71.js";import{t as m}from"./arrow-up-right-T72JbQ1Q.js";import{t as h}from"./check-DUBLcKHA.js";import{t as g}from"./list-todo-CTVRto8O.js";import{F as ee}from"./markdown-view-BlxIaCCQ.js";import{n as _,s as v,t as y}from"./install-connector-dialog-DxSv1wS2.js";import{t as b}from"./phone-DdhTnt6X.js";import{t as x}from"./play-kxZvpBg8.js";import{t as te}from"./settings-2-D-csvaET.js";import{t as ne}from"./upload-rrb46c3c.js";import{t as S}from"./x-B_N4OPjy.js";import{t as C}from"./skeleton-DzdOeGYz.js";import{a as w,i as T,o as re,r as E,s as ie,t as D}from"./dist-GJ8-1PAx.js";import{a as O,r as k}from"./connectors-api-CTuVWwBf.js";import{u as A}from"./use-realtime-voice-C7iWQuUv.js";import{n as ae}from"./voice-call-context-BM2A4bLz.js";import{t as oe}from"./page-header-store-Bm8oxpFR.js";import{s as j}from"./agent-avatar-display-loBdGw_i.js";import{t as M}from"./personal-avatar-BMRVyTrE.js";import{d as se,i as N,r as P}from"./voice-config-api-DhJ3l8fk.js";import{t as F}from"./date-formatters-DukWSVwc.js";import{t as ce}from"./personal-profile-settings-CQhZjoK6.js";var I=n(),L=e(t(),1),R=r(),z=[`intro`,`identity`,`voice`,`connections`],B=[{id:`loopi`,zh:`Loopi`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function le(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function V(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await l(s(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),j(e)}function H({modelsAvailable:e,onCreated:t}){let n=c(e=>e.language)===`zh`,r=c(e=>e.language),[i,o]=(0,L.useState)(`intro`),[d,m]=(0,L.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[g,ee]=(0,L.useState)(!1),[b,te]=(0,L.useState)(!1),[S,w]=(0,L.useState)(null),[T,re]=(0,L.useState)(null),[E,ie]=(0,L.useState)(null),[D,ae]=(0,L.useState)(null),[oe,j]=(0,L.useState)(!0),[F,ce]=(0,L.useState)([]),[I,H]=(0,L.useState)(null),U=(0,L.useRef)(null),W=(0,L.useRef)(null),[G,ue]=(0,L.useState)([]),[K,q]=(0,L.useState)(!0),[J,Y]=(0,L.useState)([]),[X,Z]=(0,L.useState)(null);(0,L.useEffect)(()=>{let e=!1;return l(s(`/api/personal-agent/onboarding`)).then(t=>{e||(o(t.payload.step),m(t.payload.draft))}).catch(t=>{e||w(t instanceof Error?t.message:String(t))}).finally(()=>{e||ee(!0)}),()=>{e=!0}},[]),(0,L.useEffect)(()=>{if(!g)return;let e=window.setTimeout(()=>{l(s(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:i,draft:d})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[d,g,i]),(0,L.useEffect)(()=>{let e=!1;return P().then(t=>{e||(t.tts&&t.enabled?ae({provider:t.tts.provider,model:t.tts.model,enabled:!0}):j(!1))}).catch(()=>{e||j(!1)}),()=>{e=!0}},[]),(0,L.useEffect)(()=>{if(!D?.enabled)return;let e=!1;return N(D.provider,D.model,`realtime`).then(t=>{e||ce(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||j(!1)}),()=>{e=!0}},[D]),(0,L.useEffect)(()=>{if(i!==`connections`)return;let e=!1;return q(!0),Promise.allSettled([k({page:1,pageSize:24,verification:`verified`}),O()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];ue(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&Y(n.value),q(!1)}}),()=>{e=!0}},[i]),(0,L.useEffect)(()=>()=>{W.current?.abort(),U.current?.close()},[]),(0,L.useEffect)(()=>()=>{E&&URL.revokeObjectURL(E)},[E]);let Q=async(e,t=d)=>{await l(s(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),o(e)},de=async e=>{w(null);let t=z[Math.max(0,Math.min(z.length-1,z.indexOf(i)+e))];try{await Q(t)}catch(e){w(e instanceof Error?e.message:String(e))}},fe=async(n=!1)=>{if(!(!e||b)){te(!0),w(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:d,r=e.voice&&D?.enabled&&F.some(t=>t.id===e.voice)?{provider:D.provider,model:D.model,voice:e.voice}:void 0,i=(await l(s(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,a=!1;if(!n&&T)try{await V(i.agentId,T),i=(await l(s(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`})})).payload}catch{a=!0}t(i,a)}catch(e){w(e instanceof Error?e.message:String(e))}finally{te(!1)}}},pe=(0,L.useCallback)(async e=>{W.current?.abort(),U.current?.close();let t=new AbortController;W.current=t,H(e),w(null);try{let n=new A;U.current=n,await n.start();let r=await se(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>H(null))}catch(e){t.signal.aborted||w(e instanceof Error?e.message:String(e)),H(null)}},[]);if(!g)return(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,R.jsx)(C,{className:`h-10 w-2/3`}),(0,R.jsx)(C,{className:`h-64 w-full rounded-2xl`}),(0,R.jsx)(C,{className:`h-12 w-full rounded-xl`})]});let $=z.indexOf(i),me={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[i];return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,R.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[$>0?(0,R.jsxs)(`button`,{type:`button`,disabled:b,onClick:()=>void de(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,R.jsx)(f,{className:`size-4`}),n?`上一步`:`Back`]}):(0,R.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,R.jsx)(a,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,R.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":$+1,"aria-valuemin":1,"aria-valuemax":z.length,children:z.map((e,t)=>(0,R.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=$?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,R.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,R.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,R.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,R.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:E?(0,R.jsx)(`img`,{src:E,alt:``,className:`size-14 rounded-xl object-cover`}):(0,R.jsx)(M,{appearance:d.appearance,className:`size-14`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,R.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:d.displayName||`Ada`})]})]}),(0,R.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${$+1} 步 · 共 ${z.length} 步`:`Step ${$+1} of ${z.length}`}),(0,R.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:me}),i===`intro`&&(0,R.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,R.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,R.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,R.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),i===`identity`&&(0,R.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,R.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,R.jsx)(`input`,{value:d.displayName,maxLength:60,onChange:e=>m(t=>({...t,displayName:e.target.value})),onBlur:()=>m(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[B.map(e=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":!T&&d.appearance===e.id,onClick:()=>{re(null),ie(null),m(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!T&&d.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,R.jsx)(M,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,R.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${T?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,R.jsx)(ne,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,R.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){w(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}re(t),ie(URL.createObjectURL(t))}}})]})]}),(0,R.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),i===`voice`&&(0,R.jsxs)(`div`,{className:`mt-5`,children:[(0,R.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),oe?(0,R.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsx)(C,{className:`h-20 rounded-xl`}),(0,R.jsx)(C,{className:`h-20 rounded-xl`})]}):D?.enabled&&F.length>0?(0,R.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-pressed":!d.voice,onClick:()=>m(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${d.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),F.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${d.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":d.voice===e.id,onClick:()=>m(t=>({...t,voice:e.id})),children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,R.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void pe(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,R.jsx)(x,{className:`size-4 ${I===e.id?`text-accent`:``}`})})]},e.id))]}):(0,R.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,R.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,R.jsx)(a,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),i===`connections`&&(0,R.jsxs)(`div`,{className:`mt-5`,children:[(0,R.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),K?(0,R.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,R.jsx)(C,{className:`h-18 rounded-xl`}),(0,R.jsx)(C,{className:`h-18 rounded-xl`})]}):(0,R.jsx)(`div`,{className:`mt-5 space-y-2`,children:G.length?G.map(e=>{let t=le(J.find(t=>t.connectorId===e.id));return(0,R.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,R.jsx)(_,{connector:e,size:`sm`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,R.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,R.jsx)(h,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,R.jsx)(`button`,{type:`button`,onClick:()=>Z(v(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,R.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,R.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,R.jsx)(a,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),S&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:S})]},i)}),(0,R.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,R.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[i===`intro`&&(0,R.jsx)(`button`,{type:`button`,disabled:!e||b,onClick:()=>void fe(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),i===`voice`&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let e={...d,voice:null};m(e),w(null),Q(`connections`,e).catch(e=>w(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,R.jsxs)(`button`,{type:`button`,disabled:b||i===`connections`&&!e,onClick:()=>i===`connections`?void fe():void de(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[b?n?`正在创建…`:`Creating…`:i===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!b&&(0,R.jsx)(p,{className:`size-4`})]})]})]})}),X&&(0,R.jsx)(y,{draft:X,onChange:Z,onClose:()=>Z(null),t:u(r).connectorsSettings,onInstalled:async()=>{Y(await O()),Z(null)}})]})}var U=5;function W(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=58)return t;let n=t.replace(/([^)]{1,80})|\([^)]{1,80}\)/g,``).replace(/([A-Za-z0-9])(?=[\u4e00-\u9fff])/g,`$1 `).replace(/\s+/g,` `).trim(),r=n.split(/[。!?;;,]/,1)[0]?.trim()||n;return r.length>58?`${r.slice(0,57).trimEnd()}…`:r}function G(e,t){if(e.phase===`closed`)return{label:t?`已结束`:`Finished`,tone:`bg-fg-subtle`};let n=e.operationalState??e.runStatus;return n===`running`?{label:t?`正在执行`:`Working`,tone:`bg-accent`}:n===`queued`?{label:t?`等待开始`:`Queued`,tone:`bg-fg-subtle`}:n===`failed`?{label:t?`执行失败`:`Failed`,tone:`bg-danger`}:n===`waiting`?{label:t?`等待继续`:`Waiting`,tone:`bg-warning`}:n===`blocked`?{label:t?`已阻塞`:`Blocked`,tone:`bg-warning`}:n===`verifying`?{label:t?`正在验证`:`Verifying`,tone:`bg-accent`}:n===`cancelled`?{label:t?`执行已取消`:`Cancelled`,tone:`bg-fg-subtle`}:e.phase===`review`?{label:t?`等待验收`:`In review`,tone:`bg-warning`}:e.phase===`active`?{label:t?`正在推进`:`In progress`,tone:`bg-accent`}:e.phase===`ready`?{label:t?`准备开始`:`Ready`,tone:`bg-fg-subtle`}:{label:t?`待处理`:`Planned`,tone:`bg-fg-subtle`}}function ue(e){let t=(0,I.c)(30),{item:n,zh:r}=e,i;t[0]!==n||t[1]!==r?(i=G(n,r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let o=i,s;t[3]===n.id?s=t[4]:(s=ee(`/personal`,n.id),t[3]=n.id,t[4]=s);let c=`mt-2 size-1.5 shrink-0 rounded-full ${o.tone}`,l;t[5]===c?l=t[6]:(l=(0,R.jsx)(`span`,{className:c,"aria-hidden":!0}),t[5]=c,t[6]=l);let u;t[7]===n.title?u=t[8]:(u=W(n.title),t[7]=n.title,t[8]=u);let d;t[9]===u?d=t[10]:(d=(0,R.jsx)(`span`,{className:`line-clamp-2 break-words text-sm font-medium leading-5 text-fg`,children:u}),t[9]=u,t[10]=d);let f;t[11]===o.label?f=t[12]:(f=(0,R.jsx)(`span`,{children:o.label}),t[11]=o.label,t[12]=f);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,R.jsx)(`span`,{className:`text-fg-subtle`,"aria-hidden":!0,children:`·`}),t[13]=p):p=t[13];let h=r?`zh`:`en`,g;t[14]!==n.updatedAt||t[15]!==h?(g=F(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let _;t[17]===g?_=t[18]:(_=(0,R.jsx)(`span`,{children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==f?(v=(0,R.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-2 text-xs text-fg-muted`,children:[f,p,_]}),t[19]=_,t[20]=f,t[21]=v):v=t[21];let y;t[22]!==v||t[23]!==d?(y=(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,v]}),t[22]=v,t[23]=d,t[24]=y):y=t[24];let b;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,R.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==s||t[28]!==l?(x=(0,R.jsxs)(a,{to:s,className:`group flex min-w-0 items-start gap-3 rounded-2xl bg-surface-panel px-4 py-4 transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[l,y,b]}),t[26]=y,t[27]=s,t[28]=l,t[29]=x):x=t[29],x}function K(){let e=o(),t=i(),n=ae(),r=(0,L.useRef)(n);r.current=n;let a=c(e=>e.language)===`zh`,u=oe(e=>e.setPageHeader),f=oe(e=>e.clearPageHeader),[p,m]=(0,L.useState)(null),[h,ee]=(0,L.useState)([]),[_,v]=(0,L.useState)(!0),[y,x]=(0,L.useState)(null),[ne,O]=(0,L.useState)(!1),[k,A]=(0,L.useState)(!1),j=(0,L.useRef)(null),se=(0,L.useRef)(null),N=(0,L.useRef)(null),[P,F]=(0,L.useState)(!1),[I,z]=(0,L.useState)(null),[B,le]=(0,L.useState)(!1),[V,W]=(0,L.useState)(!1),[G,K]=(0,L.useState)(!1),[q,J]=(0,L.useState)(0),Y=(0,L.useRef)(0),X=(0,L.useCallback)(()=>e(`/settings/personal`,{state:{settingsBackPath:`${t.pathname}${t.search}${t.hash}`}}),[t.pathname,t.search,t.hash,e]),Z=(0,L.useRef)(null),Q=(0,L.useRef)(null),de=(0,L.useCallback)(e=>{let t=Q.current;Q.current=e,(e||Z.current===t)&&(Z.current=e,r.current.setMiniAnchor(e))},[]),fe=(0,L.useCallback)(e=>{let t=N.current;N.current=e,(e||Z.current===t)&&(Z.current=e,r.current.setMiniAnchor(e))},[]);(0,L.useLayoutEffect)(()=>{let e=k?N.current:P?Q.current:null;Z.current=e,r.current.setMiniAnchor(e)},[k,P]),(0,L.useEffect)(()=>()=>r.current.setMiniAnchor(null),[]);let pe=(0,L.useCallback)(()=>{r.current.minimize(),F(!1),A(e=>!e)},[]);(0,L.useEffect)(()=>{n.expanded&&(A(!1),F(!1))},[n.expanded]),(0,L.useEffect)(()=>{let e=e=>{let t=e.detail;t&&m(t)};return window.addEventListener(`personal-agent-updated`,e),()=>window.removeEventListener(`personal-agent-updated`,e)},[]);let $=(0,L.useCallback)(async()=>{try{let[e,t]=await Promise.all([l(s(`/api/personal-agent`)),l(s(`/api/personal-agent/models`))]);m(e.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),ee(t.payload)}catch(e){x(e instanceof Error?e.message:String(e))}finally{v(!1)}},[]);(0,L.useEffect)(()=>{$()},[$]);let me=(0,L.useCallback)(async()=>{r.current.minimize(),A(!1);let e=++Y.current;F(!0),z(null),le(!1),W(!1),K(!1),J(0);try{let t=await l(s(`/api/personal-agent/activity?limit=${U}&offset=0`));if(e!==Y.current)return;z(t.payload),J(t.payload.items.length)}catch{e===Y.current&&le(!0)}},[]),he=(0,L.useCallback)(async()=>{if(!I||V||q>=I.total)return;let e=Y.current;W(!0),K(!1);try{let t=await l(s(`/api/personal-agent/activity?limit=${U}&offset=${q}`));if(e!==Y.current)return;z(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),J(e=>e+t.payload.items.length)}catch{e===Y.current&&K(!0)}finally{e===Y.current&&W(!1)}},[I,q,V]);return(0,L.useEffect)(()=>{if(!P||!I||V)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=Y.current;try{let t=await l(s(`/api/personal-agent/activity?limit=${Math.max(U,Math.min(100,q))}&offset=0`));if(e!==Y.current)return;z(t.payload),J(t.payload.items.length)}catch{}},120)},n=window.setInterval(t,5e3);return window.addEventListener(`task-changed-v2`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.clearTimeout(e),window.clearInterval(n),window.removeEventListener(`task-changed-v2`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[I,q,V,P]),(0,L.useLayoutEffect)(()=>{let e=p?.state===`ready`,t=a?`语音通话`:`Voice call`,i=()=>{A(!1),F(!1),e&&r.current.open({conversationId:p.conversationId,name:p.displayName})},o=e?p.appearance:`loopi`,s=e?p.displayName:`Ada`;return u({startExtra:null,main:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[e?(0,R.jsx)(`button`,{ref:se,type:`button`,onClick:pe,"aria-expanded":k,className:`touch-target -m-1 shrink-0 rounded-full p-1 transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":a?`编辑${s}的资料`:`Edit ${s}'s profile`,title:a?`设置`:`Settings`,children:(0,R.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,R.jsx)(M,{appearance:o,agentId:p?.agentId,className:`size-8`})})}):(0,R.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,R.jsx)(M,{appearance:o,agentId:p?.agentId,className:`size-8`})}),(0,R.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:s})]}),end:e?(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-pressed":n.expanded,onClick:i,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":t,title:t,children:(0,R.jsx)(b,{className:`size-5`})}),(0,R.jsxs)(re,{open:P,onOpenChange:e=>{e?me():F(!1)},children:[(0,R.jsx)(ie,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-pressed":P,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a?`正在做的事`:`Activity`,children:(0,R.jsx)(g,{className:`size-5`})})}),(0,R.jsx)(w,{children:(0,R.jsxs)(T,{ref:de,onInteractOutside:e=>{e.target instanceof Element&&e.target.closest(`[data-voice-call-mini]`)&&e.preventDefault()},side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":a?`派发的任务`:`Delegated tasks`,className:`xopc-session-context-popover data-[state=closed]:pointer-events-none z-50 flex h-[min(34rem,calc(100dvh-6rem))] ${n.active?`max-h-[min(var(--radix-popover-content-available-height),calc(100dvh-12rem))]`:`max-h-[var(--radix-popover-content-available-height)]`} w-[min(22rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl focus:outline-none`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:a?`交给我推进的事`:`Delegated work`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:I?a?`最近更新 · 共 ${I.total} 项`:`Recently updated · ${I.total} total`:a?`查看任务进展与结果`:`Follow progress and results`})]}),(0,R.jsx)(E,{className:`touch-target -mr-2 -mt-1 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":a?`关闭活动`:`Close activity`,children:(0,R.jsx)(S,{className:`size-4`})})]}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 pb-5 pt-3`,children:[!I&&!B&&(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(C,{className:`h-18 rounded-2xl`}),(0,R.jsx)(C,{className:`h-18 rounded-2xl`}),(0,R.jsx)(C,{className:`h-18 rounded-2xl`})]}),B&&(0,R.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a?`暂时无法读取任务`:`Could not load tasks`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void me(),className:`mt-3 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:a?`重试`:`Try again`})]}),I?.items.length===0&&(0,R.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,R.jsx)(g,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,R.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:a?`还没有派发的任务`:`No delegated work yet`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:a?`你可以在对话里直接告诉我想推进的事。`:`Tell me what you would like to move forward in chat.`})]}),I&&I.items.length>0&&(0,R.jsx)(`div`,{className:`space-y-2`,children:I.items.map(e=>(0,R.jsx)(ue,{item:e,zh:a},e.id))}),I&&q<I.total&&(0,R.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>void he(),disabled:V,className:`min-h-10 rounded-xl bg-surface-panel px-5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,children:V?a?`正在加载…`:`Loading…`:a?`加载更多`:`Load more`}),G&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:a?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,R.jsx)(`button`,{ref:j,type:`button`,onClick:pe,"aria-expanded":k,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a?`Ada 设置`:`Ada settings`,children:(0,R.jsx)(te,{className:`size-5`})})]}):null}),()=>f()},[I,B,q,V,G,f,he,me,p,u,P,k,pe,de,n.active,n.expanded,a]),_?(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,R.jsx)(C,{className:`h-20 w-20 rounded-full`}),(0,R.jsx)(C,{className:`h-9 w-72`}),(0,R.jsx)(C,{className:`h-44 w-full rounded-2xl`})]}):y&&!p?(0,R.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-6 text-sm text-danger`,children:[(0,R.jsx)(`p`,{children:y}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void $(),className:`text-accent hover:underline`,children:a?`重试`:`Retry`})]}):p?.state===`ready`?(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ne&&(0,R.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,R.jsx)(`span`,{children:a?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{O(!1),X()},className:`shrink-0 text-accent hover:underline`,children:a?`打开设置`:`Open settings`})]}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(d,{embedded:!0,personal:!0,personalWelcome:{name:p.displayName,addressAs:p.userCallName??void 0,avatar:(0,R.jsx)(M,{appearance:p.appearance,agentId:p.agentId,className:`size-14`}),opening:a?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`},conversationId:p.conversationId})})}),(0,R.jsxs)(re,{open:k,onOpenChange:A,children:[(0,R.jsx)(D,{virtualRef:j}),(0,R.jsx)(w,{children:(0,R.jsxs)(T,{ref:fe,side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":a?`Ada 快捷设置`:`Ada quick settings`,onInteractOutside:e=>{e.target instanceof Node&&(j.current?.contains(e.target)||se.current?.contains(e.target)||N.current?.contains(e.target)||e.target instanceof Element&&e.target.closest(`[data-voice-call-mini]`))&&e.preventDefault()},className:`xopc-session-context-popover data-[state=closed]:pointer-events-none z-50 flex h-[min(34rem,calc(100dvh-6rem))] ${n.active?`max-h-[min(var(--radix-popover-content-available-height),calc(100dvh-12rem))]`:`max-h-[var(--radix-popover-content-available-height)]`} min-h-0 w-[min(22rem,calc(100vw-1rem))] flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl outline-none`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a?`快捷设置`:`Quick settings`}),(0,R.jsx)(E,{className:`touch-target -mr-2 rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":a?`关闭设置`:`Close settings`,children:(0,R.jsx)(S,{className:`size-4`})})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4`,children:(0,R.jsx)(ce,{zh:a,onOpenVoiceServices:X})}),(0,R.jsx)(`button`,{type:`button`,onClick:X,className:`shrink-0 border-t border-edge px-4 py-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:a?`更多设置`:`More settings`})]})})]})]}):(0,R.jsx)(H,{modelsAvailable:h.length>0,onCreated:(e,t)=>{m(e),O(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{K as PersonalPage};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i,o as a}from"./locale-store-Dy1EByeG.js";import{t as o}from"./messages-BAnhwALN.js";import{n as s,r as c,t as l}from"./popover-select-CLsphyzA.js";import{t as u}from"./play-kxZvpBg8.js";import{t as d}from"./square-DMK_fB-3.js";import{t as f}from"./upload-rrb46c3c.js";import{t as p}from"./skeleton-DzdOeGYz.js";import{n as m,t as h}from"./voice-CDlC6XMH.js";import{T as g,d as _,t as v}from"./session-manager-D2LaQymu.js";import{t as y}from"./composer-model-config-control-DAagrRx_.js";import{i as b}from"./vendor-swr-CdRzEUwF.js";import{t as x}from"./button-Cc4hUNTt.js";import{u as S}from"./use-realtime-voice-C7iWQuUv.js";import{s as C}from"./agent-avatar-display-loBdGw_i.js";import{t as w}from"./personal-avatar-BMRVyTrE.js";import{d as T,i as E,n as D,r as O,t as k}from"./voice-config-api-DhJ3l8fk.js";var A=e(t(),1),j=n();function M({preferences:e,settings:t,failed:n,disabled:r,zh:i,onChange:a,onOpenServices:o,children:l}){let[u,d]=(0,A.useState)(null),f=(0,A.useRef)(0),g=u??e?.enginePreference??`auto`;async function _(e){if(e===g)return;let t=++f.current;d(e);try{await a({enginePreference:e})}finally{t===f.current&&d(null)}}let v=t?.defaultForNatural?h:t?.legacyModel,y=e?.naturalModel,b=y??v,S=b===h,C=t?.naturalModels??(t?.legacyModel?[{id:t.legacyModel,name:t.legacyModelLabel??t.legacyModel,tools:void 0}]:[]),w=C.find(e=>e.id===b),T=y&&y!==`boson/higgs-realtime`&&!C.some(e=>e.id===y);return(0,j.jsx)(`section`,{className:`space-y-3`,"aria-label":i?`语音通话设置`:`Voice call settings`,children:(0,j.jsxs)(`fieldset`,{disabled:r,className:`space-y-3`,children:[(0,j.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,j.jsx)(`span`,{children:i?`通话引擎`:`Call engine`}),(0,j.jsxs)(s,{side:`top`,"aria-label":i?`通话引擎`:`Call engine`,value:g,onChange:e=>{_(e.target.value)},children:[(0,j.jsx)(c,{value:`auto`,children:i?`自动选择`:`Automatic`}),(0,j.jsx)(c,{value:`natural`,children:i?`实时语音`:`Realtime voice`}),(0,j.jsx)(c,{value:`assistant`,children:i?`助手语音`:`Assistant voice`})]})]}),(0,j.jsx)(`div`,{inert:g===`natural`,"aria-hidden":g===`natural`,className:g===`natural`?`hidden`:``,children:l(g!==`natural`)}),(0,j.jsxs)(`div`,{inert:g===`assistant`,"aria-hidden":g===`assistant`,className:`space-y-3 ${g===`assistant`?`hidden`:``}`,children:[!t&&!n&&(0,j.jsx)(p,{className:`h-10 w-full`}),n&&(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:i?`无法读取自然语音模型。`:`Could not load natural voice models.`}),t&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,j.jsx)(`span`,{className:`block`,children:i?`通话模型`:`Call model`}),(0,j.jsxs)(s,{side:`top`,"aria-label":i?`自然语音模型`:`Natural voice model`,value:y??`inherit`,onChange:e=>a({naturalModel:e.target.value===`inherit`?null:e.target.value}),children:[(0,j.jsxs)(c,{value:`inherit`,children:[i?`跟随系统`:`Follow system`,v?` · ${v===`boson/higgs-realtime`?`Higgs Realtime`:t.legacyModelLabel??v}`:``]}),C.map(e=>(0,j.jsxs)(c,{value:e.id,children:[e.name,e.tools===!1?i?` · 仅对话`:` · Conversation only`:``]},e.id)),(t.credentialSource||y===`boson/higgs-realtime`)&&(0,j.jsx)(c,{value:`boson/higgs-realtime`,children:`Higgs Realtime`}),T&&(0,j.jsxs)(c,{value:y,children:[y,` · `,i?`不可用`:`Unavailable`]})]}),w?.tools===!1&&(0,j.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`此模型仅支持语音交流,不能交办任务。自动选择时会使用具备行动能力的备用引擎。`:`This model supports conversation only. Automatic selection uses the fallback Agent engine to retain actions.`})]}),S&&(0,j.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,j.jsx)(`span`,{className:`block`,children:i?`声音`:`Voice`}),(0,j.jsxs)(s,{side:`top`,"aria-label":i?`自然语音音色`:`Natural voice`,value:e?.higgsVoice??`inherit`,onChange:e=>a({higgsVoice:e.target.value===`inherit`?null:e.target.value}),children:[(0,j.jsxs)(c,{value:`inherit`,children:[i?`跟随系统音色`:`Follow system voice`,` · `,t.voice==="default"?i?`模型默认`:`Model default`:t.voice]}),m.map(e=>(0,j.jsx)(c,{value:e,children:e==="default"?i?`模型默认`:`Model default`:e},e))]})]}),o&&(!b||T||S&&!t.credentialSource)&&(0,j.jsx)(x,{type:`button`,variant:`ghost`,onClick:o,children:i?`设置自然语音服务`:`Set up natural voice`})]})]})]})})}var N=new v;function P({conversationId:e,zh:t,onSaved:n}){let r=g(t=>t.sessions[e]),[i,a]=(0,A.useState)(!0),[s,c]=(0,A.useState)(``);(0,A.useEffect)(()=>{let t=!0;return N.loadSessionAgentConfig(e).then(n=>{t&&_(e,n)}).catch(e=>{t&&c(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let l=!!r?.modelConfigSaving;async function u(t,i){g.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{_(e,await N.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await N.loadSessionAgentConfig(e).catch(()=>null);throw n&&_(e,n),t}finally{g.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,j.jsxs)(`section`,{children:[(0,j.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型`:`Chat model`}),i?(0,j.jsx)(p,{className:`h-9 w-full`}):(0,j.jsx)(y,{chat:o(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:l,thinkingDisabled:l,onModelChange:u,onThinkingChange:e=>u(r?.model??``,e)}),s&&(0,j.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:s})]})}function F({record:e,zh:t,onSelectVoice:n,onGreetingChange:i,onOpenServices:a,active:o=!0}){let[s,c]=(0,A.useState)(!1),[f,m]=(0,A.useState)(!0),[h,g]=(0,A.useState)(``),[_,v]=(0,A.useState)(null),[y,b]=(0,A.useState)([]),[x,C]=(0,A.useState)(e.voicePreference?.voice??``),[w,D]=(0,A.useState)(!1),[k,M]=(0,A.useState)(null),[N,P]=(0,A.useState)(null),[F,I]=(0,A.useState)(null),L=(0,A.useRef)(null),R=(0,A.useRef)(null);(0,A.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await O();if(e||(c(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};v(n);let r=await E(n.provider,n.model,`realtime`);e||b(r)}catch(t){e||P(t instanceof Error?t.message:String(t))}finally{e||m(!1)}})(),()=>{e=!0}},[]),(0,A.useEffect)(()=>()=>{R.current?.abort(),L.current?.close()},[]);let z=(0,A.useCallback)(()=>{R.current?.abort(),R.current=null,L.current?.close(),L.current=null,I(null)},[]);(0,A.useEffect)(()=>{o||z()},[o,z]);let B=async e=>{if(F!==null){z();return}z(),P(null);let n=new AbortController;R.current=n,I(e);try{let t=new S;L.current=t,await t.start();let r=await T(n.signal,e);n.signal.aborted||t.enqueue(r,()=>{R.current===n&&(I(null),R.current=null,L.current=null,t.close())})}catch(e){if(!n.signal.aborted){let n=e?.body?.error?.code;P(t&&n===`unsupported_voice`?`当前音色暂不可用,请刷新语音目录或选择其他音色。`:e instanceof Error?e.message:String(e))}R.current===n&&z()}},V=async e=>{if(w||e===x)return;z();let t=x;C(e),g(``),D(!0),P(null);try{await n(e&&_?{provider:_.provider,model:_.model,voice:e}:null)||C(t)}catch(e){C(t),P(e instanceof Error?e.message:String(e))}finally{D(!1)}},H=y.find(e=>e.id===x),U=t?`默认声音`:`Default voice`,W=H?.name||(x?t?`当前音色不可用`:`Current voice unavailable`:U),G=h.trim().toLocaleLowerCase(),K=y.filter(e=>!G||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(G)).map(e=>({value:e.id,label:e.name}));return(0,j.jsxs)(`section`,{children:[(0,j.jsx)(`h4`,{className:`text-sm text-fg`,children:t?`声音`:`Voice`}),f?(0,j.jsx)(`div`,{className:`mt-1`,"aria-busy":`true`,children:(0,j.jsx)(p,{className:`h-10 w-full`})}):_&&y.length?(0,j.jsxs)(`div`,{className:`mt-1 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,j.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,j.jsx)(l,{value:x,selectedLabel:W,options:K,side:`top`,placeholder:U,emptyLabel:U,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:w,onChange:e=>void V(e),searchPlaceholder:y.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:h,onSearchChange:g,statusMessage:G&&!K.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,j.jsxs)(`button`,{type:`button`,disabled:w||!!(x&&!H),onClick:()=>void B(x),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:F===null?t?`试听${W}`:`Preview ${W}`:t?`停止试听`:`Stop preview`,"aria-label":F===null?t?`试听${W}`:`Preview ${W}`:t?`停止试听`:`Stop preview`,children:[F===null?(0,j.jsx)(u,{className:`size-4`,"aria-hidden":!0}):(0,j.jsx)(d,{className:`size-4 text-accent`,"aria-hidden":!0}),F===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(H?.description||H?.style||!x)&&(0,j.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:H?.description||H?.style||(t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,j.jsxs)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,a?(0,j.jsx)(`button`,{type:`button`,onClick:a,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`}):(0,j.jsx)(r,{to:`/settings/personal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),i&&s&&(0,j.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`接通时问候`:`Greet me when connected`,(0,j.jsx)(`input`,{type:`checkbox`,checked:k??e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:w||k!==null,onChange:e=>{let t=e.target.checked;M(t),i(t).catch(e=>P(String(e))).finally(()=>M(null))}})]}),N&&(0,j.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:N})]})}var I=[{id:`loopi`,zh:`Loopi`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function L({zh:e,onOpenVoiceServices:t}){let[n,o]=(0,A.useState)(null),s=(0,A.useRef)(null),c=(0,A.useRef)(Promise.resolve()),[l,u]=(0,A.useState)(!0),[d,m]=(0,A.useState)(0),[h,g]=(0,A.useState)(null),[_,v]=(0,A.useState)(`loopi`),[y,x]=(0,A.useState)(!1),S=(0,A.useRef)(null),[T,E]=(0,A.useState)(``),[O,N]=(0,A.useState)(!1),L=(0,A.useCallback)(async()=>{g(null);try{let e=await a(i(`/api/personal-agent`));s.current=e.payload,o(e.payload),e.payload&&(E(e.payload.displayName),v(e.payload.appearance))}catch(e){g(e instanceof Error?e.message:String(e))}finally{u(!1)}},[]);(0,A.useEffect)(()=>{L()},[L]),(0,A.useEffect)(()=>{let e=e=>{let t=e.detail;t&&(t.displayName!==s.current?.displayName&&E(t.displayName),t.appearance!==s.current?.appearance&&v(t.appearance),s.current=t,o(t))};return window.addEventListener(`personal-agent-updated`,e),()=>window.removeEventListener(`personal-agent-updated`,e)},[]);let{data:R,error:z}=b(n?.state===`ready`?i(k):null,D),B=(0,A.useCallback)((e,t=!0)=>{t&&m(e=>e+1),g(null);let n=c.current.then(async()=>{let t=s.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,c=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(c)===JSON.stringify(t.voicePreference)&&!e.voiceCallPreferences)return!0;try{let l=await a(i(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,...e.voicePreference===void 0?{}:{voicePreference:c},...e.voiceCallPreferences?{voiceCallPreferences:e.voiceCallPreferences}:{}})});return s.current=l.payload,o(l.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:l.payload})),!0}catch(e){return g(e instanceof Error?e.message:String(e)),!1}}).finally(()=>{t&&m(e=>e-1)});return c.current=n,n},[]),V=async t=>{if(!n||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){g(e?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(t.size===0||t.size>512*1024){g(e?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}x(!0),g(null);try{let e=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await a(i(`/api/agents/${encodeURIComponent(n.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:e.slice(e.indexOf(`,`)+1),mimeType:t.type})}),C(n.agentId),v(`custom`),N(!1),await B({appearance:`custom`})}catch(e){g(e instanceof Error?e.message:String(e))}finally{x(!1)}};return l?(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(p,{className:`h-20 w-full`}),(0,j.jsx)(p,{className:`h-48 w-full`})]}):n?.state===`ready`?(0,j.jsxs)(`section`,{className:`space-y-5`,"aria-label":e?`Ada 资料与通话设置`:`Ada profile and call settings`,children:[(0,j.jsxs)(`div`,{className:`relative flex flex-col items-center text-center`,children:[(0,j.jsx)(`button`,{type:`button`,disabled:y,onClick:()=>N(e=>!e),"aria-expanded":O,"aria-controls":`personal-appearance-options`,"aria-label":e?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,j.jsx)(w,{appearance:_,agentId:n.agentId,className:`size-16`})}),(0,j.jsx)(`input`,{id:`personal-name`,"aria-label":e?`助手名称`:`Assistant name`,value:T,onChange:e=>E(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(E(t),B({displayName:t})):E(s.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=s.current?.displayName??``,E(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-2 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,j.jsxs)(`div`,{className:`space-y-5`,children:[h&&(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:h}),O&&(0,j.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,j.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:e?`形象`:`Appearance`}),(0,j.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[I.map(t=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>{v(t.id),N(!1),B({appearance:t.id})},"aria-pressed":_===t.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${_===t.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,j.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${t.color}`,children:(0,j.jsx)(w,{appearance:t.id,className:`size-8`})}),(0,j.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:e?t.zh:t.en})]},t.id)),(0,j.jsx)(`input`,{ref:S,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":e?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&V(t),e.currentTarget.value=``}}),(0,j.jsxs)(`button`,{type:`button`,disabled:y,onClick:()=>S.current?.click(),"aria-pressed":_===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${_===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,j.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:_===`custom`?(0,j.jsx)(w,{appearance:`custom`,agentId:n.agentId,className:`size-8`}):(0,j.jsx)(f,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,j.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:y?e?`上传中…`:`Uploading…`:e?`上传`:`Upload`})]})]})]}),(0,j.jsx)(P,{conversationId:n.conversationId,zh:e,onSaved:async()=>{let e=await a(i(`/api/personal-agent`));e.ok&&e.payload&&(s.current=e.payload,o(e.payload))}}),(0,j.jsx)(M,{preferences:n.voiceCallPreferences,settings:R,failed:!!z,disabled:d>0,zh:e,onOpenServices:t,onChange:e=>B({voiceCallPreferences:e},e.enginePreference===void 0),children:r=>(0,j.jsx)(F,{active:r,onOpenServices:t,onGreetingChange:e=>B({voiceCallPreferences:{openingGreetingEnabled:e}},!1),record:n,zh:e,onSelectVoice:e=>B({voicePreference:e})})})]})]}):(0,j.jsxs)(`div`,{className:`space-y-3 text-sm text-fg-muted`,children:[h?(0,j.jsx)(`p`,{role:`alert`,children:h}):null,(0,j.jsx)(r,{to:`/personal`,className:`text-accent hover:underline`,children:e?`前往 Ada 完成设置`:`Finish setting up Ada`}),h?(0,j.jsx)(`button`,{type:`button`,onClick:()=>void L(),className:`ml-3 text-accent hover:underline`,children:e?`重试`:`Retry`}):null]})}export{L as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,n as a,o}from"./locale-store-Dy1EByeG.js";import{t as s}from"./popover-select-CLsphyzA.js";import{t as c}from"./skeleton-DzdOeGYz.js";import{pt as l}from"./session-manager-D2LaQymu.js";import{t as u}from"./voice-settings-BiqJ0tlf.js";import{t as d}from"./use-personal-profile-C1vqD9yV.js";import{n as f,t as p}from"./settings-page-header-DEZZ8D0S.js";import"./settings-page-layout-De2j64Lo.js";import{t as m}from"./personal-profile-settings-HMQY9lz9.js";var h=n(),g=e(t(),1),_=r();function v(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var y=v();function b({zh:e}){let[t,n]=(0,g.useState)(),[r,a]=(0,g.useState)(``),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``),m=f.trim().toLowerCase().replaceAll(`_`,` `),h=[...new Set([...y,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(m)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,g.useEffect)(()=>{let e=!0;return o(i(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(l.parse(t.payload))}).catch(t=>{e&&a(String(t))}),()=>{e=!1}},[]);async function v(e){if(!(!t||u)){d(!0),a(``);try{let r=await o(i(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(l.parse(r.payload))}catch(e){a(String(e));let t=await o(i(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(l.parse(t.payload))}finally{d(!1)}}}return(0,_.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,_.jsx)(c,{className:`h-9 w-full`}):t&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(s,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:u,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void v({mode:e})}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰开始`:`Quiet from`,(0,_.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void v({quietStart:Number(e)})})]}),(0,_.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰结束`:`Quiet until`,(0,_.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void v({quietEnd:Number(e)})})]})]}),(0,_.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,_.jsx)(s,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:h,disabled:u,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:f,onSearchChange:p,statusMessage:h.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{p(``),e!==t.timezone&&v({timezone:e})}})]}),(0,_.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,_.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}function x(){let e=(0,h.c)(22),{displayName:t}=d(),n=a(S)===`zh`,[r,i]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{i(!0),s(!0)},e[0]=c):c=e[0];let l=c,v;e[1]===t?v=e[2]:(v=(0,_.jsx)(p,{title:t}),e[1]=t,e[2]=v);let y,x;e[3]===n?(y=e[4],x=e[5]):(y=(0,_.jsx)(m,{zh:n,onOpenVoiceServices:l}),x=(0,_.jsx)(b,{zh:n}),e[3]=n,e[4]=y,e[5]=x);let C;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{i(e.currentTarget.open),e.currentTarget.open&&s(!0)},e[6]=C):C=e[6];let w=n?`语音服务设置`:`Voice service settings`,T;e[7]===w?T=e[8]:(T=(0,_.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:w}),e[7]=w,e[8]=T);let E;e[9]===o?E=e[10]:(E=o&&(0,_.jsx)(u,{capability:`conversation`}),e[9]=o,e[10]=E);let D;e[11]===E?D=e[12]:(D=(0,_.jsx)(`div`,{className:`mt-4`,children:E}),e[11]=E,e[12]=D);let O;e[13]!==r||e[14]!==T||e[15]!==D?(O=(0,_.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,open:r,onToggle:C,children:[T,D]}),e[13]=r,e[14]=T,e[15]=D,e[16]=O):O=e[16];let k;return e[17]!==v||e[18]!==y||e[19]!==x||e[20]!==O?(k=(0,_.jsxs)(f,{children:[v,y,x,O]}),e[17]=v,e[18]=y,e[19]=x,e[20]=O,e[21]=k):k=e[21],k}function S(e){return e.language}export{x as PersonalSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,n as a,o}from"./locale-store-Dy1EByeG.js";import{t as s}from"./popover-select-CLsphyzA.js";import{t as c}from"./skeleton-DzdOeGYz.js";import{pt as l}from"./session-manager-D2LaQymu.js";import{t as u}from"./voice-settings-BiqJ0tlf.js";import{t as d}from"./use-personal-profile-C1vqD9yV.js";import{n as f,t as p}from"./settings-page-header-DEZZ8D0S.js";import"./settings-page-layout-De2j64Lo.js";import{t as m}from"./personal-profile-settings-CQhZjoK6.js";var h=n(),g=e(t(),1),_=r();function v(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var y=v();function b({zh:e}){let[t,n]=(0,g.useState)(),[r,a]=(0,g.useState)(``),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``),m=f.trim().toLowerCase().replaceAll(`_`,` `),h=[...new Set([...y,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(m)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,g.useEffect)(()=>{let e=!0;return o(i(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(l.parse(t.payload))}).catch(t=>{e&&a(String(t))}),()=>{e=!1}},[]);async function v(e){if(!(!t||u)){d(!0),a(``);try{let r=await o(i(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(l.parse(r.payload))}catch(e){a(String(e));let t=await o(i(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(l.parse(t.payload))}finally{d(!1)}}}return(0,_.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,_.jsx)(c,{className:`h-9 w-full`}):t&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(s,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:u,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void v({mode:e})}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰开始`:`Quiet from`,(0,_.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void v({quietStart:Number(e)})})]}),(0,_.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰结束`:`Quiet until`,(0,_.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void v({quietEnd:Number(e)})})]})]}),(0,_.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,_.jsx)(s,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:h,disabled:u,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:f,onSearchChange:p,statusMessage:h.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{p(``),e!==t.timezone&&v({timezone:e})}})]}),(0,_.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,_.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}function x(){let e=(0,h.c)(22),{displayName:t}=d(),n=a(S)===`zh`,[r,i]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{i(!0),s(!0)},e[0]=c):c=e[0];let l=c,v;e[1]===t?v=e[2]:(v=(0,_.jsx)(p,{title:t}),e[1]=t,e[2]=v);let y,x;e[3]===n?(y=e[4],x=e[5]):(y=(0,_.jsx)(m,{zh:n,onOpenVoiceServices:l}),x=(0,_.jsx)(b,{zh:n}),e[3]=n,e[4]=y,e[5]=x);let C;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{i(e.currentTarget.open),e.currentTarget.open&&s(!0)},e[6]=C):C=e[6];let w=n?`语音服务设置`:`Voice service settings`,T;e[7]===w?T=e[8]:(T=(0,_.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:w}),e[7]=w,e[8]=T);let E;e[9]===o?E=e[10]:(E=o&&(0,_.jsx)(u,{capability:`conversation`}),e[9]=o,e[10]=E);let D;e[11]===E?D=e[12]:(D=(0,_.jsx)(`div`,{className:`mt-4`,children:E}),e[11]=E,e[12]=D);let O;e[13]!==r||e[14]!==T||e[15]!==D?(O=(0,_.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,open:r,onToggle:C,children:[T,D]}),e[13]=r,e[14]=T,e[15]=D,e[16]=O):O=e[16];let k;return e[17]!==v||e[18]!==y||e[19]!==x||e[20]!==O?(k=(0,_.jsxs)(f,{children:[v,y,x,O]}),e[17]=v,e[18]=y,e[19]=x,e[20]=O,e[21]=k):k=e[21],k}function S(e){return e.language}export{x as PersonalSettingsPanel};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{l as n,t as r}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i,l as a,n as o}from"./locale-store-Dy1EByeG.js";import{t as s}from"./messages-BAnhwALN.js";import{i as c,u as l}from"./automation-display-DaVDNZz8.js";import{F as u,V as d,t as f}from"./markdown-view-BlxIaCCQ.js";import{t as p}from"./skeleton-DzdOeGYz.js";import{a as m,c as h}from"./api-B4FJ51EC.js";import{i as g}from"./vendor-swr-CdRzEUwF.js";import{t as _}from"./button-Cc4hUNTt.js";import{t as v}from"./automation-api-DxBmyzp0.js";import{n as y}from"./automation-task-card-CiJmJ7_h.js";import{i as b,n as x}from"./api-B1J5ajiP.js";import{n as S}from"./product-preview-modal-DMHOKocl.js";import{t as C}from"./open-route-MyZ2sB9C.js";import{i as w,r as T}from"./automation-result-state-CAsqgMNR.js";import{t as E}from"./project-overview-model-DrLXaO-t.js";var D=e(),O=t(),k=new Set([`queued`,`running`,`cancelling`]);function A(e){let t=(0,D.c)(60),{automationId:n,runId:r}=e,i=o(N),a=i===`zh`,c,l;t[0]!==n||t[1]!==r?(c=[`automation-run-preview`,n,r],l=async()=>{let[e,t]=await Promise.all([v.get(n),r?v.getRun(r).then(M):Promise.resolve(void 0)]);if(t&&t.automationId!==n)throw Error(`Run does not belong to this task`);return{task:e.automation,run:t}},t[0]=n,t[1]=r,t[2]=c,t[3]=l):(c=t[2],l=t[3]);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u={shouldRetryOnError:!1,refreshInterval:j},t[4]=u):u=t[4];let{data:d,error:m,mutate:h}=g(c,l,u);if(m){let e=a?`暂时无法读取这次运行,请重试。`:`Could not load this run. Try again.`,n;t[5]===e?n=t[6]:(n=(0,O.jsx)(`p`,{children:e}),t[5]=e,t[6]=n);let r;t[7]===h?r=t[8]:(r=()=>void h(),t[7]=h,t[8]=r);let i=a?`重试`:`Retry`,o;t[9]!==r||t[10]!==i?(o=(0,O.jsx)(_,{variant:`secondary`,onClick:r,children:i}),t[9]=r,t[10]=i,t[11]=o):o=t[11];let s;return t[12]!==n||t[13]!==o?(s=(0,O.jsxs)(`div`,{role:`alert`,className:`space-y-3 text-sm text-fg-muted`,children:[n,o]}),t[12]=n,t[13]=o,t[14]=s):s=t[14],s}if(!d){let e;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,O.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,O.jsx)(p,{className:`h-6 w-2/3`}),(0,O.jsx)(p,{className:`h-4 w-1/3`}),(0,O.jsx)(p,{className:`h-32`})]}),t[15]=e):e=t[15],e}let b=d.run;if(!b){let e;t[16]===d.task.name?e=t[17]:(e=(0,O.jsx)(`h2`,{className:`text-lg font-medium text-fg`,children:d.task.name}),t[16]=d.task.name,t[17]=e);let n=a?`这条旧链接没有关联具体执行,请从任务的运行记录查看。`:`This older link does not identify an execution. Choose one from the task history.`,r;t[18]===n?r=t[19]:(r=(0,O.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n}),t[18]=n,t[19]=r);let i;return t[20]!==e||t[21]!==r?(i=(0,O.jsxs)(`div`,{className:`space-y-3`,children:[e,r]}),t[20]=e,t[21]=r,t[22]=i):i=t[22],i}let x;t[23]===d.task.name?x=t[24]:(x=(0,O.jsx)(`h2`,{className:`text-lg font-medium text-fg`,children:d.task.name}),t[23]=d.task.name,t[24]=x);let S;t[25]===i?S=t[26]:(S=s(i),t[25]=i,t[26]=S);let C=S.automations.status[b.status],E;t[27]!==b.createdAtMs||t[28]!==a?(E=new Date(b.createdAtMs).toLocaleString(a?`zh-CN`:`en-US`),t[27]=b.createdAtMs,t[28]=a,t[29]=E):E=t[29];let A;t[30]!==C||t[31]!==E?(A=(0,O.jsxs)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:[C,` · `,E]}),t[30]=C,t[31]=E,t[32]=A):A=t[32];let P;t[33]!==x||t[34]!==A?(P=(0,O.jsxs)(`div`,{className:`space-y-2`,children:[x,A]}),t[33]=x,t[34]=A,t[35]=P):P=t[35];let F;t[36]!==b.status||t[37]!==a?(F=b.status===`queued`?(0,O.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a?`任务正在排队,开始后会自动更新。`:`Queued. This view updates when execution starts.`}):b.status===`running`?(0,O.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a?`正在执行,结果会自动显示在这里。`:`Running. The result will appear here automatically.`}):null,t[36]=b.status,t[37]=a,t[38]=F):F=t[38];let I;t[39]===b.summary?I=t[40]:(I=b.summary?(0,O.jsx)(f,{content:b.summary}):null,t[39]=b.summary,t[40]=I);let L;t[41]!==i||t[42]!==b?(L=b.error?(0,O.jsx)(`p`,{className:`text-sm leading-6 text-danger`,children:T(b,i)}):null,t[41]=i,t[42]=b,t[43]=L):L=t[43];let R;t[44]!==n||t[45]!==i||t[46]!==b.id||t[47]!==b.status?(R=b.status===`failed`||b.status===`timeout`?(0,O.jsx)(y,{automationId:n,runId:b.id,language:i,variant:`secondary`}):null,t[44]=n,t[45]=i,t[46]=b.id,t[47]=b.status,t[48]=R):R=t[48];let z;t[49]!==i||t[50]!==b.id||t[51]!==b.status?(z=k.has(b.status)?null:(0,O.jsx)(w,{runId:b.id,language:i}),t[49]=i,t[50]=b.id,t[51]=b.status,t[52]=z):z=t[52];let ee;return t[53]!==F||t[54]!==I||t[55]!==L||t[56]!==R||t[57]!==z||t[58]!==P?(ee=(0,O.jsxs)(`div`,{className:`space-y-5`,children:[P,F,I,L,R,z]}),t[53]=F,t[54]=I,t[55]=L,t[56]=R,t[57]=z,t[58]=P,t[59]=ee):ee=t[59],ee}function j(e){return e&&(e.task.state.runningRunId||e.run&&k.has(e.run.status))?3e3:0}function M(e){return e.run}function N(e){return e.language}var P=`rounded text-sm text-accent-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent`,F=e=>e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`);function I(e){let t=(0,D.c)(83),{project:i,target:c}=e,l=o(re),m=a(B),_=n(),v=l===`zh`,y;t[0]===l?y=t[1]:(y=s(l),t[0]=l,t[1]=y);let b=y.projectDetailPage,x;t[2]!==c.id||t[3]!==m?(x=[`chat-project-operating-view`,c.id,m],t[2]=c.id,t[3]=m,t[4]=x):x=t[4];let S;t[5]===c.id?S=t[6]:(S=()=>h(c.id),t[5]=c.id,t[6]=S);let C;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(C={shouldRetryOnError:!1},t[7]=C):C=t[7];let{data:w,error:T,isLoading:k,mutate:A}=g(x,S,C),j=`${_.pathname}${_.search}`,M=`/projects/${encodeURIComponent(c.id)}`,N;t[8]!==j||t[9]!==M||t[10]!==c.ownerAgentId?(N=e=>{let t=new URLSearchParams;return c.ownerAgentId&&t.set(`agentId`,c.ownerAgentId),d(`${M}/${e}${t.size?`?${t}`:``}`,j)},t[8]=j,t[9]=M,t[10]=c.ownerAgentId,t[11]=N):N=t[11];let I=N,V;t[12]===j?V=t[13]:(V=e=>u(j,e),t[12]=j,t[13]=V);let H=V,U,W,G,K,q,J,Y;if(t[14]!==T||t[15]!==k||t[16]!==A||t[17]!==b||t[18]!==i||t[19]!==I||t[20]!==H||t[21]!==w||t[22]!==v){let e=w?.tasks??[],n={moving:0,ready:0,waiting:0,needsUser:0,done:0};for(let t of e)t.phase===`closed`?t.resolution===`done`&&(n.done+=1):F(t)?n.needsUser+=1:[`queued`,`running`,`verifying`].includes(t.operationalState)?n.moving+=1:[`waiting`,`blocked`].includes(t.operationalState)?n.waiting+=1:n.ready+=1;let a={moving:v?`进行中`:`In progress`,ready:v?`待处理`:`To do`,waiting:v?`等待中`:`Waiting`,needsUser:v?`等你处理`:`Needs you`,done:v?`已完成`:`Completed`},o=new Set(e.filter(ne).map(te)),s=(w?.blockers??[]).filter(e=>o.has(e.taskId)).sort(ee),c=s.filter((e,t)=>s.findIndex(t=>t.taskId===e.taskId)===t).slice(0,2),l=E(e,e.length).sort(z).slice(0,3),u=[...(i.recentUpdates??[]).map((e,t)=>({id:`update:${e.id??t}`,source:`project`,summary:e.summary,at:e.createdAt,title:v?`项目进展`:`Project update`,href:I(`progress`)})),...(w?.recentResults??[]).map(e=>{let{taskId:t,taskTitle:n,receipt:r}=e;return{id:`receipt:${r.runId}`,source:`task:${t}`,summary:r.summary,at:r.finalizedAt,title:`${n} · ${v?{passed:`验证通过`,failed:`验证失败`,unverified:`未验证`}[r.verification.status]:r.verification.status}`,href:H(t)}})].filter(R).sort(L),d=u.filter((e,t)=>u.findIndex(t=>t.source===e.source&&t.summary.trim()===e.summary.trim())===t).slice(0,3),m;t[30]===v?m=t[31]:(m=e=>e===void 0||!Number.isFinite(new Date(e).getTime())?null:new Intl.DateTimeFormat(v?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)),t[30]=v,t[31]=m);let h=m,g=i.lastActiveAt||i.updatedAt,_;t[32]!==h||t[33]!==g?(_=h(g),t[32]=h,t[33]=g,t[34]=_):_=t[34];let y=_,x=i.outcome||i.description||i.brief,S=v?`项目健康度尚未评估`:`Project health not assessed`,C=v?`进展正常`:`On track`,D=v?`存在风险`:`At risk`,j=v?`偏离计划`:`Off track`,M;t[35]!==S||t[36]!==C||t[37]!==D||t[38]!==j?(M={unknown:S,on_track:C,at_risk:D,off_track:j},t[35]=S,t[36]=C,t[37]=D,t[38]=j,t[39]=M):M=t[39];let N=M;U=`space-y-5`;let B;t[40]===i.name?B=t[41]:(B=(0,O.jsx)(`h2`,{className:`min-w-0 break-words text-xl font-semibold text-fg`,children:i.name}),t[40]=i.name,t[41]=B);let re=b.statuses[i.status],V;t[42]===re?V=t[43]:(V=(0,O.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-inset px-2 py-1 text-xs text-fg-muted`,children:re}),t[42]=re,t[43]=V);let X;t[44]!==B||t[45]!==V?(X=(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[B,V]}),t[44]=B,t[45]=V,t[46]=X):X=t[46];let Z;t[47]!==x||t[48]!==v?(Z=x?(0,O.jsx)(`div`,{className:`line-clamp-3 text-sm text-fg-muted`,children:(0,O.jsx)(f,{content:x,mermaidActions:!1})}):(0,O.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v?`尚未填写项目目标。`:`No project goal recorded yet.`}),t[47]=x,t[48]=v,t[49]=Z):Z=t[49];let ie=N[i.health],ae=y?` · ${v?`最近活动`:`Last activity`} ${y}`:``,Q;t[50]!==ie||t[51]!==ae?(Q=(0,O.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[ie,ae]}),t[50]=ie,t[51]=ae,t[52]=Q):Q=t[52],t[53]!==X||t[54]!==Z||t[55]!==Q?(W=(0,O.jsxs)(`div`,{className:`space-y-2`,children:[X,Z,Q]}),t[53]=X,t[54]=Z,t[55]=Q,t[56]=W):W=t[56];let oe=v?`当前概况`:`Overview`,se=v?`当前概况`:`Overview`,$;t[57]===se?$=t[58]:($=(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:se}),t[57]=se,t[58]=$);let ce=k?(0,O.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-3`,children:[(0,O.jsx)(p,{className:`h-4 w-3/4`}),(0,O.jsx)(p,{className:`h-14 w-full`})]}):T||!w?(0,O.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-2 text-sm text-fg-muted`,children:[(0,O.jsx)(`span`,{children:v?`任务概况暂时无法读取。`:`Task overview is temporarily unavailable.`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>void A(),className:P,children:v?`重试`:`Retry`})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.length===0?v?`尚未关联任务,可在项目中添加下一步工作。`:`No tasks linked yet. Add the next piece of work in the project.`:v?`${n.moving} 项任务正在推进,${n.needsUser} 项等你处理,${n.waiting} 项等待中。`:`${n.moving} in progress, ${n.needsUser} need your input, ${n.waiting} waiting.`}),w.digest.recommendedAction&&(0,O.jsxs)(`p`,{className:`break-words text-sm leading-6 text-fg-muted`,children:[v?`建议下一步:`:`Suggested next step: `,w.digest.recommendedAction]}),(0,O.jsx)(`dl`,{className:`grid grid-cols-3 gap-3 border-t border-edge pt-3 sm:grid-cols-5`,children:Object.keys(a).map(e=>(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:a[e]}),(0,O.jsx)(`dd`,{className:`mt-1 text-xl font-semibold tabular-nums text-fg`,children:n[e]})]},e))})]});t[59]!==oe||t[60]!==$||t[61]!==ce?(G=(0,O.jsxs)(`section`,{"aria-label":oe,className:`space-y-3 rounded-xl border border-edge bg-surface-inset/50 p-4`,children:[$,ce]}),t[59]=oe,t[60]=$,t[61]=ce,t[62]=G):G=t[62],K=w&&(0,O.jsxs)(`div`,{className:`grid gap-6 sm:grid-cols-2`,children:[(0,O.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:v?`优先关注`:`Needs attention`}),c.length?(0,O.jsx)(`ul`,{className:`divide-y divide-edge`,children:c.map(e=>(0,O.jsx)(`li`,{className:`py-3 first:pt-0`,children:(0,O.jsxs)(r,{to:H(e.taskId),className:`block rounded-lg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,O.jsx)(`p`,{className:`break-words text-sm font-medium text-fg`,children:e.title}),(0,O.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-sm leading-6 text-fg-muted`,children:e.detail}),(0,O.jsx)(`span`,{className:`mt-2 inline-block ${P}`,children:v?`查看关联任务 →`:`View task →`})]})},e.taskId))}):(0,O.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:v?`暂无已记录的阻塞或待处理提醒。`:`No recorded blockers or attention items.`})]}),(0,O.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:v?`当前任务`:`Current tasks`}),(0,O.jsx)(r,{to:I(`tasks`),className:P,children:v?`查看全部`:`View all`})]}),l.length?(0,O.jsx)(`ul`,{className:`divide-y divide-edge`,children:l.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(r,{to:H(e.id),className:`block rounded-lg py-3 hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,O.jsx)(`p`,{className:`break-words text-sm font-medium text-fg`,children:e.title}),(0,O.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[b.board.phases[e.phase],e.operationalState===`idle`?``:` · ${b.board.operationalStates[e.operationalState]}`]})]})},e.id))}):(0,O.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:v?`暂无可推进的任务,等待中的任务可在全部任务中查看。`:`No actionable tasks. View all tasks to see any waiting work.`})]})]}),q=`space-y-3 border-t border-edge pt-5`;let le=v?`最近进展`:`Recent progress`,ue;t[63]===le?ue=t[64]:(ue=(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:le}),t[63]=le,t[64]=ue);let de;t[65]===I?de=t[66]:(de=I(`progress`),t[65]=I,t[66]=de);let fe=v?`查看记录`:`View history`,pe;t[67]!==de||t[68]!==fe?(pe=(0,O.jsx)(r,{to:de,className:P,children:fe}),t[67]=de,t[68]=fe,t[69]=pe):pe=t[69],t[70]!==ue||t[71]!==pe?(J=(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[ue,pe]}),t[70]=ue,t[71]=pe,t[72]=J):J=t[72],Y=d.length?(0,O.jsx)(`ul`,{className:`divide-y divide-edge-subtle`,children:d.map(e=>(0,O.jsxs)(`li`,{className:`space-y-2 py-3 first:pt-0`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,O.jsxs)(`p`,{className:`min-w-0 break-words text-xs text-fg-muted`,children:[e.title,h(e.at)?` · ${h(e.at)}`:``]}),(0,O.jsx)(r,{to:e.href,className:P,children:v?`查看来源`:`View source`})]}),(0,O.jsx)(`div`,{className:`line-clamp-3 break-words text-sm text-fg`,children:(0,O.jsx)(f,{content:e.summary,mermaidActions:!1})})]},e.id))}):(0,O.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v?`暂无项目进展或执行结果。`:`No project updates or execution results yet.`}),t[14]=T,t[15]=k,t[16]=A,t[17]=b,t[18]=i,t[19]=I,t[20]=H,t[21]=w,t[22]=v,t[23]=U,t[24]=W,t[25]=G,t[26]=K,t[27]=q,t[28]=J,t[29]=Y}else U=t[23],W=t[24],G=t[25],K=t[26],q=t[27],J=t[28],Y=t[29];let X;t[73]!==q||t[74]!==J||t[75]!==Y?(X=(0,O.jsxs)(`section`,{className:q,children:[J,Y]}),t[73]=q,t[74]=J,t[75]=Y,t[76]=X):X=t[76];let Z;return t[77]!==U||t[78]!==W||t[79]!==G||t[80]!==K||t[81]!==X?(Z=(0,O.jsxs)(`div`,{className:U,children:[W,G,K,X]}),t[77]=U,t[78]=W,t[79]=G,t[80]=K,t[81]=X,t[82]=Z):Z=t[82],Z}function L(e,t){return(t.at||0)-(e.at||0)}function R(e){return e.summary?.trim()}function z(e,t){return Number([`queued`,`running`,`verifying`].includes(t.operationalState))-Number([`queued`,`running`,`verifying`].includes(e.operationalState))}function ee(e,t){return Number([`input_required`,`approval_required`].includes(t.kind))-Number([`input_required`,`approval_required`].includes(e.kind))}function te(e){return e.id}function ne(e){return e.phase!==`closed`}function B(e){return e.conversationId}function re(e){return e.language}async function V(e){switch(e.kind){case`project`:return{kind:e.kind,value:await m(e.id)};case`automation`:{let[t,n]=await Promise.all([v.list(),v.runs(5,e.id)]);return{kind:e.kind,value:t.automations.find(t=>t.id===e.id),runs:n.runs}}case`local_app`:{let t=await x(e.id),n=e.sourceHash?await b(e.id,e.sourceHash):void 0;return{kind:e.kind,value:t,previewUrl:n?.previewUrl||t.draftPreviewUrl}}}}var H={pending:[`等待中`,`Pending`],planned:[`计划中`,`Planned`],active:[`进行中`,`Active`],paused:[`已暂停`,`Paused`],completed:[`已完成`,`Completed`],cancelled:[`已取消`,`Cancelled`],archived:[`已归档`,`Archived`],queued:[`排队中`,`Queued`],running:[`运行中`,`Running`],succeeded:[`成功`,`Succeeded`],failed:[`失败`,`Failed`],timeout:[`超时`,`Timed out`],cancelling:[`取消中`,`Cancelling`],unknown:[`尚未评估`,`Not assessed`],on_track:[`进展正常`,`On track`],at_risk:[`存在风险`,`At risk`],off_track:[`偏离计划`,`Off track`]};function U(e){let t=(0,D.c)(5),{target:n}=e;if(n.kind===`automation`&&n.view===`run`){let e;return t[0]!==n.id||t[1]!==n.runId?(e=(0,O.jsx)(A,{automationId:n.id,runId:n.runId}),t[0]=n.id,t[1]=n.runId,t[2]=e):e=t[2],e}let r;return t[3]===n?r=t[4]:(r=(0,O.jsx)(W,{target:n}),t[3]=n,t[4]=r),r}function W(e){let t=(0,D.c)(56),{target:n}=e,u=a(J),d=o(q),f=d===`zh`,p=s(d),m;t[0]===f?m=t[1]:(m=e=>H[e]?.[+!f]||e,t[0]=f,t[1]=m);let h=m,_;t[2]!==n.href||t[3]!==u?(_=[`chat-product-preview`,n.href,u],t[2]=n.href,t[3]=u,t[4]=_):_=t[4];let v;t[5]===n?v=t[6]:(v=()=>V(n),t[5]=n,t[6]=v);let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y={shouldRetryOnError:!1,refreshInterval:K},t[7]=y):y=t[7];let{data:b,error:x,isLoading:w}=g(_,v,y);if(w){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,O.jsx)(S,{}),t[8]=e):e=t[8],e}if(x){let e=f?`无法加载内容,它可能已删除或暂时不可用。`:`Unable to load this content. It may have been deleted or be temporarily unavailable.`,n;return t[9]===e?n=t[10]:(n=(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:e}),t[9]=e,t[10]=n),n}if(!b?.value){let e=f?`内容不存在或已删除。`:`This content is unavailable or has been deleted.`,n;return t[11]===e?n=t[12]:(n=(0,O.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n),n}let T=G;if(b.kind===`project`){let e;return t[13]!==b.value||t[14]!==n?(e=(0,O.jsx)(I,{project:b.value,target:n}),t[13]=b.value,t[14]=n,t[15]=e):e=t[15],e}if(b.kind===`automation`){let e=b.value,n=e.action.kind===`agent`?e.action.instruction:void 0,r;t[16]===e.name?r=t[17]:(r=(0,O.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:e.name}),t[16]=e.name,t[17]=r);let i;t[18]!==e.description||t[19]!==T?(i=T(e.description),t[18]=e.description,t[19]=T,t[20]=i):i=t[20];let a;t[21]!==n||t[22]!==T?(a=T(n),t[21]=n,t[22]=T,t[23]=a):a=t[23];let o;t[24]!==e.state.nextRunAtMs||t[25]!==f?(o=e.state.nextRunAtMs&&(0,O.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[f?`下次运行`:`Next run`,` · `,new Date(e.state.nextRunAtMs).toLocaleString(f?`zh-CN`:`en-US`)]}),t[24]=e.state.nextRunAtMs,t[25]=f,t[26]=o):o=t[26];let s;t[27]===e.state.lastError?s=t[28]:(s=e.state.lastError&&(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e.state.lastError}),t[27]=e.state.lastError,t[28]=s);let u=f?`最近运行`:`Recent runs`,m;t[29]===u?m=t[30]:(m=(0,O.jsx)(`h3`,{className:`font-medium text-fg`,children:u}),t[29]=u,t[30]=m);let g;t[31]!==b.runs||t[32]!==T||t[33]!==h||t[34]!==f?(g=b.runs.length?b.runs.map(e=>(0,O.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,O.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[h(e.status),` · `,new Date(e.createdAtMs).toLocaleString(f?`zh-CN`:`en-US`)]}),T(e.summary),e.error&&(0,O.jsx)(`p`,{className:`text-sm text-danger`,children:e.error})]},e.id)):(0,O.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`暂无运行记录。`:`No runs yet.`}),t[31]=b.runs,t[32]=T,t[33]=h,t[34]=f,t[35]=g):g=t[35];let _;return t[36]!==m||t[37]!==g?(_=(0,O.jsxs)(`section`,{className:`space-y-3`,children:[m,g]}),t[36]=m,t[37]=g,t[38]=_):_=t[38],(0,O.jsxs)(`div`,{className:`space-y-6`,children:[(0,O.jsxs)(`div`,{className:`space-y-3`,children:[r,(0,O.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[l(e)?f?`已完成`:`Completed`:e.enabled?f?`已启用`:`Enabled`:f?`已暂停`:`Paused`,` · `,c(e.trigger,p.automations,p.cron,d)]}),i,a,o,s]}),_]})}let E=b.value,k;t[39]===E.name?k=t[40]:(k=(0,O.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:E.name}),t[39]=E.name,t[40]=k);let A=E.description||E.idea,j;t[41]!==T||t[42]!==A?(j=T(A),t[41]=T,t[42]=A,t[43]=j):j=t[43];let M;t[44]!==E.name||t[45]!==b.previewUrl||t[46]!==f?(M=b.previewUrl&&(0,O.jsx)(`iframe`,{title:f?`${E.name} 交互预览`:`${E.name} interactive preview`,src:i(b.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-[min(30rem,55dvh)] w-full rounded-lg border border-edge bg-white`}),t[44]=E.name,t[45]=b.previewUrl,t[46]=f,t[47]=M):M=t[47];let N;t[48]!==E||t[49]!==f?(N=E.installationState===`installed`&&E.enabled&&E.status===`installed`&&(0,O.jsx)(r,{to:C(E),className:`inline-flex rounded-lg bg-accent px-3 py-2 text-sm text-white focus-visible:ring-2 focus-visible:ring-accent`,children:f?`使用应用`:`Use app`}),t[48]=E,t[49]=f,t[50]=N):N=t[50];let P;return t[51]!==k||t[52]!==j||t[53]!==M||t[54]!==N?(P=(0,O.jsxs)(`div`,{className:`space-y-5`,children:[k,j,M,N]}),t[51]=k,t[52]=j,t[53]=M,t[54]=N,t[55]=P):P=t[55],P}function G(e){return e?.trim()?(0,O.jsx)(f,{content:e,mermaidActions:!1}):null}function K(e){return e?.kind===`automation`&&e.value?.state.runningRunId?3e3:0}function q(e){return e.language}function J(e){return e.conversationId}export{U as default};