@xopcai/xopc 0.0.413 → 0.0.414

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 (204) 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/{agent-avatar-dicebear-BT6oqCMD.js → agent-avatar-dicebear-ClobpdW3.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BFmRRD_4.js → agent-defaults-settings-panel-mf0jgEPE.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-CKhZ4UYQ.js +77 -0
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-BdCgtTfT.js → app-management-settings-panel-CLunLNGp.js} +1 -1
  7. package/dist/gateway/static/root/assets/app-window-DXFNqt_0.js +1 -0
  8. package/dist/gateway/static/root/assets/{appearance-settings-C3-hCFlF.js → appearance-settings-DBEgoE9g.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-BZ_MaQJf.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BviFGCy4.js → archive-plugin-JElK4Goq.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-CfzazXE5.js → automations-page-CZ0UqwyU.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-workspace-CHUDHNVL.js +8 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-Dp-gtJEk.js → binary-plugins-CXFawow6.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-D-DEPdpi.js → block-editor-BoduwSYI.js} +30 -30
  15. package/dist/gateway/static/root/assets/browser-automations-page-DStDm9y1.js +3 -0
  16. package/dist/gateway/static/root/assets/browser-settings-page-6I4oetKt.js +3 -0
  17. package/dist/gateway/static/root/assets/capabilities-page-C-EecWbS.js +2 -0
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-BQoCPk3x.js +8 -0
  19. package/dist/gateway/static/root/assets/{capability-header-actions-CP2fI9Fe.js → capability-header-actions-BasrAWA0.js} +1 -1
  20. package/dist/gateway/static/root/assets/{channels-DWlrUKBr.js → channels-BKf_-Mdt.js} +1 -1
  21. package/dist/gateway/static/root/assets/{chat-terminal-dock-BL3tFntQ.js → chat-terminal-dock-CwQbzcZ_.js} +1 -1
  22. package/dist/gateway/static/root/assets/chevron-down-ccbiQQz_.js +1 -0
  23. package/dist/gateway/static/root/assets/{computer-settings-page-DEQ5GYfC.js → computer-settings-page-DNWeJKfF.js} +1 -1
  24. package/dist/gateway/static/root/assets/{connector-service-page-CecwMnC5.js → connector-service-page-CxHgC5RM.js} +1 -1
  25. package/dist/gateway/static/root/assets/connectors-page-CUBg8spT.js +1 -0
  26. package/dist/gateway/static/root/assets/{date-picker-N5jnlvPs.js → date-picker-CXxLbLJb.js} +1 -1
  27. package/dist/gateway/static/root/assets/dependency-picker-DVuWMrSj.js +1 -0
  28. package/dist/gateway/static/root/assets/desktop-pet-KbVLtAlO.js +1 -0
  29. package/dist/gateway/static/root/assets/desktop-pet-settings-BDlg9g4s.js +1 -0
  30. package/dist/gateway/static/root/assets/device-pairing-wizard-PmP_vGem.js +1 -0
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-CbMbPimD.js → directory-picker-path-field-a7xEodzo.js} +1 -1
  32. package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +1 -0
  33. package/dist/gateway/static/root/assets/{extension-debug-page-OE1nJMQ8.js → extension-debug-page-CHelH5u_.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-BEomiKhy.js → extension-page-CrVHmS9-.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-BFOjQeSX.js → extension-settings-page-CiMybi0r.js} +1 -1
  36. package/dist/gateway/static/root/assets/eye-CABVeTq0.js +1 -0
  37. package/dist/gateway/static/root/assets/folder-open-CyzJ19I9.js +1 -0
  38. package/dist/gateway/static/root/assets/{gateway-settings-CR4CsfNN.js → gateway-settings-DnrQ28E2.js} +1 -1
  39. package/dist/gateway/static/root/assets/{highlight-code-6ONPRH5r.js → highlight-code-AMjU04kR.js} +1 -1
  40. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-EJ9Kg4iQ.js → highlighted-body-KQOG7T2V-8ACAVktj.js} +1 -1
  41. package/dist/gateway/static/root/assets/home-page-pTwVME-g.js +2 -0
  42. package/dist/gateway/static/root/assets/{image-generation-api-D0HNic89.js → image-generation-api-CVBaWmrV.js} +1 -1
  43. package/dist/gateway/static/root/assets/imports-page-C5IP3e6d.js +1 -0
  44. package/dist/gateway/static/root/assets/{index-D_7q1UkI.css → index-BLL0wKRZ.css} +1 -1
  45. package/dist/gateway/static/root/assets/index-ygkHNYyo.js +710 -0
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Cmi-2SIh.js → keyboard-shortcuts-settings-BhU6VYvd.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-Cwl6EvuX.js +1 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-jgaogH9Z.js → local-apps-page-DcP1Bdlk.js} +1 -1
  49. package/dist/gateway/static/root/assets/logs-page-CS3hcTOq.js +2 -0
  50. package/dist/gateway/static/root/assets/{management-settings-Dc1opXVr.js → management-settings-DC-Y_-GP.js} +1 -1
  51. package/dist/gateway/static/root/assets/{media-plugins-BRS9puQV.js → media-plugins-BnPpcJ2J.js} +1 -1
  52. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-vckgHpON.js +1 -0
  53. package/dist/gateway/static/root/assets/note-detail-panel-C7u4dxEk.js +5 -0
  54. package/dist/gateway/static/root/assets/note-image-lightbox-jvqYtySx.js +1 -0
  55. package/dist/gateway/static/root/assets/notes-page-Bs7F5Hpf.js +8 -0
  56. package/dist/gateway/static/root/assets/page-context-capture-button-DO_yhXS1.js +1 -0
  57. package/dist/gateway/static/root/assets/personal-page-BexL2-PQ.js +1 -0
  58. package/dist/gateway/static/root/assets/{phone-dependencies-card-DhEsfEUN.js → phone-dependencies-card-ChFtdFhA.js} +1 -1
  59. package/dist/gateway/static/root/assets/phone-model-picker-CZoIAQ1j.js +1 -0
  60. package/dist/gateway/static/root/assets/phone-settings-page-DRyK0nHH.js +1 -0
  61. package/dist/gateway/static/root/assets/{plugin-details-dialog-1BwvmKZi.js → plugin-details-dialog-B-N61jJH.js} +1 -1
  62. package/dist/gateway/static/root/assets/{preview-open-alternatives-DaTaSKox.js → preview-open-alternatives-FGqN-mQx.js} +1 -1
  63. package/dist/gateway/static/root/assets/{product-open-page-wYlC0IVZ.js → product-open-page-CwnHLfdL.js} +1 -1
  64. package/dist/gateway/static/root/assets/{product-preview-content-Bxur-p6S.js → product-preview-content-BD6k5hF9.js} +1 -1
  65. package/dist/gateway/static/root/assets/project-detail-page-DtKmFBml.js +7 -0
  66. package/dist/gateway/static/root/assets/projects-page-CFZIz9mc.js +1 -0
  67. package/dist/gateway/static/root/assets/remote-access-hub-CWEc7W0m.js +1 -0
  68. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DXNidliV.js → runtime-tools-settings-panel-q_oswAdV.js} +1 -1
  69. package/dist/gateway/static/root/assets/{schema-form-DeSZ7SiO.js → schema-form-DoVn5jJK.js} +1 -1
  70. package/dist/gateway/static/root/assets/sessions-page-BuPqNxpd.js +1 -0
  71. package/dist/gateway/static/root/assets/settings-advanced-gate-QTVDCGJG.js +1 -0
  72. package/dist/gateway/static/root/assets/{settings-form-section-BNYQjZU4.js → settings-form-section-Ce8vVv-9.js} +1 -1
  73. package/dist/gateway/static/root/assets/{settings-page-29Ix0jSQ.js → settings-page-DP2w3ejC.js} +1 -1
  74. package/dist/gateway/static/root/assets/{setup-status-panel-COQZgKX9.js → setup-status-panel-ZmlE8jIE.js} +1 -1
  75. package/dist/gateway/static/root/assets/{share-preview-page-CwMRULXc.js → share-preview-page-DV4dKrmG.js} +1 -1
  76. package/dist/gateway/static/root/assets/shares-settings-CtNxWqW-.js +1 -0
  77. package/dist/gateway/static/root/assets/{skill-api-xfB5fUAh.js → skill-api-DTdejInH.js} +1 -1
  78. package/dist/gateway/static/root/assets/{skill-reload-api-Bq-3_MCt.js → skill-reload-api-Egaf8PqZ.js} +1 -1
  79. package/dist/gateway/static/root/assets/skills-page-C6FKxf4J.js +2 -0
  80. package/dist/gateway/static/root/assets/{system-settings-panel-DRJu1ehM.js → system-settings-panel-Baxkhov7.js} +1 -1
  81. package/dist/gateway/static/root/assets/task-detail-page-C77-rpkt.js +2 -0
  82. package/dist/gateway/static/root/assets/{task-result-evidence-C4o_Yue_.js → task-result-evidence-DIGSC4qF.js} +1 -1
  83. package/dist/gateway/static/root/assets/{tracing-settings-page-CYslh-Pu.js → tracing-settings-page-BaU8frtc.js} +1 -1
  84. package/dist/gateway/static/root/assets/{tunnel-api-Bi_kw6bv.js → tunnel-api-BCcOUsqu.js} +1 -1
  85. package/dist/gateway/static/root/assets/usage-page-BFeIbpbi.js +1 -0
  86. package/dist/gateway/static/root/assets/{use-autosave-BkB9uD93.js → use-autosave-C1X47WVb.js} +1 -1
  87. package/dist/gateway/static/root/assets/user-model-page-u8zY5jea.js +2 -0
  88. package/dist/gateway/static/root/assets/{voice-api-key-field-bt8_Agih.js → voice-api-key-field-Bk4DQMTw.js} +1 -1
  89. package/dist/gateway/static/root/assets/{work-discovery-overlay-D3NG14dX.js → work-discovery-overlay-B7_NmTB5.js} +1 -1
  90. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-B2OUKOQi.js → xopc-cloud-account-card-CJ_akAvc.js} +1 -1
  91. package/dist/gateway/static/root/index.html +7 -2
  92. package/dist/package.js +1 -1
  93. package/dist/src/agent/agent-manager.js +1 -1
  94. package/dist/src/agent/background-review/run-background-review.js +1 -1
  95. package/dist/src/agent/external-tools/cliProvider.js +2 -2
  96. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  97. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  98. package/dist/src/agent/service.js +1 -1
  99. package/dist/src/agent/skills/index.js +1 -1
  100. package/dist/src/agent/skills/managed-store.js +1 -1
  101. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  102. package/dist/src/agent/tool-manuals/phone.d.ts +1 -1
  103. package/dist/src/agent/tool-manuals/phone.js +2 -2
  104. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  105. package/dist/src/agent/tools/phone-use-tool.js +2 -2
  106. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  107. package/dist/src/agent-catalog/capabilities.js +2 -2
  108. package/dist/src/agent-catalog/repository.js +1 -1
  109. package/dist/src/automations/capabilities/drafts.js +1 -1
  110. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  111. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  112. package/dist/src/capabilities/runtime/product.js +1 -1
  113. package/dist/src/cli/commands/agents.js +1 -1
  114. package/dist/src/cli/commands/extension-marketplace.js +2 -2
  115. package/dist/src/cli/commands/extension.js +2 -2
  116. package/dist/src/cli/commands/models.js +1 -1
  117. package/dist/src/cli/commands/onboard/model.js +1 -1
  118. package/dist/src/cli/commands/onboard.js +1 -1
  119. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  120. package/dist/src/config/agent-profile.js +1 -1
  121. package/dist/src/execution-environments/local-worktree-manager.js +1 -1
  122. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  123. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  124. package/dist/src/extensions/update.js +1 -1
  125. package/dist/src/gateway/agents-admin.js +2 -2
  126. package/dist/src/gateway/global-defaults-admin.js +1 -1
  127. package/dist/src/gateway/hono/routes/agents.js +1 -1
  128. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  129. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  130. package/dist/src/gateway/hono/routes/notes.js +2 -2
  131. package/dist/src/gateway/hono/routes/phone.js +25 -4
  132. package/dist/src/gateway/hono/routes/projects.js +2 -2
  133. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  134. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  135. package/dist/src/gateway/image-generation-setup.js +1 -1
  136. package/dist/src/gateway/service/config-coordinator.js +1 -1
  137. package/dist/src/gateway/service.js +2 -2
  138. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  139. package/dist/src/imports/importService.js +1 -1
  140. package/dist/src/infra/update-runner.js +1 -1
  141. package/dist/src/local-apps/service.js +1 -1
  142. package/dist/src/personal-agent/service.js +1 -1
  143. package/dist/src/phone/adb-driver.d.ts +5 -2
  144. package/dist/src/phone/adb-driver.js +25 -1
  145. package/dist/src/phone/app-access.d.ts +10 -0
  146. package/dist/src/phone/app-access.js +21 -0
  147. package/dist/src/phone/applications.d.ts +4 -0
  148. package/dist/src/phone/applications.js +49 -0
  149. package/dist/src/phone/cloud-adb.d.ts +1 -0
  150. package/dist/src/phone/cloud-adb.js +52 -2
  151. package/dist/src/phone/cloud-phones.js +2 -1
  152. package/dist/src/phone/cloud-scrcpy.js +2 -1
  153. package/dist/src/phone/contracts.d.ts +9 -1
  154. package/dist/src/phone/contracts.js +2 -1
  155. package/dist/src/phone/model-adapter.d.ts +8 -2
  156. package/dist/src/phone/model-adapter.js +14 -4
  157. package/dist/src/phone/repository.js +4 -3
  158. package/dist/src/phone/runtime.d.ts +6 -1
  159. package/dist/src/phone/runtime.js +36 -8
  160. package/dist/src/phone/scrcpy-assets.d.ts +4 -0
  161. package/dist/src/phone/scrcpy-assets.js +16 -0
  162. package/dist/src/phone/scrcpy.d.ts +1 -4
  163. package/dist/src/phone/scrcpy.js +3 -11
  164. package/dist/src/runtime-tools/archive.js +1 -1
  165. package/dist/src/tasks/capabilities/read.js +2 -2
  166. package/dist/src/tasks/capabilities/write.js +1 -1
  167. package/dist/src/tui/backends/embedded-backend.js +1 -1
  168. package/dist/src/voice/realtime/persona-context.js +1 -1
  169. package/package.json +3 -3
  170. package/dist/gateway/static/root/assets/agents-Clwskw2J.js +0 -77
  171. package/dist/gateway/static/root/assets/apps-page-DJbKg3va.js +0 -1
  172. package/dist/gateway/static/root/assets/automations-workspace-D_X0_1X3.js +0 -8
  173. package/dist/gateway/static/root/assets/browser-automations-page-BI-ep6uM.js +0 -3
  174. package/dist/gateway/static/root/assets/browser-settings-page-BTyQ4-vN.js +0 -3
  175. package/dist/gateway/static/root/assets/capabilities-page-GNS95mG9.js +0 -2
  176. package/dist/gateway/static/root/assets/capabilities-settings-panel-DBiv1HN-.js +0 -8
  177. package/dist/gateway/static/root/assets/connectors-page-BcpUvrtl.js +0 -1
  178. package/dist/gateway/static/root/assets/dependency-picker-C4jddxFl.js +0 -1
  179. package/dist/gateway/static/root/assets/desktop-pet-BCbiUNQG.js +0 -1
  180. package/dist/gateway/static/root/assets/desktop-pet-settings-CkKU0JMY.js +0 -1
  181. package/dist/gateway/static/root/assets/device-pairing-wizard--E2GQoY1.js +0 -1
  182. package/dist/gateway/static/root/assets/home-page-B9w3a6r2.js +0 -2
  183. package/dist/gateway/static/root/assets/imports-page-bxTINe-2.js +0 -1
  184. package/dist/gateway/static/root/assets/index-D1oivYvN.js +0 -710
  185. package/dist/gateway/static/root/assets/local-app-workbench-page-NGCmXpa_.js +0 -1
  186. package/dist/gateway/static/root/assets/logs-page-drrr-c2W.js +0 -2
  187. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-B--edI1I.js +0 -1
  188. package/dist/gateway/static/root/assets/note-detail-panel-C3s4-ytB.js +0 -5
  189. package/dist/gateway/static/root/assets/note-image-lightbox-D7q5-KuS.js +0 -1
  190. package/dist/gateway/static/root/assets/notes-page-qVxoErUS.js +0 -8
  191. package/dist/gateway/static/root/assets/page-context-capture-button-D_VOB2_C.js +0 -1
  192. package/dist/gateway/static/root/assets/personal-page-B-T8NzQo.js +0 -1
  193. package/dist/gateway/static/root/assets/phone-model-picker-J4mFDk21.js +0 -1
  194. package/dist/gateway/static/root/assets/phone-settings-page-BLflz8CQ.js +0 -1
  195. package/dist/gateway/static/root/assets/project-detail-page-DwowzxzD.js +0 -7
  196. package/dist/gateway/static/root/assets/projects-page-Bwvn4i_e.js +0 -1
  197. package/dist/gateway/static/root/assets/remote-access-hub-DrHisOUe.js +0 -1
  198. package/dist/gateway/static/root/assets/sessions-page-seP7t0kv.js +0 -1
  199. package/dist/gateway/static/root/assets/settings-advanced-gate-VqBu7gHu.js +0 -1
  200. package/dist/gateway/static/root/assets/shares-settings-BWaykw9E.js +0 -1
  201. package/dist/gateway/static/root/assets/skills-page-C3LfWsAZ.js +0 -2
  202. package/dist/gateway/static/root/assets/task-detail-page-XCJFP-Aa.js +0 -2
  203. package/dist/gateway/static/root/assets/usage-page-CTTmklCs.js +0 -1
  204. package/dist/gateway/static/root/assets/user-model-page-BDqguzRE.js +0 -2
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-Db4nTY5N.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/pdf-runtime-DU_sMPjG.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{f as a}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as o}from"./messages-RzwPiQNL.js";import{t as s}from"./cn-0WouolD0.js";import{i as c,n as l}from"./locale-store-JogcXC4J.js";import{t as u}from"./copy-to-clipboard-HOJ79TWv.js";import{t as d}from"./skeleton-BI5TyibZ.js";import{t as f}from"./attachment-utils-core-BIOUBrpT.js";import{As as p,Ki as m,Wi as h,Wo as g,cc as _,fi as v,js as y,pi as b,qi as x}from"./index-D1oivYvN.js";var S=e(t(),1),C=n(),w=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,T=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,E=/!\[([^\]]*)\]\[([^\]]+)\]/g;function D(e,t){let n=new Map;for(let t of e.matchAll(w))n.set(O(t[1]??``),t[2]??``);return e.replace(T,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(E,(e,r,i)=>{let a=n.get(O(i));return a?`[${r.trim()||t}](${a})`:e})}function O(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var k=r();function A(e){return(0,k.jsx)(p,{source:e.source,incomplete:!e.closed,streaming:!1,copy:!0})}function j(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function M(e){let t=(0,C.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:c,setExpanded:l}=v(),d=o(a.language),f;t[0]===d?f=t[1]:(f=async()=>{let e=await u(window.location.href);g(e?`success`:`warning`,e?d.sharesSettings.copied:d.clipboard.copyFailed)},t[0]=d,t[1]=f);let p=f,m=c&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,h;t[2]===m?h=t[3]:(h=s(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,m),t[2]=m,t[3]=h);let _;t[4]!==l||t[5]!==a.loadError||t[6]!==a.loading?(_=!a.loading&&!a.loadError?()=>l(N):void 0,t[4]=l,t[5]=a.loadError,t[6]=a.loading,t[7]=_):_=t[7];let y;t[8]===i?y=t[9]:(y=()=>window.location.assign(i),t[8]=i,t[9]=y);let x;t[10]===p?x=t[11]:(x=()=>void p(),t[10]=p,t[11]=x);let S=a.loading||!!a.loadError,w;t[12]!==x||t[13]!==S?(w={onClick:x,disabled:S},t[12]=x,t[13]=S,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==c||t[18]!==n||t[19]!==_||t[20]!==y||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:c,onToggleExpanded:_,onClose:y,share:w,openInBrowser:T},t[17]=c,t[18]=n,t[19]=_,t[20]=y,t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==a||t[25]!==E?(D=(0,k.jsx)(b,{...a,header:E}),t[24]=a,t[25]=E,t[26]=D):D=t[26];let O;return t[27]!==D||t[28]!==h?(O=(0,k.jsx)(`div`,{className:h,children:D}),t[27]=D,t[28]=h,t[29]=O):O=t[29],O}function N(e){return!e}function P(){let{token:e}=a(),t=l(e=>e.language),n=t===`zh`?L:R,[r,o]=(0,S.useState)(null),[s,u]=(0,S.useState)(j),[p,g]=(0,S.useState)(!0),[v,b]=(0,S.useState)(null),[C,w]=(0,S.useState)(null),[T,E]=(0,S.useState)(null),O=(0,S.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=m(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:h(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,S.useEffect)(()=>{if(!e){b(n.invalidLink),g(!1);return}let t=!1;return(async()=>{try{g(!0),b(null),u(j()),w(null),E(null);let r=await fetch(c(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||b(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(o(a),!a.valid){b(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(c(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){b(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&w(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let s=m(a.fileName,a.mimeType),l=h(a.fileName,s),d=x(l),p=c(`/s/${encodeURIComponent(e)}?inline=1`);if(d===`text`){if(a.fileSize>5242880){b(n.tooLarge);return}let e=await fetch(p);if(!e.ok){b(n.expired);return}let r=await e.text();t||u({...j(),textContent:r});return}if(d===`binary`){if(a.fileSize>33554432){b(n.tooLarge);return}let e=await fetch(p);if(!e.ok){b(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(l===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-Db4nTY5N.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>f;u({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,f):t,extractedTextTruncated:n});return}u({...j(),binaryBuffer:r})}}catch(e){t||b(e instanceof Error?e.message:String(e))}finally{t||g(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let N=e?c(`/s/${encodeURIComponent(e)}?dl=1`):`#`,P=e?c(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return O&&r&&e?(0,k.jsx)(M,{language:t,descriptor:O,loading:p,loadError:v,textContent:s.textContent,binaryBuffer:s.binaryBuffer,extractedText:s.extractedText,extractedTextTruncated:s.extractedTextTruncated,subtitle:(0,k.jsxs)(`span`,{className:`truncate`,children:[I(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:P,landingUrl:c(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=N},canDownload:!p&&!v}}):(0,k.jsx)(y,{children:(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,k.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,k.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):p?(0,k.jsx)(d,{className:`h-4 w-48 max-w-full`}):(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,k.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[I(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,k.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:p?(0,k.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,k.jsx)(d,{className:`h-5 w-56 max-w-full`}),(0,k.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,k.jsx)(d,{className:`h-4 w-full`}),(0,k.jsx)(d,{className:`h-4 w-11/12`}),(0,k.jsx)(d,{className:`h-4 w-10/12`}),(0,k.jsx)(d,{className:`h-4 w-3/4`})]}),(0,k.jsx)(d,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):v?(0,k.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,k.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,k.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:v})]}):r?.kind===`directory`?(0,k.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&C?(0,k.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,k.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:C.title}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(C.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(C.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),C.description?(0,k.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-inset px-4 py-3 text-sm leading-6 text-fg-muted`,children:C.description}):null,(0,k.jsx)(_,{content:D(C.markdown,n.remoteImageBlocked),className:`mt-8`,renderChart:A}),(0,k.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&T?(0,k.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,k.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,k.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:T.title}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(T.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(T.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),T.description?(0,k.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:T.description}):null]}),(0,k.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[T.messages.map(e=>(0,k.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,k.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-inset px-4 py-3`:`px-1 py-1`,children:[(0,k.jsx)(_,{content:D(e.markdown,n.remoteImageBlocked),renderChart:A}),T.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,k.jsx)(F,{attachment:e},e.id)),T.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,k.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,k.jsx)(`span`,{children:e.toolName}),(0,k.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,k.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),T.toolActivities.filter(e=>!e.messageId).map(e=>(0,k.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,k.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})})}function F(e){let t=(0,C.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,k.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,k.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=I(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,k.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function I(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var L={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},R={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{P as SharePreviewPage};
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{f as a}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as o}from"./messages-RzwPiQNL.js";import{t as s}from"./cn-0WouolD0.js";import{i as c,n as l}from"./locale-store-JogcXC4J.js";import{t as u}from"./copy-to-clipboard-HOJ79TWv.js";import{t as d}from"./skeleton-BI5TyibZ.js";import{t as f}from"./attachment-utils-core-BIOUBrpT.js";import{As as p,Ki as m,Wi as h,Wo as g,cc as _,fi as v,js as y,pi as b,qi as x}from"./index-ygkHNYyo.js";var S=e(t(),1),C=n(),w=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,T=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,E=/!\[([^\]]*)\]\[([^\]]+)\]/g;function D(e,t){let n=new Map;for(let t of e.matchAll(w))n.set(O(t[1]??``),t[2]??``);return e.replace(T,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(E,(e,r,i)=>{let a=n.get(O(i));return a?`[${r.trim()||t}](${a})`:e})}function O(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var k=r();function A(e){return(0,k.jsx)(p,{source:e.source,incomplete:!e.closed,streaming:!1,copy:!0})}function j(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function M(e){let t=(0,C.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:c,setExpanded:l}=v(),d=o(a.language),f;t[0]===d?f=t[1]:(f=async()=>{let e=await u(window.location.href);g(e?`success`:`warning`,e?d.sharesSettings.copied:d.clipboard.copyFailed)},t[0]=d,t[1]=f);let p=f,m=c&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,h;t[2]===m?h=t[3]:(h=s(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,m),t[2]=m,t[3]=h);let _;t[4]!==l||t[5]!==a.loadError||t[6]!==a.loading?(_=!a.loading&&!a.loadError?()=>l(N):void 0,t[4]=l,t[5]=a.loadError,t[6]=a.loading,t[7]=_):_=t[7];let y;t[8]===i?y=t[9]:(y=()=>window.location.assign(i),t[8]=i,t[9]=y);let x;t[10]===p?x=t[11]:(x=()=>void p(),t[10]=p,t[11]=x);let S=a.loading||!!a.loadError,w;t[12]!==x||t[13]!==S?(w={onClick:x,disabled:S},t[12]=x,t[13]=S,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==c||t[18]!==n||t[19]!==_||t[20]!==y||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:c,onToggleExpanded:_,onClose:y,share:w,openInBrowser:T},t[17]=c,t[18]=n,t[19]=_,t[20]=y,t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==a||t[25]!==E?(D=(0,k.jsx)(b,{...a,header:E}),t[24]=a,t[25]=E,t[26]=D):D=t[26];let O;return t[27]!==D||t[28]!==h?(O=(0,k.jsx)(`div`,{className:h,children:D}),t[27]=D,t[28]=h,t[29]=O):O=t[29],O}function N(e){return!e}function P(){let{token:e}=a(),t=l(e=>e.language),n=t===`zh`?L:R,[r,o]=(0,S.useState)(null),[s,u]=(0,S.useState)(j),[p,g]=(0,S.useState)(!0),[v,b]=(0,S.useState)(null),[C,w]=(0,S.useState)(null),[T,E]=(0,S.useState)(null),O=(0,S.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=m(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:h(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,S.useEffect)(()=>{if(!e){b(n.invalidLink),g(!1);return}let t=!1;return(async()=>{try{g(!0),b(null),u(j()),w(null),E(null);let r=await fetch(c(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||b(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(o(a),!a.valid){b(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(c(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){b(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&w(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let s=m(a.fileName,a.mimeType),l=h(a.fileName,s),d=x(l),p=c(`/s/${encodeURIComponent(e)}?inline=1`);if(d===`text`){if(a.fileSize>5242880){b(n.tooLarge);return}let e=await fetch(p);if(!e.ok){b(n.expired);return}let r=await e.text();t||u({...j(),textContent:r});return}if(d===`binary`){if(a.fileSize>33554432){b(n.tooLarge);return}let e=await fetch(p);if(!e.ok){b(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(l===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-Db4nTY5N.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>f;u({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,f):t,extractedTextTruncated:n});return}u({...j(),binaryBuffer:r})}}catch(e){t||b(e instanceof Error?e.message:String(e))}finally{t||g(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let N=e?c(`/s/${encodeURIComponent(e)}?dl=1`):`#`,P=e?c(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return O&&r&&e?(0,k.jsx)(M,{language:t,descriptor:O,loading:p,loadError:v,textContent:s.textContent,binaryBuffer:s.binaryBuffer,extractedText:s.extractedText,extractedTextTruncated:s.extractedTextTruncated,subtitle:(0,k.jsxs)(`span`,{className:`truncate`,children:[I(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:P,landingUrl:c(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=N},canDownload:!p&&!v}}):(0,k.jsx)(y,{children:(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,k.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,k.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):p?(0,k.jsx)(d,{className:`h-4 w-48 max-w-full`}):(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,k.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[I(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,k.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:p?(0,k.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,k.jsx)(d,{className:`h-5 w-56 max-w-full`}),(0,k.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,k.jsx)(d,{className:`h-4 w-full`}),(0,k.jsx)(d,{className:`h-4 w-11/12`}),(0,k.jsx)(d,{className:`h-4 w-10/12`}),(0,k.jsx)(d,{className:`h-4 w-3/4`})]}),(0,k.jsx)(d,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):v?(0,k.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,k.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,k.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:v})]}):r?.kind===`directory`?(0,k.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&C?(0,k.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,k.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:C.title}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(C.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(C.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),C.description?(0,k.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-inset px-4 py-3 text-sm leading-6 text-fg-muted`,children:C.description}):null,(0,k.jsx)(_,{content:D(C.markdown,n.remoteImageBlocked),className:`mt-8`,renderChart:A}),(0,k.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&T?(0,k.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,k.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,k.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:T.title}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(T.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(T.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),T.description?(0,k.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:T.description}):null]}),(0,k.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[T.messages.map(e=>(0,k.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,k.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-inset px-4 py-3`:`px-1 py-1`,children:[(0,k.jsx)(_,{content:D(e.markdown,n.remoteImageBlocked),renderChart:A}),T.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,k.jsx)(F,{attachment:e},e.id)),T.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,k.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,k.jsx)(`span`,{children:e.toolName}),(0,k.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,k.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),T.toolActivities.filter(e=>!e.messageId).map(e=>(0,k.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,k.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})})}function F(e){let t=(0,C.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,k.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,k.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=I(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,k.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function I(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var L={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},R={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{P as SharePreviewPage};
@@ -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{m as i}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{n as s,r as c}from"./popover-select-DGKUpVsz.js";import{t as l}from"./copy-Dv6d4Dvw.js";import{t as u}from"./folder-open-CyzJ19I9.js";import{t as d}from"./loader-circle-CifKLtgG.js";import{t as f}from"./messages-RzwPiQNL.js";import{t as p}from"./cn-0WouolD0.js";import{i as m,l as h,n as g,o as _}from"./locale-store-JogcXC4J.js";import{t as v}from"./copy-to-clipboard-HOJ79TWv.js";import{i as y}from"./vendor-swr-BIWyz7Rc.js";import{t as b}from"./button-aIC072nz.js";import{t as x}from"./skeleton-BI5TyibZ.js";import{n as S,r as C}from"./gateway-config-swr-DF_HV6NP.js";import{o as w}from"./agents-admin-api-CeBkHnl8.js";import{Ai as T,An as E,Bc as D,Ci as O,Ei as k,Fc as ee,Fi as A,Fl as te,Hl as j,Ic as ne,Lc as M,Mi as N,Ni as P,Oi as re,Ot as F,Pi as I,Si as L,Ti as R,Uu as z,Vc as ie,bi as B,dl as V,ea as H,fu as U,gi as ae,id as W,il as G,ji as oe,jo as se,ki as ce,ma as K,na as le,qc as ue,vd as de,vi as fe,vo as pe,xi as me,yd as he,yn as ge,zc as _e}from"./index-ygkHNYyo.js";import{t as ve}from"./number-input-DDeqHK-G.js";import{n as ye,t as be}from"./settings-page-header-CYpuTXUW.js";import{t as q}from"./settings-page-layout-B20AfmFG.js";import{t as J}from"./settings-form-section-Ce8vVv-9.js";var Y=e(t(),1),xe=n(),X={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`],noteEnabled:!0,noteMaxTotalSizeMb:250,noteMaxAttachmentCount:50,siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function Se(){return structuredClone(X)}var Z=36e5,Ce=864e5,Q=1048576;function we(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Te(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 Ee(e){let t=we(e)?e:{},n=we(t.gateway)?t.gateway:{},r=we(n.share)?n.share:{},i=we(r.directory)?r.directory:{},a=we(r.note)?r.note:{},o=we(n.siteShare)?n.siteShare:{},s=we(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):X.defaultTtlHours*Z,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):X.maxTtlDays*Ce,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):X.maxFileSizeMb*Q,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):X.directoryMaxFolderSizeMb*Q,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):X.siteDefaultTtlHours*Z,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):X.siteMaxTtlDays*Ce,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):X.siteMaxRootDirSizeMb*Q,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):X.noteMaxTotalSizeMb*Q;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/Z)),maxTtlDays:Math.max(1,Math.round(l/Ce)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):X.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/Q)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/Q)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):X.directoryMaxFileCount,inlinePreviewMimes:Te(r.inlinePreviewMimes,32).length?Te(r.inlinePreviewMimes,32):[...X.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/Q)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):X.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/Z)),siteMaxTtlDays:Math.max(1,Math.round(p/Ce)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):X.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/Q)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):X.siteMaxFileCount}}function De(e){let t=e.defaultTtlHours*Z,n=e.maxTtlDays*Ce,r=e.siteDefaultTtlHours*Z,i=e.siteMaxTtlDays*Ce;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.`:e.noteMaxTotalSizeMb<1||e.noteMaxTotalSizeMb>2048?`Maximum Note snapshot size must be between 1 MB and 2 GB.`:e.noteMaxAttachmentCount<0||e.noteMaxAttachmentCount>500?`Maximum Note attachment count must be between 0 and 500.`: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 Oe(e){let t=De(e);if(t)throw Error(t);await _(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*Z,maxTtlMs:e.maxTtlDays*Ce,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Q,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Q,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*Q,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*Z,maxTtlMs:e.siteMaxTtlDays*Ce,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Q,maxFileCount:e.siteMaxFileCount}}}})}),S()}var $=r();function ke(){return p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,se,`dark:border-edge`)}function Ae({hasToken:e}){let t=f(g(e=>e.language)).sharesSettings,{data:n,isLoading:r}=C(e),i=(0,Y.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(Ee(n.payload.config)),[n]),a=(0,Y.useRef)(!1),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),h=o??i,_=i,v=(0,Y.useMemo)(()=>!h||!_?!1:JSON.stringify(h)!==JSON.stringify(_),[h,_]),y=(0,Y.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),x=(0,Y.useCallback)(async()=>{if(!(!h||c)){l(!0),d(null),m(!1);try{await Oe(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,Y.useCallback)(()=>{a.current=!1,s(null),d(null),m(!1)},[]);return!e||!h?r?(0,$.jsx)(J,{children:(0,$.jsx)(ge,{rows:2})}):null:(0,$.jsxs)(J,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[p?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,$.jsx)(b,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>y(Se()),children:t.policyUseRecommended}),(0,$.jsx)(b,{type:`button`,variant:`secondary`,disabled:!v||c,onClick:S,children:t.policyDiscard}),(0,$.jsx)(b,{type:`button`,variant:`primary`,disabled:!v||c,onClick:()=>void x(),children:c?t.policySaving:t.policySave})]})]}),v?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,$.jsx)(je,{t,form:h,onChange:y})]})}function je(e){let t=(0,xe.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,$.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,$.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,$.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,$.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,$.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,$.jsx)(Me,{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,$.jsx)(Me,{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,$.jsx)(Me,{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,$.jsx)(Me,{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 C=!r.enabled,w;t[47]===i?w=t[48]:(w=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=w);let T;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==C||t[53]!==w?(T=(0,$.jsx)(Me,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:C,onChange:w}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=C,t[53]=w,t[54]=T):T=t[54];let E=!r.enabled,D;t[55]===i?D=t[56]:(D=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=D);let O;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==E||t[61]!==D?(O=(0,$.jsx)(Me,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:E,onChange:D}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=E,t[61]=D,t[62]=O):O=t[62];let k;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==T||t[67]!==O||t[68]!==p?(k=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,T,O]}),t[63]=g,t[64]=y,t[65]=S,t[66]=T,t[67]=O,t[68]=p,t[69]=k):k=t[69];let ee=!r.enabled,A;t[70]===i?A=t[71]:(A=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=A);let te;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==ee||t[75]!==A?(te=(0,$.jsx)(Ne,{t:n,values:r.inlinePreviewMimes,disabled:ee,onChange:A}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=ee,t[75]=A,t[76]=te):te=t[76];let j;t[77]!==k||t[78]!==te||t[79]!==s||t[80]!==u?(j=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[s,u,k,te]}),t[77]=k,t[78]=te,t[79]=s,t[80]=u,t[81]=j):j=t[81];let ne;t[82]===n.policyNoteSection?ne=t[83]:(ne=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=ne);let M;t[84]===n.policyNoteSectionHint?M=t[85]:(M=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=M);let N;t[86]!==ne||t[87]!==M?(N=(0,$.jsxs)(`div`,{className:`mb-4`,children:[ne,M]}),t[86]=ne,t[87]=M,t[88]=N):N=t[88];let P;t[89]===i?P=t[90]:(P=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=P);let re;t[91]!==r.noteEnabled||t[92]!==P?(re=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:P}),t[91]=r.noteEnabled,t[92]=P,t[93]=re):re=t[93];let F;t[94]!==n.policyNoteEnabled||t[95]!==re?(F=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[re,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=re,t[96]=F):F=t[96];let I=!r.enabled||!r.noteEnabled,L;t[97]===i?L=t[98]:(L=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=L);let R;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==I||t[103]!==L?(R=(0,$.jsx)(Me,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:I,onChange:L}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=I,t[103]=L,t[104]=R):R=t[104];let z=!r.enabled||!r.noteEnabled,ie;t[105]===i?ie=t[106]:(ie=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=ie);let B;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==z||t[111]!==ie?(B=(0,$.jsx)(Me,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:z,onChange:ie}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=z,t[111]=ie,t[112]=B):B=t[112];let V;t[113]!==R||t[114]!==B?(V=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[R,B]}),t[113]=R,t[114]=B,t[115]=V):V=t[115];let H;t[116]!==N||t[117]!==F||t[118]!==V?(H=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[N,F,V]}),t[116]=N,t[117]=F,t[118]=V,t[119]=H):H=t[119];let U;t[120]===n.policySiteSection?U=t[121]:(U=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=U);let ae;t[122]===n.policySiteSectionHint?ae=t[123]:(ae=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=ae);let W;t[124]!==U||t[125]!==ae?(W=(0,$.jsxs)(`div`,{className:`mb-4`,children:[U,ae]}),t[124]=U,t[125]=ae,t[126]=W):W=t[126];let G;t[127]===i?G=t[128]:(G=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=G);let oe;t[129]!==r.siteEnabled||t[130]!==G?(oe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:G}),t[129]=r.siteEnabled,t[130]=G,t[131]=oe):oe=t[131];let se;t[132]!==n.policySiteEnabled||t[133]!==oe?(se=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[oe,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=oe,t[134]=se):se=t[134];let ce=!r.siteEnabled,K;t[135]===i?K=t[136]:(K=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=K);let le;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==ce||t[141]!==K?(le=(0,$.jsx)(Me,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:ce,onChange:K}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=ce,t[141]=K,t[142]=le):le=t[142];let ue=!r.siteEnabled,de;t[143]===i?de=t[144]:(de=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=de);let fe;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==ue||t[149]!==de?(fe=(0,$.jsx)(Me,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:ue,onChange:de}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=ue,t[149]=de,t[150]=fe):fe=t[150];let pe=!r.siteEnabled,me;t[151]===i?me=t[152]:(me=e=>i({maxActiveSites:e}),t[151]=i,t[152]=me);let he;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==pe||t[157]!==me?(he=(0,$.jsx)(Me,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:pe,onChange:me}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=pe,t[157]=me,t[158]=he):he=t[158];let ge=!r.siteEnabled,_e;t[159]===i?_e=t[160]:(_e=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=_e);let ve;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==ge||t[165]!==_e?(ve=(0,$.jsx)(Me,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:ge,onChange:_e}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=ge,t[165]=_e,t[166]=ve):ve=t[166];let ye=!r.siteEnabled,be;t[167]===i?be=t[168]:(be=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=be);let q;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==ye||t[173]!==be?(q=(0,$.jsx)(Me,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:ye,onChange:be}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=ye,t[173]=be,t[174]=q):q=t[174];let J;t[175]!==le||t[176]!==fe||t[177]!==he||t[178]!==ve||t[179]!==q?(J=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[le,fe,he,ve,q]}),t[175]=le,t[176]=fe,t[177]=he,t[178]=ve,t[179]=q,t[180]=J):J=t[180];let Y;t[181]!==W||t[182]!==se||t[183]!==J?(Y=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[W,se,J]}),t[181]=W,t[182]=se,t[183]=J,t[184]=Y):Y=t[184];let X;return t[185]!==j||t[186]!==H||t[187]!==Y?(X=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[j,H,Y]}),t[185]=j,t[186]=H,t[187]=Y,t[188]=X):X=t[188],X}function Me(e){let t=(0,xe.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,$.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=p(ke(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let f;t[4]!==s||t[5]!==o||t[6]!==l?(f=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]=f):f=t[7];let m;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==f||t[13]!==a?(m=(0,$.jsx)(ve,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:f}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=f,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,$.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,$.jsxs)(`div`,{children:[u,m,h]}),t[17]=u,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function Ne(e){let t=(0,xe.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,$.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,$.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,$.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,$.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,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let f;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(f=p(ke(),`font-mono text-xs`),t[13]=f):f=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,$.jsx)(`input`,{className:f,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,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[c,l,d,g]}),t[20]=c,t[21]=l,t[22]=d,t[23]=g,t[24]=_):_=t[24],_}function Pe(e){let t=(0,xe.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:o,conversationId:l,agentId:m}=e,_=o===void 0?`any`:o,v=f(g(Le)),x=v.workspace,S=v.sharesSettings,C=ae(Ie),{data:T}=y(h(Fe)?`picker-agents-list`:null,w),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]===C?r=t[3]:(r=C.trim(),t[2]=C,t[3]=r);let i=r;if(i){O=i;break bb0}if(T?.defaultId){O=T.defaultId;break bb0}if(T?.agents?.[0]?.id){O=T.agents[0].id;break bb0}O=``}let k=O,[A,j]=(0,Y.useState)(k),N,P;t[4]===k?(N=t[5],P=t[6]):(N=()=>{j(k)},P=[k],t[4]=k,t[5]=N,t[6]=P),(0,Y.useEffect)(N,P);let{tree:re,loading:F,error:I,loadRoot:L,loadChildren:R,reset:z}=fe(A,l??null),B;t[7]===a?B=t[8]:(B=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=B);let[V,U]=(0,Y.useState)(B),W;t[9]!==a||t[10]!==L||t[11]!==n||t[12]!==z||t[13]!==U?(W=()=>{if(!n){z(),U(a?{path:a,isDirectory:!1}:null);return}L()},t[9]=a,t[10]=L,t[11]=n,t[12]=z,t[13]=U,t[14]=W):W=t[14];let G;t[15]!==l||t[16]!==a||t[17]!==L||t[18]!==n||t[19]!==A||t[20]!==z?(G=[n,A,l,L,z,a],t[15]=l,t[16]=a,t[17]=L,t[18]=n,t[19]=A,t[20]=z,t[21]=G):G=t[21],(0,Y.useEffect)(W,G);let oe;t[22]===R?oe=t[23]:(oe=e=>{R(e)},t[22]=R,t[23]=oe);let se=oe,ce=V!==null&&(_===`any`||_===`file`&&!V.isDirectory||_===`directory`&&V.isDirectory),K;bb1:{if(!V){K=S.pickerHintNone;break bb1}if(_===`file`&&V.isDirectory){K=S.pickerHintNeedsFile;break bb1}if(_===`directory`&&!V.isDirectory){K=S.pickerHintNeedsDirectory;break bb1}K=`${V.isDirectory?`📁`:`📄`} ${V.path}`}let le=K,de=T?.agents??[],pe;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(_e,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=pe):pe=t[24];let me;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(me=p(`xopc-dialog-content 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-overlay shadow-popover outline-none`),t[25]=me):me=t[25];let he;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(u,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=he):he=t[26];let ge=v.cron.refresh,ve=v.cron.refresh,ye;t[27]===L?ye=t[28]:(ye=()=>void L(),t[27]=L,t[28]=ye);let be=F&&`animate-spin`,q;t[29]===be?q=t[30]:(q=p(`size-4`,be),t[29]=be,t[30]=q);let J;t[31]===q?J=t[32]:(J=(0,$.jsx)(te,{className:q,"aria-hidden":!0}),t[31]=q,t[32]=J);let X;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,$.jsx)(ue,{className:`size-4`}),t[33]=X):X=t[33];let Se;t[34]!==I||t[35]!==x.loadError?(Se=I?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[x.loadError,`: `,I]}):null,t[34]=I,t[35]=x.loadError,t[36]=Se):Se=t[36];let Z;t[37]!==se||t[38]!==F||t[39]!==V?.path||t[40]!==U||t[41]!==x.emptyDir||t[42]!==x.title||t[43]!==re?(Z=F&&re.length===0?(0,$.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(d,{className:`size-4 animate-spin`}),x.title,`…`]}):(0,$.jsx)(H,{tree:re,selectedPath:V?.path??null,onSelectFile:e=>U({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>U({path:e,isDirectory:t}),onExpandDir:se,onAction:void 0,emptyHint:x.emptyDir}),t[37]=se,t[38]=F,t[39]=V?.path,t[40]=U,t[41]=x.emptyDir,t[42]=x.title,t[43]=re,t[44]=Z):Z=t[44];let Ce;t[45]!==Se||t[46]!==Z?(Ce=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[Se,Z]}),t[45]=Se,t[46]=Z,t[47]=Ce):Ce=t[47];let Q;t[48]===le?Q=t[49]:(Q=(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:le}),t[48]=le,t[49]=Q);let we;t[50]===r?we=t[51]:(we=()=>r(!1),t[50]=r,t[51]=we);let Te;t[52]!==S.cancel||t[53]!==we?(Te=(0,$.jsx)(b,{type:`button`,variant:`ghost`,onClick:we,children:S.cancel}),t[52]=S.cancel,t[53]=we,t[54]=Te):Te=t[54];let Ee=!ce,De;t[55]!==i||t[56]!==r||t[57]!==A||t[58]!==V?(De=()=>{V&&(i({...V,agentId:A}),r(!1))},t[55]=i,t[56]=r,t[57]=A,t[58]=V,t[59]=De):De=t[59];let Oe;t[60]!==S.pickerConfirm||t[61]!==Ee||t[62]!==De?(Oe=(0,$.jsx)(b,{type:`button`,disabled:Ee,onClick:De,children:S.pickerConfirm}),t[60]=S.pickerConfirm,t[61]=Ee,t[62]=De,t[63]=Oe):Oe=t[63];let ke;t[64]!==Te||t[65]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Te,Oe]}),t[64]=Te,t[65]=Oe,t[66]=ke):ke=t[66];let Ae;return t[67]!==Q||t[68]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Q,ke]}),t[67]=Q,t[68]=ke,t[69]=Ae):Ae=t[69],(0,$.jsx)(ee,{open:n,onOpenChange:r,children:(0,$.jsxs)(D,{children:[pe,(0,$.jsxs)(M,{className:me,children:[(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[he,(0,$.jsx)(ie,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:S.pickerTitle}),(0,$.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:ge,"aria-label":ve,disabled:F,onClick:ye,children:J}),(0,$.jsx)(ne,{asChild:!0,children:(0,$.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":x.close,children:X})})]}),de.length>0?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,$.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:S.pickerAgentLabel}),(0,$.jsx)(s,{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:A,onChange:e=>{j(e.target.value),U(null)},children:de.map(e=>(0,$.jsxs)(c,{value:e.id,children:[E(e,v.agentsSettings),e.id===T?.defaultId?` ★`:``]},e.id))})]}):null,Ce,Ae]})]})})}function Fe(e){return e.conversationId}function Ie(e){return e.agentId}function Le(e){return e.language}var Re=[`shares`,`policy`];function ze(e){let t=(e??``).trim();return Re.includes(t)?t:`shares`}function Be(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 Ve(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 He=[{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 Ue(){let e=(0,xe.c)(23),t=g(Ge),n=f(t).sharesSettings,r=!!h(We),[a,o]=i(),s;e[0]===a?s=e[1]:(s=ze(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,$.jsx)(ye,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},p=Re.map(e=>({id:e,label:d[e]})),m;e[4]===n.title?m=e[5]:(m=(0,$.jsx)(be,{title:n.title}),e[4]=n.title,e[5]=m);let _;e[6]!==c||e[7]!==u||e[8]!==n.tabsAria||e[9]!==p?(_=(0,$.jsx)(pe,{items:p,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[6]=c,e[7]=u,e[8]=n.tabsAria,e[9]=p,e[10]=_):_=e[10];let v;e[11]!==c||e[12]!==r||e[13]!==t||e[14]!==n?(v=c===`shares`?(0,$.jsx)(Ke,{t:n,language:t}):(0,$.jsx)(Ae,{hasToken:r}),e[11]=c,e[12]=r,e[13]=t,e[14]=n,e[15]=v):v=e[15];let y;e[16]!==c||e[17]!==v?(y=(0,$.jsx)(q,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[16]=c,e[17]=v,e[18]=y):y=e[18];let b;return e[19]!==m||e[20]!==_||e[21]!==y?(b=(0,$.jsxs)(ye,{children:[m,_,y]}),e[19]=m,e[20]=_,e[21]=y,e[22]=b):b=e[22],b}function We(e){return e.conversationId}function Ge(e){return e.language}function Ke(e){let t=(0,xe.c)(79),{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}=y(`shares-list`,re,i),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:3e4},t[1]=l):l=t[1];let u=y(`hosted-publications-list`,k,l),d;t[2]===a?.payload?.shares?d=t[3]:(d=a?.payload?.shares??[],t[2]=a?.payload?.shares,t[3]=d);let f=d,[m,h]=(0,Y.useState)(!1),g;bb0:{if(m){g=f;break bb0}let e;t[4]===f?e=t[5]:(e=f.filter(Ze),t[4]=f,t[5]=e),g=e}let _=g,v;t[6]===f?v=t[7]:(v=f.filter(Xe),t[6]=f,t[7]=v);let x=v.length,S;t[8]===f?S=t[9]:(S=f.filter(Ye),t[8]=f,t[9]=S);let C=S.length,w;t[10]===c?w=t[11]:(w=()=>void c(),t[10]=c,t[11]=w);let T;t[12]!==n||t[13]!==w?(T=(0,$.jsx)(rt,{t:n,onCreated:w}),t[12]=n,t[13]=w,t[14]=T):T=t[14];let E=u.data?.connected===!0,D=u.data?.publishingAllowed===!0,O;t[15]===u?O=t[16]:(O=()=>void u.mutate(),t[15]=u,t[16]=O);let ee;t[17]!==r||t[18]!==D||t[19]!==O||t[20]!==E?(ee=(0,$.jsx)(Qe,{language:r,connected:E,publishingAllowed:D,onCreated:O}),t[17]=r,t[18]=D,t[19]=O,t[20]=E,t[21]=ee):ee=t[21];let A=m?n.allSharesTitle:n.listTitle,j;t[22]===x?j=t[23]:(j=x>0&&(0,$.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,x,`)`]}),t[22]=x,t[23]=j);let ne;t[24]!==A||t[25]!==j?(ne=(0,$.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[A,j]}),t[24]=A,t[25]=j,t[26]=ne):ne=t[26];let M;t[27]===c?M=t[28]:(M=()=>void c(),t[27]=c,t[28]=M);let N=s&&`animate-spin`,P;t[29]===N?P=t[30]:(P=p(`size-3.5`,N),t[29]=N,t[30]=P);let F;t[31]===P?F=t[32]:(F=(0,$.jsx)(te,{className:P}),t[31]=P,t[32]=F);let I;t[33]!==s||t[34]!==M||t[35]!==F?(I=(0,$.jsx)(b,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:M,disabled:s,children:F}),t[33]=s,t[34]=M,t[35]=F,t[36]=I):I=t[36];let L;t[37]!==C||t[38]!==m||t[39]!==n.hideExpired||t[40]!==n.showExpired?(L=C>0&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>h(Je),children:m?n.hideExpired:n.showExpired}),t[37]=C,t[38]=m,t[39]=n.hideExpired,t[40]=n.showExpired,t[41]=L):L=t[41];let R;t[42]!==I||t[43]!==L?(R=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[I,L]}),t[42]=I,t[43]=L,t[44]=R):R=t[44];let z;t[45]!==ne||t[46]!==R?(z=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[ne,R]}),t[45]=ne,t[46]=R,t[47]=z):z=t[47];let ie;t[48]!==a||t[49]!==o||t[50]!==_||t[51]!==s||t[52]!==r||t[53]!==c||t[54]!==n?(ie=s&&!a?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(qe)}):o?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:n.error}),(0,$.jsx)(b,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):_.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:_.map(e=>(0,$.jsx)(at,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[48]=a,t[49]=o,t[50]=_,t[51]=s,t[52]=r,t[53]=c,t[54]=n,t[55]=ie):ie=t[55];let B;t[56]!==C||t[57]!==c||t[58]!==m||t[59]!==n?(B=C>0&&m&&(0,$.jsx)(ot,{t:n,onCleaned:()=>void c()}),t[56]=C,t[57]=c,t[58]=m,t[59]=n,t[60]=B):B=t[60];let V;t[61]!==z||t[62]!==ie||t[63]!==B?(V=(0,$.jsxs)(J,{children:[z,ie,B]}),t[61]=z,t[62]=ie,t[63]=B,t[64]=V):V=t[64];let H;t[65]===u?H=t[66]:(H=()=>void u.mutate(),t[65]=u,t[66]=H);let U;t[67]!==u.data||t[68]!==u.error||t[69]!==u.isLoading||t[70]!==r||t[71]!==n||t[72]!==H?(U=(0,$.jsx)($e,{data:u.data,error:u.error,isLoading:u.isLoading,language:r,t:n,onChanged:H}),t[67]=u.data,t[68]=u.error,t[69]=u.isLoading,t[70]=r,t[71]=n,t[72]=H,t[73]=U):U=t[73];let ae;return t[74]!==ee||t[75]!==V||t[76]!==U||t[77]!==T?(ae=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[T,ee,V,U]}),t[74]=ee,t[75]=V,t[76]=U,t[77]=T,t[78]=ae):ae=t[78],ae}function qe(e,t){return(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(x,{className:`h-4 w-2/3`}),(0,$.jsx)(x,{className:`mt-2 h-3 w-1/2`})]}),(0,$.jsx)(x,{className:`h-7 w-20 rounded-md`})]})},t)}function Je(e){return!e}function Ye(e){return e.expired||e.revoked}function Xe(e){return!e.expired&&!e.revoked}function Ze(e){return!e.expired&&!e.revoked}function Qe({language:e,connected:t,publishingAllowed:n,onCreated:r}){let i=e===`zh`,[a,o]=(0,Y.useState)(``),[l,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(!1),[_,y]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(6048e5),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(null),k=async()=>{if(a.trim()){w(!0),O(null);try{E(await me({path:a.trim(),title:_.trim()||void 0,ttlMs:x,spaFallback:!0,...l?{agentId:l}:{}})),r()}catch(e){O(e instanceof Error?e.message:String(e))}finally{w(!1)}}};return(0,$.jsxs)(J,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(de,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`发布静态网站`:`Publish static website`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i?`把工作区内的 HTML 文件,或包含 index.html 的网站目录,发布到隔离的托管域名。`:`Publish an HTML file or a website directory containing index.html to the isolated hosted origin.`}),t&&!n?(0,$.jsx)(`p`,{className:`mt-3 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning`,children:i?`管理员已暂停你的公网分享能力。已有远端链接当前不可访问;你仍可在下方撤销它们。`:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but you can still revoke them below.`}):null,(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-[1fr_12rem]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{value:a,onChange:e=>{o(e.target.value),m(!1),E(null)},placeholder:i?`选择 HTML 文件或网站目录`:`Select an HTML file or website directory`,className:`h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`}),(0,$.jsxs)(b,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>g(!0),children:[a&&!p?(0,$.jsx)(W,{className:`size-4`}):(0,$.jsx)(u,{className:`size-4`}),a?i?`更换`:`Change`:i?`选择`:`Browse`]})]}),(0,$.jsxs)(s,{value:String(x),onChange:e=>S(Number(e.target.value)),children:[(0,$.jsx)(c,{value:`86400000`,children:i?`24 小时`:`24 hours`}),(0,$.jsx)(c,{value:`604800000`,children:i?`7 天`:`7 days`}),(0,$.jsx)(c,{value:`2592000000`,children:i?`30 天`:`30 days`})]}),(0,$.jsx)(`input`,{value:_,onChange:e=>y(e.target.value),placeholder:i?`网站标题(可选)`:`Site title (optional)`,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent sm:col-span-2`})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,$.jsxs)(b,{type:`button`,onClick:()=>void k(),disabled:!a.trim()||C||!t||!n,children:[C?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(de,{className:`size-4`}),C?i?`发布中…`:`Publishing…`:i?`发布网站`:`Publish site`]}),T?(0,$.jsxs)(`button`,{type:`button`,className:`min-w-0 truncate text-xs text-accent hover:underline`,onClick:()=>void v(T.shareUrl),children:[T.shareUrl,` · `,T.fileCount,` `,i?`个文件`:`files`,` · `,Be(T.totalBytes)]}):null]}),D?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:D}):null]})]}),(0,$.jsx)(Pe,{open:h,onOpenChange:g,initialPath:a||void 0,agentId:l||void 0,selectKind:`any`,onConfirm:e=>{o(e.path),f(e.agentId),m(e.isDirectory),E(null),O(null)}})]})}function $e(e){let t=(0,xe.c)(18),{data:n,error:r,isLoading:i,language:a,t:o,onChanged:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(de,{className:`size-4 text-accent`,"aria-hidden":!0}),t[0]=c):c=t[0];let l;t[1]===o.hostedTitle?l=t[2]:(l=(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[c,o.hostedTitle]}),t[1]=o.hostedTitle,t[2]=l);let u;t[3]===o.hostedHint?u=t[4]:(u=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.hostedHint}),t[3]=o.hostedHint,t[4]=u);let d;t[5]!==l||t[6]!==u?(d=(0,$.jsx)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:(0,$.jsxs)(`div`,{children:[l,u]})}),t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==r||t[10]!==i||t[11]!==a||t[12]!==s||t[13]!==o?(f=i&&!n?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:2}).map(et)}):r?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o.error}):n?.connected?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[n.publishingAllowed?null:(0,$.jsx)(`p`,{className:`rounded-md bg-warning-soft px-3 py-2 text-xs text-warning`,children:a===`zh`?`管理员已暂停公网分享。已有托管链接当前不可访问,也不能更新;撤销操作仍然可用。`:`An administrator has paused public sharing. Existing hosted links are unavailable and cannot be updated; revocation remains available.`}),n.publications.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedEmpty}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.publications.map(e=>(0,$.jsx)(tt,{publication:e,language:a,t:o,publishingAllowed:n.publishingAllowed,onChanged:s},e.id))})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedDisconnected}),(0,$.jsx)(F,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:s})]}),t[8]=n,t[9]=r,t[10]=i,t[11]=a,t[12]=s,t[13]=o,t[14]=f):f=t[14];let p;return t[15]!==d||t[16]!==f?(p=(0,$.jsxs)(J,{children:[d,f]}),t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function et(e,t){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:[(0,$.jsx)(x,{className:`h-4 w-2/3`}),(0,$.jsx)(x,{className:`mt-2 h-3 w-1/2`})]},t)}function tt({publication:e,language:t,t:n,publishingAllowed:r,onChanged:i}){let[o,s]=(0,Y.useState)(!1),[c,u]=(0,Y.useState)(!1),[f,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(!1),[_,y]=(0,Y.useState)(!1),x=Date.now()>=new Date(e.expiresAt).getTime(),S=e.status===`active`&&!x,C=e.status===`revoked`?n.statusRevoked:x?n.statusExpired:e.status===`staging`?t===`zh`?`准备中`:`Staging`:n.statusActive,w=e.kind===`note_document`?V:e.kind===`static_site`?de:U,E=e.kind===`note_document`?t===`zh`?`笔记文档`:`Note document`:e.kind===`static_site`?t===`zh`?`静态网站`:`Static website`:t===`zh`?`会话快照`:`Conversation snapshot`,D=(0,Y.useCallback)(async()=>{e.shareUrl&&await v(e.shareUrl)&&(m(!0),window.setTimeout(()=>m(!1),2e3))},[e.shareUrl]),O=(0,Y.useCallback)(async()=>{s(!1),u(!0);try{await T(e.id),i()}catch{}finally{u(!1)}},[e.id,i]),k=(0,Y.useCallback)(async()=>{if(!(!e.revision||e.revision<=1)){g(!0);try{let t=(await R(e.id)).find(t=>t.revision<e.revision);if(!t)return;await N(e.id,e.revision,t.revision),i()}catch{}finally{g(!1)}}},[e.id,e.revision,i]),ee=(0,Y.useCallback)(async()=>{y(!0);try{await ce(e.id),i()}catch{}finally{y(!1)}},[e.id,i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(w,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:p(`text-xs font-medium`,S?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`),children:C})]}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[E,` · `,n.hostedRevision,` `,e.revision??`—`,` · `,e.managedFromThisDevice?n.hostedThisDevice:n.hostedOtherDevice]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{children:[t===`zh`?`浏览`:`Views`,`: `,e.viewCount,e.maxViews===null?``:` / ${e.maxViews}`]}),(0,$.jsx)(`span`,{children:x?n.statusExpired:Ve(e.expiresAt,t)}),e.description?(0,$.jsx)(`span`,{className:`italic`,children:e.description}):null]})]}),S?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.shareUrl?(0,$.jsx)(b,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:!r,title:n.copyUrl,onClick:()=>void D(),children:f?(0,$.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(l,{className:`size-3.5`})}):null,(e.revision??0)>1?(0,$.jsx)(b,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:h||!r,onClick:()=>void k(),title:t===`zh`?`回滚上一版本`:`Roll back one revision`,children:h?(0,$.jsx)(d,{className:`size-3.5 animate-spin`}):(0,$.jsx)(z,{className:`size-3.5`})}):null,e.kind===`static_site`&&e.managedFromThisDevice?(0,$.jsx)(b,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:_||!r,onClick:()=>void ee(),title:t===`zh`?`发布工作区中的最新版本`:`Publish latest workspace version`,children:(0,$.jsx)(te,{className:p(`size-3.5`,_&&`animate-spin`)})}):null,(0,$.jsx)(b,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,disabled:c,onClick:()=>s(!0),children:c?(0,$.jsx)(d,{className:`size-3.5 animate-spin`}):(0,$.jsx)(G,{className:`size-3.5`})})]}):null]})}),(0,$.jsx)(le,{open:o,title:n.revokeConfirmTitle,description:n.revokeConfirmBody,confirmLabel:n.revokeConfirmLabel,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void O(),onCancel:()=>s(!1)})]})}var nt={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function rt({t:e,onCreated:t}){let[n,r]=(0,Y.useReducer)(K,nt),{expanded:i,path:a,isDirectory:o,agentId:l,ttlMs:u,maxViews:f,description:m,directoryMode:h,creating:g,result:_,errorMsg:v,resultDialogOpen:y,pickerOpen:x}=n,S=(0,Y.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await L({path:a.trim(),ttlMs:u,maxViews:f,description:m.trim()||void 0,...l?{agentId:l}:{},...o?{kind:`directory`,directoryMode:h}:{}})).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,o,l,u,f,m,h,t]),C=(0,Y.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,$.jsxs)(J,{children:[(0,$.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:p(`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,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:o?`📁`:`📄`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,$.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,$.jsxs)(b,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,$.jsx)(W,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),o?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,$.jsxs)(s,{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,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,$.jsx)(c,{value:`browse`,children:e.directoryModeBrowse}),(0,$.jsx)(c,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,$.jsx)(s,{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:u,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:He.map(t=>(0,$.jsx)(c,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,$.jsxs)(s,{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:f??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,$.jsx)(c,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,$.jsx)(c,{value:`1`,children:`1`}),(0,$.jsx)(c,{value:`5`,children:`5`}),(0,$.jsx)(c,{value:`10`,children:`10`}),(0,$.jsx)(c,{value:`50`,children:`50`}),(0,$.jsx)(c,{value:`100`,children:`100`})]})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,$.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:m,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,$.jsxs)(b,{type:`button`,disabled:g||!a.trim(),onClick:()=>void S(),children:[g?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(j,{className:`size-4`}),g?e.creating:e.createButton]}),(0,$.jsx)(b,{type:`button`,variant:`ghost`,onClick:()=>{C(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),v&&(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v})]}),(0,$.jsx)(I,{open:y,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:_}),(0,$.jsx)(Pe,{open:x,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,$.jsxs)(b,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,$.jsx)(j,{className:`size-4`}),e.createTitle]})}var it={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function at({share:e,t,language:n,onRevoked:r,onExtended:i}){let[s,c]=(0,Y.useReducer)(K,it),{revokeOpen:u,revoking:f,linksOpen:m,urlCopied:h,copyFailed:g,extending:_}=s,y=!e.expired&&!e.revoked,x=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,S=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,C=(0,Y.useCallback)(async()=>{c({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await oe(e.id),r()}catch{}finally{c({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),w=(0,Y.useCallback)(async()=>{if(c({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await v(e.shareUrl)){c({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>c({type:`patch`,patch:{copyFailed:!1}}),2500);return}c({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>c({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),T=(0,Y.useCallback)(async()=>{c({type:`patch`,patch:{extending:!0}});try{await O(e.id,864e5),i()}catch{}finally{c({type:`patch`,patch:{extending:!1}})}},[e.id,i]),E=`share-links-${e.id}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:p(`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":E,onClick:()=>c({type:`patch`,patch:{linksOpen:!m}}),children:[(0,$.jsx)(o,{className:p(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,m?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,$.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):e.kind===`session`?(0,$.jsx)(U,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(W,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:p(`text-xs font-medium`,S),children:x})]}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.kind===`note`?n===`zh`?`笔记快照 · 版本 ${e.snapshotRevision??1}`:`Note snapshot · revision ${e.snapshotRevision??1}`:e.kind===`session`?n===`zh`?`会话快照 · ${e.messageCount??0} 条消息 · 版本 ${e.snapshotRevision??1}`:`Conversation snapshot · ${e.messageCount??0} messages · revision ${e.snapshotRevision??1}`:e.workspaceRelativePath}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:Be(e.fileSize)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(he,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Ve(e.expiresAt,n)]}),(0,$.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,$.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:y&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void w(),children:h?(0,$.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(l,{className:`size-3.5`})}),(0,$.jsx)(b,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void T(),disabled:_,title:t.extend,children:_?(0,$.jsx)(d,{className:`size-3.5 animate-spin`}):(0,$.jsx)(he,{className:`size-3.5`})}),(0,$.jsx)(b,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>c({type:`patch`,patch:{revokeOpen:!0}}),disabled:f,children:f?(0,$.jsx)(d,{className:`size-3.5 animate-spin`}):(0,$.jsx)(G,{className:`size-3.5`})})]})})]}),y&&m?(0,$.jsxs)(`div`,{id:E,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,$.jsx)(A,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),g?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(P,{reachability:e.reachability})})]}):null]}),(0,$.jsx)(le,{open:u,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void C(),onCancel:()=>c({type:`patch`,patch:{revokeOpen:!1}})})]})}function ot({t:e,onCleaned:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1),o=(0,Y.useCallback)(async()=>{r(!1),a(!0);try{await B(),t()}catch{}finally{a(!1)}},[t]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(b,{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,$.jsx)(d,{className:`size-3.5 animate-spin`}):(0,$.jsx)(G,{className:`size-3.5`}),e.cleanExpired]})}),(0,$.jsx)(le,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{Ue as SharesSettingsPanel};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-0WouolD0.js";import{a as r,i,l as a}from"./locale-store-JogcXC4J.js";import{li as o}from"./index-D1oivYvN.js";import"./skill-reload-api-Bq-3_MCt.js";var s=`https://skillhub.cn`,c=`https://clawhub.ai`;function l(e){let t=e.trim();return t?`${s}/skills/${encodeURIComponent(t)}`:null}function u(e){let t=e.trim();return t?`${c}/${encodeURIComponent(t)}`:null}function d(e,t){return e===`skillhub`?l(t):e===`clawhub`?u(t):null}function f(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function p(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function m(e){return e.filter(e=>e.type!==`collision`)}function h(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 g(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}var _=e(),v=t(),y=[{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 b(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 x(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 S(e){let t=(0,_.c)(9),{name:r,className:i}=e,a;t[0]===r?a=t[1]:(a=x(r),t[0]=r,t[1]=a);let o=a,s=y[b(r)%y.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,v.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}async function C(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 r=new Headers,o=await fetch(i(`/api/skills/upload`),{method:`POST`,headers:r,body:n});o.status===401&&a.getState().onUnauthorized();let s=await o.json().catch(()=>({}));if(!o.ok)throw Error(s.error||`HTTP ${o.status}`);if(!s.payload?.skillId)throw Error(`Invalid response`);return s.payload}async function w(e,t){let n=t?`?target=${encodeURIComponent(t)}`:``,a=await r(i(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!a.ok)throw Error(await o(a))}async function T(e,t){let n=await r(i(`/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 E(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function D(e){let t=new URLSearchParams;E(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let n=t.toString(),a=await r(i(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!a.ok)throw Error(await o(a));let s=await a.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function O(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()),E(t,e.provider);let n=t.toString(),a=await r(i(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!a.ok)throw Error(await o(a));let s=await a.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function k(e,t){let n=encodeURIComponent(e),a=new URLSearchParams;E(a,t?.provider);let s=a.toString(),c=await r(i(`/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 A(e){let t=await r(i(`/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 j(e){let t=await r(i(`/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 M(){let e=await r(i(`/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 N(){let e=await r(i(`/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}export{g as _,N as a,A as c,S as d,m as f,d as g,f as h,M as i,T as l,p as m,D as n,O as o,h as p,k as r,j as s,w as t,C as u};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-0WouolD0.js";import{a as r,i,l as a}from"./locale-store-JogcXC4J.js";import{li as o}from"./index-ygkHNYyo.js";import"./skill-reload-api-Egaf8PqZ.js";var s=`https://skillhub.cn`,c=`https://clawhub.ai`;function l(e){let t=e.trim();return t?`${s}/skills/${encodeURIComponent(t)}`:null}function u(e){let t=e.trim();return t?`${c}/${encodeURIComponent(t)}`:null}function d(e,t){return e===`skillhub`?l(t):e===`clawhub`?u(t):null}function f(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function p(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function m(e){return e.filter(e=>e.type!==`collision`)}function h(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 g(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}var _=e(),v=t(),y=[{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 b(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 x(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 S(e){let t=(0,_.c)(9),{name:r,className:i}=e,a;t[0]===r?a=t[1]:(a=x(r),t[0]=r,t[1]=a);let o=a,s=y[b(r)%y.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,v.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}async function C(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 r=new Headers,o=await fetch(i(`/api/skills/upload`),{method:`POST`,headers:r,body:n});o.status===401&&a.getState().onUnauthorized();let s=await o.json().catch(()=>({}));if(!o.ok)throw Error(s.error||`HTTP ${o.status}`);if(!s.payload?.skillId)throw Error(`Invalid response`);return s.payload}async function w(e,t){let n=t?`?target=${encodeURIComponent(t)}`:``,a=await r(i(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!a.ok)throw Error(await o(a))}async function T(e,t){let n=await r(i(`/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 E(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function D(e){let t=new URLSearchParams;E(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let n=t.toString(),a=await r(i(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!a.ok)throw Error(await o(a));let s=await a.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function O(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()),E(t,e.provider);let n=t.toString(),a=await r(i(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!a.ok)throw Error(await o(a));let s=await a.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function k(e,t){let n=encodeURIComponent(e),a=new URLSearchParams;E(a,t?.provider);let s=a.toString(),c=await r(i(`/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 A(e){let t=await r(i(`/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 j(e){let t=await r(i(`/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 M(){let e=await r(i(`/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 N(){let e=await r(i(`/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}export{g as _,N as a,A as c,S as d,m as f,d as g,f as h,M as i,T as l,p as m,D as n,O as o,h as p,k as r,j as s,w as t,C as u};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n}from"./locale-store-JogcXC4J.js";import{li as r}from"./index-D1oivYvN.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};
1
+ import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n}from"./locale-store-JogcXC4J.js";import{li as r}from"./index-ygkHNYyo.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{l as a,m as o,t as s,u as c}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as l}from"./popover-select-DGKUpVsz.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./download-Dk-ZjtO6.js";import{t as f}from"./ellipsis-0k4rZLoy.js";import{t as p}from"./external-link-DjqjBmc3.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./messages-RzwPiQNL.js";import{t as g}from"./cn-0WouolD0.js";import{l as _,n as v}from"./locale-store-JogcXC4J.js";import{t as y}from"./vendor-swr-BIWyz7Rc.js";import{t as b}from"./button-aIC072nz.js";import{i as x}from"./gateway-config-swr-DF_HV6NP.js";import{Ad as S,Bc as C,F as w,Fc as T,Fl as E,Hl as D,Ic as O,Lc as k,Mu as A,R as j,Vc as M,aa as N,ca as P,cc as F,ci as I,il as L,io as R,ks as z,oa as B,pl as V,qc as ee,rl as H,ro as U,sa as W,sd as G,si as K,ua as q,ui as J,vl as Y,vo as te,wa as ne,ya as re,zc as ie}from"./index-ygkHNYyo.js";import{n as ae,t as oe}from"./capability-header-actions-BasrAWA0.js";import{t as se}from"./skill-reload-api-Egaf8PqZ.js";import{_ as ce,a as le,c as ue,d as de,f as fe,g as pe,h as me,i as he,l as ge,m as _e,n as ve,o as ye,p as be,r as xe,s as Se,t as Ce,u as we}from"./skill-api-DTdejInH.js";var X=e(t(),1),Z=n(),Q=r();function Te(e){let t=(0,Z.c)(15),{sk:n,findingSkills:r,onFindSkills:i,secondary:a,compactOnMobile:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=r?m:Y,u=s?`secondary`:`primary`,d;t[0]===i?d=t[1]:(d=()=>void i(),t[0]=i,t[1]=d);let f=r?`size-4 animate-spin`:`size-4`,p;t[2]!==l||t[3]!==f?(p=(0,Q.jsx)(l,{className:f,"aria-hidden":!0}),t[2]=l,t[3]=f,t[4]=p):p=t[4];let h=c?`hidden sm:inline`:void 0,g;t[5]!==n.findCta||t[6]!==h?(g=(0,Q.jsx)(`span`,{className:h,children:n.findCta}),t[5]=n.findCta,t[6]=h,t[7]=g):g=t[7];let _;return t[8]!==r||t[9]!==n.findHint||t[10]!==u||t[11]!==d||t[12]!==p||t[13]!==g?(_=(0,Q.jsxs)(b,{variant:u,className:`shrink-0`,title:n.findHint,disabled:r,"aria-busy":r,onClick:d,children:[p,g]}),t[8]=r,t[9]=n.findHint,t[10]=u,t[11]=d,t[12]=p,t[13]=g,t[14]=_):_=t[14],_}var Ee=(0,X.memo)(function(e){let t=(0,Z.c)(30),{loading:n,onReloadClick:r,sk:i,setPendingFile:a,setInstallOpen:o}=e,c=v(De),l;t[0]===c?l=t[1]:(l=h(c),t[0]=c,t[1]=l);let u=l,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=g(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,z.transition),t[2]=p):p=t[2];let _=p,y;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t[3]=y):y=t[3];let x;t[4]===u.capabilitiesHub.moreActions?x=t[5]:(x=(0,Q.jsx)(q,{asChild:!0,children:(0,Q.jsx)(b,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":u.capabilitiesHub.moreActions,title:u.capabilitiesHub.moreActions,children:y})}),t[4]=u.capabilitiesHub.moreActions,t[5]=x);let S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(d,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[6]=S):S=t[6];let C;t[7]===u.imports.title?C=t[8]:(C=(0,Q.jsx)(B,{asChild:!0,children:(0,Q.jsxs)(s,{to:`/settings/imports`,className:_,children:[S,u.imports.title]})}),t[7]=u.imports.title,t[8]=C);let w;t[9]===n?w=t[10]:(w=n?(0,Q.jsx)(m,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,Q.jsx)(E,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[9]=n,t[10]=w);let T;t[11]!==n||t[12]!==r||t[13]!==i.reloadRuntime||t[14]!==w?(T=(0,Q.jsxs)(B,{className:_,disabled:n,onSelect:r,children:[w,i.reloadRuntime]}),t[11]=n,t[12]=r,t[13]=i.reloadRuntime,t[14]=w,t[15]=T):T=t[15];let O;t[16]!==o||t[17]!==a?(O=()=>{a(null),o(!0)},t[16]=o,t[17]=a,t[18]=O):O=t[18];let k;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(D,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[19]=k):k=t[19];let A;t[20]!==i.installCta||t[21]!==O?(A=(0,Q.jsxs)(B,{className:_,onSelect:O,children:[k,i.installCta]}),t[20]=i.installCta,t[21]=O,t[22]=A):A=t[22];let j;t[23]!==A||t[24]!==C||t[25]!==T?(j=(0,Q.jsx)(W,{children:(0,Q.jsxs)(N,{align:`end`,sideOffset:6,className:`z-50 min-w-52 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[C,T,A]})}),t[23]=A,t[24]=C,t[25]=T,t[26]=j):j=t[26];let M;return t[27]!==j||t[28]!==x?(M=(0,Q.jsxs)(P,{children:[x,j]}),t[27]=j,t[28]=x,t[29]=M):M=t[29],M});function De(e){return e.language}function Oe(e){return!!(e.plugin&&(!e.plugin.active||e.plugin.authorizationStatus===`required`))}function ke(e){let t=(0,Z.c)(23),{skill:n,detail:r}=e,i=r===void 0?!1:r,o=a(),c=v(Ae),l;t[0]===c?l=t[1]:(l=c.startsWith(`zh`),t[0]=c,t[1]=l);let u=l,d;t[2]!==n.origin||t[3]!==n.plugin?.id?(d=n.plugin?.id??(n.origin.startsWith(`plugin:`)?n.origin.slice(7):null),t[2]=n.origin,t[3]=n.plugin?.id,t[4]=d):d=t[4];let f=d;if(!f)return null;let p=n.plugin?.authorizationStatus===`required`,m=i?`mb-4 rounded-xl border border-edge p-3 text-sm`:`mt-3 border-t border-edge-subtle pt-3 text-xs`,h;t[5]!==i||t[6]!==u?(h=i?(0,Q.jsx)(`p`,{className:`mb-2 text-fg-muted`,children:u?`此技能随插件安装,由插件统一更新和卸载。可在 Agent 设置中调整使用范围。`:`Installed with its plugin. Update or uninstall the plugin to manage this skill. Adjust availability in Agent settings.`}):null,t[5]=i,t[6]=u,t[7]=h):h=t[7];let g=o.pathname+o.search,_;t[8]!==f||t[9]!==p||t[10]!==g?(_=j(f,`skills`,p,g),t[8]=f,t[9]=p,t[10]=g,t[11]=_):_=t[11];let y=u?`来自插件:`:`From plugin: `,b=n.plugin?.title??n.plugin?.name??f,x=p?u?`需要授权`:`Authorization required`:n.plugin?.active===!1?u?`插件未就绪`:`Plugin not ready`:u?`管理插件`:`Manage plugin`,S;t[12]===x?S=t[13]:(S=(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[`· `,x]}),t[12]=x,t[13]=S);let C;t[14]!==b||t[15]!==S||t[16]!==_||t[17]!==y?(C=(0,Q.jsxs)(s,{to:_,className:`inline-flex min-h-8 items-center gap-2 rounded-md text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[y,b,S]}),t[14]=b,t[15]=S,t[16]=_,t[17]=y,t[18]=C):C=t[18];let w;return t[19]!==C||t[20]!==m||t[21]!==h?(w=(0,Q.jsxs)(`div`,{className:m,children:[h,C]}),t[19]=C,t[20]=m,t[21]=h,t[22]=w):w=t[22],w}function Ae(e){return e.language}var je=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Me(){let e=(0,Z.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:g(`h-4 min-w-0 flex-1`,je)}),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:g(`size-8 shrink-0 rounded-lg`,je)}),(0,Q.jsx)(`div`,{className:g(`h-8 w-[4.5rem] shrink-0 rounded-lg`,je)})]})]}),r=(0,Q.jsx)(`div`,{className:g(`h-3 w-full`,je)}),i=(0,Q.jsx)(`div`,{className:g(`h-3 w-[92%]`,je)}),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:g(`h-3 w-full`,je)}),(0,Q.jsx)(`div`,{className:g(`h-2.5 w-4/5`,je)})]})]})})}),e[4]=a):a=e[4],a}function Ne(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Me,{}),e[0]=t):t=e[0],t}var Pe=new Set([`installed`,`marketplace`]),Fe=new Set([`all`,`builtin`,`installed`,`global`,`workspace`,`plugin`,`extra`]),Ie=new Set([`all`,`enabled`,`disabled`]),Le=`mprov`,Re=[`s0`,`s1`,`s2`,`s3`,`s4`,`s5`],ze=[`business`,`creative`,`documents`,`engineering`,`tools`];function Be(e){let t=(0,Z.c)(45),n=v(He),r;t[0]===n?r=t[1]:(r=n.startsWith(`zh`),t[0]=n,t[1]=r);let i=r,{sk:a,loading:o,catalog:s,filteredCatalog:c,builtinCategories:l,builtinCategoryFilter:d,setBuiltinCategoryFilter:f,catalogDisplayRows:p,skillPresentation:m,catalogStatusFilter:h,resolveSkillEnabled:_,categoryLabel:y,sourceLabel:x,openSkillDetail:C,onSkillToggle:w,onUseSkillInChat:T,usingSkillInChatName:E,togglingSkillName:D}=e;if(o){let e=a.loading,n;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(n=Re.map(Ve),t[2]=n):n=t[2];let r;return t[3]===a.loading?r=t[4]:(r=(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:n}),t[3]=a.loading,t[4]=r),r}if(s.length===0){let n;t[5]===a.empty?n=t[6]:(n=(0,Q.jsx)(`p`,{className:`mb-3`,children:a.empty}),t[5]=a.empty,t[6]=n);let r;t[7]!==e.findingSkills||t[8]!==e.onFindSkills||t[9]!==a?(r=(0,Q.jsx)(Te,{sk:a,findingSkills:e.findingSkills,onFindSkills:e.onFindSkills,secondary:!0}),t[7]=e.findingSkills,t[8]=e.onFindSkills,t[9]=a,t[10]=r):r=t[10];let i;return t[11]!==n||t[12]!==r?(i=(0,Q.jsxs)(`div`,{className:`py-16 text-center text-sm text-fg-muted`,children:[n,r]}),t[11]=n,t[12]=r,t[13]=i):i=t[13],i}if(c.length===0){let n;t[14]===a.noSearchResults?n=t[15]:(n=(0,Q.jsx)(`p`,{className:`mb-3`,children:a.noSearchResults}),t[14]=a.noSearchResults,t[15]=n);let r;t[16]!==e.findingSkills||t[17]!==e.onFindSkills||t[18]!==a?(r=(0,Q.jsx)(Te,{sk:a,findingSkills:e.findingSkills,onFindSkills:e.onFindSkills,secondary:!0}),t[16]=e.findingSkills,t[17]=e.onFindSkills,t[18]=a,t[19]=r):r=t[19];let i;return t[20]!==n||t[21]!==r?(i=(0,Q.jsxs)(`div`,{className:`py-16 text-center text-sm text-fg-muted`,children:[n,r]}),t[20]=n,t[21]=r,t[22]=i):i=t[22],i}let O;t[23]!==l||t[24]!==d||t[25]!==y||t[26]!==f||t[27]!==a?(O=l.length>1?(0,Q.jsx)(te,{items:[{id:``,label:a.marketplaceCategoryAll},...l.map(e=>({id:e,label:y(e),title:y(e)}))],activeTab:d,onChange:f,ariaLabel:a.marketplaceCategoriesAria,tabIdPrefix:`skills-builtin-category-tab`,className:`gap-2 pt-0.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,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[23]=l,t[24]=d,t[25]=y,t[26]=f,t[27]=a,t[28]=O):O=t[28];let k;t[29]!==p||t[30]!==h||t[31]!==w||t[32]!==T||t[33]!==C||t[34]!==_||t[35]!==a||t[36]!==m||t[37]!==x||t[38]!==D||t[39]!==E||t[40]!==i?(k=p.length===0?(0,Q.jsx)(`div`,{className:`py-16 text-center text-sm text-fg-muted`,children:h===`disabled`?a.noDisabledSkills:a.noSearchResults}):(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:p.map(e=>{let t=_(e),n=Oe(e),r=m(e);return(0,Q.jsxs)(`article`,{className:g(`group flex h-full flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors`,t&&!n?`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:g(`min-w-0 flex-1 cursor-pointer rounded-lg text-left outline-none`,z.focusRingPanel),"aria-labelledby":`catalog-skill-title-${e.directoryId}`,onClick:()=>void C(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:r.displayName})}),!t&&!n?(0,Q.jsx)(b,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:D===e.name,onClick:()=>void w(e.name,!0),children:D===e.name?a.uploading:a.detailModalEnable}):(0,Q.jsx)(b,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:E===e.name||D===e.name,onClick:()=>void T({name:e.name,source:`catalog`}),children:n?e.plugin?.authorizationStatus===`required`?i?`去授权`:`Connect account`:i?`管理插件`:`Manage plugin`:E===e.name?a.previewUseInChatBusy:a.previewUseInChat})]}),(0,Q.jsx)(`button`,{type:`button`,className:g(`mt-2 flex min-h-0 w-full flex-1 cursor-pointer flex-col rounded-lg text-left outline-none`,z.focusRingPanel),"aria-labelledby":`catalog-skill-title-${e.directoryId}`,onClick:()=>void C(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:r.description||void 0,children:r.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:x(e)}),(0,Q.jsxs)(`span`,{className:g(`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 font-medium`,t&&!n?`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&&!n?(0,Q.jsx)(u,{className:`size-3`,"aria-hidden":!0}):(0,Q.jsx)(S,{className:`size-3`,"aria-hidden":!0}),n?e.plugin?.authorizationStatus===`required`?i?`需要授权`:`Authorization required`:i?`插件未就绪`:`Plugin not ready`:t?a.statusEnabled:a.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:[a.col.managed,`: `,a.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:[a.hubRemote,` ·`,` `,e.hub.kind===`git`?a.hubKindGit:a.hubKindArchive,` ·`,` `,e.hub.source.length>48?`${e.hub.source.slice(0,48)}…`:e.hub.source]}):null]})]})})}),(0,Q.jsx)(ke,{skill:e})]},`${e.directoryId}-${e.path}`)})}),t[29]=p,t[30]=h,t[31]=w,t[32]=T,t[33]=C,t[34]=_,t[35]=a,t[36]=m,t[37]=x,t[38]=D,t[39]=E,t[40]=i,t[41]=k):k=t[41];let A;return t[42]!==O||t[43]!==k?(A=(0,Q.jsxs)(Q.Fragment,{children:[O,k]}),t[42]=O,t[43]=k,t[44]=A):A=t[44],A}function Ve(e){return(0,Q.jsx)(Ne,{},e)}function He(e){return e.language}function Ue(e){let t=(0,Z.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)(ie,{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)(M,{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?_e(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)(b,{type:`button`,variant:`secondary`,onClick:p,children:n.cancel}),t[13]=n.cancel,t[14]=p,t[15]=m):m=t[15];let h;t[16]===s?h=t[17]:(h=()=>void s(),t[16]=s,t[17]=h);let g;t[18]!==n.deleteConfirm||t[19]!==h?(g=(0,Q.jsx)(b,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:h,children:n.deleteConfirm}),t[18]=n.deleteConfirm,t[19]=h,t[20]=g):g=t[20];let _;t[21]!==m||t[22]!==g?(_=(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[m,g]}),t[21]=m,t[22]=g,t[23]=_):_=t[23];let v;t[24]!==_||t[25]!==u||t[26]!==f?(v=(0,Q.jsxs)(C,{children:[l,(0,Q.jsxs)(k,{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-overlay p-4 shadow-popover dark:border-edge`,children:[u,f,_]})]}),t[24]=_,t[25]=u,t[26]=f,t[27]=v):v=t[27];let y;return t[28]!==r||t[29]!==c||t[30]!==v?(y=(0,Q.jsx)(T,{open:r,onOpenChange:c,children:v}),t[28]=r,t[29]=c,t[30]=v,t[31]=y):y=t[31],y}function We(e){let t=(0,Z.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 Ge(e){let t=(0,Z.c)(119),{preview:n,description:r,sk:i}=e,a=n.metadata,o=n.toolConditions,s=!!o&&(o.requiresTools.length>0||o.requiresToolsets.length>0||o.fallbackForTools.length>0||o.fallbackForToolsets.length>0),c=a.requires,l=c&&((c.bins?.length??0)>0||(c.env?.length??0)>0||(c.anyBins?.length??0)>0),u,d,f,p,m,h,_,v,y,b,x,S,C,w,T;if(t[0]!==r||t[1]!==o||t[2]!==l||t[3]!==s||t[4]!==a.emoji||t[5]!==a.homepage||t[6]!==a.install||t[7]!==a.os||t[8]!==n.description||t[9]!==n.disableModelInvocation||t[10]!==n.requiredEnvVarNames||t[11]!==c||t[12]!==i.detailEnvVarsLabel||t[13]!==i.detailHomepageLabel||t[14]!==i.detailInstallLabel||t[15]!==i.detailNotInjectedNote||t[16]!==i.detailPlatformsLabel||t[17]!==i.detailRequiresAnyBins||t[18]!==i.detailRequiresBins||t[19]!==i.detailRequiresEnv||t[20]!==i.detailRequiresLabel||t[21]!==i.detailSummaryHeading||t[22]!==i.detailToolGatingLabel||t[23]!==i.detailToolsFallbackList||t[24]!==i.detailToolsRequiresList||t[25]!==i.detailToolsetsFallbackList||t[26]!==i.detailToolsetsRequiresList){let e=a.install?.filter(Je)??[],E=n.requiredEnvVarNames?.filter(qe)??[];_=`space-y-6`,m=`skill-detail-summary-heading`,t[42]===i.detailSummaryHeading?h=t[43]:(h=(0,Q.jsx)(`h3`,{id:`skill-detail-summary-heading`,className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:i.detailSummaryHeading}),t[42]=i.detailSummaryHeading,t[43]=h),y=`rounded-xl border border-edge bg-surface-base px-4 py-3 dark:bg-surface-hover/25`,t[44]===a.emoji?b=t[45]:(b=a.emoji?.trim()?(0,Q.jsx)(`p`,{className:`text-2xl leading-none`,"aria-hidden":!0,children:a.emoji.trim()}):null,t[44]=a.emoji,t[45]=b);let D;t[46]===a.emoji?D=t[47]:(D=a.emoji?.trim()?`mt-2`:``,t[46]=a.emoji,t[47]=D);let O;t[48]===D?O=t[49]:(O=g(`text-sm leading-relaxed text-fg`,D),t[48]=D,t[49]=O);let k=r??n.description;t[50]!==O||t[51]!==k?(x=(0,Q.jsx)(`p`,{className:O,children:k}),t[50]=O,t[51]=k,t[52]=x):x=t[52],t[53]!==n.disableModelInvocation||t[54]!==i.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:i.detailNotInjectedNote}):null,t[53]=n.disableModelInvocation,t[54]=i.detailNotInjectedNote,t[55]=S):S=t[55];let A;t[56]===a.homepage?A=t[57]:(A=a.homepage?.trim()?(0,Q.jsx)(`a`,{href:a.homepage.trim(),target:`_blank`,rel:`noopener noreferrer`,className:`break-all text-accent underline-offset-2 hover:underline`,children:a.homepage.trim()}):null,t[56]=a.homepage,t[57]=A),t[58]!==i.detailHomepageLabel||t[59]!==A?(C=(0,Q.jsx)(We,{label:i.detailHomepageLabel,children:A}),t[58]=i.detailHomepageLabel,t[59]=A,t[60]=C):C=t[60];let j;t[61]===a.os?j=t[62]:(j=a.os&&a.os.length>0?(0,Q.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:a.os.join(`, `)}):null,t[61]=a.os,t[62]=j),t[63]!==i.detailPlatformsLabel||t[64]!==j?(w=(0,Q.jsx)(We,{label:i.detailPlatformsLabel,children:j}),t[63]=i.detailPlatformsLabel,t[64]=j,t[65]=w):w=t[65];let M;t[66]!==l||t[67]!==c||t[68]!==i.detailRequiresAnyBins||t[69]!==i.detailRequiresBins||t[70]!==i.detailRequiresEnv?(M=l&&c?(0,Q.jsxs)(`ul`,{className:`list-inside list-disc space-y-1 text-sm text-fg-muted`,children:[c.bins&&c.bins.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`text-fg`,children:[i.detailRequiresBins,`: `]}),c.bins.join(`, `)]}):null,c.env&&c.env.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`text-fg`,children:[i.detailRequiresEnv,`: `]}),(0,Q.jsx)(`span`,{className:`font-mono text-xs`,children:c.env.join(`, `)})]}):null,c.anyBins&&c.anyBins.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`text-fg`,children:[i.detailRequiresAnyBins,`: `]}),c.anyBins.join(`, `)]}):null]}):null,t[66]=l,t[67]=c,t[68]=i.detailRequiresAnyBins,t[69]=i.detailRequiresBins,t[70]=i.detailRequiresEnv,t[71]=M):M=t[71],t[72]!==i.detailRequiresLabel||t[73]!==M?(T=(0,Q.jsx)(We,{label:i.detailRequiresLabel,children:M}),t[72]=i.detailRequiresLabel,t[73]=M,t[74]=T):T=t[74];let N=e.length>0?(0,Q.jsx)(`ul`,{className:`list-inside list-decimal space-y-1.5 text-sm text-fg-muted`,children:e.map(Ke)}):null;t[75]!==i.detailInstallLabel||t[76]!==N?(f=(0,Q.jsx)(We,{label:i.detailInstallLabel,children:N}),t[75]=i.detailInstallLabel,t[76]=N,t[77]=f):f=t[77];let P;t[78]!==o||t[79]!==s||t[80]!==i.detailToolsFallbackList||t[81]!==i.detailToolsRequiresList||t[82]!==i.detailToolsetsFallbackList||t[83]!==i.detailToolsetsRequiresList?(P=s&&o?(0,Q.jsxs)(`ul`,{className:`mt-1 space-y-2 text-sm text-fg-muted`,children:[o.requiresTools.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg`,children:[i.detailToolsRequiresList,`: `]}),o.requiresTools.join(`, `)]}):null,o.requiresToolsets.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg`,children:[i.detailToolsetsRequiresList,`: `]}),o.requiresToolsets.join(`, `)]}):null,o.fallbackForTools.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg`,children:[i.detailToolsFallbackList,`: `]}),o.fallbackForTools.join(`, `)]}):null,o.fallbackForToolsets.length>0?(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg`,children:[i.detailToolsetsFallbackList,`: `]}),o.fallbackForToolsets.join(`, `)]}):null]}):null,t[78]=o,t[79]=s,t[80]=i.detailToolsFallbackList,t[81]=i.detailToolsRequiresList,t[82]=i.detailToolsetsFallbackList,t[83]=i.detailToolsetsRequiresList,t[84]=P):P=t[84],t[85]!==i.detailToolGatingLabel||t[86]!==P?(p=(0,Q.jsx)(We,{label:i.detailToolGatingLabel,children:P}),t[85]=i.detailToolGatingLabel,t[86]=P,t[87]=p):p=t[87],u=We,d=i.detailEnvVarsLabel,v=E.length>0?(0,Q.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:E.join(`, `)}):null,t[0]=r,t[1]=o,t[2]=l,t[3]=s,t[4]=a.emoji,t[5]=a.homepage,t[6]=a.install,t[7]=a.os,t[8]=n.description,t[9]=n.disableModelInvocation,t[10]=n.requiredEnvVarNames,t[11]=c,t[12]=i.detailEnvVarsLabel,t[13]=i.detailHomepageLabel,t[14]=i.detailInstallLabel,t[15]=i.detailNotInjectedNote,t[16]=i.detailPlatformsLabel,t[17]=i.detailRequiresAnyBins,t[18]=i.detailRequiresBins,t[19]=i.detailRequiresEnv,t[20]=i.detailRequiresLabel,t[21]=i.detailSummaryHeading,t[22]=i.detailToolGatingLabel,t[23]=i.detailToolsFallbackList,t[24]=i.detailToolsRequiresList,t[25]=i.detailToolsetsFallbackList,t[26]=i.detailToolsetsRequiresList,t[27]=u,t[28]=d,t[29]=f,t[30]=p,t[31]=m,t[32]=h,t[33]=_,t[34]=v,t[35]=y,t[36]=b,t[37]=x,t[38]=S,t[39]=C,t[40]=w,t[41]=T}else u=t[27],d=t[28],f=t[29],p=t[30],m=t[31],h=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=t[41];let E;t[88]!==u||t[89]!==d||t[90]!==v?(E=(0,Q.jsx)(u,{label:d,children:v}),t[88]=u,t[89]=d,t[90]=v,t[91]=E):E=t[91];let D;t[92]!==f||t[93]!==p||t[94]!==E||t[95]!==y||t[96]!==b||t[97]!==x||t[98]!==S||t[99]!==C||t[100]!==w||t[101]!==T?(D=(0,Q.jsxs)(`div`,{className:y,children:[b,x,S,C,w,T,f,p,E]}),t[92]=f,t[93]=p,t[94]=E,t[95]=y,t[96]=b,t[97]=x,t[98]=S,t[99]=C,t[100]=w,t[101]=T,t[102]=D):D=t[102];let O;t[103]!==m||t[104]!==h||t[105]!==D?(O=(0,Q.jsxs)(`section`,{"aria-labelledby":m,children:[h,D]}),t[103]=m,t[104]=h,t[105]=D,t[106]=O):O=t[106];let k;t[107]===i.detailInstructionsHeading?k=t[108]:(k=(0,Q.jsx)(`h3`,{id:`skill-detail-instructions-heading`,className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:i.detailInstructionsHeading}),t[107]=i.detailInstructionsHeading,t[108]=k);let A;t[109]!==n.bodyMarkdown||t[110]!==i.detailNoInstructionsBody?(A=n.bodyMarkdown.trim()?(0,Q.jsx)(`div`,{className:`markdown-content min-w-0 break-words`,children:(0,Q.jsx)(F,{content:n.bodyMarkdown})}):(0,Q.jsx)(`p`,{className:`text-sm italic text-fg-muted`,children:i.detailNoInstructionsBody}),t[109]=n.bodyMarkdown,t[110]=i.detailNoInstructionsBody,t[111]=A):A=t[111];let j;t[112]!==k||t[113]!==A?(j=(0,Q.jsxs)(`section`,{"aria-labelledby":`skill-detail-instructions-heading`,children:[k,A]}),t[112]=k,t[113]=A,t[114]=j):j=t[114];let M;return t[115]!==_||t[116]!==O||t[117]!==j?(M=(0,Q.jsxs)(`div`,{className:_,children:[O,j]}),t[115]=_,t[116]=O,t[117]=j,t[118]=M):M=t[118],M}function Ke(e,t){return(0,Q.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:(0,Q.jsx)(`span`,{className:`text-fg`,children:be(e)})},e.id||`${e.kind}-${t}`)}function qe(e){return e.trim()}function Je(e){return e&&typeof e.kind==`string`}var Ye=[{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 Xe(e){let t=(0,Z.c)(86),n=v(Qe).startsWith(`zh`),r;t[0]===e.detailFromCatalog?r=t[1]:(r=e.detailFromCatalog&&Oe(e.detailFromCatalog),t[0]=e.detailFromCatalog,t[1]=r);let i=r,a=i?e.detailFromCatalog?.plugin?.authorizationStatus===`required`?n?`去授权`:`Connect account`:n?`管理插件`:`Manage plugin`:e.sk.previewUseInChat,{sk:o,detailOpen:s,setDetailOpen:c,detailSource:l,setDetailSource:u,detailTitle:d,setDetailTitle:f,detailCatalogPreview:m,setDetailCatalogPreview:h,detailMarketplacePreview:_,setDetailMarketplacePreview:y,detailLoading:x,detailError:S,setDetailError:w,detailEnabled:E,detailPresentation:D,detailDirectoryId:A,detailManaged:j,detailFromCatalog:N,detailExternalUrl:P,usingSkillInChatName:F,installingMarketName:I,togglingSkillName:R,isSkillInstalledByName:B,onUseSkillInChat:V,onMarketInstall:U,onSkillToggle:W,setConfirmId:G,setConfirmOpen:K}=e,q;t[2]!==h||t[3]!==w||t[4]!==y||t[5]!==c||t[6]!==u||t[7]!==f?(q=e=>{c(e),e||(u(`catalog`),h(null),y(null),w(null),f(``))},t[2]=h,t[3]=w,t[4]=y,t[5]=c,t[6]=u,t[7]=f,t[8]=q):q=t[8];let J;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Q.jsx)(ie,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[9]=J):J=t[9];let Y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(Y=g(`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-overlay shadow-float dark:border-edge`),t[10]=Y):Y=t[10];let te=d||`?`,ne;t[11]===te?ne=t[12]:(ne=(0,Q.jsx)(de,{name:te}),t[11]=te,t[12]=ne);let re=D?.displayName||d||`—`,ae;t[13]===re?ae=t[14]:(ae=(0,Q.jsx)(M,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:re}),t[13]=re,t[14]=ae);let oe;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(oe=g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,z.focusRingPanel),t[15]=oe):oe=t[15];let se;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(ee,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=se):se=t[16];let ce;t[17]===o.detailCloseAria?ce=t[18]:(ce=(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:oe,"aria-label":o.detailCloseAria,children:se})}),t[17]=o.detailCloseAria,t[18]=ce);let le;t[19]!==ce||t[20]!==ne||t[21]!==ae?(le=(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:[ne,ae,ce]}),t[19]=ce,t[20]=ne,t[21]=ae,t[22]=le):le=t[22];let ue;t[23]===N?ue=t[24]:(ue=N?(0,Q.jsx)(ke,{skill:N,detail:!0}):null,t[23]=N,t[24]=ue);let fe;t[25]!==m||t[26]!==E||t[27]!==S||t[28]!==x||t[29]!==_||t[30]!==D?.description||t[31]!==l||t[32]!==o||t[33]!==i?(fe=x?(0,Q.jsx)(`div`,{className:`flex h-full min-h-[14rem] flex-col gap-2.5 py-1`,"aria-busy":`true`,"aria-label":o.loading,children:Ye.map(Ze)}):S?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):l===`catalog`&&m?(0,Q.jsxs)(Q.Fragment,{children:[!E&&!i?(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)(H,{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:o.detailDisabledNotice})]}):null,(0,Q.jsx)(Ge,{preview:m,description:D?.description,sk:o})]}):l===`store`&&_?(0,Q.jsx)(Ge,{preview:_,sk:o}):(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o.detailLoadFailed}),t[25]=m,t[26]=E,t[27]=S,t[28]=x,t[29]=_,t[30]=D?.description,t[31]=l,t[32]=o,t[33]=i,t[34]=fe):fe=t[34];let pe;t[35]!==ue||t[36]!==fe?(pe=(0,Q.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto p-4`,children:[ue,fe]}),t[35]=ue,t[36]=fe,t[37]=pe):pe=t[37];let me;t[38]!==P||t[39]!==l||t[40]!==o.marketplaceOpenExternal||t[41]!==o.marketplaceOpenExternalAria?(me=l===`store`&&P?(0,Q.jsxs)(`a`,{href:P,target:`_blank`,rel:`noopener noreferrer`,className:g(`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`,z.focusRingPanel),"aria-label":o.marketplaceOpenExternalAria,title:o.marketplaceOpenExternal,children:[(0,Q.jsx)(p,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:o.marketplaceOpenExternal})]}):null,t[38]=P,t[39]=l,t[40]=o.marketplaceOpenExternal,t[41]=o.marketplaceOpenExternalAria,t[42]=me):me=t[42];let he;t[43]!==A||t[44]!==j||t[45]!==l||t[46]!==G||t[47]!==K||t[48]!==o.delete?(he=l===`catalog`&&j&&A?(0,Q.jsxs)(b,{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:()=>{G(A),K(!0)},children:[(0,Q.jsx)(L,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),o.delete]}):null,t[43]=A,t[44]=j,t[45]=l,t[46]=G,t[47]=K,t[48]=o.delete,t[49]=he):he=t[49];let ge;t[50]!==me||t[51]!==he?(ge=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[me,he]}),t[50]=me,t[51]=he,t[52]=ge):ge=t[52];let _e;t[53]!==a||t[54]!==E||t[55]!==x||t[56]!==l||t[57]!==d||t[58]!==I||t[59]!==B||t[60]!==U||t[61]!==W||t[62]!==V||t[63]!==c||t[64]!==o.cancel||t[65]!==o.detailModalDisable||t[66]!==o.detailModalEnable||t[67]!==o.marketplaceInstall||t[68]!==o.marketplaceReinstall||t[69]!==o.previewUseInChatBusy||t[70]!==o.uploading||t[71]!==o.useRequiresEnabled||t[72]!==R||t[73]!==F?(_e=(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:l===`store`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{type:`button`,variant:`ghost`,onClick:()=>c(!1),children:o.cancel}),(0,Q.jsx)(b,{type:`button`,variant:`secondary`,disabled:!d||x||F===d||I===d,onClick:()=>void V(),children:F===d?o.previewUseInChatBusy:a}),(0,Q.jsx)(b,{type:`button`,variant:B(d)?`secondary`:`primary`,disabled:!d||I===d,onClick:()=>{d&&U(d,{useDetailProvider:!0})},children:I===d?o.uploading:B(d)?o.marketplaceReinstall:o.marketplaceInstall})]}):(0,Q.jsxs)(Q.Fragment,{children:[E?(0,Q.jsx)(b,{type:`button`,variant:`secondary`,disabled:!d||R===d,onClick:()=>{d&&W(d,!1)},children:R===d?o.uploading:o.detailModalDisable}):(0,Q.jsx)(b,{type:`button`,variant:`primary`,disabled:!d||R===d,onClick:()=>{d&&W(d,!0)},children:R===d?o.uploading:o.detailModalEnable}),(0,Q.jsx)(b,{type:`button`,variant:`secondary`,disabled:!d||!E||x||F===d||R===d,title:E?void 0:o.useRequiresEnabled,onClick:()=>void V(),children:F===d?o.previewUseInChatBusy:a})]})}),t[53]=a,t[54]=E,t[55]=x,t[56]=l,t[57]=d,t[58]=I,t[59]=B,t[60]=U,t[61]=W,t[62]=V,t[63]=c,t[64]=o.cancel,t[65]=o.detailModalDisable,t[66]=o.detailModalEnable,t[67]=o.marketplaceInstall,t[68]=o.marketplaceReinstall,t[69]=o.previewUseInChatBusy,t[70]=o.uploading,t[71]=o.useRequiresEnabled,t[72]=R,t[73]=F,t[74]=_e):_e=t[74];let ve;t[75]!==ge||t[76]!==_e?(ve=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge px-4 py-3`,children:[ge,_e]}),t[75]=ge,t[76]=_e,t[77]=ve):ve=t[77];let ye;t[78]!==le||t[79]!==pe||t[80]!==ve?(ye=(0,Q.jsxs)(C,{children:[J,(0,Q.jsxs)(k,{className:Y,children:[le,pe,ve]})]}),t[78]=le,t[79]=pe,t[80]=ve,t[81]=ye):ye=t[81];let be;return t[82]!==s||t[83]!==q||t[84]!==ye?(be=(0,Q.jsx)(T,{open:s,onOpenChange:q,children:ye}),t[82]=s,t[83]=q,t[84]=ye,t[85]=be):be=t[85],be}function Ze(e){return(0,Q.jsx)(`div`,{className:g(`h-4 animate-pulse rounded-md bg-surface-hover dark:bg-surface-active/50`,e.width)},e.id)}function Qe(e){return e.language}function $e(e){let t=(0,Z.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:p,onInstallSubmit:m}=e,h;t[0]!==c||t[1]!==i||t[2]!==o?(h=e=>{i(e),e||(o(null),c(!1))},t[0]=c,t[1]=i,t[2]=o,t[3]=h):h=t[3];let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(ie,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[4]=_):_=t[4];let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=g(`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-overlay p-6 shadow-float dark:border-edge`),t[5]=v):v=t[5];let y;t[6]===n.installModalTitle?y=t[7]:(y=(0,Q.jsx)(M,{className:`text-base font-semibold text-fg`,children:n.installModalTitle}),t[6]=n.installModalTitle,t[7]=y);let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,z.focusRingPanel),t[8]=b):b=t[8];let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(ee,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=x):x=t[9];let S;t[10]===n.installClose?S=t[11]:(S=(0,Q.jsx)(`span`,{className:`sr-only`,children:n.installClose}),t[10]=n.installClose,t[11]=S);let w;t[12]!==n.installClose||t[13]!==S?(w=(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:b,"aria-label":n.installClose,children:[x,S]})}),t[12]=n.installClose,t[13]=S,t[14]=w):w=t[14];let E;t[15]!==y||t[16]!==w?(E=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[y,w]}),t[15]=y,t[16]=w,t[17]=E):E=t[17];let D=s?`border-accent bg-accent-soft/60 dark:bg-blue-950/40`:`border-edge bg-surface-base dark:bg-surface-hover/30`,A;t[18]===D?A=t[19]:(A=g(`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`,D),t[18]=D,t[19]=A);let j;t[20]!==p||t[21]!==n.installModalDropHint||t[22]!==l?(j=(0,Q.jsx)(`input`,{type:`file`,accept:`.zip,.md,application/zip,text/markdown`,className:`sr-only`,"aria-label":n.installModalDropHint,disabled:l,onChange:p}),t[20]=p,t[21]=n.installModalDropHint,t[22]=l,t[23]=j):j=t[23];let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(G,{className:`size-12 text-fg-subtle`,strokeWidth:1.25,"aria-hidden":!0}),t[24]=N):N=t[24];let P;t[25]===n.installModalDropHint?P=t[26]:(P=(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.installModalDropHint}),t[25]=n.installModalDropHint,t[26]=P);let F;t[27]===a?F=t[28]:(F=a?(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:a.name}):null,t[27]=a,t[28]=F);let I;t[29]!==d||t[30]!==u||t[31]!==f||t[32]!==A||t[33]!==j||t[34]!==P||t[35]!==F?(I=(0,Q.jsxs)(`label`,{className:A,onDragLeave:d,onDragOver:u,onDrop:f,children:[j,N,P,F]}),t[29]=d,t[30]=u,t[31]=f,t[32]=A,t[33]=j,t[34]=P,t[35]=F,t[36]=I):I=t[36];let L;t[37]===n.installModalReqTitle?L=t[38]:(L=(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.installModalReqTitle}),t[37]=n.installModalReqTitle,t[38]=L);let R;t[39]===n.installModalReq1?R=t[40]:(R=(0,Q.jsx)(`li`,{children:n.installModalReq1}),t[39]=n.installModalReq1,t[40]=R);let B;t[41]===n.installModalReq2?B=t[42]:(B=(0,Q.jsx)(`li`,{children:n.installModalReq2}),t[41]=n.installModalReq2,t[42]=B);let V;t[43]!==R||t[44]!==B?(V=(0,Q.jsxs)(`ul`,{className:`list-inside list-disc space-y-1 text-sm text-fg-muted`,children:[R,B]}),t[43]=R,t[44]=B,t[45]=V):V=t[45];let H;t[46]!==L||t[47]!==V?(H=(0,Q.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[L,V]}),t[46]=L,t[47]=V,t[48]=H):H=t[48];let U=!a||l,W=!a||l?`cursor-not-allowed bg-surface-active text-fg-disabled`:`bg-accent text-on-accent hover:bg-accent-hover`,K;t[49]===W?K=t[50]:(K=g(`mt-6 flex w-full items-center justify-center rounded-xl py-3 text-sm font-semibold`,`transition-colors`,W,z.focusRingPanel),t[49]=W,t[50]=K);let q;t[51]===m?q=t[52]:(q=()=>void m(),t[51]=m,t[52]=q);let J=l?n.uploading:n.installAction,Y;t[53]!==U||t[54]!==K||t[55]!==q||t[56]!==J?(Y=(0,Q.jsx)(`button`,{type:`button`,disabled:U,className:K,onClick:q,children:J}),t[53]=U,t[54]=K,t[55]=q,t[56]=J,t[57]=Y):Y=t[57];let te;t[58]!==I||t[59]!==H||t[60]!==Y||t[61]!==E?(te=(0,Q.jsxs)(C,{children:[_,(0,Q.jsxs)(k,{className:v,children:[E,I,H,Y]})]}),t[58]=I,t[59]=H,t[60]=Y,t[61]=E,t[62]=te):te=t[62];let ne;return t[63]!==r||t[64]!==h||t[65]!==te?(ne=(0,Q.jsx)(T,{open:r,onOpenChange:h,children:te}),t[63]=r,t[64]=h,t[65]=te,t[66]=ne):ne=t[66],ne}function et(e){let t=(0,Z.c)(30),{sk:n,mpCategories:r,mpCategoriesLoading:i,mpCategoriesError:a,mpPayload:o,mpLoading:s,mpError:c,marketCategoryId:l,setMarketCategoryId:d,mpHasMore:f,onLoadMoreMarket:p,onRetryMarket:m,isSkillInstalledByName:h,openMarketplaceDetail:_,onMarketInstall:v,installingMarketName:y,onUseSkillInChat:x,usingSkillInChatName:S,searchInputActive:C,searchQuery:T,setSearchQuery:E,registeredProviders:D,marketplacePresentation:O,marketBrowseProvider:k,setMarketBrowseProvider:j}=e,M=!C,N;t[0]===k?N=t[1]:(N=e=>e.id!==k,t[0]=k,t[1]=N);let P=D.filter(N),F=T.trim(),I;t[2]===n.marketplaceCategoryAll?I=t[3]:(I={id:``,label:n.marketplaceCategoryAll},t[2]=n.marketplaceCategoryAll,t[3]=I);let L;t[4]!==r||t[5]!==I?(L=[I,...r.map($)],t[4]=r,t[5]=I,t[6]=L):L=t[6];let R=L,B;t[7]===r?B=t[8]:(B=new Map(r.map(at)),t[7]=r,t[8]=B);let ee=B,H=(0,X.useRef)(null),U,W;t[9]!==c||t[10]!==f||t[11]!==s||t[12]!==p?(U=()=>{let e=H.current;if(!e||!f||s||c)return;let t=new IntersectionObserver(e=>{e.some(it)&&p()},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},W=[f,s,c,p],t[9]=c,t[10]=f,t[11]=s,t[12]=p,t[13]=U,t[14]=W):(U=t[13],W=t[14]),(0,X.useEffect)(U,W);let G;t[15]!==R||t[16]!==l||t[17]!==r.length||t[18]!==i||t[19]!==d||t[20]!==M||t[21]!==n.marketplaceCategoriesAria?(G=M?r.length>0?(0,Q.jsx)(te,{items:R,activeTab:l,onChange:d,ariaLabel:n.marketplaceCategoriesAria,tabIdPrefix:`skills-marketplace-category-tab`,className:`min-h-[2.75rem] items-center gap-2 pt-0.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,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:none] [&::-webkit-scrollbar]:hidden`,"aria-hidden":!0,children:[`p0`,`p1`,`p2`,`p3`,`p4`].map(rt)}):null:null,t[15]=R,t[16]=l,t[17]=r.length,t[18]=i,t[19]=d,t[20]=M,t[21]=n.marketplaceCategoriesAria,t[22]=G):G=t[22];let K;t[23]!==a||t[24]!==M?(K=M&&a?(0,Q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,role:`alert`,children:a}):null,t[23]=a,t[24]=M,t[25]=K):K=t[25];let q=!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:Re.map(nt)}):c&&!o?(0,Q.jsxs)(`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:[(0,Q.jsx)(`p`,{children:c}),(0,Q.jsx)(b,{className:`mt-2`,onClick:m,children:n.marketplaceRetry})]}):o?(0,Q.jsxs)(`div`,{className:`relative`,children:[o.items.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center text-sm text-fg-muted`,children:[(0,Q.jsx)(`p`,{className:`px-4`,children:C&&F?_e(n.marketplaceEmptySearch,{query:F}):n.marketplaceEmpty}),(0,Q.jsx)(Te,{sk:n,findingSkills:e.findingSkills,onFindSkills:e.onFindSkills,secondary:!0}),C?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[P.map(e=>(0,Q.jsx)(b,{type:`button`,variant:`secondary`,className:`h-8 px-3 text-xs`,onClick:()=>j(e.id),children:_e(n.marketplaceEmptySearchTryProvider,{provider:e.displayName})},e.id)),(0,Q.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 px-3 text-xs`,onClick:()=>E(``),children:n.marketplaceEmptySearchClear})]}):null]}):(0,Q.jsx)(`div`,{className:g(`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`),children:o.items.map(e=>{let t=O(e),r=me(e,e.providerId??k),i=h(r),a=e.category??e.categories?.[0],o=a?ee.get(a)??a:null;return(0,Q.jsxs)(`article`,{className:g(`group flex h-full flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,`transition-colors hover:bg-surface-hover [content-visibility:auto] [contain-intrinsic-size:auto_220px]`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(w,{iconUrl:e.branding?.iconUrl,fallback:A}),(0,Q.jsx)(`button`,{type:`button`,className:g(`min-w-0 flex-1 rounded-lg text-left outline-none`,z.focusRingPanel),onClick:()=>void _(r,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:t.displayName})}),i?(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)(u,{className:`size-3`,"aria-hidden":!0}),n.marketplaceInstalled]}):(0,Q.jsx)(b,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:y===r,onClick:()=>void v(r,{providerOverride:e.providerId??null}),children:y===r?n.uploading:n.marketplaceInstall})]}),(0,Q.jsx)(`button`,{type:`button`,className:g(`mt-2 flex min-h-0 w-full flex-1 cursor-pointer flex-col rounded-lg text-left outline-none`,z.focusRingPanel),"aria-labelledby":`mp-skill-title-${e.id}`,onClick:()=>void _(r,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:t.description||void 0,children:t.description||`—`}),o?(0,Q.jsx)(`span`,{className:`w-fit max-w-full truncate rounded-full bg-surface-inset px-2 py-0.5 text-[10px] font-medium text-fg-muted`,children:o}):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}`:``}${i?` · ${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)(V,{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]})]})})}),i?(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)(b,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:S===r,onClick:()=>void x({name:r,source:`store`,providerOverride:e.providerId??null}),children:S===r?n.previewUseInChatBusy:n.previewUseInChat})}):null]},e.id)})}),(0,Q.jsx)(`div`,{ref:H,className:`h-1`,"aria-hidden":!0}),s?(0,Q.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,"aria-busy":`true`,"aria-label":n.loading,children:Re.slice(0,3).map(tt)}):c?(0,Q.jsxs)(`div`,{className:`mt-4 text-center`,role:`alert`,children:[(0,Q.jsx)(`p`,{className:`mb-2 text-sm text-fg-muted`,children:c}),(0,Q.jsx)(b,{onClick:m,children:n.marketplaceRetry})]}):!f&&o.items.length>0?(0,Q.jsx)(`p`,{className:`mt-4 text-center text-xs text-fg-subtle`,children:C?n.marketplaceSearchEnd:n.marketplaceEnd}):null]}):null,J;return t[26]!==G||t[27]!==K||t[28]!==q?(J=(0,Q.jsxs)(Q.Fragment,{children:[G,K,q]}),t[26]=G,t[27]=K,t[28]=q,t[29]=J):J=t[29],J}function tt(e){return(0,Q.jsx)(Me,{},e)}function nt(e){return(0,Q.jsx)(Me,{},e)}function rt(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 it(e){return e.isIntersecting}function at(e){return[e.id,e.label]}function $(e){return{id:e.id,label:e.label,title:e.label}}function ot(e){let t=(0,Z.c)(141),{vm:n,embedded:r,onHeaderActionChange:i}=e,a=r===void 0?!1:r,{sk:o,hasToken:s,error:c,actionFeedback:u,skillDiagnostics:d,mainTab:f,setMainTab:p,sourceFilter:m,setSourceFilter:h,builtinTabStats:_,userTabStats:v,catalogDisabledCount:y,catalogStatusFilter:x,setCatalogStatusFilter:S,marketSort:C,setMarketSort:w,marketBrowseProvider:T,setMarketBrowseProvider:E,registeredProviders:D,searchInputActive:O,resultTab:k,setResultTab:A,aggregatedTabCounts:j,aggregatedProviderStatus:M,recoveryReturnPath:N}=n,P,F,I,L,R,z,B,V,ee;if(t[0]!==u||t[1]!==M||t[2]!==j||t[3]!==_||t[4]!==a||t[5]!==c||t[6]!==s||t[7]!==i||t[8]!==N||t[9]!==D||t[10]!==o.diagnosticsTitle||t[11]!==o.marketplaceLoadFailed||t[12]!==o.marketplaceResultsTabAll||t[13]!==o.needToken||t[14]!==o.recoveryDone||t[15]!==o.recoveryHint||t[16]!==o.recoveryTitle||t[17]!==o.tabDiscover||t[18]!==o.tabInstalled||t[19]!==d||t[20]!==v||t[21]!==n){ee=Symbol.for(`react.early_return_sentinel`);bb0:{let e=fe(d);if(!s){let e;t[31]!==a||t[32]!==i||t[33]!==n?(e=(0,Q.jsx)(ut,{vm:n,embedded:a,onHeaderActionChange:i}),t[31]=a,t[32]=i,t[33]=n,t[34]=e):e=t[34];let r;t[35]===o.needToken?r=t[36]:(r=(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:o.needToken}),t[35]=o.needToken,t[36]=r);let s;t[37]!==r||t[38]!==e?(s=(0,Q.jsxs)(Q.Fragment,{children:[e,r]}),t[37]=r,t[38]=e,t[39]=s):s=t[39],ee=s;break bb0}let r=_.total+v.total,l;t[40]!==r||t[41]!==o.tabInstalled?(l={id:`installed`,label:o.tabInstalled,count:r},t[40]=r,t[41]=o.tabInstalled,t[42]=l):l=t[42];let f;t[43]===o.tabDiscover?f=t[44]:(f={id:`marketplace`,label:o.tabDiscover},t[43]=o.tabDiscover,t[44]=f);let p;t[45]!==f||t[46]!==l?(p=[l,f],t[45]=f,t[46]=l,t[47]=p):p=t[47],P=p;let m;t[48]===D?m=t[49]:(m=[`all`,...D.map(lt)],t[48]=D,t[49]=m);let h=m,y;t[50]!==M||t[51]!==j||t[52]!==D||t[53]!==o.marketplaceLoadFailed||t[54]!==o.marketplaceResultsTabAll||t[55]!==h?(y=h.map(e=>{let t=e===`all`?o.marketplaceResultsTabAll:D.find(t=>t.id===e)?.displayName??e,n=j[e]??0,r=e===`all`?null:M[e];return{id:e,label:t,title:r===`error`?`${t} · ${o.marketplaceLoadFailed}`:void 0,suffix:r===`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}):r===`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[50]=M,t[51]=j,t[52]=D,t[53]=o.marketplaceLoadFailed,t[54]=o.marketplaceResultsTabAll,t[55]=h,t[56]=y):y=t[56],F=y,t[57]!==a||t[58]!==i||t[59]!==n?(V=(0,Q.jsx)(ut,{vm:n,embedded:a,onHeaderActionChange:i}),t[57]=a,t[58]=i,t[59]=n,t[60]=V):V=t[60],B=`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`;let x=a?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`;t[61]===x?I=t[62]:(I=g(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,x),t[61]=x,t[62]=I),t[63]!==N||t[64]!==o.recoveryDone||t[65]!==o.recoveryHint||t[66]!==o.recoveryTitle||t[67]!==n.onRecoveryDone?(L=N?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:o.recoveryTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.recoveryHint})]}),(0,Q.jsx)(b,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:n.onRecoveryDone,children:o.recoveryDone})]}):null,t[63]=N,t[64]=o.recoveryDone,t[65]=o.recoveryHint,t[66]=o.recoveryTitle,t[67]=n.onRecoveryDone,t[68]=L):L=t[68],t[69]!==u||t[70]!==c?(R=u?(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:g(`rounded-xl border px-3 py-2 text-sm`,u.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:u.message}):c?(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}):null,t[69]=u,t[70]=c,t[71]=R):R=t[71],z=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:_e(o.diagnosticsTitle,{count:e.length})}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.slice(0,3).map(ct)})]}):null}t[0]=u,t[1]=M,t[2]=j,t[3]=_,t[4]=a,t[5]=c,t[6]=s,t[7]=i,t[8]=N,t[9]=D,t[10]=o.diagnosticsTitle,t[11]=o.marketplaceLoadFailed,t[12]=o.marketplaceResultsTabAll,t[13]=o.needToken,t[14]=o.recoveryDone,t[15]=o.recoveryHint,t[16]=o.recoveryTitle,t[17]=o.tabDiscover,t[18]=o.tabInstalled,t[19]=d,t[20]=v,t[21]=n,t[22]=P,t[23]=F,t[24]=I,t[25]=L,t[26]=R,t[27]=z,t[28]=B,t[29]=V,t[30]=ee}else P=t[22],F=t[23],I=t[24],L=t[25],R=t[26],z=t[27],B=t[28],V=t[29],ee=t[30];if(ee!==Symbol.for(`react.early_return_sentinel`))return ee;let H;t[72]!==f||t[73]!==P||t[74]!==p||t[75]!==o.skillsNavAria?(H=(0,Q.jsx)(te,{items:P,activeTab:f,onChange:p,ariaLabel:o.skillsNavAria,tabIdPrefix:`skills-tab`,panelIdPrefix:`skills-panel`,className:`flex-wrap`}),t[72]=f,t[73]=P,t[74]=p,t[75]=o.skillsNavAria,t[76]=H):H=t[76];let U;t[77]!==y||t[78]!==x||t[79]!==f||t[80]!==T||t[81]!==C||t[82]!==D||t[83]!==O||t[84]!==S||t[85]!==E||t[86]!==w||t[87]!==h||t[88]!==o.filterAll||t[89]!==o.filterDisabledOnly||t[90]!==o.filterEnabled||t[91]!==o.filterExtra||t[92]!==o.filterGlobal||t[93]!==o.filterInstalled||t[94]!==o.filterPlugin||t[95]!==o.filterWorkspace||t[96]!==o.marketplaceBrowseSwitchAria||t[97]!==o.marketplaceSortDownloads||t[98]!==o.marketplaceSortLabel||t[99]!==o.marketplaceSortNewest||t[100]!==o.sourceFilterAria||t[101]!==o.statusFilterAria||t[102]!==o.tabBuiltin||t[103]!==m?(U=(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2 sm:justify-end`,children:f===`installed`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(l,{value:m,placeholder:o.filterAll,ariaLabel:o.sourceFilterAria,options:[{value:`all`,label:o.filterAll},{value:`builtin`,label:o.tabBuiltin},{value:`installed`,label:o.filterInstalled},{value:`workspace`,label:o.filterWorkspace},{value:`global`,label:o.filterGlobal},{value:`plugin`,label:o.filterPlugin},{value:`extra`,label:o.filterExtra}],allowEmpty:!1,triggerClassName:`h-9 w-auto min-w-[9rem] bg-surface-panel text-xs shadow-surface`,align:`end`,onChange:e=>h(e)}),(0,Q.jsx)(l,{value:x,placeholder:o.filterAll,ariaLabel:o.statusFilterAria,options:[{value:`all`,label:o.filterAll},{value:`enabled`,label:o.filterEnabled},{value:`disabled`,label:_e(o.filterDisabledOnly,{count:y})}],allowEmpty:!1,triggerClassName:`h-9 w-auto min-w-[9rem] bg-surface-panel text-xs shadow-surface`,align:`end`,onChange:e=>S(e)})]}):(0,Q.jsxs)(Q.Fragment,{children:[O?null:(0,Q.jsx)(l,{value:T??``,placeholder:o.marketplaceBrowseSwitchAria,ariaLabel:o.marketplaceBrowseSwitchAria,options:D.map(st),allowEmpty:!1,triggerClassName:`h-9 w-auto min-w-[9rem] bg-surface-panel text-xs shadow-surface`,align:`end`,onChange:E}),(0,Q.jsx)(l,{value:C,placeholder:o.marketplaceSortLabel,ariaLabel:o.marketplaceSortLabel,options:[{value:`downloads`,label:o.marketplaceSortDownloads},{value:`newest`,label:o.marketplaceSortNewest}],allowEmpty:!1,triggerClassName:`h-9 w-auto min-w-[9rem] bg-surface-panel text-xs shadow-surface`,align:`end`,onChange:e=>w(e)})]})}),t[77]=y,t[78]=x,t[79]=f,t[80]=T,t[81]=C,t[82]=D,t[83]=O,t[84]=S,t[85]=E,t[86]=w,t[87]=h,t[88]=o.filterAll,t[89]=o.filterDisabledOnly,t[90]=o.filterEnabled,t[91]=o.filterExtra,t[92]=o.filterGlobal,t[93]=o.filterInstalled,t[94]=o.filterPlugin,t[95]=o.filterWorkspace,t[96]=o.marketplaceBrowseSwitchAria,t[97]=o.marketplaceSortDownloads,t[98]=o.marketplaceSortLabel,t[99]=o.marketplaceSortNewest,t[100]=o.sourceFilterAria,t[101]=o.statusFilterAria,t[102]=o.tabBuiltin,t[103]=m,t[104]=U):U=t[104];let W;t[105]!==U||t[106]!==H?(W=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 dark:border-edge-subtle sm:flex-row sm:items-center sm:justify-between`,children:[H,U]}),t[105]=U,t[106]=H,t[107]=W):W=t[107];let G;t[108]!==f||t[109]!==k||t[110]!==F||t[111]!==O||t[112]!==A||t[113]!==o.marketplaceResultsTabsAria?(G=f===`marketplace`&&O?(0,Q.jsx)(te,{items:F,activeTab:k,onChange:A,ariaLabel:o.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[108]=f,t[109]=k,t[110]=F,t[111]=O,t[112]=A,t[113]=o.marketplaceResultsTabsAria,t[114]=G):G=t[114];let K;t[115]!==f||t[116]!==n?(K=f===`marketplace`?(0,Q.jsx)(et,{...n}):(0,Q.jsx)(Be,{...n}),t[115]=f,t[116]=n,t[117]=K):K=t[117];let q;t[118]!==W||t[119]!==G||t[120]!==K?(q=(0,Q.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[W,G,K]}),t[118]=W,t[119]=G,t[120]=K,t[121]=q):q=t[121];let J;t[122]!==q||t[123]!==I||t[124]!==L||t[125]!==R||t[126]!==z?(J=(0,Q.jsxs)(`div`,{className:I,children:[L,R,z,q]}),t[122]=q,t[123]=I,t[124]=L,t[125]=R,t[126]=z,t[127]=J):J=t[127];let Y,ne,re;t[128]===n?(Y=t[129],ne=t[130],re=t[131]):(Y=(0,Q.jsx)(Xe,{...n}),ne=(0,Q.jsx)($e,{...n}),re=(0,Q.jsx)(Ue,{...n}),t[128]=n,t[129]=Y,t[130]=ne,t[131]=re);let ie;t[132]!==J||t[133]!==Y||t[134]!==ne||t[135]!==re||t[136]!==B?(ie=(0,Q.jsxs)(`div`,{className:B,children:[J,Y,ne,re]}),t[132]=J,t[133]=Y,t[134]=ne,t[135]=re,t[136]=B,t[137]=ie):ie=t[137];let ae;return t[138]!==ie||t[139]!==V?(ae=(0,Q.jsxs)(Q.Fragment,{children:[V,ie]}),t[138]=ie,t[139]=V,t[140]=ae):ae=t[140],ae}function st(e){return{value:e.id,label:e.displayName}}function ct(e,t){return(0,Q.jsxs)(`li`,{className:`truncate`,children:[e.type,`: `,e.message]},`${e.path??e.skillName??`diagnostic`}-${t}`)}function lt(e){return e.id}function ut(e){let t=(0,Z.c)(22),{vm:n,embedded:r,onHeaderActionChange:i}=e,a=r===void 0?!1:r,{sk:o,hasToken:s,loading:c,onReloadClick:l,searchQuery:u,setSearchQuery:d,mainTab:f,setPendingFile:p,setInstallOpen:m,inSettingsShell:h}=n,g=R(ft),_=R(dt),v;t[0]!==s||t[1]!==c||t[2]!==f||t[3]!==l||t[4]!==u||t[5]!==m||t[6]!==p||t[7]!==d||t[8]!==o||t[9]!==n.findingSkills||t[10]!==n.onFindSkills?(v=s?{searchLabel:f===`marketplace`?o.marketplaceSearchPackages:o.searchPlaceholder,search:(0,Q.jsx)(ae,{value:u,onChange:d,placeholder:f===`marketplace`?o.marketplaceSearchPackages:o.searchPlaceholder}),primary:(0,Q.jsx)(Te,{sk:o,findingSkills:n.findingSkills,onFindSkills:n.onFindSkills,compactOnMobile:!0}),overflow:(0,Q.jsx)(Ee,{loading:c,onReloadClick:l,sk:o,setPendingFile:p,setInstallOpen:m})}:null,t[0]=s,t[1]=c,t[2]=f,t[3]=l,t[4]=u,t[5]=m,t[6]=p,t[7]=d,t[8]=o,t[9]=n.findingSkills,t[10]=n.onFindSkills,t[11]=v):v=t[11];let y=v,b,x;return t[12]!==_||t[13]!==a||t[14]!==s||t[15]!==y||t[16]!==h||t[17]!==i||t[18]!==g||t[19]!==o.title?(b=()=>a?(i?.(y),()=>i?.(null)):!s||h?(_(),()=>_()):(g({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:o.title})}),end:(0,Q.jsx)(oe,{contribution:y})}),()=>_()),x=[_,a,s,y,h,i,g,o.title],t[12]=_,t[13]=a,t[14]=s,t[15]=y,t[16]=h,t[17]=i,t[18]=g,t[19]=o.title,t[20]=b,t[21]=x):(b=t[20],x=t[21]),(0,X.useLayoutEffect)(b,x),null}function dt(e){return e.clearPageHeader}function ft(e){return e.setPageHeader}async function pt(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 mt(e){let t=(0,Z.c)(33),n=_(yt),r=_(vt),i;t[0]!==n||t[1]!==e.category||t[2]!==e.enabled||t[3]!==e.provider||t[4]!==e.sort||t[5]!==r?(i=(t,i)=>!e.enabled||!e.provider||i&&(!i.items.length||i.meta.page>=i.meta.totalPages)?null:[`skills-feed`,n,r,e.provider,e.category,e.sort,t+1],t[0]=n,t[1]=e.category,t[2]=e.enabled,t[3]=e.provider,t[4]=e.sort,t[5]=r,t[6]=i):i=t[6];let a=i,o;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateFirstPage:!1,revalidateOnFocus:!1,shouldRetryOnError:!1,persistSize:!1},t[7]=o):o=t[7];let{data:s,error:c,size:l,setSize:u,isValidating:d,mutate:f}=y(a,_t,o),p=(0,X.useRef)(null),m;t[8]===a?m=t[9]:(m=JSON.stringify(a(0,null)),t[8]=a,t[9]=m);let h=m,g;t[10]===s?g=t[11]:(g=s?.at(-1),t[10]=s,t[11]=g);let v=g,b;t[12]===s?b=t[13]:(b=[...new Map((s??[]).flatMap(gt).map(ht)).values()],t[12]=s,t[13]=b);let x=b,S=e.enabled&&!c&&(d||!s||l>s.length),C=!!(v?.items.length&&v.meta.page<v.meta.totalPages),w;t[14]!==x||t[15]!==v?(w=v?{...v,items:x}:null,t[14]=x,t[15]=v,t[16]=w):w=t[16];let T;t[17]!==c||t[18]!==C||t[19]!==S||t[20]!==h||t[21]!==u||t[22]!==l?(T=()=>{if(S||c||!C||p.current?.scope===h)return;let e=u(l+1);p.current={scope:h,request:e},e.finally(()=>{p.current?.request===e&&(p.current=null)})},t[17]=c,t[18]=C,t[19]=S,t[20]=h,t[21]=u,t[22]=l,t[23]=T):T=t[23];let E;t[24]===f?E=t[25]:(E=()=>{f()},t[24]=f,t[25]=E);let D;return t[26]!==c||t[27]!==C||t[28]!==S||t[29]!==w||t[30]!==T||t[31]!==E?(D={payload:w,loading:S,error:c,hasMore:C,loadMore:T,retry:E},t[26]=c,t[27]=C,t[28]=S,t[29]=w,t[30]=T,t[31]=E,t[32]=D):D=t[32],D}function ht(e){return[e.id,e]}function gt(e){return e.items}function _t(e){let[,,,t,n,r,i]=e;return ye({provider:t,category:n,sort:r,page:i,pageSize:20})}function vt(e){return e.conversationId}function yt(e){return e.baseUrl}function bt(){let e=v(e=>e.language),t=h(e).skills,n=!!_(e=>e.conversationId),r=c(),i=a(),[s,l]=o(),u=(()=>{let e=s.get(`returnTo`);return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:null})(),d=s.get(`mprov`)?.trim()||null,[f,p]=(0,X.useState)(!1),[m,g]=(0,X.useState)(null),[y,b]=(0,X.useState)(!1),S=s.get(`q`)??``,C=s.get(`tab`),w=s.get(`source`),T=s.get(`status`),E=Pe.has(C)?C:`installed`,D=Fe.has(w)?w:`all`,O=Ie.has(T)?T:`all`,[k,A]=(0,X.useState)(S),[M]=ne(k,250),N=M.trim(),P=k.trim().length>0,F=N.length>0,[L,R]=(0,X.useState)(null),[z,B]=(0,X.useState)(E),[V,ee]=(0,X.useState)(D),[H,W]=(0,X.useState)(``),[G,q]=(0,X.useState)(O),Y=(0,X.useCallback)(e=>{B(e),e===`marketplace`&&(ee(`all`),q(`all`))},[]),[te,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(null),[de,fe]=(0,X.useState)(!1),[me,_e]=(0,X.useState)(!1),[be,Z]=(0,X.useState)(null),[Q,Te]=(0,X.useState)(null),[Ee,De]=(0,X.useState)({}),[ke,Ae]=(0,X.useState)(!1),[je,Me]=(0,X.useState)(`catalog`),[Ne,Re]=(0,X.useState)(``),[Be,Ve]=(0,X.useState)(null),[He,Ue]=(0,X.useState)(null),[We,Ge]=(0,X.useState)(!1),[Ke,qe]=(0,X.useState)(null),[Je,Ye]=(0,X.useState)(`downloads`),[Xe,Ze]=(0,X.useState)(1),[Qe,$e]=(0,X.useState)(0),[et,tt]=(0,X.useState)(null),[nt,rt]=(0,X.useState)(null),[it,at]=(0,X.useState)(``),[$,ot]=(0,X.useState)(()=>d),[st,ct]=(0,X.useState)(0),[lt,ut]=(0,X.useState)(0),[dt,ft]=(0,X.useState)([]),ht=(0,X.useRef)(null),gt=(0,X.useRef)(d),_t=(0,X.useRef)(null),vt=(0,X.useRef)(``),yt=(0,X.useRef)(null),bt=(0,X.useRef)(!1),[xt,St]=(0,X.useState)({query:``,byProvider:{}}),[Ct,wt]=(0,X.useState)(`all`),Tt=(0,X.useRef)(0),Et=(0,X.useRef)(N);Et.current!==N&&(Et.current=N,wt(e=>e===`all`?e:`all`));let Dt=U(()=>I().then(e=>(ft(e.diagnostics??[]),e.catalog.map(ce))),[n,lt],{enabled:n,initial:[],errorData:[]}),{data:Ot,loading:kt,setData:At}=Dt,jt=U(async()=>{try{let{providers:e,current:t}=await le();return{providers:e.map(e=>({id:e.id,displayName:e.displayName})),current:t}}catch{try{return{providers:[],current:(await he()).provider}}catch{return{providers:[],current:`store`}}}},[n,st],{enabled:n,initial:{providers:[],current:null}}),Mt=f||kt,Nt=jt.data.providers;(0,X.useEffect)(()=>{let e=e=>{if(x(e.detail)===`skills`){if(bt.current){bt.current=!1;return}ut(e=>e+1)}else ct(e=>e+1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[]);let Pt=s.toString(),Ft=(0,X.useRef)(Pt);if(Ft.current!==Pt){Ft.current=Pt;let e=s.get(`q`)??``,t=s.get(`tab`),n=s.get(`source`),r=s.get(`status`),i=Pe.has(t)?t:`installed`,a=Fe.has(n)?n:`all`,o=Ie.has(r)?r:`all`;A(t=>t===e?t:e),B(e=>e===i?e:i),ee(e=>e===a?e:a),q(e=>e===o?e:o);let c=s.get(`mcat`)??``;at(i===`marketplace`?e=>e===c?e:c:``)}let It=(0,X.useRef)(n);!n&&It.current&&(ot(null),ht.current=null),It.current=n,n&&d&&gt.current!==d&&(gt.current=d,ot(d)),n&&d==null&&jt.data.current&&jt.data.current!==_t.current&&(_t.current=jt.data.current,ot(e=>e??jt.data.current));let Lt=`${N}|${Je}|${z}|${it}|${$??``}|${Ct}`;vt.current!==Lt&&(vt.current=Lt,Ze(1)),z===`marketplace`&&$&&yt.current!=null&&yt.current!==$&&at(``),yt.current=$;let Rt=mt({enabled:n&&z===`marketplace`&&!!$&&!P,provider:$,category:it.trim(),sort:Je});(0,X.useEffect)(()=>{if(!n||!F||z!==`marketplace`||Nt.length===0)return;let e=++Tt.current,r={};for(let e of Nt)r[e.id]={status:`loading`,rows:[]};St({query:N,byProvider:r});let i=[],a=[];for(let n of Nt){let r=new AbortController;i.push(r);let o=window.setTimeout(()=>{r.abort(new DOMException(`Adapter timed out`,`TimeoutError`))},8e3);a.push(o),ye({provider:n.id,q:N,page:1,pageSize:40,sort:Je,signal:r.signal}).then(t=>{if(window.clearTimeout(o),e!==Tt.current)return;let r=t.items.map(e=>({...e,providerId:n.id}));St(e=>({...e,byProvider:{...e.byProvider,[n.id]:{status:`ok`,rows:r}}}))}).catch(r=>{if(window.clearTimeout(o),e!==Tt.current)return;let i=r instanceof DOMException&&(r.name===`TimeoutError`||r.name===`AbortError`)?t.marketplaceLoadFailed:r instanceof Error?r.message:t.marketplaceLoadFailed;St(e=>({...e,byProvider:{...e.byProvider,[n.id]:{status:`error`,rows:[],error:i}}}))})}return()=>{Tt.current+=1;for(let e of a)window.clearTimeout(e);for(let e of i)e.abort()}},[n,z,F,N,Nt,Je,Qe,t.marketplaceLoadFailed]);let zt=U(()=>ve({provider:$,locale:e}).then(e=>e.items),[n,z,$,e],{enabled:n&&z===`marketplace`&&!!$,initial:[],errorData:[]}),Bt=(0,X.useMemo)(()=>{if(!F||xt.query!==N)return[];let e=Nt.map(e=>({id:e.id,rows:[...xt.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())},[F,N,xt,Nt]),Vt=(0,X.useMemo)(()=>{if(!F)return{};let e={all:Bt.length};for(let t of Nt)e[t.id]=Bt.filter(e=>e.providerId===t.id||(e.additionalSources??[]).some(e=>e.providerId===t.id)).length;return e},[F,Bt,Nt]),Ht=(0,X.useMemo)(()=>F?Ct===`all`?Bt:Bt.filter(e=>e.providerId===Ct||(e.additionalSources??[]).some(e=>e.providerId===Ct)):[],[F,Bt,Ct]),Ut=(0,X.useMemo)(()=>{if(!F)return{};let e={};for(let t of Nt)e[t.id]=xt.byProvider[t.id]?.status??`loading`;return e},[F,xt,Nt]),Wt=(0,X.useMemo)(()=>Object.values(Ut).some(e=>e===`loading`),[Ut]),Gt=(0,X.useMemo)(()=>{if(!F)return!1;let e=Object.values(Ut);return e.length>0&&e.every(e=>e===`error`)},[F,Ut]),Kt=(0,X.useMemo)(()=>{if(!F||Bt.length===0&&Wt)return null;let e=Ht.length;return{items:Ht.slice(0,Xe*20),meta:{page:Xe,pageSize:20,total:e,totalPages:Math.max(1,Math.ceil(e/20))},provider:Ct}},[F,Bt,Wt,Ht,Xe,Ct]),qt=z===`marketplace`?P?F?Kt:null:Rt.payload:null,Jt=z===`marketplace`?P?F?Wt:!0:Rt.loading:!1,Yt=F?Gt?t.marketplaceLoadFailed:null:Rt.error instanceof Error?Rt.error.message:Rt.error?t.marketplaceLoadFailed:null,Xt=z===`marketplace`?zt.data:[],Zt=z===`marketplace`?zt.loading:!1,Qt=zt.error instanceof Error?zt.error.message:zt.error?t.marketplaceCategoriesFailed:null;it.trim()&&Xt.length>0&&!Xt.some(e=>e.id===it)&&at(``);let $t=(0,X.useCallback)(async e=>{let n=e?.silent===!0;n||p(!0),g(null);try{let e=await I();return ft(e.diagnostics??[]),At(e.catalog.map(ce)),{ok:!0}}catch(e){let n=e instanceof Error?e.message:t.loadFailed;return g(n),{ok:!1,message:n}}finally{n||p(!1)}},[At,t.loadFailed]),en=!f&&Dt.error?Dt.error instanceof Error?Dt.error.message:t.loadFailed:null,tn=m??en;(0,X.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e);return N?t.set(`q`,N):t.delete(`q`),z===`marketplace`?t.set(`tab`,z):t.delete(`tab`),z===`installed`&&V!==`all`?t.set(`source`,V):t.delete(`source`),z===`installed`&&G!==`all`?t.set(`status`,G):t.delete(`status`),z===`marketplace`&&it.trim()?t.set(`mcat`,it.trim()):t.delete(`mcat`),z===`marketplace`&&$?t.set(Le,$):t.delete(Le),t.toString()===e.toString()?e:t},{replace:!0})},[z,it,$,N,G,l,V]);let nn=(0,X.useCallback)((e,t,n=5e3)=>{R({kind:e,message:t}),window.setTimeout(()=>R(null),n)},[]),rn=(0,X.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]),an=(0,X.useCallback)(async e=>{Me(`catalog`),Ae(!0),Re(e.name),Ve(null),Ue(null),qe(null),Ge(!0);try{let t=await Se(e.name);Ve(t),Re(t.name)}catch(e){Ve(null),qe(e instanceof Error?e.message:t.detailLoadFailed)}finally{Ge(!1)}},[t.detailLoadFailed]),on=(0,X.useCallback)(async e=>{let n=e.trim();if(n){Me(`catalog`),Ae(!0),Re(n),Ve(null),Ue(null),qe(null),Ge(!0);try{let e=await Se(n);Ve(e),Re(e.name)}catch(e){Ve(null),qe(e instanceof Error?e.message:t.detailLoadFailed)}finally{Ge(!1)}}},[t.detailLoadFailed]),sn=(0,X.useCallback)(async(e,n,r)=>{let i=r?.trim()||$;if(i){ht.current=i,Me(`store`),Ae(!0),Re(n?.trim()||e),Ve(null),Ue(null),qe(null),Ge(!0);try{let t=await xe(e,{provider:i});Re(t.name),Ue(t.skillDocPreview)}catch(e){Ue(null),qe(e instanceof Error?e.message:t.detailLoadFailed)}finally{Ge(!1)}}},[$,t.detailLoadFailed]),cn=(0,X.useCallback)(async(e,n)=>{Te(e),De(t=>({...t,[e]:n})),R(null);try{return await ge(e,n),await $t({silent:!0}),!0}catch(n){return De(t=>{let{[e]:n,...r}=t;return r}),nn(`error`,n instanceof Error?n.message:t.skillToggleFailed),!1}finally{Te(null),De(t=>{let{[e]:n,...r}=t;return r})}},[$t,nn,t.skillToggleFailed]),ln=(0,X.useCallback)(async()=>{R(null),p(!0),g(null);try{await se()}catch(e){g(e instanceof Error?e.message:t.reloadFailed),p(!1);return}await $t()},[$t,t.reloadFailed]),un=(0,X.useMemo)(()=>{let e=k.trim().toLowerCase();return e?Ot.filter(t=>[t.name,t.description,t.plugin?.name,...Object.values(t.localizations??{}).flatMap(e=>e?[e.displayName,e.description]:[]),t.directoryId,t.path,t.source,t.hub?.source,t.hub?.ref].filter(Boolean).join(` `).toLowerCase().includes(e)):Ot},[Ot,k]),dn=(0,X.useCallback)(t=>J(t,e),[e]),fn=(0,X.useMemo)(()=>{let e=Ot.filter(e=>e.source===`builtin`);return{total:e.length,enabled:e.filter(e=>Ee[e.name]??e.enabled).length}},[Ot,Ee]),pn=(0,X.useMemo)(()=>{let e=Ot.filter(e=>e.source!==`builtin`);return{total:e.length,enabled:e.filter(e=>Ee[e.name]??e.enabled).length}},[Ot,Ee]),mn=(0,X.useMemo)(()=>Ne?Ot.find(e=>e.name===Ne):void 0,[Ot,Ne]),hn=mn?dn(mn):null,gn=mn==null?!0:Ee[Ne]??mn.enabled,_n=mn?.directoryId??null,vn=!mn?.origin.startsWith(`plugin:`)&&(mn?.managed??!1),yn=(0,X.useMemo)(()=>je!==`store`||!Ne?null:pe(ht.current??$,Ne),[je,Ne,$]),bn=(0,X.useMemo)(()=>{let e=un;return z===`installed`&&V!==`all`&&(e=V===`installed`?e.filter(e=>e.source!==`builtin`):V===`plugin`?e.filter(e=>e.origin.startsWith(`plugin:`)):e.filter(e=>e.source===V)),e},[un,z,V]),xn=(0,X.useMemo)(()=>{let e=new Set,t=[];for(let n of bn){let r=n.category;!r||e.has(r)||(e.add(r),t.push(r))}return t.sort((e,t)=>{let n=ze.indexOf(e),r=ze.indexOf(t);return n>=0&&r>=0?n-r:n>=0?-1:r>=0?1:e.localeCompare(t)})},[bn]),Sn=(0,X.useCallback)(e=>t.categoryLabel?.[e]||e,[t.categoryLabel]),Cn=(0,X.useMemo)(()=>H?bn.filter(e=>e.category===H):bn,[bn,H]);(0,X.useEffect)(()=>{W(``)},[V]);let wn=(0,X.useCallback)(e=>Ee[e.name]??e.enabled,[Ee]),Tn=(0,X.useMemo)(()=>Cn.filter(e=>!wn(e)).length,[Cn,wn]),En=(0,X.useMemo)(()=>{let t=Cn;return G===`disabled`&&(t=t.filter(e=>!wn(e))),G===`enabled`&&(t=t.filter(e=>wn(e))),[...t].toSorted((t,n)=>{let r=wn(t);return r===wn(n)?dn(t).displayName.localeCompare(dn(n).displayName,e,{sensitivity:`base`}):r?-1:1})},[Cn,G,e,wn,dn]),Dn=async e=>{R(null),b(!0),g(null);try{let n;try{n=await pt(e)}catch{g(t.invalidFile),nn(`error`,t.invalidFile);return}let r=await we(n,{overwrite:!0});bt.current=!0,await $t(),nn(`success`,rn(r)),ie(!1),oe(null),B(`installed`),ee(`installed`),await on(r.availability?.skillName||r.skillId)}catch(e){g(e instanceof Error?e.message:t.uploadFailed),nn(`error`,e instanceof Error?e.message:t.uploadFailed)}finally{b(!1)}},On=()=>{ae&&Dn(ae)},kn=e=>{let t=e.target.files?.[0];e.target.value=``,t&&oe(t)},An=e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.types.includes(`Files`)&&(fe(!0),e.dataTransfer.dropEffect=`copy`)},jn=e=>{let t=e.currentTarget,n=e.relatedTarget;n&&t.contains(n)||fe(!1)},Mn=e=>{e.preventDefault(),e.stopPropagation(),fe(!1);let t=e.dataTransfer?.files?.[0];t&&oe(t)},Nn=e=>{if(e.origin.startsWith(`plugin:`))return`${t.source.plugin} · ${e.plugin?.title??e.plugin?.name??e.origin.slice(7)}`;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}},Pn=async()=>{let e=be,n=ke&&je===`catalog`&&_n===e;if(_e(!1),Z(null),e){R(null);try{await Ce(e),bt.current=!0,await $t(),n&&(Ae(!1),Me(`catalog`),Re(``),Ve(null),Ue(null),qe(null))}catch(e){g(e instanceof Error?e.message:t.deleteFailed)}}},Fn=(0,X.useCallback)(e=>Ot.some(t=>t.name===e),[Ot]),In=(0,X.useRef)(!1),[Ln,Rn]=(0,X.useState)(!1),zn=(0,X.useCallback)(async()=>{if(!In.current){In.current=!0,Rn(!0),R(null);try{let{defaultId:e}=await re(),{skills:n}=await K(e,void 0,!0);if(!n.some(e=>e.name===`find-skills`&&e.availableForCurrentAgent))throw Error(t.findUnavailable);let i=new URLSearchParams({projectScope:`none`,scene:`find-skills`,skill:`find-skills`});k.trim()&&i.set(`draft`,t.findQuery.replace(`{{query}}`,k.trim())),r(`/chat/new?${i}`,{state:{forceNewChat:!0,agentId:e}})}catch(e){nn(`error`,e instanceof Error?e.message:t.findFailed)}finally{In.current=!1,Rn(!1)}}},[r,k,nn,t.findUnavailable,t.findFailed,t.findQuery]),Bn=(0,X.useCallback)(async e=>{let n=(e?.name??Ne).trim();if(!n)return;let a=e?.source??je;if(a===`catalog`){let e=Ot.find(e=>e.name===n);if(e?.plugin&&Oe(e)){Ae(!1),r(j(e.plugin.id,`skills`,e.plugin.authorizationStatus===`required`,i.pathname+i.search));return}if(e&&!(Ee[e.name]??e.enabled))return}R(null);let o=a===`store`&&!Fn(n);rt(n);try{if(o){let t=e?.providerOverride?.trim()||ht.current||$;await ue({name:n,overwrite:!1,...t?{provider:t}:{}}),bt.current=!0,await $t({silent:!0})}Ae(!1),r(`/chat/new?skill=${encodeURIComponent(n)}`)}catch(e){nn(`error`,e instanceof Error?e.message:t.uploadFailed)}finally{rt(null)}},[Ot,Ne,i.pathname,i.search,je,Ee,Fn,$t,r,nn,t.uploadFailed,$]),Vn=(0,X.useCallback)(async(e,n)=>{let r=Fn(e);if(!(r&&!window.confirm(t.marketplaceReinstallConfirm))){R(null),tt(e);try{let t=n?.providerOverride?.trim()||(n?.useDetailProvider?ht.current??$:$),i=await ue({name:e,overwrite:r,...t?{provider:t}:{}});bt.current=!0,await $t({silent:!0}),nn(`success`,rn(i)),B(`installed`),ee(`installed`),await on(i.availability?.skillName||i.skillId||e)}catch(e){nn(`error`,e instanceof Error?e.message:t.uploadFailed)}finally{tt(null)}}},[Fn,rn,$t,$,on,nn,t.marketplaceReinstallConfirm,t.uploadFailed]),{pathname:Hn}=a(),Un=Hn.startsWith(`/settings/`);return{sk:t,hasToken:n,catalog:Ot,loading:Mt,error:tn,uploading:y,searchQuery:k,setSearchQuery:A,actionFeedback:L,skillDiagnostics:dt,mainTab:z,setMainTab:Y,sourceFilter:V,setSourceFilter:ee,builtinCategoryFilter:H,setBuiltinCategoryFilter:W,installOpen:te,setInstallOpen:ie,pendingFile:ae,setPendingFile:oe,dropActive:de,setDropActive:fe,confirmOpen:me,setConfirmOpen:_e,confirmId:be,setConfirmId:Z,togglingSkillName:Q,enabledOverride:Ee,detailOpen:ke,setDetailOpen:Ae,detailSource:je,setDetailSource:Me,detailTitle:Ne,setDetailTitle:Re,detailCatalogPreview:Be,setDetailCatalogPreview:Ve,detailMarketplacePreview:He,setDetailMarketplacePreview:Ue,detailLoading:We,detailError:Ke,setDetailError:qe,marketSort:Je,setMarketSort:Ye,mpHasMore:P?!!(Kt&&Kt.items.length<Kt.meta.total):Rt.hasMore,onLoadMoreMarket:()=>{P?Jt||Ze(e=>e+1):Rt.loadMore()},onRetryMarket:()=>{P?$e(e=>e+1):Rt.retry()},mpLoading:Jt,mpError:Yt,mpPayload:qt,searchActive:F,searchInputActive:P,resultTab:Ct,setResultTab:wt,aggregatedTabCounts:Vt,aggregatedProviderStatus:Ut,aggregatedAllFailed:Gt,installingMarketName:et,usingSkillInChatName:nt,onUseSkillInChat:Bn,onFindSkills:zn,findingSkills:Ln,marketCategoryId:it,setMarketCategoryId:at,mpCategories:Xt,mpCategoriesError:Qt,mpCategoriesLoading:Zt,marketBrowseProvider:$,setMarketBrowseProvider:ot,registeredProviders:Nt,builtinTabStats:fn,userTabStats:pn,detailEnabled:gn,detailPresentation:hn,detailDirectoryId:_n,detailManaged:vn,detailFromCatalog:mn,detailExternalUrl:yn,filteredCatalog:bn,builtinCategories:xn,categoryFilteredCatalog:Cn,catalogDisplayRows:En,skillPresentation:dn,marketplacePresentation:t=>J(t,e),catalogDisabledCount:Tn,catalogStatusFilter:G,setCatalogStatusFilter:q,resolveSkillEnabled:wn,inSettingsShell:Un,recoveryReturnPath:u,onRecoveryDone:()=>u&&r(u),categoryLabel:Sn,onReloadClick:ln,openSkillDetail:an,openMarketplaceDetail:sn,onSkillToggle:cn,onInstallSubmit:On,onFileInputChange:kn,onModalDragOver:An,onModalDragLeave:jn,onModalDrop:Mn,sourceLabel:Nn,runDelete:Pn,onMarketInstall:Vn,isSkillInstalledByName:Fn}}function xt(e){let t=(0,Z.c)(4),{embedded:n,onHeaderActionChange:r}=e,i=n===void 0?!1:n,a=bt(),o;return t[0]!==i||t[1]!==r||t[2]!==a?(o=(0,Q.jsx)(ot,{vm:a,embedded:i,onHeaderActionChange:r}),t[0]=i,t[1]=r,t[2]=a,t[3]=o):o=t[3],o}export{xt as SkillsPage};
@@ -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"./messages-RzwPiQNL.js";import{t as a}from"./cn-0WouolD0.js";import{n as o}from"./locale-store-JogcXC4J.js";import{n as s}from"./electron-env-Dit0bHgy.js";import{Fl as c,Jt as l,Kt as u,Yt as d,ks as f,ma as p,qd as m,qt as h,xl as g}from"./index-D1oivYvN.js";import{n as _,t as v}from"./settings-page-header-CYpuTXUW.js";import"./settings-page-layout-B20AfmFG.js";import{r as y,t as b}from"./settings-form-section-BNYQjZU4.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!s()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`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=i(o(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(l),[r,a]=(0,x.useState)(null),[s,c]=(0,x.useState)(!1),f=async t=>{if(!t){n(d({enabled:!1})),a(null);return}c(!0);try{let t=await u();if(t!==`granted`){a(t===`unsupported`?e.unsupported:e.denied);return}n(d({enabled:!0})),a(await h(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},p=e=>{n(d(e))};return(0,C.jsxs)(_,{gap:`gap-6`,children:[(0,C.jsx)(v,{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)(m,{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],[`needsInput`,e.needsInput,e.needsInputDesc]].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:s||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?f(t.target.checked):p({[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.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`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=i(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=i(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=o(e=>e.language),t=i(e),n=t.systemSettings,[l,u]=(0,x.useReducer)(p,L),{behavior:d,perms:m,loadError:h,permFeedback:A,permBusy:N,refreshing:R}=l,z=typeof window<`u`?window.electronAPI?.system:void 0,B=(0,x.useCallback)(async e=>{if(z){u({type:`patch`,patch:{loadError:null}});try{u({type:`patch`,patch:{behavior:await z.getBehavior(),perms:await z.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:n.refreshDone}:{}}})}catch(t){u({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[z,n.refreshDone]),V=(0,x.useCallback)(async()=>{if(!(R||N)){u({type:`patch`,patch:{refreshing:!0}});try{await B({showRefreshFeedback:!0})}finally{u({type:`patch`,patch:{refreshing:!1}})}}},[B,N,R]);if((0,x.useEffect)(()=>{let e=new Set([n.refreshDone,n.openSettingsDone,n.openSettingsFailed,n.desktopNotify.testShown]);if(!A||!e.has(A))return;let t=window.setTimeout(()=>{u({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(t)},[A,n.openSettingsDone,n.openSettingsFailed,n.refreshDone,n.desktopNotify.testShown]),(0,x.useEffect)(()=>{s()&&z&&B()},[z,B]),!s()||!z)return(0,C.jsx)(w,{});let H=async e=>{try{let{behavior:t}=await z.setBehavior(e);u({type:`patch`,patch:{behavior:t}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},U=async e=>{if(!e){await H({notifyEnabled:!1});return}u({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(n.desktopNotify.testTitle,n.desktopNotify.testBody);if(e===`unsupported`){u({type:`patch`,patch:{permFeedback:n.notificationsFeedback.unsupported}});return}if(e===`denied`){u({type:`patch`,patch:{permFeedback:n.desktopNotify.denied}});return}if(e==="default"){u({type:`patch`,patch:{permFeedback:n.notificationsFeedback.default}});return}await H({notifyEnabled:!0}),u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:n.desktopNotify.testShown}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},W=async e=>{u({type:`patch`,patch:{permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{(await z.openPrivacy(e)).ok?u({type:`patch`,patch:{permFeedback:n.openSettingsDone}}):u({type:`patch`,patch:{permFeedback:n.openSettingsFailed}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},G=async()=>{u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestMicrophone(),t=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:E(e,t,n.permFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},K=async()=>{if(z.requestAccessibility){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestAccessibility();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:D(e,n.accessibilityFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(z.requestNotifications){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestNotifications();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:O(e,n.notificationsFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},J=async()=>{if(z.requestScreen){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestScreen();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:k(e,n.screenFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},Y=d?d.platform===`win32`?n.permissionsHintWin:d.platform===`linux`?n.permissionsHintLinux:d.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(_,{gap:`gap-6`,children:[(0,C.jsx)(v,{title:n.title}),h?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:h}):null,A?(0,C.jsx)(`p`,{className:a(`text-sm`,A===n.refreshDone||A===n.openSettingsDone||A===n.permFeedback.granted||A===n.permFeedback.alreadyGranted||A===n.accessibilityFeedback.granted||A===n.accessibilityFeedback.alreadyGranted||A===n.notificationsFeedback.granted||A===n.notificationsFeedback.alreadyGranted||A===n.screenFeedback.granted||A===n.screenFeedback.alreadyGranted||A===n.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:A}):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}),n.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.endpointToolsSettings.deviceAccess.background}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.endpointToolsSettings.deviceAccess.sleep})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d?.backgroundSupported,checked:!!d?.runInBackground,onChange:e=>void H({runInBackground: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:n.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.openAtLogin,onChange:e=>{H({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:n.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.keepAwakePreferred,onChange:e=>{H({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:n.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d||N,checked:!!d?.notifyEnabled,onChange:e=>{U(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:n.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.notifySoundEnabled,onChange:e=>{H({notifySoundEnabled:e.target.checked})}})]})]})]}),d&&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:n.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:Y}),d.platform===`darwin`&&!d.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:n.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:R||N,"aria-busy":R,className:a(`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`,f.press),onClick:()=>void V(),children:[(0,C.jsx)(c,{className:a(`size-3.5`,R&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),R?n.refreshing:n.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(d.platform).map(({key:t,pane:i})=>{let o=F(e,m[t]),s=n.perm[t],c=m[t]===`unknown`?I(e,t,d.platform):null;return s?(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:s.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:s.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${o.className}`,children:o.label}),c?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:c}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[t===`notifications`&&j(t,m[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`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`,f.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,m[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`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`,f.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,m[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`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`,f.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,m[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`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`,f.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,m[t],d.platform)?(0,C.jsxs)(`button`,{type:`button`,className:a(`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`,f.press),onClick:()=>void W(i),children:[n.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},t):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"./messages-RzwPiQNL.js";import{t as a}from"./cn-0WouolD0.js";import{n as o}from"./locale-store-JogcXC4J.js";import{n as s}from"./electron-env-Dit0bHgy.js";import{Fl as c,Jt as l,Kt as u,Ud as d,Yt as f,ks as p,ma as m,qt as h,xl as g}from"./index-ygkHNYyo.js";import{n as _,t as v}from"./settings-page-header-CYpuTXUW.js";import"./settings-page-layout-B20AfmFG.js";import{r as y,t as b}from"./settings-form-section-Ce8vVv-9.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!s()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`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=i(o(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(l),[r,a]=(0,x.useState)(null),[s,c]=(0,x.useState)(!1),p=async t=>{if(!t){n(f({enabled:!1})),a(null);return}c(!0);try{let t=await u();if(t!==`granted`){a(t===`unsupported`?e.unsupported:e.denied);return}n(f({enabled:!0})),a(await h(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},m=e=>{n(f(e))};return(0,C.jsxs)(_,{gap:`gap-6`,children:[(0,C.jsx)(v,{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)(d,{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],[`needsInput`,e.needsInput,e.needsInputDesc]].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:s||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?p(t.target.checked):m({[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.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`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=i(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=i(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=o(e=>e.language),t=i(e),n=t.systemSettings,[l,u]=(0,x.useReducer)(m,L),{behavior:d,perms:f,loadError:h,permFeedback:A,permBusy:N,refreshing:R}=l,z=typeof window<`u`?window.electronAPI?.system:void 0,B=(0,x.useCallback)(async e=>{if(z){u({type:`patch`,patch:{loadError:null}});try{u({type:`patch`,patch:{behavior:await z.getBehavior(),perms:await z.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:n.refreshDone}:{}}})}catch(t){u({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[z,n.refreshDone]),V=(0,x.useCallback)(async()=>{if(!(R||N)){u({type:`patch`,patch:{refreshing:!0}});try{await B({showRefreshFeedback:!0})}finally{u({type:`patch`,patch:{refreshing:!1}})}}},[B,N,R]);if((0,x.useEffect)(()=>{let e=new Set([n.refreshDone,n.openSettingsDone,n.openSettingsFailed,n.desktopNotify.testShown]);if(!A||!e.has(A))return;let t=window.setTimeout(()=>{u({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(t)},[A,n.openSettingsDone,n.openSettingsFailed,n.refreshDone,n.desktopNotify.testShown]),(0,x.useEffect)(()=>{s()&&z&&B()},[z,B]),!s()||!z)return(0,C.jsx)(w,{});let H=async e=>{try{let{behavior:t}=await z.setBehavior(e);u({type:`patch`,patch:{behavior:t}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},U=async e=>{if(!e){await H({notifyEnabled:!1});return}u({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(n.desktopNotify.testTitle,n.desktopNotify.testBody);if(e===`unsupported`){u({type:`patch`,patch:{permFeedback:n.notificationsFeedback.unsupported}});return}if(e===`denied`){u({type:`patch`,patch:{permFeedback:n.desktopNotify.denied}});return}if(e==="default"){u({type:`patch`,patch:{permFeedback:n.notificationsFeedback.default}});return}await H({notifyEnabled:!0}),u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:n.desktopNotify.testShown}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},W=async e=>{u({type:`patch`,patch:{permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{(await z.openPrivacy(e)).ok?u({type:`patch`,patch:{permFeedback:n.openSettingsDone}}):u({type:`patch`,patch:{permFeedback:n.openSettingsFailed}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},G=async()=>{u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestMicrophone(),t=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:E(e,t,n.permFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},K=async()=>{if(z.requestAccessibility){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestAccessibility();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:D(e,n.accessibilityFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(z.requestNotifications){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestNotifications();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:O(e,n.notificationsFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},J=async()=>{if(z.requestScreen){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestScreen();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:k(e,n.screenFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},Y=d?d.platform===`win32`?n.permissionsHintWin:d.platform===`linux`?n.permissionsHintLinux:d.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(_,{gap:`gap-6`,children:[(0,C.jsx)(v,{title:n.title}),h?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:h}):null,A?(0,C.jsx)(`p`,{className:a(`text-sm`,A===n.refreshDone||A===n.openSettingsDone||A===n.permFeedback.granted||A===n.permFeedback.alreadyGranted||A===n.accessibilityFeedback.granted||A===n.accessibilityFeedback.alreadyGranted||A===n.notificationsFeedback.granted||A===n.notificationsFeedback.alreadyGranted||A===n.screenFeedback.granted||A===n.screenFeedback.alreadyGranted||A===n.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:A}):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}),n.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.endpointToolsSettings.deviceAccess.background}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.endpointToolsSettings.deviceAccess.sleep})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d?.backgroundSupported,checked:!!d?.runInBackground,onChange:e=>void H({runInBackground: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:n.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.openAtLogin,onChange:e=>{H({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:n.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.keepAwakePreferred,onChange:e=>{H({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:n.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d||N,checked:!!d?.notifyEnabled,onChange:e=>{U(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:n.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.notifySoundEnabled,onChange:e=>{H({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:n.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:Y}),d.platform===`darwin`&&!d.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:n.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:R||N,"aria-busy":R,className:a(`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`,p.press),onClick:()=>void V(),children:[(0,C.jsx)(c,{className:a(`size-3.5`,R&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),R?n.refreshing:n.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(d.platform).map(({key:t,pane:i})=>{let o=F(e,f[t]),s=n.perm[t],c=f[t]===`unknown`?I(e,t,d.platform):null;return s?(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:s.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:s.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${o.className}`,children:o.label}),c?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:c}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[t===`notifications`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`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`,p.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`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`,p.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`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`,p.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`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`,p.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,f[t],d.platform)?(0,C.jsxs)(`button`,{type:`button`,className:a(`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`,p.press),onClick:()=>void W(i),children:[n.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},t):null})})]}):null]})}export{R as SystemSettingsPanel};