@xopcai/xopc 0.0.201 → 0.0.203

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 (164) 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/{activity-store-DOhnAQOQ.js → activity-store-SZAay-ze.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D8Cw0Mve.js → agent-avatar-dicebear-DPLJtxoS.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DyjRuuRa.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-E9Bk-Idp.js → api-C1cSt2ru.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-BubrReXg.js → app-management-settings-panel-B3PCMqor.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-BY5Az2p4.js → appearance-settings-txSx3REK.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-BEhBaooZ.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BY8843mB.js → archive-plugin-B2VVc17j.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-DG45KScf.js → attachment-load-Crk7x8qR.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BUC6FL6O.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-DGIF2ZAv.js → binary-plugins-CLlJsq5D.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-C1Qktr1g.js → block-editor-cJ5lVNAG.js} +46 -46
  15. package/dist/gateway/static/root/assets/browser-settings-page-Bq2m4VpX.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-D_jnndyz.js → browser-workflow-inputs-WRiFG88u.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-DyIRvPaq.js → browser-workflows-page-BHLdVoOC.js} +2 -2
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-BiQbVvYU.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api--tz0mGLY.js → capability-presets-api-DmElfgC9.js} +1 -1
  20. package/dist/gateway/static/root/assets/capability-presets-settings-panel-CYlZQpLY.js +3 -0
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-CkOKF9nc.js → channel-recipient-api-BUEOtPft.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-settings-DlDiCMhO.js +1 -0
  23. package/dist/gateway/static/root/assets/channels-status-swr-Dm_-934M.js +1 -0
  24. package/dist/gateway/static/root/assets/{connectors-api-FBOe9SWC.js → connectors-api-BCdn44_o.js} +1 -1
  25. package/dist/gateway/static/root/assets/connectors-page-Ce-eaPHw.js +2 -0
  26. package/dist/gateway/static/root/assets/cron-expression-D2hF3t68.js +2 -0
  27. package/dist/gateway/static/root/assets/{date-picker-Dtn7e6TW.js → date-picker-Dvjoq2mB.js} +1 -1
  28. package/dist/gateway/static/root/assets/dependency-picker-zv1OIhk3.js +1 -0
  29. package/dist/gateway/static/root/assets/desktop-pet-DJZhKLTb.js +1 -0
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-FDmaty3P.js → desktop-pet-settings-B3ubM-eY.js} +1 -1
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-X2e8xn8j.js → directory-picker-path-field-BZEJIWOT.js} +1 -1
  32. package/dist/gateway/static/root/assets/download-Dk-ZjtO6.js +1 -0
  33. package/dist/gateway/static/root/assets/{extension-debug-page-Dx4MBfga.js → extension-debug-page-Bvq3E1A1.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-Bf_FEDhM.js → extension-page-CuCJjWNm.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-CrOgZxkf.js → extension-settings-page-CpTk_ajr.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-api-CZ4r-7qT.js → gateway-config-api-C2yM6qj7.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-swr-Cv2ywpdb.js → gateway-config-swr-CN-JHMAh.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-DpWmVi0w.js → gateway-settings-COwi--2Q.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-undf-k5g.js → gateway-startup-retry-Dq1RyCjz.js} +1 -1
  40. package/dist/gateway/static/root/assets/{heartbeat-settings-DSQZhSvT.js → heartbeat-settings-Dc6H4VGF.js} +1 -1
  41. package/dist/gateway/static/root/assets/home-page-BB3RGxwm.js +3 -0
  42. package/dist/gateway/static/root/assets/index-CPTLS-Zn.js +85 -0
  43. package/dist/gateway/static/root/assets/index-Dm-cvIpl.css +2 -0
  44. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Bc3Quw42.js → keyboard-shortcuts-settings-cue30Z5p.js} +1 -1
  45. package/dist/gateway/static/root/assets/local-app-workbench-page-DfO6FOB9.js +2 -0
  46. package/dist/gateway/static/root/assets/local-apps-page-DKQSCsa0.js +1 -0
  47. package/dist/gateway/static/root/assets/{locale-store-CnamlR07.js → locale-store-81Gv0wwo.js} +1 -1
  48. package/dist/gateway/static/root/assets/logs-page-DODbODyl.js +2 -0
  49. package/dist/gateway/static/root/assets/{management-settings-CJmcaVje.js → management-settings--4H26QR-.js} +1 -1
  50. package/dist/gateway/static/root/assets/{markdown-split-AcuFp0TH.js → markdown-split-BTvpyjAi.js} +1 -1
  51. package/dist/gateway/static/root/assets/markdown-view-B12xeflb.css +1 -0
  52. package/dist/gateway/static/root/assets/markdown-view-B4iBrVWK.js +69 -0
  53. package/dist/gateway/static/root/assets/{media-plugins-BvFgsiJL.js → media-plugins-DrejWl8t.js} +1 -1
  54. package/dist/gateway/static/root/assets/messages-ELK_1h2D.js +3 -0
  55. package/dist/gateway/static/root/assets/{notes-page-IW7IQ9nJ.js → notes-page-DfSzeQKd.js} +1 -1
  56. package/dist/gateway/static/root/assets/notes-workbench-DxL4GhwV.js +4 -0
  57. package/dist/gateway/static/root/assets/plus-Q2yW6OE7.js +1 -0
  58. package/dist/gateway/static/root/assets/preview-open-alternatives-yjh1_7K3.js +1 -0
  59. package/dist/gateway/static/root/assets/{product-open-page-CWEzLykF.js → product-open-page-DopWBJLa.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-Bl3LJHZB.js +1 -0
  61. package/dist/gateway/static/root/assets/projects-page-DStOErTC.js +1 -0
  62. package/dist/gateway/static/root/assets/remote-access-hub-C_hh9ztK.js +1 -0
  63. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DAohEZrX.js → runtime-tools-settings-panel-_dHhbYV2.js} +2 -2
  64. package/dist/gateway/static/root/assets/{schema-form-C_OBW8A5.js → schema-form-DZhORvJZ.js} +1 -1
  65. package/dist/gateway/static/root/assets/sessions-page-DDY21KYw.js +1 -0
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-BJrHIcw8.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-C7w2WS-A.js → settings-form-section-Du5eAgFS.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-zwibve4m.js → settings-loading-skeleton-DWS27sv1.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-B9W03dSW.js → settings-page-DPD0MwoN.js} +1 -1
  70. package/dist/gateway/static/root/assets/setup-status-panel-CnXN4LH_.js +1 -0
  71. package/dist/gateway/static/root/assets/share-preview-page-D6HmH2ga.js +2 -0
  72. package/dist/gateway/static/root/assets/shares-settings-U3lvtO3Y.js +1 -0
  73. package/dist/gateway/static/root/assets/skill-reload-api-B6GiZgZU.js +1 -0
  74. package/dist/gateway/static/root/assets/skills-page-XVO7d3fh.js +2 -0
  75. package/dist/gateway/static/root/assets/{skills-page.utils-D9QT5cxj.js → skills-page.utils-DwxIpWrI.js} +1 -1
  76. package/dist/gateway/static/root/assets/{system-settings-panel-c1HVtv1Y.js → system-settings-panel-BmKbxR8_.js} +1 -1
  77. package/dist/gateway/static/root/assets/task-detail-page-DA6ItYrc.js +1 -0
  78. package/dist/gateway/static/root/assets/{theme-store-BDyUTObE.js → theme-store-hOF81tUQ.js} +1 -1
  79. package/dist/gateway/static/root/assets/{use-autosave-D6UkH_Ga.js → use-autosave-GJfDpf66.js} +1 -1
  80. package/dist/gateway/static/root/assets/user-context-page-CQ1QrRE6.js +1 -0
  81. package/dist/gateway/static/root/assets/{voice-api-key-field-BOxkKbGh.js → voice-api-key-field-B0zve9EE.js} +1 -1
  82. package/dist/gateway/static/root/assets/work-discovery-overlay-DrIbHnBz.js +1 -0
  83. package/dist/gateway/static/root/assets/work-discovery-page-CQW8pPec.js +1 -0
  84. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-ZA3bP65I.js → workflow-run-setup-panel-D-_zQxim.js} +2 -2
  85. package/dist/gateway/static/root/assets/workflows-page-O21l_f5c.js +5 -0
  86. package/dist/gateway/static/root/assets/{working-directory-picker-modal-BcyiDXU3.js → working-directory-picker-modal-5xYx48tV.js} +1 -1
  87. package/dist/gateway/static/root/assets/x-B_N4OPjy.js +1 -0
  88. package/dist/gateway/static/root/index.html +19 -14
  89. package/dist/package.js +1 -1
  90. package/dist/src/agent/agent-manager.js +2 -1
  91. package/dist/src/agent/embedded/run-for-session.js +3 -2
  92. package/dist/src/agent/embedded/run-turn.js +29 -16
  93. package/dist/src/agent/embedded/types.d.ts +2 -2
  94. package/dist/src/agent/embedded/xopc-stream-bridge.d.ts +2 -1
  95. package/dist/src/agent/embedded/xopc-stream-bridge.js +2 -2
  96. package/dist/src/agent/memory/context-budget.d.ts +6 -1
  97. package/dist/src/agent/memory/context-budget.js +94 -2
  98. package/dist/src/agent/prompt/cache-boundary.d.ts +2 -0
  99. package/dist/src/agent/prompt/cache-boundary.js +10 -1
  100. package/dist/src/agent/prompt/sections/project-context.d.ts +1 -4
  101. package/dist/src/agent/prompt/sections/project-context.js +6 -13
  102. package/dist/src/agent/prompt/service-prompt-builder.js +2 -1
  103. package/dist/src/agent/prompt/system-prompt.d.ts +1 -3
  104. package/dist/src/agent/prompt/system-prompt.js +6 -15
  105. package/dist/src/agent/tools/cache-stability.d.ts +3 -0
  106. package/dist/src/agent/tools/cache-stability.js +19 -0
  107. package/dist/src/agent/tools/factory.js +2 -1
  108. package/dist/src/agent-manifest/schema.d.ts +40 -20
  109. package/dist/src/agent-manifest/schema.js +4 -5
  110. package/dist/src/config/schema.d.ts +40 -20
  111. package/dist/src/extensions/types/providers.d.ts +0 -2
  112. package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -1
  113. package/dist/src/gateway/hono/oauth-async.d.ts +1 -0
  114. package/dist/src/gateway/hono/oauth-async.js +14 -2
  115. package/dist/src/providers/extension-stream-bridge.js +0 -2
  116. package/dist/src/providers/google-managed-prompt-cache.d.ts +14 -0
  117. package/dist/src/providers/google-managed-prompt-cache.js +125 -0
  118. package/dist/src/providers/prompt-cache-fingerprint.d.ts +4 -0
  119. package/dist/src/providers/prompt-cache-fingerprint.js +44 -0
  120. package/dist/src/providers/prompt-cache-lifecycle.d.ts +9 -0
  121. package/dist/src/providers/prompt-cache-lifecycle.js +31 -0
  122. package/dist/src/providers/prompt-cache-observability.d.ts +20 -0
  123. package/dist/src/providers/prompt-cache-observability.js +44 -0
  124. package/dist/src/providers/prompt-cache-payload.d.ts +10 -3
  125. package/dist/src/providers/prompt-cache-payload.js +204 -31
  126. package/dist/src/providers/prompt-cache-plan.d.ts +15 -0
  127. package/dist/src/providers/prompt-cache-plan.js +29 -0
  128. package/package.json +3 -3
  129. package/dist/gateway/static/root/assets/agents-ANavi648.js +0 -68
  130. package/dist/gateway/static/root/assets/apps-page-CFh9MBxc.js +0 -1
  131. package/dist/gateway/static/root/assets/automations-page-751CeNI3.js +0 -6
  132. package/dist/gateway/static/root/assets/browser-settings-page-CGAWs-TT.js +0 -8
  133. package/dist/gateway/static/root/assets/capabilities-settings-panel-CghUK68J.js +0 -7
  134. package/dist/gateway/static/root/assets/capability-presets-settings-panel-XsTfkvUn.js +0 -3
  135. package/dist/gateway/static/root/assets/channels-settings-DkoAZZMe.js +0 -1
  136. package/dist/gateway/static/root/assets/channels-status-swr-DNDvMWpl.js +0 -1
  137. package/dist/gateway/static/root/assets/connectors-page-e4vekkAu.js +0 -2
  138. package/dist/gateway/static/root/assets/cron-expression-Q4QaYjpI.js +0 -2
  139. package/dist/gateway/static/root/assets/dependency-picker-Br6nPaM6.js +0 -1
  140. package/dist/gateway/static/root/assets/desktop-pet-DzTM6aH8.js +0 -1
  141. package/dist/gateway/static/root/assets/home-page-L0uHiu0T.js +0 -3
  142. package/dist/gateway/static/root/assets/index-Bp8I_eX4.css +0 -1
  143. package/dist/gateway/static/root/assets/index-DRrjYYzZ.js +0 -152
  144. package/dist/gateway/static/root/assets/local-app-workbench-page-Copi3sdP.js +0 -2
  145. package/dist/gateway/static/root/assets/local-apps-page-CP9X_vtz.js +0 -1
  146. package/dist/gateway/static/root/assets/logs-page-DMKq6e29.js +0 -2
  147. package/dist/gateway/static/root/assets/messages-D7kOD_o_.js +0 -3
  148. package/dist/gateway/static/root/assets/notes-workbench-Zb8U0anO.js +0 -4
  149. package/dist/gateway/static/root/assets/preview-open-alternatives-C-b34dgQ.js +0 -1
  150. package/dist/gateway/static/root/assets/project-detail-page-BuIbLnan.js +0 -1
  151. package/dist/gateway/static/root/assets/projects-page-BwUfRqNV.js +0 -1
  152. package/dist/gateway/static/root/assets/remote-access-hub-BTaXxcEi.js +0 -1
  153. package/dist/gateway/static/root/assets/sessions-page-BnHoTCD3.js +0 -1
  154. package/dist/gateway/static/root/assets/settings-advanced-gate-BTB_fxjt.js +0 -1
  155. package/dist/gateway/static/root/assets/setup-status-panel-C8Hec2Af.js +0 -1
  156. package/dist/gateway/static/root/assets/share-preview-page-6e3ks2be.js +0 -2
  157. package/dist/gateway/static/root/assets/shares-settings-Bwc5HfLI.js +0 -1
  158. package/dist/gateway/static/root/assets/skill-reload-api-D7kunhqy.js +0 -1
  159. package/dist/gateway/static/root/assets/skills-page-WgkaNzpc.js +0 -2
  160. package/dist/gateway/static/root/assets/task-detail-page-CjP-6WVU.js +0 -1
  161. package/dist/gateway/static/root/assets/user-context-page-D8ZhPDNF.js +0 -1
  162. package/dist/gateway/static/root/assets/work-discovery-overlay-Dd19yK9t.js +0 -1
  163. package/dist/gateway/static/root/assets/work-discovery-page-DUkdJl1e.js +0 -1
  164. package/dist/gateway/static/root/assets/workflows-page-C2b5W5bw.js +0 -5
@@ -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{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,r as s}from"./popover-select-BzdnTy3h.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./cn-JdwAhgNB.js";import{t as p}from"./button-CSEbl4zT.js";import{s as m}from"./form-field-width-DJw_jULe.js";import{t as h}from"./copy-to-clipboard-HOJ79TWv.js";import{t as g}from"./messages-ELK_1h2D.js";import{l as _,n as v,r as y,s as b}from"./locale-store-81Gv0wwo.js";import{a as x,n as S,o as ee,r as C,s as w,t as te}from"./dist-BPoKqzeH.js";import{i as ne}from"./vendor-swr-BIWyz7Rc.js";import{n as T,r as E}from"./gateway-config-swr-CN-JHMAh.js";import{r as D}from"./settings-form-draft-Dy10ldo8.js";import{Aa as O,An as k,Bc as A,Cl as j,Cr as M,Gc as N,Ln as P,Ns as re,Pi as F,_i as ie,as as I,di as ae,fi as oe,gi as L,hi as R,li as se,mi as z,ol as B,pi as ce,vi as V,yi as H}from"./index-CPTLS-Zn.js";import{n as U,r as W,t as G}from"./settings-page-layout-BRQNel6r.js";import{t as K}from"./settings-loading-skeleton-DWS27sv1.js";import{t as q}from"./settings-form-section-Du5eAgFS.js";import{t as le}from"./page-tabs-BaEQMYm_.js";var J=e(t(),1),ue=n(),Y={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function de(){return structuredClone(Y)}var fe=36e5,X=864e5,Z=1048576;function pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function me(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function he(e){let t=pe(e)?e:{},n=pe(t.gateway)?t.gateway:{},r=pe(n.share)?n.share:{},i=pe(r.directory)?r.directory:{},a=pe(n.siteShare)?n.siteShare:{},o=pe(a.static)?a.static:{},s=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):Y.defaultTtlHours*fe,c=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):Y.maxTtlDays*X,l=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):Y.maxFileSizeMb*Z,u=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):Y.directoryMaxFolderSizeMb*Z,d=typeof a.defaultTtlMs==`number`&&Number.isFinite(a.defaultTtlMs)?Math.floor(a.defaultTtlMs):Y.siteDefaultTtlHours*fe,f=typeof a.maxTtlMs==`number`&&Number.isFinite(a.maxTtlMs)?Math.floor(a.maxTtlMs):Y.siteMaxTtlDays*X,p=typeof o.maxRootDirSize==`number`&&Number.isFinite(o.maxRootDirSize)?Math.floor(o.maxRootDirSize):Y.siteMaxRootDirSizeMb*Z;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(s/fe)),maxTtlDays:Math.max(1,Math.round(c/X)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):Y.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(l/Z)),directoryMaxFolderSizeMb:Math.max(1,Math.round(u/Z)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):Y.directoryMaxFileCount,inlinePreviewMimes:me(r.inlinePreviewMimes,32).length?me(r.inlinePreviewMimes,32):[...Y.inlinePreviewMimes],siteEnabled:a.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(d/fe)),siteMaxTtlDays:Math.max(1,Math.round(f/X)),maxActiveSites:typeof a.maxActiveSites==`number`&&Number.isFinite(a.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(a.maxActiveSites))):Y.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(p/Z)),siteMaxFileCount:typeof o.maxFileCount==`number`&&Number.isFinite(o.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(o.maxFileCount))):Y.siteMaxFileCount}}function ge(e){let t=e.defaultTtlHours*fe,n=e.maxTtlDays*X,r=e.siteDefaultTtlHours*fe,i=e.siteMaxTtlDays*X;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function _e(e){let t=ge(e);if(t)throw Error(t);await b(y(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*fe,maxTtlMs:e.maxTtlDays*X,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Z,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Z,maxFileCount:e.directoryMaxFileCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*fe,maxTtlMs:e.siteMaxTtlDays*X,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Z,maxFileCount:e.siteMaxFileCount}}}})}),T()}var Q=r();function ve(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m,`dark:border-edge`)}function ye({hasToken:e}){let t=g(v(e=>e.language)).sharesSettings,{data:n,isLoading:r}=E(e),i=(0,J.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(he(n.payload.config)),[n]),a=(0,J.useRef)(!1),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,m]=(0,J.useState)(!1),h=o??i,_=i,y=(0,J.useMemo)(()=>!h||!_?!1:JSON.stringify(h)!==JSON.stringify(_),[h,_]),b=(0,J.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),x=(0,J.useCallback)(async()=>{if(!(!h||c)){l(!0),d(null),m(!1);try{await _e(h),a.current=!1,s(null),m(!0),window.setTimeout(()=>m(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[h,c,t.policySaveError]),S=(0,J.useCallback)(()=>{a.current=!1,s(null),d(null),m(!1)},[]);return!e||!h?r?(0,Q.jsx)(q,{children:(0,Q.jsx)(K,{rows:2})}):null:(0,Q.jsxs)(q,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[f?(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Q.jsx)(p,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>b(de()),children:t.policyUseRecommended}),(0,Q.jsx)(p,{type:`button`,variant:`secondary`,disabled:!y||c,onClick:S,children:t.policyDiscard}),(0,Q.jsx)(p,{type:`button`,variant:`primary`,disabled:!y||c,onClick:()=>void x(),children:c?t.policySaving:t.policySave})]})]}),y?(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Q.jsx)(be,{t,form:h,onChange:b})]})}function be(e){let t=(0,ue.c)(150),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,Q.jsx)($,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,Q.jsx)($,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,Q.jsx)($,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,Q.jsx)($,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let ee=!r.enabled,C;t[47]===i?C=t[48]:(C=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=C);let w;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==ee||t[53]!==C?(w=(0,Q.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:ee,onChange:C}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=ee,t[53]=C,t[54]=w):w=t[54];let te=!r.enabled,ne;t[55]===i?ne=t[56]:(ne=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=ne);let T;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==te||t[61]!==ne?(T=(0,Q.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:te,onChange:ne}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=te,t[61]=ne,t[62]=T):T=t[62];let E;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==w||t[67]!==T||t[68]!==p?(E=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,w,T]}),t[63]=g,t[64]=y,t[65]=S,t[66]=w,t[67]=T,t[68]=p,t[69]=E):E=t[69];let D=!r.enabled,O;t[70]===i?O=t[71]:(O=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=O);let k;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==D||t[75]!==O?(k=(0,Q.jsx)(xe,{t:n,values:r.inlinePreviewMimes,disabled:D,onChange:O}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=D,t[75]=O,t[76]=k):k=t[76];let A;t[77]!==E||t[78]!==k||t[79]!==s||t[80]!==u?(A=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[s,u,E,k]}),t[77]=E,t[78]=k,t[79]=s,t[80]=u,t[81]=A):A=t[81];let j;t[82]===n.policySiteSection?j=t[83]:(j=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[82]=n.policySiteSection,t[83]=j);let M;t[84]===n.policySiteSectionHint?M=t[85]:(M=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[84]=n.policySiteSectionHint,t[85]=M);let N;t[86]!==j||t[87]!==M?(N=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[j,M]}),t[86]=j,t[87]=M,t[88]=N):N=t[88];let P;t[89]===i?P=t[90]:(P=e=>i({siteEnabled:e.target.checked}),t[89]=i,t[90]=P);let re;t[91]!==r.siteEnabled||t[92]!==P?(re=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:P}),t[91]=r.siteEnabled,t[92]=P,t[93]=re):re=t[93];let F;t[94]!==n.policySiteEnabled||t[95]!==re?(F=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[re,n.policySiteEnabled]}),t[94]=n.policySiteEnabled,t[95]=re,t[96]=F):F=t[96];let ie=!r.siteEnabled,I;t[97]===i?I=t[98]:(I=e=>i({siteDefaultTtlHours:e}),t[97]=i,t[98]=I);let ae;t[99]!==r.siteDefaultTtlHours||t[100]!==n.policySiteDefaultTtlHint||t[101]!==n.policySiteDefaultTtlHours||t[102]!==ie||t[103]!==I?(ae=(0,Q.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:ie,onChange:I}),t[99]=r.siteDefaultTtlHours,t[100]=n.policySiteDefaultTtlHint,t[101]=n.policySiteDefaultTtlHours,t[102]=ie,t[103]=I,t[104]=ae):ae=t[104];let oe=!r.siteEnabled,L;t[105]===i?L=t[106]:(L=e=>i({siteMaxTtlDays:e}),t[105]=i,t[106]=L);let R;t[107]!==r.siteMaxTtlDays||t[108]!==n.policySiteMaxTtlDays||t[109]!==n.policySiteMaxTtlHint||t[110]!==oe||t[111]!==L?(R=(0,Q.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:oe,onChange:L}),t[107]=r.siteMaxTtlDays,t[108]=n.policySiteMaxTtlDays,t[109]=n.policySiteMaxTtlHint,t[110]=oe,t[111]=L,t[112]=R):R=t[112];let se=!r.siteEnabled,z;t[113]===i?z=t[114]:(z=e=>i({maxActiveSites:e}),t[113]=i,t[114]=z);let B;t[115]!==r.maxActiveSites||t[116]!==n.policyMaxActiveSites||t[117]!==n.policyMaxActiveSitesHint||t[118]!==se||t[119]!==z?(B=(0,Q.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:se,onChange:z}),t[115]=r.maxActiveSites,t[116]=n.policyMaxActiveSites,t[117]=n.policyMaxActiveSitesHint,t[118]=se,t[119]=z,t[120]=B):B=t[120];let ce=!r.siteEnabled,V;t[121]===i?V=t[122]:(V=e=>i({siteMaxRootDirSizeMb:e}),t[121]=i,t[122]=V);let H;t[123]!==r.siteMaxRootDirSizeMb||t[124]!==n.policySiteMaxRootDirSizeHint||t[125]!==n.policySiteMaxRootDirSizeMb||t[126]!==ce||t[127]!==V?(H=(0,Q.jsx)($,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:ce,onChange:V}),t[123]=r.siteMaxRootDirSizeMb,t[124]=n.policySiteMaxRootDirSizeHint,t[125]=n.policySiteMaxRootDirSizeMb,t[126]=ce,t[127]=V,t[128]=H):H=t[128];let U=!r.siteEnabled,W;t[129]===i?W=t[130]:(W=e=>i({siteMaxFileCount:e}),t[129]=i,t[130]=W);let G;t[131]!==r.siteMaxFileCount||t[132]!==n.policySiteMaxFileCount||t[133]!==n.policySiteMaxFileCountHint||t[134]!==U||t[135]!==W?(G=(0,Q.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:U,onChange:W}),t[131]=r.siteMaxFileCount,t[132]=n.policySiteMaxFileCount,t[133]=n.policySiteMaxFileCountHint,t[134]=U,t[135]=W,t[136]=G):G=t[136];let K;t[137]!==ae||t[138]!==R||t[139]!==B||t[140]!==H||t[141]!==G?(K=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ae,R,B,H,G]}),t[137]=ae,t[138]=R,t[139]=B,t[140]=H,t[141]=G,t[142]=K):K=t[142];let q;t[143]!==N||t[144]!==F||t[145]!==K?(q=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[N,F,K]}),t[143]=N,t[144]=F,t[145]=K,t[146]=q):q=t[146];let le;return t[147]!==A||t[148]!==q?(le=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[A,q]}),t[147]=A,t[148]=q,t[149]=le):le=t[149],le}function $(e){let t=(0,ue.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=f(ve(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let p;t[4]!==s||t[5]!==o||t[6]!==l?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==p||t[13]!==a?(m=(0,Q.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:p}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=p,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==u||t[18]!==m||t[19]!==h?(g=(0,Q.jsxs)(`div`,{children:[u,m,h]}),t[17]=u,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function xe(e){let t=(0,ue.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=r.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,Q.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let d;t[11]===u?d=t[12]:(d=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=f(ve(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===s?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Q.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,d,g]}),t[20]=c,t[21]=l,t[22]=d,t[23]=g,t[24]=_):_=t[24],_}function Se(e){let t=(0,ue.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,sessionKey:u,agentId:m}=e,h=c===void 0?`any`:c,y=g(v(Te)),b=y.workspace,T=y.sharesSettings,E=se(we),{data:D}=ne(_(Ce)?`picker-agents-list`:null,P),O;bb0:{let e;t[0]===m?e=t[1]:(e=m?.trim(),t[0]=m,t[1]=e);let n=e;if(n){O=n;break bb0}let r;t[2]===E?r=t[3]:(r=E.trim(),t[2]=E,t[3]=r);let i=r;if(i){O=i;break bb0}if(D?.defaultId){O=D.defaultId;break bb0}if(D?.agents?.[0]?.id){O=D.agents[0].id;break bb0}O=``}let j=O,[M,N]=(0,J.useState)(j),ie,I;t[4]===j?(ie=t[5],I=t[6]):(ie=()=>{N(j)},I=[j],t[4]=j,t[5]=ie,t[6]=I),(0,J.useEffect)(ie,I);let{tree:oe,loading:L,error:R,loadRoot:z,loadChildren:B,reset:ce}=ae(M,u??null),V;t[7]===a?V=t[8]:(V=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=V);let[H,U]=(0,J.useState)(V),W;t[9]!==a||t[10]!==z||t[11]!==n||t[12]!==ce||t[13]!==U?(W=()=>{if(!n){ce(),U(a?{path:a,isDirectory:!1}:null);return}z()},t[9]=a,t[10]=z,t[11]=n,t[12]=ce,t[13]=U,t[14]=W):W=t[14];let G;t[15]!==a||t[16]!==z||t[17]!==n||t[18]!==M||t[19]!==ce||t[20]!==u?(G=[n,M,u,z,ce,a],t[15]=a,t[16]=z,t[17]=n,t[18]=M,t[19]=ce,t[20]=u,t[21]=G):G=t[21],(0,J.useEffect)(W,G);let K;t[22]===B?K=t[23]:(K=e=>{B(e)},t[22]=B,t[23]=K);let q=K,le=H!==null&&(h===`any`||h===`file`&&!H.isDirectory||h===`directory`&&H.isDirectory),Y;bb1:{if(!H){Y=T.pickerHintNone;break bb1}if(h===`file`&&H.isDirectory){Y=T.pickerHintNeedsFile;break bb1}if(h===`directory`&&!H.isDirectory){Y=T.pickerHintNeedsDirectory;break bb1}Y=`${H.isDirectory?`📁`:`📄`} ${H.path}`}let de=Y,fe=D?.agents??[],X;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(x,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=f(`fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-popover outline-none`),t[25]=Z):Z=t[25];let pe;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Q.jsx)(A,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=pe):pe=t[26];let me=y.cron.refresh,he=y.cron.refresh,ge;t[27]===z?ge=t[28]:(ge=()=>void z(),t[27]=z,t[28]=ge);let _e=L&&`animate-spin`,ve;t[29]===_e?ve=t[30]:(ve=f(`size-4`,_e),t[29]=_e,t[30]=ve);let ye;t[31]===ve?ye=t[32]:(ye=(0,Q.jsx)(re,{className:ve,"aria-hidden":!0}),t[31]=ve,t[32]=ye);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Q.jsx)(d,{className:`size-4`}),t[33]=be):be=t[33];let $;t[34]!==R||t[35]!==b.loadError?($=R?(0,Q.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[b.loadError,`: `,R]}):null,t[34]=R,t[35]=b.loadError,t[36]=$):$=t[36];let xe;t[37]!==q||t[38]!==L||t[39]!==H?.path||t[40]!==U||t[41]!==b.emptyDir||t[42]!==b.title||t[43]!==oe?(xe=L&&oe.length===0?(0,Q.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Q.jsx)(l,{className:`size-4 animate-spin`}),b.title,`…`]}):(0,Q.jsx)(F,{tree:oe,selectedPath:H?.path??null,onSelectFile:e=>U({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>U({path:e,isDirectory:t}),onExpandDir:q,onAction:void 0,emptyHint:b.emptyDir}),t[37]=q,t[38]=L,t[39]=H?.path,t[40]=U,t[41]=b.emptyDir,t[42]=b.title,t[43]=oe,t[44]=xe):xe=t[44];let Se;t[45]!==$||t[46]!==xe?(Se=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[$,xe]}),t[45]=$,t[46]=xe,t[47]=Se):Se=t[47];let Ee;t[48]===de?Ee=t[49]:(Ee=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:de}),t[48]=de,t[49]=Ee);let De;t[50]===r?De=t[51]:(De=()=>r(!1),t[50]=r,t[51]=De);let Oe;t[52]!==T.cancel||t[53]!==De?(Oe=(0,Q.jsx)(p,{type:`button`,variant:`ghost`,onClick:De,children:T.cancel}),t[52]=T.cancel,t[53]=De,t[54]=Oe):Oe=t[54];let ke=!le,Ae;t[55]!==i||t[56]!==r||t[57]!==M||t[58]!==H?(Ae=()=>{H&&(i({...H,agentId:M}),r(!1))},t[55]=i,t[56]=r,t[57]=M,t[58]=H,t[59]=Ae):Ae=t[59];let je;t[60]!==T.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Q.jsx)(p,{type:`button`,disabled:ke,onClick:Ae,children:T.pickerConfirm}),t[60]=T.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Oe,je]}),t[64]=Oe,t[65]=je,t[66]=Me):Me=t[66];let Ne;return t[67]!==Ee||t[68]!==Me?(Ne=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ee,Me]}),t[67]=Ee,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Q.jsx)(te,{open:n,onOpenChange:r,children:(0,Q.jsxs)(ee,{children:[X,(0,Q.jsxs)(C,{className:Z,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[pe,(0,Q.jsx)(w,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:T.pickerTitle}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:me,"aria-label":he,disabled:L,onClick:ge,children:ye}),(0,Q.jsx)(S,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":b.close,children:be})})]}),fe.length>0?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:T.pickerAgentLabel}),(0,Q.jsx)(o,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:M,onChange:e=>{N(e.target.value),U(null)},children:fe.map(e=>(0,Q.jsxs)(s,{value:e.id,children:[k(e,y.agentsSettings),e.id===D?.defaultId?` ★`:``]},e.id))})]}):null,Se,Ne]})]})})}function Ce(e){return e.token}function we(e){return e.agentId}function Te(e){return e.language}var Ee=[`shares`,`policy`];function De(e){let t=(e??``).trim();return Ee.includes(t)?t:`shares`}function Oe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function ke(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var Ae=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function je(){let e=(0,ue.c)(24),t=v(Ne),n=g(t).sharesSettings,r=!!_(Me),[a,o]=i(),s;e[0]===a?s=e[1]:(s=De(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let u=l;if(!r)return(0,Q.jsx)(W,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},f=Ee.map(e=>({id:e,label:d[e]})),p;e[4]!==n.subtitle||e[5]!==n.title?(p=(0,Q.jsx)(U,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=p):p=e[6];let m;e[7]!==c||e[8]!==u||e[9]!==n.tabsAria||e[10]!==f?(m=(0,Q.jsx)(le,{items:f,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=c,e[8]=u,e[9]=n.tabsAria,e[10]=f,e[11]=m):m=e[11];let h;e[12]!==c||e[13]!==r||e[14]!==t||e[15]!==n?(h=c===`shares`?(0,Q.jsx)(Pe,{t:n,language:t}):(0,Q.jsx)(ye,{hasToken:r}),e[12]=c,e[13]=r,e[14]=t,e[15]=n,e[16]=h):h=e[16];let y;e[17]!==c||e[18]!==h?(y=(0,Q.jsx)(G,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:h}),e[17]=c,e[18]=h,e[19]=y):y=e[19];let b;return e[20]!==p||e[21]!==m||e[22]!==y?(b=(0,Q.jsxs)(W,{children:[p,m,y]}),e[20]=p,e[21]=m,e[22]=y,e[23]=b):b=e[23],b}function Me(e){return e.token}function Ne(e){return e.language}function Pe(e){let t=(0,ue.c)(60),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=ne(`shares-list`,R,i),l;t[1]===a?.payload?.shares?l=t[2]:(l=a?.payload?.shares??[],t[1]=a?.payload?.shares,t[2]=l);let u=l,[d,m]=(0,J.useState)(!1),h;bb0:{if(d){h=u;break bb0}let e;t[3]===u?e=t[4]:(e=u.filter(ze),t[3]=u,t[4]=e),h=e}let g=h,_;t[5]===u?_=t[6]:(_=u.filter(Re),t[5]=u,t[6]=_);let v=_.length,y;t[7]===u?y=t[8]:(y=u.filter(Le),t[7]=u,t[8]=y);let b=y.length,x;t[9]===c?x=t[10]:(x=()=>void c(),t[9]=c,t[10]=x);let S;t[11]!==n||t[12]!==x?(S=(0,Q.jsx)(Ve,{t:n,onCreated:x}),t[11]=n,t[12]=x,t[13]=S):S=t[13];let ee=d?n.allSharesTitle:n.listTitle,C;t[14]===v?C=t[15]:(C=v>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[14]=v,t[15]=C);let w;t[16]!==ee||t[17]!==C?(w=(0,Q.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[ee,C]}),t[16]=ee,t[17]=C,t[18]=w):w=t[18];let te;t[19]===c?te=t[20]:(te=()=>void c(),t[19]=c,t[20]=te);let T=s&&`animate-spin`,E;t[21]===T?E=t[22]:(E=f(`size-3.5`,T),t[21]=T,t[22]=E);let D;t[23]===E?D=t[24]:(D=(0,Q.jsx)(re,{className:E}),t[23]=E,t[24]=D);let O;t[25]!==s||t[26]!==te||t[27]!==D?(O=(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:te,disabled:s,children:D}),t[25]=s,t[26]=te,t[27]=D,t[28]=O):O=t[28];let k;t[29]!==b||t[30]!==d||t[31]!==n.hideExpired||t[32]!==n.showExpired?(k=b>0&&(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Ie),children:d?n.hideExpired:n.showExpired}),t[29]=b,t[30]=d,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=k):k=t[33];let A;t[34]!==O||t[35]!==k?(A=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O,k]}),t[34]=O,t[35]=k,t[36]=A):A=t[36];let j;t[37]!==w||t[38]!==A?(j=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[w,A]}),t[37]=w,t[38]=A,t[39]=j):j=t[39];let M;t[40]!==a||t[41]!==o||t[42]!==g||t[43]!==s||t[44]!==r||t[45]!==c||t[46]!==n?(M=s&&!a?(0,Q.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Fe)}):o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Q.jsx)(`span`,{children:n.error}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):g.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,Q.jsx)(Ue,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[40]=a,t[41]=o,t[42]=g,t[43]=s,t[44]=r,t[45]=c,t[46]=n,t[47]=M):M=t[47];let N;t[48]!==b||t[49]!==c||t[50]!==d||t[51]!==n?(N=b>0&&d&&(0,Q.jsx)(We,{t:n,onCleaned:()=>void c()}),t[48]=b,t[49]=c,t[50]=d,t[51]=n,t[52]=N):N=t[52];let P;t[53]!==j||t[54]!==M||t[55]!==N?(P=(0,Q.jsxs)(q,{children:[j,M,N]}),t[53]=j,t[54]=M,t[55]=N,t[56]=P):P=t[56];let F;return t[57]!==P||t[58]!==S?(F=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,P]}),t[57]=P,t[58]=S,t[59]=F):F=t[59],F}function Fe(e,t){return(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(O,{className:`h-4 w-2/3`}),(0,Q.jsx)(O,{className:`mt-2 h-3 w-1/2`})]}),(0,Q.jsx)(O,{className:`h-7 w-20 rounded-md`})]})},t)}function Ie(e){return!e}function Le(e){return e.expired||e.revoked}function Re(e){return!e.expired&&!e.revoked}function ze(e){return!e.expired&&!e.revoked}var Be={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function Ve({t:e,onCreated:t}){let[n,r]=(0,J.useReducer)(D,Be),{expanded:i,path:a,isDirectory:c,agentId:d,ttlMs:m,maxViews:h,description:g,directoryMode:_,creating:v,result:y,errorMsg:b,resultDialogOpen:x,pickerOpen:S}=n,ee=(0,J.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await ce({path:a.trim(),ttlMs:m,maxViews:h,description:g.trim()||void 0,...d?{agentId:d}:{},...c?{kind:`directory`,directoryMode:_}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,c,d,m,h,g,_,t]),C=(0,J.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Q.jsxs)(q,{children:[(0,Q.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:f(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:c?`📁`:`📄`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,Q.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Q.jsxs)(p,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Q.jsx)(N,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),c?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Q.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:_,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Q.jsx)(s,{value:`browse`,children:e.directoryModeBrowse}),(0,Q.jsx)(s,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Q.jsx)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:m,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Ae.map(t=>(0,Q.jsx)(s,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Q.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:h??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Q.jsx)(s,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Q.jsx)(s,{value:`1`,children:`1`}),(0,Q.jsx)(s,{value:`5`,children:`5`}),(0,Q.jsx)(s,{value:`10`,children:`10`}),(0,Q.jsx)(s,{value:`50`,children:`50`}),(0,Q.jsx)(s,{value:`100`,children:`100`})]})]})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Q.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:g,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsxs)(p,{type:`button`,disabled:v||!a.trim(),onClick:()=>void ee(),children:[v?(0,Q.jsx)(l,{className:`size-4 animate-spin`}):(0,Q.jsx)(u,{className:`size-4`}),v?e.creating:e.createButton]}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,onClick:()=>{C(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),b&&(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b})]}),(0,Q.jsx)(V,{open:x,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:y}),(0,Q.jsx)(Se,{open:S,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,Q.jsxs)(p,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Q.jsx)(u,{className:`size-4`}),e.createTitle]})}var He={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Ue({share:e,t,language:n,onRevoked:r,onExtended:i}){let[o,s]=(0,J.useReducer)(D,He),{revokeOpen:u,revoking:d,linksOpen:m,urlCopied:g,copyFailed:_,extending:v}=o,y=!e.expired&&!e.revoked,b=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,x=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,S=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await L(e.id),r()}catch{}finally{s({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),ee=(0,J.useCallback)(async()=>{if(s({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await h(e.shareUrl)){s({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{copyFailed:!1}}),2500);return}s({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),C=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{extending:!0}});try{await z(e.id,864e5),i()}catch{}finally{s({type:`patch`,patch:{extending:!1}})}},[e.id,i]),w=`share-links-${e.id}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:f(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":m,"aria-controls":w,onClick:()=>s({type:`patch`,patch:{linksOpen:!m}}),children:[(0,Q.jsx)(j,{className:f(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,m?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),(0,Q.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:f(`text-xs font-medium`,x),children:b})]}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.workspaceRelativePath}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:Oe(e.fileSize)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(B,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:ke(e.expiresAt,n)]}),(0,Q.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Q.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:y&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void ee(),children:g?(0,Q.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(c,{className:`size-3.5`})}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void C(),disabled:v,title:t.extend,children:v?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(B,{className:`size-3.5`})}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>s({type:`patch`,patch:{revokeOpen:!0}}),disabled:d,children:d?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(I,{className:`size-3.5`})})]})})]}),y&&m?(0,Q.jsxs)(`div`,{id:w,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Q.jsx)(H,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),_?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(ie,{reachability:e.reachability})})]}):null]}),(0,Q.jsx)(M,{open:u,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void S(),onCancel:()=>s({type:`patch`,patch:{revokeOpen:!1}})})]})}function We({t:e,onCleaned:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),o=(0,J.useCallback)(async()=>{r(!1),a(!0);try{await oe(),t()}catch{}finally{a(!1)}},[t]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsxs)(p,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(I,{className:`size-3.5`}),e.cleanExpired]})}),(0,Q.jsx)(M,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{je as SharesSettingsPanel};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{o as t,r as n}from"./locale-store-81Gv0wwo.js";import{Kn as r}from"./index-CPTLS-Zn.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-DT31yWkU.js","assets/rolldown-runtime-aKtaBQYM.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{c as a,f as o,l as s}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as c}from"./popover-select-BzdnTy3h.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./markdown-view-B4iBrVWK.js";import{t as d}from"./loader-circle-CifKLtgG.js";import{t as f}from"./plus-Q2yW6OE7.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./cn-JdwAhgNB.js";import{t as h}from"./button-CSEbl4zT.js";import{n as g}from"./interaction-BmQogeqz.js";import{t as _}from"./messages-ELK_1h2D.js";import{l as v,n as y}from"./locale-store-81Gv0wwo.js";import{a as b,n as x,o as S,r as C,s as w,t as T}from"./dist-BPoKqzeH.js";import{t as E}from"./config-reload-event-Bjh2zoKp.js";import{Ba as D,Fi as O,Gn as k,Jc as A,Si as j,Sl as M,Va as N,as as P,bl as F,is as I,ks as L,ms as R,vl as z,wc as B,xl as V}from"./index-CPTLS-Zn.js";import{t as H}from"./page-tabs-BaEQMYm_.js";import{t as U}from"./skill-reload-api-B6GiZgZU.js";import{_ as W,a as G,c as ee,d as K,f as q,g as J,h as te,i as ne,l as re,m as ie,n as ae,o as oe,p as se,r as Y,s as ce,t as le,u as ue}from"./skills-page.utils-DwxIpWrI.js";var X=n(),Z=e(t(),1),Q=r(),de=(0,Z.memo)(function(e){let t=(0,X.c)(23),{loading:n,onReloadClick:r,searchQuery:i,setSearchQuery:a,mainTab:o,sk:s,setPendingFile:c,setInstallOpen:l}=e,u;t[0]!==n||t[1]!==r||t[2]!==s.reloadDiskAria||t[3]!==s.reloadRuntime?(u=(0,Q.jsx)(O,{className:`size-9 shrink-0 p-0`,loading:n,label:s.reloadDiskAria,title:s.reloadRuntime,onClick:r}),t[0]=n,t[1]=r,t[2]=s.reloadDiskAria,t[3]=s.reloadRuntime,t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(L,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[5]=d):d=t[5];let p;t[6]===a?p=t[7]:(p=e=>a(e.target.value),t[6]=a,t[7]=p);let m=o===`marketplace`?s.marketplaceSearchPackages:s.searchPlaceholder,g;t[8]!==i||t[9]!==p||t[10]!==m?(g=(0,Q.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:i,onChange:p,placeholder:m,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[8]=i,t[9]=p,t[10]=m,t[11]=g):g=t[11];let _;t[12]!==l||t[13]!==c?(_=()=>{c(null),l(!0)},t[12]=l,t[13]=c,t[14]=_):_=t[14];let v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(f,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[15]=v):v=t[15];let y;t[16]!==s.installCta||t[17]!==_?(y=(0,Q.jsxs)(h,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:_,children:[v,s.installCta]}),t[16]=s.installCta,t[17]=_,t[18]=y):y=t[18];let b;return t[19]!==u||t[20]!==g||t[21]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,g,y]}),t[19]=u,t[20]=g,t[21]=y,t[22]=b):b=t[22],b}),fe=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function pe(){let e=(0,X.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:m(`h-4 min-w-0 flex-1`,fe)}),e[0]=t):t=e[0];let n,r,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[t,(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Q.jsx)(`div`,{className:m(`size-8 shrink-0 rounded-lg`,fe)}),(0,Q.jsx)(`div`,{className:m(`h-8 w-[4.5rem] shrink-0 rounded-lg`,fe)})]})]}),r=(0,Q.jsx)(`div`,{className:m(`h-3 w-full`,fe)}),i=(0,Q.jsx)(`div`,{className:m(`h-3 w-[92%]`,fe)}),e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(`div`,{className:`flex h-full min-h-[10.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[n,r,i,(0,Q.jsxs)(`div`,{className:`mt-auto space-y-1 pt-0.5`,children:[(0,Q.jsx)(`div`,{className:m(`h-3 w-full`,fe)}),(0,Q.jsx)(`div`,{className:m(`h-2.5 w-4/5`,fe)})]})]})})}),e[4]=a):a=e[4],a}function me(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(pe,{}),e[0]=t):t=e[0],t}var he=new Set([`installed`,`marketplace`]),ge=new Set([`all`,`builtin`,`installed`,`global`,`workspace`,`extra`]),_e=new Set([`all`,`enabled`,`disabled`]),ve=`mprov`,ye=[`s0`,`s1`,`s2`,`s3`,`s4`,`s5`],be=[`business`,`creative`,`documents`,`engineering`,`tools`];function xe(e){let t=(0,X.c)(27),{sk:n,loading:r,catalog:i,filteredCatalog:a,builtinCategories:o,builtinCategoryFilter:s,setBuiltinCategoryFilter:c,catalogDisplayRows:l,catalogStatusFilter:u,resolveSkillEnabled:d,categoryLabel:f,sourceLabel:p,openSkillDetail:_,onSkillToggle:v,onUseSkillInChat:y,usingSkillInChatName:b,togglingSkillName:x}=e;if(r){let e=n.loading,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=ye.map(Se),t[0]=r):r=t[0];let i;return t[1]===n.loading?i=t[2]:(i=(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,"aria-busy":`true`,"aria-label":e,children:r}),t[1]=n.loading,t[2]=i),i}if(i.length===0){let e;return t[3]===n.empty?e=t[4]:(e=(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge py-16 text-center text-sm text-fg-muted`,children:n.empty}),t[3]=n.empty,t[4]=e),e}if(a.length===0){let e;return t[5]===n.noSearchResults?e=t[6]:(e=(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge py-16 text-center text-sm text-fg-muted`,children:n.noSearchResults}),t[5]=n.noSearchResults,t[6]=e),e}let S;t[7]!==o||t[8]!==s||t[9]!==f||t[10]!==c||t[11]!==n?(S=o.length>1?(0,Q.jsx)(H,{items:[{id:``,label:n.marketplaceCategoryAll},...o.map(e=>({id:e,label:f(e),title:f(e)}))],activeTab:s,onChange:c,ariaLabel:n.marketplaceCategoriesAria,tabIdPrefix:`skills-builtin-category-tab`,className:`gap-2 pt-0.5 [scrollbar-width:thin]`,buttonClassName:`max-w-[14rem] truncate rounded-full border px-3 py-1.5 text-xs`,selectedClassName:`border-fg bg-fg text-surface-panel dark:border-fg dark:bg-fg dark:text-surface-base`,unselectedClassName:`border-edge bg-surface-panel text-fg-muted hover:border-edge-strong hover:text-fg dark:border-edge dark:bg-surface-hover/40`}):null,t[7]=o,t[8]=s,t[9]=f,t[10]=c,t[11]=n,t[12]=S):S=t[12];let C;t[13]!==l||t[14]!==u||t[15]!==v||t[16]!==y||t[17]!==_||t[18]!==d||t[19]!==n||t[20]!==p||t[21]!==x||t[22]!==b?(C=l.length===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge py-16 text-center text-sm text-fg-muted`,children:u===`disabled`?n.noDisabledSkills:n.noSearchResults}):(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:l.map(e=>{let t=d(e);return(0,Q.jsxs)(`article`,{className:m(`group flex h-full flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors`,t?`hover:bg-surface-hover`:`bg-amber-50/30 hover:bg-amber-50/50 dark:bg-amber-950/20`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,className:m(`min-w-0 flex-1 cursor-pointer rounded-lg text-left outline-none`,g.focusRingPanel),"aria-labelledby":`catalog-skill-title-${e.directoryId}`,onClick:()=>void _(e),children:(0,Q.jsx)(`h3`,{id:`catalog-skill-title-${e.directoryId}`,className:`truncate text-[15px] font-semibold leading-8 tracking-tight text-fg`,children:e.name})}),t?(0,Q.jsx)(h,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:b===e.name||x===e.name,onClick:()=>void y({name:e.name,source:`catalog`}),children:b===e.name?n.previewUseInChatBusy:n.previewUseInChat}):(0,Q.jsx)(h,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:x===e.name,onClick:()=>void v(e.name,!0),children:x===e.name?n.uploading:n.detailModalEnable})]}),(0,Q.jsx)(`button`,{type:`button`,className:m(`mt-2 flex min-h-0 w-full flex-1 cursor-pointer flex-col rounded-lg text-left outline-none`,g.focusRingPanel),"aria-labelledby":`catalog-skill-title-${e.directoryId}`,onClick:()=>void _(e),children:(0,Q.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`line-clamp-2 text-sm leading-relaxed text-fg-muted`,title:e.description?e.description:void 0,children:e.description||`—`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover/60 px-2 py-0.5 dark:bg-surface-active/50`,children:p(e)}),(0,Q.jsxs)(`span`,{className:m(`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 font-medium`,t?`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`border-amber-500/30 bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:[t?(0,Q.jsx)(z,{className:`size-3`,"aria-hidden":!0}):(0,Q.jsx)(F,{className:`size-3`,"aria-hidden":!0}),t?n.statusEnabled:n.statusDisabled]}),e.managed?(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-hover/60 px-2 py-0.5 dark:bg-surface-active/50`,children:[n.col.managed,`: `,n.yes]}):null,e.hub?(0,Q.jsxs)(`span`,{className:`max-w-full break-all rounded-md bg-surface-hover/60 px-2 py-0.5 font-mono text-[10px] leading-snug dark:bg-surface-active/50 line-clamp-2`,title:`${e.hub.source}${e.hub.ref?`\nref: ${e.hub.ref}`:``}\nupdated: ${e.hub.updatedAt}`,children:[n.hubRemote,` ·`,` `,e.hub.kind===`git`?n.hubKindGit:n.hubKindArchive,` ·`,` `,e.hub.source.length>48?`${e.hub.source.slice(0,48)}…`:e.hub.source]}):null]})]})})})]},`${e.directoryId}-${e.path}`)})}),t[13]=l,t[14]=u,t[15]=v,t[16]=y,t[17]=_,t[18]=d,t[19]=n,t[20]=p,t[21]=x,t[22]=b,t[23]=C):C=t[23];let w;return t[24]!==S||t[25]!==C?(w=(0,Q.jsxs)(Q.Fragment,{children:[S,C]}),t[24]=S,t[25]=C,t[26]=w):w=t[26],w}function Se(e){return(0,Q.jsx)(me,{},e)}function Ce(e){let t=(0,X.c)(32),{sk:n,confirmOpen:r,setConfirmOpen:i,confirmId:a,setConfirmId:o,runDelete:s}=e,c;t[0]!==o||t[1]!==i?(c=e=>{i(e),e||o(null)},t[0]=o,t[1]=i,t[2]=c):c=t[2];let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[3]=l):l=t[3];let u;t[4]===n.deleteTitle?u=t[5]:(u=(0,Q.jsx)(w,{className:`text-base font-semibold text-fg`,children:n.deleteTitle}),t[4]=n.deleteTitle,t[5]=u);let d;t[6]!==a||t[7]!==n.deleteMessage?(d=a?Y(n.deleteMessage,{id:a}):``,t[6]=a,t[7]=n.deleteMessage,t[8]=d):d=t[8];let f;t[9]===d?f=t[10]:(f=(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:d}),t[9]=d,t[10]=f);let p;t[11]===i?p=t[12]:(p=()=>i(!1),t[11]=i,t[12]=p);let m;t[13]!==n.cancel||t[14]!==p?(m=(0,Q.jsx)(h,{type:`button`,variant:`secondary`,onClick:p,children:n.cancel}),t[13]=n.cancel,t[14]=p,t[15]=m):m=t[15];let g;t[16]===s?g=t[17]:(g=()=>void s(),t[16]=s,t[17]=g);let _;t[18]!==n.deleteConfirm||t[19]!==g?(_=(0,Q.jsx)(h,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:g,children:n.deleteConfirm}),t[18]=n.deleteConfirm,t[19]=g,t[20]=_):_=t[20];let v;t[21]!==m||t[22]!==_?(v=(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[m,_]}),t[21]=m,t[22]=_,t[23]=v):v=t[23];let y;t[24]!==v||t[25]!==u||t[26]!==f?(y=(0,Q.jsxs)(S,{children:[l,(0,Q.jsxs)(C,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[u,f,v]})]}),t[24]=v,t[25]=u,t[26]=f,t[27]=y):y=t[27];let x;return t[28]!==r||t[29]!==c||t[30]!==y?(x=(0,Q.jsx)(T,{open:r,onOpenChange:c,children:y}),t[28]=r,t[29]=c,t[30]=y,t[31]=x):x=t[31],x}function we(e){let t=(0,X.c)(7),{label:n,children:r}=e;if(r==null||r===!1)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Q.jsx)(`div`,{className:`mt-1.5 min-w-0 text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3 dark:border-edge/60`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Te(e){let t=(0,X.c)(118),{preview:n,sk:r}=e,i=n.metadata,a=n.toolConditions,o=!!a&&(a.requiresTools.length>0||a.requiresToolsets.length>0||a.fallbackForTools.length>0||a.fallbackForToolsets.length>0),s=i.requires,c=s&&((s.bins?.length??0)>0||(s.env?.length??0)>0||(s.anyBins?.length??0)>0),l,d,f,p,h,g,_,v,y,b,x,S,C,w,T;if(t[0]!==a||t[1]!==c||t[2]!==o||t[3]!==i.emoji||t[4]!==i.homepage||t[5]!==i.install||t[6]!==i.os||t[7]!==n.description||t[8]!==n.disableModelInvocation||t[9]!==n.requiredEnvVarNames||t[10]!==s||t[11]!==r.detailEnvVarsLabel||t[12]!==r.detailHomepageLabel||t[13]!==r.detailInstallLabel||t[14]!==r.detailNotInjectedNote||t[15]!==r.detailPlatformsLabel||t[16]!==r.detailRequiresAnyBins||t[17]!==r.detailRequiresBins||t[18]!==r.detailRequiresEnv||t[19]!==r.detailRequiresLabel||t[20]!==r.detailSummaryHeading||t[21]!==r.detailToolGatingLabel||t[22]!==r.detailToolsFallbackList||t[23]!==r.detailToolsRequiresList||t[24]!==r.detailToolsetsFallbackList||t[25]!==r.detailToolsetsRequiresList){let e=i.install?.filter(Oe)??[],u=n.requiredEnvVarNames?.filter(De)??[];_=`space-y-6`,h=`skill-detail-summary-heading`,t[41]===r.detailSummaryHeading?g=t[42]:(g=(0,Q.jsx)(`h3`,{id:`skill-detail-summary-heading`,className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:r.detailSummaryHeading}),t[41]=r.detailSummaryHeading,t[42]=g),y=`rounded-xl border border-edge bg-surface-base px-4 py-3 dark:bg-surface-hover/25`,t[43]===i.emoji?b=t[44]:(b=i.emoji?.trim()?(0,Q.jsx)(`p`,{className:`text-2xl leading-none`,"aria-hidden":!0,children:i.emoji.trim()}):null,t[43]=i.emoji,t[44]=b);let E;t[45]===i.emoji?E=t[46]:(E=i.emoji?.trim()?`mt-2`:``,t[45]=i.emoji,t[46]=E);let D;t[47]===E?D=t[48]:(D=m(`text-sm leading-relaxed text-fg`,E),t[47]=E,t[48]=D),t[49]!==n.description||t[50]!==D?(x=(0,Q.jsx)(`p`,{className:D,children:n.description}),t[49]=n.description,t[50]=D,t[51]=x):x=t[51],t[52]!==n.disableModelInvocation||t[53]!==r.detailNotInjectedNote?(S=n.disableModelInvocation?(0,Q.jsx)(`p`,{className:`mt-3 rounded-lg border border-amber-200/80 bg-amber-50/90 px-3 py-2 text-xs leading-snug text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/40 dark:text-amber-100`,children:r.detailNotInjectedNote}):null,t[52]=n.disableModelInvocation,t[53]=r.detailNotInjectedNote,t[54]=S):S=t[54];let O;t[55]===i.homepage?O=t[56]:(O=i.homepage?.trim()?(0,Q.jsx)(`a`,{href:i.homepage.trim(),target:`_blank`,rel:`noopener noreferrer`,className:`break-all text-accent underline-offset-2 hover:underline`,children:i.homepage.trim()}):null,t[55]=i.homepage,t[56]=O),t[57]!==r.detailHomepageLabel||t[58]!==O?(C=(0,Q.jsx)(we,{label:r.detailHomepageLabel,children:O}),t[57]=r.detailHomepageLabel,t[58]=O,t[59]=C):C=t[59];let k;t[60]===i.os?k=t[61]:(k=i.os&&i.os.length>0?(0,Q.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:i.os.join(`, `)}):null,t[60]=i.os,t[61]=k),t[62]!==r.detailPlatformsLabel||t[63]!==k?(w=(0,Q.jsx)(we,{label:r.detailPlatformsLabel,children:k}),t[62]=r.detailPlatformsLabel,t[63]=k,t[64]=w):w=t[64];let A;t[65]!==c||t[66]!==s||t[67]!==r.detailRequiresAnyBins||t[68]!==r.detailRequiresBins||t[69]!==r.detailRequiresEnv?(A=c&&s?(0,Q.jsxs)(`ul`,{className:`list-inside list-disc space-y-1 text-sm text-fg-muted`,children:[s.bins&&s.bins.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`text-fg`,children:[r.detailRequiresBins,`: `]}),s.bins.join(`, `)]}):null,s.env&&s.env.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`text-fg`,children:[r.detailRequiresEnv,`: `]}),(0,Q.jsx)(`span`,{className:`font-mono text-xs`,children:s.env.join(`, `)})]}):null,s.anyBins&&s.anyBins.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`text-fg`,children:[r.detailRequiresAnyBins,`: `]}),s.anyBins.join(`, `)]}):null]}):null,t[65]=c,t[66]=s,t[67]=r.detailRequiresAnyBins,t[68]=r.detailRequiresBins,t[69]=r.detailRequiresEnv,t[70]=A):A=t[70],t[71]!==r.detailRequiresLabel||t[72]!==A?(T=(0,Q.jsx)(we,{label:r.detailRequiresLabel,children:A}),t[71]=r.detailRequiresLabel,t[72]=A,t[73]=T):T=t[73];let j=e.length>0?(0,Q.jsx)(`ul`,{className:`list-inside list-decimal space-y-1.5 text-sm text-fg-muted`,children:e.map(Ee)}):null;t[74]!==r.detailInstallLabel||t[75]!==j?(f=(0,Q.jsx)(we,{label:r.detailInstallLabel,children:j}),t[74]=r.detailInstallLabel,t[75]=j,t[76]=f):f=t[76];let M;t[77]!==a||t[78]!==o||t[79]!==r.detailToolsFallbackList||t[80]!==r.detailToolsRequiresList||t[81]!==r.detailToolsetsFallbackList||t[82]!==r.detailToolsetsRequiresList?(M=o&&a?(0,Q.jsxs)(`ul`,{className:`mt-1 space-y-2 text-sm text-fg-muted`,children:[a.requiresTools.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsRequiresList,`: `]}),a.requiresTools.join(`, `)]}):null,a.requiresToolsets.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsetsRequiresList,`: `]}),a.requiresToolsets.join(`, `)]}):null,a.fallbackForTools.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsFallbackList,`: `]}),a.fallbackForTools.join(`, `)]}):null,a.fallbackForToolsets.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsetsFallbackList,`: `]}),a.fallbackForToolsets.join(`, `)]}):null]}):null,t[77]=a,t[78]=o,t[79]=r.detailToolsFallbackList,t[80]=r.detailToolsRequiresList,t[81]=r.detailToolsetsFallbackList,t[82]=r.detailToolsetsRequiresList,t[83]=M):M=t[83],t[84]!==r.detailToolGatingLabel||t[85]!==M?(p=(0,Q.jsx)(we,{label:r.detailToolGatingLabel,children:M}),t[84]=r.detailToolGatingLabel,t[85]=M,t[86]=p):p=t[86],l=we,d=r.detailEnvVarsLabel,v=u.length>0?(0,Q.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:u.join(`, `)}):null,t[0]=a,t[1]=c,t[2]=o,t[3]=i.emoji,t[4]=i.homepage,t[5]=i.install,t[6]=i.os,t[7]=n.description,t[8]=n.disableModelInvocation,t[9]=n.requiredEnvVarNames,t[10]=s,t[11]=r.detailEnvVarsLabel,t[12]=r.detailHomepageLabel,t[13]=r.detailInstallLabel,t[14]=r.detailNotInjectedNote,t[15]=r.detailPlatformsLabel,t[16]=r.detailRequiresAnyBins,t[17]=r.detailRequiresBins,t[18]=r.detailRequiresEnv,t[19]=r.detailRequiresLabel,t[20]=r.detailSummaryHeading,t[21]=r.detailToolGatingLabel,t[22]=r.detailToolsFallbackList,t[23]=r.detailToolsRequiresList,t[24]=r.detailToolsetsFallbackList,t[25]=r.detailToolsetsRequiresList,t[26]=l,t[27]=d,t[28]=f,t[29]=p,t[30]=h,t[31]=g,t[32]=_,t[33]=v,t[34]=y,t[35]=b,t[36]=x,t[37]=S,t[38]=C,t[39]=w,t[40]=T}else l=t[26],d=t[27],f=t[28],p=t[29],h=t[30],g=t[31],_=t[32],v=t[33],y=t[34],b=t[35],x=t[36],S=t[37],C=t[38],w=t[39],T=t[40];let E;t[87]!==l||t[88]!==d||t[89]!==v?(E=(0,Q.jsx)(l,{label:d,children:v}),t[87]=l,t[88]=d,t[89]=v,t[90]=E):E=t[90];let D;t[91]!==f||t[92]!==p||t[93]!==E||t[94]!==y||t[95]!==b||t[96]!==x||t[97]!==S||t[98]!==C||t[99]!==w||t[100]!==T?(D=(0,Q.jsxs)(`div`,{className:y,children:[b,x,S,C,w,T,f,p,E]}),t[91]=f,t[92]=p,t[93]=E,t[94]=y,t[95]=b,t[96]=x,t[97]=S,t[98]=C,t[99]=w,t[100]=T,t[101]=D):D=t[101];let O;t[102]!==h||t[103]!==g||t[104]!==D?(O=(0,Q.jsxs)(`section`,{"aria-labelledby":h,children:[g,D]}),t[102]=h,t[103]=g,t[104]=D,t[105]=O):O=t[105];let k;t[106]===r.detailInstructionsHeading?k=t[107]:(k=(0,Q.jsx)(`h3`,{id:`skill-detail-instructions-heading`,className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:r.detailInstructionsHeading}),t[106]=r.detailInstructionsHeading,t[107]=k);let A;t[108]!==n.bodyMarkdown||t[109]!==r.detailNoInstructionsBody?(A=n.bodyMarkdown.trim()?(0,Q.jsx)(`div`,{className:`markdown-content min-w-0 break-words`,children:(0,Q.jsx)(u,{content:n.bodyMarkdown})}):(0,Q.jsx)(`p`,{className:`text-sm italic text-fg-muted`,children:r.detailNoInstructionsBody}),t[108]=n.bodyMarkdown,t[109]=r.detailNoInstructionsBody,t[110]=A):A=t[110];let j;t[111]!==k||t[112]!==A?(j=(0,Q.jsxs)(`section`,{"aria-labelledby":`skill-detail-instructions-heading`,children:[k,A]}),t[111]=k,t[112]=A,t[113]=j):j=t[113];let M;return t[114]!==_||t[115]!==O||t[116]!==j?(M=(0,Q.jsxs)(`div`,{className:_,children:[O,j]}),t[114]=_,t[115]=O,t[116]=j,t[117]=M):M=t[117],M}function Ee(e,t){return(0,Q.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:(0,Q.jsx)(`span`,{className:`text-fg`,children:ae(e)})},e.id||`${e.kind}-${t}`)}function De(e){return e.trim()}function Oe(e){return e&&typeof e.kind==`string`}var ke=[{id:`s0`,width:`w-[92%]`},{id:`s1`,width:`w-full`},{id:`s2`,width:`w-4/5`},{id:`s3`,width:`w-[92%]`},{id:`s4`,width:`w-full`},{id:`s5`,width:`w-4/5`},{id:`s6`,width:`w-[92%]`},{id:`s7`,width:`w-full`},{id:`s8`,width:`w-4/5`},{id:`s9`,width:`w-[92%]`}];function Ae(e){let t=(0,X.c)(81),{sk:n,detailOpen:r,setDetailOpen:i,detailSource:a,setDetailSource:o,detailTitle:s,setDetailTitle:c,detailCatalogPreview:u,setDetailCatalogPreview:d,detailMarketplacePreview:f,setDetailMarketplacePreview:_,detailLoading:v,detailError:y,setDetailError:E,detailEnabled:D,detailDirectoryId:O,detailManaged:k,detailExternalUrl:A,usingSkillInChatName:j,installingMarketName:M,togglingSkillName:N,isSkillInstalledByName:F,onUseSkillInChat:L,onMarketInstall:R,onSkillToggle:z,setConfirmId:V,setConfirmOpen:H}=e,U;t[0]!==d||t[1]!==E||t[2]!==_||t[3]!==i||t[4]!==o||t[5]!==c?(U=e=>{i(e),e||(o(`catalog`),d(null),_(null),E(null),c(``))},t[0]=d,t[1]=E,t[2]=_,t[3]=i,t[4]=o,t[5]=c,t[6]=U):U=t[6];let W;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Q.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=W):W=t[7];let G;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(G=m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(88vh,44rem)] max-h-[min(92vh,56rem)] w-[min(100%-2rem,min(92vw,56rem))]`,`-translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[8]=G):G=t[8];let ee=s||`?`,K;t[9]===ee?K=t[10]:(K=(0,Q.jsx)(ce,{name:ee}),t[9]=ee,t[10]=K);let q=s||`—`,J;t[11]===q?J=t[12]:(J=(0,Q.jsx)(w,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:q}),t[11]=q,t[12]=J);let te;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(te=m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,g.focusRingPanel),t[13]=te):te=t[13];let ne;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Q.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=ne):ne=t[14];let re;t[15]===n.detailCloseAria?re=t[16]:(re=(0,Q.jsx)(x,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:te,"aria-label":n.detailCloseAria,children:ne})}),t[15]=n.detailCloseAria,t[16]=re);let ie;t[17]!==K||t[18]!==J||t[19]!==re?(ie=(0,Q.jsxs)(`div`,{className:`group flex min-h-[3.25rem] shrink-0 items-center gap-3 border-b border-edge px-4 py-3`,children:[K,J,re]}),t[17]=K,t[18]=J,t[19]=re,t[20]=ie):ie=t[20];let ae;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Q.jsx)(B,{className:`mt-0.5 size-4 shrink-0 text-blue-600 dark:text-blue-400`,strokeWidth:1.75,"aria-hidden":!0}),t[21]=ae):ae=t[21];let oe=a===`store`&&f?n.detailModalBanner:a===`store`?n.detailModalBannerStore:n.detailModalBanner,se;t[22]===oe?se=t[23]:(se=(0,Q.jsxs)(`div`,{className:`flex min-h-[3.25rem] shrink-0 items-start gap-2 border-b border-blue-200/80 bg-blue-50/95 px-4 py-2.5 text-sm text-fg dark:border-blue-900/50 dark:bg-blue-950/45`,children:[ae,(0,Q.jsx)(`p`,{className:`min-w-0 leading-relaxed`,children:oe})]}),t[22]=oe,t[23]=se);let Y;t[24]!==u||t[25]!==D||t[26]!==y||t[27]!==v||t[28]!==f||t[29]!==a||t[30]!==n?(Y=(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto p-4`,children:v?(0,Q.jsx)(`div`,{className:`flex h-full min-h-[14rem] flex-col gap-2.5 py-1`,"aria-busy":`true`,"aria-label":n.loading,children:ke.map(je)}):y?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):a===`catalog`&&u?(0,Q.jsxs)(Q.Fragment,{children:[D?null:(0,Q.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2.5 text-sm text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,Q.jsx)(I,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-300`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`leading-relaxed`,children:n.detailDisabledNotice})]}),(0,Q.jsx)(Te,{preview:u,sk:n})]}):a===`store`&&f?(0,Q.jsx)(Te,{preview:f,sk:n}):(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n.detailLoadFailed})}),t[24]=u,t[25]=D,t[26]=y,t[27]=v,t[28]=f,t[29]=a,t[30]=n,t[31]=Y):Y=t[31];let le;t[32]!==A||t[33]!==a||t[34]!==n.marketplaceOpenExternal||t[35]!==n.marketplaceOpenExternalAria?(le=a===`store`&&A?(0,Q.jsxs)(`a`,{href:A,target:`_blank`,rel:`noopener noreferrer`,className:m(`inline-flex h-9 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 text-sm font-medium text-fg-muted`,`hover:bg-surface-hover hover:text-fg dark:border-edge`,g.focusRingPanel),"aria-label":n.marketplaceOpenExternalAria,title:n.marketplaceOpenExternal,children:[(0,Q.jsx)(l,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:n.marketplaceOpenExternal})]}):null,t[32]=A,t[33]=a,t[34]=n.marketplaceOpenExternal,t[35]=n.marketplaceOpenExternalAria,t[36]=le):le=t[36];let ue;t[37]!==O||t[38]!==k||t[39]!==a||t[40]!==V||t[41]!==H||t[42]!==n.delete?(ue=a===`catalog`&&k&&O?(0,Q.jsxs)(h,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-950/40 dark:hover:text-red-300`,onClick:()=>{V(O),H(!0)},children:[(0,Q.jsx)(P,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),n.delete]}):null,t[37]=O,t[38]=k,t[39]=a,t[40]=V,t[41]=H,t[42]=n.delete,t[43]=ue):ue=t[43];let Z;t[44]!==le||t[45]!==ue?(Z=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[le,ue]}),t[44]=le,t[45]=ue,t[46]=Z):Z=t[46];let de;t[47]!==D||t[48]!==v||t[49]!==a||t[50]!==s||t[51]!==M||t[52]!==F||t[53]!==R||t[54]!==z||t[55]!==L||t[56]!==i||t[57]!==n.cancel||t[58]!==n.detailModalDisable||t[59]!==n.detailModalEnable||t[60]!==n.marketplaceInstall||t[61]!==n.marketplaceReinstall||t[62]!==n.previewUseInChat||t[63]!==n.previewUseInChatBusy||t[64]!==n.uploading||t[65]!==n.useRequiresEnabled||t[66]!==N||t[67]!==j?(de=(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:a===`store`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{type:`button`,variant:`ghost`,onClick:()=>i(!1),children:n.cancel}),(0,Q.jsx)(h,{type:`button`,variant:`secondary`,disabled:!s||v||j===s||M===s,onClick:()=>void L(),children:j===s?n.previewUseInChatBusy:n.previewUseInChat}),(0,Q.jsx)(h,{type:`button`,variant:F(s)?`secondary`:`primary`,disabled:!s||M===s,onClick:()=>{s&&R(s,{useDetailProvider:!0})},children:M===s?n.uploading:F(s)?n.marketplaceReinstall:n.marketplaceInstall})]}):(0,Q.jsxs)(Q.Fragment,{children:[D?(0,Q.jsx)(h,{type:`button`,variant:`secondary`,disabled:!s||N===s,onClick:()=>{s&&z(s,!1)},children:N===s?n.uploading:n.detailModalDisable}):(0,Q.jsx)(h,{type:`button`,variant:`primary`,disabled:!s||N===s,onClick:()=>{s&&z(s,!0)},children:N===s?n.uploading:n.detailModalEnable}),(0,Q.jsx)(h,{type:`button`,variant:`secondary`,disabled:!s||!D||v||j===s||N===s,title:D?void 0:n.useRequiresEnabled,onClick:()=>void L(),children:j===s?n.previewUseInChatBusy:n.previewUseInChat})]})}),t[47]=D,t[48]=v,t[49]=a,t[50]=s,t[51]=M,t[52]=F,t[53]=R,t[54]=z,t[55]=L,t[56]=i,t[57]=n.cancel,t[58]=n.detailModalDisable,t[59]=n.detailModalEnable,t[60]=n.marketplaceInstall,t[61]=n.marketplaceReinstall,t[62]=n.previewUseInChat,t[63]=n.previewUseInChatBusy,t[64]=n.uploading,t[65]=n.useRequiresEnabled,t[66]=N,t[67]=j,t[68]=de):de=t[68];let fe;t[69]!==Z||t[70]!==de?(fe=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge px-4 py-3`,children:[Z,de]}),t[69]=Z,t[70]=de,t[71]=fe):fe=t[71];let pe;t[72]!==ie||t[73]!==se||t[74]!==Y||t[75]!==fe?(pe=(0,Q.jsxs)(S,{children:[W,(0,Q.jsxs)(C,{className:G,children:[ie,se,Y,fe]})]}),t[72]=ie,t[73]=se,t[74]=Y,t[75]=fe,t[76]=pe):pe=t[76];let me;return t[77]!==r||t[78]!==U||t[79]!==pe?(me=(0,Q.jsx)(T,{open:r,onOpenChange:U,children:pe}),t[77]=r,t[78]=U,t[79]=pe,t[80]=me):me=t[80],me}function je(e){return(0,Q.jsx)(`div`,{className:m(`h-4 animate-pulse rounded-md bg-surface-hover dark:bg-surface-active/50`,e.width)},e.id)}function Me(e){let t=(0,X.c)(67),{sk:n,installOpen:r,setInstallOpen:i,pendingFile:a,setPendingFile:o,dropActive:s,setDropActive:c,uploading:l,onModalDragOver:u,onModalDragLeave:d,onModalDrop:f,onFileInputChange:h,onInstallSubmit:_}=e,v;t[0]!==c||t[1]!==i||t[2]!==o?(v=e=>{i(e),e||(o(null),c(!1))},t[0]=c,t[1]=i,t[2]=o,t[3]=v):v=t[3];let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[4]=y):y=t[4];let E;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto`,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-float dark:border-edge`),t[5]=E):E=t[5];let D;t[6]===n.installModalTitle?D=t[7]:(D=(0,Q.jsx)(w,{className:`text-base font-semibold text-fg`,children:n.installModalTitle}),t[6]=n.installModalTitle,t[7]=D);let O;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,g.focusRingPanel),t[8]=O):O=t[8];let k;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=k):k=t[9];let j;t[10]===n.installClose?j=t[11]:(j=(0,Q.jsx)(`span`,{className:`sr-only`,children:n.installClose}),t[10]=n.installClose,t[11]=j);let M;t[12]!==n.installClose||t[13]!==j?(M=(0,Q.jsx)(x,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:O,"aria-label":n.installClose,children:[k,j]})}),t[12]=n.installClose,t[13]=j,t[14]=M):M=t[14];let N;t[15]!==D||t[16]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[D,M]}),t[15]=D,t[16]=M,t[17]=N):N=t[17];let P=s?`border-accent bg-accent-soft/60 dark:bg-blue-950/40`:`border-edge bg-surface-base dark:bg-surface-hover/30`,F;t[18]===P?F=t[19]:(F=m(`mt-4 flex min-h-[11rem] cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed px-6 py-12 text-center transition-colors`,P),t[18]=P,t[19]=F);let I;t[20]!==h||t[21]!==n.installModalDropHint||t[22]!==l?(I=(0,Q.jsx)(`input`,{type:`file`,accept:`.zip,.md,application/zip,text/markdown`,className:`sr-only`,"aria-label":n.installModalDropHint,disabled:l,onChange:h}),t[20]=h,t[21]=n.installModalDropHint,t[22]=l,t[23]=I):I=t[23];let L;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(A,{className:`size-12 text-fg-subtle`,strokeWidth:1.25,"aria-hidden":!0}),t[24]=L):L=t[24];let R;t[25]===n.installModalDropHint?R=t[26]:(R=(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.installModalDropHint}),t[25]=n.installModalDropHint,t[26]=R);let z;t[27]===a?z=t[28]:(z=a?(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:a.name}):null,t[27]=a,t[28]=z);let B;t[29]!==d||t[30]!==u||t[31]!==f||t[32]!==F||t[33]!==I||t[34]!==R||t[35]!==z?(B=(0,Q.jsxs)(`label`,{className:F,onDragLeave:d,onDragOver:u,onDrop:f,children:[I,L,R,z]}),t[29]=d,t[30]=u,t[31]=f,t[32]=F,t[33]=I,t[34]=R,t[35]=z,t[36]=B):B=t[36];let V;t[37]===n.installModalReqTitle?V=t[38]:(V=(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.installModalReqTitle}),t[37]=n.installModalReqTitle,t[38]=V);let H;t[39]===n.installModalReq1?H=t[40]:(H=(0,Q.jsx)(`li`,{children:n.installModalReq1}),t[39]=n.installModalReq1,t[40]=H);let U;t[41]===n.installModalReq2?U=t[42]:(U=(0,Q.jsx)(`li`,{children:n.installModalReq2}),t[41]=n.installModalReq2,t[42]=U);let W;t[43]!==H||t[44]!==U?(W=(0,Q.jsxs)(`ul`,{className:`list-inside list-disc space-y-1 text-sm text-fg-muted`,children:[H,U]}),t[43]=H,t[44]=U,t[45]=W):W=t[45];let G;t[46]!==V||t[47]!==W?(G=(0,Q.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[V,W]}),t[46]=V,t[47]=W,t[48]=G):G=t[48];let ee=!a||l,K=!a||l?`cursor-not-allowed bg-surface-active text-fg-disabled`:`bg-accent text-white hover:bg-accent-hover`,q;t[49]===K?q=t[50]:(q=m(`mt-6 flex w-full items-center justify-center rounded-xl py-3 text-sm font-semibold`,`transition-colors`,K,g.focusRingPanel),t[49]=K,t[50]=q);let J;t[51]===_?J=t[52]:(J=()=>void _(),t[51]=_,t[52]=J);let te=l?n.uploading:n.installAction,ne;t[53]!==ee||t[54]!==q||t[55]!==J||t[56]!==te?(ne=(0,Q.jsx)(`button`,{type:`button`,disabled:ee,className:q,onClick:J,children:te}),t[53]=ee,t[54]=q,t[55]=J,t[56]=te,t[57]=ne):ne=t[57];let re;t[58]!==B||t[59]!==G||t[60]!==ne||t[61]!==N?(re=(0,Q.jsxs)(S,{children:[y,(0,Q.jsxs)(C,{className:E,children:[N,B,G,ne]})]}),t[58]=B,t[59]=G,t[60]=ne,t[61]=N,t[62]=re):re=t[62];let ie;return t[63]!==r||t[64]!==v||t[65]!==re?(ie=(0,Q.jsx)(T,{open:r,onOpenChange:v,children:re}),t[63]=r,t[64]=v,t[65]=re,t[66]=ie):ie=t[66],ie}function Ne(e){let t=(0,X.c)(68),{sk:n,mpCategories:r,mpCategoriesLoading:i,mpCategoriesError:a,mpPayload:o,mpLoading:s,mpError:c,marketCategoryId:l,setMarketCategoryId:u,marketPage:f,setMarketPage:p,isSkillInstalledByName:_,openMarketplaceDetail:v,onMarketInstall:y,installingMarketName:b,onUseSkillInChat:x,usingSkillInChatName:S,searchInputActive:C,searchQuery:w,setSearchQuery:T,registeredProviders:E,marketBrowseProvider:D,setMarketBrowseProvider:O}=e,k=!C,A,j,N;if(t[0]!==b||t[1]!==_||t[2]!==D||t[3]!==l||t[4]!==f||t[5]!==r||t[6]!==a||t[7]!==i||t[8]!==c||t[9]!==s||t[10]!==o||t[11]!==y||t[12]!==x||t[13]!==v||t[14]!==E||t[15]!==C||t[16]!==w||t[17]!==O||t[18]!==u||t[19]!==p||t[20]!==T||t[21]!==k||t[22]!==n.loading||t[23]!==n.marketplaceAuthor||t[24]!==n.marketplaceCategoriesAria||t[25]!==n.marketplaceCategoryAll||t[26]!==n.marketplaceDownloads||t[27]!==n.marketplaceEmpty||t[28]!==n.marketplaceEmptySearch||t[29]!==n.marketplaceEmptySearchClear||t[30]!==n.marketplaceEmptySearchTryProvider||t[31]!==n.marketplaceInstall||t[32]!==n.marketplaceInstalled||t[33]!==n.marketplacePageNext||t[34]!==n.marketplacePagePrev||t[35]!==n.marketplacePageStatus||t[36]!==n.marketplaceVersion||t[37]!==n.previewUseInChat||t[38]!==n.previewUseInChatBusy||t[39]!==n.uploading||t[40]!==S){let e;t[44]===D?e=t[45]:(e=e=>e.id!==D,t[44]=D,t[45]=e);let P=E.filter(e),F=w.trim(),I;t[46]===n.marketplaceCategoryAll?I=t[47]:(I={id:``,label:n.marketplaceCategoryAll},t[46]=n.marketplaceCategoryAll,t[47]=I);let L;t[48]!==r||t[49]!==I?(L=[I,...r.map(Re)],t[48]=r,t[49]=I,t[50]=L):L=t[50];let B=L,U;t[51]===r?U=t[52]:(U=new Map(r.map(Le)),t[51]=r,t[52]=U);let W=U;t[53]!==B||t[54]!==l||t[55]!==r.length||t[56]!==i||t[57]!==u||t[58]!==k||t[59]!==n.marketplaceCategoriesAria?(A=k?r.length>0?(0,Q.jsx)(H,{items:B,activeTab:l,onChange:u,ariaLabel:n.marketplaceCategoriesAria,tabIdPrefix:`skills-marketplace-category-tab`,className:`min-h-[2.75rem] items-center gap-2 pt-0.5 [scrollbar-width:thin]`,buttonClassName:`max-w-[14rem] truncate rounded-full border px-3 py-1.5 text-xs`,selectedClassName:`border-fg bg-fg text-surface-panel dark:border-fg dark:bg-fg dark:text-surface-base`,unselectedClassName:`border-edge bg-surface-panel text-fg-muted hover:border-edge-strong hover:text-fg dark:border-edge dark:bg-surface-hover/40`}):i?(0,Q.jsx)(`div`,{className:`-mx-1 flex min-h-[2.75rem] items-center gap-2 overflow-x-auto px-1 pb-1 pt-0.5 [scrollbar-width:thin]`,"aria-hidden":!0,children:[`p0`,`p1`,`p2`,`p3`,`p4`].map(Ie)}):null:null,t[53]=B,t[54]=l,t[55]=r.length,t[56]=i,t[57]=u,t[58]=k,t[59]=n.marketplaceCategoriesAria,t[60]=A):A=t[60],t[61]!==a||t[62]!==k?(j=k&&a?(0,Q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,role:`alert`,children:a}):null,t[61]=a,t[62]=k,t[63]=j):j=t[63],N=!o&&!c?(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,"aria-busy":`true`,"aria-label":n.loading,children:ye.map(Fe)}):c&&!o?(0,Q.jsx)(`div`,{className:`rounded-xl border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:c}):o?(0,Q.jsxs)(`div`,{className:`relative`,children:[s?(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":n.loading,children:(0,Q.jsx)(d,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,o.items.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-2xl border border-dashed border-edge py-12 text-center text-sm text-fg-muted`,children:[(0,Q.jsx)(`p`,{className:`px-4`,children:C&&F?Y(n.marketplaceEmptySearch,{query:F}):n.marketplaceEmpty}),C?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[P.map(e=>(0,Q.jsx)(h,{type:`button`,variant:`secondary`,className:`h-8 px-3 text-xs`,onClick:()=>O(e.id),children:Y(n.marketplaceEmptySearchTryProvider,{provider:e.displayName})},e.id)),(0,Q.jsx)(h,{type:`button`,variant:`ghost`,className:`h-8 px-3 text-xs`,onClick:()=>T(``),children:n.marketplaceEmptySearchClear})]}):null]}):(0,Q.jsx)(`div`,{className:m(`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,s&&`pointer-events-none opacity-[0.52] motion-reduce:opacity-100`),children:o.items.map(e=>{let t=ne(e,e.providerId??D),r=_(t),i=e.category??e.categories?.[0],a=i?W.get(i)??i:null;return(0,Q.jsxs)(`article`,{className:m(`group flex h-full flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,`transition-colors hover:bg-surface-hover`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,className:m(`min-w-0 flex-1 rounded-lg text-left outline-none`,g.focusRingPanel),onClick:()=>void v(t,e.name,e.providerId??void 0),children:(0,Q.jsx)(`h3`,{id:`mp-skill-title-${e.id}`,className:`truncate text-[15px] font-semibold leading-snug tracking-tight text-fg`,children:e.name})}),r?(0,Q.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Q.jsx)(z,{className:`size-3`,"aria-hidden":!0}),n.marketplaceInstalled]}):(0,Q.jsx)(h,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:s||b===t,onClick:()=>void y(t,{providerOverride:e.providerId??null}),children:b===t?n.uploading:n.marketplaceInstall})]}),(0,Q.jsx)(`button`,{type:`button`,className:m(`mt-2 flex min-h-0 w-full flex-1 cursor-pointer flex-col rounded-lg text-left outline-none`,g.focusRingPanel),"aria-labelledby":`mp-skill-title-${e.id}`,onClick:()=>void v(t,e.name,e.providerId??void 0),children:(0,Q.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`line-clamp-2 text-sm leading-relaxed text-fg-muted`,title:e.description?e.description:void 0,children:e.description||`—`}),a?(0,Q.jsx)(`span`,{className:`w-fit max-w-full truncate rounded-full bg-surface-subtle px-2 py-0.5 text-[10px] font-medium text-fg-muted`,children:a}):null,(0,Q.jsxs)(`div`,{className:`mt-auto min-h-[2.625rem] space-y-1 text-[11px] leading-snug text-fg-muted`,children:[(0,Q.jsxs)(`p`,{className:`line-clamp-1`,title:`${n.marketplaceAuthor}: ${e.author.username} · ${n.marketplaceDownloads}: ${e.downloads}${e.stars!=null&&e.stars>0?` · ★${e.stars}`:``}${r?` · ${n.marketplaceInstalled}`:``}`,children:[(0,Q.jsx)(`span`,{className:`text-fg-subtle`,children:n.marketplaceAuthor}),` `,(0,Q.jsx)(`span`,{className:`text-fg`,children:e.author.username}),(0,Q.jsx)(`span`,{className:`text-fg-subtle`,children:` · `}),(0,Q.jsxs)(`span`,{children:[n.marketplaceDownloads,`: `,e.downloads]}),e.stars!=null&&e.stars>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-fg-subtle`,children:` · `}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-fg-muted`,children:[(0,Q.jsx)(R,{className:`size-3 shrink-0 text-amber-600 dark:text-amber-400`,strokeWidth:2,"aria-hidden":!0}),e.stars]})]}):null]}),e.latestVersion?(0,Q.jsxs)(`p`,{className:`line-clamp-1 min-h-[1.125rem] font-mono text-[10px] text-fg-subtle`,title:`${n.marketplaceVersion}: ${e.latestVersion}`,children:[n.marketplaceVersion,`: `,e.latestVersion]}):null]})]})})}),r?(0,Q.jsx)(`div`,{role:`group`,className:`mt-3 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3`,children:(0,Q.jsx)(h,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:s||S===t,onClick:()=>void x({name:t,source:`store`,providerOverride:e.providerId??null}),children:S===t?n.previewUseInChatBusy:n.previewUseInChat})}):null]},e.id)})}),o.items.length>0?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col items-center justify-between gap-3 sm:flex-row`,children:[(0,Q.jsx)(`p`,{className:`text-center text-xs text-fg-muted sm:text-left`,children:Y(n.marketplacePageStatus,{page:o.meta.page,totalPages:o.meta.totalPages,total:o.meta.total})}),o.meta.totalPages>1?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-9 gap-1 px-2`,disabled:s||f<=1,"aria-label":n.marketplacePagePrev,onClick:()=>p(Pe),children:[(0,Q.jsx)(M,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:n.marketplacePagePrev})]}),(0,Q.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-9 gap-1 px-2`,disabled:s||f>=o.meta.totalPages,"aria-label":n.marketplacePageNext,onClick:()=>p(e=>Math.min(o.meta.totalPages,e+1)),children:[(0,Q.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:n.marketplacePageNext}),(0,Q.jsx)(V,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})]})]}):null]}):null]}):null,t[0]=b,t[1]=_,t[2]=D,t[3]=l,t[4]=f,t[5]=r,t[6]=a,t[7]=i,t[8]=c,t[9]=s,t[10]=o,t[11]=y,t[12]=x,t[13]=v,t[14]=E,t[15]=C,t[16]=w,t[17]=O,t[18]=u,t[19]=p,t[20]=T,t[21]=k,t[22]=n.loading,t[23]=n.marketplaceAuthor,t[24]=n.marketplaceCategoriesAria,t[25]=n.marketplaceCategoryAll,t[26]=n.marketplaceDownloads,t[27]=n.marketplaceEmpty,t[28]=n.marketplaceEmptySearch,t[29]=n.marketplaceEmptySearchClear,t[30]=n.marketplaceEmptySearchTryProvider,t[31]=n.marketplaceInstall,t[32]=n.marketplaceInstalled,t[33]=n.marketplacePageNext,t[34]=n.marketplacePagePrev,t[35]=n.marketplacePageStatus,t[36]=n.marketplaceVersion,t[37]=n.previewUseInChat,t[38]=n.previewUseInChatBusy,t[39]=n.uploading,t[40]=S,t[41]=A,t[42]=j,t[43]=N}else A=t[41],j=t[42],N=t[43];let P;return t[64]!==A||t[65]!==j||t[66]!==N?(P=(0,Q.jsxs)(Q.Fragment,{children:[A,j,N]}),t[64]=A,t[65]=j,t[66]=N,t[67]=P):P=t[67],P}function Pe(e){return Math.max(1,e-1)}function Fe(e){return(0,Q.jsx)(pe,{},e)}function Ie(e){return(0,Q.jsx)(`div`,{className:`h-8 w-[4.5rem] shrink-0 animate-pulse rounded-full bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`},e)}function Le(e){return[e.id,e.label]}function Re(e){return{id:e.id,label:e.label,title:e.label}}function ze(e){let t=(0,X.c)(130),{vm:n}=e,{sk:r,hasToken:i,error:a,actionFeedback:o,skillDiagnostics:s,mainTab:l,setMainTab:u,sourceFilter:d,setSourceFilter:f,builtinTabStats:p,userTabStats:h,catalogDisabledCount:g,catalogStatusFilter:_,setCatalogStatusFilter:v,marketSort:y,setMarketSort:b,marketBrowseProvider:x,setMarketBrowseProvider:S,registeredProviders:C,inSettingsShell:w,searchInputActive:T,resultTab:E,setResultTab:D,aggregatedTabCounts:O,aggregatedProviderStatus:k}=n,A,j,M,N,P,F,I,L;if(t[0]!==o||t[1]!==k||t[2]!==O||t[3]!==p||t[4]!==a||t[5]!==i||t[6]!==C||t[7]!==r.diagnosticsHint||t[8]!==r.diagnosticsTitle||t[9]!==r.marketplaceLoadFailed||t[10]!==r.marketplaceResultsTabAll||t[11]!==r.needToken||t[12]!==r.tabDiscover||t[13]!==r.tabInstalled||t[14]!==s||t[15]!==h||t[16]!==n){L=Symbol.for(`react.early_return_sentinel`);bb0:{let e=le(s);if(!i){let e;t[25]===n?e=t[26]:(e=(0,Q.jsx)(Ue,{vm:n}),t[25]=n,t[26]=e);let i;t[27]===r.needToken?i=t[28]:(i=(0,Q.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:r.needToken}),t[27]=r.needToken,t[28]=i);let a;t[29]!==e||t[30]!==i?(a=(0,Q.jsxs)(Q.Fragment,{children:[e,i]}),t[29]=e,t[30]=i,t[31]=a):a=t[31],L=a;break bb0}let c=p.total+h.total,l;t[32]!==c||t[33]!==r.tabInstalled?(l={id:`installed`,label:r.tabInstalled,count:c},t[32]=c,t[33]=r.tabInstalled,t[34]=l):l=t[34];let u;t[35]===r.tabDiscover?u=t[36]:(u={id:`marketplace`,label:r.tabDiscover},t[35]=r.tabDiscover,t[36]=u);let d;t[37]!==l||t[38]!==u?(d=[l,u],t[37]=l,t[38]=u,t[39]=d):d=t[39],A=d;let f;t[40]===C?f=t[41]:(f=[`all`,...C.map(He)],t[40]=C,t[41]=f);let g=f,_;t[42]!==k||t[43]!==O||t[44]!==C||t[45]!==r.marketplaceLoadFailed||t[46]!==r.marketplaceResultsTabAll||t[47]!==g?(_=g.map(e=>{let t=e===`all`?r.marketplaceResultsTabAll:C.find(t=>t.id===e)?.displayName??e,n=O[e]??0,i=e===`all`?null:k[e];return{id:e,label:t,title:i===`error`?`${t} · ${r.marketplaceLoadFailed}`:void 0,suffix:i===`loading`?(0,Q.jsx)(`span`,{className:`inline-block size-1.5 animate-pulse rounded-full bg-fg-muted/60 motion-reduce:animate-none`,"aria-hidden":!0}):i===`error`?(0,Q.jsx)(`span`,{className:`inline-block size-1.5 rounded-full bg-red-500`,"aria-hidden":!0}):(0,Q.jsx)(`span`,{className:`tabular-nums opacity-70`,children:n})}}),t[42]=k,t[43]=O,t[44]=C,t[45]=r.marketplaceLoadFailed,t[46]=r.marketplaceResultsTabAll,t[47]=g,t[48]=_):_=t[48],j=_,t[49]===n?I=t[50]:(I=(0,Q.jsx)(Ue,{vm:n}),t[49]=n,t[50]=I),F=`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,M=`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,t[51]!==o||t[52]!==a?(N=o?(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:m(`rounded-xl border px-3 py-2 text-sm`,o.kind===`success`?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-red-200 bg-red-50 text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`),children:o.message}):a?(0,Q.jsx)(`div`,{className:`rounded-xl border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:a}):null,t[51]=o,t[52]=a,t[53]=N):N=t[53],P=e.length>0?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-200`,role:`status`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:Y(r.diagnosticsTitle,{count:e.length})}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs opacity-80`,children:r.diagnosticsHint}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.slice(0,3).map(Ve)})]}):null}t[0]=o,t[1]=k,t[2]=O,t[3]=p,t[4]=a,t[5]=i,t[6]=C,t[7]=r.diagnosticsHint,t[8]=r.diagnosticsTitle,t[9]=r.marketplaceLoadFailed,t[10]=r.marketplaceResultsTabAll,t[11]=r.needToken,t[12]=r.tabDiscover,t[13]=r.tabInstalled,t[14]=s,t[15]=h,t[16]=n,t[17]=A,t[18]=j,t[19]=M,t[20]=N,t[21]=P,t[22]=F,t[23]=I,t[24]=L}else A=t[17],j=t[18],M=t[19],N=t[20],P=t[21],F=t[22],I=t[23],L=t[24];if(L!==Symbol.for(`react.early_return_sentinel`))return L;let R;t[54]!==w||t[55]!==n.loading||t[56]!==n.mainTab||t[57]!==n.onReloadClick||t[58]!==n.searchQuery||t[59]!==n.setInstallOpen||t[60]!==n.setPendingFile||t[61]!==n.setSearchQuery||t[62]!==n.sk?(R=w?(0,Q.jsx)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-4 dark:border-edge-subtle sm:flex-row sm:flex-wrap sm:items-center sm:justify-end`,children:(0,Q.jsx)(de,{loading:n.loading,onReloadClick:n.onReloadClick,searchQuery:n.searchQuery,setSearchQuery:n.setSearchQuery,mainTab:n.mainTab,sk:n.sk,setPendingFile:n.setPendingFile,setInstallOpen:n.setInstallOpen})}):null,t[54]=w,t[55]=n.loading,t[56]=n.mainTab,t[57]=n.onReloadClick,t[58]=n.searchQuery,t[59]=n.setInstallOpen,t[60]=n.setPendingFile,t[61]=n.setSearchQuery,t[62]=n.sk,t[63]=R):R=t[63];let z;t[64]!==l||t[65]!==A||t[66]!==u||t[67]!==r.skillsNavAria?(z=(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,Q.jsx)(H,{items:A,activeTab:l,onChange:u,ariaLabel:r.skillsNavAria,tabIdPrefix:`skills-tab`,panelIdPrefix:`skills-panel`,className:`flex-wrap`})}),t[64]=l,t[65]=A,t[66]=u,t[67]=r.skillsNavAria,t[68]=z):z=t[68];let B;t[69]!==g||t[70]!==_||t[71]!==l||t[72]!==x||t[73]!==y||t[74]!==C||t[75]!==E||t[76]!==j||t[77]!==T||t[78]!==v||t[79]!==S||t[80]!==b||t[81]!==D||t[82]!==f||t[83]!==r.discoverHeading||t[84]!==r.discoverHint||t[85]!==r.filterAll||t[86]!==r.filterDisabledOnly||t[87]!==r.filterEnabled||t[88]!==r.filterExtra||t[89]!==r.filterGlobal||t[90]!==r.filterInstalled||t[91]!==r.filterWorkspace||t[92]!==r.installedHeading||t[93]!==r.installedHint||t[94]!==r.marketplaceBrowseSwitchAria||t[95]!==r.marketplaceResultsTabsAria||t[96]!==r.marketplaceSortDownloads||t[97]!==r.marketplaceSortLabel||t[98]!==r.marketplaceSortNewest||t[99]!==r.sourceFilterAria||t[100]!==r.statusFilterAria||t[101]!==r.tabBuiltin||t[102]!==d?(B=l===`installed`?(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-balance text-sm font-semibold text-fg`,children:r.installedHeading}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:r.installedHint})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2 sm:justify-end`,children:[(0,Q.jsx)(c,{value:d,placeholder:r.filterAll,ariaLabel:r.sourceFilterAria,options:[{value:`all`,label:r.filterAll},{value:`builtin`,label:r.tabBuiltin},{value:`installed`,label:r.filterInstalled},{value:`workspace`,label:r.filterWorkspace},{value:`global`,label:r.filterGlobal},{value:`extra`,label:r.filterExtra}],allowEmpty:!1,triggerClassName:`h-9 w-auto min-w-[9rem] bg-surface-panel text-xs shadow-surface`,align:`end`,onChange:e=>f(e)}),(0,Q.jsx)(c,{value:_,placeholder:r.filterAll,ariaLabel:r.statusFilterAria,options:[{value:`all`,label:r.filterAll},{value:`enabled`,label:r.filterEnabled},{value:`disabled`,label:Y(r.filterDisabledOnly,{count:g})}],allowEmpty:!1,triggerClassName:`h-9 w-auto min-w-[9rem] bg-surface-panel text-xs shadow-surface`,align:`end`,onChange:e=>v(e)})]})]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-balance text-sm font-semibold text-fg`,children:r.discoverHeading}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:r.discoverHint})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2 sm:justify-end`,children:[T?null:(0,Q.jsx)(c,{value:x??``,placeholder:r.marketplaceBrowseSwitchAria,ariaLabel:r.marketplaceBrowseSwitchAria,options:C.map(Be),allowEmpty:!1,triggerClassName:`h-9 w-auto min-w-[9rem] bg-surface-panel text-xs shadow-surface`,align:`end`,onChange:S}),(0,Q.jsx)(c,{value:y,placeholder:r.marketplaceSortLabel,ariaLabel:r.marketplaceSortLabel,options:[{value:`downloads`,label:r.marketplaceSortDownloads},{value:`newest`,label:r.marketplaceSortNewest}],allowEmpty:!1,triggerClassName:`h-9 w-auto min-w-[9rem] bg-surface-panel text-xs shadow-surface`,align:`end`,onChange:e=>b(e)})]})]}),T?(0,Q.jsx)(H,{items:j,activeTab:E,onChange:D,ariaLabel:r.marketplaceResultsTabsAria,tabIdPrefix:`skills-marketplace-results-tab`,panelIdPrefix:`skills-marketplace-results-panel`,className:`min-h-9 gap-1 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,buttonClassName:`rounded-md px-2.5 py-1.5 text-xs`,selectedClassName:`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`,unselectedClassName:`text-fg-muted hover:text-fg`}):null]}),t[69]=g,t[70]=_,t[71]=l,t[72]=x,t[73]=y,t[74]=C,t[75]=E,t[76]=j,t[77]=T,t[78]=v,t[79]=S,t[80]=b,t[81]=D,t[82]=f,t[83]=r.discoverHeading,t[84]=r.discoverHint,t[85]=r.filterAll,t[86]=r.filterDisabledOnly,t[87]=r.filterEnabled,t[88]=r.filterExtra,t[89]=r.filterGlobal,t[90]=r.filterInstalled,t[91]=r.filterWorkspace,t[92]=r.installedHeading,t[93]=r.installedHint,t[94]=r.marketplaceBrowseSwitchAria,t[95]=r.marketplaceResultsTabsAria,t[96]=r.marketplaceSortDownloads,t[97]=r.marketplaceSortLabel,t[98]=r.marketplaceSortNewest,t[99]=r.sourceFilterAria,t[100]=r.statusFilterAria,t[101]=r.tabBuiltin,t[102]=d,t[103]=B):B=t[103];let V;t[104]!==l||t[105]!==n?(V=l===`marketplace`?(0,Q.jsx)(Ne,{...n}):(0,Q.jsx)(xe,{...n}),t[104]=l,t[105]=n,t[106]=V):V=t[106];let U;t[107]!==V||t[108]!==z||t[109]!==B?(U=(0,Q.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[z,B,V]}),t[107]=V,t[108]=z,t[109]=B,t[110]=U):U=t[110];let W;t[111]!==M||t[112]!==U||t[113]!==N||t[114]!==P||t[115]!==R?(W=(0,Q.jsxs)(`div`,{className:M,children:[N,P,R,U]}),t[111]=M,t[112]=U,t[113]=N,t[114]=P,t[115]=R,t[116]=W):W=t[116];let G,ee,K;t[117]===n?(G=t[118],ee=t[119],K=t[120]):(G=(0,Q.jsx)(Ae,{...n}),ee=(0,Q.jsx)(Me,{...n}),K=(0,Q.jsx)(Ce,{...n}),t[117]=n,t[118]=G,t[119]=ee,t[120]=K);let q;t[121]!==W||t[122]!==G||t[123]!==ee||t[124]!==K||t[125]!==F?(q=(0,Q.jsxs)(`div`,{className:F,children:[W,G,ee,K]}),t[121]=W,t[122]=G,t[123]=ee,t[124]=K,t[125]=F,t[126]=q):q=t[126];let J;return t[127]!==q||t[128]!==I?(J=(0,Q.jsxs)(Q.Fragment,{children:[I,q]}),t[127]=q,t[128]=I,t[129]=J):J=t[129],J}function Be(e){return{value:e.id,label:e.displayName}}function Ve(e,t){return(0,Q.jsxs)(`li`,{className:`truncate`,children:[e.type,`: `,e.message]},`${e.path??e.skillName??`diagnostic`}-${t}`)}function He(e){return e.id}function Ue(e){let t=(0,X.c)(17),{vm:n}=e,{sk:r,hasToken:i,loading:a,onReloadClick:o,searchQuery:s,setSearchQuery:c,mainTab:l,setPendingFile:u,setInstallOpen:d,inSettingsShell:f}=n,p=N(Ge),m=N(We),h;t[0]!==a||t[1]!==l||t[2]!==o||t[3]!==s||t[4]!==d||t[5]!==u||t[6]!==c||t[7]!==r?(h=(0,Q.jsx)(de,{loading:a,onReloadClick:o,searchQuery:s,setSearchQuery:c,mainTab:l,sk:r,setPendingFile:u,setInstallOpen:d}),t[0]=a,t[1]=l,t[2]=o,t[3]=s,t[4]=d,t[5]=u,t[6]=c,t[7]=r,t[8]=h):h=t[8];let g=h,_,v;return t[9]!==m||t[10]!==i||t[11]!==f||t[12]!==p||t[13]!==r.title||t[14]!==g?(_=()=>!i||f?(m(),()=>m()):(p({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r.title})}),end:g}),()=>m()),v=[m,i,f,p,g,r.title],t[9]=m,t[10]=i,t[11]=f,t[12]=p,t[13]=r.title,t[14]=g,t[15]=_,t[16]=v):(_=t[15],v=t[16]),(0,Z.useLayoutEffect)(_,v),null}function We(e){return e.clearPageHeader}function Ge(e){return e.setPageHeader}async function Ke(t){let n=t.name.toLowerCase();if(n.endsWith(`.zip`))return t;if(n.endsWith(`skill.md`)){let n=(await i(async()=>{let{default:t}=await import(`./jszip.min-DT31yWkU.js`).then(t=>e(t.default,1));return{default:t}},__vite__mapDeps([0,1]))).default,r=new n;r.file(`SKILL.md`,await t.arrayBuffer());let a=await r.generateAsync({type:`blob`,compression:`DEFLATE`}),o=t.name.replace(/\.md$/i,``).replace(/\s+/g,`-`)||`skill`;return new File([a],`${o}.zip`,{type:`application/zip`})}throw Error(`invalid`)}function qe(){let e=y(e=>e.language),t=_(e).skills,n=!!v(e=>e.token),r=s(),[i,c]=o(),l=i.get(`mprov`)?.trim()||null,[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),g=i.get(`q`)??``,b=i.get(`tab`),x=i.get(`source`),S=i.get(`status`),C=he.has(b)?b:`installed`,w=b===`builtin`?`builtin`:b===`user`?`installed`:null,T=ge.has(x)?x:w??`all`,O=_e.has(S)?S:`all`,[A,M]=(0,Z.useState)(g),[N]=j(A,250),P=N.trim(),F=A.trim().length>0,I=P.length>0,[L,R]=(0,Z.useState)(null),[z,B]=(0,Z.useState)(C),[V,H]=(0,Z.useState)(T),[ne,ae]=(0,Z.useState)(``),[Y,ce]=(0,Z.useState)(O),[le,X]=(0,Z.useState)(!1),[Q,de]=(0,Z.useState)(null),[fe,pe]=(0,Z.useState)(!1),[me,ye]=(0,Z.useState)(!1),[xe,Se]=(0,Z.useState)(null),[Ce,we]=(0,Z.useState)(null),[Te,Ee]=(0,Z.useState)({}),[De,Oe]=(0,Z.useState)(!1),[ke,Ae]=(0,Z.useState)(`catalog`),[je,Me]=(0,Z.useState)(``),[Ne,Pe]=(0,Z.useState)(null),[Fe,Ie]=(0,Z.useState)(null),[Le,Re]=(0,Z.useState)(!1),[ze,Be]=(0,Z.useState)(null),[Ve,He]=(0,Z.useState)(`downloads`),[Ue,We]=(0,Z.useState)(1),[Ge,qe]=(0,Z.useState)(null),[Je,Ye]=(0,Z.useState)(null),[Xe,Ze]=(0,Z.useState)(``),[$,Qe]=(0,Z.useState)(()=>l),[$e,et]=(0,Z.useState)(0),[tt,nt]=(0,Z.useState)(0),[rt,it]=(0,Z.useState)([]),at=(0,Z.useRef)(null),ot=(0,Z.useRef)(l),st=(0,Z.useRef)(null),ct=(0,Z.useRef)(``),lt=(0,Z.useRef)(null),ut=(0,Z.useRef)(!1),[dt,ft]=(0,Z.useState)({query:``,byProvider:{}}),[pt,mt]=(0,Z.useState)(`all`),ht=(0,Z.useRef)(0),gt=(0,Z.useRef)(P);gt.current!==P&&(gt.current=P,mt(e=>e===`all`?e:`all`));let _t=D(()=>k().then(e=>(it(e.diagnostics??[]),e.catalog.map(oe))),[n,tt],{enabled:n,initial:[],errorData:[]}),{data:vt,loading:yt,setData:bt}=_t,xt=D(async()=>{try{let{providers:e,current:t}=await q();return{providers:e.map(e=>({id:e.id,displayName:e.displayName})),current:t}}catch{try{return{providers:[],current:(await K()).provider}}catch{return{providers:[],current:`store`}}}},[n,$e],{enabled:n,initial:{providers:[],current:null}}),St=u||yt,Ct=xt.data.providers;(0,Z.useEffect)(()=>{let e=e=>{if(E(e.detail)===`skills`){if(ut.current){ut.current=!1;return}nt(e=>e+1)}else et(e=>e+1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[]);let wt=i.toString(),Tt=(0,Z.useRef)(wt);if(Tt.current!==wt){Tt.current=wt;let e=i.get(`q`)??``,t=i.get(`tab`),n=i.get(`source`),r=i.get(`status`),a=he.has(t)?t:`installed`,o=t===`builtin`?`builtin`:t===`user`?`installed`:null,s=ge.has(n)?n:o??`all`,c=_e.has(r)?r:`all`;M(t=>t===e?t:e),B(e=>e===a?e:a),H(e=>e===s?e:s),ce(e=>e===c?e:c);let l=i.get(`mcat`)??``;Ze(a===`marketplace`?e=>e===l?e:l:``)}let Et=(0,Z.useRef)(n);!n&&Et.current&&(Qe(null),at.current=null),Et.current=n,n&&l&&ot.current!==l&&(ot.current=l,Qe(l)),n&&l==null&&xt.data.current&&xt.data.current!==st.current&&(st.current=xt.data.current,Qe(e=>e??xt.data.current));let Dt=`${P}|${Ve}|${z}|${Xe}|${$??``}|${pt}`;ct.current!==Dt&&(ct.current=Dt,We(1)),z===`marketplace`&&$&&lt.current!=null&&lt.current!==$&&Ze(``),lt.current=$;let Ot=D(()=>se({page:Ue,pageSize:20,sort:Ve,category:Xe.trim()||void 0,provider:$}),[n,z,Xe,Ue,Ve,I,$],{enabled:n&&z===`marketplace`&&!!$&&!I,initial:null,errorData:null});(0,Z.useEffect)(()=>{if(!n||!I||z!==`marketplace`||Ct.length===0)return;let e=++ht.current,r={};for(let e of Ct)r[e.id]={status:`loading`,rows:[]};ft({query:P,byProvider:r});let i=[],a=[];for(let n of Ct){let r=new AbortController;i.push(r);let o=window.setTimeout(()=>{r.abort(new DOMException(`Adapter timed out`,`TimeoutError`))},8e3);a.push(o),se({provider:n.id,q:P,page:1,pageSize:40,sort:Ve,signal:r.signal}).then(t=>{if(window.clearTimeout(o),e!==ht.current)return;let r=t.items.map(e=>({...e,providerId:n.id}));ft(e=>({...e,byProvider:{...e.byProvider,[n.id]:{status:`ok`,rows:r}}}))}).catch(r=>{if(window.clearTimeout(o),e!==ht.current)return;let i=r instanceof DOMException&&(r.name===`TimeoutError`||r.name===`AbortError`)?t.marketplaceLoadFailed:r instanceof Error?r.message:t.marketplaceLoadFailed;ft(e=>({...e,byProvider:{...e.byProvider,[n.id]:{status:`error`,rows:[],error:i}}}))})}return()=>{for(let e of a)window.clearTimeout(e);for(let e of i)e.abort()}},[n,z,I,P,Ct,Ve,t.marketplaceLoadFailed]);let kt=D(()=>re({provider:$,locale:e}).then(e=>e.items),[n,z,$,e],{enabled:n&&z===`marketplace`&&!!$,initial:[],errorData:[]}),At=(0,Z.useMemo)(()=>{if(!I||dt.query!==P)return[];let e=Ct.map(e=>({id:e.id,rows:[...dt.byProvider[e.id]?.rows??[]]})),t=[];for(;e.some(e=>e.rows.length>0);)for(let n of e)n.rows.length>0&&t.push(n.rows.shift());let n=new Map;for(let e of t){let t=[(e.id??``).toLowerCase().trim(),(e.name??``).toLowerCase().trim(),(e.author?.username??``).toLowerCase().trim()].join(`|`),r=n.get(t);if(!r){n.set(t,{...e,additionalSources:[]});continue}if(e.providerId&&e.providerId!==r.providerId){let t=r.additionalSources??[];t.some(t=>t.providerId===e.providerId)||(t.push({providerId:e.providerId,sourceLabel:e.sourceLabel}),r.additionalSources=t)}}return Array.from(n.values())},[I,P,dt,Ct]),jt=(0,Z.useMemo)(()=>{if(!I)return{};let e={all:At.length};for(let t of Ct)e[t.id]=At.filter(e=>e.providerId===t.id||(e.additionalSources??[]).some(e=>e.providerId===t.id)).length;return e},[I,At,Ct]),Mt=(0,Z.useMemo)(()=>I?pt===`all`?At:At.filter(e=>e.providerId===pt||(e.additionalSources??[]).some(e=>e.providerId===pt)):[],[I,At,pt]),Nt=(0,Z.useMemo)(()=>{if(!I)return{};let e={};for(let t of Ct)e[t.id]=dt.byProvider[t.id]?.status??`loading`;return e},[I,dt,Ct]),Pt=(0,Z.useMemo)(()=>Object.values(Nt).some(e=>e===`loading`),[Nt]),Ft=(0,Z.useMemo)(()=>{if(!I)return!1;let e=Object.values(Nt);return e.length>0&&e.every(e=>e===`error`)},[I,Nt]),It=(0,Z.useMemo)(()=>{if(!I||At.length===0&&Pt)return null;let e=Mt.length,t=(Ue-1)*20;return{items:Mt.slice(t,t+20),meta:{page:Ue,pageSize:20,total:e,totalPages:Math.max(1,Math.ceil(e/20))},provider:pt}},[I,At,Pt,Mt,Ue,pt]),Lt=z===`marketplace`?F?I?It:null:Ot.data:null,Rt=z===`marketplace`?F?I?Pt:!0:Ot.loading:!1,zt=I?Ft?t.marketplaceLoadFailed:null:Ot.error instanceof Error?Ot.error.message:Ot.error?t.marketplaceLoadFailed:null,Bt=z===`marketplace`?kt.data:[],Vt=z===`marketplace`?kt.loading:!1,Ht=kt.error instanceof Error?kt.error.message:kt.error?t.marketplaceCategoriesFailed:null;Xe.trim()&&Bt.length>0&&!Bt.some(e=>e.id===Xe)&&Ze(``);let Ut=(0,Z.useCallback)(async e=>{let n=e?.silent===!0;n||d(!0),p(null);try{let e=await k();return it(e.diagnostics??[]),bt(e.catalog.map(oe)),{ok:!0}}catch(e){let n=e instanceof Error?e.message:t.loadFailed;return p(n),{ok:!1,message:n}}finally{n||d(!1)}},[bt,t.loadFailed]),Wt=!u&&_t.error?_t.error instanceof Error?_t.error.message:t.loadFailed:null,Gt=f??Wt;(0,Z.useEffect)(()=>{c(e=>{let t=new URLSearchParams(e);return P?t.set(`q`,P):t.delete(`q`),z===`marketplace`?t.set(`tab`,z):t.delete(`tab`),V===`all`?t.delete(`source`):t.set(`source`,V),z===`installed`&&Y!==`all`?t.set(`status`,Y):t.delete(`status`),z===`marketplace`&&Xe.trim()?t.set(`mcat`,Xe.trim()):t.delete(`mcat`),z===`marketplace`&&$?t.set(ve,$):t.delete(ve),t.toString()===e.toString()?e:t},{replace:!0})},[z,Xe,$,P,Y,c,V]);let Kt=(0,Z.useCallback)((e,t,n=5e3)=>{R({kind:e,message:t}),window.setTimeout(()=>R(null),n)},[]),qt=(0,Z.useCallback)(e=>{let n=e.availability;if(!n)return t.installSuccess;let r=n.skillName||n.skillId;if(!n.loaded)return`Skill "${r}" installed, but it was not loaded. Check skill diagnostics.`;if(n.diagnostics.length>0)return`Skill "${r}" installed with ${n.diagnostics.length} diagnostic(s).`;if(n.enabled===!1)return`Skill "${r}" installed but disabled. Enable it before use.`;if(n.availableForDefaultAgent===!1){let e=n.unavailableReason||`unavailable`;return`Skill "${r}" installed but unavailable for agent "${n.defaultAgentId}" (${e}).`}return`Skill "${r}" installed and ready.`},[t.installSuccess]),Jt=(0,Z.useCallback)(async e=>{Ae(`catalog`),Oe(!0),Me(e.name),Pe(null),Ie(null),Be(null),Re(!0);try{let t=await ie(e.name);Pe(t),Me(t.name)}catch(e){Pe(null),Be(e instanceof Error?e.message:t.detailLoadFailed)}finally{Re(!1)}},[t.detailLoadFailed]),Yt=(0,Z.useCallback)(async e=>{let n=e.trim();if(n){Ae(`catalog`),Oe(!0),Me(n),Pe(null),Ie(null),Be(null),Re(!0);try{let e=await ie(n);Pe(e),Me(e.name)}catch(e){Pe(null),Be(e instanceof Error?e.message:t.detailLoadFailed)}finally{Re(!1)}}},[t.detailLoadFailed]),Xt=(0,Z.useCallback)(async(e,n,r)=>{let i=r?.trim()||$;if(i){at.current=i,Ae(`store`),Oe(!0),Me(n?.trim()||e),Pe(null),Ie(null),Be(null),Re(!0);try{let t=await ue(e,{provider:i});Me(t.name),Ie(t.skillDocPreview)}catch(e){Ie(null),Be(e instanceof Error?e.message:t.detailLoadFailed)}finally{Re(!1)}}},[$,t.detailLoadFailed]),Zt=(0,Z.useCallback)(async(e,n)=>{we(e),Ee(t=>({...t,[e]:n})),R(null);try{return await J(e,n),await Ut({silent:!0}),!0}catch(n){return Ee(t=>{let{[e]:n,...r}=t;return r}),Kt(`error`,n instanceof Error?n.message:t.skillToggleFailed),!1}finally{we(null),Ee(t=>{let{[e]:n,...r}=t;return r})}},[Ut,Kt,t.skillToggleFailed]),Qt=(0,Z.useCallback)(async()=>{R(null),d(!0),p(null);try{await U()}catch(e){p(e instanceof Error?e.message:t.reloadFailed),d(!1);return}await Ut()},[Ut,t.reloadFailed]),$t=(0,Z.useMemo)(()=>{let e=A.trim().toLowerCase();return e?vt.filter(t=>[t.name,t.description,t.directoryId,t.path,t.source,t.hub?.source,t.hub?.ref].filter(Boolean).join(` `).toLowerCase().includes(e)):vt},[vt,A]),en=(0,Z.useMemo)(()=>{let e=vt.filter(e=>e.source===`builtin`);return{total:e.length,enabled:e.filter(e=>Te[e.name]??e.enabled).length}},[vt,Te]),tn=(0,Z.useMemo)(()=>{let e=vt.filter(e=>e.source!==`builtin`);return{total:e.length,enabled:e.filter(e=>Te[e.name]??e.enabled).length}},[vt,Te]),nn=(0,Z.useMemo)(()=>je?vt.find(e=>e.name===je):void 0,[vt,je]),rn=nn==null?!0:Te[je]??nn.enabled,an=nn?.directoryId??null,on=nn?.managed??!1,sn=(0,Z.useMemo)(()=>ke!==`store`||!je?null:G(at.current??$,je),[ke,je,$]),cn=(0,Z.useMemo)(()=>{let e=$t;return z===`installed`&&V!==`all`&&(e=V===`installed`?e.filter(e=>e.source!==`builtin`):e.filter(e=>e.source===V)),e},[$t,z,V]),ln=(0,Z.useMemo)(()=>{let e=new Set,t=[];for(let n of cn){let r=n.category;!r||e.has(r)||(e.add(r),t.push(r))}return t.sort((e,t)=>{let n=be.indexOf(e),r=be.indexOf(t);return n>=0&&r>=0?n-r:n>=0?-1:r>=0?1:e.localeCompare(t)})},[cn]),un=(0,Z.useCallback)(e=>t.categoryLabel?.[e]||e,[t.categoryLabel]),dn=(0,Z.useMemo)(()=>ne?cn.filter(e=>e.category===ne):cn,[cn,ne]);(0,Z.useEffect)(()=>{ae(``)},[V]);let fn=(0,Z.useCallback)(e=>Te[e.name]??e.enabled,[Te]),pn=(0,Z.useMemo)(()=>dn.filter(e=>!fn(e)).length,[dn,fn]),mn=(0,Z.useMemo)(()=>{let e=dn;return Y===`disabled`&&(e=e.filter(e=>!fn(e))),Y===`enabled`&&(e=e.filter(e=>fn(e))),[...e].toSorted((e,t)=>{let n=fn(e);return n===fn(t)?e.name.localeCompare(t.name,void 0,{sensitivity:`base`}):n?-1:1})},[dn,Y,fn]),hn=async e=>{R(null),h(!0),p(null);try{let n;try{n=await Ke(e)}catch{p(t.invalidFile),Kt(`error`,t.invalidFile);return}let r=await W(n,{overwrite:!0});ut.current=!0,await Ut(),Kt(`success`,qt(r)),X(!1),de(null),B(`installed`),H(`installed`),await Yt(r.availability?.skillName||r.skillId)}catch(e){p(e instanceof Error?e.message:t.uploadFailed),Kt(`error`,e instanceof Error?e.message:t.uploadFailed)}finally{h(!1)}},gn=()=>{Q&&hn(Q)},_n=e=>{let t=e.target.files?.[0];e.target.value=``,t&&de(t)},vn=e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.types.includes(`Files`)&&(pe(!0),e.dataTransfer.dropEffect=`copy`)},yn=e=>{let t=e.currentTarget,n=e.relatedTarget;n&&t.contains(n)||pe(!1)},bn=e=>{e.preventDefault(),e.stopPropagation(),pe(!1);let t=e.dataTransfer?.files?.[0];t&&de(t)},xn=e=>{if(e.origin===`agents-global`)return t.source.agentsGlobal;if(e.origin===`agents-workspace`)return t.source.agentsWorkspace;switch(e.source){case`builtin`:return t.source.builtin;case`workspace`:return t.source.workspace;case`global`:return t.source.global;case`extra`:return t.source.extra;default:return e.source}},Sn=async()=>{let e=xe,n=De&&ke===`catalog`&&an===e;if(ye(!1),Se(null),e){R(null);try{await ee(e),ut.current=!0,await Ut(),n&&(Oe(!1),Ae(`catalog`),Me(``),Pe(null),Ie(null),Be(null))}catch(e){p(e instanceof Error?e.message:t.deleteFailed)}}},Cn=(0,Z.useCallback)(e=>vt.some(t=>t.name===e),[vt]),wn=(0,Z.useCallback)(async e=>{let n=(e?.name??je).trim();if(!n)return;let i=e?.source??ke;if(i===`catalog`){let e=vt.find(e=>e.name===n);if(e&&!(Te[e.name]??e.enabled))return}R(null);let a=i===`store`&&!Cn(n);Ye(n);try{if(a){let t=e?.providerOverride?.trim()||at.current||$;await te({name:n,overwrite:!1,...t?{provider:t}:{}}),ut.current=!0,await Ut({silent:!0})}Oe(!1),r(`/chat/new?skill=${encodeURIComponent(n)}`)}catch(e){Kt(`error`,e instanceof Error?e.message:t.uploadFailed)}finally{Ye(null)}},[vt,je,ke,Te,Cn,Ut,r,Kt,t.uploadFailed,$]),Tn=(0,Z.useCallback)(async(e,n)=>{let r=Cn(e);if(!(r&&!window.confirm(t.marketplaceReinstallConfirm))){R(null),qe(e);try{let t=n?.providerOverride?.trim()||(n?.useDetailProvider?at.current??$:$),i=await te({name:e,overwrite:r,...t?{provider:t}:{}});ut.current=!0,await Ut({silent:!0}),Kt(`success`,qt(i)),B(`installed`),H(`installed`),await Yt(i.availability?.skillName||i.skillId||e)}catch(e){Kt(`error`,e instanceof Error?e.message:t.uploadFailed)}finally{qe(null)}}},[Cn,qt,Ut,$,Yt,Kt,t.marketplaceReinstallConfirm,t.uploadFailed]),{pathname:En}=a();return{sk:t,hasToken:n,catalog:vt,loading:St,error:Gt,uploading:m,searchQuery:A,setSearchQuery:M,actionFeedback:L,skillDiagnostics:rt,mainTab:z,setMainTab:B,sourceFilter:V,setSourceFilter:H,builtinCategoryFilter:ne,setBuiltinCategoryFilter:ae,installOpen:le,setInstallOpen:X,pendingFile:Q,setPendingFile:de,dropActive:fe,setDropActive:pe,confirmOpen:me,setConfirmOpen:ye,confirmId:xe,setConfirmId:Se,togglingSkillName:Ce,enabledOverride:Te,detailOpen:De,setDetailOpen:Oe,detailSource:ke,setDetailSource:Ae,detailTitle:je,setDetailTitle:Me,detailCatalogPreview:Ne,setDetailCatalogPreview:Pe,detailMarketplacePreview:Fe,setDetailMarketplacePreview:Ie,detailLoading:Le,detailError:ze,setDetailError:Be,marketSort:Ve,setMarketSort:He,marketPage:Ue,setMarketPage:We,mpLoading:Rt,mpError:zt,mpPayload:Lt,searchActive:I,searchInputActive:F,resultTab:pt,setResultTab:mt,aggregatedTabCounts:jt,aggregatedProviderStatus:Nt,aggregatedAllFailed:Ft,installingMarketName:Ge,usingSkillInChatName:Je,onUseSkillInChat:wn,marketCategoryId:Xe,setMarketCategoryId:Ze,mpCategories:Bt,mpCategoriesError:Ht,mpCategoriesLoading:Vt,marketBrowseProvider:$,setMarketBrowseProvider:Qe,registeredProviders:Ct,builtinTabStats:en,userTabStats:tn,detailEnabled:rn,detailDirectoryId:an,detailManaged:on,detailExternalUrl:sn,filteredCatalog:cn,builtinCategories:ln,categoryFilteredCatalog:dn,catalogDisplayRows:mn,catalogDisabledCount:pn,catalogStatusFilter:Y,setCatalogStatusFilter:ce,resolveSkillEnabled:fn,inSettingsShell:En.startsWith(`/settings/`),categoryLabel:un,onReloadClick:Qt,openSkillDetail:Jt,openMarketplaceDetail:Xt,onSkillToggle:Zt,onInstallSubmit:gn,onFileInputChange:_n,onModalDragOver:vn,onModalDragLeave:yn,onModalDrop:bn,sourceLabel:xn,runDelete:Sn,onMarketInstall:Tn,isSkillInstalledByName:Cn}}function Je(){let e=(0,X.c)(2),t=qe(),n;return e[0]===t?n=e[1]:(n=(0,Q.jsx)(ze,{vm:t}),e[0]=t,e[1]=n),n}export{Je as SkillsPage};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{l as r,o as i,r as a}from"./locale-store-CnamlR07.js";import{Kn as o}from"./index-DRrjYYzZ.js";import"./skill-reload-api-D7kunhqy.js";async function s(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`),n.append(`target`,t.target??`global`);let i=r.getState().token,o=new Headers;i&&o.set(`Authorization`,`Bearer ${i}`);let s=await fetch(a(`/api/skills/upload`),{method:`POST`,headers:o,body:n});s.status===401&&r.getState().onUnauthorized();let c=await s.json().catch(()=>({}));if(!s.ok)throw Error(c.error||`HTTP ${s.status}`);if(!c.payload?.skillId)throw Error(`Invalid response`);return c.payload}async function c(e,t){let n=t?`?target=${encodeURIComponent(t)}`:``,r=await i(a(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!r.ok)throw Error(await o(r))}async function l(e,t){let n=await i(a(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await o(n))}function u(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function d(e){let t=new URLSearchParams;u(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let n=t.toString(),r=await i(a(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function f(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),u(t,e.provider);let n=t.toString(),r=await i(a(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function p(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;u(r,t?.provider);let s=r.toString(),c=await i(a(`/api/skills/marketplace/packages/${n}${s?`?${s}`:``}`),{cache:`no-store`});if(!c.ok)throw Error(await o(c));let l=(await c.json()).payload;if(!l?.name||!l.skillDocPreview||typeof l.skillDocPreview.name!=`string`||typeof l.skillDocPreview.description!=`string`||typeof l.skillDocPreview.bodyMarkdown!=`string`||typeof l.skillDocPreview.disableModelInvocation!=`boolean`||!l.skillDocPreview.metadata||typeof l.skillDocPreview.metadata!=`object`||typeof l.skillDocPreview.metadata.name!=`string`||typeof l.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return l}async function m(e){let t=await i(a(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:`global`,...e})});if(!t.ok)throw Error(await o(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function h(e){let t=await i(a(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let n=(await t.json()).payload;if(!n||typeof n.name!=`string`||typeof n.description!=`string`||typeof n.bodyMarkdown!=`string`||typeof n.disableModelInvocation!=`boolean`||!n.metadata||typeof n.metadata!=`object`||typeof n.metadata.name!=`string`||typeof n.metadata.description!=`string`)throw Error(`Invalid response`);return n}async function g(){let e=await i(a(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function _(){let e=await i(a(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}var v=e(),y=t(),b=[{light:`bg-sky-100 text-sky-800`,dark:`dark:bg-sky-950/55 dark:text-sky-200`},{light:`bg-violet-100 text-violet-800`,dark:`dark:bg-violet-950/55 dark:text-violet-200`},{light:`bg-emerald-100 text-emerald-800`,dark:`dark:bg-emerald-950/55 dark:text-emerald-200`},{light:`bg-orange-100 text-orange-800`,dark:`dark:bg-orange-950/55 dark:text-orange-200`},{light:`bg-rose-100 text-rose-800`,dark:`dark:bg-rose-950/55 dark:text-rose-200`},{light:`bg-amber-100 text-amber-900`,dark:`dark:bg-amber-950/55 dark:text-amber-200`},{light:`bg-cyan-100 text-cyan-800`,dark:`dark:bg-cyan-950/55 dark:text-cyan-200`},{light:`bg-indigo-100 text-indigo-800`,dark:`dark:bg-indigo-950/55 dark:text-indigo-200`},{light:`bg-fuchsia-100 text-fuchsia-800`,dark:`dark:bg-fuchsia-950/55 dark:text-fuchsia-200`},{light:`bg-teal-100 text-teal-800`,dark:`dark:bg-teal-950/55 dark:text-teal-200`}];function x(e){let t=0;for(let n=0;n<e.length;n+=1)t=Math.imul(31,t)+e.charCodeAt(n)|0;return Math.abs(t)}function S(e){let t=e.trim();if(!t)return`?`;let n=t.match(/[\p{L}\p{N}]/u);return n?n[0].toLocaleUpperCase(`en-US`):t[0]}function C(e){let t=(0,v.c)(9),{name:r,className:i}=e,a;t[0]===r?a=t[1]:(a=S(r),t[0]=r,t[1]=a);let o=a,s=b[x(r)%b.length],c;t[2]!==i||t[3]!==s.dark||t[4]!==s.light?(c=n(`flex size-11 shrink-0 items-center justify-center rounded-xl font-semibold tracking-tight shadow-surface`,`text-[1.05rem] ring-1 ring-inset ring-black/[0.06] dark:ring-white/[0.1]`,`transition-[transform,box-shadow] duration-200 ease-out group-hover:ring-black/[0.1] dark:group-hover:ring-white/[0.14]`,`group-hover:-translate-y-px`,s.light,s.dark,i),t[2]=i,t[3]=s.dark,t[4]=s.light,t[5]=c):c=t[5];let l;return t[6]!==o||t[7]!==c?(l=(0,y.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}var w=`https://skillhub.cn`,T=`https://clawhub.ai`;function E(e){let t=e.trim();return t?`${w}/skills/${encodeURIComponent(t)}`:null}function D(e){let t=e.trim();return t?`${T}/${encodeURIComponent(t)}`:null}function O(e,t){return e===`skillhub`?E(t):e===`clawhub`?D(t):null}function k(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function A(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function j(e){return e.filter(e=>e.type!==`collision`)}function M(e){let t=[e.kind];return e.label?.trim()&&t.push(e.label.trim()),e.package?.trim()&&t.push(e.package.trim()),e.formula?.trim()&&t.push(e.formula.trim()),e.module?.trim()&&t.push(e.module.trim()),e.url?.trim()&&t.push(e.url.trim()),t.join(` · `)}function N(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}export{s as _,O as a,c,g as d,_ as f,l as g,m as h,k as i,d as l,h as m,M as n,N as o,f as p,A as r,C as s,j as t,p as u};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{l as r,o as i,r as a}from"./locale-store-81Gv0wwo.js";import{Kn as o}from"./index-CPTLS-Zn.js";import"./skill-reload-api-B6GiZgZU.js";async function s(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`),n.append(`target`,t.target??`global`);let i=r.getState().token,o=new Headers;i&&o.set(`Authorization`,`Bearer ${i}`);let s=await fetch(a(`/api/skills/upload`),{method:`POST`,headers:o,body:n});s.status===401&&r.getState().onUnauthorized();let c=await s.json().catch(()=>({}));if(!s.ok)throw Error(c.error||`HTTP ${s.status}`);if(!c.payload?.skillId)throw Error(`Invalid response`);return c.payload}async function c(e,t){let n=t?`?target=${encodeURIComponent(t)}`:``,r=await i(a(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!r.ok)throw Error(await o(r))}async function l(e,t){let n=await i(a(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await o(n))}function u(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function d(e){let t=new URLSearchParams;u(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let n=t.toString(),r=await i(a(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function f(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),u(t,e.provider);let n=t.toString(),r=await i(a(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function p(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;u(r,t?.provider);let s=r.toString(),c=await i(a(`/api/skills/marketplace/packages/${n}${s?`?${s}`:``}`),{cache:`no-store`});if(!c.ok)throw Error(await o(c));let l=(await c.json()).payload;if(!l?.name||!l.skillDocPreview||typeof l.skillDocPreview.name!=`string`||typeof l.skillDocPreview.description!=`string`||typeof l.skillDocPreview.bodyMarkdown!=`string`||typeof l.skillDocPreview.disableModelInvocation!=`boolean`||!l.skillDocPreview.metadata||typeof l.skillDocPreview.metadata!=`object`||typeof l.skillDocPreview.metadata.name!=`string`||typeof l.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return l}async function m(e){let t=await i(a(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:`global`,...e})});if(!t.ok)throw Error(await o(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function h(e){let t=await i(a(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let n=(await t.json()).payload;if(!n||typeof n.name!=`string`||typeof n.description!=`string`||typeof n.bodyMarkdown!=`string`||typeof n.disableModelInvocation!=`boolean`||!n.metadata||typeof n.metadata!=`object`||typeof n.metadata.name!=`string`||typeof n.metadata.description!=`string`)throw Error(`Invalid response`);return n}async function g(){let e=await i(a(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function _(){let e=await i(a(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}var v=e(),y=t(),b=[{light:`bg-sky-100 text-sky-800`,dark:`dark:bg-sky-950/55 dark:text-sky-200`},{light:`bg-violet-100 text-violet-800`,dark:`dark:bg-violet-950/55 dark:text-violet-200`},{light:`bg-emerald-100 text-emerald-800`,dark:`dark:bg-emerald-950/55 dark:text-emerald-200`},{light:`bg-orange-100 text-orange-800`,dark:`dark:bg-orange-950/55 dark:text-orange-200`},{light:`bg-rose-100 text-rose-800`,dark:`dark:bg-rose-950/55 dark:text-rose-200`},{light:`bg-amber-100 text-amber-900`,dark:`dark:bg-amber-950/55 dark:text-amber-200`},{light:`bg-cyan-100 text-cyan-800`,dark:`dark:bg-cyan-950/55 dark:text-cyan-200`},{light:`bg-indigo-100 text-indigo-800`,dark:`dark:bg-indigo-950/55 dark:text-indigo-200`},{light:`bg-fuchsia-100 text-fuchsia-800`,dark:`dark:bg-fuchsia-950/55 dark:text-fuchsia-200`},{light:`bg-teal-100 text-teal-800`,dark:`dark:bg-teal-950/55 dark:text-teal-200`}];function x(e){let t=0;for(let n=0;n<e.length;n+=1)t=Math.imul(31,t)+e.charCodeAt(n)|0;return Math.abs(t)}function S(e){let t=e.trim();if(!t)return`?`;let n=t.match(/[\p{L}\p{N}]/u);return n?n[0].toLocaleUpperCase(`en-US`):t[0]}function C(e){let t=(0,v.c)(9),{name:r,className:i}=e,a;t[0]===r?a=t[1]:(a=S(r),t[0]=r,t[1]=a);let o=a,s=b[x(r)%b.length],c;t[2]!==i||t[3]!==s.dark||t[4]!==s.light?(c=n(`flex size-11 shrink-0 items-center justify-center rounded-xl font-semibold tracking-tight shadow-surface`,`text-[1.05rem] ring-1 ring-inset ring-black/[0.06] dark:ring-white/[0.1]`,`transition-[transform,box-shadow] duration-200 ease-out group-hover:ring-black/[0.1] dark:group-hover:ring-white/[0.14]`,`group-hover:-translate-y-px`,s.light,s.dark,i),t[2]=i,t[3]=s.dark,t[4]=s.light,t[5]=c):c=t[5];let l;return t[6]!==o||t[7]!==c?(l=(0,y.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}var w=`https://skillhub.cn`,T=`https://clawhub.ai`;function E(e){let t=e.trim();return t?`${w}/skills/${encodeURIComponent(t)}`:null}function D(e){let t=e.trim();return t?`${T}/${encodeURIComponent(t)}`:null}function O(e,t){return e===`skillhub`?E(t):e===`clawhub`?D(t):null}function k(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function A(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function j(e){return e.filter(e=>e.type!==`collision`)}function M(e){let t=[e.kind];return e.label?.trim()&&t.push(e.label.trim()),e.package?.trim()&&t.push(e.package.trim()),e.formula?.trim()&&t.push(e.formula.trim()),e.module?.trim()&&t.push(e.module.trim()),e.url?.trim()&&t.push(e.url.trim()),t.join(` · `)}function N(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}export{s as _,O as a,c,g as d,_ as f,l as g,m as h,k as i,d as l,h as m,M as n,N as o,f as p,A as r,C as s,j as t,p as u};
@@ -1 +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"./external-link-DjqjBmc3.js";import{t as i}from"./cn-JdwAhgNB.js";import{n as a}from"./interaction-BmQogeqz.js";import{t as o}from"./messages-D7kOD_o_.js";import{n as s}from"./locale-store-CnamlR07.js";import{r as c}from"./settings-form-draft-Dy10ldo8.js";import{Ls as l,Po as u,Qt as d,Ts as f,Vl as p,Xt as m,Yt as h,Zt as g}from"./index-DRrjYYzZ.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-C7w2WS-A.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!u()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.task===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=o(s(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(g),[r,i]=(0,x.useState)(null),[a,c]=(0,x.useState)(!1),l=async t=>{if(!t){n(d({enabled:!1})),i(null);return}c(!0);try{let t=await h();if(t!==`granted`){i(t===`unsupported`?e.unsupported:e.denied);return}n(d({enabled:!0})),i(await m(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},u=e=>{n(d(e))};return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:e.pageTitle}),(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(p,{className:`size-4 text-accent`,strokeWidth:1.75}),e.title]}),(0,C.jsx)(`p`,{className:`mb-4 text-sm text-fg-muted`,children:e.description}),(0,C.jsx)(`div`,{className:`space-y-2`,children:[[`enabled`,e.enabled,e.enabledDesc],[`completed`,e.completed,e.completedDesc],[`failed`,e.failedRuns,e.failedRunsDesc]].map(([e,n,r])=>(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,C.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?l(t.target.checked):u({[e]:t.target.checked})}})]},e))}),r?(0,C.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,role:`status`,children:r}):null,(0,C.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:e.limitation})]})]})}async function T(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function E(e,t,n){return e.task===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.task===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.task===`opened-settings`?t.openedSettings:e.status===`granted`?e.task===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.task===`opened-settings`?t.openedSettings:e.status===`granted`?e.task===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.task===`opened-settings`?t.openedSettings:e.status===`granted`?e.task===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var A=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function j(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||A.has(e)?t===`unknown`:!1}function M(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:A.has(e)?t===`denied`:!0}var N=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function P(e){return e===`linux`?N:N.filter(t=>!t.platforms||t.platforms.includes(e))}function F(e,t){let n=o(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function I(e,t,n){let r=o(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var L={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function R(){let e=s(e=>e.language),t=o(e).systemSettings,[n,d]=(0,x.useReducer)(c,L),{behavior:p,perms:m,loadError:h,permFeedback:g,permBusy:A,refreshing:N}=n,R=typeof window<`u`?window.electronAPI?.system:void 0,z=(0,x.useCallback)(async e=>{if(R){d({type:`patch`,patch:{loadError:null}});try{d({type:`patch`,patch:{behavior:await R.getBehavior(),perms:await R.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:t.refreshDone}:{}}})}catch(t){d({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[R,t.refreshDone]),B=(0,x.useCallback)(async()=>{if(!(N||A)){d({type:`patch`,patch:{refreshing:!0}});try{await z({showRefreshFeedback:!0})}finally{d({type:`patch`,patch:{refreshing:!1}})}}},[z,A,N]);if((0,x.useEffect)(()=>{let e=new Set([t.refreshDone,t.openSettingsDone,t.openSettingsFailed,t.desktopNotify.testShown]);if(!g||!e.has(g))return;let n=window.setTimeout(()=>{d({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(n)},[g,t.openSettingsDone,t.openSettingsFailed,t.refreshDone,t.desktopNotify.testShown]),(0,x.useEffect)(()=>{u()&&R&&z()},[R,z]),!u()||!R)return(0,C.jsx)(w,{});let V=async e=>{try{let{behavior:t}=await R.setBehavior(e);d({type:`patch`,patch:{behavior:t}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},H=async e=>{if(!e){await V({notifyEnabled:!1});return}d({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(t.desktopNotify.testTitle,t.desktopNotify.testBody);if(e===`unsupported`){d({type:`patch`,patch:{permFeedback:t.notificationsFeedback.unsupported}});return}if(e===`denied`){d({type:`patch`,patch:{permFeedback:t.desktopNotify.denied}});return}if(e==="default"){d({type:`patch`,patch:{permFeedback:t.notificationsFeedback.default}});return}await V({notifyEnabled:!0}),d({type:`patch`,patch:{perms:await R.getPermissions()}}),d({type:`patch`,patch:{permFeedback:t.desktopNotify.testShown}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},U=async e=>{d({type:`patch`,patch:{permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{(await R.openPrivacy(e)).ok?d({type:`patch`,patch:{permFeedback:t.openSettingsDone}}):d({type:`patch`,patch:{permFeedback:t.openSettingsFailed}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},W=async()=>{d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await R.requestMicrophone(),n=await T();d({type:`patch`,patch:{perms:await R.getPermissions()}}),d({type:`patch`,patch:{permFeedback:E(e,n,t.permFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},G=async()=>{if(R.requestAccessibility){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await R.requestAccessibility();d({type:`patch`,patch:{perms:await R.getPermissions()}}),d({type:`patch`,patch:{permFeedback:D(e,t.accessibilityFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},K=async()=>{if(R.requestNotifications){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await R.requestNotifications();d({type:`patch`,patch:{perms:await R.getPermissions()}}),d({type:`patch`,patch:{permFeedback:O(e,t.notificationsFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(R.requestScreen){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await R.requestScreen();d({type:`patch`,patch:{perms:await R.getPermissions()}}),d({type:`patch`,patch:{permFeedback:k(e,t.screenFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},J=p?p.platform===`win32`?t.permissionsHintWin:p.platform===`linux`?t.permissionsHintLinux:p.platform===`darwin`?t.permissionsHintDarwin:t.permissionsHint:t.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:t.title}),h?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:h}):null,g?(0,C.jsx)(`p`,{className:i(`text-sm`,g===t.refreshDone||g===t.openSettingsDone||g===t.permFeedback.granted||g===t.permFeedback.alreadyGranted||g===t.accessibilityFeedback.granted||g===t.accessibilityFeedback.alreadyGranted||g===t.notificationsFeedback.granted||g===t.notificationsFeedback.alreadyGranted||g===t.screenFeedback.granted||g===t.screenFeedback.alreadyGranted||g===t.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:g}):null,(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(f,{className:`size-4 text-accent`,strokeWidth:1.75}),t.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!p,checked:!!p?.openAtLogin,onChange:e=>{V({openAtLogin:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!p,checked:!!p?.keepAwakePreferred,onChange:e=>{V({keepAwakePreferred:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!p||A,checked:!!p?.notifyEnabled,onChange:e=>{H(e.target.checked)}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!p,checked:!!p?.notifySoundEnabled,onChange:e=>{V({notifySoundEnabled:e.target.checked})}})]})]})]}),p&&m?(0,C.jsxs)(`section`,{className:y(),children:[(0,C.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:J}),p.platform===`darwin`&&!p.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:t.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:N||A,"aria-busy":N,className:i(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,a.press),onClick:()=>void B(),children:[(0,C.jsx)(l,{className:i(`size-3.5`,N&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),N?t.refreshing:t.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(p.platform).map(({key:n,pane:o})=>{let s=F(e,m[n]),c=t.perm[n],l=m[n]===`unknown`?I(e,n,p.platform):null;return c?(0,C.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:c.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${s.className}`,children:s.label}),l?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[n===`notifications`&&j(n,m[n],p.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,a.press),onClick:()=>void K(),children:t.requestAccess}):null,n===`microphone`&&j(n,m[n],p.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,a.press),onClick:()=>void W(),children:t.requestAccess}):null,n===`accessibility`&&j(n,m[n],p.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,a.press),onClick:()=>void G(),children:t.requestAccess}):null,n===`screen`&&j(n,m[n],p.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,a.press),onClick:()=>void q(),children:t.requestAccess}):null,M(n,m[n],p.platform)?(0,C.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,a.press),onClick:()=>void U(o),children:[t.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):null})})]}):null]})}export{R as SystemSettingsPanel};
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"./external-link-DjqjBmc3.js";import{t as i}from"./cn-JdwAhgNB.js";import{n as a}from"./interaction-BmQogeqz.js";import{t as o}from"./messages-ELK_1h2D.js";import{n as s}from"./locale-store-81Gv0wwo.js";import{r as c}from"./settings-form-draft-Dy10ldo8.js";import{Ns as l,Pl as u,Qt as d,Xt as f,Yt as p,Zt as m,jo as h,xs as g}from"./index-CPTLS-Zn.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-Du5eAgFS.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!h()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.task===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=o(s(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(m),[r,i]=(0,x.useState)(null),[a,c]=(0,x.useState)(!1),l=async t=>{if(!t){n(d({enabled:!1})),i(null);return}c(!0);try{let t=await p();if(t!==`granted`){i(t===`unsupported`?e.unsupported:e.denied);return}n(d({enabled:!0})),i(await f(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},h=e=>{n(d(e))};return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:e.pageTitle}),(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(u,{className:`size-4 text-accent`,strokeWidth:1.75}),e.title]}),(0,C.jsx)(`p`,{className:`mb-4 text-sm text-fg-muted`,children:e.description}),(0,C.jsx)(`div`,{className:`space-y-2`,children:[[`enabled`,e.enabled,e.enabledDesc],[`completed`,e.completed,e.completedDesc],[`failed`,e.failedRuns,e.failedRunsDesc]].map(([e,n,r])=>(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,C.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?l(t.target.checked):h({[e]:t.target.checked})}})]},e))}),r?(0,C.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,role:`status`,children:r}):null,(0,C.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:e.limitation})]})]})}async function T(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function E(e,t,n){return e.task===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.task===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.task===`opened-settings`?t.openedSettings:e.status===`granted`?e.task===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.task===`opened-settings`?t.openedSettings:e.status===`granted`?e.task===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.task===`opened-settings`?t.openedSettings:e.status===`granted`?e.task===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var A=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function j(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||A.has(e)?t===`unknown`:!1}function M(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:A.has(e)?t===`denied`:!0}var N=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function P(e){return e===`linux`?N:N.filter(t=>!t.platforms||t.platforms.includes(e))}function F(e,t){let n=o(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function I(e,t,n){let r=o(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var L={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function R(){let e=s(e=>e.language),t=o(e).systemSettings,[n,u]=(0,x.useReducer)(c,L),{behavior:d,perms:f,loadError:p,permFeedback:m,permBusy:A,refreshing:N}=n,R=typeof window<`u`?window.electronAPI?.system:void 0,z=(0,x.useCallback)(async e=>{if(R){u({type:`patch`,patch:{loadError:null}});try{u({type:`patch`,patch:{behavior:await R.getBehavior(),perms:await R.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:t.refreshDone}:{}}})}catch(t){u({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[R,t.refreshDone]),B=(0,x.useCallback)(async()=>{if(!(N||A)){u({type:`patch`,patch:{refreshing:!0}});try{await z({showRefreshFeedback:!0})}finally{u({type:`patch`,patch:{refreshing:!1}})}}},[z,A,N]);if((0,x.useEffect)(()=>{let e=new Set([t.refreshDone,t.openSettingsDone,t.openSettingsFailed,t.desktopNotify.testShown]);if(!m||!e.has(m))return;let n=window.setTimeout(()=>{u({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(n)},[m,t.openSettingsDone,t.openSettingsFailed,t.refreshDone,t.desktopNotify.testShown]),(0,x.useEffect)(()=>{h()&&R&&z()},[R,z]),!h()||!R)return(0,C.jsx)(w,{});let V=async e=>{try{let{behavior:t}=await R.setBehavior(e);u({type:`patch`,patch:{behavior:t}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},H=async e=>{if(!e){await V({notifyEnabled:!1});return}u({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(t.desktopNotify.testTitle,t.desktopNotify.testBody);if(e===`unsupported`){u({type:`patch`,patch:{permFeedback:t.notificationsFeedback.unsupported}});return}if(e===`denied`){u({type:`patch`,patch:{permFeedback:t.desktopNotify.denied}});return}if(e==="default"){u({type:`patch`,patch:{permFeedback:t.notificationsFeedback.default}});return}await V({notifyEnabled:!0}),u({type:`patch`,patch:{perms:await R.getPermissions()}}),u({type:`patch`,patch:{permFeedback:t.desktopNotify.testShown}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},U=async e=>{u({type:`patch`,patch:{permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{(await R.openPrivacy(e)).ok?u({type:`patch`,patch:{permFeedback:t.openSettingsDone}}):u({type:`patch`,patch:{permFeedback:t.openSettingsFailed}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},W=async()=>{u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await R.requestMicrophone(),n=await T();u({type:`patch`,patch:{perms:await R.getPermissions()}}),u({type:`patch`,patch:{permFeedback:E(e,n,t.permFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},G=async()=>{if(R.requestAccessibility){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await R.requestAccessibility();u({type:`patch`,patch:{perms:await R.getPermissions()}}),u({type:`patch`,patch:{permFeedback:D(e,t.accessibilityFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},K=async()=>{if(R.requestNotifications){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await R.requestNotifications();u({type:`patch`,patch:{perms:await R.getPermissions()}}),u({type:`patch`,patch:{permFeedback:O(e,t.notificationsFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(R.requestScreen){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await R.requestScreen();u({type:`patch`,patch:{perms:await R.getPermissions()}}),u({type:`patch`,patch:{permFeedback:k(e,t.screenFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},J=d?d.platform===`win32`?t.permissionsHintWin:d.platform===`linux`?t.permissionsHintLinux:d.platform===`darwin`?t.permissionsHintDarwin:t.permissionsHint:t.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:t.title}),p?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:p}):null,m?(0,C.jsx)(`p`,{className:i(`text-sm`,m===t.refreshDone||m===t.openSettingsDone||m===t.permFeedback.granted||m===t.permFeedback.alreadyGranted||m===t.accessibilityFeedback.granted||m===t.accessibilityFeedback.alreadyGranted||m===t.notificationsFeedback.granted||m===t.notificationsFeedback.alreadyGranted||m===t.screenFeedback.granted||m===t.screenFeedback.alreadyGranted||m===t.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:m}):null,(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(g,{className:`size-4 text-accent`,strokeWidth:1.75}),t.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.openAtLogin,onChange:e=>{V({openAtLogin:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.keepAwakePreferred,onChange:e=>{V({keepAwakePreferred:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d||A,checked:!!d?.notifyEnabled,onChange:e=>{H(e.target.checked)}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.notifySoundEnabled,onChange:e=>{V({notifySoundEnabled:e.target.checked})}})]})]})]}),d&&f?(0,C.jsxs)(`section`,{className:y(),children:[(0,C.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:J}),d.platform===`darwin`&&!d.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:t.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:N||A,"aria-busy":N,className:i(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,a.press),onClick:()=>void B(),children:[(0,C.jsx)(l,{className:i(`size-3.5`,N&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),N?t.refreshing:t.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(d.platform).map(({key:n,pane:o})=>{let s=F(e,f[n]),c=t.perm[n],l=f[n]===`unknown`?I(e,n,d.platform):null;return c?(0,C.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:c.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${s.className}`,children:s.label}),l?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[n===`notifications`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,a.press),onClick:()=>void K(),children:t.requestAccess}):null,n===`microphone`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,a.press),onClick:()=>void W(),children:t.requestAccess}):null,n===`accessibility`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,a.press),onClick:()=>void G(),children:t.requestAccess}):null,n===`screen`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,a.press),onClick:()=>void q(),children:t.requestAccess}):null,M(n,f[n],d.platform)?(0,C.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,a.press),onClick:()=>void U(o),children:[t.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):null})})]}):null]})}export{R as SystemSettingsPanel};
@@ -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{d as i,f as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as s,r as c}from"./popover-select-BzdnTy3h.js";import{t as l}from"./external-link-DjqjBmc3.js";import{f as u,u as ee}from"./markdown-view-B4iBrVWK.js";import{t as te}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{l as p,n as ne}from"./locale-store-81Gv0wwo.js";import{i as m,n as re,o as ie,r as h,s as ae,t as g}from"./dist-BPoKqzeH.js";import{A as _,Aa as v,Bl as oe,Gt as se,H as y,K as ce,Kt as le,M as b,R as x,Va as S,Vc as C,Vs as w,W as T,Xc as E,Yi as D,Zr as O,ci as ue,dl as k,dr as A,fa as j,fr as de,gr as fe,ka as pe,mr as me,n as he,pr as ge,q as _e,qs as ve,qt as ye,rc as be,si as M,ul as N,vl as xe}from"./index-CPTLS-Zn.js";import{t as Se}from"./date-picker-Dvjoq2mB.js";import{t as Ce}from"./dependency-picker-zv1OIhk3.js";var P=e(t(),1),F=n();function we(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Te(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}var I=r();function Ee(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function De(){let e=(0,F.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,I.jsx)(v,{className:`h-32 rounded-2xl`}),(0,I.jsx)(v,{className:`h-52 rounded-2xl`}),(0,I.jsx)(v,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Oe(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function ke(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var Ae=`xopc.taskDetail.chatPanelPercent`,L=42;function je(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?L:Math.min(r,Math.max(n,e))}function Me(){try{let e=Number(window.localStorage.getItem(Ae));return Number.isFinite(e)&&e>=30&&e<=60?e:L}catch{return L}}function Ne(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`paused`:e.operationalState}function R(e){let t=(0,F.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,I.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let a;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>{let t=i?.get(e)??`unverified`;return(0,I.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,I.jsx)(t===`passed`?xe:t===`failed`?k:N,{className:t===`passed`?`mt-1 size-4 shrink-0 text-success`:t===`failed`?`mt-1 size-4 shrink-0 text-danger`:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,I.jsx)(`span`,{children:e})]},e)},t[5]=i,t[6]=e),a=n.map(e),t[2]=n,t[3]=i,t[4]=a}else a=t[4];let o;return t[7]===a?o=t[8]:(o=(0,I.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Pe({taskId:e,presentation:t,backgroundPath:n}){let[r]=a(),i=ne(e=>e.language),te=p(e=>e.token),m=(0,P.useMemo)(()=>_e(i),[i]),re=S(e=>e.setPageHeader),ie=S(e=>e.clearPageHeader),{data:h,error:ae,mutate:g,lastChange:v,conversationLoading:ue,conversationError:k}=_(e),[ye,M]=(0,P.useState)(null),[N,F]=(0,P.useState)(!1),[Pe,z]=(0,P.useState)([]),[B,V]=(0,P.useState)(null),[Fe,Ie]=(0,P.useState)([]),[Le,H]=(0,P.useState)(!1),[U,W]=(0,P.useState)(``),[Re,G]=(0,P.useState)(!1),[ze,Be]=(0,P.useState)(``),[K,Ve]=(0,P.useState)(Me),[He,Ue]=(0,P.useState)(!1),We=(0,P.useRef)(null),Ge=(0,P.useRef)(!1),Ke=(0,P.useRef)(!1),qe=(0,P.useRef)(``),Je=(0,P.useRef)(null),Ye=(0,P.useRef)(null),Xe=(0,P.useRef)(null),[Ze,q]=(0,P.useState)(null),[Qe,$e]=(0,P.useState)(null),et=h?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,tt=(0,P.useMemo)(()=>ee(r.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[r]);(0,P.useEffect)(()=>{M(null),q(null),H(!1),G(!1),$e(null)},[e]),(0,P.useEffect)(()=>{let e=!0;return pe().then(t=>{e&&Ie(t.items)}).catch(()=>void 0),()=>{e=!1}},[te]),(0,P.useEffect)(()=>{if(!v||v.source===`user`)return;$e(v);let e=window.setTimeout(()=>$e(null),3500);return()=>window.clearTimeout(e)},[v]),(0,P.useEffect)(()=>{let t=h?.task.projectId,n=h?.dependencies??[];if(!t){Xe.current=null,V(null),z(n);return}Xe.current!==t&&(Xe.current=t,V(null));let r=!0;return j(t).then(t=>{if(!r)return;V(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});z([...i.values()])}).catch(()=>{r&&z(n)}),()=>{r=!1}},[et,h?.task.projectId,e]);let J=async t=>{if(h){F(!0),M(null);try{await g(await b(e,t,h.task.version),{revalidate:!1})}catch{M(m.actionFailed)}finally{F(!1)}}},Y=async t=>{if(!h)return!1;F(!0),M(null);try{return await g(T(e,t,h.task.version),{optimisticData:Te(h,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return M(m.actionFailed),!1}finally{F(!1)}},nt=async()=>{if(!h)return;if(Ge.current){Ge.current=!1;return}let e=U.trim(),t=Je.current;if(we(t,h.task.version,h.task.title,e)){q(`title`);return}if(!e||e===h.task.title){W(h.task.title),H(!1);return}await Y({title:e})&&(q(null),H(!1))},rt=async()=>{if(!h)return;if(Ke.current){Ke.current=!1;return}let e=ze.trim(),t=Ye.current;if(we(t,h.task.version,h.task.body??``,e)){q(`description`);return}if(ze===qe.current||e===(h.task.body??``).trim()){G(!1);return}await Y({body:e||null})&&(q(null),G(!1))},it=async e=>{if(!(!h||e===h.task.phase)){if(h.task.phase===`closed`){await J({type:`reopen`,phase:e===`closed`?`ready`:e});return}if(e===`closed`){await J({type:`close`,resolution:`done`});return}await J({type:`move`,phase:e})}},X=(0,P.useCallback)(e=>{Ve(e);try{window.localStorage.setItem(Ae,String(e))}catch{}},[]),at=(0,P.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=We.current?.clientWidth??0;X(je(e.key===`Home`?L:K+(e.key===`ArrowLeft`?2:-2),t))},[K,X]),ot=(0,P.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=We.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),Ue(!0);let i=K,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=je((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}Ue(!1),X(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[K,X]),st=async t=>{if(h){F(!0),M(null);try{await g(await ce(e,t,h.task.version),{revalidate:!1})}catch{M(m.dependencyUpdateFailed)}finally{F(!1)}}},ct=async t=>{if(!(!h||!t||t===h.conversation.currentExecutorAgentId)){F(!0),M(null);try{await g(await x(e,t,h.task.version),{revalidate:!1})}catch{M(m.actionFailed)}finally{F(!1)}}};if((0,P.useLayoutEffect)(()=>{if(t!==`modal`)return re({startExtra:(0,I.jsx)(o,{to:tt,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":m.backToWork,children:(0,I.jsx)(oe,{className:`size-4`})}),main:h?(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:B?`${B} / ${m.taskLabel}`:m.taskLabel}),(0,I.jsx)(`p`,{className:`text-xs text-fg-muted`,children:m.detailStatuses[Ne(h)]})]}):null,end:null}),ie},[ie,m.backToWork,m.detailStatuses,m.taskLabel,h,t,B,tt,re]),ae&&!h)return(0,I.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:m.taskNotFound});if(!h)return(0,I.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,I.jsx)(De,{})});let lt=h.waits[0],ut=lt?.kind===`paused`?lt:void 0,Z=h.receipts[0],dt=m.detailStatuses[Ne(h)],ft=m.detailStatusDescriptions[Ne(h)],pt=h.task.body?.trim()||h.task.contract?.objective.trim(),mt=new Map(Z?.verification.checks.map(e=>[e.criterion,e.status])),ht=h.allowedCommands.includes(`mark_ready`),gt=h.allowedCommands.includes(`start`),_t=h.allowedCommands.includes(`add_wait`),vt=h.task.phase===`review`&&h.allowedCommands.includes(`close`),yt=h.allowedCommands.includes(`reopen`),bt=h.conversation.activeSessionKey,Q=h.conversation.currentExecutorAgentId??h.task.delegateAgentId??h.task.ownerId,xt=Fe.find(e=>e.id===Q),St=h.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Ct=h.task.contract?.acceptanceCriteria??[],wt=Ct.filter(e=>mt.get(e)===`passed`).length,Tt=h.task.contract?.expectedOutputs??[],Et=h.task.contract?.constraints??[],Dt=h.task.contract?.approvalRequired??[],Ot=h.task.contract?.assumptions??[],kt=h.task.contract?.risks??[],$=(...e)=>!!Qe?.changedFields.some(t=>e.includes(t)),At=e=>t===`modal`&&n?le(n,e):u(`/tasks/${e}`,tt),jt=h.allowedCommands.includes(`move`),Mt=e=>e!==h.task.phase&&(e===`closed`?!vt:h.task.phase===`closed`?!yt:!jt),Nt=(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ht?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`mark_ready`}),children:[(0,I.jsx)(w,{className:`size-4`}),m.scheduleTask]}):null,ut?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`resolve_wait`,waitId:ut.id}),children:[(0,I.jsx)(w,{className:`size-4`}),m.resumeTask]}):null,!lt&&gt&&Q?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`start`,executor:{kind:`agent`,agentId:Q}}),children:[(0,I.jsx)(w,{className:`size-4`}),m.runTask]}):null,vt?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`close`,resolution:`done`}),children:[(0,I.jsx)(xe,{className:`size-4`}),m.approveTask]}):null,yt?(0,I.jsxs)(f,{variant:`primary`,disabled:N,onClick:()=>void J({type:`reopen`,phase:`ready`}),children:[(0,I.jsx)(w,{className:`size-4`}),m.reopenTask]}):null,!lt&&_t?(0,I.jsxs)(f,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:N,onClick:()=>void J({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,I.jsx)(ve,{className:`size-4`}),m.pauseTask]}):null,h.task.phase===`closed`?null:(0,I.jsxs)(me,{children:[(0,I.jsx)(fe,{asChild:!0,children:(0,I.jsx)(f,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:N,"aria-label":m.moreActions,children:(0,I.jsx)(E,{className:`size-4`,"aria-hidden":!0})})}),(0,I.jsx)(ge,{children:(0,I.jsx)(A,{align:`end`,sideOffset:6,className:`z-[100] min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,I.jsx)(de,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void J({type:`close`,resolution:`cancelled`}),children:m.cancelTask})})})]})]});return(0,I.jsxs)(`div`,{ref:We,className:`${t===`modal`?`flex h-full min-h-0 flex-col lg:flex-row`:`flex min-h-[calc(100dvh-8rem)] flex-col overflow-hidden lg:flex-row`} ${He?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${K}%`},children:[(0,I.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,I.jsxs)(`header`,{className:d(`px-4 pb-5`,$(`title`)&&`task-detail-live-update`),children:[(0,I.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[B?(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,I.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),B]}):null,(0,I.jsx)(`span`,{children:`/`}),(0,I.jsx)(`span`,{children:m.taskLabel}),Qe?(0,I.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:Qe.source===`agent`?i===`zh`?`Agent 刚刚更新`:`Updated by Agent`:i===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Le?(0,I.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:U,onChange:e=>W(e.target.value),onBlur:()=>void nt(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Ge.current=!0,W(h.task.title),H(!1),queueMicrotask(()=>{Ge.current=!1}))},className:`mt-3 w-full max-w-3xl rounded-lg bg-surface-hover px-3 py-2 text-2xl font-semibold leading-8 text-fg outline-none ring-2 ring-accent/30 focus:ring-accent/60`}):(0,I.jsx)(`button`,{type:`button`,className:`mt-3 block max-w-3xl rounded-lg text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{Je.current={value:h.task.title,version:h.task.version},q(null),W(h.task.title),H(!0)},children:(0,I.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:h.task.title})}),Ze===`title`?(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,I.jsx)(`span`,{children:i===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{W(h.task.title),q(null),H(!1)},children:i===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({title:U.trim()}).then(e=>{e&&(q(null),H(!1))}),children:i===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),ye?(0,I.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:ye}):null]}),(0,I.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,I.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`body`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.taskDescription}),Re?(0,I.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:ze,onChange:e=>Be(e.target.value),onBlur:()=>void rt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Ke.current=!0,Be(h.task.body??h.task.contract?.objective??``),G(!1),queueMicrotask(()=>{Ke.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,I.jsx)(`button`,{type:`button`,className:`-mx-1 mt-2 block w-[calc(100%+0.5rem)] rounded-lg px-1 py-1 text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=h.task.body??h.task.contract?.objective??``;qe.current=e,Ye.current={value:h.task.body??``,version:h.task.version},q(null),Be(e),G(!0)},children:(0,I.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:pt&&pt!==h.task.title?pt:m.noTaskDescription})}),Ze===`description`?(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,I.jsx)(`span`,{children:i===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{Be(h.task.body??``),q(null),G(!1)},children:i===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({body:ze.trim()||null}).then(e=>{e&&(q(null),G(!1))}),children:i===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),h.attention.length>0?(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-warning/10 p-4`,$(`attention`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h3`,{className:`font-medium text-fg`,children:St?m.needsAttention:m.waitingStatus}),(0,I.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:h.attention.map((e,t)=>(0,I.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`contract`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.taskDefinition}),(0,I.jsxs)(`div`,{className:`mt-5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:m.successDefinition}),Ct.length>0?(0,I.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:m.criteriaProgress.replace(`{{verified}}`,String(wt)).replace(`{{total}}`,String(Ct.length))}):null]}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Ct,empty:m.noDefinition,verificationByCriterion:mt})})]}),Tt.length>0?(0,I.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:m.expectedOutputs}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Tt,empty:m.noDefinition})})]}):null,Et.length>0?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:m.constraints}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Et,empty:m.noDefinition})})]}):null,Dt.length>0?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:m.approvalRequired}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Dt,empty:m.noDefinition})})]}):null,Ot.length>0?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:m.contextAssumptions}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:Ot,empty:m.noDefinition})})]}):null,kt.length>0?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:m.contextRisks}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(R,{items:kt,empty:m.noDefinition})})]}):null]}),Z?(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.latestResult}),(0,I.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg`,children:Z.summary})]}),(0,I.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[m.receiptStatuses[Z.status],` · `,m.verificationStatuses[Z.verification.status]]})]}),Z.remainingWork.length>0?(0,I.jsxs)(`div`,{className:`mt-4`,children:[(0,I.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:m.remainingWork}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(R,{items:Z.remainingWork,empty:m.noRemainingWork})})]}):null,Z.nextAction?(0,I.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:m.nextAction}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Z.nextAction})]}):null,(0,I.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(f,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void y(Z.runId,`helpful`),children:m.doneWell}),(0,I.jsx)(f,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void y(Z.runId,`not_helpful`),children:m.needsFix}),Z.evidence.filter(e=>e.uri).map(e=>(0,I.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,I.jsx)(l,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),h.receipts.length>1?(0,I.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:m.executionHistory.replace(`{{count}}`,String(h.receipts.length-1))}),(0,I.jsx)(`div`,{className:`mt-3 space-y-3`,children:h.receipts.slice(1).map(e=>(0,I.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:m.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,h.context.length>0?(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`context`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.contextUsed}),(0,I.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:h.context.map(e=>(0,I.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[m.contextRoleLabels[e.role],` · `,m.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,I.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,I.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,I.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-subtle p-4`,$(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.taskProperties}),(0,I.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.taskPhase}),(0,I.jsx)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:h.task.phase,disabled:N,onChange:e=>void it(e.target.value),children:[`backlog`,`ready`,`active`,`review`,`closed`].map(e=>(0,I.jsx)(c,{value:e,disabled:Mt(e),children:Ee(e,i)},e))})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.priority}),(0,I.jsx)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:h.task.priority,disabled:N,onChange:e=>void Y({priority:e.target.value}),children:[`low`,`normal`,`high`,`critical`].map(e=>(0,I.jsx)(c,{value:e,children:m.priorityLabels[e]},e))})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.dueDate}),(0,I.jsx)(Se,{disabled:N,value:Oe(h.task.dueAt),onChange:e=>void Y({dueAt:ke(e)}),ariaLabel:m.dueDate})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.executorLabel}),(0,I.jsxs)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:h.conversation.currentExecutorAgentId??``,disabled:N,onChange:e=>void ct(e.target.value),children:[(0,I.jsx)(c,{value:``,disabled:!0,children:m.unassigned}),Fe.map(e=>(0,I.jsx)(c,{value:e.id,children:e.name||e.id},e.id))]})]}),B?(0,I.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,I.jsx)(`span`,{children:m.projectLabel}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,I.jsx)(C,{className:`size-3.5`}),B]})]}):null]}),(0,I.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,I.jsx)(`p`,{children:dt}),(0,I.jsx)(`p`,{children:ft}),(0,I.jsx)(`p`,{className:`mt-2`,children:m.updatedAt.replace(`{{date}}`,O(h.task.updatedAt,i))})]})]}),(0,I.jsxs)(`section`,{className:d(`rounded-xl bg-surface-panel p-4`,$(`dependencies`)&&`task-detail-live-update`),children:[(0,I.jsx)(`h2`,{className:`font-medium text-fg`,children:m.taskRelations}),(0,I.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.dependencies}),(0,I.jsx)(Ce,{borderless:!0,candidates:Pe,selectedIds:h.dependencies.map(e=>e.id),disabled:N,onChange:e=>void st(e),labels:{link:m.linkDependencies,linked:m.linkedDependencies,searchPlaceholder:m.dependencySearchPlaceholder,noMatches:m.noDependencyMatches,noCandidates:m.noDependencyCandidates,remove:m.removeDependency}})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.dependents}),h.dependents.length>0?(0,I.jsx)(`div`,{className:`space-y-1.5`,children:h.dependents.map(e=>(0,I.jsx)(o,{to:At(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,I.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:m.noDependents})]})]})]})]})]})]}),(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(K),tabIndex:0,onPointerDown:ot,onKeyDown:at,onDoubleClick:()=>X(L),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${He?`bg-surface-hover`:``}`,children:(0,I.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,I.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:shrink-0`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,I.jsx)(`div`,{className:`min-w-0`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Q?(0,I.jsx)(D,{agentId:Q,avatar:xt?.avatar,size:28,className:`shrink-0`}):null,(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:i===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,I.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[xt?.name??Q??m.unassigned,` · `,dt]})]})]})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[Nt,bt?(0,I.jsx)(f,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,I.jsxs)(o,{to:se(e),children:[(0,I.jsx)(l,{className:`size-3.5`}),i===`zh`?`全屏`:`Full screen`]})}):null]})]}),bt?(0,I.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,I.jsx)(he,{embedded:!0,sessionKey:bt,taskId:e})}):ue?(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,I.jsxs)(`div`,{className:`max-w-xs`,children:[(0,I.jsx)(be,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,I.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):k?(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,I.jsxs)(`div`,{className:`max-w-xs`,children:[(0,I.jsx)(be,{className:`mx-auto size-8 text-danger`}),(0,I.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,I.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:k instanceof Error?k.message:String(k)})]})}):(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,I.jsxs)(`div`,{className:`max-w-xs`,children:[(0,I.jsx)(be,{className:`mx-auto size-8 text-fg-subtle`}),(0,I.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,I.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:i===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]})}function z(){let e=(0,F.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,I.jsx)(Pe,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function B(e){let t=(0,F.c)(43),{taskId:n,backgroundPath:r,onClose:i}=e,a=ne(Re),o=ue(W),s=ue(U),c=ue(H),l=M(Le),u=M(Ie),ee=o?s:0,d;t[0]!==i||t[1]!==u?(d=e=>{e||(u(null),i())},t[0]=i,t[1]=u,t[2]=d):d=t[2];let f=a===`zh`?`关闭任务详情`:`Close task details`,p;t[3]!==i||t[4]!==u?(p=()=>{u(null),i()},t[3]=i,t[4]=u,t[5]=p):p=t[5];let _;t[6]!==f||t[7]!==p?(_=(0,I.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":f,onClick:p}),t[6]=f,t[7]=p,t[8]=_):_=t[8];let v=o?`true`:`false`,oe=`${ee/2}px`,se=`${ee}px`,y;t[9]!==oe||t[10]!==se?(y={"--task-detail-workspace-offset":oe,"--task-detail-workspace-width":se},t[9]=oe,t[10]=se,t[11]=y):y=t[11];let ce=y,le=a===`zh`?`任务详情`:`Task details`,b;t[12]===le?b=t[13]:(b=(0,I.jsx)(ae,{className:`font-medium text-fg`,children:le}),t[12]=le,t[13]=b);let x=a===`zh`?`查看并操作任务详情`:`View and manage task details`,S;t[14]===x?S=t[15]:(S=(0,I.jsx)(m,{className:`sr-only`,children:x}),t[14]=x,t[15]=S);let C=a===`zh`?`关闭任务详情`:`Close task details`,w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,I.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]===C?T=t[18]:(T=(0,I.jsx)(re,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":C,children:w}),t[17]=C,t[18]=T);let E;t[19]!==b||t[20]!==S||t[21]!==T?(E=(0,I.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[b,S,T]}),t[19]=b,t[20]=S,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==r||t[24]!==n?(D=(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,I.jsx)(Pe,{taskId:n,presentation:`modal`,backgroundPath:r})}),t[23]=r,t[24]=n,t[25]=D):D=t[25];let O;t[26]!==E||t[27]!==D||t[28]!==v||t[29]!==ce?(O=(0,I.jsxs)(h,{className:`task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl bg-surface-base shadow-float focus:outline-none`,"data-workspace-panel-open":v,style:ce,onEscapeKeyDown:Fe,onInteractOutside:V,children:[E,D]}),t[26]=E,t[27]=D,t[28]=v,t[29]=ce,t[30]=O):O=t[30];let k;t[31]!==l||t[32]!==o||t[33]!==s||t[34]!==c?(k=l?(0,I.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:o?s:0},children:(0,I.jsx)(ye,{allowOutsideChat:!0,sessionKey:c??void 0})}):null,t[31]=l,t[32]=o,t[33]=s,t[34]=c,t[35]=k):k=t[35];let A;t[36]!==O||t[37]!==k||t[38]!==_?(A=(0,I.jsxs)(ie,{children:[_,O,k]}),t[36]=O,t[37]=k,t[38]=_,t[39]=A):A=t[39];let j;return t[40]!==d||t[41]!==A?(j=(0,I.jsx)(g,{modal:!1,open:!0,onOpenChange:d,children:A}),t[40]=d,t[41]=A,t[42]=j):j=t[42],j}function V(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Fe(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Ie(e){return e.setPath}function Le(e){return e.path}function H(e){return e.sessionKeyOverride}function U(e){return e.widthPx}function W(e){return e.open}function Re(e){return e.language}export{B as TaskDetailModal,z as TaskDetailPage};
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-CnamlR07.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#ffffff`,emerald:`#f0fdf4`,mono:`#ffffff`,clay:`#fffaf0`},dark:{default:`#0a0a0a`,emerald:`#000000`,mono:`#101010`,clay:`#0a1a1a`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e===`cal`?`mono`:e==="default"||e===`emerald`||e===`mono`||e===`clay`?e:n}function l(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function u(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}l(o(t),r,!1)}catch{l(o(`system`),`default`,!1)}}var d=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();l(r,a,r!==i),e({preference:n,resolved:r})},setColorScheme:n=>{let{resolved:r}=t();l(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function f(){let{preference:e,colorScheme:t}=d.getState(),n=o(e);l(n,t,!1),d.setState({resolved:n})}function p(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=d.getState();if(e!==`system`)return;let n=o(`system`),r=d.getState().resolved;l(n,t,n!==r),d.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{d as i,p as n,f as r,u as t};
1
+ import{p as e}from"./locale-store-81Gv0wwo.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#ffffff`,emerald:`#f0fdf4`,mono:`#ffffff`,clay:`#fffaf0`},dark:{default:`#0a0a0a`,emerald:`#000000`,mono:`#101010`,clay:`#0a1a1a`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e===`cal`?`mono`:e==="default"||e===`emerald`||e===`mono`||e===`clay`?e:n}function l(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function u(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}l(o(t),r,!1)}catch{l(o(`system`),`default`,!1)}}var d=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();l(r,a,r!==i),e({preference:n,resolved:r})},setColorScheme:n=>{let{resolved:r}=t();l(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function f(){let{preference:e,colorScheme:t}=d.getState(),n=o(e);l(n,t,!1),d.setState({resolved:n})}function p(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=d.getState();if(e!==`system`)return;let n=o(`system`),r=d.getState().resolved;l(n,t,n!==r),d.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{d as i,p as n,f as r,u 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{t as i}from"./check-DUBLcKHA.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./locale-store-CnamlR07.js";import{Dl as c}from"./index-DRrjYYzZ.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=s(f)===`zh`,m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:p?`自动保存`:`Autosave`,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=o(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(a,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./check-DUBLcKHA.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./locale-store-81Gv0wwo.js";import{bl as c}from"./index-CPTLS-Zn.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=s(f)===`zh`,m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:p?`自动保存`:`Autosave`,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=o(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(a,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};