@xopcai/xopc 0.0.141 → 0.0.142

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 (171) 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-BRTCpm3t.js → agent-avatar-dicebear-BawPxiu5.js} +1 -1
  4. package/dist/gateway/static/root/assets/agents-CyvCIHnB.js +2 -0
  5. package/dist/gateway/static/root/assets/{app-management-settings-panel-DaMMZBAT.js → app-management-settings-panel-81xd1p9R.js} +1 -1
  6. package/dist/gateway/static/root/assets/{appearance-settings-BXHThPyM.js → appearance-settings-DYeQsYU8.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-B4omjLxa.js → apps-page-DK_Vx6nl.js} +1 -1
  8. package/dist/gateway/static/root/assets/{archive-plugin-izB-4N4L.js → archive-plugin-D_oa7oti.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-CJihXa5y.js → attachment-load-Cd-bwI2N.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automation-suggestion-card-fgtj5Gek.js → automation-suggestion-card-B1LV3YYv.js} +1 -1
  11. package/dist/gateway/static/root/assets/automations-page-fzrovqhv.js +4 -0
  12. package/dist/gateway/static/root/assets/{binary-plugins-D3VUeG8s.js → binary-plugins-O8svLKWw.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-KnA0sLI3.js → block-editor-Dhj5f4Bx.js} +47 -47
  14. package/dist/gateway/static/root/assets/browser-settings-page-BDn-n-UB.js +8 -0
  15. package/dist/gateway/static/root/assets/{capability-presets-api-D8rRNhc6.js → capability-presets-api-dJy1Eqgx.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-sCHojZr4.js → capability-presets-settings-panel-Co5ipo_Q.js} +1 -1
  17. package/dist/gateway/static/root/assets/{channel-recipient-api-BWgqwC5h.js → channel-recipient-api-Bfuhp2ty.js} +1 -1
  18. package/dist/gateway/static/root/assets/channels-settings-BWlpaxg9.js +1 -0
  19. package/dist/gateway/static/root/assets/channels-status-swr-D_jkIZLV.js +1 -0
  20. package/dist/gateway/static/root/assets/connectors-page-BcekbW4q.js +2 -0
  21. package/dist/gateway/static/root/assets/{desktop-pet-CzdqX001.js → desktop-pet-DFMfIb5F.js} +1 -1
  22. package/dist/gateway/static/root/assets/{desktop-pet-settings-DqqUPC7G.js → desktop-pet-settings-BJCUuL8Y.js} +1 -1
  23. package/dist/gateway/static/root/assets/{directory-picker-path-field-PzlO5tSM.js → directory-picker-path-field-BrYt1gAr.js} +1 -1
  24. package/dist/gateway/static/root/assets/{dreaming-settings-BmL54kQq.js → dreaming-settings-BN1Z2mIo.js} +3 -3
  25. package/dist/gateway/static/root/assets/{extension-debug-page-DcW8Ie3r.js → extension-debug-page-Bh630pLD.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-page-DT5cpace.js → extension-page-B-1KxvVy.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-CbMk4GhQ.js → extension-settings-page-BF9NACI3.js} +1 -1
  28. package/dist/gateway/static/root/assets/{fetch-06q5eCMA.js → fetch-B1WtuprY.js} +1 -1
  29. package/dist/gateway/static/root/assets/{gateway-config-api-4VXUJtLz.js → gateway-config-api-De2N821l.js} +1 -1
  30. package/dist/gateway/static/root/assets/{gateway-settings-CdghmKHJ.js → gateway-settings-DN9sNREz.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-startup-retry-2f7_vsv7.js → gateway-startup-retry-nEujFSDj.js} +1 -1
  32. package/dist/gateway/static/root/assets/goal-create-dialog-BpoQW8cD.js +1 -0
  33. package/dist/gateway/static/root/assets/goal-detail-page-CBRSPd0b.js +4 -0
  34. package/dist/gateway/static/root/assets/{goals-config-api-BpuQTufF.js → goals-config-api-DUy3eEse.js} +1 -1
  35. package/dist/gateway/static/root/assets/goals-page-BCcBi407.js +2 -0
  36. package/dist/gateway/static/root/assets/{goals-settings-CW1NwxvV.js → goals-settings-pkTXzXkh.js} +1 -1
  37. package/dist/gateway/static/root/assets/{heartbeat-settings-C86k5tff.js → heartbeat-settings-ezsufgLQ.js} +1 -1
  38. package/dist/gateway/static/root/assets/{index-ehajXmqL.js → index-DcUaXYeb.js} +65 -65
  39. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CVIwwM15.js +1 -0
  40. package/dist/gateway/static/root/assets/logs-page-DQtTRXtj.js +7 -0
  41. package/dist/gateway/static/root/assets/{markdown-split-zS4KLNAf.js → markdown-split-B_6us9j7.js} +1 -1
  42. package/dist/gateway/static/root/assets/{media-plugins-_BgNJ9_7.js → media-plugins-D_fryIyj.js} +1 -1
  43. package/dist/gateway/static/root/assets/messages-BXNELNBa.js +3 -0
  44. package/dist/gateway/static/root/assets/models-hub-panel-BP2M9n6Q.js +2 -0
  45. package/dist/gateway/static/root/assets/notes-page-CspveYaO.js +1 -0
  46. package/dist/gateway/static/root/assets/notes-workbench-BHwzJ0OC.js +2 -0
  47. package/dist/gateway/static/root/assets/{page-tabs-B7sGQkgU.js → page-tabs-D_8jGlqx.js} +1 -1
  48. package/dist/gateway/static/root/assets/{preview-open-alternatives-D1ri4s_O.js → preview-open-alternatives-BBLMK8Mp.js} +1 -1
  49. package/dist/gateway/static/root/assets/project-detail-page-Dy3rsobs.js +1 -0
  50. package/dist/gateway/static/root/assets/projects-page-CWKpPE0L.js +1 -0
  51. package/dist/gateway/static/root/assets/remote-access-hub-CqNRyXEo.js +1 -0
  52. package/dist/gateway/static/root/assets/{save-bar-controls-BClrOinh.js → save-bar-controls-DVS3FR5r.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schedule-field-CL7YTwLV.js → schedule-field-D6vKd6-T.js} +1 -1
  54. package/dist/gateway/static/root/assets/{schema-form-ww4PiIje.js → schema-form-BPy4lbIh.js} +1 -1
  55. package/dist/gateway/static/root/assets/sessions-page-MEME7ivF.js +1 -0
  56. package/dist/gateway/static/root/assets/settings-advanced-gate-JVd0qaSF.js +1 -0
  57. package/dist/gateway/static/root/assets/{settings-collapsible-section-D9gEEVm2.js → settings-collapsible-section-WzdikxPt.js} +1 -1
  58. package/dist/gateway/static/root/assets/{settings-form-section-DGeEoBkb.js → settings-form-section-CvfzhBV-.js} +1 -1
  59. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BXUeMR37.js → settings-loading-skeleton-BxR-Ulhi.js} +1 -1
  60. package/dist/gateway/static/root/assets/{settings-page-C5G2klUB.js → settings-page-DYEbB1EV.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-page-layout-CEepfbCa.js → settings-page-layout-CKefvbYi.js} +1 -1
  62. package/dist/gateway/static/root/assets/{setup-status-panel-oQ8OLnw3.js → setup-status-panel-dWN8BJ3z.js} +1 -1
  63. package/dist/gateway/static/root/assets/{share-preview-page-CXtDHMSi.js → share-preview-page-D8foINzP.js} +1 -1
  64. package/dist/gateway/static/root/assets/shares-settings-Tgbv1s7G.js +1 -0
  65. package/dist/gateway/static/root/assets/skill-reload-api-D_YK0b_Z.js +1 -0
  66. package/dist/gateway/static/root/assets/skills-page-DGytfoZK.js +2 -0
  67. package/dist/gateway/static/root/assets/{system-settings-panel-W6MBJXrr.js → system-settings-panel-BokgAgf7.js} +1 -1
  68. package/dist/gateway/static/root/assets/{typed-models-lib-BkODXN7T.js → typed-models-lib-BwHlNL3L.js} +1 -1
  69. package/dist/gateway/static/root/assets/{use-channel-catalog-CTbwLZXc.js → use-channel-catalog-DR11ap3A.js} +1 -1
  70. package/dist/gateway/static/root/assets/{user-profile-settings-panel-CeC308-E.js → user-profile-settings-panel-8YtygcJp.js} +1 -1
  71. package/dist/gateway/static/root/assets/{utils-ZxrKHxyb.js → utils-BKUWB-TT.js} +1 -1
  72. package/dist/gateway/static/root/assets/voice-api-key-field-BVH71EFf.js +1 -0
  73. package/dist/gateway/static/root/assets/work-item-detail-page-JeTE7XNM.js +1 -0
  74. package/dist/gateway/static/root/assets/workflow-run-setup-panel-CL_rnAUB.js +3 -0
  75. package/dist/gateway/static/root/assets/{workflow-start-dialog-CtLTtNUB.js → workflow-start-dialog-_u8Uc1ze.js} +1 -1
  76. package/dist/gateway/static/root/assets/workflows-page-ixgk_y1l.js +18 -0
  77. package/dist/gateway/static/root/index.html +4 -4
  78. package/dist/package.js +1 -1
  79. package/dist/src/agent/embedded/session-runner.js +5 -5
  80. package/dist/src/agent/embedded/session-runner.js.map +1 -1
  81. package/dist/src/agent/embedded/xopc-auth-storage.d.ts +4 -3
  82. package/dist/src/agent/embedded/xopc-auth-storage.js +6 -6
  83. package/dist/src/agent/embedded/xopc-auth-storage.js.map +1 -1
  84. package/dist/src/agent/embedded/xopc-stream-bridge.js +1 -0
  85. package/dist/src/agent/embedded/xopc-stream-bridge.js.map +1 -1
  86. package/dist/src/agent/goals/checklist-judge.js +3 -3
  87. package/dist/src/agent/goals/checklist-judge.js.map +1 -1
  88. package/dist/src/agent/goals/judge.js +2 -2
  89. package/dist/src/agent/goals/judge.js.map +1 -1
  90. package/dist/src/agent/image/understanding/pi-ai-provider.js +2 -2
  91. package/dist/src/agent/image/understanding/pi-ai-provider.js.map +1 -1
  92. package/dist/src/agent/memory/compaction.js +2 -2
  93. package/dist/src/agent/memory/compaction.js.map +1 -1
  94. package/dist/src/agent/service/btw-query.d.ts +4 -0
  95. package/dist/src/agent/service/btw-query.js +94 -13
  96. package/dist/src/agent/service/btw-query.js.map +1 -1
  97. package/dist/src/agent/session/session-inspector.js +9 -1
  98. package/dist/src/agent/session/session-inspector.js.map +1 -1
  99. package/dist/src/agent/tools/session-search-tool.js +2 -2
  100. package/dist/src/agent/tools/session-search-tool.js.map +1 -1
  101. package/dist/src/agent/tools/web-extract.js +2 -2
  102. package/dist/src/agent/tools/web-extract.js.map +1 -1
  103. package/dist/src/ai-assist/text-assist.d.ts +2 -1
  104. package/dist/src/ai-assist/text-assist.js +10 -23
  105. package/dist/src/ai-assist/text-assist.js.map +1 -1
  106. package/dist/src/auth/credentials.js +5 -2
  107. package/dist/src/auth/credentials.js.map +1 -1
  108. package/dist/src/auth/oauth/github-copilot.d.ts +3 -4
  109. package/dist/src/auth/oauth/github-copilot.js +66 -2
  110. package/dist/src/auth/oauth/github-copilot.js.map +1 -0
  111. package/dist/src/auth/oauth/index.js +2 -2
  112. package/dist/src/automations/draft/automation-draft-service.js +3 -3
  113. package/dist/src/automations/draft/automation-draft-service.js.map +1 -1
  114. package/dist/src/chat-commands/builtins/review.js +22 -5
  115. package/dist/src/chat-commands/builtins/review.js.map +1 -1
  116. package/dist/src/chat-commands/types.d.ts +4 -0
  117. package/dist/src/gateway/hono/routes/models.js +1 -0
  118. package/dist/src/gateway/hono/routes/models.js.map +1 -1
  119. package/dist/src/gateway/hono/routes/voice.js +2 -2
  120. package/dist/src/gateway/hono/routes/voice.js.map +1 -1
  121. package/dist/src/goals/goal-contract-draft.js +2 -2
  122. package/dist/src/goals/goal-contract-draft.js.map +1 -1
  123. package/dist/src/goals/goal-evidence-review.js +2 -2
  124. package/dist/src/goals/goal-evidence-review.js.map +1 -1
  125. package/dist/src/notes/service.js +2 -2
  126. package/dist/src/notes/service.js.map +1 -1
  127. package/dist/src/providers/constants.d.ts +2 -0
  128. package/dist/src/providers/constants.js +11 -0
  129. package/dist/src/providers/constants.js.map +1 -0
  130. package/dist/src/providers/extension-stream-bridge.js +1 -0
  131. package/dist/src/providers/extension-stream-bridge.js.map +1 -1
  132. package/dist/src/providers/index.d.ts +3 -3
  133. package/dist/src/providers/index.js +5 -4
  134. package/dist/src/providers/index.js.map +1 -1
  135. package/dist/src/providers/model-call.d.ts +17 -0
  136. package/dist/src/providers/model-call.js +60 -0
  137. package/dist/src/providers/model-call.js.map +1 -0
  138. package/dist/src/session/session-title.js +2 -2
  139. package/dist/src/session/session-title.js.map +1 -1
  140. package/dist/src/voice/tts/summarize.js +2 -2
  141. package/dist/src/voice/tts/summarize.js.map +1 -1
  142. package/dist/src/workflows/draft/workflow-draft-service.js +2 -2
  143. package/dist/src/workflows/draft/workflow-draft-service.js.map +1 -1
  144. package/package.json +5 -5
  145. package/dist/gateway/static/root/assets/agents-Bd863Akz.js +0 -2
  146. package/dist/gateway/static/root/assets/automations-page-Dz2mgjIR.js +0 -4
  147. package/dist/gateway/static/root/assets/browser-settings-page-DZZz5v_i.js +0 -8
  148. package/dist/gateway/static/root/assets/channels-settings-UyVSnf9s.js +0 -1
  149. package/dist/gateway/static/root/assets/channels-status-swr-CB5FzcLf.js +0 -1
  150. package/dist/gateway/static/root/assets/connectors-page-BzhHiUO4.js +0 -2
  151. package/dist/gateway/static/root/assets/goal-create-dialog-CAlsM9MP.js +0 -1
  152. package/dist/gateway/static/root/assets/goal-detail-page-CLPa4F2y.js +0 -4
  153. package/dist/gateway/static/root/assets/goals-page-B2VpdzfH.js +0 -2
  154. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-8xwKEhui.js +0 -1
  155. package/dist/gateway/static/root/assets/logs-page-C_BMONOO.js +0 -7
  156. package/dist/gateway/static/root/assets/messages-B-8CqAeX.js +0 -3
  157. package/dist/gateway/static/root/assets/models-hub-panel-Do_cwNjF.js +0 -2
  158. package/dist/gateway/static/root/assets/notes-page-5IdlPHaX.js +0 -1
  159. package/dist/gateway/static/root/assets/notes-workbench-0KsRZJIZ.js +0 -2
  160. package/dist/gateway/static/root/assets/project-detail-page-Dk2zB1gy.js +0 -1
  161. package/dist/gateway/static/root/assets/projects-page-CJQntm2G.js +0 -1
  162. package/dist/gateway/static/root/assets/remote-access-hub-CHeZZg7O.js +0 -1
  163. package/dist/gateway/static/root/assets/sessions-page-9Hb_r0AG.js +0 -1
  164. package/dist/gateway/static/root/assets/settings-advanced-gate-PmzVFvAv.js +0 -1
  165. package/dist/gateway/static/root/assets/shares-settings-BlNoairj.js +0 -1
  166. package/dist/gateway/static/root/assets/skill-reload-api-BYV5x1KO.js +0 -1
  167. package/dist/gateway/static/root/assets/skills-page-ClBcKQZP.js +0 -2
  168. package/dist/gateway/static/root/assets/voice-api-key-field-BE57S-nS.js +0 -1
  169. package/dist/gateway/static/root/assets/work-item-detail-page-Di1ww5Aa.js +0 -1
  170. package/dist/gateway/static/root/assets/workflow-run-setup-panel-CzK84i-B.js +0 -3
  171. package/dist/gateway/static/root/assets/workflows-page-CZFZdua9.js +0 -18
@@ -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{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-BXNELNBa.js";import{a as s,o as c,t as l}from"./fetch-B1WtuprY.js";import{n as u}from"./locale-store-Ba72bFmP.js";import{t as d}from"./config-reload-event-Bjh2zoKp.js";import{$o as f,Al as p,Br as m,Cc as h,Co as g,Es as _,Ha as v,Hr as y,Ja as b,Ka as x,Lr as S,Ml as C,Mo as w,Nc as T,Rr as E,Si as D,Ua as O,Uo as k,Wa as A,Wo as j,Xa as M,Ya as ee,Ys as N,al as P,ci as F,gr as I,hr as L,jc as te,kl as R,ko as z,ol as B,ps as ne,qa as re,sl as ie,uc as ae,ui as V,zr as oe}from"./index-DcUaXYeb.js";import{t as H}from"./page-tabs-D_8jGlqx.js";import{t as se}from"./skill-reload-api-D_YK0b_Z.js";var U=n(),W=e(t(),1),G=r(),K=(0,W.memo)(function(e){let t=(0,U.c)(23),{loading:n,onReloadClick:r,searchQuery:i,setSearchQuery:a,mainTab:o,sk:s,setPendingFile:c,setInstallOpen:l}=e,u;t[0]!==n||t[1]!==r||t[2]!==s.reloadDiskAria||t[3]!==s.reloadRuntime?(u=(0,G.jsx)(D,{className:`size-9 shrink-0 p-0`,loading:n,label:s.reloadDiskAria,title:s.reloadRuntime,onClick:r}),t[0]=n,t[1]=r,t[2]=s.reloadDiskAria,t[3]=s.reloadRuntime,t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,G.jsx)(ne,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[5]=d):d=t[5];let f;t[6]===a?f=t[7]:(f=e=>a(e.target.value),t[6]=a,t[7]=f);let p=o===`marketplace`?s.marketplaceSearchPackages:s.searchPlaceholder,m;t[8]!==i||t[9]!==f||t[10]!==p?(m=(0,G.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,G.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:i,onChange:f,placeholder:p,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[8]=i,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]!==l||t[13]!==c?(h=()=>{c(null),l(!0)},t[12]=l,t[13]=c,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,G.jsx)(_,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[15]=g):g=t[15];let v;t[16]!==s.installCta||t[17]!==h?(v=(0,G.jsxs)(z,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:h,children:[g,s.installCta]}),t[16]=s.installCta,t[17]=h,t[18]=v):v=t[18];let y;return t[19]!==u||t[20]!==m||t[21]!==v?(y=(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,m,v]}),t[19]=u,t[20]=m,t[21]=v,t[22]=y):y=t[22],y}),q=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ce(){let e=(0,U.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsx)(`div`,{className:a(`h-4 min-w-0 flex-1`,q)}),e[0]=t):t=e[0];let n,r,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[t,(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,G.jsx)(`div`,{className:a(`size-8 shrink-0 rounded-lg`,q)}),(0,G.jsx)(`div`,{className:a(`h-8 w-[4.5rem] shrink-0 rounded-lg`,q)})]})]}),r=(0,G.jsx)(`div`,{className:a(`h-3 w-full`,q)}),i=(0,G.jsx)(`div`,{className:a(`h-3 w-[92%]`,q)}),e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);let o;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,G.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,G.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[n,r,i,(0,G.jsxs)(`div`,{className:`mt-auto space-y-1 pt-0.5`,children:[(0,G.jsx)(`div`,{className:a(`h-3 w-full`,q)}),(0,G.jsx)(`div`,{className:a(`h-2.5 w-4/5`,q)})]})]})})}),e[4]=o):o=e[4],o}function J(){let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsx)(ce,{}),e[0]=t):t=e[0],t}var le=new Set([`builtin`,`user`,`marketplace`]),ue=new Set([`all`,`global`,`workspace`,`extra`]),de=`mprov`,Y=[`s0`,`s1`,`s2`,`s3`,`s4`,`s5`],fe=[`business`,`creative`,`documents`,`engineering`,`tools`];function pe(e){let t=(0,U.c)(28),{sk:n,mainTab:r,loading:i,catalog:o,filteredCatalog:s,builtinCategories:c,builtinCategoryFilter:l,setBuiltinCategoryFilter:u,catalogDisplayRows:d,catalogStatusFilter:f,resolveSkillEnabled:p,categoryLabel:m,sourceLabel:h,openSkillDetail:_,onSkillToggle:v,onUseSkillInChat:y,usingSkillInChatName:b,togglingSkillName:x}=e;if(i){let e=n.loading,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Y.map(me),t[0]=r):r=t[0];let i;return t[1]===n.loading?i=t[2]:(i=(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,"aria-busy":`true`,"aria-label":e,children:r}),t[1]=n.loading,t[2]=i),i}if(o.length===0){let e;return t[3]===n.empty?e=t[4]:(e=(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge py-16 text-center text-sm text-fg-muted`,children:n.empty}),t[3]=n.empty,t[4]=e),e}if(s.length===0){let e;return t[5]===n.noSearchResults?e=t[6]:(e=(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge py-16 text-center text-sm text-fg-muted`,children:n.noSearchResults}),t[5]=n.noSearchResults,t[6]=e),e}let S;t[7]!==c||t[8]!==l||t[9]!==m||t[10]!==u||t[11]!==n?(S=c.length>1?(0,G.jsx)(H,{items:[{id:``,label:n.marketplaceCategoryAll},...c.map(e=>({id:e,label:m(e),title:m(e)}))],activeTab:l,onChange:u,ariaLabel:n.marketplaceCategoriesAria,tabIdPrefix:`skills-builtin-category-tab`,className:`gap-2 pt-0.5 [scrollbar-width:thin]`,buttonClassName:`max-w-[14rem] truncate rounded-full border px-3 py-1.5 text-xs`,selectedClassName:`border-fg bg-fg text-surface-panel dark:border-fg dark:bg-fg dark:text-surface-base`,unselectedClassName:`border-edge bg-surface-panel text-fg-muted hover:border-edge-strong hover:text-fg dark:border-edge dark:bg-surface-hover/40`}):null,t[7]=c,t[8]=l,t[9]=m,t[10]=u,t[11]=n,t[12]=S):S=t[12];let C;t[13]!==d||t[14]!==f||t[15]!==r||t[16]!==v||t[17]!==y||t[18]!==_||t[19]!==p||t[20]!==n||t[21]!==h||t[22]!==x||t[23]!==b?(C=d.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge py-16 text-center text-sm text-fg-muted`,children:f===`disabled`?n.noDisabledSkills:n.noSearchResults}):(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:d.map(e=>{let t=p(e);return(0,G.jsxs)(`article`,{className:a(`group flex h-full flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors`,t?`hover:bg-surface-hover`:`bg-amber-50/30 hover:bg-amber-50/50 dark:bg-amber-950/20`),children:[(0,G.jsx)(`div`,{role:`button`,tabIndex:0,className:a(`flex min-h-0 flex-1 cursor-pointer flex-col rounded-lg text-left outline-none`,g.focusRingPanel),"aria-labelledby":`catalog-skill-title-${e.directoryId}`,onClick:t=>{t.target.closest(`button`)||_(e)},onKeyDown:t=>{t.target.closest(`button`)||(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),_(e))},children:(0,G.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsx)(`h3`,{id:`catalog-skill-title-${e.directoryId}`,className:`min-w-0 flex-1 truncate text-[15px] font-semibold leading-snug tracking-tight text-fg`,children:e.name}),(0,G.jsxs)(`div`,{role:`group`,className:a(`hidden shrink-0 items-center gap-1 transition-opacity sm:flex`,`sm:pointer-events-none sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`),onClick:Z,onKeyDown:X,children:[t?null:(0,G.jsx)(z,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:x===e.name,onClick:()=>void v(e.name,!0),children:x===e.name?n.uploading:n.detailModalEnable}),(0,G.jsx)(z,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:!t||b===e.name||x===e.name,title:t?void 0:n.useRequiresEnabled,onClick:()=>void y({name:e.name,source:`catalog`}),children:b===e.name?n.previewUseInChatBusy:n.previewUseInChat})]})]}),(0,G.jsx)(`p`,{className:`line-clamp-2 text-sm leading-relaxed text-fg-muted`,title:e.description?e.description:void 0,children:e.description||`—`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:r!==`builtin`||e.managed?(0,G.jsxs)(G.Fragment,{children:[r===`builtin`?null:(0,G.jsx)(`span`,{className:`rounded-md bg-surface-hover/60 px-2 py-0.5 dark:bg-surface-active/50`,children:h(e.source)}),e.managed?(0,G.jsxs)(`span`,{className:`rounded-md bg-surface-hover/60 px-2 py-0.5 dark:bg-surface-active/50`,children:[n.col.managed,`: `,n.yes]}):null,e.hub?(0,G.jsxs)(`span`,{className:`max-w-full break-all rounded-md bg-surface-hover/60 px-2 py-0.5 font-mono text-[10px] leading-snug dark:bg-surface-active/50 line-clamp-2`,title:`${e.hub.source}${e.hub.ref?`\nref: ${e.hub.ref}`:``}\nupdated: ${e.hub.updatedAt}`,children:[n.hubRemote,` ·`,` `,e.hub.kind===`git`?n.hubKindGit:n.hubKindArchive,` ·`,` `,e.hub.source.length>48?`${e.hub.source.slice(0,48)}…`:e.hub.source]}):null]}):null})]})})}),(0,G.jsxs)(`div`,{role:`group`,className:`mt-3 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3 sm:hidden`,children:[t?null:(0,G.jsx)(z,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:x===e.name,onClick:()=>void v(e.name,!0),children:x===e.name?n.uploading:n.detailModalEnable}),(0,G.jsx)(z,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:!t||b===e.name||x===e.name,title:t?void 0:n.useRequiresEnabled,onClick:()=>void y({name:e.name,source:`catalog`}),children:b===e.name?n.previewUseInChatBusy:n.previewUseInChat})]})]},`${e.directoryId}-${e.path}`)})}),t[13]=d,t[14]=f,t[15]=r,t[16]=v,t[17]=y,t[18]=_,t[19]=p,t[20]=n,t[21]=h,t[22]=x,t[23]=b,t[24]=C):C=t[24];let w;return t[25]!==S||t[26]!==C?(w=(0,G.jsxs)(G.Fragment,{children:[S,C]}),t[25]=S,t[26]=C,t[27]=w):w=t[27],w}function X(e){return e.stopPropagation()}function Z(e){return e.stopPropagation()}function me(e){return(0,G.jsx)(J,{},e)}var Q=`https://skillhub.cn`,he=`https://clawhub.ai`;function ge(e){let t=e.trim();return t?`${Q}/skills/${encodeURIComponent(t)}`:null}function _e(e){let t=e.trim();return t?`${he}/${encodeURIComponent(t)}`:null}function ve(e,t){return e===`skillhub`?ge(t):e===`clawhub`?_e(t):null}function ye(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function be(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function xe(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 Se(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}function Ce(e){let t=(0,U.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,G.jsx)(x,{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,G.jsx)(ee,{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?be(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,G.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,G.jsx)(z,{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,G.jsx)(z,{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,G.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,G.jsxs)(re,{children:[l,(0,G.jsxs)(A,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[u,f,_]})]}),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,G.jsx)(b,{open:r,onOpenChange:c,children:v}),t[28]=r,t[29]=c,t[30]=v,t[31]=y):y=t[31],y}var we=[{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 Te(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 Ee(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 De(e){let t=(0,U.c)(9),{name:n,className:r}=e,i;t[0]===n?i=t[1]:(i=Ee(n),t[0]=n,t[1]=i);let o=i,s=we[Te(n)%we.length],c;t[2]!==r||t[3]!==s.dark||t[4]!==s.light?(c=a(`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,r),t[2]=r,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,G.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}function Oe(e){let t=(0,U.c)(7),{label:n,children:r}=e;if(r==null||r===!1)return null;let i;t[0]===n?i=t[1]:(i=(0,G.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,G.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,G.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 ke(e){let t=(0,U.c)(118),{preview:n,sk:r}=e,i=n.metadata,o=n.toolConditions,s=!!o&&(o.requiresTools.length>0||o.requiresToolsets.length>0||o.fallbackForTools.length>0||o.fallbackForToolsets.length>0),c=i.requires,l=c&&((c.bins?.length??0)>0||(c.env?.length??0)>0||(c.anyBins?.length??0)>0),u,d,f,p,m,h,g,_,v,y,b,x,S,C,w;if(t[0]!==o||t[1]!==l||t[2]!==s||t[3]!==i.emoji||t[4]!==i.homepage||t[5]!==i.install||t[6]!==i.os||t[7]!==n.description||t[8]!==n.disableModelInvocation||t[9]!==n.requiredEnvVarNames||t[10]!==c||t[11]!==r.detailEnvVarsLabel||t[12]!==r.detailHomepageLabel||t[13]!==r.detailInstallLabel||t[14]!==r.detailNotInjectedNote||t[15]!==r.detailPlatformsLabel||t[16]!==r.detailRequiresAnyBins||t[17]!==r.detailRequiresBins||t[18]!==r.detailRequiresEnv||t[19]!==r.detailRequiresLabel||t[20]!==r.detailSummaryHeading||t[21]!==r.detailToolGatingLabel||t[22]!==r.detailToolsFallbackList||t[23]!==r.detailToolsRequiresList||t[24]!==r.detailToolsetsFallbackList||t[25]!==r.detailToolsetsRequiresList){let e=i.install?.filter(Me)??[],T=n.requiredEnvVarNames?.filter(je)??[];g=`space-y-6`,m=`skill-detail-summary-heading`,t[41]===r.detailSummaryHeading?h=t[42]:(h=(0,G.jsx)(`h3`,{id:`skill-detail-summary-heading`,className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:r.detailSummaryHeading}),t[41]=r.detailSummaryHeading,t[42]=h),v=`rounded-xl border border-edge bg-surface-base px-4 py-3 dark:bg-surface-hover/25`,t[43]===i.emoji?y=t[44]:(y=i.emoji?.trim()?(0,G.jsx)(`p`,{className:`text-2xl leading-none`,"aria-hidden":!0,children:i.emoji.trim()}):null,t[43]=i.emoji,t[44]=y);let E;t[45]===i.emoji?E=t[46]:(E=i.emoji?.trim()?`mt-2`:``,t[45]=i.emoji,t[46]=E);let D;t[47]===E?D=t[48]:(D=a(`text-sm leading-relaxed text-fg`,E),t[47]=E,t[48]=D),t[49]!==n.description||t[50]!==D?(b=(0,G.jsx)(`p`,{className:D,children:n.description}),t[49]=n.description,t[50]=D,t[51]=b):b=t[51],t[52]!==n.disableModelInvocation||t[53]!==r.detailNotInjectedNote?(x=n.disableModelInvocation?(0,G.jsx)(`p`,{className:`mt-3 rounded-lg border border-amber-200/80 bg-amber-50/90 px-3 py-2 text-xs leading-snug text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/40 dark:text-amber-100`,children:r.detailNotInjectedNote}):null,t[52]=n.disableModelInvocation,t[53]=r.detailNotInjectedNote,t[54]=x):x=t[54];let O;t[55]===i.homepage?O=t[56]:(O=i.homepage?.trim()?(0,G.jsx)(`a`,{href:i.homepage.trim(),target:`_blank`,rel:`noopener noreferrer`,className:`break-all text-accent underline-offset-2 hover:underline`,children:i.homepage.trim()}):null,t[55]=i.homepage,t[56]=O),t[57]!==r.detailHomepageLabel||t[58]!==O?(S=(0,G.jsx)(Oe,{label:r.detailHomepageLabel,children:O}),t[57]=r.detailHomepageLabel,t[58]=O,t[59]=S):S=t[59];let k;t[60]===i.os?k=t[61]:(k=i.os&&i.os.length>0?(0,G.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:i.os.join(`, `)}):null,t[60]=i.os,t[61]=k),t[62]!==r.detailPlatformsLabel||t[63]!==k?(C=(0,G.jsx)(Oe,{label:r.detailPlatformsLabel,children:k}),t[62]=r.detailPlatformsLabel,t[63]=k,t[64]=C):C=t[64];let A;t[65]!==l||t[66]!==c||t[67]!==r.detailRequiresAnyBins||t[68]!==r.detailRequiresBins||t[69]!==r.detailRequiresEnv?(A=l&&c?(0,G.jsxs)(`ul`,{className:`list-inside list-disc space-y-1 text-sm text-fg-muted`,children:[c.bins&&c.bins.length>0?(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`span`,{className:`text-fg`,children:[r.detailRequiresBins,`: `]}),c.bins.join(`, `)]}):null,c.env&&c.env.length>0?(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`span`,{className:`text-fg`,children:[r.detailRequiresEnv,`: `]}),(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:c.env.join(`, `)})]}):null,c.anyBins&&c.anyBins.length>0?(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`span`,{className:`text-fg`,children:[r.detailRequiresAnyBins,`: `]}),c.anyBins.join(`, `)]}):null]}):null,t[65]=l,t[66]=c,t[67]=r.detailRequiresAnyBins,t[68]=r.detailRequiresBins,t[69]=r.detailRequiresEnv,t[70]=A):A=t[70],t[71]!==r.detailRequiresLabel||t[72]!==A?(w=(0,G.jsx)(Oe,{label:r.detailRequiresLabel,children:A}),t[71]=r.detailRequiresLabel,t[72]=A,t[73]=w):w=t[73];let j=e.length>0?(0,G.jsx)(`ul`,{className:`list-inside list-decimal space-y-1.5 text-sm text-fg-muted`,children:e.map(Ae)}):null;t[74]!==r.detailInstallLabel||t[75]!==j?(f=(0,G.jsx)(Oe,{label:r.detailInstallLabel,children:j}),t[74]=r.detailInstallLabel,t[75]=j,t[76]=f):f=t[76];let M;t[77]!==o||t[78]!==s||t[79]!==r.detailToolsFallbackList||t[80]!==r.detailToolsRequiresList||t[81]!==r.detailToolsetsFallbackList||t[82]!==r.detailToolsetsRequiresList?(M=s&&o?(0,G.jsxs)(`ul`,{className:`mt-1 space-y-2 text-sm text-fg-muted`,children:[o.requiresTools.length>0?(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsRequiresList,`: `]}),o.requiresTools.join(`, `)]}):null,o.requiresToolsets.length>0?(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsetsRequiresList,`: `]}),o.requiresToolsets.join(`, `)]}):null,o.fallbackForTools.length>0?(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsFallbackList,`: `]}),o.fallbackForTools.join(`, `)]}):null,o.fallbackForToolsets.length>0?(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.detailToolsetsFallbackList,`: `]}),o.fallbackForToolsets.join(`, `)]}):null]}):null,t[77]=o,t[78]=s,t[79]=r.detailToolsFallbackList,t[80]=r.detailToolsRequiresList,t[81]=r.detailToolsetsFallbackList,t[82]=r.detailToolsetsRequiresList,t[83]=M):M=t[83],t[84]!==r.detailToolGatingLabel||t[85]!==M?(p=(0,G.jsx)(Oe,{label:r.detailToolGatingLabel,children:M}),t[84]=r.detailToolGatingLabel,t[85]=M,t[86]=p):p=t[86],u=Oe,d=r.detailEnvVarsLabel,_=T.length>0?(0,G.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:T.join(`, `)}):null,t[0]=o,t[1]=l,t[2]=s,t[3]=i.emoji,t[4]=i.homepage,t[5]=i.install,t[6]=i.os,t[7]=n.description,t[8]=n.disableModelInvocation,t[9]=n.requiredEnvVarNames,t[10]=c,t[11]=r.detailEnvVarsLabel,t[12]=r.detailHomepageLabel,t[13]=r.detailInstallLabel,t[14]=r.detailNotInjectedNote,t[15]=r.detailPlatformsLabel,t[16]=r.detailRequiresAnyBins,t[17]=r.detailRequiresBins,t[18]=r.detailRequiresEnv,t[19]=r.detailRequiresLabel,t[20]=r.detailSummaryHeading,t[21]=r.detailToolGatingLabel,t[22]=r.detailToolsFallbackList,t[23]=r.detailToolsRequiresList,t[24]=r.detailToolsetsFallbackList,t[25]=r.detailToolsetsRequiresList,t[26]=u,t[27]=d,t[28]=f,t[29]=p,t[30]=m,t[31]=h,t[32]=g,t[33]=_,t[34]=v,t[35]=y,t[36]=b,t[37]=x,t[38]=S,t[39]=C,t[40]=w}else u=t[26],d=t[27],f=t[28],p=t[29],m=t[30],h=t[31],g=t[32],_=t[33],v=t[34],y=t[35],b=t[36],x=t[37],S=t[38],C=t[39],w=t[40];let T;t[87]!==u||t[88]!==d||t[89]!==_?(T=(0,G.jsx)(u,{label:d,children:_}),t[87]=u,t[88]=d,t[89]=_,t[90]=T):T=t[90];let E;t[91]!==f||t[92]!==p||t[93]!==T||t[94]!==v||t[95]!==y||t[96]!==b||t[97]!==x||t[98]!==S||t[99]!==C||t[100]!==w?(E=(0,G.jsxs)(`div`,{className:v,children:[y,b,x,S,C,w,f,p,T]}),t[91]=f,t[92]=p,t[93]=T,t[94]=v,t[95]=y,t[96]=b,t[97]=x,t[98]=S,t[99]=C,t[100]=w,t[101]=E):E=t[101];let D;t[102]!==m||t[103]!==h||t[104]!==E?(D=(0,G.jsxs)(`section`,{"aria-labelledby":m,children:[h,E]}),t[102]=m,t[103]=h,t[104]=E,t[105]=D):D=t[105];let O;t[106]===r.detailInstructionsHeading?O=t[107]:(O=(0,G.jsx)(`h3`,{id:`skill-detail-instructions-heading`,className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:r.detailInstructionsHeading}),t[106]=r.detailInstructionsHeading,t[107]=O);let k;t[108]!==n.bodyMarkdown||t[109]!==r.detailNoInstructionsBody?(k=n.bodyMarkdown.trim()?(0,G.jsx)(`div`,{className:`markdown-content min-w-0 break-words`,children:(0,G.jsx)(V,{content:n.bodyMarkdown})}):(0,G.jsx)(`p`,{className:`text-sm italic text-fg-muted`,children:r.detailNoInstructionsBody}),t[108]=n.bodyMarkdown,t[109]=r.detailNoInstructionsBody,t[110]=k):k=t[110];let A;t[111]!==O||t[112]!==k?(A=(0,G.jsxs)(`section`,{"aria-labelledby":`skill-detail-instructions-heading`,children:[O,k]}),t[111]=O,t[112]=k,t[113]=A):A=t[113];let j;return t[114]!==g||t[115]!==D||t[116]!==A?(j=(0,G.jsxs)(`div`,{className:g,children:[D,A]}),t[114]=g,t[115]=D,t[116]=A,t[117]=j):j=t[117],j}function Ae(e,t){return(0,G.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:(0,G.jsx)(`span`,{className:`text-fg`,children:xe(e)})},e.id||`${e.kind}-${t}`)}function je(e){return e.trim()}function Me(e){return e&&typeof e.kind==`string`}var Ne=[{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 Pe(e){let t=(0,U.c)(81),{sk:n,detailOpen:r,setDetailOpen:i,detailSource:o,setDetailSource:s,detailTitle:c,setDetailTitle:l,detailCatalogPreview:u,setDetailCatalogPreview:d,detailMarketplacePreview:f,setDetailMarketplacePreview:p,detailLoading:m,detailError:h,setDetailError:_,detailEnabled:v,detailDirectoryId:y,detailManaged:S,detailExternalUrl:C,usingSkillInChatName:E,installingMarketName:D,togglingSkillName:M,isSkillInstalledByName:N,onUseSkillInChat:P,onMarketInstall:F,onSkillToggle:I,setConfirmId:L,setConfirmOpen:te}=e,R;t[0]!==d||t[1]!==_||t[2]!==p||t[3]!==i||t[4]!==s||t[5]!==l?(R=e=>{i(e),e||(s(`catalog`),d(null),p(null),_(null),l(``))},t[0]=d,t[1]=_,t[2]=p,t[3]=i,t[4]=s,t[5]=l,t[6]=R):R=t[6];let B;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,G.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=B):B=t[7];let ne;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(ne=a(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(88vh,44rem)] max-h-[min(92vh,56rem)] w-[min(100%-2rem,min(92vw,56rem))]`,`-translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[8]=ne):ne=t[8];let ie=c||`?`,V;t[9]===ie?V=t[10]:(V=(0,G.jsx)(De,{name:ie}),t[9]=ie,t[10]=V);let oe=c||`—`,H;t[11]===oe?H=t[12]:(H=(0,G.jsx)(ee,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:oe}),t[11]=oe,t[12]=H);let se;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(se=a(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,g.focusRingPanel),t[13]=se):se=t[13];let W;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,G.jsx)(w,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=W):W=t[14];let K;t[15]===n.detailCloseAria?K=t[16]:(K=(0,G.jsx)(O,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,className:se,"aria-label":n.detailCloseAria,children:W})}),t[15]=n.detailCloseAria,t[16]=K);let q;t[17]!==V||t[18]!==H||t[19]!==K?(q=(0,G.jsxs)(`div`,{className:`group flex min-h-[3.25rem] shrink-0 items-center gap-3 border-b border-edge px-4 py-3`,children:[V,H,K]}),t[17]=V,t[18]=H,t[19]=K,t[20]=q):q=t[20];let ce;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,G.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-blue-600 dark:text-blue-400`,strokeWidth:1.75,"aria-hidden":!0}),t[21]=ce):ce=t[21];let J=o===`store`&&f?n.detailModalBanner:o===`store`?n.detailModalBannerStore:n.detailModalBanner,le;t[22]===J?le=t[23]:(le=(0,G.jsxs)(`div`,{className:`flex min-h-[3.25rem] shrink-0 items-start gap-2 border-b border-blue-200/80 bg-blue-50/95 px-4 py-2.5 text-sm text-fg dark:border-blue-900/50 dark:bg-blue-950/45`,children:[ce,(0,G.jsx)(`p`,{className:`min-w-0 leading-relaxed`,children:J})]}),t[22]=J,t[23]=le);let ue;t[24]!==u||t[25]!==v||t[26]!==h||t[27]!==m||t[28]!==f||t[29]!==o||t[30]!==n?(ue=(0,G.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto p-4`,children:m?(0,G.jsx)(`div`,{className:`flex h-full min-h-[14rem] flex-col gap-2.5 py-1`,"aria-busy":`true`,"aria-label":n.loading,children:Ne.map(Fe)}):h?(0,G.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):o===`catalog`&&u?(0,G.jsxs)(G.Fragment,{children:[v?null:(0,G.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,G.jsx)(k,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-300`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`p`,{className:`leading-relaxed`,children:n.detailDisabledNotice})]}),(0,G.jsx)(ke,{preview:u,sk:n})]}):o===`store`&&f?(0,G.jsx)(ke,{preview:f,sk:n}):(0,G.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n.detailLoadFailed})}),t[24]=u,t[25]=v,t[26]=h,t[27]=m,t[28]=f,t[29]=o,t[30]=n,t[31]=ue):ue=t[31];let de;t[32]!==C||t[33]!==o||t[34]!==n.marketplaceOpenExternal||t[35]!==n.marketplaceOpenExternalAria?(de=o===`store`&&C?(0,G.jsxs)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,className:a(`inline-flex h-9 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 text-sm font-medium text-fg-muted`,`hover:bg-surface-hover hover:text-fg dark:border-edge`,g.focusRingPanel),"aria-label":n.marketplaceOpenExternalAria,title:n.marketplaceOpenExternal,children:[(0,G.jsx)(T,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:n.marketplaceOpenExternal})]}):null,t[32]=C,t[33]=o,t[34]=n.marketplaceOpenExternal,t[35]=n.marketplaceOpenExternalAria,t[36]=de):de=t[36];let Y;t[37]!==y||t[38]!==S||t[39]!==o||t[40]!==L||t[41]!==te||t[42]!==n.delete?(Y=o===`catalog`&&S&&y?(0,G.jsxs)(z,{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:()=>{L(y),te(!0)},children:[(0,G.jsx)(j,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),n.delete]}):null,t[37]=y,t[38]=S,t[39]=o,t[40]=L,t[41]=te,t[42]=n.delete,t[43]=Y):Y=t[43];let fe;t[44]!==de||t[45]!==Y?(fe=(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[de,Y]}),t[44]=de,t[45]=Y,t[46]=fe):fe=t[46];let pe;t[47]!==v||t[48]!==m||t[49]!==o||t[50]!==c||t[51]!==D||t[52]!==N||t[53]!==F||t[54]!==I||t[55]!==P||t[56]!==i||t[57]!==n.cancel||t[58]!==n.detailModalDisable||t[59]!==n.detailModalEnable||t[60]!==n.marketplaceInstall||t[61]!==n.marketplaceReinstall||t[62]!==n.previewUseInChat||t[63]!==n.previewUseInChatBusy||t[64]!==n.uploading||t[65]!==n.useRequiresEnabled||t[66]!==M||t[67]!==E?(pe=(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:o===`store`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(z,{type:`button`,variant:`ghost`,onClick:()=>i(!1),children:n.cancel}),(0,G.jsx)(z,{type:`button`,variant:`secondary`,disabled:!c||m||E===c||D===c,onClick:()=>void P(),children:E===c?n.previewUseInChatBusy:n.previewUseInChat}),(0,G.jsx)(z,{type:`button`,variant:N(c)?`secondary`:`primary`,disabled:!c||D===c,onClick:()=>{c&&F(c,{useDetailProvider:!0})},children:D===c?n.uploading:N(c)?n.marketplaceReinstall:n.marketplaceInstall})]}):(0,G.jsxs)(G.Fragment,{children:[v?(0,G.jsx)(z,{type:`button`,variant:`secondary`,disabled:!c||M===c,onClick:()=>{c&&I(c,!1)},children:M===c?n.uploading:n.detailModalDisable}):(0,G.jsx)(z,{type:`button`,variant:`primary`,disabled:!c||M===c,onClick:()=>{c&&I(c,!0)},children:M===c?n.uploading:n.detailModalEnable}),(0,G.jsx)(z,{type:`button`,variant:`secondary`,disabled:!c||!v||m||E===c||M===c,title:v?void 0:n.useRequiresEnabled,onClick:()=>void P(),children:E===c?n.previewUseInChatBusy:n.previewUseInChat})]})}),t[47]=v,t[48]=m,t[49]=o,t[50]=c,t[51]=D,t[52]=N,t[53]=F,t[54]=I,t[55]=P,t[56]=i,t[57]=n.cancel,t[58]=n.detailModalDisable,t[59]=n.detailModalEnable,t[60]=n.marketplaceInstall,t[61]=n.marketplaceReinstall,t[62]=n.previewUseInChat,t[63]=n.previewUseInChatBusy,t[64]=n.uploading,t[65]=n.useRequiresEnabled,t[66]=M,t[67]=E,t[68]=pe):pe=t[68];let X;t[69]!==fe||t[70]!==pe?(X=(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge px-4 py-3`,children:[fe,pe]}),t[69]=fe,t[70]=pe,t[71]=X):X=t[71];let Z;t[72]!==q||t[73]!==le||t[74]!==ue||t[75]!==X?(Z=(0,G.jsxs)(re,{children:[B,(0,G.jsxs)(A,{className:ne,children:[q,le,ue,X]})]}),t[72]=q,t[73]=le,t[74]=ue,t[75]=X,t[76]=Z):Z=t[76];let me;return t[77]!==r||t[78]!==R||t[79]!==Z?(me=(0,G.jsx)(b,{open:r,onOpenChange:R,children:Z}),t[77]=r,t[78]=R,t[79]=Z,t[80]=me):me=t[80],me}function Fe(e){return(0,G.jsx)(`div`,{className:a(`h-4 animate-pulse rounded-md bg-surface-hover dark:bg-surface-active/50`,e.width)},e.id)}function $(e){let t=(0,U.c)(67),{sk:n,installOpen:r,setInstallOpen:i,pendingFile:o,setPendingFile:s,dropActive:c,setDropActive:l,uploading:u,onModalDragOver:d,onModalDragLeave:f,onModalDrop:p,onFileInputChange:m,onInstallSubmit:h}=e,_;t[0]!==l||t[1]!==i||t[2]!==s?(_=e=>{i(e),e||(s(null),l(!1))},t[0]=l,t[1]=i,t[2]=s,t[3]=_):_=t[3];let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,G.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[4]=v):v=t[4];let y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=a(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto`,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-float dark:border-edge`),t[5]=y):y=t[5];let S;t[6]===n.installModalTitle?S=t[7]:(S=(0,G.jsx)(ee,{className:`text-base font-semibold text-fg`,children:n.installModalTitle}),t[6]=n.installModalTitle,t[7]=S);let C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=a(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,g.focusRingPanel),t[8]=C):C=t[8];let T;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,G.jsx)(w,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=T):T=t[9];let E;t[10]===n.installClose?E=t[11]:(E=(0,G.jsx)(`span`,{className:`sr-only`,children:n.installClose}),t[10]=n.installClose,t[11]=E);let D;t[12]!==n.installClose||t[13]!==E?(D=(0,G.jsx)(O,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:C,"aria-label":n.installClose,children:[T,E]})}),t[12]=n.installClose,t[13]=E,t[14]=D):D=t[14];let k;t[15]!==S||t[16]!==D?(k=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[S,D]}),t[15]=S,t[16]=D,t[17]=k):k=t[17];let j=c?`border-accent bg-accent-soft/60 dark:bg-blue-950/40`:`border-edge bg-surface-base dark:bg-surface-hover/30`,M;t[18]===j?M=t[19]:(M=a(`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`,j),t[18]=j,t[19]=M);let N;t[20]!==m||t[21]!==n.installModalDropHint||t[22]!==u?(N=(0,G.jsx)(`input`,{type:`file`,accept:`.zip,.md,application/zip,text/markdown`,className:`sr-only`,"aria-label":n.installModalDropHint,disabled:u,onChange:m}),t[20]=m,t[21]=n.installModalDropHint,t[22]=u,t[23]=N):N=t[23];let P;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,G.jsx)(te,{className:`size-12 text-fg-subtle`,strokeWidth:1.25,"aria-hidden":!0}),t[24]=P):P=t[24];let F;t[25]===n.installModalDropHint?F=t[26]:(F=(0,G.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.installModalDropHint}),t[25]=n.installModalDropHint,t[26]=F);let I;t[27]===o?I=t[28]:(I=o?(0,G.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:o.name}):null,t[27]=o,t[28]=I);let L;t[29]!==f||t[30]!==d||t[31]!==p||t[32]!==M||t[33]!==N||t[34]!==F||t[35]!==I?(L=(0,G.jsxs)(`label`,{className:M,onDragLeave:f,onDragOver:d,onDrop:p,children:[N,P,F,I]}),t[29]=f,t[30]=d,t[31]=p,t[32]=M,t[33]=N,t[34]=F,t[35]=I,t[36]=L):L=t[36];let R;t[37]===n.installModalReqTitle?R=t[38]:(R=(0,G.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.installModalReqTitle}),t[37]=n.installModalReqTitle,t[38]=R);let z;t[39]===n.installModalReq1?z=t[40]:(z=(0,G.jsx)(`li`,{children:n.installModalReq1}),t[39]=n.installModalReq1,t[40]=z);let B;t[41]===n.installModalReq2?B=t[42]:(B=(0,G.jsx)(`li`,{children:n.installModalReq2}),t[41]=n.installModalReq2,t[42]=B);let ne;t[43]!==z||t[44]!==B?(ne=(0,G.jsxs)(`ul`,{className:`list-inside list-disc space-y-1 text-sm text-fg-muted`,children:[z,B]}),t[43]=z,t[44]=B,t[45]=ne):ne=t[45];let ie;t[46]!==R||t[47]!==ne?(ie=(0,G.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[R,ne]}),t[46]=R,t[47]=ne,t[48]=ie):ie=t[48];let ae=!o||u,V=!o||u?`cursor-not-allowed bg-surface-active text-fg-disabled`:`bg-accent text-white hover:bg-accent-hover`,oe;t[49]===V?oe=t[50]:(oe=a(`mt-6 flex w-full items-center justify-center rounded-xl py-3 text-sm font-semibold`,`transition-colors`,V,g.focusRingPanel),t[49]=V,t[50]=oe);let H;t[51]===h?H=t[52]:(H=()=>void h(),t[51]=h,t[52]=H);let se=u?n.uploading:n.installAction,W;t[53]!==ae||t[54]!==oe||t[55]!==H||t[56]!==se?(W=(0,G.jsx)(`button`,{type:`button`,disabled:ae,className:oe,onClick:H,children:se}),t[53]=ae,t[54]=oe,t[55]=H,t[56]=se,t[57]=W):W=t[57];let K;t[58]!==L||t[59]!==ie||t[60]!==W||t[61]!==k?(K=(0,G.jsxs)(re,{children:[v,(0,G.jsxs)(A,{className:y,children:[k,L,ie,W]})]}),t[58]=L,t[59]=ie,t[60]=W,t[61]=k,t[62]=K):K=t[62];let q;return t[63]!==r||t[64]!==_||t[65]!==K?(q=(0,G.jsx)(b,{open:r,onOpenChange:_,children:K}),t[63]=r,t[64]=_,t[65]=K,t[66]=q):q=t[66],q}function Ie(e){let t=(0,U.c)(66),{sk:n,mpCategories:r,mpCategoriesLoading:i,mpCategoriesError:o,mpPayload:s,mpLoading:c,mpError:l,marketCategoryId:u,setMarketCategoryId:d,marketPage:p,setMarketPage:m,isSkillInstalledByName:h,openMarketplaceDetail:_,onMarketInstall:v,installingMarketName:y,onUseSkillInChat:b,usingSkillInChatName:x,searchInputActive:S,searchQuery:C,setSearchQuery:w,registeredProviders:T,marketBrowseProvider:E,setMarketBrowseProvider:D}=e,O=!S,k,A,j;if(t[0]!==y||t[1]!==h||t[2]!==E||t[3]!==u||t[4]!==p||t[5]!==r||t[6]!==o||t[7]!==i||t[8]!==l||t[9]!==c||t[10]!==s||t[11]!==v||t[12]!==b||t[13]!==_||t[14]!==T||t[15]!==S||t[16]!==C||t[17]!==D||t[18]!==d||t[19]!==m||t[20]!==w||t[21]!==O||t[22]!==n.loading||t[23]!==n.marketplaceAuthor||t[24]!==n.marketplaceCategoriesAria||t[25]!==n.marketplaceCategoryAll||t[26]!==n.marketplaceDownloads||t[27]!==n.marketplaceEmpty||t[28]!==n.marketplaceEmptySearch||t[29]!==n.marketplaceEmptySearchClear||t[30]!==n.marketplaceEmptySearchTryProvider||t[31]!==n.marketplaceInstall||t[32]!==n.marketplaceInstalled||t[33]!==n.marketplacePageNext||t[34]!==n.marketplacePagePrev||t[35]!==n.marketplacePageStatus||t[36]!==n.marketplaceVersion||t[37]!==n.previewUseInChat||t[38]!==n.previewUseInChatBusy||t[39]!==n.uploading||t[40]!==x){let e;t[44]===E?e=t[45]:(e=e=>e.id!==E,t[44]=E,t[45]=e);let M=T.filter(e),ee=C.trim(),F;t[46]===n.marketplaceCategoryAll?F=t[47]:(F={id:``,label:n.marketplaceCategoryAll},t[46]=n.marketplaceCategoryAll,t[47]=F);let I;t[48]!==r||t[49]!==F?(I=[F,...r.map(He)],t[48]=r,t[49]=F,t[50]=I):I=t[50];let L=I;t[51]!==L||t[52]!==u||t[53]!==r.length||t[54]!==i||t[55]!==d||t[56]!==O||t[57]!==n.marketplaceCategoriesAria?(k=O?r.length>0?(0,G.jsx)(H,{items:L,activeTab:u,onChange:d,ariaLabel:n.marketplaceCategoriesAria,tabIdPrefix:`skills-marketplace-category-tab`,className:`min-h-[2.75rem] items-center gap-2 pt-0.5 [scrollbar-width:thin]`,buttonClassName:`max-w-[14rem] truncate rounded-full border px-3 py-1.5 text-xs`,selectedClassName:`border-fg bg-fg text-surface-panel dark:border-fg dark:bg-fg dark:text-surface-base`,unselectedClassName:`border-edge bg-surface-panel text-fg-muted hover:border-edge-strong hover:text-fg dark:border-edge dark:bg-surface-hover/40`}):i?(0,G.jsx)(`div`,{className:`-mx-1 flex min-h-[2.75rem] items-center gap-2 overflow-x-auto px-1 pb-1 pt-0.5 [scrollbar-width:thin]`,"aria-hidden":!0,children:[`p0`,`p1`,`p2`,`p3`,`p4`].map(Ve)}):null:null,t[51]=L,t[52]=u,t[53]=r.length,t[54]=i,t[55]=d,t[56]=O,t[57]=n.marketplaceCategoriesAria,t[58]=k):k=t[58],t[59]!==o||t[60]!==O?(A=O&&o?(0,G.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,role:`alert`,children:o}):null,t[59]=o,t[60]=O,t[61]=A):A=t[61],j=!s&&!l?(0,G.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:Y.map(Be)}):l&&!s?(0,G.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:l}):s?(0,G.jsxs)(`div`,{className:`relative`,children:[c?(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":n.loading,children:(0,G.jsx)(N,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,s.items.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-2xl border border-dashed border-edge py-12 text-center text-sm text-fg-muted`,children:[(0,G.jsx)(`p`,{className:`px-4`,children:S&&ee?be(n.marketplaceEmptySearch,{query:ee}):n.marketplaceEmpty}),S?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[M.map(e=>(0,G.jsx)(z,{type:`button`,variant:`secondary`,className:`h-8 px-3 text-xs`,onClick:()=>D(e.id),children:be(n.marketplaceEmptySearchTryProvider,{provider:e.displayName})},e.id)),(0,G.jsx)(z,{type:`button`,variant:`ghost`,className:`h-8 px-3 text-xs`,onClick:()=>w(``),children:n.marketplaceEmptySearchClear})]}):null]}):(0,G.jsx)(`div`,{className:a(`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,c&&`pointer-events-none opacity-[0.52] motion-reduce:opacity-100`),children:s.items.map(e=>{let t=ye(e,e.providerId??E),r=h(t);return(0,G.jsxs)(`article`,{className:a(`group flex h-full flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,`transition-colors hover:bg-surface-hover`),children:[(0,G.jsx)(`div`,{role:`button`,tabIndex:0,className:a(`flex min-h-0 flex-1 cursor-pointer flex-col rounded-lg text-left outline-none`,g.focusRingPanel),"aria-labelledby":`mp-skill-title-${e.id}`,onClick:n=>{n.target.closest(`button`)||_(t,e.name,e.providerId??void 0)},onKeyDown:n=>{n.target.closest(`button`)||(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),_(t,e.name,e.providerId??void 0))},children:(0,G.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsx)(`h3`,{id:`mp-skill-title-${e.id}`,className:`min-w-0 flex-1 truncate text-[15px] font-semibold leading-snug tracking-tight text-fg`,children:e.name}),(0,G.jsxs)(`div`,{role:`group`,className:a(`hidden shrink-0 items-center gap-1 transition-opacity sm:flex`,`sm:pointer-events-none sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`),onClick:ze,onKeyDown:Re,children:[r?null:(0,G.jsx)(z,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:c||y===t,onClick:()=>void v(t,{providerOverride:e.providerId??null}),children:y===t?n.uploading:n.marketplaceInstall}),(0,G.jsx)(z,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:c||x===t||y===t,onClick:()=>void b({name:t,source:`store`,providerOverride:e.providerId??null}),children:x===t?n.previewUseInChatBusy:n.previewUseInChat})]})]}),(0,G.jsx)(`p`,{className:`line-clamp-2 text-sm leading-relaxed text-fg-muted`,title:e.description?e.description:void 0,children:e.description||`—`}),(0,G.jsxs)(`div`,{className:`mt-auto min-h-[2.625rem] space-y-1 text-[11px] leading-snug text-fg-muted`,children:[(0,G.jsxs)(`p`,{className:`line-clamp-1`,title:`${n.marketplaceAuthor}: ${e.author.username} · ${n.marketplaceDownloads}: ${e.downloads}${e.stars!=null&&e.stars>0?` · ★${e.stars}`:``}${r?` · ${n.marketplaceInstalled}`:``}`,children:[(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:n.marketplaceAuthor}),` `,(0,G.jsx)(`span`,{className:`text-fg`,children:e.author.username}),(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:` · `}),(0,G.jsxs)(`span`,{children:[n.marketplaceDownloads,`: `,e.downloads]}),e.stars!=null&&e.stars>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:` · `}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-fg-muted`,children:[(0,G.jsx)(f,{className:`size-3 shrink-0 text-amber-600 dark:text-amber-400`,strokeWidth:2,"aria-hidden":!0}),e.stars]})]}):null,r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:` · `}),(0,G.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:n.marketplaceInstalled})]}):null]}),e.latestVersion?(0,G.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]})]})})}),(0,G.jsxs)(`div`,{role:`group`,className:`mt-3 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3 sm:hidden`,children:[r?null:(0,G.jsx)(z,{type:`button`,variant:`primary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:c||y===t,onClick:()=>void v(t,{providerOverride:e.providerId??null}),children:y===t?n.uploading:n.marketplaceInstall}),(0,G.jsx)(z,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 whitespace-nowrap px-2.5 text-xs font-medium`,disabled:c||x===t||y===t,onClick:()=>void b({name:t,source:`store`,providerOverride:e.providerId??null}),children:x===t?n.previewUseInChatBusy:n.previewUseInChat})]})]},e.id)})}),s.items.length>0?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-col items-center justify-between gap-3 sm:flex-row`,children:[(0,G.jsx)(`p`,{className:`text-center text-xs text-fg-muted sm:text-left`,children:be(n.marketplacePageStatus,{page:s.meta.page,totalPages:s.meta.totalPages,total:s.meta.total})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(z,{type:`button`,variant:`ghost`,className:`h-9 gap-1 px-2`,disabled:c||p<=1,"aria-label":n.marketplacePagePrev,onClick:()=>m(Le),children:[(0,G.jsx)(B,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:n.marketplacePagePrev})]}),(0,G.jsxs)(z,{type:`button`,variant:`ghost`,className:`h-9 gap-1 px-2`,disabled:c||p>=s.meta.totalPages,"aria-label":n.marketplacePageNext,onClick:()=>m(e=>Math.min(s.meta.totalPages,e+1)),children:[(0,G.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:n.marketplacePageNext}),(0,G.jsx)(P,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})]})]})]}):null]}):null,t[0]=y,t[1]=h,t[2]=E,t[3]=u,t[4]=p,t[5]=r,t[6]=o,t[7]=i,t[8]=l,t[9]=c,t[10]=s,t[11]=v,t[12]=b,t[13]=_,t[14]=T,t[15]=S,t[16]=C,t[17]=D,t[18]=d,t[19]=m,t[20]=w,t[21]=O,t[22]=n.loading,t[23]=n.marketplaceAuthor,t[24]=n.marketplaceCategoriesAria,t[25]=n.marketplaceCategoryAll,t[26]=n.marketplaceDownloads,t[27]=n.marketplaceEmpty,t[28]=n.marketplaceEmptySearch,t[29]=n.marketplaceEmptySearchClear,t[30]=n.marketplaceEmptySearchTryProvider,t[31]=n.marketplaceInstall,t[32]=n.marketplaceInstalled,t[33]=n.marketplacePageNext,t[34]=n.marketplacePagePrev,t[35]=n.marketplacePageStatus,t[36]=n.marketplaceVersion,t[37]=n.previewUseInChat,t[38]=n.previewUseInChatBusy,t[39]=n.uploading,t[40]=x,t[41]=k,t[42]=A,t[43]=j}else k=t[41],A=t[42],j=t[43];let M;return t[62]!==k||t[63]!==A||t[64]!==j?(M=(0,G.jsxs)(G.Fragment,{children:[k,A,j]}),t[62]=k,t[63]=A,t[64]=j,t[65]=M):M=t[65],M}function Le(e){return Math.max(1,e-1)}function Re(e){return e.stopPropagation()}function ze(e){return e.stopPropagation()}function Be(e){return(0,G.jsx)(ce,{},e)}function Ve(e){return(0,G.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 He(e){return{id:e.id,label:e.label,title:e.label}}function Ue(e){let t=(0,U.c)(114),{vm:n}=e,{sk:r,hasToken:i,error:o,actionFeedback:s,skillDiagnostics:c,mainTab:l,setMainTab:u,setSourceFilter:d,builtinTabStats:f,userTabStats:p,catalogDisabledCount:_,catalogStatusFilter:v,setCatalogStatusFilter:b,marketSort:x,setMarketSort:C,marketBrowseProvider:w,setMarketBrowseProvider:T,registeredProviders:D,filterLabel:O,inSettingsShell:k,searchInputActive:A,resultTab:j,setResultTab:M,aggregatedTabCounts:ee,aggregatedProviderStatus:N}=n;if(!i){let e;t[0]===n?e=t[1]:(e=(0,G.jsx)(qe,{vm:n}),t[0]=n,t[1]=e);let i;t[2]===r.needToken?i=t[3]:(i=(0,G.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:r.needToken}),t[2]=r.needToken,t[3]=i);let a;return t[4]!==e||t[5]!==i?(a=(0,G.jsxs)(G.Fragment,{children:[e,i]}),t[4]=e,t[5]=i,t[6]=a):a=t[6],a}let P;t[7]===r.tabMarketplace?P=t[8]:(P={id:`marketplace`,label:r.tabMarketplace},t[7]=r.tabMarketplace,t[8]=P);let F=`${f.enabled}/${f.total}`,I;t[9]!==r.tabBuiltin||t[10]!==F?(I={id:`builtin`,label:r.tabBuiltin,count:F},t[9]=r.tabBuiltin,t[10]=F,t[11]=I):I=t[11];let L=`${p.enabled}/${p.total}`,te;t[12]!==r.tabUser||t[13]!==L?(te={id:`user`,label:r.tabUser,count:L},t[12]=r.tabUser,t[13]=L,t[14]=te):te=t[14];let R;t[15]!==P||t[16]!==I||t[17]!==te?(R=[P,I,te],t[15]=P,t[16]=I,t[17]=te,t[18]=R):R=t[18];let z=R,B;t[19]===D?B=t[20]:(B=[`all`,...D.map(Ke)],t[19]=D,t[20]=B);let ne=B,re;t[21]!==N||t[22]!==ee||t[23]!==D||t[24]!==r.marketplaceLoadFailed||t[25]!==r.marketplaceResultsTabAll||t[26]!==ne?(re=ne.map(e=>{let t=e===`all`?r.marketplaceResultsTabAll:D.find(t=>t.id===e)?.displayName??e,n=ee[e]??0,i=e===`all`?null:N[e];return{id:e,label:t,title:i===`error`?`${t} · ${r.marketplaceLoadFailed}`:void 0,suffix:i===`loading`?(0,G.jsx)(`span`,{className:`inline-block size-1.5 animate-pulse rounded-full bg-fg-muted/60 motion-reduce:animate-none`,"aria-hidden":!0}):i===`error`?(0,G.jsx)(`span`,{className:`inline-block size-1.5 rounded-full bg-red-500`,"aria-hidden":!0}):(0,G.jsx)(`span`,{className:`tabular-nums opacity-70`,children:n})}}),t[21]=N,t[22]=ee,t[23]=D,t[24]=r.marketplaceLoadFailed,t[25]=r.marketplaceResultsTabAll,t[26]=ne,t[27]=re):re=t[27];let ae=re,V;t[28]===n?V=t[29]:(V=(0,G.jsx)(qe,{vm:n}),t[28]=n,t[29]=V);let se;t[30]!==s||t[31]!==o?(se=s?(0,G.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:a(`rounded-xl border px-3 py-2 text-sm`,s.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:s.message}):o?(0,G.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:o}):null,t[30]=s,t[31]=o,t[32]=se):se=t[32];let W;t[33]===c?W=t[34]:(W=c.length>0?(0,G.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,G.jsxs)(`div`,{className:`font-medium`,children:[`Skill diagnostics: `,c.length]}),(0,G.jsx)(`ul`,{className:`mt-1 space-y-1`,children:c.slice(0,3).map(Ge)})]}):null,t[33]=c,t[34]=W);let q;t[35]!==k||t[36]!==n.loading||t[37]!==n.mainTab||t[38]!==n.onReloadClick||t[39]!==n.searchQuery||t[40]!==n.setInstallOpen||t[41]!==n.setPendingFile||t[42]!==n.setSearchQuery||t[43]!==n.sk?(q=k?(0,G.jsx)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-4 dark:border-edge-subtle sm:flex-row sm:flex-wrap sm:items-center sm:justify-end`,children:(0,G.jsx)(K,{loading:n.loading,onReloadClick:n.onReloadClick,searchQuery:n.searchQuery,setSearchQuery:n.setSearchQuery,mainTab:n.mainTab,sk:n.sk,setPendingFile:n.setPendingFile,setInstallOpen:n.setInstallOpen})}):null,t[35]=k,t[36]=n.loading,t[37]=n.mainTab,t[38]=n.onReloadClick,t[39]=n.searchQuery,t[40]=n.setInstallOpen,t[41]=n.setPendingFile,t[42]=n.setSearchQuery,t[43]=n.sk,t[44]=q):q=t[44];let ce;t[45]!==l||t[46]!==z||t[47]!==u||t[48]!==r.skillsNavAria?(ce=(0,G.jsx)(H,{items:z,activeTab:l,onChange:u,ariaLabel:r.skillsNavAria,tabIdPrefix:`skills-tab`,panelIdPrefix:`skills-panel`,className:`flex-wrap`}),t[45]=l,t[46]=z,t[47]=u,t[48]=r.skillsNavAria,t[49]=ce):ce=t[49];let J=l===`user`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`,le;t[50]===J?le=t[51]:(le=a(`flex min-h-9 min-w-0 items-center gap-2`,J),t[50]=J,t[51]=le);let ue;t[52]!==O||t[53]!==l||t[54]!==d||t[55]!==r.filterAll||t[56]!==r.filterExtra||t[57]!==r.filterGlobal||t[58]!==r.filterWorkspace?(ue=l===`user`?(0,G.jsxs)(m,{children:[(0,G.jsx)(y,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,g.transition,g.focusRingPanel),children:[(0,G.jsx)(h,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:O}),(0,G.jsx)(ie,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,G.jsx)(oe,{children:(0,G.jsx)(S,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[`all`,`global`,`workspace`,`extra`].map(e=>(0,G.jsx)(E,{className:a(`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none`,`hover:bg-surface-hover data-[highlighted]:bg-surface-hover`),onSelect:()=>d(e),children:e===`all`?r.filterAll:e===`global`?r.filterGlobal:e===`workspace`?r.filterWorkspace:r.filterExtra},e))})})]}):null,t[52]=O,t[53]=l,t[54]=d,t[55]=r.filterAll,t[56]=r.filterExtra,t[57]=r.filterGlobal,t[58]=r.filterWorkspace,t[59]=ue):ue=t[59];let de;t[60]!==l||t[61]!==w||t[62]!==x||t[63]!==D||t[64]!==j||t[65]!==ae||t[66]!==A||t[67]!==T||t[68]!==C||t[69]!==M||t[70]!==r.marketplaceBrowseSwitchAria||t[71]!==r.marketplaceResultsTabsAria||t[72]!==r.marketplaceSortDownloads||t[73]!==r.marketplaceSortNewest?(de=l===`marketplace`?A?(0,G.jsx)(H,{items:ae,activeTab:j,onChange:M,ariaLabel:r.marketplaceResultsTabsAria,tabIdPrefix:`skills-marketplace-results-tab`,panelIdPrefix:`skills-marketplace-results-panel`,className:`inline-flex h-9 shrink-0 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`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`inline-flex h-9 shrink-0 rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":r.marketplaceBrowseSwitchAria,children:D.map(e=>{let t=w===e.id;return(0,G.jsx)(`button`,{type:`button`,className:a(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,g.focusRingPanel,t?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":t,onClick:()=>T(e.id),children:e.displayName},e.id)})}),(0,G.jsxs)(m,{children:[(0,G.jsx)(y,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,g.transition,g.focusRingPanel),children:[(0,G.jsx)(h,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:x===`newest`?r.marketplaceSortNewest:r.marketplaceSortDownloads}),(0,G.jsx)(ie,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,G.jsx)(oe,{children:(0,G.jsxs)(S,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,G.jsx)(E,{className:a(`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none`,`hover:bg-surface-hover data-[highlighted]:bg-surface-hover`),onSelect:()=>C(`downloads`),children:r.marketplaceSortDownloads}),(0,G.jsx)(E,{className:a(`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none`,`hover:bg-surface-hover data-[highlighted]:bg-surface-hover`),onSelect:()=>C(`newest`),children:r.marketplaceSortNewest})]})})]})]}):null,t[60]=l,t[61]=w,t[62]=x,t[63]=D,t[64]=j,t[65]=ae,t[66]=A,t[67]=T,t[68]=C,t[69]=M,t[70]=r.marketplaceBrowseSwitchAria,t[71]=r.marketplaceResultsTabsAria,t[72]=r.marketplaceSortDownloads,t[73]=r.marketplaceSortNewest,t[74]=de):de=t[74];let Y;t[75]!==_||t[76]!==v||t[77]!==l||t[78]!==b||t[79]!==r.filterAll||t[80]!==r.filterDisabledOnly||t[81]!==r.filterDisabledOnlyAria?(Y=l!==`marketplace`&&_>0?(0,G.jsx)(`button`,{type:`button`,className:a(`inline-flex h-9 shrink-0 items-center rounded-lg border px-2.5 text-xs font-medium transition-colors`,g.focusRingPanel,v===`disabled`?`border-fg bg-fg text-surface-panel dark:border-fg dark:bg-fg dark:text-surface-base`:`border-amber-300/80 bg-amber-50/90 text-amber-950 hover:border-amber-400 dark:border-amber-700/60 dark:bg-amber-950/40 dark:text-amber-100`),"aria-pressed":v===`disabled`,"aria-label":r.filterDisabledOnlyAria,onClick:()=>b(We),children:v===`disabled`?r.filterAll:be(r.filterDisabledOnly,{count:_})}):l===`builtin`?(0,G.jsx)(`div`,{className:`h-9 min-w-[9rem] shrink-0`,"aria-hidden":!0}):null,t[75]=_,t[76]=v,t[77]=l,t[78]=b,t[79]=r.filterAll,t[80]=r.filterDisabledOnly,t[81]=r.filterDisabledOnlyAria,t[82]=Y):Y=t[82];let fe;t[83]!==le||t[84]!==ue||t[85]!==de||t[86]!==Y?(fe=(0,G.jsxs)(`div`,{className:le,children:[ue,de,Y]}),t[83]=le,t[84]=ue,t[85]=de,t[86]=Y,t[87]=fe):fe=t[87];let X;t[88]!==ce||t[89]!==fe?(X=(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[ce,fe]}),t[88]=ce,t[89]=fe,t[90]=X):X=t[90];let Z;t[91]!==l||t[92]!==n?(Z=l===`marketplace`?(0,G.jsx)(Ie,{...n}):(0,G.jsx)(pe,{...n}),t[91]=l,t[92]=n,t[93]=Z):Z=t[93];let me;t[94]!==X||t[95]!==Z?(me=(0,G.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[X,Z]}),t[94]=X,t[95]=Z,t[96]=me):me=t[96];let Q;t[97]!==se||t[98]!==W||t[99]!==q||t[100]!==me?(Q=(0,G.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[se,W,q,me]}),t[97]=se,t[98]=W,t[99]=q,t[100]=me,t[101]=Q):Q=t[101];let he,ge,_e;t[102]===n?(he=t[103],ge=t[104],_e=t[105]):(he=(0,G.jsx)(Pe,{...n}),ge=(0,G.jsx)($,{...n}),_e=(0,G.jsx)(Ce,{...n}),t[102]=n,t[103]=he,t[104]=ge,t[105]=_e);let ve;t[106]!==Q||t[107]!==he||t[108]!==ge||t[109]!==_e?(ve=(0,G.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[Q,he,ge,_e]}),t[106]=Q,t[107]=he,t[108]=ge,t[109]=_e,t[110]=ve):ve=t[110];let ye;return t[111]!==V||t[112]!==ve?(ye=(0,G.jsxs)(G.Fragment,{children:[V,ve]}),t[111]=V,t[112]=ve,t[113]=ye):ye=t[113],ye}function We(e){return e===`disabled`?`all`:`disabled`}function Ge(e,t){return(0,G.jsxs)(`li`,{className:`truncate`,children:[e.type,`: `,e.message]},`${e.path??e.skillName??`diagnostic`}-${t}`)}function Ke(e){return e.id}function qe(e){let t=(0,U.c)(17),{vm:n}=e,{sk:r,hasToken:i,loading:a,onReloadClick:o,searchQuery:s,setSearchQuery:c,mainTab:l,setPendingFile:u,setInstallOpen:d,inSettingsShell:f}=n,p=M(Ye),m=M(Je),h;t[0]!==a||t[1]!==l||t[2]!==o||t[3]!==s||t[4]!==d||t[5]!==u||t[6]!==c||t[7]!==r?(h=(0,G.jsx)(K,{loading:a,onReloadClick:o,searchQuery:s,setSearchQuery:c,mainTab:l,sk:r,setPendingFile:u,setInstallOpen:d}),t[0]=a,t[1]=l,t[2]=o,t[3]=s,t[4]=d,t[5]=u,t[6]=c,t[7]=r,t[8]=h):h=t[8];let g=h,_,v;return t[9]!==m||t[10]!==i||t[11]!==f||t[12]!==p||t[13]!==r.title||t[14]!==g?(_=()=>!i||f?(m(),()=>m()):(p({startExtra:null,main:(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r.title})}),end:g}),()=>m()),v=[m,i,f,p,g,r.title],t[9]=m,t[10]=i,t[11]=f,t[12]=p,t[13]=r.title,t[14]=g,t[15]=_,t[16]=v):(_=t[15],v=t[16]),(0,W.useLayoutEffect)(_,v),null}function Je(e){return e.clearPageHeader}function Ye(e){return e.setPageHeader}async function Xe(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??`workspace`);let r=s.getState().token,i=new Headers;r&&i.set(`Authorization`,`Bearer ${r}`);let a=await fetch(c(`/api/skills/upload`),{method:`POST`,headers:i,body:n});a.status===401&&s.getState().onUnauthorized();let o=await a.json().catch(()=>({}));if(!a.ok)throw Error(o.error||`HTTP ${a.status}`);if(!o.payload?.skillId)throw Error(`Invalid response`);return o.payload}async function Ze(e,t){let n=t?`?target=${encodeURIComponent(t)}`:``,r=await l(c(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!r.ok)throw Error(await I(r))}async function Qe(e,t){let n=await l(c(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await I(n))}function $e(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function et(e){let t=new URLSearchParams;$e(t,e?.provider);let n=t.toString(),r=await l(c(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await I(r));let i=await r.json();if(!i.payload||!Array.isArray(i.payload.items))throw Error(`Invalid response`);return{items:i.payload.items}}async function tt(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(),r=await l(c(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await I(r));let i=await r.json();if(!i.payload?.items||!i.payload.meta)throw Error(`Invalid response`);return i.payload}async function nt(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;$e(r,t?.provider);let i=r.toString(),a=await l(c(`/api/skills/marketplace/packages/${n}${i?`?${i}`:``}`),{cache:`no-store`});if(!a.ok)throw Error(await I(a));let o=(await a.json()).payload;if(!o?.name||!o.skillDocPreview||typeof o.skillDocPreview.name!=`string`||typeof o.skillDocPreview.description!=`string`||typeof o.skillDocPreview.bodyMarkdown!=`string`||typeof o.skillDocPreview.disableModelInvocation!=`boolean`||!o.skillDocPreview.metadata||typeof o.skillDocPreview.metadata!=`object`||typeof o.skillDocPreview.metadata.name!=`string`||typeof o.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return o}async function rt(e){let t=await l(c(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:`workspace`,...e})});if(!t.ok)throw Error(await I(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function it(e){let t=await l(c(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await I(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 at(){let e=await l(c(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await I(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function ot(){let e=await l(c(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await I(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}async function st(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 ct(){let e=o(u(e=>e.language)).skills,t=!!s(e=>e.token),n=p(),[r,i]=C(),a=r.get(`mprov`)?.trim()||null,[c,l]=(0,W.useState)(!1),[f,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(!1),_=r.get(`q`)??``,y=r.get(`tab`),b=r.get(`source`),x=le.has(y)?y:`marketplace`,S=ue.has(b)?b:`all`,[w,T]=(0,W.useState)(_),[E]=F(w,250),D=E.trim(),O=w.trim().length>0,k=D.length>0,[A,j]=(0,W.useState)(null),[M,ee]=(0,W.useState)(x),[N,P]=(0,W.useState)(S),[I,te]=(0,W.useState)(``),[z,B]=(0,W.useState)(`all`),[ne,re]=(0,W.useState)(!1),[ie,ae]=(0,W.useState)(null),[V,oe]=(0,W.useState)(!1),[H,U]=(0,W.useState)(!1),[G,K]=(0,W.useState)(null),[q,ce]=(0,W.useState)(null),[J,Y]=(0,W.useState)({}),[pe,X]=(0,W.useState)(!1),[Z,me]=(0,W.useState)(`catalog`),[Q,he]=(0,W.useState)(``),[ge,_e]=(0,W.useState)(null),[ye,be]=(0,W.useState)(null),[xe,Ce]=(0,W.useState)(!1),[we,Te]=(0,W.useState)(null),[Ee,De]=(0,W.useState)(`downloads`),[Oe,ke]=(0,W.useState)(1),[Ae,je]=(0,W.useState)(null),[Me,Ne]=(0,W.useState)(null),[Pe,Fe]=(0,W.useState)(``),[$,Ie]=(0,W.useState)(()=>a),[Le,Re]=(0,W.useState)(0),[ze,Be]=(0,W.useState)(0),[Ve,He]=(0,W.useState)([]),Ue=(0,W.useRef)(null),We=(0,W.useRef)(a),Ge=(0,W.useRef)(null),Ke=(0,W.useRef)(``),qe=(0,W.useRef)(null),Je=(0,W.useRef)(!1),[Ye,$e]=(0,W.useState)({query:``,byProvider:{}}),[ct,lt]=(0,W.useState)(`all`),ut=(0,W.useRef)(0),dt=(0,W.useRef)(D);dt.current!==D&&(dt.current=D,lt(e=>e===`all`?e:`all`));let ft=v(()=>L().then(e=>(He(e.diagnostics??[]),e.catalog.map(Se))),[t,ze],{enabled:t,initial:[],errorData:[]}),{data:pt,loading:mt,setData:ht}=ft,gt=v(async()=>{try{let{providers:e,current:t}=await ot();return{providers:e.map(e=>({id:e.id,displayName:e.displayName})),current:t}}catch{try{return{providers:[],current:(await at()).provider}}catch{return{providers:[],current:`store`}}}},[t,Le],{enabled:t,initial:{providers:[],current:null}}),_t=c||mt,vt=gt.data.providers;(0,W.useEffect)(()=>{let e=e=>{if(d(e.detail)===`skills`){if(Je.current){Je.current=!1;return}Be(e=>e+1)}else Re(e=>e+1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[]);let yt=r.toString(),bt=(0,W.useRef)(yt);if(bt.current!==yt){bt.current=yt;let e=r.get(`q`)??``,t=r.get(`tab`),n=r.get(`source`),i=le.has(t)?t:`marketplace`,a=ue.has(n)?n:`all`;T(t=>t===e?t:e),ee(e=>e===i?e:i),P(e=>e===a?e:a);let o=r.get(`mcat`)??``;Fe(i===`marketplace`?e=>e===o?e:o:``)}let xt=(0,W.useRef)(t);!t&&xt.current&&(Ie(null),Ue.current=null),xt.current=t,t&&a&&We.current!==a&&(We.current=a,Ie(a)),t&&a==null&&gt.data.current&&gt.data.current!==Ge.current&&(Ge.current=gt.data.current,Ie(e=>e??gt.data.current));let St=`${D}|${Ee}|${M}|${Pe}|${$??``}|${ct}`;Ke.current!==St&&(Ke.current=St,ke(1)),M===`marketplace`&&$&&qe.current!=null&&qe.current!==$&&Fe(``),qe.current=$;let Ct=v(()=>tt({page:Oe,pageSize:20,sort:Ee,category:Pe.trim()||void 0,provider:$}),[t,M,Pe,Oe,Ee,k,$],{enabled:t&&M===`marketplace`&&!!$&&!k,initial:null,errorData:null});(0,W.useLayoutEffect)(()=>{!t||!O||ee(e=>e===`marketplace`?e:`marketplace`)},[t,O]),(0,W.useEffect)(()=>{if(!t||!k||M!==`marketplace`||vt.length===0)return;let n=++ut.current,r={};for(let e of vt)r[e.id]={status:`loading`,rows:[]};$e({query:D,byProvider:r});let i=[],a=[];for(let t of vt){let r=new AbortController;i.push(r);let o=window.setTimeout(()=>{r.abort(new DOMException(`Adapter timed out`,`TimeoutError`))},8e3);a.push(o),tt({provider:t.id,q:D,page:1,pageSize:40,sort:Ee,signal:r.signal}).then(e=>{if(window.clearTimeout(o),n!==ut.current)return;let r=e.items.map(e=>({...e,providerId:t.id}));$e(e=>({...e,byProvider:{...e.byProvider,[t.id]:{status:`ok`,rows:r}}}))}).catch(r=>{if(window.clearTimeout(o),n!==ut.current)return;let i=r instanceof DOMException&&(r.name===`TimeoutError`||r.name===`AbortError`)?e.marketplaceLoadFailed:r instanceof Error?r.message:e.marketplaceLoadFailed;$e(e=>({...e,byProvider:{...e.byProvider,[t.id]:{status:`error`,rows:[],error:i}}}))})}return()=>{for(let e of a)window.clearTimeout(e);for(let e of i)e.abort()}},[t,M,k,D,vt,Ee,e.marketplaceLoadFailed]);let wt=v(()=>et({provider:$}).then(e=>e.items),[t,M,$],{enabled:t&&M===`marketplace`&&!!$,initial:[],errorData:[]}),Tt=(0,W.useMemo)(()=>{if(!k||Ye.query!==D)return[];let e=vt.map(e=>({id:e.id,rows:[...Ye.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())},[k,D,Ye,vt]),Et=(0,W.useMemo)(()=>{if(!k)return{};let e={all:Tt.length};for(let t of vt)e[t.id]=Tt.filter(e=>e.providerId===t.id||(e.additionalSources??[]).some(e=>e.providerId===t.id)).length;return e},[k,Tt,vt]),Dt=(0,W.useMemo)(()=>k?ct===`all`?Tt:Tt.filter(e=>e.providerId===ct||(e.additionalSources??[]).some(e=>e.providerId===ct)):[],[k,Tt,ct]),Ot=(0,W.useMemo)(()=>{if(!k)return{};let e={};for(let t of vt)e[t.id]=Ye.byProvider[t.id]?.status??`loading`;return e},[k,Ye,vt]),kt=(0,W.useMemo)(()=>Object.values(Ot).some(e=>e===`loading`),[Ot]),At=(0,W.useMemo)(()=>{if(!k)return!1;let e=Object.values(Ot);return e.length>0&&e.every(e=>e===`error`)},[k,Ot]),jt=(0,W.useMemo)(()=>{if(!k||Tt.length===0&&kt)return null;let e=Dt.length,t=(Oe-1)*20;return{items:Dt.slice(t,t+20),meta:{page:Oe,pageSize:20,total:e,totalPages:Math.max(1,Math.ceil(e/20))},provider:ct}},[k,Tt,kt,Dt,Oe,ct]),Mt=M===`marketplace`?O?k?jt:null:Ct.data:null,Nt=M===`marketplace`?O?k?kt:!0:Ct.loading:!1,Pt=k?At?e.marketplaceLoadFailed:null:Ct.error instanceof Error?Ct.error.message:Ct.error?e.marketplaceLoadFailed:null,Ft=M===`marketplace`?wt.data:[],It=M===`marketplace`?wt.loading:!1,Lt=wt.error instanceof Error?wt.error.message:wt.error?e.marketplaceCategoriesFailed:null;Pe.trim()&&Ft.length>0&&!Ft.some(e=>e.id===Pe)&&Fe(``);let Rt=(0,W.useCallback)(async t=>{let n=t?.silent===!0;n||l(!0),m(null);try{let e=await L();return He(e.diagnostics??[]),ht(e.catalog.map(Se)),{ok:!0}}catch(t){let n=t instanceof Error?t.message:e.loadFailed;return m(n),{ok:!1,message:n}}finally{n||l(!1)}},[ht,e.loadFailed]),zt=!c&&ft.error?ft.error instanceof Error?ft.error.message:e.loadFailed:null,Bt=f??zt;(0,W.useEffect)(()=>{i(e=>{let t=new URLSearchParams(e);return D?t.set(`q`,D):t.delete(`q`),M===`marketplace`?t.delete(`tab`):t.set(`tab`,M),N===`all`?t.delete(`source`):t.set(`source`,N),M===`marketplace`&&Pe.trim()?t.set(`mcat`,Pe.trim()):t.delete(`mcat`),M===`marketplace`&&$?t.set(de,$):t.delete(de),t.toString()===e.toString()?e:t},{replace:!0})},[M,Pe,$,D,i,N]);let Vt=(0,W.useCallback)((e,t,n=5e3)=>{j({kind:e,message:t}),window.setTimeout(()=>j(null),n)},[]),Ht=(0,W.useCallback)(t=>{let n=t.availability;if(!n)return e.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.`},[e.installSuccess]),Ut=(0,W.useCallback)(async t=>{me(`catalog`),X(!0),he(t.name),_e(null),be(null),Te(null),Ce(!0);try{let e=await it(t.name);_e(e),he(e.name)}catch(t){_e(null),Te(t instanceof Error?t.message:e.detailLoadFailed)}finally{Ce(!1)}},[e.detailLoadFailed]),Wt=(0,W.useCallback)(async t=>{let n=t.trim();if(n){me(`catalog`),X(!0),he(n),_e(null),be(null),Te(null),Ce(!0);try{let e=await it(n);_e(e),he(e.name)}catch(t){_e(null),Te(t instanceof Error?t.message:e.detailLoadFailed)}finally{Ce(!1)}}},[e.detailLoadFailed]),Gt=(0,W.useCallback)(async(t,n,r)=>{let i=r?.trim()||$;if(i){Ue.current=i,me(`store`),X(!0),he(n?.trim()||t),_e(null),be(null),Te(null),Ce(!0);try{let e=await nt(t,{provider:i});he(e.name),be(e.skillDocPreview)}catch(t){be(null),Te(t instanceof Error?t.message:e.detailLoadFailed)}finally{Ce(!1)}}},[$,e.detailLoadFailed]),Kt=(0,W.useCallback)(async(t,n)=>{ce(t),Y(e=>({...e,[t]:n})),j(null);try{return await Qe(t,n),await Rt({silent:!0}),!0}catch(n){return Y(e=>{let{[t]:n,...r}=e;return r}),Vt(`error`,n instanceof Error?n.message:e.skillToggleFailed),!1}finally{ce(null),Y(e=>{let{[t]:n,...r}=e;return r})}},[Rt,Vt,e.skillToggleFailed]),qt=(0,W.useCallback)(async()=>{j(null),l(!0),m(null);try{await se()}catch(t){m(t instanceof Error?t.message:e.reloadFailed),l(!1);return}await Rt()},[Rt,e.reloadFailed]),Jt=(0,W.useMemo)(()=>{let e=w.trim().toLowerCase();return e?pt.filter(t=>[t.name,t.description,t.directoryId,t.path,t.source,t.hub?.source,t.hub?.ref].filter(Boolean).join(` `).toLowerCase().includes(e)):pt},[pt,w]),Yt=(0,W.useMemo)(()=>{let e=Jt.filter(e=>e.source===`builtin`);return{total:e.length,enabled:e.filter(e=>J[e.name]??e.enabled).length}},[Jt,J]),Xt=(0,W.useMemo)(()=>{let e=Jt.filter(e=>e.source!==`builtin`);return{total:e.length,enabled:e.filter(e=>J[e.name]??e.enabled).length}},[Jt,J]),Zt=(0,W.useMemo)(()=>Q?pt.find(e=>e.name===Q):void 0,[pt,Q]),Qt=Zt==null?!0:J[Q]??Zt.enabled,$t=Zt?.directoryId??null,en=Zt?.managed??!1,tn=(0,W.useMemo)(()=>Z!==`store`||!Q?null:ve(Ue.current??$,Q),[Z,Q,$]),nn=(0,W.useMemo)(()=>{let e=Jt;return M===`builtin`?e=e.filter(e=>e.source===`builtin`):M===`user`&&(e=e.filter(e=>e.source!==`builtin`),N!==`all`&&(e=e.filter(e=>e.source===N))),e},[Jt,M,N]),rn=(0,W.useMemo)(()=>{let e=new Set,t=[];for(let n of nn){let r=n.category;!r||e.has(r)||(e.add(r),t.push(r))}return t.sort((e,t)=>{let n=fe.indexOf(e),r=fe.indexOf(t);return n>=0&&r>=0?n-r:n>=0?-1:r>=0?1:e.localeCompare(t)})},[nn]),an=(0,W.useCallback)(t=>e.categoryLabel?.[t]||t,[e.categoryLabel]),on=(0,W.useMemo)(()=>I?nn.filter(e=>e.category===I):nn,[nn,I]);(0,W.useEffect)(()=>{B(`all`)},[M]);let sn=(0,W.useCallback)(e=>J[e.name]??e.enabled,[J]),cn=(0,W.useMemo)(()=>on.filter(e=>!sn(e)).length,[on,sn]),ln=(0,W.useMemo)(()=>{let e=on;return z===`disabled`&&(e=e.filter(e=>!sn(e))),[...e].toSorted((e,t)=>{let n=sn(e);return n===sn(t)?e.name.localeCompare(t.name,void 0,{sensitivity:`base`}):n?-1:1})},[on,z,sn]),un=async t=>{j(null),g(!0),m(null);try{let n;try{n=await st(t)}catch{m(e.invalidFile),Vt(`error`,e.invalidFile);return}let r=await Xe(n,{overwrite:!0});Je.current=!0,await Rt(),Vt(`success`,Ht(r)),re(!1),ae(null),ee(`user`),await Wt(r.availability?.skillName||r.skillId)}catch(t){m(t instanceof Error?t.message:e.uploadFailed),Vt(`error`,t instanceof Error?t.message:e.uploadFailed)}finally{g(!1)}},dn=()=>{ie&&un(ie)},fn=e=>{let t=e.target.files?.[0];e.target.value=``,t&&ae(t)},pn=e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.types.includes(`Files`)&&(oe(!0),e.dataTransfer.dropEffect=`copy`)},mn=e=>{let t=e.currentTarget,n=e.relatedTarget;n&&t.contains(n)||oe(!1)},hn=e=>{e.preventDefault(),e.stopPropagation(),oe(!1);let t=e.dataTransfer?.files?.[0];t&&ae(t)},gn=t=>{switch(t){case`builtin`:return e.source.builtin;case`workspace`:return e.source.workspace;case`global`:return e.source.global;case`extra`:return e.source.extra;default:return t}},_n=async()=>{let t=G,n=pe&&Z===`catalog`&&$t===t;if(U(!1),K(null),t){j(null);try{await Ze(t),Je.current=!0,await Rt(),n&&(X(!1),me(`catalog`),he(``),_e(null),be(null),Te(null))}catch(t){m(t instanceof Error?t.message:e.deleteFailed)}}},vn=(0,W.useCallback)(e=>pt.some(t=>t.name===e),[pt]),yn=(0,W.useCallback)(async t=>{let r=(t?.name??Q).trim();if(!r)return;let i=t?.source??Z;if(i===`catalog`){let e=pt.find(e=>e.name===r);if(e&&!(J[e.name]??e.enabled))return}j(null);let a=i===`store`&&!vn(r);Ne(r);try{if(a){let e=t?.providerOverride?.trim()||Ue.current||$;await rt({name:r,overwrite:!1,...e?{provider:e}:{}}),Je.current=!0,await Rt({silent:!0})}X(!1),n(`/chat/new?skill=${encodeURIComponent(r)}`)}catch(t){Vt(`error`,t instanceof Error?t.message:e.uploadFailed)}finally{Ne(null)}},[pt,Q,Z,J,vn,Rt,n,Vt,e.uploadFailed,$]),bn=(0,W.useCallback)(async(t,n)=>{let r=vn(t);if(!(r&&!window.confirm(e.marketplaceReinstallConfirm))){j(null),je(t);try{let e=n?.providerOverride?.trim()||(n?.useDetailProvider?Ue.current??$:$),i=await rt({name:t,overwrite:r,...e?{provider:e}:{}});Je.current=!0,await Rt({silent:!0}),Vt(`success`,Ht(i)),ee(`user`),await Wt(i.availability?.skillName||i.skillId||t)}catch(t){Vt(`error`,t instanceof Error?t.message:e.uploadFailed)}finally{je(null)}}},[vn,Ht,Rt,$,Wt,Vt,e.marketplaceReinstallConfirm,e.uploadFailed]),xn=N===`all`?e.filterAll:N===`global`?e.filterGlobal:N===`workspace`?e.filterWorkspace:e.filterExtra,{pathname:Sn}=R();return{sk:e,hasToken:t,catalog:pt,loading:_t,error:Bt,uploading:h,searchQuery:w,setSearchQuery:T,actionFeedback:A,skillDiagnostics:Ve,mainTab:M,setMainTab:ee,sourceFilter:N,setSourceFilter:P,builtinCategoryFilter:I,setBuiltinCategoryFilter:te,installOpen:ne,setInstallOpen:re,pendingFile:ie,setPendingFile:ae,dropActive:V,setDropActive:oe,confirmOpen:H,setConfirmOpen:U,confirmId:G,setConfirmId:K,togglingSkillName:q,enabledOverride:J,detailOpen:pe,setDetailOpen:X,detailSource:Z,setDetailSource:me,detailTitle:Q,setDetailTitle:he,detailCatalogPreview:ge,setDetailCatalogPreview:_e,detailMarketplacePreview:ye,setDetailMarketplacePreview:be,detailLoading:xe,detailError:we,setDetailError:Te,marketSort:Ee,setMarketSort:De,marketPage:Oe,setMarketPage:ke,mpLoading:Nt,mpError:Pt,mpPayload:Mt,searchActive:k,searchInputActive:O,resultTab:ct,setResultTab:lt,aggregatedTabCounts:Et,aggregatedProviderStatus:Ot,aggregatedAllFailed:At,installingMarketName:Ae,usingSkillInChatName:Me,onUseSkillInChat:yn,marketCategoryId:Pe,setMarketCategoryId:Fe,mpCategories:Ft,mpCategoriesError:Lt,mpCategoriesLoading:It,marketBrowseProvider:$,setMarketBrowseProvider:Ie,registeredProviders:vt,builtinTabStats:Yt,userTabStats:Xt,detailEnabled:Qt,detailDirectoryId:$t,detailManaged:en,detailExternalUrl:tn,filteredCatalog:nn,builtinCategories:rn,categoryFilteredCatalog:on,catalogDisplayRows:ln,catalogDisabledCount:cn,catalogStatusFilter:z,setCatalogStatusFilter:B,resolveSkillEnabled:sn,filterLabel:xn,inSettingsShell:Sn.startsWith(`/settings/`),categoryLabel:an,onReloadClick:qt,openSkillDetail:Ut,openMarketplaceDetail:Gt,onSkillToggle:Kt,onInstallSubmit:dn,onFileInputChange:fn,onModalDragOver:pn,onModalDragLeave:mn,onModalDrop:hn,sourceLabel:gn,runDelete:_n,onMarketInstall:bn,isSkillInstalledByName:vn}}function lt(){let e=(0,U.c)(2),t=ct(),n;return e[0]===t?n=e[1]:(n=(0,G.jsx)(Ue,{vm:t}),e[0]=t,e[1]=n),n}export{lt 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"./cn-BQ_8x0bT.js";import{t as i}from"./messages-B-8CqAeX.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Ac as o,Dt as s,Ja as c,Mr as l,Nr as u,_s as d,bo as f,rs as p}from"./index-ehajXmqL.js";import{n as m,t as h}from"./settings-page-layout-CEepfbCa.js";import{r as g,t as _}from"./settings-form-section-DGeEoBkb.js";var v=e(t(),1),y=n();async function b(){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 x(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 S(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function C(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 w(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 T=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function E(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||T.has(e)?t===`unknown`:!1}function D(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:T.has(e)?t===`denied`:!0}var O=[{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 k(e){return e===`linux`?O:O.filter(t=>!t.platforms||t.platforms.includes(e))}function A(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 j(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 M={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function N(){let e=a(e=>e.language),t=i(e).systemSettings,[n,T]=(0,v.useReducer)(s,M),{behavior:O,perms:N,loadError:P,permFeedback:F,permBusy:I,refreshing:L}=n,R=typeof window<`u`?window.electronAPI?.system:void 0,z=(0,v.useCallback)(async e=>{if(R){T({type:`patch`,patch:{loadError:null}});try{T({type:`patch`,patch:{behavior:await R.getBehavior(),perms:await R.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:t.refreshDone}:{}}})}catch(t){T({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[R,t.refreshDone]),B=(0,v.useCallback)(async()=>{if(!(L||I)){T({type:`patch`,patch:{refreshing:!0}});try{await z({showRefreshFeedback:!0})}finally{T({type:`patch`,patch:{refreshing:!1}})}}},[z,I,L]);if((0,v.useEffect)(()=>{let e=new Set([t.refreshDone,t.openSettingsDone,t.openSettingsFailed,t.desktopNotify.testShown]);if(!F||!e.has(F))return;let n=window.setTimeout(()=>{T({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(n)},[F,t.openSettingsDone,t.openSettingsFailed,t.refreshDone,t.desktopNotify.testShown]),(0,v.useEffect)(()=>{c()&&R&&z()},[R,z]),!c()||!R)return(0,y.jsxs)(h,{gap:`gap-3`,children:[(0,y.jsx)(m,{title:t.title}),(0,y.jsxs)(`div`,{className:g(),children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.desktopOnlyTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.desktopOnlyBody})]})]});let V=async e=>{try{let{behavior:t}=await R.setBehavior(e);T({type:`patch`,patch:{behavior:t}}),(e.notifyEnabled!==void 0||e.notifySoundEnabled!==void 0)&&l()}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},H=async e=>{if(!e){await V({notifyEnabled:!1});return}T({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await u(t.desktopNotify.testTitle,t.desktopNotify.testBody);if(e===`unsupported`){T({type:`patch`,patch:{permFeedback:t.notificationsFeedback.unsupported}});return}if(e===`denied`){T({type:`patch`,patch:{permFeedback:t.desktopNotify.denied}});return}if(e==="default"){T({type:`patch`,patch:{permFeedback:t.notificationsFeedback.default}});return}await V({notifyEnabled:!0}),T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:t.desktopNotify.testShown}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}},U=async e=>{T({type:`patch`,patch:{permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{(await R.openPrivacy(e)).ok?T({type:`patch`,patch:{permFeedback:t.openSettingsDone}}):T({type:`patch`,patch:{permFeedback:t.openSettingsFailed}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},W=async()=>{T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestMicrophone(),n=await b();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:x(e,n,t.permFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}},G=async()=>{if(R.requestAccessibility){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestAccessibility();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:S(e,t.accessibilityFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},K=async()=>{if(R.requestNotifications){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestNotifications();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:C(e,t.notificationsFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(R.requestScreen){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestScreen();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:w(e,t.screenFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},J=O?O.platform===`win32`?t.permissionsHintWin:O.platform===`linux`?t.permissionsHintLinux:O.platform===`darwin`?t.permissionsHintDarwin:t.permissionsHint:t.permissionsHint;return(0,y.jsxs)(h,{gap:`gap-6`,children:[(0,y.jsx)(m,{title:t.title}),P?(0,y.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:P}):null,F?(0,y.jsx)(`p`,{className:r(`text-sm`,F===t.refreshDone||F===t.openSettingsDone||F===t.permFeedback.granted||F===t.permFeedback.alreadyGranted||F===t.accessibilityFeedback.granted||F===t.accessibilityFeedback.alreadyGranted||F===t.notificationsFeedback.granted||F===t.notificationsFeedback.alreadyGranted||F===t.screenFeedback.granted||F===t.screenFeedback.alreadyGranted||F===t.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:F}):null,(0,y.jsxs)(_,{children:[(0,y.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,y.jsx)(p,{className:`size-4 text-accent`,strokeWidth:1.75}),t.behaviorGroup]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.openAtLogin}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.openAtLoginDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.openAtLogin,onChange:e=>{V({openAtLogin:e.target.checked})}})]}),(0,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.keepAwake}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.keepAwakeDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.keepAwakePreferred,onChange:e=>{V({keepAwakePreferred:e.target.checked})}})]}),(0,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifyDesktop}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifyDesktopDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O||I,checked:!!O?.notifyEnabled,onChange:e=>{H(e.target.checked)}})]}),(0,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifySound}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifySoundDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.notifySoundEnabled,onChange:e=>{V({notifySoundEnabled:e.target.checked})}})]})]})]}),O&&N?(0,y.jsxs)(`section`,{className:g(),children:[(0,y.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.permissionsTitle}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:J}),O.platform===`darwin`&&!O.packaged?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:t.permissionsHintDevDarwin}):null]}),(0,y.jsxs)(`button`,{type:`button`,disabled:L||I,"aria-busy":L,className:r(`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 B(),children:[(0,y.jsx)(d,{className:r(`size-3.5`,L&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),L?t.refreshing:t.refresh]})]}),(0,y.jsx)(`ul`,{className:`space-y-3`,children:k(O.platform).map(({key:n,pane:i})=>{let a=A(e,N[n]),s=t.perm[n],c=N[n]===`unknown`?j(e,n,O.platform):null;return s?(0,y.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,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s.title}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:s.desc}),(0,y.jsx)(`p`,{className:`mt-1 text-xs font-medium ${a.className}`,children:a.label}),c?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:c}):null]}),(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[n===`notifications`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`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:t.requestAccess}):null,n===`microphone`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`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 W(),children:t.requestAccess}):null,n===`accessibility`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`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:t.requestAccess}):null,n===`screen`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`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:t.requestAccess}):null,D(n,N[n],O.platform)?(0,y.jsxs)(`button`,{type:`button`,className:r(`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 U(i),children:[t.openSettings,(0,y.jsx)(o,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):null})})]}):null]})}export{N 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"./cn-BQ_8x0bT.js";import{t as i}from"./messages-BXNELNBa.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Co as o,Dt as s,Fr as c,Ir as l,Nc as u,Za as d,bs as f,os as p}from"./index-DcUaXYeb.js";import{n as m,t as h}from"./settings-page-layout-CKefvbYi.js";import{r as g,t as _}from"./settings-form-section-CvfzhBV-.js";var v=e(t(),1),y=n();async function b(){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 x(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 S(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function C(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 w(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 T=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function E(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||T.has(e)?t===`unknown`:!1}function D(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:T.has(e)?t===`denied`:!0}var O=[{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 k(e){return e===`linux`?O:O.filter(t=>!t.platforms||t.platforms.includes(e))}function A(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 j(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 M={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function N(){let e=a(e=>e.language),t=i(e).systemSettings,[n,T]=(0,v.useReducer)(s,M),{behavior:O,perms:N,loadError:P,permFeedback:F,permBusy:I,refreshing:L}=n,R=typeof window<`u`?window.electronAPI?.system:void 0,z=(0,v.useCallback)(async e=>{if(R){T({type:`patch`,patch:{loadError:null}});try{T({type:`patch`,patch:{behavior:await R.getBehavior(),perms:await R.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:t.refreshDone}:{}}})}catch(t){T({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[R,t.refreshDone]),B=(0,v.useCallback)(async()=>{if(!(L||I)){T({type:`patch`,patch:{refreshing:!0}});try{await z({showRefreshFeedback:!0})}finally{T({type:`patch`,patch:{refreshing:!1}})}}},[z,I,L]);if((0,v.useEffect)(()=>{let e=new Set([t.refreshDone,t.openSettingsDone,t.openSettingsFailed,t.desktopNotify.testShown]);if(!F||!e.has(F))return;let n=window.setTimeout(()=>{T({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(n)},[F,t.openSettingsDone,t.openSettingsFailed,t.refreshDone,t.desktopNotify.testShown]),(0,v.useEffect)(()=>{d()&&R&&z()},[R,z]),!d()||!R)return(0,y.jsxs)(h,{gap:`gap-3`,children:[(0,y.jsx)(m,{title:t.title}),(0,y.jsxs)(`div`,{className:g(),children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.desktopOnlyTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.desktopOnlyBody})]})]});let V=async e=>{try{let{behavior:t}=await R.setBehavior(e);T({type:`patch`,patch:{behavior:t}}),(e.notifyEnabled!==void 0||e.notifySoundEnabled!==void 0)&&c()}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},H=async e=>{if(!e){await V({notifyEnabled:!1});return}T({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await l(t.desktopNotify.testTitle,t.desktopNotify.testBody);if(e===`unsupported`){T({type:`patch`,patch:{permFeedback:t.notificationsFeedback.unsupported}});return}if(e===`denied`){T({type:`patch`,patch:{permFeedback:t.desktopNotify.denied}});return}if(e==="default"){T({type:`patch`,patch:{permFeedback:t.notificationsFeedback.default}});return}await V({notifyEnabled:!0}),T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:t.desktopNotify.testShown}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}},U=async e=>{T({type:`patch`,patch:{permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{(await R.openPrivacy(e)).ok?T({type:`patch`,patch:{permFeedback:t.openSettingsDone}}):T({type:`patch`,patch:{permFeedback:t.openSettingsFailed}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},W=async()=>{T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestMicrophone(),n=await b();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:x(e,n,t.permFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}},G=async()=>{if(R.requestAccessibility){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestAccessibility();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:S(e,t.accessibilityFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},K=async()=>{if(R.requestNotifications){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestNotifications();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:C(e,t.notificationsFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(R.requestScreen){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestScreen();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:w(e,t.screenFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},J=O?O.platform===`win32`?t.permissionsHintWin:O.platform===`linux`?t.permissionsHintLinux:O.platform===`darwin`?t.permissionsHintDarwin:t.permissionsHint:t.permissionsHint;return(0,y.jsxs)(h,{gap:`gap-6`,children:[(0,y.jsx)(m,{title:t.title}),P?(0,y.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:P}):null,F?(0,y.jsx)(`p`,{className:r(`text-sm`,F===t.refreshDone||F===t.openSettingsDone||F===t.permFeedback.granted||F===t.permFeedback.alreadyGranted||F===t.accessibilityFeedback.granted||F===t.accessibilityFeedback.alreadyGranted||F===t.notificationsFeedback.granted||F===t.notificationsFeedback.alreadyGranted||F===t.screenFeedback.granted||F===t.screenFeedback.alreadyGranted||F===t.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:F}):null,(0,y.jsxs)(_,{children:[(0,y.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,y.jsx)(p,{className:`size-4 text-accent`,strokeWidth:1.75}),t.behaviorGroup]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.openAtLogin}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.openAtLoginDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.openAtLogin,onChange:e=>{V({openAtLogin:e.target.checked})}})]}),(0,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.keepAwake}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.keepAwakeDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.keepAwakePreferred,onChange:e=>{V({keepAwakePreferred:e.target.checked})}})]}),(0,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifyDesktop}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifyDesktopDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O||I,checked:!!O?.notifyEnabled,onChange:e=>{H(e.target.checked)}})]}),(0,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifySound}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifySoundDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.notifySoundEnabled,onChange:e=>{V({notifySoundEnabled:e.target.checked})}})]})]})]}),O&&N?(0,y.jsxs)(`section`,{className:g(),children:[(0,y.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.permissionsTitle}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:J}),O.platform===`darwin`&&!O.packaged?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:t.permissionsHintDevDarwin}):null]}),(0,y.jsxs)(`button`,{type:`button`,disabled:L||I,"aria-busy":L,className:r(`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`,o.press),onClick:()=>void B(),children:[(0,y.jsx)(f,{className:r(`size-3.5`,L&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),L?t.refreshing:t.refresh]})]}),(0,y.jsx)(`ul`,{className:`space-y-3`,children:k(O.platform).map(({key:n,pane:i})=>{let a=A(e,N[n]),s=t.perm[n],c=N[n]===`unknown`?j(e,n,O.platform):null;return s?(0,y.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,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s.title}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:s.desc}),(0,y.jsx)(`p`,{className:`mt-1 text-xs font-medium ${a.className}`,children:a.label}),c?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:c}):null]}),(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[n===`notifications`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`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`,o.press),onClick:()=>void K(),children:t.requestAccess}):null,n===`microphone`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`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`,o.press),onClick:()=>void W(),children:t.requestAccess}):null,n===`accessibility`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`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`,o.press),onClick:()=>void G(),children:t.requestAccess}):null,n===`screen`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`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`,o.press),onClick:()=>void q(),children:t.requestAccess}):null,D(n,N[n],O.platform)?(0,y.jsxs)(`button`,{type:`button`,className:r(`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`,o.press),onClick:()=>void U(i),children:[t.openSettings,(0,y.jsx)(u,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):null})})]}):null]})}export{N as SystemSettingsPanel};
@@ -1 +1 @@
1
- import{t as e}from"./cn-BQ_8x0bT.js";import{Co as t,To as n,wo as r}from"./index-ehajXmqL.js";function i(){return e(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,n,`dark:border-edge`)}function a(){return e(r,t)}var o=`h-auto shrink-0 px-2.5 py-1.5 text-xs font-medium`,s=/^[a-z][a-z0-9_-]{0,63}$/;function c(e){let t=e.trim(),n=t.indexOf(`/`);return n>0&&n<t.length-1}function l(e){let t=e&&typeof e==`object`&&!Array.isArray(e)&&`roles`in e?Object.entries(e.roles??{}).map(([e,t])=>({id:e,...t&&typeof t==`object`&&!Array.isArray(t)?t:{}})):e;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e,r=typeof t.id==`string`?t.id.trim():``,i=typeof t.model==`string`?t.model.trim():``;if(!r||!i)continue;let a=typeof t.description==`string`?t.description.trim():``,o=Array.isArray(t.fallbacks)?t.fallbacks.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean):[];n.push({id:r,model:i,fallbacks:o,description:a})}return n}function u(e,t){let n=new Set([t.toLowerCase()]),r=[];for(let t of e){let e=t.trim(),i=e.toLowerCase();!e||!c(e)||n.has(i)||(n.add(i),r.push(e))}return r}function d(e){let t=new Map;for(let n of e){let e=n.id.trim(),r=n.model.trim();if(!e||!s.test(e)||!r||!c(r))continue;let i=n.description.trim(),a=u(n.fallbacks??[],r);t.set(e,{model:r,...a.length>0?{fallbacks:a}:{},...i?{description:i}:{}})}return t.size===0?null:{roles:Object.fromEntries(t.entries())}}function f(e,t){let n=new Set;for(let r of e){let e=r.id.trim(),i=r.model.trim(),a=r.fallbacks??[];if(!(!e&&!i&&!r.description.trim()&&a.every(e=>!e.trim()))){if(!e||!s.test(e))return t.invalidId;if(n.has(e))return t.duplicateId;if(n.add(e),!i||!c(i)||a.some(e=>e.trim()&&!c(e)))return t.invalidModel}}return null}function p(e){return e.length===0?`—`:e.map(e=>`${e.id} -> ${e.model}${e.fallbacks?.length?` (+${e.fallbacks.length})`:``}`).join(`, `)}function m(e){return(e??[]).map(e=>({id:e.id,model:e.model,fallbacks:e.fallbacks??[],description:e.description?.trim()??``}))}export{f as a,a as c,m as i,p as n,o,l as r,i as s,d as t};
1
+ import{t as e}from"./cn-BQ_8x0bT.js";import{Do as t,Eo as n,Oo as r}from"./index-DcUaXYeb.js";function i(){return e(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,r,`dark:border-edge`)}function a(){return e(t,n)}var o=`h-auto shrink-0 px-2.5 py-1.5 text-xs font-medium`,s=/^[a-z][a-z0-9_-]{0,63}$/;function c(e){let t=e.trim(),n=t.indexOf(`/`);return n>0&&n<t.length-1}function l(e){let t=e&&typeof e==`object`&&!Array.isArray(e)&&`roles`in e?Object.entries(e.roles??{}).map(([e,t])=>({id:e,...t&&typeof t==`object`&&!Array.isArray(t)?t:{}})):e;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e,r=typeof t.id==`string`?t.id.trim():``,i=typeof t.model==`string`?t.model.trim():``;if(!r||!i)continue;let a=typeof t.description==`string`?t.description.trim():``,o=Array.isArray(t.fallbacks)?t.fallbacks.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean):[];n.push({id:r,model:i,fallbacks:o,description:a})}return n}function u(e,t){let n=new Set([t.toLowerCase()]),r=[];for(let t of e){let e=t.trim(),i=e.toLowerCase();!e||!c(e)||n.has(i)||(n.add(i),r.push(e))}return r}function d(e){let t=new Map;for(let n of e){let e=n.id.trim(),r=n.model.trim();if(!e||!s.test(e)||!r||!c(r))continue;let i=n.description.trim(),a=u(n.fallbacks??[],r);t.set(e,{model:r,...a.length>0?{fallbacks:a}:{},...i?{description:i}:{}})}return t.size===0?null:{roles:Object.fromEntries(t.entries())}}function f(e,t){let n=new Set;for(let r of e){let e=r.id.trim(),i=r.model.trim(),a=r.fallbacks??[];if(!(!e&&!i&&!r.description.trim()&&a.every(e=>!e.trim()))){if(!e||!s.test(e))return t.invalidId;if(n.has(e))return t.duplicateId;if(n.add(e),!i||!c(i)||a.some(e=>e.trim()&&!c(e)))return t.invalidModel}}return null}function p(e){return e.length===0?`—`:e.map(e=>`${e.id} -> ${e.model}${e.fallbacks?.length?` (+${e.fallbacks.length})`:``}`).join(`, `)}function m(e){return(e??[]).map(e=>({id:e.id,model:e.model,fallbacks:e.fallbacks??[],description:e.description?.trim()??``}))}export{f as a,a as c,m as i,p as n,o,l as r,i as s,d as t};
@@ -1 +1 @@
1
- import{n as e}from"./vendor-react-BOUWij0V.js";import{n as t,o as n}from"./fetch-06q5eCMA.js";import{i as r}from"./vendor-swr-BIWyz7Rc.js";var i=e();function a(e){return n(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function o(e){return(await t(a(e))).payload?.channels??[]}function s(e,t){let n=(0,i.c)(14),s;n[0]!==e||n[1]!==t?(s=e?a(t):null,n[0]=e,n[1]=t,n[2]=s):s=n[2];let c;n[3]===t?c=n[4]:(c=()=>o(t),n[3]=t,n[4]=c);let l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},n[5]=l):l=n[5];let{data:u,error:d,isLoading:f,isValidating:p,mutate:m}=r(s,c,l),h;n[6]===u?h=n[7]:(h=u??[],n[6]=u,n[7]=h);let g;return n[8]!==d||n[9]!==f||n[10]!==p||n[11]!==m||n[12]!==h?(g={entries:h,isLoading:f,isValidating:p,error:d,mutate:m},n[8]=d,n[9]=f,n[10]=p,n[11]=m,n[12]=h,n[13]=g):g=n[13],g}export{s as t};
1
+ import{n as e}from"./vendor-react-BOUWij0V.js";import{n as t,o as n}from"./fetch-B1WtuprY.js";import{i as r}from"./vendor-swr-BIWyz7Rc.js";var i=e();function a(e){return n(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function o(e){return(await t(a(e))).payload?.channels??[]}function s(e,t){let n=(0,i.c)(14),s;n[0]!==e||n[1]!==t?(s=e?a(t):null,n[0]=e,n[1]=t,n[2]=s):s=n[2];let c;n[3]===t?c=n[4]:(c=()=>o(t),n[3]=t,n[4]=c);let l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},n[5]=l):l=n[5];let{data:u,error:d,isLoading:f,isValidating:p,mutate:m}=r(s,c,l),h;n[6]===u?h=n[7]:(h=u??[],n[6]=u,n[7]=h);let g;return n[8]!==d||n[9]!==f||n[10]!==p||n[11]!==m||n[12]!==h?(g={entries:h,isLoading:f,isValidating:p,error:d,mutate:m},n[8]=d,n[9]=f,n[10]=p,n[11]=m,n[12]=h,n[13]=g):g=n[13],g}export{s as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B-8CqAeX.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{Bt as s,Eo as c,Ht as l,It as u,Jc as d,Lt as f,Pt as p,_a as m,bo as h,ir as g,lr as _,ps as v,ro as y,sc as b,to as x}from"./index-ehajXmqL.js";import{n as S,t as C}from"./settings-page-layout-CEepfbCa.js";import{n as w,t as T}from"./settings-form-section-DGeEoBkb.js";import{t as E}from"./utils-ZxrKHxyb.js";var D=n(),O=e(t(),1),k=r(),A={callName:``,pronouns:``,timezone:``,notes:``};function j(e){if(e.timezone)return e;let t=f();return t?{...e,timezone:t}:e}function M(){let e=(0,D.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,k.jsxs)(`div`,{className:`grid gap-2`,children:[(0,k.jsx)(m,{className:`h-4 w-24`}),(0,k.jsx)(m,{className:`h-10 rounded-lg`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,k.jsxs)(`div`,{className:`grid gap-2`,children:[(0,k.jsx)(m,{className:`h-4 w-24`}),(0,k.jsx)(m,{className:`h-10 rounded-lg`})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,k.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"aria-hidden":`true`,children:[t,n,(0,k.jsxs)(`div`,{className:`grid gap-2 sm:col-span-2`,children:[(0,k.jsx)(m,{className:`h-4 w-28`}),(0,k.jsx)(m,{className:`h-28 rounded-lg`})]})]}),e[2]=r):r=e[2],r}function N(){let e=o(e=>e.language),t=a(e).userProfileSettings,n=E(),[r,m]=(0,O.useState)(A),[D,N]=(0,O.useState)(JSON.stringify(A)),[P,F]=(0,O.useState)(``),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(!1),[B,V]=(0,O.useState)(!0),[H,U]=(0,O.useState)(!1),[W,G]=(0,O.useState)(!1),[K,q]=(0,O.useState)(null);(0,O.useEffect)(()=>{let e=!1;return V(!0),q(null),g().then(t=>{if(e)return;let n=j(s(t)),r=u.some(e=>e.value===n.timezone),i=!n.pronouns||p.some(e=>e.value===n.pronouns);m(n),N(JSON.stringify(n)),L(!!(n.timezone&&!r)),F(n.timezone&&!r?n.timezone:``),z(!!(n.pronouns&&!i))}).catch(n=>{e||q(n instanceof Error?n.message:t.loadError)}).finally(()=>{e||V(!1)}),()=>{e=!0}},[t.loadError]);let J=JSON.stringify(r)!==D,Y=(0,O.useCallback)((t,n)=>e===`zh`?n:t,[e]),X=(0,O.useCallback)(e=>{m(t=>({...t,...e})),G(!1)},[]),Z=(0,O.useMemo)(()=>I?`__custom__`:u.some(e=>e.value===r.timezone)?r.timezone:`__custom__`,[I,r.timezone]),Q=(0,O.useCallback)(e=>{if(e===`__custom__`){L(!0);return}L(!1),F(``),X({timezone:e})},[X]),$=(0,O.useCallback)(()=>{let e=f();if(!e)return;let t=u.some(t=>t.value===e);L(!t),F(t?``:e),X({timezone:e})},[X]);async function ee(){U(!0),q(null);try{await _(l(r)),N(JSON.stringify(r)),G(!0)}catch(e){q(e instanceof Error?e.message:t.saveError)}finally{U(!1)}}return(0,k.jsxs)(C,{gap:`gap-6`,children:[(0,k.jsx)(S,{title:t.title,subtitle:t.subtitle,actions:(0,k.jsxs)(c,{type:`button`,variant:`primary`,disabled:B||H||!J,onClick:()=>void ee(),children:[(0,k.jsx)(v,{className:`size-4`,"aria-hidden":!0}),H?t.saving:W?t.saved:t.save]})}),(0,k.jsxs)(T,{children:[(0,k.jsx)(w,{icon:d,title:t.sectionTitle,subtitle:t.sectionSubtitle}),B?(0,k.jsx)(M,{}):(0,k.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:t.callName}),(0,k.jsx)(`input`,{className:n,value:r.callName,onChange:e=>X({callName:e.target.value}),placeholder:t.callNamePlaceholder,autoComplete:`off`})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:t.pronouns}),(0,k.jsxs)(x,{className:n,value:p.some(e=>e.value===r.pronouns)?r.pronouns:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){z(!0);return}z(!1),X({pronouns:e.target.value})},children:[(0,k.jsx)(y,{value:``,disabled:!0,children:t.pronounsPlaceholder}),p.map(e=>(0,k.jsx)(y,{value:e.value,children:Y(e.labelEn,e.labelZh)},e.value)),(0,k.jsx)(y,{value:`__custom__`,children:t.custom})]}),R?(0,k.jsx)(`input`,{className:i(n,`mt-1 text-xs`),value:p.some(e=>e.value===r.pronouns)?``:r.pronouns,onChange:e=>X({pronouns:e.target.value}),placeholder:t.pronounsPlaceholder,autoComplete:`off`}):null]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:t.timezone}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,k.jsxs)(x,{className:i(n,`min-w-0 flex-1`),value:Z,onChange:e=>Q(e.target.value),children:[u.map(e=>(0,k.jsx)(y,{value:e.value,children:Y(e.labelEn,e.labelZh)},e.value)),(0,k.jsx)(y,{value:`__custom__`,children:t.timezoneCustom})]}),(0,k.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,h.press),onClick:$,children:t.timezoneDetect})]}),I?(0,k.jsx)(`input`,{className:i(n,`mt-1 font-mono text-xs`),value:P,onChange:e=>{F(e.target.value),X({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null]}),(0,k.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:t.notes}),(0,k.jsx)(`textarea`,{className:i(n,`min-h-28 resize-y text-sm leading-relaxed`),value:r.notes,onChange:e=>X({notes:e.target.value}),placeholder:t.notesPlaceholder,rows:5,spellCheck:!0})]})]}),(0,k.jsxs)(`div`,{className:`mt-4 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,k.jsx)(b,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,k.jsx)(`span`,{children:t.note})]}),K?(0,k.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:K}):null]})]})}export{N as UserProfileSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-BXNELNBa.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{Co as s,Gt as c,Ht as l,Vt as u,Zc as d,ba as f,fr as p,gs as m,io as h,ko as g,oo as _,qt as v,sr as y,uc as b,zt as x}from"./index-DcUaXYeb.js";import{n as S,t as C}from"./settings-page-layout-CKefvbYi.js";import{n as w,t as T}from"./settings-form-section-CvfzhBV-.js";import{t as E}from"./utils-BKUWB-TT.js";var D=n(),O=e(t(),1),k=r(),A={callName:``,pronouns:``,timezone:``,notes:``};function j(e){if(e.timezone)return e;let t=l();return t?{...e,timezone:t}:e}function M(){let e=(0,D.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,k.jsxs)(`div`,{className:`grid gap-2`,children:[(0,k.jsx)(f,{className:`h-4 w-24`}),(0,k.jsx)(f,{className:`h-10 rounded-lg`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,k.jsxs)(`div`,{className:`grid gap-2`,children:[(0,k.jsx)(f,{className:`h-4 w-24`}),(0,k.jsx)(f,{className:`h-10 rounded-lg`})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,k.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"aria-hidden":`true`,children:[t,n,(0,k.jsxs)(`div`,{className:`grid gap-2 sm:col-span-2`,children:[(0,k.jsx)(f,{className:`h-4 w-28`}),(0,k.jsx)(f,{className:`h-28 rounded-lg`})]})]}),e[2]=r):r=e[2],r}function N(){let e=o(e=>e.language),t=a(e).userProfileSettings,n=E(),[r,f]=(0,O.useState)(A),[D,N]=(0,O.useState)(JSON.stringify(A)),[P,F]=(0,O.useState)(``),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(!1),[B,V]=(0,O.useState)(!0),[H,U]=(0,O.useState)(!1),[W,G]=(0,O.useState)(!1),[K,q]=(0,O.useState)(null);(0,O.useEffect)(()=>{let e=!1;return V(!0),q(null),y().then(t=>{if(e)return;let n=j(c(t)),r=u.some(e=>e.value===n.timezone),i=!n.pronouns||x.some(e=>e.value===n.pronouns);f(n),N(JSON.stringify(n)),L(!!(n.timezone&&!r)),F(n.timezone&&!r?n.timezone:``),z(!!(n.pronouns&&!i))}).catch(n=>{e||q(n instanceof Error?n.message:t.loadError)}).finally(()=>{e||V(!1)}),()=>{e=!0}},[t.loadError]);let J=JSON.stringify(r)!==D,Y=(0,O.useCallback)((t,n)=>e===`zh`?n:t,[e]),X=(0,O.useCallback)(e=>{f(t=>({...t,...e})),G(!1)},[]),Z=(0,O.useMemo)(()=>I?`__custom__`:u.some(e=>e.value===r.timezone)?r.timezone:`__custom__`,[I,r.timezone]),Q=(0,O.useCallback)(e=>{if(e===`__custom__`){L(!0);return}L(!1),F(``),X({timezone:e})},[X]),$=(0,O.useCallback)(()=>{let e=l();if(!e)return;let t=u.some(t=>t.value===e);L(!t),F(t?``:e),X({timezone:e})},[X]);async function ee(){U(!0),q(null);try{await p(v(r)),N(JSON.stringify(r)),G(!0)}catch(e){q(e instanceof Error?e.message:t.saveError)}finally{U(!1)}}return(0,k.jsxs)(C,{gap:`gap-6`,children:[(0,k.jsx)(S,{title:t.title,subtitle:t.subtitle,actions:(0,k.jsxs)(g,{type:`button`,variant:`primary`,disabled:B||H||!J,onClick:()=>void ee(),children:[(0,k.jsx)(m,{className:`size-4`,"aria-hidden":!0}),H?t.saving:W?t.saved:t.save]})}),(0,k.jsxs)(T,{children:[(0,k.jsx)(w,{icon:d,title:t.sectionTitle,subtitle:t.sectionSubtitle}),B?(0,k.jsx)(M,{}):(0,k.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:t.callName}),(0,k.jsx)(`input`,{className:n,value:r.callName,onChange:e=>X({callName:e.target.value}),placeholder:t.callNamePlaceholder,autoComplete:`off`})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:t.pronouns}),(0,k.jsxs)(h,{className:n,value:x.some(e=>e.value===r.pronouns)?r.pronouns:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){z(!0);return}z(!1),X({pronouns:e.target.value})},children:[(0,k.jsx)(_,{value:``,disabled:!0,children:t.pronounsPlaceholder}),x.map(e=>(0,k.jsx)(_,{value:e.value,children:Y(e.labelEn,e.labelZh)},e.value)),(0,k.jsx)(_,{value:`__custom__`,children:t.custom})]}),R?(0,k.jsx)(`input`,{className:i(n,`mt-1 text-xs`),value:x.some(e=>e.value===r.pronouns)?``:r.pronouns,onChange:e=>X({pronouns:e.target.value}),placeholder:t.pronounsPlaceholder,autoComplete:`off`}):null]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:t.timezone}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,k.jsxs)(h,{className:i(n,`min-w-0 flex-1`),value:Z,onChange:e=>Q(e.target.value),children:[u.map(e=>(0,k.jsx)(_,{value:e.value,children:Y(e.labelEn,e.labelZh)},e.value)),(0,k.jsx)(_,{value:`__custom__`,children:t.timezoneCustom})]}),(0,k.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,s.press),onClick:$,children:t.timezoneDetect})]}),I?(0,k.jsx)(`input`,{className:i(n,`mt-1 font-mono text-xs`),value:P,onChange:e=>{F(e.target.value),X({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null]}),(0,k.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:t.notes}),(0,k.jsx)(`textarea`,{className:i(n,`min-h-28 resize-y text-sm leading-relaxed`),value:r.notes,onChange:e=>X({notes:e.target.value}),placeholder:t.notesPlaceholder,rows:5,spellCheck:!0})]})]}),(0,k.jsxs)(`div`,{className:`mt-4 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,k.jsx)(b,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,k.jsx)(`span`,{children:t.note})]}),K?(0,k.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:K}):null]})]})}export{N as UserProfileSettingsPanel};
@@ -1 +1 @@
1
- import{t as e}from"./cn-BQ_8x0bT.js";import{To as t}from"./index-ehajXmqL.js";function n(){return e(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,t,`dark:border-edge`)}function r(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function i(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}export{i as n,r,n as t};
1
+ import{t as e}from"./cn-BQ_8x0bT.js";import{Oo as t}from"./index-DcUaXYeb.js";function n(){return e(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,t,`dark:border-edge`)}function r(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function i(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}export{i as n,r,n as t};
@@ -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{t as i}from"./cn-BQ_8x0bT.js";import{a,n as o,o as s}from"./fetch-B1WtuprY.js";import{o as c}from"./vendor-swr-BIWyz7Rc.js";import{Dl as l,Ft as u,Nc as d,Oo as f,Pt as p,Ys as m,dn as h,gs as g,io as _,ko as v,oo as y,sl as b,va as x,vo as S,ya as C}from"./index-DcUaXYeb.js";var w=`/api/image/providers`;async function ee(){return(await o(s(`/api/image/providers`)))?.payload?.providers??[]}var T=e(t(),1),te=n();function E(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function ne(e){return e?.apiKey?`••••••••••••`:``}function D(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:ne(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function O(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function k(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(h(n)&&h(r)))return n||(r?null:void 0)}function re(e,t,n){let r={};for(let i of e){let e=t[i]??E(),a=n[i]??E();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=k(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=O(e,a,`region`);c!==void 0&&(o.region=c);let l=O(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=O(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function A(e){let t=await o(s(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function ie(e){Object.keys(e).length!==0&&(await o(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await x())}var j=r();function ae(e){let t=(0,te.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>A(n).then(M),t[0]=n,t[1]=c);let l=c,f=`img-cred-key-${n}`,p;t[2]!==a.apiKeyLabel||t[3]!==f?(p=(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:f,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=f,t[4]=p):p=t[4];let m;t[5]!==s||t[6]!==o?(m=o.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,j.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u(e.kind,s),(0,j.jsx)(d,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=m):m=t[7];let h=`img-cred-key-${n}`,g;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==h||t[12]!==r?(g=(0,j.jsx)(S,{id:h,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=h,t[12]=r,t[13]=g):g=t[13];let _;return t[14]!==p||t[15]!==m||t[16]!==g?(_=(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[p,m,g]}),t[14]=p,t[15]=m,t[16]=g,t[17]=_):_=t[17],_}function M(e){return e.apiKey??null}function N(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,f)}function oe(){return i(N(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var P=`__custom__`;function se(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:P}function ce(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:P}function le(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function ue(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function de(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function fe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function pe(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function F(e){let t=(0,te.c)(76),{summaries:n,credDraft:r,credBaseline:a,credDirty:o,credSaving:s,credError:c,credSavedFlash:u,credNoopFlash:f,updateCredRow:h,onDiscardCredentials:x,onSaveCredentials:S,extensionIds:C,showExtensionLinks:w,showImageModelsLink:ee,hideActions:ne,language:D,apiKeyLinkLabels:O,messages:k}=e,re=ne===void 0?!1:ne,A;t[0]===n?A=t[1]:(A=n.some(ve),t[0]=n,t[1]=A);let ie=A,M;t[2]===n?M=t[3]:(M=n.some(_e),t[2]=n,t[3]=M);let F=M,[I,ye]=(0,T.useState)(ge),[be,L]=(0,T.useState)(he),R;if(t[4]!==a||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)fe(r[e.id]??E(),a[e.id]??E())&&R.add(e.id);t[4]=a,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==be||t[10]!==I?(B=e=>be.has(e)?!1:I.has(e)?!0:z.has(e),t[8]=z,t[9]=be,t[10]=I,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),ye(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),ye(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===k.credentialsIntro?W=t[15]:(W=(0,j.jsx)(`p`,{children:k.credentialsIntro}),t[14]=k.credentialsIntro,t[15]=W);let G;t[16]!==ie||t[17]!==k.regionHint?(G=ie?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.regionHint}):null,t[16]=ie,t[17]=k.regionHint,t[18]=G):G=t[18];let K;t[19]!==F||t[20]!==k.endpointPresetsHint?(K=F?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.endpointPresetsHint}):null,t[19]=F,t[20]=k.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==ee||t[23]!==k.imageModelsLinkTitle||t[24]!==k.openImageModelsPage?(q=ee?(0,j.jsx)(`p`,{children:(0,j.jsx)(l,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:k.imageModelsLinkTitle,children:k.openImageModelsPage})}):null,t[22]=ee,t[23]=k.imageModelsLinkTitle,t[24]=k.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,j.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===c?Y=t[32]:(Y=c?(0,j.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:c}):null,t[31]=c,t[32]=Y);let X;t[33]!==o||t[34]!==f||t[35]!==u||t[36]!==s||t[37]!==re||t[38]!==x||t[39]!==S||t[40]!==k.credentialsNothingToSave||t[41]!==k.credentialsSaved||t[42]!==k.discardCredentials||t[43]!==k.saveCredentials||t[44]!==k.savingCredentials?(X=re?null:(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[u?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsSaved}):null,f?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsNothingToSave}):null,(0,j.jsx)(v,{type:`button`,variant:`secondary`,onClick:x,disabled:!o||s,children:k.discardCredentials}),(0,j.jsx)(v,{type:`button`,variant:`primary`,onClick:S,disabled:!o||s,children:s?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(m,{className:`size-3.5 animate-spin`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.savingCredentials})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(g,{className:`size-3.5`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.saveCredentials})]})})]}),t[33]=o,t[34]=f,t[35]=u,t[36]=s,t[37]=re,t[38]=x,t[39]=S,t[40]=k.credentialsNothingToSave,t[41]=k.credentialsSaved,t[42]=k.discardCredentials,t[43]=k.saveCredentials,t[44]=k.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==O||t[47]!==a||t[48]!==r||t[49]!==C||t[50]!==V||t[51]!==D||t[52]!==w||t[53]!==n||t[54]!==k||t[55]!==U||t[56]!==h){let e;t[58]!==O||t[59]!==a||t[60]!==r||t[61]!==C||t[62]!==V||t[63]!==D||t[64]!==w||t[65]!==k||t[66]!==U||t[67]!==h?(e=e=>{let t=r[e.id]??E(),n=e.ui,o=w&&C.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,s=fe(t,a[e.id]??E()),c=V(e.id),u=e.label??e.id,f=pe(k,e.models.length);return(0,j.jsxs)(`section`,{className:i(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,s&&`ring-1 ring-accent/50`),children:[(0,j.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":c,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:u}),(0,j.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),s?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.unsavedChanges}):null,e.configured?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.configured}):(0,j.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:k.missingKey})]}),(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,j.jsx)(`span`,{children:f}),e.defaultModel?(0,j.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,j.jsx)(b,{className:i(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,c?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`sr-only`,children:c?k.collapseProvider:k.expandProvider})]}),c?(0,j.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 px-4 py-4`,children:[o?(0,j.jsxs)(l,{to:o,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:k.extensionSettingsLinkTitle,children:[(0,j.jsx)(d,{className:`size-3`}),k.openExtensionSettings]}):null,e.models.length>0?(0,j.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,j.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,j.jsx)(ae,{providerId:e.id,value:t.apiKey,onChange:t=>h(e.id,{apiKey:t}),apiKeyLinks:p(e.id,D),apiKeyLinkLabels:O,labels:{apiKeyLabel:k.apiKeyLabel,optionalPlaceholder:k.optionalPlaceholder,maskedHelp:k.apiKeyMaskedHelp,copy:k.apiKeyCopy,copied:k.apiKeyCopied,show:k.apiKeyShow,hide:k.apiKeyHide,notInConfigFile:k.apiKeyNotInConfigFile,loadFailed:k.apiKeyRevealFailed}}),n?.regions?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:k.regionLabel}),(0,j.jsxs)(_,{id:`img-cred-region-preset-${e.id}`,className:oe(),value:se(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){h(e.id,{region:``,imageBaseUrl:``});return}if(r===P){h(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&h(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,j.jsx)(y,{value:``,children:k.regionPresetDefault}),n.regions.map(e=>(0,j.jsx)(y,{value:e.value,children:le(k,e.value,e.label)},e.value)),(0,j.jsx)(y,{value:P,children:k.regionPresetCustom})]}),se(t,n.regions)===P?(0,j.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,j.jsx)(`input`,{type:`text`,className:N(),value:t.region,placeholder:`region`,onChange:t=>h(e.id,{region:t.target.value})}),(0,j.jsx)(`input`,{type:`url`,className:N(),value:t.imageBaseUrl,placeholder:k.imageBaseUrlLabel,onChange:t=>h(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:ue(k,n.baseUrlPresetKind)}),de(k,n.baseUrlPresetKind)?(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:de(k,n.baseUrlPresetKind)}):null,(0,j.jsxs)(_,{id:`img-cred-base-preset-${e.id}`,className:oe(),value:ce(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){h(e.id,{baseUrl:``});return}if(n===P){h(e.id,{baseUrl:``});return}h(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,j.jsx)(y,{value:``,children:k.baseUrlPresetDefault}),n.baseUrlPresets.map(me),(0,j.jsx)(y,{value:P,children:k.baseUrlPresetCustom})]}),ce(t,n.baseUrlPresets)===P?(0,j.jsx)(`input`,{type:`url`,className:i(N(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>h(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&se(t,n.regions)!==P?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:k.imageBaseUrlLabel}),(0,j.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:i(N(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:k.imageBaseUrlPresetHint}),(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:k.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=O,t[59]=a,t[60]=r,t[61]=C,t[62]=V,t[63]=D,t[64]=w,t[65]=k,t[66]=U,t[67]=h,t[68]=e):e=t[68],Z=n.map(e),t[46]=O,t[47]=a,t[48]=r,t[49]=C,t[50]=V,t[51]=D,t[52]=w,t[53]=n,t[54]=k,t[55]=U,t[56]=h,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,j.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,j.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function me(e){return(0,j.jsx)(y,{value:e.value,children:e.label},e.value)}function he(){return new Set}function ge(){return new Set}function _e(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ve(e){return(e.ui?.regions?.length??0)>0}function I(e){let t=C(a(e=>!!e.token)),n=t.data,r=(0,T.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,T.useRef)(!1),[o,l]=(0,T.useState)(null),[u,d]=(0,T.useState)(!1),[f,p]=(0,T.useState)(null),[m,h]=(0,T.useState)(!1),[g,_]=(0,T.useState)(!1),v=(0,T.useMemo)(()=>D(n?.payload?.config,r),[n?.payload?.config,r]),y=o??v,b=v;return{gwSwr:t,credDraft:y,credBaseline:b,credDirty:(0,T.useMemo)(()=>JSON.stringify(y)!==JSON.stringify(b),[y,b]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,T.useCallback)((e,t)=>{i.current=!0,l(n=>{let r=n??v,i=r[e]??E();return{...r,[e]:{...i,...t}}})},[v]),onDiscardCredentials:(0,T.useCallback)(()=>{i.current=!1,l(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,T.useCallback)(async e=>{let n=re(r,y,b);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ie(n),await t.mutate?.(),c(s(w)),i.current=!1,l(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,y,b,t])}}function ye(){return{enabled:!1,provider:`alibaba`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},fallback:{enabled:!0,order:[`alibaba`,`openai`]}}}function be(){return{enabled:!1,provider:`edge`,trigger:`always`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`en-US-MichelleNeural`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`alibaba`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=ye();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!0,order:[`alibaba`,`openai`]};if(L(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=be();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`always`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function W(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function G(e){let t=L(e)?e:{};return{stt:B(t.stt),tts:H(t.tts)}}async function K(){return G((await o(s(`/api/config`))).payload?.config??{})}async function q(e){await o(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts)})}),x()}async function J(){let e=await o(s(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await o(s(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await o(s(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(e){let t=await o(s(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function Q(e){let t=await o(s(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function $(e){let t=(0,te.c)(15),{kind:n,providerId:r,fieldId:a,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Q({kind:n,provider:r}).then(xe),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=i(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let h;t[5]!==a||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(h=(0,j.jsx)(S,{id:a,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=a,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==h?(g=(0,j.jsx)(`div`,{className:m,children:h}),t[12]=m,t[13]=h,t[14]=g):g=t[14],g}function xe(e){return e.apiKey??null}export{X as a,Z as c,ee as d,w as f,K as i,I as l,J as n,G as o,Y as r,q as s,$ as t,F as u};
@@ -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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-BXNELNBa.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{Al as s,Dl as c,Es as ee,Fs as te,Gs as l,Ic as u,Jo as d,Nc as ne,Wo as re,Xa as f,Zi as p,a as m,bs as ie,f as ae,gt as oe,io as se,jl as ce,kc as h,ko as g,l as le,m as ue,nl as de,o as fe,oo as _,p as pe,s as v,u as y,ul as b,xc as x,xl as S,ys as me}from"./index-DcUaXYeb.js";var C=n(),w=e(t(),1),T=r();function he(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function E(e){return e?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):``}function ge(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function _e(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:e.kind===`note`?`/notes/${encodeURIComponent(e.targetId)}`:`#`}function D(e){let t=(0,C.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.jsx)(`dt`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a=r||`-`,o;t[2]===a?o=t[3]:(o=(0,T.jsx)(`dd`,{className:`min-w-0 break-words text-sm text-fg`,children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ve(e){let t=(0,C.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,T.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted shadow-surface`,children:r.detail.noActivity}),t[0]=r.detail.noActivity,t[1]=e),e}let i;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,T.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,T.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:E(e.createdAt)})]})},e.id),t[5]=r,t[6]=e),i=n.map(e),t[2]=n,t[3]=r,t[4]=i}else i=t[4];let a;return t[7]===i?a=t[8]:(a=(0,T.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function O(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function k(e,t,n){let r=t?.projectKind,i=[e.title,e.description,e.nextAction,e.blockedReason,e.status,e.priority,t?.name,t?.description,r].filter(Boolean).join(` `),a=[n.title,n.description,n.metadata.whenToUse,...n.metadata.tags??[]].filter(Boolean).join(` `),o=O(i),s=0;for(let e of O(a))o.has(e)&&(s+=3);let c=a.toLowerCase();return(e.status===`blocked`||e.status===`needs_input`)&&/debug|diagnos|review|audit|fix|检查|排查|修复/.test(c)&&(s+=8),e.status===`in_review`&&/review|audit|check|验收|评审|检查/.test(c)&&(s+=6),e.attachments?.length&&/analy|extract|summar|review|整理|分析|总结/.test(c)&&(s+=5),r===`coding`&&/code|repo|test|pr|review|代码|仓库|测试/.test(c)&&(s+=5),s}function ye(e,t,n){return[...n].sort((n,r)=>k(e,t,r)-k(e,t,n)||n.title.localeCompare(r.title))}function A(){let{workItemId:e=``}=ce(),t=s(),n=a(o(e=>e.language)).projectDetailPage.workItems,[r,C]=(0,w.useState)(null),[O,A]=(0,w.useState)(null),[j,M]=(0,w.useState)([]),[N,be]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(!0),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(null),W=(0,w.useRef)(null),G=f(e=>e.setPageHeader),K=f(e=>e.clearPageHeader),q=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,w.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([le(e),y(e).catch(()=>({events:[]}))]);C(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([p(t.item.projectId).catch(()=>null),oe().catch(()=>[])]),a=ye(t.item,r,i);A(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,w.useEffect)(()=>{J()},[J]);let Y=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await ae(r.id);C(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),X=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await m(r.id);C(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),Z=(0,w.useCallback)(async e=>{M((await y(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await pe(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});C(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t,Z,P,I]),Se=(0,w.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await ue(r.id,e);C(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,w.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await fe(r.id,e.id);C(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,w.useCallback)(async e=>{if(r){U(null);try{await v(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?N.filter(e=>k(r,O,e)>0).slice(0,3):[],[r,O,N]),$=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(g,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(g,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(g,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.createGoal})]})]}):null]}),[B,X,Y,r,J,n.detail.createGoal,n.detail.startChat,n.refreshShort]);return(0,w.useLayoutEffect)(()=>(G({startExtra:(0,T.jsx)(c,{to:q,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":O?.name?n.detail.backToProject.replace(`{{name}}`,O.name):n.detail.backToProjects,children:(0,T.jsx)(S,{className:`size-4`,"aria-hidden":!0})}),main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(b,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,T.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,O?.name||r.projectId,` · `,n.updated,`: `,E(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,O?.name,q,G,n,O]),R?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(c,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(S,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger-soft px-4 py-3 text-sm text-danger`,children:H||n.detail.notFound})]}):(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-4 shadow-surface sm:px-5`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(b,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,T.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 font-medium`,he(r.status)),children:n.statuses[r.status]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(g,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(g,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,T.jsx)(D,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,T.jsx)(D,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,T.jsx)(D,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,T.jsx)(D,{label:n.updated,value:E(r.updatedAt)})]})]}),(0,T.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,T.jsxs)(`section`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,T.jsx)(h,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,T.jsx)(ve,{events:j,t:n})]}),(0,T.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(x,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,T.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,T.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(se,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,T.jsx)(_,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(_,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,T.jsx)(`button`,{type:`button`,className:i(`min-w-0 rounded-md border px-2 py-1 text-left text-xs transition-colors`,P===e.id?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),disabled:B,onClick:()=>F(e.id),children:(0,T.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,T.jsx)(`textarea`,{className:`min-h-20 resize-y rounded-md border border-edge bg-surface-base px-2 py-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:B,onChange:e=>L(e.target.value)})]}),(0,T.jsxs)(g,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(me,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(te,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(g,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,T.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base px-2 py-2 text-sm`,children:[(0,T.jsx)(h,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,T.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,ge(e.size)]})]}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:n.attachments.download,"aria-label":n.attachments.download,disabled:B,onClick:()=>void we(e),children:(0,T.jsx)(u,{className:`size-3.5`,"aria-hidden":!0})}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:n.attachments.remove,"aria-label":n.attachments.remove,disabled:B,onClick:()=>void Ce(e),children:(0,T.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(c,{to:_e(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,T.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,T.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,T.jsxs)(c,{to:q,className:`mt-2 inline-flex min-w-0 items-center gap-2 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(de,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:O?.name||r.projectId})]})]})]})]})]})}export{A as WorkItemDetailPage};
@@ -0,0 +1,3 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-BXNELNBa.js";import{o,t as s}from"./fetch-B1WtuprY.js";import{$ as c,D as l,Ja as u,Jo as d,Ka as f,Mc as p,Mo as m,N as h,Q as g,Ro as _,U as v,Ua as y,Wa as b,Ya as x,as as S,bs as C,io as w,ko as T,oo as E,qa as D,rs as O,sc as k,sl as ee,ts as A,ui as j}from"./index-DcUaXYeb.js";var M=e(t(),1),N=n();function P(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function F(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function I(e,t={}){let n=P(e.split(`
2
+ `).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
3
+ `));if(!n)return null;if(n.type===`text_delta`&&typeof n.delta==`string`)return t.onDelta?.(n.delta),null;if(n.type===`thinking_delta`&&typeof n.delta==`string`)return t.onThinkingDelta?.(n.delta),null;if(n.type===`done`&&typeof n.text==`string`)return n.text;if(n.type===`error`)throw Error(F(n));return null}async function L(e,t={}){let n=await s(o(`/api/ai/text-assist`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(t||`AI suggestion failed (${n.status})`)}if(!n.body){let e=await n.json().catch(()=>null);if(e?.text)return e;throw Error(`AI suggestion stream is empty`)}let r=n.body.getReader(),i=new TextDecoder,a=``,c=``,l=``;for(;;){let{done:e,value:n}=await r.read();if(n){a+=i.decode(n,{stream:!e});let r=a.split(/\r?\n\r?\n/);a=r.pop()??``;for(let e of r){let n=I(e,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});n!==null&&(c=n)}}if(e)break}if(a.trim()){let e=I(a,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});e!==null&&(c=e)}let u=c.trim();if(!u)throw Error(`AI returned an empty suggestion`);return{text:u,thinking:l.trim()||void 0}}function te(){let[e,t]=(0,M.useState)(``),[n,r]=(0,M.useState)(``),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(null);return{suggestion:e,thinking:n,loading:i,error:o,generate:(0,M.useCallback)(async e=>{a(!0),s(null),t(``),r(``);try{let n=await L(e,{onDelta:e=>{t(t=>t+e)},onThinkingDelta:e=>{r(t=>t+e)}});return t(n.text),r(n.thinking??``),n.text}catch(e){return s(e instanceof Error?e.message:`AI suggestion failed`),null}finally{a(!1)}},[]),reset:(0,M.useCallback)(()=>{t(``),r(``),s(null),a(!1)},[])}}var R=r(),ne=5;function re(e){return e.startsWith(`zh`)?{title:`AI 优化文案`,buttonTitle:`优化文案`,current:`当前内容`,suggestion:`AI 建议`,editedSuggestion:`审核并编辑建议`,thinking:`模型思考`,thinkingLoading:`思考中`,edit:`编辑`,preview:`预览`,loading:`正在生成建议...`,empty:`暂无内容`,generate:`生成建议`,regenerate:`重新生成`,applyCurrent:`应用当前内容`,replace:`替换`,append:`追加`,cancel:`取消`,close:`关闭`}:{title:`AI text assist`,buttonTitle:`Improve text`,current:`Current`,suggestion:`Suggestion`,editedSuggestion:`Review and edit suggestion`,thinking:`Model thinking`,thinkingLoading:`Thinking`,edit:`Edit`,preview:`Preview`,loading:`Generating suggestion...`,empty:`No content`,generate:`Generate suggestion`,regenerate:`Regenerate`,applyCurrent:`Apply current`,replace:`Replace`,append:`Append`,cancel:`Cancel`,close:`Close`}}function z(e){let t=(0,N.c)(232),{value:n,onApply:r,fieldId:a,fieldLabel:o,scenario:s,format:c,intent:l,locale:d,context:h,disabled:g,className:_,showLabel:v}=e,S=s===void 0?`generic.text`:s,w=c===void 0?`plain`:c,E=l===void 0?`improve`:l,k=v===void 0?!0:v,[P,F]=(0,M.useState)(!1),[I,L]=(0,M.useState)(n),[z,B]=(0,M.useState)(`preview`),[V,H]=(0,M.useState)(``),[U,W]=(0,M.useState)(`edit`),[G,oe]=(0,M.useState)(!0),se=(0,M.useRef)(null),K=(0,M.useRef)(!0),{suggestion:q,thinking:J,loading:Y,error:X,generate:ce,reset:le}=te(),ue;t[0]===d?ue=t[1]:(ue=re(d),t[0]=d,t[1]=ue);let Z=ue,de;t[2]!==Y||t[3]!==J?(de=Y&&J.trim().length>0,t[2]=Y,t[3]=J,t[4]=de):de=t[4];let Q=de,fe,pe;t[5]!==P||t[6]!==n?(fe=()=>{P||L(n)},pe=[P,n],t[5]=P,t[6]=n,t[7]=fe,t[8]=pe):(fe=t[7],pe=t[8]),(0,M.useEffect)(fe,pe);let me,he;t[9]===q?(me=t[10],he=t[11]):(he=()=>{H(q)},me=[q],t[9]=q,t[10]=me,t[11]=he),(0,M.useEffect)(he,me);let ge,_e;t[12]===J?(ge=t[13],_e=t[14]):(ge=()=>{J.trim()&&oe(!0)},_e=[J],t[12]=J,t[13]=ge,t[14]=_e),(0,M.useEffect)(ge,_e);let ve;t[15]!==Q||t[16]!==G?(ve=()=>{let e=se.current;!e||!Q||!G||K.current&&(e.scrollTop=e.scrollHeight)},t[15]=Q,t[16]=G,t[17]=ve):ve=t[17];let ye;t[18]!==Q||t[19]!==J||t[20]!==G?(ye=[Q,J,G],t[18]=Q,t[19]=J,t[20]=G,t[21]=ye):ye=t[21],(0,M.useLayoutEffect)(ve,ye);let be;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>{let e=se.current;e&&(K.current=e.scrollHeight-e.scrollTop-e.clientHeight<=ne)},t[22]=be):be=t[22];let xe=be,Se;t[23]!==h||t[24]!==a||t[25]!==o||t[26]!==w||t[27]!==ce||t[28]!==E||t[29]!==d||t[30]!==S?(Se=async e=>{W(`edit`),oe(!0),K.current=!0,await ce({intent:E,scenario:S,input:e,locale:d,field:{id:a,label:o,format:w},context:h})},t[23]=h,t[24]=a,t[25]=o,t[26]=w,t[27]=ce,t[28]=E,t[29]=d,t[30]=S,t[31]=Se):Se=t[31];let Ce=Se,we;t[32]!==le||t[33]!==n?(we=()=>{L(n),B(`preview`),H(``),W(`edit`),oe(!0),le(),F(!0)},t[32]=le,t[33]=n,t[34]=we):we=t[34];let Te=we,Ee;t[35]!==I||t[36]!==Ce?(Ee=async()=>{await Ce(I)},t[35]=I,t[36]=Ce,t[37]=Ee):Ee=t[37];let De=Ee,Oe;t[38]!==le||t[39]!==n?(Oe=()=>{F(!1),L(n),B(`preview`),H(``),W(`edit`),oe(!0),le()},t[38]=le,t[39]=n,t[40]=Oe):Oe=t[40];let $=Oe,ke;t[41]!==$||t[42]!==I||t[43]!==r?(ke=()=>{r(I),$()},t[41]=$,t[42]=I,t[43]=r,t[44]=ke):ke=t[44];let Ae=ke,je;t[45]!==$||t[46]!==V||t[47]!==r?(je=()=>{V.trim()&&(r(V),$())},t[45]=$,t[46]=V,t[47]=r,t[48]=je):je=t[48];let Me=je,Ne;t[49]!==$||t[50]!==I||t[51]!==V||t[52]!==r?(Ne=()=>{if(!V.trim())return;let e=I.trimEnd();r(e?`${e}\n\n${V}`:V),$()},t[49]=$,t[50]=I,t[51]=V,t[52]=r,t[53]=Ne):Ne=t[53];let Pe=Ne,Fe;t[54]!==V||t[55]!==X||t[56]!==Y?(Fe=!Y&&!X&&V.trim().length>0,t[54]=V,t[55]=X,t[56]=Y,t[57]=Fe):Fe=t[57];let Ie=Fe,Le=I!==n,Re;t[58]!==V||t[59]!==X||t[60]!==J?(Re=V.trim().length>0||J.trim().length>0||!!X,t[58]=V,t[59]=X,t[60]=J,t[61]=Re):Re=t[61];let ze=Re,Be=!k&&`size-7 p-0`,Ve;t[62]!==_||t[63]!==Be?(Ve=i(`h-7 gap-1 px-2 text-xs`,Be,_),t[62]=_,t[63]=Be,t[64]=Ve):Ve=t[64];let He=g||Y,Ue;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,R.jsx)(O,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[65]=Ue):Ue=t[65];let We=k?Z.buttonTitle:null,Ge;t[66]!==Z.buttonTitle||t[67]!==Te||t[68]!==Ve||t[69]!==He||t[70]!==We?(Ge=(0,R.jsxs)(T,{type:`button`,variant:`ghost`,className:Ve,title:Z.buttonTitle,"aria-label":Z.buttonTitle,disabled:He,onClick:Te,children:[Ue,We]}),t[66]=Z.buttonTitle,t[67]=Te,t[68]=Ve,t[69]=He,t[70]=We,t[71]=Ge):Ge=t[71];let Ke;t[72]===$?Ke=t[73]:(Ke=e=>e?F(!0):$(),t[72]=$,t[73]=Ke);let qe;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,R.jsx)(f,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),t[74]=qe):qe=t[74];let Je;t[75]===Z.title?Je=t[76]:(Je=(0,R.jsx)(x,{className:`text-base font-semibold text-fg`,children:Z.title}),t[75]=Z.title,t[76]=Je);let Ye;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=(0,R.jsx)(m,{className:`size-5`,strokeWidth:1.75}),t[77]=Ye):Ye=t[77];let Xe;t[78]===Z.close?Xe=t[79]:(Xe=(0,R.jsx)(y,{asChild:!0,children:(0,R.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":Z.close,children:Ye})}),t[78]=Z.close,t[79]=Xe);let Ze;t[80]!==Je||t[81]!==Xe?(Ze=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[Je,Xe]}),t[80]=Je,t[81]=Xe,t[82]=Ze):Ze=t[82];let Qe;t[83]===Z.current?Qe=t[84]:(Qe=(0,R.jsx)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:Z.current}),t[83]=Z.current,t[84]=Qe);let $e=z===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,et;t[85]===$e?et=t[86]:(et=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,$e),t[85]=$e,t[86]=et);let tt,nt;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(tt=()=>B(`edit`),nt=(0,R.jsx)(A,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[87]=tt,t[88]=nt):(tt=t[87],nt=t[88]);let rt;t[89]!==Z.edit||t[90]!==et?(rt=(0,R.jsxs)(`button`,{type:`button`,className:et,onClick:tt,children:[nt,Z.edit]}),t[89]=Z.edit,t[90]=et,t[91]=rt):rt=t[91];let it=z===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,at;t[92]===it?at=t[93]:(at=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,it),t[92]=it,t[93]=at);let ot,st;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(ot=()=>B(`preview`),st=(0,R.jsx)(p,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[94]=ot,t[95]=st):(ot=t[94],st=t[95]);let ct;t[96]!==Z.preview||t[97]!==at?(ct=(0,R.jsxs)(`button`,{type:`button`,className:at,onClick:ot,children:[st,Z.preview]}),t[96]=Z.preview,t[97]=at,t[98]=ct):ct=t[98];let lt;t[99]!==rt||t[100]!==ct?(lt=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[rt,ct]}),t[99]=rt,t[100]=ct,t[101]=lt):lt=t[101];let ut;t[102]!==Qe||t[103]!==lt?(ut=(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[Qe,lt]}),t[102]=Qe,t[103]=lt,t[104]=ut):ut=t[104];let dt;t[105]!==I||t[106]!==z||t[107]!==w||t[108]!==Z.current||t[109]!==Z.empty?(dt=z===`preview`?(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:w===`markdown`?(0,R.jsx)(j,{content:I||Z.empty,compact:!0,className:`text-sm`}):(0,R.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:I||Z.empty})}):(0,R.jsx)(`textarea`,{className:`min-h-0 flex-1 resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25`,value:I,onChange:e=>L(e.currentTarget.value),placeholder:Z.empty,"aria-label":Z.current}),t[105]=I,t[106]=z,t[107]=w,t[108]=Z.current,t[109]=Z.empty,t[110]=dt):dt=t[110];let ft;t[111]!==ut||t[112]!==dt?(ft=(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[ut,dt]}),t[111]=ut,t[112]=dt,t[113]=ft):ft=t[113];let pt;t[114]===Z.editedSuggestion?pt=t[115]:(pt=(0,R.jsx)(`span`,{children:Z.editedSuggestion}),t[114]=Z.editedSuggestion,t[115]=pt);let mt;t[116]!==Z.loading||t[117]!==Y?(mt=Y?(0,R.jsx)(`span`,{className:`ml-2 font-normal`,children:Z.loading}):null,t[116]=Z.loading,t[117]=Y,t[118]=mt):mt=t[118];let ht;t[119]!==pt||t[120]!==mt?(ht=(0,R.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:[pt,mt]}),t[119]=pt,t[120]=mt,t[121]=ht):ht=t[121];let gt=U===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,_t;t[122]===gt?_t=t[123]:(_t=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,gt),t[122]=gt,t[123]=_t);let vt,yt;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>W(`edit`),yt=(0,R.jsx)(A,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[124]=vt,t[125]=yt):(vt=t[124],yt=t[125]);let bt;t[126]!==Z.edit||t[127]!==_t?(bt=(0,R.jsxs)(`button`,{type:`button`,className:_t,onClick:vt,children:[yt,Z.edit]}),t[126]=Z.edit,t[127]=_t,t[128]=bt):bt=t[128];let xt=U===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,St;t[129]===xt?St=t[130]:(St=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,xt),t[129]=xt,t[130]=St);let Ct,wt;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(Ct=()=>W(`preview`),wt=(0,R.jsx)(p,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[131]=Ct,t[132]=wt):(Ct=t[131],wt=t[132]);let Tt;t[133]!==Z.preview||t[134]!==St?(Tt=(0,R.jsxs)(`button`,{type:`button`,className:St,onClick:Ct,children:[wt,Z.preview]}),t[133]=Z.preview,t[134]=St,t[135]=Tt):Tt=t[135];let Et;t[136]!==bt||t[137]!==Tt?(Et=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[bt,Tt]}),t[136]=bt,t[137]=Tt,t[138]=Et):Et=t[138];let Dt;t[139]!==ht||t[140]!==Et?(Dt=(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[ht,Et]}),t[139]=ht,t[140]=Et,t[141]=Dt):Dt=t[141];let Ot=Q?`opacity-100`:`pointer-events-none opacity-0`,kt;t[142]===Ot?kt=t[143]:(kt=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Ot),t[142]=Ot,t[143]=kt);let At=!Q,jt;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(jt=()=>oe(ie),t[144]=jt):jt=t[144];let Mt;t[145]!==Z.thinkingLoading||t[146]!==Y?(Mt=Y?(0,R.jsxs)(`span`,{className:`ml-1 font-normal`,children:[`· `,Z.thinkingLoading]}):null,t[145]=Z.thinkingLoading,t[146]=Y,t[147]=Mt):Mt=t[147];let Nt;t[148]!==Z.thinking||t[149]!==Mt?(Nt=(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[Z.thinking,Mt]}),t[148]=Z.thinking,t[149]=Mt,t[150]=Nt):Nt=t[150];let Pt=G&&`rotate-180`,Ft;t[151]===Pt?Ft=t[152]:(Ft=i(`size-3.5 shrink-0 transition-transform`,Pt),t[151]=Pt,t[152]=Ft);let It;t[153]===Ft?It=t[154]:(It=(0,R.jsx)(ee,{className:Ft,strokeWidth:1.75,"aria-hidden":!0}),t[153]=Ft,t[154]=It);let Lt;t[155]!==Nt||t[156]!==It?(Lt=(0,R.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center justify-between gap-2 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:text-fg`,onClick:jt,children:[Nt,It]}),t[155]=Nt,t[156]=It,t[157]=Lt):Lt=t[157];let Rt;t[158]!==J||t[159]!==G?(Rt=G?(0,R.jsx)(`pre`,{ref:se,className:`min-h-0 flex-1 overflow-auto border-t border-edge px-2.5 py-2 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,onScroll:xe,children:J}):null,t[158]=J,t[159]=G,t[160]=Rt):Rt=t[160];let zt;t[161]!==Lt||t[162]!==Rt?(zt=(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-lg border border-edge bg-surface-muted/70`,children:[Lt,Rt]}),t[161]=Lt,t[162]=Rt,t[163]=zt):zt=t[163];let Bt;t[164]!==kt||t[165]!==At||t[166]!==zt?(Bt=(0,R.jsx)(`div`,{className:kt,"aria-hidden":At,children:zt}),t[164]=kt,t[165]=At,t[166]=zt,t[167]=Bt):Bt=t[167];let Vt=Q?`pointer-events-none opacity-0`:`opacity-100`,Ht;t[168]===Vt?Ht=t[169]:(Ht=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Vt),t[168]=Vt,t[169]=Ht);let Ut;t[170]!==V||t[171]!==X||t[172]!==w||t[173]!==Z.empty||t[174]!==Z.loading||t[175]!==Z.suggestion||t[176]!==Y||t[177]!==U?(Ut=X?(0,R.jsx)(`pre`,{className:`h-full min-h-0 overflow-auto whitespace-pre-wrap rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg-muted`,children:X}):U===`preview`?(0,R.jsx)(`div`,{className:`h-full min-h-0 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:Y&&!V.trim()?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Z.loading}):w===`markdown`?(0,R.jsx)(j,{content:V||Z.empty,compact:!0,className:`text-sm`}):(0,R.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:V||Z.empty})}):(0,R.jsx)(`textarea`,{className:`h-full min-h-0 w-full resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25 disabled:text-fg-muted`,value:V,onChange:e=>H(e.currentTarget.value),disabled:Y,placeholder:Y?Z.loading:Z.empty,"aria-label":Z.suggestion}),t[170]=V,t[171]=X,t[172]=w,t[173]=Z.empty,t[174]=Z.loading,t[175]=Z.suggestion,t[176]=Y,t[177]=U,t[178]=Ut):Ut=t[178];let Wt;t[179]!==Ht||t[180]!==Ut?(Wt=(0,R.jsx)(`div`,{className:Ht,children:Ut}),t[179]=Ht,t[180]=Ut,t[181]=Wt):Wt=t[181];let Gt;t[182]!==Bt||t[183]!==Wt?(Gt=(0,R.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[Bt,Wt]}),t[182]=Bt,t[183]=Wt,t[184]=Gt):Gt=t[184];let Kt;t[185]!==Dt||t[186]!==Gt?(Kt=(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[Dt,Gt]}),t[185]=Dt,t[186]=Gt,t[187]=Kt):Kt=t[187];let qt;t[188]!==ft||t[189]!==Kt?(qt=(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-3 overflow-hidden p-4 md:grid-cols-2`,children:[ft,Kt]}),t[188]=ft,t[189]=Kt,t[190]=qt):qt=t[190];let Jt;t[191]!==$||t[192]!==Z.cancel?(Jt=(0,R.jsx)(T,{type:`button`,variant:`secondary`,onClick:$,children:Z.cancel}),t[191]=$,t[192]=Z.cancel,t[193]=Jt):Jt=t[193];let Yt=!Le,Xt;t[194]!==Ae||t[195]!==Z.applyCurrent||t[196]!==Yt?(Xt=(0,R.jsx)(T,{type:`button`,variant:`secondary`,disabled:Yt,onClick:Ae,children:Z.applyCurrent}),t[194]=Ae,t[195]=Z.applyCurrent,t[196]=Yt,t[197]=Xt):Xt=t[197];let Zt;t[198]===De?Zt=t[199]:(Zt=()=>void De(),t[198]=De,t[199]=Zt);let Qt;t[200]===ze?Qt=t[201]:(Qt=ze?(0,R.jsx)(C,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,R.jsx)(O,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[200]=ze,t[201]=Qt);let $t=ze?Z.regenerate:Z.generate,en;t[202]!==Y||t[203]!==Zt||t[204]!==Qt||t[205]!==$t?(en=(0,R.jsxs)(T,{type:`button`,variant:`secondary`,disabled:Y,onClick:Zt,children:[Qt,$t]}),t[202]=Y,t[203]=Zt,t[204]=Qt,t[205]=$t,t[206]=en):en=t[206];let tn=!Ie,nn;t[207]!==Pe||t[208]!==Z.append||t[209]!==tn?(nn=(0,R.jsx)(T,{type:`button`,variant:`secondary`,disabled:tn,onClick:Pe,children:Z.append}),t[207]=Pe,t[208]=Z.append,t[209]=tn,t[210]=nn):nn=t[210];let rn=!Ie,an;t[211]!==Me||t[212]!==Z.replace||t[213]!==rn?(an=(0,R.jsx)(T,{type:`button`,variant:`primary`,disabled:rn,onClick:Me,children:Z.replace}),t[211]=Me,t[212]=Z.replace,t[213]=rn,t[214]=an):an=t[214];let on;t[215]!==Jt||t[216]!==Xt||t[217]!==en||t[218]!==nn||t[219]!==an?(on=(0,R.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Jt,Xt,en,nn,an]}),t[215]=Jt,t[216]=Xt,t[217]=en,t[218]=nn,t[219]=an,t[220]=on):on=t[220];let sn;t[221]!==Ze||t[222]!==qt||t[223]!==on?(sn=(0,R.jsxs)(D,{children:[qe,(0,R.jsx)(`div`,{className:`fixed inset-0 z-[80] flex items-center justify-center p-4 pointer-events-none`,children:(0,R.jsxs)(b,{className:`xopc-dialog-content-pane pointer-events-auto flex h-[min(78vh,38rem)] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,onOpenAutoFocus:ae,children:[Ze,qt,on]})})]}),t[221]=Ze,t[222]=qt,t[223]=on,t[224]=sn):sn=t[224];let cn;t[225]!==P||t[226]!==Ke||t[227]!==sn?(cn=(0,R.jsx)(u,{open:P,onOpenChange:Ke,children:sn}),t[225]=P,t[226]=Ke,t[227]=sn,t[228]=cn):cn=t[228];let ln;return t[229]!==cn||t[230]!==Ge?(ln=(0,R.jsxs)(R.Fragment,{children:[Ge,cn]}),t[229]=cn,t[230]=Ge,t[231]=ln):ln=t[231],ln}function ie(e){return!e}function ae(e){return e.preventDefault()}function B(e,t){return e[t]??t}function V(e){let t=(0,N.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,R.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,R.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function H(e){let t=(0,N.c)(34),{workflowName:n,language:r,argValues:o,onArgValuesChange:s,goal:c,onGoalChange:l,examplePrompts:u,showGoal:d,inputClassName:f,aiAssist:p}=e,m;t[0]===u?m=t[1]:(m=u===void 0?[]:u,t[0]=u,t[1]=m);let h=m,_=d===void 0?!0:d,y,b,x,S,C,w,T;if(t[2]!==p||t[3]!==o||t[4]!==h||t[5]!==c||t[6]!==f||t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==_||t[11]!==n){x=a(r).workflows;let e=v[n]??[];b=e.length>0;let u=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,f),d;t[19]!==o||t[20]!==s||t[21]!==l?(d=e=>{g(e,l,e=>{s(e(o))})},t[19]=o,t[20]=s,t[21]=l,t[22]=d):d=t[22],y=d,S=`flex flex-col gap-3`,C=e.map(e=>{let t=B(x.args,e.labelKey),a=B(x.args,e.placeholderKey),c=o[e.key]??``;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[t,e.required?` *`:``]}),e.multiline&&p?(0,R.jsx)(z,{value:c,onApply:t=>s({...o,[e.key]:t}),fieldId:`workflow.arg.${e.key}`,fieldLabel:t,scenario:p.argScenario??`workflow.arg`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o,fieldKey:e.key},disabled:p.disabled,showLabel:!1}):null]}),e.multiline?(0,R.jsx)(`textarea`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:i(u,`min-h-20 resize-y`)}):(0,R.jsx)(`input`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:u})]},e.key)}),w=b&&h.length>0?(0,R.jsx)(V,{examples:h,labels:x,onSelect:y}):null,T=_?(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:x.goalLabel}),p?(0,R.jsx)(z,{value:c,onApply:l,fieldId:`workflow.goal`,fieldLabel:x.goalLabel,scenario:p.goalScenario??`cron.workflowGoal`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o},disabled:p.disabled,showLabel:!1}):null]}),(0,R.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:x.goalPlaceholder,className:i(u,`min-h-20 resize-y`)})]}):null,t[2]=p,t[3]=o,t[4]=h,t[5]=c,t[6]=f,t[7]=r,t[8]=s,t[9]=l,t[10]=_,t[11]=n,t[12]=y,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T}else y=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],T=t[18];let E;t[23]!==y||t[24]!==h||t[25]!==b||t[26]!==x?(E=!b&&h.length>0?(0,R.jsx)(V,{examples:h,labels:x,onSelect:y}):null,t[23]=y,t[24]=h,t[25]=b,t[26]=x,t[27]=E):E=t[27];let D;return t[28]!==S||t[29]!==C||t[30]!==w||t[31]!==T||t[32]!==E?(D=(0,R.jsxs)(`div`,{className:S,children:[C,w,T,E]}),t[28]=S,t[29]=C,t[30]=w,t[31]=T,t[32]=E,t[33]=D):D=t[33],D}var U=`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`;function W(e){return!!(e&&e.type===`object`&&e.properties&&!Array.isArray(e.properties))}function G({schema:e,value:t,onChange:n,labels:r,aiAssist:a,onValidChange:o}){let s=(0,M.useMemo)(()=>K(e),[e]),[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(()=>JSON.stringify(t,null,2)),[f,p]=(0,M.useState)(null);if(s.length===0)return null;let m=(e,r)=>{let i={...t,[e]:r};(r===``||r===void 0)&&delete i[e],n(i),c&&d(JSON.stringify(i,null,2))},h=e=>{d(e);try{let t=e.trim()?JSON.parse(e):{};if(!t||typeof t!=`object`||Array.isArray(t)){p(r.rawJsonInvalid),o?.(!1);return}p(null),n(t),o?.(!0,t)}catch{p(r.rawJsonInvalid),o?.(!1)}};return(0,R.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel/70 p-4 shadow-surface`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.inputSchemaHeading}),(0,R.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:()=>{let e=!c;l(e),e&&(d(JSON.stringify(t,null,2)),p(null),o?.(!0))},children:r.rawJson})]}),c?(0,R.jsxs)(`div`,{className:`mt-3`,children:[(0,R.jsx)(`textarea`,{value:u,onChange:e=>h(e.target.value),spellCheck:!1,className:i(U,`min-h-40 font-mono text-xs leading-5`)}),f?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-300`,children:f}):null]}):(0,R.jsx)(`div`,{className:`mt-3 grid gap-3`,children:s.map(e=>(0,R.jsx)(oe,{field:e,value:t[e.key],labels:r,aiAssist:a,allValues:t,onChange:t=>m(e.key,t)},e.key))})]})}function oe(e){let t=(0,N.c)(30),{field:n,value:r,labels:a,aiAssist:o,allValues:s,onChange:c}=e,l=n.schema.title||n.key,u=typeof n.schema.description==`string`?n.schema.description:void 0,d=Array.isArray(n.schema.type)?n.schema.type[0]:n.schema.type,f;t[0]===n.schema.enum?f=t[1]:(f=Array.isArray(n.schema.enum)?n.schema.enum:[],t[0]=n.schema.enum,t[1]=f);let p=f,m=!!o&&!p.length&&(d===`string`||!d),h=String(l),g=n.required?` *`:``,_;t[2]!==h||t[3]!==g?(_=(0,R.jsxs)(`span`,{className:`text-xs font-medium text-fg`,children:[h,g]}),t[2]=h,t[3]=g,t[4]=_):_=t[4];let v;t[5]!==o||t[6]!==s||t[7]!==n.key||t[8]!==n.schema||t[9]!==c||t[10]!==m||t[11]!==l||t[12]!==r?(v=m&&o?(0,R.jsx)(z,{value:typeof r==`string`?r:r==null?``:String(r),onApply:c,fieldId:`workflow.schema.${n.key}`,fieldLabel:String(l),scenario:o.scenario??`workflow.arg`,locale:o.locale,context:{...o.context,fieldKey:n.key,fieldSchema:n.schema,inputValues:s},disabled:o.disabled,showLabel:!1}):null,t[5]=o,t[6]=s,t[7]=n.key,t[8]=n.schema,t[9]=c,t[10]=m,t[11]=l,t[12]=r,t[13]=v):v=t[13];let y;t[14]!==_||t[15]!==v?(y=(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===u?b=t[18]:(b=u?(0,R.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-subtle`,children:u}):null,t[17]=u,t[18]=b);let x;t[19]!==u||t[20]!==p||t[21]!==a||t[22]!==c||t[23]!==d||t[24]!==r?(x=p.length>0?(0,R.jsxs)(w,{value:r==null?``:String(r),onChange:e=>c(e.target.value),className:U,children:[(0,R.jsx)(E,{value:``}),p.map(se)]}):d===`boolean`?(0,R.jsxs)(w,{value:typeof r==`boolean`?String(r):``,onChange:e=>c(e.target.value===``?void 0:e.target.value===`true`),className:U,children:[(0,R.jsx)(E,{value:``}),(0,R.jsx)(E,{value:`true`,children:a.booleanTrue}),(0,R.jsx)(E,{value:`false`,children:a.booleanFalse})]}):d===`number`||d===`integer`?(0,R.jsx)(`input`,{type:`number`,value:typeof r==`number`||typeof r==`string`?String(r):``,onChange:e=>c(e.target.value===``?void 0:Number(e.target.value)),className:U}):(0,R.jsx)(`textarea`,{value:typeof r==`string`?r:r==null?``:String(r),onChange:e=>c(e.target.value),className:i(U,u&&u.length>80?`min-h-20 resize-y`:`min-h-10 resize-y`)}),t[19]=u,t[20]=p,t[21]=a,t[22]=c,t[23]=d,t[24]=r,t[25]=x):x=t[25];let S;return t[26]!==y||t[27]!==b||t[28]!==x?(S=(0,R.jsxs)(`div`,{className:`block`,children:[y,b,x]}),t[26]=y,t[27]=b,t[28]=x,t[29]=S):S=t[29],S}function se(e){return(0,R.jsx)(E,{value:String(e),children:String(e)},String(e))}function K(e){let t=e.properties??{},n=new Set(e.required??[]);return Object.entries(t).map(([e,t])=>({key:e,schema:t,required:n.has(e)}))}function q(e,t){return!W(e)||!e?!0:K(e).every(e=>{if(!e.required)return!0;let n=t[e.key];return n==null?!1:typeof n==`string`?n.trim().length>0:!0})}function J(e){let t=(0,N.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,R.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,R.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function Y(e,t){if(e)return W(e.inputSchema)?Object.keys(t.schemaInput).length>0?t.schemaInput:void 0:l(t.argValues)}function X(e,t,n){let r=a(t).workflows;if(!e)return r.noInputSummary;let i=c(e,t);if(W(e.inputSchema)&&Object.keys(n.schemaInput).length>0)return Object.entries(n.schemaInput).map(([e,t])=>`${e}: ${String(t)}`).join(` · `);let o=Object.values(n.argValues).map(e=>e.trim()).filter(Boolean),s=n.goal.trim()||i.description;return s&&o.unshift(s),o.length>0?o.join(` · `):r.noInputSummary}function ce(e,t,n=!0){return e?n?W(e.inputSchema)?q(e.inputSchema,t.schemaInput)?{valid:!0}:{valid:!1,reason:`schema-required`}:{valid:(v[e.name]??[]).every(e=>!e.required||!!t.argValues[e.key]?.trim())}:{valid:!1,reason:`raw-json`}:{valid:!1}}function le(e){let t=(0,N.c)(114),{definition:n,language:r,value:o,onChange:s,aiAssist:l,inputClassName:u,onValidityChange:d}=e,f;t[0]===r?f=t[1]:(f=a(r),t[0]=r,t[1]=f);let p=f.workflows,m;t[2]!==n||t[3]!==r?(m=c(n,r),t[2]=n,t[3]=r,t[4]=m):m=t[4];let h=m,[g,_]=(0,M.useState)(!0),v;t[5]===h.examplePrompts?v=t[6]:(v=h.examplePrompts??[],t[5]=h.examplePrompts,t[6]=v);let y=v,b;t[7]===n.inputSchema?b=t[8]:(b=W(n.inputSchema),t[7]=n.inputSchema,t[8]=b);let x=b,S,C,w,T,E,D,O,k,ee,A;if(t[9]!==l||t[10]!==n||t[11]!==y||t[12]!==x||t[13]!==u||t[14]!==p||t[15]!==r||t[16]!==h.description||t[17]!==s||t[18]!==d||t[19]!==g||t[20]!==o){E=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,u),a;t[31]!==n||t[32]!==s||t[33]!==d||t[34]!==g?(a=(e,t)=>{let r=t===void 0?g:t;s(e),d?.(ce(n,e,r))},t[31]=n,t[32]=s,t[33]=d,t[34]=g,t[35]=a):a=t[35];let c=a,f;t[36]!==c||t[37]!==o?(f=e=>c({...o,goal:e}),t[36]=c,t[37]=o,t[38]=f):f=t[38];let m=f,v;t[39]!==c||t[40]!==o?(v=e=>c({...o,schemaInput:e}),t[39]=c,t[40]=o,t[41]=v):v=t[41];let b=v,j;t[42]!==c||t[43]!==o?(j=e=>c({...o,argValues:e}),t[42]=c,t[43]=o,t[44]=j):j=t[44];let M=j,N;if(t[45]!==m||t[46]!==b||t[47]!==o.schemaInput?(N=e=>{if(e.field===`goal`){m(e.text);return}b({...o.schemaInput,[e.field]:e.text})},t[45]=m,t[46]=b,t[47]=o.schemaInput,t[48]=N):N=t[48],S=N,!x){let e;t[49]!==l||t[50]!==n.id||t[51]!==n.name||t[52]!==n.title||t[53]!==h.description?(e=l?{disabled:l.disabled,argScenario:l.inputScenario??`workflow.arg`,goalScenario:l.goalScenario??`workflow.goal`,context:{...l.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:h.description}}:void 0,t[49]=l,t[50]=n.id,t[51]=n.name,t[52]=n.title,t[53]=h.description,t[54]=e):e=t[54];let i;t[55]!==n.name||t[56]!==y||t[57]!==u||t[58]!==r||t[59]!==M||t[60]!==m||t[61]!==e||t[62]!==o.argValues||t[63]!==o.goal?(i=(0,R.jsx)(H,{workflowName:n.name,language:r,argValues:o.argValues,onArgValuesChange:M,goal:o.goal,onGoalChange:m,examplePrompts:y,inputClassName:u,aiAssist:e}),t[55]=n.name,t[56]=y,t[57]=u,t[58]=r,t[59]=M,t[60]=m,t[61]=e,t[62]=o.argValues,t[63]=o.goal,t[64]=i):i=t[64],E=i;break bb0}w=`flex flex-col gap-3`,t[65]!==l||t[66]!==n||t[67]!==p.booleanFalse||t[68]!==p.booleanTrue||t[69]!==p.inputSchemaHeading||t[70]!==p.rawJson||t[71]!==p.rawJsonInvalid||t[72]!==r||t[73]!==h.description||t[74]!==d||t[75]!==b||t[76]!==o?(T=n.inputSchema?(0,R.jsx)(G,{schema:n.inputSchema,value:o.schemaInput,onChange:b,onValidChange:(e,t)=>{_(e),d?.(ce(n,t?{...o,schemaInput:t}:o,e))},aiAssist:l?{locale:r,disabled:l.disabled,scenario:l.inputScenario??`workflow.arg`,context:{...l.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:h.description}}:void 0,labels:{inputSchemaHeading:p.inputSchemaHeading,rawJson:p.rawJson,rawJsonInvalid:p.rawJsonInvalid,booleanTrue:p.booleanTrue,booleanFalse:p.booleanFalse}}):null,t[65]=l,t[66]=n,t[67]=p.booleanFalse,t[68]=p.booleanTrue,t[69]=p.inputSchemaHeading,t[70]=p.rawJson,t[71]=p.rawJsonInvalid,t[72]=r,t[73]=h.description,t[74]=d,t[75]=b,t[76]=o,t[77]=T):T=t[77],A=`flex flex-col gap-1`;let P;t[78]===p.goalLabel?P=t[79]:(P=(0,R.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:p.goalLabel}),t[78]=p.goalLabel,t[79]=P);let F;t[80]!==l||t[81]!==n.id||t[82]!==n.name||t[83]!==n.title||t[84]!==p.goalLabel||t[85]!==r||t[86]!==h.description||t[87]!==m||t[88]!==o.goal||t[89]!==o.schemaInput?(F=l?(0,R.jsx)(z,{value:o.goal,onApply:m,fieldId:`workflow.goal`,fieldLabel:p.goalLabel,scenario:l.goalScenario??`workflow.goal`,locale:r,context:{...l.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:h.description,workflowInput:o.schemaInput},disabled:l.disabled,showLabel:!1}):null,t[80]=l,t[81]=n.id,t[82]=n.name,t[83]=n.title,t[84]=p.goalLabel,t[85]=r,t[86]=h.description,t[87]=m,t[88]=o.goal,t[89]=o.schemaInput,t[90]=F):F=t[90],t[91]!==P||t[92]!==F?(C=(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[P,F]}),t[91]=P,t[92]=F,t[93]=C):C=t[93],D=o.goal,t[94]===m?O=t[95]:(O=e=>m(e.target.value),t[94]=m,t[95]=O),k=p.goalPlaceholder,ee=i(e,`min-h-20 resize-y`)}t[9]=l,t[10]=n,t[11]=y,t[12]=x,t[13]=u,t[14]=p,t[15]=r,t[16]=h.description,t[17]=s,t[18]=d,t[19]=g,t[20]=o,t[21]=S,t[22]=C,t[23]=w,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=ee,t[30]=A}else S=t[21],C=t[22],w=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],ee=t[29],A=t[30];if(E!==Symbol.for(`react.early_return_sentinel`))return E;let j;t[96]!==D||t[97]!==O||t[98]!==k||t[99]!==ee?(j=(0,R.jsx)(`textarea`,{value:D,onChange:O,placeholder:k,className:ee}),t[96]=D,t[97]=O,t[98]=k,t[99]=ee,t[100]=j):j=t[100];let P;t[101]!==C||t[102]!==j||t[103]!==A?(P=(0,R.jsxs)(`div`,{className:A,children:[C,j]}),t[101]=C,t[102]=j,t[103]=A,t[104]=P):P=t[104];let F;t[105]!==S||t[106]!==y||t[107]!==p?(F=(0,R.jsx)(J,{examples:y,labels:p,onSelect:S}),t[105]=S,t[106]=y,t[107]=p,t[108]=F):F=t[108];let I;return t[109]!==w||t[110]!==T||t[111]!==P||t[112]!==F?(I=(0,R.jsxs)(`div`,{className:w,children:[T,P,F]}),t[109]=w,t[110]=T,t[111]=P,t[112]=F,t[113]=I):I=t[113],I}function ue(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?h(t.agentScaleExact,{count:n.min}):h(t.agentScaleRange,{min:n.min,max:n.max}):h(t.agentScaleExact,{count:e.defaults.maxSubagents})}function Z(e){let t=(0,N.c)(41),{definition:n,language:r,value:o,onChange:s,mode:l,badgeLabel:u,aiAssist:f,inputClassName:p,showTimeout:m,defaultAdvancedOpen:g,onValidityChange:v}=e,y=m===void 0?!1:m,b=g===void 0?!1:g,x=a(r).workflows,[C,w]=(0,M.useState)(b),T;t[0]!==n||t[1]!==r?(T=c(n,r),t[0]=n,t[1]=r,t[2]=T):T=t[2];let E=T,D;t[3]!==n.defaults||t[4]!==o.concurrency?(D=o.concurrency.trim()?Number(o.concurrency):n.defaults.concurrency,t[3]=n.defaults,t[4]=o.concurrency,t[5]=D):D=t[5];let O=D,A;t[6]!==n.defaults||t[7]!==o.maxSubagents?(A=o.maxSubagents.trim()?Number(o.maxSubagents):n.defaults.maxSubagents,t[6]=n.defaults,t[7]=o.maxSubagents,t[8]=A):A=t[8];let j=A,P;t[9]!==n||t[10]!==r||t[11]!==o?(P=X(n,r,o),t[9]=n,t[10]=r,t[11]=o,t[12]=P):P=t[12];let F=P,I=u??x.readyToStart,L;t[13]!==s||t[14]!==o?(L=e=>s({...o,...e}),t[13]=s,t[14]=o,t[15]=L):L=t[15];let te=L,ne=l===`automation`&&`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,re;t[16]===ne?re=t[17]:(re=i(`space-y-4`,ne),t[16]=ne,t[17]=re);let z=F||E.description,ie;t[18]===z?ie=t[19]:(ie=(0,R.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:z}),t[18]=z,t[19]=ie);let ae;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,R.jsx)(k,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[20]=ae):ae=t[20];let B;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,R.jsx)(_,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[21]=B):B=t[21];let V;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,R.jsx)(S,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[22]=V):V=t[22];let H;t[23]!==s||t[24]!==o?(H=e=>s({...o,...e}),t[23]=s,t[24]=o,t[25]=H):H=t[25];let U;t[26]===v?U=t[27]:(U=e=>{v?.(e)},t[26]=v,t[27]=U);let W;t[28]!==f||t[29]!==n||t[30]!==p||t[31]!==r||t[32]!==H||t[33]!==U||t[34]!==o?(W=(0,R.jsx)(le,{definition:n,language:r,value:o,onChange:H,onValidityChange:U,aiAssist:f,inputClassName:p}),t[28]=f,t[29]=n,t[30]=p,t[31]=r,t[32]=H,t[33]=U,t[34]=o,t[35]=W):W=t[35];let G;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>w(de),t[36]=G):G=t[36];let oe=x.advancedSettings,se=C&&`rotate-180`,K;t[37]===se?K=t[38]:(K=i(`size-4 transition-transform`,se),t[37]=se,t[38]=K);let q;return t[39]===K?q=t[40]:(q=(0,R.jsx)(ee,{className:K}),t[39]=K,t[40]=q),(0,R.jsxs)(`div`,{className:re,children:[(0,R.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:x.runPlanPreview}),ie]}),(0,R.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2 py-1 text-[11px] font-medium text-accent-fg`,children:I})]}),(0,R.jsxs)(`div`,{className:`mt-4 grid gap-2 text-xs text-fg-muted sm:grid-cols-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[ae,(0,R.jsx)(`span`,{children:h(x.phaseCount,{count:n.phases.length})})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[B,(0,R.jsx)(`span`,{children:ue(n,x)})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[V,(0,R.jsx)(`span`,{children:h(x.runLimitsSummary,{concurrency:O,max:j})})]})]}),n.phases.length>0?(0,R.jsxs)(`div`,{className:`mt-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[(0,R.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),x.startPlanPhases]}),(0,R.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:n.phases.map(Q)})]}):null]}),W,(0,R.jsxs)(`div`,{className:`rounded-xl border border-edge`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between px-3 py-2.5 text-left text-sm text-fg`,onClick:G,children:[oe,q]}),C?(0,R.jsxs)(`div`,{className:`grid gap-3 border-t border-edge px-3 pb-3 pt-3 sm:grid-cols-2`,children:[(0,R.jsx)(`input`,{value:o.concurrency,onChange:e=>te({concurrency:e.target.value}),placeholder:h(x.concurrencyPlaceholder,{default:n.defaults.concurrency}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,R.jsx)(`input`,{value:o.maxSubagents,onChange:e=>te({maxSubagents:e.target.value}),placeholder:h(x.maxSubagentsPlaceholder,{default:n.defaults.maxSubagents}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),y?(0,R.jsx)(`input`,{value:o.timeoutSeconds??``,onChange:e=>te({timeoutSeconds:e.target.value}),placeholder:h(x.timeoutSecondsPlaceholder,{default:n.defaults.timeoutSec}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}):null]}):null]})]})}function de(e){return!e}function Q(e,t){return(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t>0?(0,R.jsx)(`span`,{className:`text-fg-subtle`,children:`→`}):null,(0,R.jsx)(`span`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1 text-[11px] text-fg-muted`,children:e.title})]},e.id)}export{z as a,B as i,Y as n,ce as r,Z as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-B-8CqAeX.js";import{$ as a,Eo as o,Ga as s,Ha as c,Ka as l,Ua as u,Va as d,Wa as f}from"./index-ehajXmqL.js";import{n as p,r as m,t as h}from"./workflow-run-setup-panel-CzK84i-B.js";var g=n(),_=e(t(),1),v=r();function y(e){let t=(0,g.c)(69),{open:n,definition:r,language:y,starting:b,onClose:x,onStart:S}=e,C;t[0]===y?C=t[1]:(C=i(y),t[0]=y,t[1]=C);let w=C.workflows,T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T={goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},t[2]=T):T=t[2];let[E,D]=(0,_.useState)(T),O;t[3]!==r||t[4]!==y?(O=r?a(r,y):null,t[3]=r,t[4]=y,t[5]=O):O=t[5];let k=O,A;t[6]!==r||t[7]!==E?(A=m(r,E),t[6]=r,t[7]=E,t[8]=A):A=t[8];let j=A,M;t[9]!==E.concurrency||t[10]!==E.maxSubagents?(M=[E.concurrency,E.maxSubagents].every(ee),t[9]=E.concurrency,t[10]=E.maxSubagents,t[11]=M):M=t[11];let te=M,N=j.valid&&te&&!b,P;t[12]!==r||t[13]!==n?(P=()=>{!n||!r||D({goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``})},t[12]=r,t[13]=n,t[14]=P):P=t[14];let F=r?.id,I;if(t[15]!==n||t[16]!==F?(I=[n,F],t[15]=n,t[16]=F,t[17]=I):I=t[17],(0,_.useEffect)(P,I),!r||!k)return null;let L;t[18]!==N||t[19]!==r||t[20]!==E||t[21]!==k.description||t[22]!==S?(L=()=>{if(!N)return;let e=p(r,E);S({goal:E.goal.trim()||k.description,input:e,concurrency:E.concurrency.trim()?Number(E.concurrency):void 0,maxSubagents:E.maxSubagents.trim()?Number(E.maxSubagents):void 0})},t[18]=N,t[19]=r,t[20]=E,t[21]=k.description,t[22]=S,t[23]=L):L=t[23];let R=L,z;t[24]===x?z=t[25]:(z=e=>!e&&x(),t[24]=x,t[25]=z);let B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,v.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[26]=B):B=t[26];let V;t[27]!==r.title||t[28]!==w.startTitle?(V=(0,v.jsxs)(l,{className:`text-base font-semibold text-fg`,children:[w.startTitle,` · `,r.title]}),t[27]=r.title,t[28]=w.startTitle,t[29]=V):V=t[29];let H;t[30]===k.description?H=t[31]:(H=(0,v.jsx)(c,{className:`mt-1 text-sm text-fg-muted`,children:k.description}),t[30]=k.description,t[31]=H);let U;t[32]!==V||t[33]!==H?(U=(0,v.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[V,H]}),t[32]=V,t[33]=H,t[34]=U):U=t[34];let W;t[35]!==r.id||t[36]!==r.name||t[37]!==r.title||t[38]!==k.description?(W={context:{surface:`workflow-start`,workflowId:r.id,workflowName:r.name,workflowTitle:r.title,workflowDescription:k.description}},t[35]=r.id,t[36]=r.name,t[37]=r.title,t[38]=k.description,t[39]=W):W=t[39];let G;t[40]!==r||t[41]!==E||t[42]!==w.readyToStart||t[43]!==y||t[44]!==W?(G=(0,v.jsx)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-auto px-5 py-4`,children:(0,v.jsx)(h,{definition:r,language:y,value:E,onChange:D,mode:`manual`,badgeLabel:w.readyToStart,aiAssist:W})}),t[40]=r,t[41]=E,t[42]=w.readyToStart,t[43]=y,t[44]=W,t[45]=G):G=t[45];let K;t[46]!==N||t[47]!==w.inputRequiredHint?(K=N?null:(0,v.jsx)(`div`,{className:`mr-auto self-center text-xs text-fg-subtle`,children:w.inputRequiredHint}),t[46]=N,t[47]=w.inputRequiredHint,t[48]=K):K=t[48];let q;t[49]!==w.cancelDialog||t[50]!==x||t[51]!==b?(q=(0,v.jsx)(o,{variant:`secondary`,onClick:x,disabled:b,children:w.cancelDialog}),t[49]=w.cancelDialog,t[50]=x,t[51]=b,t[52]=q):q=t[52];let J=!N,Y=b?w.starting:w.start,X;t[53]!==R||t[54]!==J||t[55]!==Y?(X=(0,v.jsx)(o,{variant:`primary`,onClick:R,disabled:J,children:Y}),t[53]=R,t[54]=J,t[55]=Y,t[56]=X):X=t[56];let Z;t[57]!==K||t[58]!==q||t[59]!==X?(Z=(0,v.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[K,q,X]}),t[57]=K,t[58]=q,t[59]=X,t[60]=Z):Z=t[60];let Q;t[61]!==U||t[62]!==G||t[63]!==Z?(Q=(0,v.jsxs)(f,{children:[B,(0,v.jsxs)(d,{className:`fixed left-1/2 top-1/2 z-66 flex max-h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[U,G,Z]})]}),t[61]=U,t[62]=G,t[63]=Z,t[64]=Q):Q=t[64];let $;return t[65]!==n||t[66]!==z||t[67]!==Q?($=(0,v.jsx)(s,{open:n,onOpenChange:z,children:Q}),t[65]=n,t[66]=z,t[67]=Q,t[68]=$):$=t[68],$}function ee(e){let t=e.trim();if(!t)return!0;let n=Number(t);return Number.isInteger(n)&&n>0}export{y as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-BXNELNBa.js";import{$ as a,Ga as o,Ja as s,Ka as c,Wa as l,Ya as u,ko as d,qa as f}from"./index-DcUaXYeb.js";import{n as p,r as m,t as h}from"./workflow-run-setup-panel-CL_rnAUB.js";var g=n(),_=e(t(),1),v=r();function y(e){let t=(0,g.c)(69),{open:n,definition:r,language:y,starting:b,onClose:x,onStart:S}=e,C;t[0]===y?C=t[1]:(C=i(y),t[0]=y,t[1]=C);let w=C.workflows,T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T={goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},t[2]=T):T=t[2];let[E,D]=(0,_.useState)(T),O;t[3]!==r||t[4]!==y?(O=r?a(r,y):null,t[3]=r,t[4]=y,t[5]=O):O=t[5];let k=O,A;t[6]!==r||t[7]!==E?(A=m(r,E),t[6]=r,t[7]=E,t[8]=A):A=t[8];let j=A,M;t[9]!==E.concurrency||t[10]!==E.maxSubagents?(M=[E.concurrency,E.maxSubagents].every(ee),t[9]=E.concurrency,t[10]=E.maxSubagents,t[11]=M):M=t[11];let te=M,N=j.valid&&te&&!b,P;t[12]!==r||t[13]!==n?(P=()=>{!n||!r||D({goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``})},t[12]=r,t[13]=n,t[14]=P):P=t[14];let F=r?.id,I;if(t[15]!==n||t[16]!==F?(I=[n,F],t[15]=n,t[16]=F,t[17]=I):I=t[17],(0,_.useEffect)(P,I),!r||!k)return null;let L;t[18]!==N||t[19]!==r||t[20]!==E||t[21]!==k.description||t[22]!==S?(L=()=>{if(!N)return;let e=p(r,E);S({goal:E.goal.trim()||k.description,input:e,concurrency:E.concurrency.trim()?Number(E.concurrency):void 0,maxSubagents:E.maxSubagents.trim()?Number(E.maxSubagents):void 0})},t[18]=N,t[19]=r,t[20]=E,t[21]=k.description,t[22]=S,t[23]=L):L=t[23];let R=L,z;t[24]===x?z=t[25]:(z=e=>!e&&x(),t[24]=x,t[25]=z);let B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,v.jsx)(c,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[26]=B):B=t[26];let V;t[27]!==r.title||t[28]!==w.startTitle?(V=(0,v.jsxs)(u,{className:`text-base font-semibold text-fg`,children:[w.startTitle,` · `,r.title]}),t[27]=r.title,t[28]=w.startTitle,t[29]=V):V=t[29];let H;t[30]===k.description?H=t[31]:(H=(0,v.jsx)(o,{className:`mt-1 text-sm text-fg-muted`,children:k.description}),t[30]=k.description,t[31]=H);let U;t[32]!==V||t[33]!==H?(U=(0,v.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[V,H]}),t[32]=V,t[33]=H,t[34]=U):U=t[34];let W;t[35]!==r.id||t[36]!==r.name||t[37]!==r.title||t[38]!==k.description?(W={context:{surface:`workflow-start`,workflowId:r.id,workflowName:r.name,workflowTitle:r.title,workflowDescription:k.description}},t[35]=r.id,t[36]=r.name,t[37]=r.title,t[38]=k.description,t[39]=W):W=t[39];let G;t[40]!==r||t[41]!==E||t[42]!==w.readyToStart||t[43]!==y||t[44]!==W?(G=(0,v.jsx)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-auto px-5 py-4`,children:(0,v.jsx)(h,{definition:r,language:y,value:E,onChange:D,mode:`manual`,badgeLabel:w.readyToStart,aiAssist:W})}),t[40]=r,t[41]=E,t[42]=w.readyToStart,t[43]=y,t[44]=W,t[45]=G):G=t[45];let K;t[46]!==N||t[47]!==w.inputRequiredHint?(K=N?null:(0,v.jsx)(`div`,{className:`mr-auto self-center text-xs text-fg-subtle`,children:w.inputRequiredHint}),t[46]=N,t[47]=w.inputRequiredHint,t[48]=K):K=t[48];let q;t[49]!==w.cancelDialog||t[50]!==x||t[51]!==b?(q=(0,v.jsx)(d,{variant:`secondary`,onClick:x,disabled:b,children:w.cancelDialog}),t[49]=w.cancelDialog,t[50]=x,t[51]=b,t[52]=q):q=t[52];let J=!N,Y=b?w.starting:w.start,X;t[53]!==R||t[54]!==J||t[55]!==Y?(X=(0,v.jsx)(d,{variant:`primary`,onClick:R,disabled:J,children:Y}),t[53]=R,t[54]=J,t[55]=Y,t[56]=X):X=t[56];let Z;t[57]!==K||t[58]!==q||t[59]!==X?(Z=(0,v.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[K,q,X]}),t[57]=K,t[58]=q,t[59]=X,t[60]=Z):Z=t[60];let Q;t[61]!==U||t[62]!==G||t[63]!==Z?(Q=(0,v.jsxs)(f,{children:[B,(0,v.jsxs)(l,{className:`fixed left-1/2 top-1/2 z-66 flex max-h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[U,G,Z]})]}),t[61]=U,t[62]=G,t[63]=Z,t[64]=Q):Q=t[64];let $;return t[65]!==n||t[66]!==z||t[67]!==Q?($=(0,v.jsx)(s,{open:n,onOpenChange:z,children:Q}),t[65]=n,t[66]=z,t[67]=Q,t[68]=$):$=t[68],$}function ee(e){let t=e.trim();if(!t)return!0;let n=Number(t);return Number.isInteger(n)&&n>0}export{y as t};