@tickernelz/wardmote-ui 2026.1114.2 → 2026.1114.3

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 (140) hide show
  1. package/dist/assets/{ActiveAgentsPanel-Budj8e9v.js → ActiveAgentsPanel-CF0fwsze.js} +1 -1
  2. package/dist/assets/{AdapterManager-DhiW44Eo.js → AdapterManager-DUXWwNxv.js} +1 -1
  3. package/dist/assets/{AdvancedToolsRoute-CICI1XRd.js → AdvancedToolsRoute-BamlkE3p.js} +1 -1
  4. package/dist/assets/{AgentActionButtons-DIhpv51Y.js → AgentActionButtons-CPIhsP04.js} +1 -1
  5. package/dist/assets/{AgentBubbleActionRow-DIr3TdR9.js → AgentBubbleActionRow-BUAUmJKa.js} +1 -1
  6. package/dist/assets/{AgentChat-CeuGtMXr.js → AgentChat-BAn_ghsu.js} +1 -1
  7. package/dist/assets/{AgentChats-CmDtTrMa.js → AgentChats-f73hodzr.js} +1 -1
  8. package/dist/assets/{AgentDefaults-DpYaMGkf.js → AgentDefaults-BL1XYvEo.js} +1 -1
  9. package/dist/assets/{AgentDetail-DFTeFc4-.js → AgentDetail-DthxFfuB.js} +1 -1
  10. package/dist/assets/{AgentTodoCard-DRXZ7hmU.js → AgentTodoCard-BvgkWD0T.js} +1 -1
  11. package/dist/assets/{Agents-CClUUMUq.js → Agents-D5qI6yZZ.js} +3 -3
  12. package/dist/assets/{AppDetail-DfHLFOtj.js → AppDetail-B6PtMl8J.js} +1 -1
  13. package/dist/assets/{AppNotConnected-CcmXbFtD.js → AppNotConnected-C_tGn786.js} +1 -1
  14. package/dist/assets/{ApprovalCard-uT_9D_uH.js → ApprovalCard-DrfZAdGQ.js} +1 -1
  15. package/dist/assets/{ApprovalDetail-CE41WFbd.js → ApprovalDetail-sfPpfdXc.js} +1 -1
  16. package/dist/assets/{ApprovalPayload-_zU9bukt.js → ApprovalPayload-C4F3ItGH.js} +1 -1
  17. package/dist/assets/{Approvals-BXrjqpKc.js → Approvals-DZoMl7_m.js} +1 -1
  18. package/dist/assets/{AppsConnect-DH7aSjtS.js → AppsConnect-D8Gu187f.js} +1 -1
  19. package/dist/assets/{AppsReview-C0Y3SxmZ.js → AppsReview-DokFETm0.js} +1 -1
  20. package/dist/assets/{ArtifactCard-DKUUBZ0K.js → ArtifactCard-BTf2-JIV.js} +1 -1
  21. package/dist/assets/{Artifacts-Bsv5m0aU.js → Artifacts-CK8FaygC.js} +1 -1
  22. package/dist/assets/{AssistantConnection-Dm2PaSeU.js → AssistantConnection-BlKC7jk0.js} +1 -1
  23. package/dist/assets/{AttentionInteractionResolver-CBjNuhYo.js → AttentionInteractionResolver-C2iz6oqT.js} +1 -1
  24. package/dist/assets/{AuditHub-DbUni0O_.js → AuditHub-DMhunMn8.js} +1 -1
  25. package/dist/assets/{BoardChat-CgzCuFIL.js → BoardChat-C4W8JLKB.js} +1 -1
  26. package/dist/assets/{BootstrapSetupUxLab-D-niQCV5.js → BootstrapSetupUxLab-D58OwniR.js} +1 -1
  27. package/dist/assets/{Browse-0bmB5mqw.js → Browse-BDjohBak.js} +1 -1
  28. package/dist/assets/{BudgetPolicyCard-CqFUHqOj.js → BudgetPolicyCard-DfAAgk9Z.js} +1 -1
  29. package/dist/assets/{CaseDetail-DakrB2jI.js → CaseDetail-CL0FC5sG.js} +1 -1
  30. package/dist/assets/{Cases-DXbr4HJt.js → Cases-C-7dXrEt.js} +1 -1
  31. package/dist/assets/{ChatEndpointDetail-BdDKo-Gq.js → ChatEndpointDetail-C-IYAYG8.js} +1 -1
  32. package/dist/assets/{ChatEndpointSetup-BX3iDH7N.js → ChatEndpointSetup-CM3QixMj.js} +1 -1
  33. package/dist/assets/{ChoiceControls-Bu-fd6qI.js → ChoiceControls-3Qpci4yE.js} +1 -1
  34. package/dist/assets/{Companies-FcUNLIkt.js → Companies-97toQ8Cw.js} +1 -1
  35. package/dist/assets/{CompanyAccess-BUcTNg7_.js → CompanyAccess-CKhS1BaS.js} +1 -1
  36. package/dist/assets/{CompanyActivity-ScpRBz1G.js → CompanyActivity-DzNrAyAb.js} +1 -1
  37. package/dist/assets/{CompanyConnections-DMEwbZv7.js → CompanyConnections-ORCH4i3U.js} +1 -1
  38. package/dist/assets/{CompanyEnvironments-EqXhVruZ.js → CompanyEnvironments-DphURbtb.js} +1 -1
  39. package/dist/assets/{CompanyExport-DQ9ffuua.js → CompanyExport-XeVCUcK3.js} +1 -1
  40. package/dist/assets/{CompanyImport-BhuZu4oc.js → CompanyImport-DPKpUaRa.js} +1 -1
  41. package/dist/assets/{CompanySettings-BSkg4ahA.js → CompanySettings-4JQpzuS1.js} +1 -1
  42. package/dist/assets/{CompanySettingsPluginPage-BzZkZqh-.js → CompanySettingsPluginPage-cVvXh0_G.js} +1 -1
  43. package/dist/assets/{CompanySkills-BbA4RKIw.js → CompanySkills-BA_9Ztwj.js} +1 -1
  44. package/dist/assets/{ComposerAddMenu-D9z2INup.js → ComposerAddMenu-DNp4ecG8.js} +1 -1
  45. package/dist/assets/{ConfigureBuiltInAgentModal-BUJPbmWc.js → ConfigureBuiltInAgentModal-CQCHDkl4.js} +1 -1
  46. package/dist/assets/{ConnectionSetupFlow-DKjP5RBZ.js → ConnectionSetupFlow-BaarToKu.js} +1 -1
  47. package/dist/assets/{CopyableGatewayUrl-BZyE_jT9.js → CopyableGatewayUrl-DxQsV7Hr.js} +1 -1
  48. package/dist/assets/{Dashboard--lTwxjV-.js → Dashboard--iaPJqJp.js} +1 -1
  49. package/dist/assets/{DashboardLive-BYyTgF5d.js → DashboardLive-4rGeotay.js} +1 -1
  50. package/dist/assets/{DecisionDateChips-vXwAFdua.js → DecisionDateChips-CJOLtNrJ.js} +1 -1
  51. package/dist/assets/{DecisionModelSettings-NrNERkaW.js → DecisionModelSettings-D-OxKIGP.js} +1 -1
  52. package/dist/assets/{DecisionQueuePage-BaaKuZBi.js → DecisionQueuePage-D-kNFav_.js} +1 -1
  53. package/dist/assets/{DesignGuide-DS6MuXWY.js → DesignGuide-D7486q4b.js} +1 -1
  54. package/dist/assets/{DocumentFrameHeader-DTSqcw4Q.js → DocumentFrameHeader-B61HhahB.js} +1 -1
  55. package/dist/assets/{EmailEndpointSetup-CJFYu2G0.js → EmailEndpointSetup-6OHb9B4q.js} +1 -1
  56. package/dist/assets/{ExecutionWorkspaceDetail-CuD5xWOB.js → ExecutionWorkspaceDetail-BGV-9D5Y.js} +1 -1
  57. package/dist/assets/{FolderControls-B7TWghGc.js → FolderControls-L2RzbfdQ.js} +1 -1
  58. package/dist/assets/{GatewayDetail-xNVOxSIs.js → GatewayDetail-CdXNQ9gD.js} +1 -1
  59. package/dist/assets/{GatewaysList-DsSKLm1h.js → GatewaysList-B0Jq1IRC.js} +1 -1
  60. package/dist/assets/{GoalDetail-oN5pyUUY.js → GoalDetail-D2VhPtvw.js} +1 -1
  61. package/dist/assets/{GoalTree-DaFizciF.js → GoalTree-kFpgH4dA.js} +1 -1
  62. package/dist/assets/{Goals-xgGKfQZi.js → Goals-B-_gq_Qu.js} +1 -1
  63. package/dist/assets/{ImageGalleryModal-CjHED0Lb.js → ImageGalleryModal-DzKBMOnu.js} +1 -1
  64. package/dist/assets/{Inbox-wHhHozfr.js → Inbox-zllmqRcB.js} +1 -1
  65. package/dist/assets/{InstanceAdvanced-Bdf2a4c_.js → InstanceAdvanced-B7tDfjwG.js} +1 -1
  66. package/dist/assets/{InviteLanding-McBYpNeW.js → InviteLanding-brwa_8NC.js} +1 -1
  67. package/dist/assets/{IssueChatLongThreadPerf-DD3RLbBo.js → IssueChatLongThreadPerf-D0HJe6IV.js} +1 -1
  68. package/dist/assets/{IssueChatThread-BN-_8hT8.js → IssueChatThread-CMXzuvrF.js} +1 -1
  69. package/dist/assets/{IssueDetail-CsaD311l.js → IssueDetail-DGdg-mB8.js} +1 -1
  70. package/dist/assets/{IssueDocumentAnnotations-BVdH4RTa.js → IssueDocumentAnnotations-BK-LgExc.js} +1 -1
  71. package/dist/assets/{IssueOutputSection-CDIMRaF0.js → IssueOutputSection-aSyiE1pg.js} +1 -1
  72. package/dist/assets/{IssueRecoveryActionCard-C9qJAHes.js → IssueRecoveryActionCard-vAuL_OEC.js} +1 -1
  73. package/dist/assets/{IssueThreadInteractionCard-BbigJB2U.js → IssueThreadInteractionCard-wFidFTIh.js} +1 -1
  74. package/dist/assets/{Issues-BWoc80Y9.js → Issues-CsmM33z_.js} +1 -1
  75. package/dist/assets/{LiveNowTodoLine-B9oTH2L0.js → LiveNowTodoLine-CP32NNp_.js} +1 -1
  76. package/dist/assets/{ManagedAiConnectionDetails-B0aWUPkf.js → ManagedAiConnectionDetails-Ba0awZ-O.js} +1 -1
  77. package/dist/assets/{McpConnect-Dzf7W2K6.js → McpConnect-CYLP1yLX.js} +1 -1
  78. package/dist/assets/{MembershipAction-oiLtxQm3.js → MembershipAction-CKs7Ua9x.js} +1 -1
  79. package/dist/assets/{ModelsAndProviders-BEb4Z38S.js → ModelsAndProviders-gaR7HDQm.js} +1 -1
  80. package/dist/assets/{NewAgent-C3MxIRJj.js → NewAgent-DBQzvxIr.js} +1 -1
  81. package/dist/assets/{OmpAllSettings-DBtL1qDL.js → OmpAllSettings-B_Knr51Z.js} +1 -1
  82. package/dist/assets/{PipelineSettings-BcAtsehE.js → PipelineSettings-Dl-94FB5.js} +1 -1
  83. package/dist/assets/{Pipelines-CkiYUQS-.js → Pipelines-CY9hGe0h.js} +1 -1
  84. package/dist/assets/{PixelsOffice-BSlctoug.js → PixelsOffice-BgyGZsiV.js} +1 -1
  85. package/dist/assets/{PluginPage-C6Qnf9ka.js → PluginPage-CMA4Ei50.js} +1 -1
  86. package/dist/assets/{PluginSettings-Do37r6Zu.js → PluginSettings-Cm4H1JRT.js} +1 -1
  87. package/dist/assets/{ProfileDetailRoute-DRFQNId6.js → ProfileDetailRoute-BEBctbC6.js} +1 -1
  88. package/dist/assets/{ProfileSettings-BMwLBQDB.js → ProfileSettings-Djo7BLIj.js} +1 -1
  89. package/dist/assets/{ProfileWizardRoute-XnnvzH9S.js → ProfileWizardRoute-DxLujEtD.js} +1 -1
  90. package/dist/assets/{ProjectDetail-BW6Lr4Iq.js → ProjectDetail-CmmdvUHn.js} +1 -1
  91. package/dist/assets/{ProjectWorkspaceDetail-DR4JCa1b.js → ProjectWorkspaceDetail-BsA0hJ-k.js} +1 -1
  92. package/dist/assets/{ProjectWorkspacesContent-CadPZn0k.js → ProjectWorkspacesContent-BNNI_WAk.js} +1 -1
  93. package/dist/assets/{Projects-DLBFbxcj.js → Projects-BTAauZr0.js} +1 -1
  94. package/dist/assets/{PublicIssueSharePage-C9yRZOdP.js → PublicIssueSharePage-DdPjfmD9.js} +1 -1
  95. package/dist/assets/{ReviewQueueCard-CIkiY-Lm.js → ReviewQueueCard-BC6VY8Bc.js} +1 -1
  96. package/dist/assets/{RichWorkProductCard-JGHGU_RI.js → RichWorkProductCard-ClpMt_Bh.js} +1 -1
  97. package/dist/assets/{RoutineDetail-izWzADvA.js → RoutineDetail-BT6_GKnC.js} +1 -1
  98. package/dist/assets/{RoutineRunVariablesDialog-DiT_o5Dm.js → RoutineRunVariablesDialog-D_Mls1sV.js} +1 -1
  99. package/dist/assets/{Routines-CHtabiYj.js → Routines-4LevOfvV.js} +1 -1
  100. package/dist/assets/{ScrollToBottom-pyHLjOjY.js → ScrollToBottom-jItsgDR8.js} +1 -1
  101. package/dist/assets/{Search-yNNB6kys.js → Search-bmcm0_m_.js} +1 -1
  102. package/dist/assets/{Secrets-BOyOk5BF.js → Secrets-DfR1fBAZ.js} +1 -1
  103. package/dist/assets/{SkillSourceTree-M58QwBFF.js → SkillSourceTree--FWKWyF3.js} +1 -1
  104. package/dist/assets/{SkillSources-Cw4PU-Bz.js → SkillSources-jUDjqy5i.js} +1 -1
  105. package/dist/assets/{SkillStudio-Cj_M3ZJa.js → SkillStudio-BsqtUnzF.js} +1 -1
  106. package/dist/assets/{SourceTrustBadge-BZBQe5No.js → SourceTrustBadge-CfBrvKL3.js} +1 -1
  107. package/dist/assets/{StatusCards-DaJdQUN5.js → StatusCards-Dt3zorUZ.js} +1 -1
  108. package/dist/assets/{SummarySlotCard-DlSmN6PL.js → SummarySlotCard-D1C0qH2L.js} +1 -1
  109. package/dist/assets/{TaskChatLab-CU5eA7nX.js → TaskChatLab-B0coUvdp.js} +1 -1
  110. package/dist/assets/{TaskChatMarker-wBVUFL3u.js → TaskChatMarker-C40twVjh.js} +1 -1
  111. package/dist/assets/{TaskChatProtocolCard-D-Dwy2EL.js → TaskChatProtocolCard--bi_tc6i.js} +1 -1
  112. package/dist/assets/{TaskChatThreadView-Crlf9I05.js → TaskChatThreadView-DkzFDrLW.js} +1 -1
  113. package/dist/assets/{TaskDetailRelationsPanel-CkktN1EC.js → TaskDetailRelationsPanel-DZGkinoJ.js} +1 -1
  114. package/dist/assets/{TaskTreeControls-B_ulMOi1.js → TaskTreeControls-DznugVpi.js} +1 -1
  115. package/dist/assets/Terminal-NjEb5-2b.js +1 -0
  116. package/dist/assets/TerminalView-DZxK2Ei5.js +58 -0
  117. package/dist/assets/{TrustPresetSection-DTc1Rj4q.js → TrustPresetSection-CjNwNBo3.js} +1 -1
  118. package/dist/assets/{UserProfile-C6q55R0Q.js → UserProfile-Dujv3qdz.js} +1 -1
  119. package/dist/assets/{WhatNeedsMe-1igJA4gL.js → WhatNeedsMe-C9P2EsqQ.js} +1 -1
  120. package/dist/assets/{Workspaces-rtQKliW0.js → Workspaces-BTgSx9nA.js} +1 -1
  121. package/dist/assets/{connection-owner-CZwxTEuM.js → connection-owner-DL4yKhSt.js} +1 -1
  122. package/dist/assets/dist-ypeTPGg_.js +1 -0
  123. package/dist/assets/dropdown-menu-DEO3mF_E.js +1 -0
  124. package/dist/assets/{environment-variables-editor-CCxeFKKk.js → environment-variables-editor-0qgSPgNN.js} +1 -1
  125. package/dist/assets/{index-DDoARkPG.js → index-3AxqhPET.js} +4 -4
  126. package/dist/assets/index-B5bd7Tk6.css +2 -0
  127. package/dist/assets/{issue-properties-lmRBaUTG.js → issue-properties-B1cYnBDU.js} +1 -1
  128. package/dist/assets/{issue-workspace-selection-4JI2Uh9p.js → issue-workspace-selection-S8UgGgK1.js} +1 -1
  129. package/dist/assets/{pipeline-stage-presentation-BSuBql6K.js → pipeline-stage-presentation-5UBw7nsb.js} +1 -1
  130. package/dist/assets/{shared-DDwmHbeD.js → shared-4LF6wQ38.js} +1 -1
  131. package/dist/assets/{tool-taxonomy-DR7Q8sVs.js → tool-taxonomy-B5zpbkHA.js} +1 -1
  132. package/dist/assets/{transcript-adapter-wiFIjKfq.js → transcript-adapter-C29ZJiU2.js} +1 -1
  133. package/dist/assets/{useSummaryDraftStream-CWOQt25o.js → useSummaryDraftStream-R2Y2bAUU.js} +1 -1
  134. package/dist/index.html +7 -6
  135. package/dist/sw.js +1 -1
  136. package/package.json +1 -1
  137. package/dist/assets/Terminal-Bo-WuezO.js +0 -1
  138. package/dist/assets/TerminalView-AkFY5bLC.js +0 -58
  139. package/dist/assets/dropdown-menu-CqRAF7Oj.js +0 -1
  140. package/dist/assets/index-KZ2bEg2H.css +0 -2
@@ -1,2 +1,2 @@
1
- var Se=Object.defineProperty;var n=(a,s)=>Se(a,"name",{value:s,configurable:!0});import{i as xe}from"./rolldown-runtime-ZpX3ckPj.js";import{na as Ce,t as Ie,ta as Pe,tn as oe}from"./createLucideIcon-DJi9suAC.js";import{n as $e,v as ze}from"./star-BZgQbzhV.js";import{X as Re,_ as q,n as Fe,o as Le,r as L,t as M,v as ee}from"./queryKeys-DYV5MhM_.js";import{n as Ue}from"./CompanyContext-CSrVsSze.js";import{an as De,o as Ee,ot as He,t as S}from"./router-2UfGeejU.js";import{i as X,p as Ge,r as Te,t as Ae}from"./dropdown-menu-CqRAF7Oj.js";import{t as Y}from"./check-Ctsrlfa-.js";import{t as Be}from"./circle-alert-C-L4OsHh.js";import{t as qe}from"./ellipsis-vertical-DWXPf6Ow.js";import{t as he}from"./external-link-nl1b263c.js";import{t as Z}from"./file-text-Cw7ntqRx.js";import{r as ce,t as N}from"./button-CMwV3L1P.js";import{t as pe}from"./plus-C6fnr28l.js";import{t as Oe}from"./refresh-cw-B_Oki9wZ.js";import{t as Me}from"./triangle-alert-CBVKiaXB.js";import{a as ue,n as fe,r as ge,s as je,t as ke}from"./dialog-CKUblzlR.js";import{t as _e}from"./input-DobnTAyB.js";import{t as O}from"./github-icon-Bbgf67tg.js";import{n as Ke}from"./BreadcrumbContext-BVZDZoC0.js";import{a as Qe,i as Je,o as Ve,r as We,s as Xe,t as Ye}from"./command-Ca3v36Mu.js";import{t as Ze}from"./app-connect-policy-CUzbEnhU.js";import{$ as es,Q as ss,Z as ts}from"./index-DDoARkPG.js";import{t as is}from"./issue-output-CU3gasZ1.js";import{r as ns}from"./company-skill-routes-D5LJ1l8M.js";import{t as as}from"./SkillSourceTree-M58QwBFF.js";import{n as rs,t as ls}from"./skill-source-connect-return-C3vV7DQP.js";var be={name:"file-image",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]};be.node;var os=Ie(be),k=xe(Ce(),1),z=n(a=>`/companies/${a}/skill-sources`,"base"),U={list:n(a=>L.get(z(a)),"list"),repositories:n(a=>L.get(`${z(a)}/repositories`),"repositories"),discover:n((a,s)=>L.post(`${z(a)}/discover`,s),"discover"),discoverStream:n(async(a,s,p,r)=>{const b=await Le(`${z(a)}/discover`,{method:"POST",body:JSON.stringify(s),headers:{Accept:"application/x-ndjson"},signal:r});if(!b.body||!b.headers.get("Content-Type")?.includes("application/x-ndjson"))throw new Error("Live scan unavailable. Refresh the page and try again.");const u=b.body.getReader(),o=new TextDecoder;let l="";try{for(;;){r?.throwIfAborted();const{value:x,done:h}=await u.read();r?.throwIfAborted(),l+=o.decode(x,{stream:!h});let v;for(;(v=l.indexOf(`
1
+ var Se=Object.defineProperty;var n=(a,s)=>Se(a,"name",{value:s,configurable:!0});import{i as xe}from"./rolldown-runtime-ZpX3ckPj.js";import{na as Ce,t as Ie,ta as Pe,tn as oe}from"./createLucideIcon-DJi9suAC.js";import{n as $e,v as ze}from"./star-BZgQbzhV.js";import{X as Re,_ as q,n as Fe,o as Le,r as L,t as M,v as ee}from"./queryKeys-DYV5MhM_.js";import{n as Ue}from"./CompanyContext-CSrVsSze.js";import{an as De,o as Ee,ot as He,t as S}from"./router-2UfGeejU.js";import{i as X,p as Ge,r as Te,t as Ae}from"./dropdown-menu-DEO3mF_E.js";import{t as Y}from"./check-Ctsrlfa-.js";import{t as Be}from"./circle-alert-C-L4OsHh.js";import{t as qe}from"./ellipsis-vertical-DWXPf6Ow.js";import{t as he}from"./external-link-nl1b263c.js";import{t as Z}from"./file-text-Cw7ntqRx.js";import{r as ce,t as N}from"./button-CMwV3L1P.js";import{t as pe}from"./plus-C6fnr28l.js";import{t as Oe}from"./refresh-cw-B_Oki9wZ.js";import{t as Me}from"./triangle-alert-CBVKiaXB.js";import{a as ue,n as fe,r as ge,s as je,t as ke}from"./dialog-CKUblzlR.js";import{t as _e}from"./input-DobnTAyB.js";import{t as O}from"./github-icon-Bbgf67tg.js";import{n as Ke}from"./BreadcrumbContext-BVZDZoC0.js";import{a as Qe,i as Je,o as Ve,r as We,s as Xe,t as Ye}from"./command-Ca3v36Mu.js";import{t as Ze}from"./app-connect-policy-CUzbEnhU.js";import{$ as es,Q as ss,Z as ts}from"./index-3AxqhPET.js";import{t as is}from"./issue-output-CU3gasZ1.js";import{r as ns}from"./company-skill-routes-D5LJ1l8M.js";import{t as as}from"./SkillSourceTree--FWKWyF3.js";import{n as rs,t as ls}from"./skill-source-connect-return-C3vV7DQP.js";var be={name:"file-image",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]};be.node;var os=Ie(be),k=xe(Ce(),1),z=n(a=>`/companies/${a}/skill-sources`,"base"),U={list:n(a=>L.get(z(a)),"list"),repositories:n(a=>L.get(`${z(a)}/repositories`),"repositories"),discover:n((a,s)=>L.post(`${z(a)}/discover`,s),"discover"),discoverStream:n(async(a,s,p,r)=>{const b=await Le(`${z(a)}/discover`,{method:"POST",body:JSON.stringify(s),headers:{Accept:"application/x-ndjson"},signal:r});if(!b.body||!b.headers.get("Content-Type")?.includes("application/x-ndjson"))throw new Error("Live scan unavailable. Refresh the page and try again.");const u=b.body.getReader(),o=new TextDecoder;let l="";try{for(;;){r?.throwIfAborted();const{value:x,done:h}=await u.read();r?.throwIfAborted(),l+=o.decode(x,{stream:!h});let v;for(;(v=l.indexOf(`
2
2
  `))!==-1;){r?.throwIfAborted();const j=l.slice(0,v);if(l=l.slice(v+1),!j.trim())continue;const g=JSON.parse(j);if(g.type==="error")throw new Fe(g.error,g.status,g);if(g.type==="complete")return g.discovery;if(g.type==="progress"||g.type==="candidate")p(g);else throw new Error("Unexpected repository scan response. Try again.")}if(h)throw new Error("Repository scan interrupted. Try again.")}}finally{await u.cancel().catch(()=>{}),u.releaseLock()}},"discoverStream"),preview:n((a,s)=>L.post(`${z(a)}/preview`,s),"preview"),create:n((a,s)=>L.post(z(a),s),"create"),select:n((a,s,p)=>L.patch(`${z(a)}/${s}`,p),"select"),refresh:n((a,s)=>L.post(`${z(a)}/${s}/refresh`,{}),"refresh"),disconnect:n((a,s)=>L.delete(`${z(a)}/${s}`),"disconnect")},e=xe(Pe(),1);function de({repository:a,progress:s,found:p=[],importing:r=!1,count:b=0}){const u=s?.phase??"connecting",o=u==="connecting"||u==="downloading"?0:u==="listing"?1:2,l=u==="downloading"?s?.download:void 0,x=s?.totalSkills,h=!r&&u==="checking"&&x!=null,v=r?`Importing ${b} ${b===1?"skill":"skills"}`:h?`${x} ${x===1?"skill":"skills"} found`:u==="downloading"?l?.stage==="resolving"?"Preparing repository":"Downloading repository":u==="listing"?"Finding skills":"Opening repository",j=r?"Checking package files and saving local copies…":h?`${s?.checkedSkills??0} of ${x} checked`:u==="downloading"?l?`${l.percent}% ${l.stage==="resolving"?"prepared":"received"}${l.receivedBytes?` · ${is(l.receivedBytes)}`:""}`:"Receiving the repository from GitHub…":u==="listing"?"Searching every folder for SKILL.md…":"Connecting to GitHub and resolving the branch…",g=p.slice(-5);return(0,e.jsxs)("section",{className:"skill-import-enter flex min-w-0 flex-col gap-5","aria-label":r?"Import progress":"Repository scan progress",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-3 rounded-lg border border-line bg-bg-3/30 px-3 py-2.5",children:[(0,e.jsx)(O,{className:"size-5 shrink-0 text-ink-3"}),(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:a,children:a})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-bg-3",children:(0,e.jsx)(ce,{className:"size-5 motion-safe:animate-spin text-ink-3","aria-hidden":!0})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",role:"status","aria-live":"polite","aria-atomic":"true",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:v}),(0,e.jsx)("p",{className:"mt-0.5 text-xs text-ink-3",children:j})]})]}),!r&&l?(0,e.jsx)("progress",{className:"skill-import-progress h-1 w-full",value:l.percent,max:100,"aria-label":l.stage==="resolving"?"Preparing repository":"Repository download"}):h&&x>0?(0,e.jsx)("progress",{className:"skill-import-progress h-1 w-full",value:s?.checkedSkills??0,max:x,"aria-label":"Skills checked"}):(0,e.jsx)("div",{className:"h-1 overflow-hidden rounded-full bg-bg-3",role:"progressbar","aria-label":r?"Saving skill snapshots":"Scanning repository",children:(0,e.jsx)("div",{className:"skill-import-sweep h-full rounded-full bg-ink/30"})}),!r&&(0,e.jsx)("ol",{className:"flex items-center justify-between gap-2 text-xs text-ink-3","aria-label":"Scan stages",children:["Download","Find skills","Check files"].map((c,t)=>(0,e.jsxs)("li",{className:`flex items-center gap-1.5 ${t===o?"text-ink":""}`,"aria-current":t===o?"step":void 0,children:[t<o?(0,e.jsx)(Y,{className:"size-3","aria-hidden":!0}):(0,e.jsx)("span",{className:`size-1.5 rounded-full ${t===o?"bg-ink motion-safe:animate-pulse":"bg-ink-3/40"}`}),c]},c))})]}),(0,e.jsxs)("div",{className:"overflow-hidden rounded-lg border border-line bg-bg-3/20",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-line px-3 py-2 text-xs text-ink-3",children:[(0,e.jsx)("span",{children:r?"Selected skills":"Recently checked"}),g.length>0&&(0,e.jsx)("span",{className:"tabular-nums",children:r?`${b} selected`:`${s?.checkedSkills??p.length} checked`})]}),g.length>0?(0,e.jsx)("ul",{className:"divide-y divide-line","aria-label":r?"Skills being imported":"Skills checked so far",children:g.map(c=>(0,e.jsxs)("li",{className:"skill-import-enter flex min-w-0 items-center gap-2.5 px-3 py-2.5",children:[c.error?(0,e.jsx)(Be,{className:"size-4 shrink-0 text-bad","aria-label":"Validation issue"}):r?(0,e.jsx)(Z,{className:"size-4 shrink-0 text-ink-3","aria-hidden":!0}):(0,e.jsx)(Y,{className:"size-4 shrink-0 text-ink-3","aria-hidden":!0}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-baseline gap-2",children:[(0,e.jsx)("span",{className:"truncate text-sm font-medium",children:c.name}),(0,e.jsxs)("span",{className:"shrink-0 text-xs text-ink-3",children:[c.fileCount," ",c.fileCount===1?"file":"files"]})]}),(0,e.jsx)("p",{className:`truncate text-xs ${c.error?"text-bad":"text-ink-3"}`,title:c.error??c.path,children:c.error??c.path})]})]},c.path))}):(0,e.jsx)("div",{className:"flex flex-col gap-3 px-3 py-4","aria-hidden":"true",children:["w-2/3","w-1/2","w-3/4"].map(c=>(0,e.jsxs)("div",{className:"flex items-center gap-3 motion-safe:animate-pulse",children:[(0,e.jsx)(Z,{className:"size-4 text-ink-3/40"}),(0,e.jsx)("span",{className:`${c} h-2 rounded-full bg-bg-3`})]},c))}),(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2 border-t border-line px-3 py-2 text-xs text-ink-3",children:[(0,e.jsx)(ce,{className:"size-3 shrink-0 motion-safe:animate-spin","aria-hidden":!0}),(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate",title:s?.currentPath??void 0,children:r?"Saving complete packages, including scripts and references":s?.currentPath??"Waiting for repository contents…"}),h&&s?.totalFiles!=null&&(0,e.jsxs)("span",{className:"shrink-0 tabular-nums",children:[s.checkedFiles,"/",s.totalFiles," files"]})]})]}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:r?"This may take a moment for larger packages.":"You’ll choose what to import after every package has been checked."})]})}n(de,"SkillImportProgress");function cs({companyId:a,repository:s,commitSha:p,skill:r,initialFile:b,onClose:u}){const o=r.inspection,[l,x]=(0,k.useState)(b??"SKILL.md"),h=ss(Object.fromEntries((o?.files??[]).map(m=>[m.path,null]))).sort((m,P)=>+(P.name==="SKILL.md")-+(m.name==="SKILL.md")),[v,j]=(0,k.useState)(new Set),g=new Set([...es(h,"dir")].filter(m=>!v.has(m))),c=o?.files.find(m=>m.path===l),t=ee({queryKey:M.skillSources.preview(a,s.repositoryUrl,s.connectionId??null,p,r.path,l),queryFn:n(()=>U.preview(a,{...s,commitSha:p,skillPath:r.path,filePath:l}),"queryFn"),enabled:!!(p&&c&&!r.error),retry:!1,staleTime:3e5,refetchOnWindowFocus:!1}),d=r.path.includes("/")?r.path.slice(0,r.path.lastIndexOf("/")):"",C=l==="SKILL.md"?r.path:[d,l].filter(Boolean).join("/"),f=p?`${s.repositoryUrl}/blob/${p}/${C.split("/").map(encodeURIComponent).join("/")}`:s.repositoryUrl;return(0,e.jsx)(ke,{open:!0,onOpenChange:n(m=>{m||u()},"onOpenChange"),children:(0,e.jsxs)(fe,{className:"flex max-h-(--sz-calc-18) flex-col overflow-y-auto p-4 sm:max-w-4xl sm:p-6",children:[(0,e.jsxs)(ue,{children:[(0,e.jsx)(je,{children:r.name}),(0,e.jsxs)(ge,{className:"break-all font-mono text-xs",children:[d||"Repository root","/ · ",o?.files.length??r.fileCount??"?"," files",p?` · ${p.slice(0,8)}`:""]})]}),!o&&(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Refresh this source to inspect its complete package contents."}),r.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:r.error}),o?.requirements&&(0,e.jsxs)("section",{className:"rounded-md border border-line bg-bg-3/30 p-3 text-sm",children:[(0,e.jsx)("h3",{className:"font-medium",children:"Runtime requirements"}),(0,e.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-ink-3",children:o.requirements}),(0,e.jsx)("p",{className:"mt-2 text-xs text-ink-3",children:"Declared by the skill author. Importing does not install dependencies or run scripts."})]}),!!o?.references.length&&(0,e.jsxs)("section",{className:"rounded-md border border-line p-3 text-sm","aria-label":"Package reference warnings",children:[(0,e.jsxs)("h3",{className:"flex items-center gap-2 font-medium",children:[(0,e.jsx)(Me,{className:"size-4"}),"Check references"]}),(0,e.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"These referenced paths are not included. If the skill needs them, fix the source or leave this skill unchecked."}),(0,e.jsx)("ul",{className:"mt-2 space-y-2",children:o.references.map(m=>(0,e.jsxs)("li",{className:"break-all text-xs",children:[(0,e.jsx)("span",{className:"font-mono",children:m.target})," · ",m.kind==="outside_package"?"Outside this package":"Not found",(0,e.jsxs)("span",{className:"text-ink-3",children:[" · referenced in ",m.fromPath]})]},`${m.fromPath}:${m.resolvedPath}`))}),(0,e.jsx)("p",{className:"mt-2 text-xs text-ink-3",children:"Checks cover Markdown links and explicit relative resource paths. They cannot establish every runtime dependency."})]}),!!o?.warnings.length&&(0,e.jsxs)("details",{className:"text-xs text-ink-3",children:[(0,e.jsxs)("summary",{className:"cursor-pointer",children:["Content audit · ",o.warnings.length," ",o.warnings.length===1?"notice":"notices"]}),(0,e.jsx)("ul",{className:"mt-2 space-y-1",children:o.warnings.map(m=>(0,e.jsx)("li",{children:m},m))})]}),o&&(0,e.jsxs)("div",{className:"flex min-h-0 flex-col overflow-hidden rounded-md border border-line md:flex-row",children:[(0,e.jsx)("div",{className:"max-h-48 shrink-0 overflow-auto border-b border-line py-1 md:max-h-(--sz-480px) md:w-56 md:border-b-0 md:border-r",children:(0,e.jsx)(ts,{nodes:h,selectedFile:l,expandedDirs:g,showCheckboxes:!1,wrapLabels:!1,ariaLabel:"Included package files",onSelectFile:x,onToggleDir:n(m=>j(P=>{const D=new Set(P);return D.has(m)?D.delete(m):D.add(m),D}),"onToggleDir")})}),(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-line bg-bg-3/30 px-3 py-2 text-xs",children:[(0,e.jsx)("span",{className:"break-all font-mono",children:l}),c&&(0,e.jsxs)("span",{className:"text-ink-3",children:[c.sizeBytes.toLocaleString()," bytes",c.executable?" · executable":""]})]}),(0,e.jsxs)("div",{className:"max-h-(--sz-480px) min-h-40 overflow-auto p-3",children:[t.isFetching&&(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading preview…"}),t.error&&(0,e.jsxs)("div",{role:"alert",className:"space-y-2 text-sm",children:[(0,e.jsx)("p",{className:"text-bad",children:t.error.message}),(0,e.jsx)(N,{variant:"secondary",size:"sm",onClick:n(()=>{t.refetch()},"onClick"),children:"Try again"})," ",(0,e.jsx)(S,{to:"/apps",className:"underline",children:"Manage GitHub access"})]}),r.error&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Preview unavailable for a package that failed validation."}),t.data?.file.encoding==="base64"&&(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3 py-8 text-sm text-ink-3",children:[(0,e.jsx)(os,{className:"size-6"}),(0,e.jsx)("p",{children:"Binary asset · included without changes"}),(0,e.jsx)("p",{className:"text-xs",children:"Open on GitHub to preview or download this file."})]}),t.data?.content!==null&&t.data?.content!==void 0&&(0,e.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs leading-relaxed",children:t.data.content}),t.data?.truncated&&(0,e.jsx)("p",{className:"mt-3 text-xs text-ink-3",children:"Showing the first 64 KB. The complete file is imported."})]})]})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)(N,{type:"button",variant:"secondary",onClick:u,children:"Back to selection"}),(0,e.jsx)(N,{asChild:!0,variant:"ghost",size:"sm",children:(0,e.jsxs)("a",{href:f,target:"_blank",rel:"noreferrer",children:["Open on GitHub",(0,e.jsx)(he,{className:"size-3.5"})]})})]})]})})}n(cs,"SkillPackagePreview");var me=n(a=>M.skillSources.all(a),"sourceKey");function Ts(){const{selectedCompanyId:a,selectedCompany:s}=Ue(),{sourceId:p}=ze(),r=Ee(),b=Re(),{setBreadcrumbs:u}=Ke(),[o,l]=(0,k.useState)({}),x=a??"";(0,k.useEffect)(()=>{u([{label:"Skills",href:"/skills"},{label:"Sources"}])},[u]);const h=ee({queryKey:me(x),queryFn:n(()=>U.list(x),"queryFn"),enabled:!!x});async function v(){await Promise.all([b.invalidateQueries({queryKey:me(x)}),b.invalidateQueries({queryKey:M.companySkills.list(x)})])}n(v,"invalidate");const j=q({mutationFn:n(t=>U.refresh(x,t),"mutationFn"),onSuccess:n(async t=>{l(d=>({...d,[t.source.id]:t.warnings.join(" · ")})),await v()},"onSuccess"),onError:n((t,d)=>{l(C=>({...C,[d]:t.message})),v()},"onError")}),g=q({mutationFn:n(t=>U.disconnect(x,t),"mutationFn"),onSuccess:v}),c=h.data?.find(t=>t.id===p);return x?(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 p-4 md:p-6",children:[(0,e.jsxs)("header",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-xl font-semibold",children:"Skill sources"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:"Import skills from GitHub and refresh them when you’re ready."})]}),(0,e.jsxs)(N,{onClick:n(()=>r("/skills/sources/new"),"onClick"),children:[(0,e.jsx)(pe,{className:"size-4"}),"Import from GitHub"]})]}),(0,e.jsx)(S,{to:"/skills",className:"text-sm text-ink-3 hover:text-ink",children:"Installed skills"}),h.isPending&&(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading sources…"}),h.error&&(0,e.jsxs)("p",{role:"alert",className:"text-sm text-bad",children:[h.error.message," ",(0,e.jsx)(N,{variant:"ghost",size:"sm",onClick:n(()=>{h.refetch()},"onClick"),children:"Try again"})]}),g.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:g.error.message}),h.data?.length===0&&(0,e.jsxs)("div",{className:"flex flex-col items-start gap-3 py-8",children:[(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["No repositories added yet. Import your skills to make them available in ",s?.name??"this company","."]}),(0,e.jsx)(N,{variant:"secondary",onClick:n(()=>r("/skills/sources/new"),"onClick"),children:"Import from GitHub"})]}),(0,e.jsx)("div",{className:"divide-y divide-line",children:h.data?.map(t=>{const d=t.entries.filter(f=>f.skillId),C=t.entries.filter(f=>f.selection==="new"&&f.present).length;return(0,e.jsxs)("section",{className:"flex flex-col gap-3 py-4","aria-label":t.fullName,children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,e.jsx)(O,{className:"size-5 shrink-0 text-ink-3"}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("a",{href:t.repositoryUrl,target:"_blank",rel:"noreferrer",title:t.fullName,className:"block truncate rounded-sm text-sm font-medium hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:t.fullName}),!t.enabled&&(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Disconnected"}),j.isPending&&j.variables===t.id&&(0,e.jsx)("p",{role:"status",className:"text-xs text-ink-3",children:"Refreshing…"}),C>0&&(0,e.jsxs)(S,{to:`/skills/sources/${t.id}`,className:"text-xs underline",children:[C," new ",C===1?"skill":"skills"," available"]})]})]}),(0,e.jsxs)(Ae,{children:[(0,e.jsx)(Ge,{asChild:!0,children:(0,e.jsx)(N,{size:"icon-sm",variant:"ghost",className:"shrink-0","aria-label":`More actions for ${t.fullName}`,children:(0,e.jsx)(qe,{className:"size-4"})})}),(0,e.jsxs)(Te,{align:"end",children:[(0,e.jsx)(X,{disabled:!t.enabled||j.isPending,onSelect:n(()=>j.mutate(t.id),"onSelect"),children:j.isPending&&j.variables===t.id?"Refreshing…":"Refresh"}),(0,e.jsx)(X,{onSelect:n(()=>r(`/skills/sources/${t.id}`),"onSelect"),children:"Select skills"}),(0,e.jsx)(X,{variant:"destructive",disabled:!t.enabled||g.isPending,onSelect:n(()=>g.mutate(t.id),"onSelect"),children:"Disconnect source"})]})]})]}),d.length>0&&(0,e.jsx)("ul",{className:"ml-8 min-w-0","aria-label":`Installed skills from ${t.fullName}`,children:d.map(f=>(0,e.jsx)("li",{children:(0,e.jsxs)(S,{to:ns(f.skillId),title:f.path,className:"group flex min-w-0 items-center gap-2 rounded-sm py-1 text-sm hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:[(0,e.jsx)(Z,{className:"size-3.5 shrink-0 text-ink-3"}),(0,e.jsx)("span",{className:"truncate font-medium group-hover:underline",children:f.name}),f.description&&(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-ink-3",children:f.description})]})},f.id))}),o[t.id]&&(0,e.jsx)("p",{role:"status",className:"text-xs text-ink-3",children:o[t.id]}),t.lastError&&t.lastAttemptAt&&(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Last attempt ",De(t.lastAttemptAt)]}),t.lastError&&(0,e.jsxs)("p",{role:"alert",className:"text-sm text-bad",children:[t.lastError," ",(0,e.jsx)(S,{to:`/skills/sources/${t.id}`,className:"underline",children:"Review source"})]}),t.connectionId&&(0,e.jsx)(S,{to:`/apps/${t.connectionId}/permissions`,className:"text-xs text-ink-3 hover:text-ink",children:"Manage GitHub connection"})]},t.id)})}),p&&(p==="new"||c)&&(0,e.jsx)(ds,{companyId:x,source:c,onClose:n(()=>r("/skills/sources"),"onClose"),onSaved:n(async t=>{l(d=>({...d,[t.source.id]:t.warnings.join(" · ")})),await v(),r("/skills/sources")},"onSaved")},`${x}:${p}`),p&&p!=="new"&&h.isSuccess&&!c&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"Source not found."})]}):(0,e.jsx)("p",{className:"p-6 text-sm text-ink-3",children:"Select a company to manage skill sources."})}n(Ts,"SkillSources");function ds({companyId:a,source:s,onClose:p,onSaved:r}){const b=`wardmote.skill-source-draft:${a}:${s?.id??"new"}`,[u]=(0,k.useState)(s?.revision),[o]=(0,k.useState)(()=>{try{const i=JSON.parse(sessionStorage.getItem(b)??"{}");return!s||i.revision===s.revision?i:{}}catch{return{}}}),[l,x]=(0,k.useState)(o.repositoryUrl??s?.repositoryUrl??""),[h,v]=(0,k.useState)(o.showRepositoryUrl??!!o.repositoryUrl),[j,g]=(0,k.useState)("connectionId"in o?o.connectionId:s?.connectionId??null),[c,t]=(0,k.useState)(null),[d,C]=(0,k.useState)(o.discovery??null),[f,m]=(0,k.useState)(()=>new Set(o.selectedPaths??(s?s.entries.filter(i=>i.selection!=="excluded").map(i=>i.path):[]))),[P,D]=(0,k.useState)(o.excludedFolders??s?.excludedFolders??[]),y=ee({queryKey:M.skillSources.repositories(a),queryFn:n(()=>U.repositories(a),"queryFn"),refetchOnMount:"always",retry:!1}),R=y.data?.repositories??[],se=oe(l),te=R.find(i=>oe(i.url)?.repositoryUrl===se?.repositoryUrl),ie=te?.connectionIds??[],_=j&&ie.includes(j)?j:ie[0]??null,ne=_??s?.connectionId??null,H=Ze("github"),G=n(()=>rs(a,s?.id??"new"),"rememberReturn");(0,k.useEffect)(()=>{ls(a)},[a]),(0,k.useEffect)(()=>{sessionStorage.setItem(b,JSON.stringify({revision:u,repositoryUrl:l,showRepositoryUrl:h,connectionId:j,discovery:d,selectedPaths:[...f],excludedFolders:P}))},[b,u,l,h,j,d,f,P]);const E=(0,k.useRef)(null),[Ne,K]=(0,k.useState)(null),[ve,Q]=(0,k.useState)([]);(0,k.useEffect)(()=>()=>{E.current?.abort()},[]);const w=q({mutationFn:n(async()=>{const i=new AbortController;E.current?.abort(),E.current=i,K(null),Q([]);const $=await U.discoverStream(a,{repositoryUrl:l,connectionId:_},B=>{i.signal.aborted||E.current!==i||(B.type==="progress"?K(B):Q(ye=>[...ye.filter(we=>we.path!==B.candidate.path),B.candidate].slice(-5)))},i.signal);return{discovery:$,connectionId:$.connectionId===void 0?_:$.connectionId,controller:i}},"mutationFn"),onSuccess:n(i=>{i.controller.signal.aborted||E.current!==i.controller||(C(i.discovery),g(i.connectionId),m(new Set(i.discovery.candidates.map($=>$.path))),D([]))},"onSuccess")}),I=q({mutationFn:n(()=>s?U.select(a,s.id,{revision:u,selectedPaths:[...f],excludedFolders:P,connectionId:ne}):U.create(a,{repositoryUrl:d.repositoryUrl,trackingRef:d.trackingRef,commitSha:d.commitSha,connectionId:j,selectedPaths:[...f],excludedFolders:P}),"mutationFn"),onSuccess:n(async i=>{sessionStorage.removeItem(b),await r(i)},"onSuccess")}),T=s?s.entries.map(i=>({...i,note:i.present?i.selection==="new"?"New skill":i.skillId?"Already imported":void 0:"Removed from source · installed copy retained"})):d?.candidates??[],A=!!(s||d),J=T.filter(i=>f.has(i.path)&&!i.error).length,V=T.filter(i=>f.has(i.path)&&i.error).length,F=w.isPending||I.isPending,ae=(w.error?.name==="AbortError"?null:w.error)??I.error;function re(){E.current?.abort(),E.current=null,w.reset(),K(null),Q([])}n(re,"stopScan");function W(){C(null),w.reset(),I.reset()}n(W,"clearScan");function le(){re(),sessionStorage.removeItem(b),p()}return n(le,"dismiss"),(0,e.jsx)(ke,{open:!0,onOpenChange:n(i=>{!i&&!I.isPending&&le()},"onOpenChange"),children:(0,e.jsxs)(fe,{className:"flex max-h-(--sz-calc-18) flex-col overflow-y-auto p-4 sm:max-w-2xl sm:p-6","aria-describedby":s?"source-description":void 0,children:[(0,e.jsxs)(ue,{children:[(0,e.jsx)(je,{children:s?s.fullName:"Import from GitHub"}),s&&(0,e.jsx)(ge,{id:"source-description",children:"Choose the skills to keep synced. Unchecked skills stay installed."})]}),!A&&!w.isPending&&(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[R.length>0&&(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:[R.length," ",R.length===1?"repository":"repositories"]}),(0,e.jsx)(N,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Refresh repositories",title:"Refresh repositories",disabled:F||y.isFetching,onClick:n(()=>{y.refetch()},"onClick"),children:(0,e.jsx)(Oe,{className:y.isFetching?"size-3 animate-spin":"size-3"})})]}),(0,e.jsx)(N,{asChild:!0,variant:"secondary",size:"sm",children:(0,e.jsxs)(S,{onClick:G,to:H,children:[(0,e.jsx)(pe,{className:"size-4"}),"Add repos"]})})]}),y.isPending&&(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading your GitHub repositories…"}),R.length>0&&(0,e.jsxs)(Ye,{className:"h-auto border border-line",label:"Source repositories",children:[(0,e.jsx)(Qe,{placeholder:"Search repositories…","aria-label":"Search repositories",disabled:F}),(0,e.jsxs)(Xe,{className:"max-h-48",children:[(0,e.jsx)(We,{children:"No matching repositories."}),(0,e.jsx)(Je,{children:R.map(i=>(0,e.jsxs)(Ve,{value:i.fullName,keywords:i.connections,disabled:F,onSelect:n(()=>{x(i.url),W()},"onSelect"),children:[(0,e.jsx)(O,{className:"size-4 shrink-0"}),(0,e.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,e.jsx)("span",{className:"block truncate",children:i.fullName}),(0,e.jsx)("span",{className:"block truncate text-xs text-ink-3",children:i.connections.join(" · ")})]}),i.private&&(0,e.jsx)($e,{className:"size-3 shrink-0 text-ink-3","aria-label":"Private repository"}),te?.id===i.id&&(0,e.jsx)(Y,{className:"size-4 shrink-0","aria-label":"Selected repository"})]},i.id))})]})]}),(y.error||!!y.data?.failedConnectionCount)&&(0,e.jsxs)("p",{role:"alert",className:"text-xs text-bad",children:[R.length?"Some GitHub connections could not load repositories.":"Could not load GitHub repositories."," ",(0,e.jsx)(N,{variant:"ghost",size:"sm",disabled:y.isFetching,onClick:n(()=>{y.refetch()},"onClick"),children:"Try again"}),(0,e.jsx)(S,{to:"/apps",className:"underline",children:"Manage connections"})]}),!y.isPending&&R.length===0&&(0,e.jsx)(N,{asChild:!0,variant:"secondary",className:"h-28 w-full flex-col gap-3 whitespace-normal text-center",children:(0,e.jsxs)(S,{onClick:G,to:H,children:[(0,e.jsx)(O,{className:"size-6"}),"Connect GitHub to see your repos"]})}),(0,e.jsx)(N,{type:"button",variant:"link",size:"sm",className:"h-auto self-end p-0 text-xs font-normal underline",disabled:F,"aria-expanded":h,"aria-controls":"source-repository-url",onClick:n(()=>v(!0),"onClick"),children:"... or add public repo by URL"})]}),h&&(0,e.jsxs)("label",{id:"source-repository-url",className:"flex flex-col gap-2 text-sm",children:["Repository URL",(0,e.jsx)(_e,{autoFocus:!0,value:l,onChange:n(i=>{x(i.target.value),W()},"onChange"),placeholder:"https://github.com/owner/repository",disabled:F})]})]}),A&&!I.isPending&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs text-ink-3",children:[!s&&(0,e.jsx)("span",{className:"break-all",children:d?.fullName}),(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,e.jsx)(He,{className:"size-3.5"}),(0,e.jsx)("span",{className:"font-mono",children:s?.trackingRef==="HEAD"?"Default branch":s?.trackingRef??d?.trackingRef})]}),(0,e.jsxs)("a",{href:s?.repositoryUrl??d?.repositoryUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 hover:text-ink",children:["View on GitHub",(0,e.jsx)(he,{className:"size-3"})]})]}),s?.lastError&&(0,e.jsxs)("p",{role:"alert",className:"text-sm text-bad",children:[s.lastError," ",(0,e.jsx)(S,{onClick:G,to:s.connectionId?`/apps/${s.connectionId}/permissions`:H,className:"underline",children:"Manage GitHub connection"})]}),A&&!I.isPending&&(0,e.jsx)(as,{onPreview:n((i,$)=>t({skill:i,filePath:$}),"onPreview"),candidates:T,selected:f,excludedFolders:P,onChange:n((i,$)=>{m(i),D($)},"onChange"),disabled:F}),d?.warnings.map(i=>(0,e.jsx)("p",{className:"text-xs text-ink-3",children:i},i)),V>0&&(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:[V," selected ",V===1?"skill has":"skills have"," validation errors and will be skipped."]}),ae&&(0,e.jsxs)("p",{role:"alert",className:"text-sm text-bad",children:[ae.message," ",(0,e.jsx)(S,{onClick:G,to:H,className:"underline",children:"Connect a GitHub account"})]}),w.isPending&&(0,e.jsx)(de,{repository:se?.fullName??l,progress:Ne,found:ve}),I.isPending&&(0,e.jsx)(de,{importing:!0,repository:s?.fullName??d.fullName,count:J,found:T.filter(i=>f.has(i.path)&&!i.error).map(i=>({...i,fileCount:i.inspection?.files.length??1}))}),(0,e.jsxs)("footer",{className:"flex items-center justify-between gap-3 border-t border-line pt-4",children:[(0,e.jsx)(N,{variant:"ghost",disabled:I.isPending,onClick:n(()=>{w.isPending?re():d&&!s?W():le()},"onClick"),children:w.isPending?"Cancel scan":d&&!s?"Back":"Cancel"}),A?(0,e.jsx)(N,{disabled:F||!s&&f.size===0,onClick:n(()=>I.mutate(),"onClick"),children:I.isPending?"Saving…":s?"Save selection":`Import ${J} ${J===1?"skill":"skills"}`}):(0,e.jsx)(N,{disabled:F||y.isPending||!l.trim(),onClick:n(()=>w.mutate(),"onClick"),children:w.isPending?"Scanning…":"Find skills"})]}),c&&(0,e.jsx)(cs,{companyId:a,repository:{repositoryUrl:s?.repositoryUrl??d.repositoryUrl,connectionId:s?ne:j},commitSha:c.skill.inspection?.commitSha??s?.lastScanCommit??d?.commitSha??null,skill:c.skill,initialFile:c.filePath,onClose:n(()=>t(null),"onClose")},`${c.skill.path}:${c.filePath??""}`)]})})}n(ds,"SourceDialog");export{Ts as SkillSources};
@@ -1,4 +1,4 @@
1
- var ns=Object.defineProperty;var s=(t,n)=>ns(t,"name",{value:n,configurable:!0});import{i as yt}from"./rolldown-runtime-ZpX3ckPj.js";import{O as ge,ai as as,ci as is,di as ls,f as vt,ii as Nt,l as H,na as rs,oi as wt,ri as it,si as lt,t as St,ta as os,ui as Ie}from"./createLucideIcon-DJi9suAC.js";import{h as cs,v as ds,y as Ct}from"./star-BZgQbzhV.js";import{X as Z,_ as B,t as R,v as Y}from"./queryKeys-DYV5MhM_.js";import{n as us}from"./CompanyContext-CSrVsSze.js";import{lt as Tt,o as Te,t as Fe,zt as ke}from"./router-2UfGeejU.js";import{n as ms,t as xs}from"./collapsible-CqjPlqOa.js";import{a as hs,n as ps,t as fs}from"./avatar-UO226cef.js";import{c as gs,i as Oe,p as Ft,r as At,t as Dt}from"./dropdown-menu-CqRAF7Oj.js";import{t as U}from"./label-BPz3pg9_.js";import{i as oe,n as Me,r as Rt,t as Et}from"./tabs-B2Os_leL.js";import{c as q,t as js}from"./MarkdownEditor-DXD-Cu3u.js";import{o as bs,r as ks,t as ys}from"./popover-BhYHYj7q.js";import{t as vs}from"./arrow-left-Ce_LIut0.js";import{t as Ue}from"./chevron-down-BCvxsWfI.js";import{t as fe}from"./chevron-right-s7L6hXXq.js";import{t as Qe}from"./SearchableSelect-CIJ5K8ih.js";import{t as Ns}from"./AgentIconPicker-D87bSkxE.js";import{t as ws}from"./clock-CzrJT_cP.js";import{r as Ss,t as Ye}from"./MarkdownBody-BTjuUgFa.js";import{t as Pt}from"./copy-_wvZOjTe.js";import{t as Lt}from"./ellipsis-BTiLRUn4.js";import{t as Cs}from"./external-link-nl1b263c.js";import{t as It}from"./file-text-Cw7ntqRx.js";import{t as Ts}from"./flask-conical-CEYKkO5k.js";import{t as Fs}from"./folder-git-2-D2Hz-CeQ.js";import{t as As}from"./info-DXpx_HA2.js";import{r as Ge,t as C}from"./button-CMwV3L1P.js";import{t as Ds}from"./maximize-2-DgliXYEr.js";import{t as Rs,u as Es}from"./IssueThreadInteractionCard-BbigJB2U.js";import{t as Ps}from"./play-CJNuUj69.js";import{t as ce}from"./plus-C6fnr28l.js";import{t as Ls}from"./rotate-ccw-CQEJ4ewP.js";import{t as te}from"./trash-D7zTaHTj.js";import{t as ae}from"./triangle-alert-CBVKiaXB.js";import{t as Mt}from"./users-DyKzwIh4.js";import{t as Is}from"./x-DRDFdlYE.js";import{i as G,n as W,r as je,t as J}from"./tooltip-B5WQ3lq5.js";import{t as ee}from"./badge-DuA2EgZC.js";import{n as de}from"./ToastContext-DMdt9oTd.js";import{t as we}from"./agents-DmlgUVso.js";import{a as ue,i as be,n as me,r as xe,s as he,t as pe}from"./dialog-CKUblzlR.js";import{t as X}from"./input-DobnTAyB.js";import{n as Ms}from"./BreadcrumbContext-BVZDZoC0.js";import{a as $s,i as zs,o as qs,r as _s,s as Ks,t as Bs}from"./command-Ca3v36Mu.js";import{t as Ve}from"./AgentIdentity-I_kB4rMX.js";import{t as ie}from"./textarea-BRPEfJ-g.js";import{n as Os,r as Vs}from"./recent-selections-BnN_nb6Y.js";import{t as Us}from"./attachment-icon-4xDiQblX.js";import{t as Qs}from"./toggle-switch-BHxNtSq9.js";import{t as Ys}from"./clipboard-CTLKYvRL.js";import{t as Gs}from"./use-adapter-capabilities-Bu8XkVZ9.js";import{n as Ws}from"./use-copy-action-D5dEzo6L.js";import{o as Js,r as Xs,t as Ae}from"./card-Bru3x_SJ.js";import{Ea as Hs,Ja as $t,Q as zt,Ra as Zs,Sa as en,T as De,Z as qt,pn as _t,wa as Kt}from"./index-DDoARkPG.js";import{a as tn,c as sn,d as We,i as Je,n as nn,o as an,r as se,s as Xe,t as ln}from"./ImageGalleryModal-CjHED0Lb.js";import{t as rn}from"./FoldCurtain-DUAOdtCt.js";import{a as rt,i as on,n as cn,s as ot,t as Bt}from"./issue-output-CU3gasZ1.js";import{o as dn,r as un,s as mn,t as xn}from"./sheet-jd7y5x4-.js";import{a as ye,c as hn,i as pn,l as fn,n as gn,o as $e,r as jn,s as bn,t as kn}from"./SkillCardIcon-BTCafp8l.js";import{t as He}from"./EntityRow-BIfupmlZ.js";import{t as yn}from"./line-diff-DAcZgvm2.js";import{t as vn}from"./FilterBar-5ta25FCb.js";import{t as Nn}from"./SkillBinaryFile-DNe-MmCv.js";import{a as le,i as wn}from"./company-skill-routes-D5LJ1l8M.js";import{i as Sn,n as Cn,r as Re,t as Tn}from"./CompanySkills-BbA4RKIw.js";import{n as ze,r as Fn,t as ct}from"./resizable-panels-Qjbo0P05.js";import{n as Ot,r as An,t as Dn}from"./IssueOutputSection-CDIMRaF0.js";var Vt={name:"file-plus",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]};Vt.node;var Ze=St(Vt),Ut={name:"folder-minus",size:24,node:[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};Ut.node;var Rn=St(Ut),d=yt(rs(),1),Qt="wardmote:recent-studio-skills";function En(){return Os(Qt)}s(En,"getRecentStudioSkillIds");function Pn(t){Vs(Qt,t)}s(Pn,"trackRecentStudioSkill");var e=yt(os(),1),qe="__latest__";function Ln({companyId:t,skill:n,canManage:a=!0}){const[o,r]=(0,d.useState)(!1),l=n.usedByAgents.length,i=`${l} ${l===1?"agent uses":"agents use"} this skill`;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",onClick:s(()=>r(!0),"onClick"),"aria-label":i,className:H("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors",l>0?"border-line bg-bg-3 text-ink hover:bg-bg-3":"border-line/60 bg-transparent text-ink-3 hover:bg-bg-3/50"),children:[(0,e.jsx)(Mt,{className:"h-3.5 w-3.5","aria-hidden":"true"}),l," ",l===1?"agent":"agents"]}),(0,e.jsx)(In,{open:o,onOpenChange:r,companyId:t,skill:n,canManage:a})]})}s(Ln,"AgentsUsingSkillBadge");function In({open:t,onOpenChange:n,companyId:a,skill:o,canManage:r=!0}){const l=Z(),i=de(),c=Gs(),[u,f]=(0,d.useState)(null),[m,k]=(0,d.useState)(null),h=o.currentVersion!==null,x=Y({queryKey:R.companySkills.versions(a,o.id),queryFn:s(()=>q.versions(a,o.id),"queryFn"),enabled:t&&h}),b=Y({queryKey:R.agents.list(a),queryFn:s(()=>we.list(a),"queryFn"),enabled:t});(0,d.useEffect)(()=>{t||k(null)},[t]);const S=(0,d.useMemo)(()=>[...x.data??[]].sort((p,L)=>L.revisionNumber-p.revisionNumber),[x.data]),D=o.currentVersion?.revisionNumber??null,E=(0,d.useMemo)(()=>new Map(S.map(p=>[p.id,p.revisionNumber])),[S]),j=(0,d.useMemo)(()=>new Map((b.data??[]).map(p=>[p.id,p])),[b.data]),N=(0,d.useMemo)(()=>new Set(o.usedByAgents.map(p=>p.id)),[o.usedByAgents]),w=(0,d.useMemo)(()=>(b.data??[]).filter(p=>!N.has(p.id)&&p.status!=="terminated"&&c(p.adapterType).supportsSkills).sort((p,L)=>p.name.localeCompare(L.name)),[b.data,N,c]),y=B({mutationFn:s(async({agent:p,change:L})=>{const K=o.key,I=await we.skills(p.id,a),M=I.desiredSkillEntries??I.desiredSkills.map(P=>({key:P,versionId:null})),_=[...M.filter(P=>P.key!==K)];if(L.kind!=="remove"){const P=L.kind==="pin"?L.versionId:null;_.push({key:K,versionId:P})}return zn(M,_)?{agentId:p.id,changed:!1}:(await we.syncSkills(p.id,_,"replace",a),{agentId:p.id,changed:!0})},"mutationFn"),onSuccess:s(async({agentId:p})=>{await Promise.all([l.invalidateQueries({queryKey:R.companySkills.detail(a,o.id)}),l.invalidateQueries({queryKey:R.companySkills.list(a)}),l.invalidateQueries({queryKey:R.agents.skills(p)})])},"onSuccess"),onError:s(p=>{const L=p instanceof Error?p.message:"Failed to update agent skills.";i?.pushToast({tone:"error",title:"Update failed",body:L.includes("403")?"You don't have permission to change this agent's skills.":L})},"onError")});async function v(p,L){f(p.id);try{await y.mutateAsync({agent:p,change:L}),k(null)}catch{}finally{f(null)}}s(v,"applyChange");const T=o.usedByAgents,$=T.length;return(0,e.jsx)(pe,{open:t,onOpenChange:n,children:(0,e.jsxs)(me,{className:"max-w-lg",children:[(0,e.jsxs)(ue,{children:[(0,e.jsxs)(he,{children:["Agents using ",o.name]}),(0,e.jsx)(xe,{children:$===0?"No agents have this skill assigned yet.":`${$} ${$===1?"agent has":"agents have"} this skill in their desired set.`})]}),(0,e.jsx)("div",{className:"max-h-80 overflow-y-auto",children:$===0?(0,e.jsx)("div",{className:"rounded-md border border-dashed border-line px-4 py-8 text-center text-sm text-ink-3",children:r?"Add an agent below to assign this skill.":"This skill isn't assigned to any agents."}):(0,e.jsx)("ul",{className:"divide-y divide-line",children:T.map(p=>(0,e.jsx)(Mn,{agent:p,icon:j.get(p.id)?.icon??null,canManage:r,hasVersions:h,versions:S,latestRevision:D,pinnedRevision:p.versionId?E.get(p.versionId)??null:null,busy:u===p.id,confirmingRemove:m===p.id,onRequestRemove:s(()=>k(p.id),"onRequestRemove"),onCancelRemove:s(()=>k(null),"onCancelRemove"),onRemove:s(()=>v(p,{kind:"remove"}),"onRemove"),onPin:s(L=>v(p,{kind:"pin",versionId:L}),"onPin")},p.id))})}),r?(0,e.jsxs)("div",{className:"flex items-center gap-2 border-t border-line pt-3",children:[(0,e.jsx)($n,{agents:w,loading:b.isLoading,disabled:y.isPending,onSelect:s(p=>v(p,{kind:"add"}),"onSelect")}),y.isPending?(0,e.jsx)(Ge,{className:"h-4 w-4 animate-spin text-ink-3","aria-hidden":"true"}):null]}):null]})})}s(In,"AgentsUsingSkillDialog");function Mn({agent:t,icon:n,canManage:a,hasVersions:o,versions:r,latestRevision:l,pinnedRevision:i,busy:c,confirmingRemove:u,onRequestRemove:f,onCancelRemove:m,onRemove:k,onPin:h}){const x=i!==null&&l!==null&&l>i?l-i:0;return(0,e.jsxs)("li",{className:"flex items-center gap-3 py-2.5",children:[(0,e.jsx)(Ns,{icon:n,className:"h-6 w-6 shrink-0 rounded-md text-ink-3"}),(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,e.jsx)(Fe,{to:`/agents/${t.urlKey}/skills`,className:"truncate text-sm font-medium text-ink hover:underline",children:t.name}),(0,e.jsx)("span",{className:"truncate text-(length:--text-micro) uppercase tracking-(--tracking-caps) text-ink-3",children:t.adapterType})]}),(0,e.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-0.5",children:[o?a?(0,e.jsxs)("select",{"aria-label":`${t.name} skill version`,value:t.versionId??qe,disabled:c,onChange:s(b=>h(b.target.value===qe?null:b.target.value),"onChange"),className:"h-8 rounded-md border border-line bg-bg px-2 text-xs text-ink disabled:opacity-60",children:[(0,e.jsxs)("option",{value:qe,children:["Latest",l!==null?` (v${l})`:""]}),r.map(b=>(0,e.jsxs)("option",{value:b.id,children:["v",b.revisionNumber,b.label?` · ${b.label}`:""]},b.id))]}):(0,e.jsx)("span",{className:"text-xs text-ink-3",children:t.versionId?`v${i??"?"}`:`Latest${l!==null?` (v${l})`:""}`}):(0,e.jsx)("span",{className:"text-sm text-ink-3","aria-label":`${t.name} version`,children:"—"}),x>0?(0,e.jsxs)("span",{className:"text-(length:--text-nano) text-amber-500",children:[x," version",x===1?"":"s"," behind latest"]}):null]}),a?u?(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,e.jsx)(C,{variant:"delete",size:"sm",onClick:k,disabled:c,"aria-label":`Confirm removing this skill from ${t.name}`,children:c?(0,e.jsx)(Ge,{className:"h-3.5 w-3.5 animate-spin"}):"Remove"}),(0,e.jsx)(C,{variant:"ghost",size:"sm",onClick:m,disabled:c,children:"Cancel"})]}):(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",onClick:f,disabled:c,className:"shrink-0","aria-label":`Remove this skill from ${t.name}`,children:(0,e.jsx)(te,{className:"h-4 w-4"})}):null]})}s(Mn,"AgentRow");function $n({agents:t,loading:n,disabled:a,onSelect:o}){const r=(0,d.useMemo)(()=>[{id:"agents",options:t.map(l=>({key:l.id,value:l.id,label:l.name,title:l.name,searchText:[l.name,l.adapterType].join(" "),agent:l}))}],[t]);return(0,e.jsx)(Qe,{value:"",groups:r,loading:n,loadingMessage:"Loading agents...",placeholder:"Add agent…",searchPlaceholder:"Search agents...",emptyMessage:"All eligible agents already have this skill.",disabled:a,onValueChange:s((l,i)=>(o(i.agent),{close:!0}),"onValueChange"),triggerClassName:"h-8 w-full justify-start",contentClassName:"w-72",renderValue:s(()=>(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-ink-3",children:[(0,e.jsx)(ce,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Add agent…"]}),"renderValue"),renderOption:s(l=>(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)("span",{className:"truncate",children:l.label}),(0,e.jsx)("span",{className:"truncate text-(length:--text-micro) uppercase tracking-(--tracking-caps) text-ink-3",children:l.agent.adapterType})]}),"renderOption")})}s($n,"AddAgentPicker");function zn(t,n){if(t.length!==n.length)return!1;const a=s(r=>`${r.key}\0${r.versionId??""}`,"encode"),o=new Set(t.map(a));return n.every(r=>o.has(a(r)))}s(zn,"desiredSetsEqual");function qn(t){if(!t)return null;const n=t.trim();return n?/^[0-9a-f]{8,40}$/i.test(n)?n.slice(0,7):n:null}s(qn,"shortSha");function _n(t){switch(t){case"github":return"GitHub";case"skills_sh":return"skills.sh";case"url":return"a URL";case"catalog":return"the catalog";case"local_path":return"a local path";default:return"its source"}}s(_n,"sourceTypeFallbackLabel");function Kn(t){let n=t.replace(/^git@github\.com:/i,"").replace(/^https?:\/\/github\.com\//i,"");n=n.split("#")[0].split("?")[0].replace(/\.git$/i,"");const a=n.split("/").filter(Boolean);return a.length>=2?`${a[0]}/${a[1]}`:null}s(Kn,"githubOwnerRepo");function Bn(t){return t.replace(/^https?:\/\//i,"").replace(/\/+$/,"")}s(Bn,"prettyUrl");function On(t){const n=t.sourceLocator?.trim()??"";return n?t.sourceType==="github"?Kn(n)??n:t.sourceType==="url"?Bn(n):n:_n(t.sourceType)}s(On,"formatForkSourceName");function Vn(t){const n=On(t),a=qn(t.sourceRef);return a?`${n} @ ${a}`:n}s(Vn,"formatLineageLabel");function Un(t){return t.find(n=>n.createdByCurrentActor&&!n.diverged)??null}s(Un,"pickReusableFork");function Qn(t){return t<=0?"No agents currently use this skill":`${t} ${t===1?"agent":"agents"} currently use${t===1?"s":""} this skill`}s(Qn,"agentUsageSentence");function Yn(t){return t.map(n=>n.id)}s(Yn,"reassignTargetIds");function Gn(t){if(!t||typeof t!="object")return!1;const n=t.sourceKind;return typeof n=="string"&&n.trim()==="project_scan"}s(Gn,"isProjectScanSkill");function Wn({companyId:t,skill:n,open:a,onOpenChange:o}){const r=Te(),l=Z(),i=de(),[c,u]=(0,d.useState)(!0),f=(0,d.useMemo)(()=>({skillId:n.id,original:{id:n.id,name:n.name,slug:n.slug,sourceType:n.sourceType,sourceLocator:n.sourceLocator,sourceRef:n.sourceRef},agentUsageCount:n.attachedAgentCount,usedByAgents:n.usedByAgents,existingForks:n.existingForks}),[n]),m=Y({queryKey:R.companySkills.forkPrecheck(t,n.id),queryFn:s(()=>q.forkPrecheck(t,n.id),"queryFn"),enabled:a&&!!(t&&n.id),initialData:f}).data??f,k=m.usedByAgents,h=m.agentUsageCount,x=(0,d.useMemo)(()=>Un(m.existingForks),[m.existingForks]);(0,d.useEffect)(()=>{a&&u(!0)},[a]);const b=B({mutationFn:s(()=>q.fork(t,n.id,{reassignAgentIds:c?Yn(k):[]}),"mutationFn"),onSuccess:s(j=>{l.invalidateQueries({queryKey:R.companySkills.list(t)}),l.invalidateQueries({queryKey:R.companySkills.detail(t,n.id)}),l.invalidateQueries({queryKey:R.agents.list(t)});for(const w of j.reassignments)l.invalidateQueries({queryKey:R.agents.skills(w.agentId)});const N=j.reassignments.length;i?.pushToast({tone:"success",title:"Editing a copy",body:N>0?`Created a copy of ${n.name} and switched ${N} ${N===1?"agent":"agents"} to it.`:`Created a copy of ${n.name}. It's now editable.`}),o(!1),r(le(j.skill.id))},"onSuccess"),onError:s(j=>{i?.pushToast({tone:"error",title:"Couldn't create a copy",body:j instanceof Error?j.message:"The fork request failed."})},"onError")}),S=b.isPending,D=c&&h>0?`Create copy & switch ${h} ${h===1?"agent":"agents"}`:"Create copy",E=s(()=>{x&&(o(!1),r(le(x.id)))},"openExisting");return(0,e.jsx)(pe,{open:a,onOpenChange:s(j=>S?void 0:o(j),"onOpenChange"),children:(0,e.jsxs)(me,{className:"sm:max-w-lg",children:[(0,e.jsxs)(ue,{children:[(0,e.jsxs)(he,{className:"flex items-center gap-2",children:[(0,e.jsx)(Re,{className:"h-4 w-4"}),"Edit a copy of ",n.name]}),(0,e.jsxs)(xe,{children:[n.name," is read-only because it comes from an external source. Creating a fully editable copy in your workspace leaves the original untouched and still updatable."]})]}),x?(0,e.jsxs)("div",{className:"rounded-md border border-accent/40 bg-accent/5 p-3 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-ink",children:"You already have a copy"}),(0,e.jsx)("p",{className:"mt-0.5 text-ink-3",children:"An unedited copy of this skill already exists. Open it instead of making another."}),(0,e.jsx)(C,{type:"button",size:"sm",className:"mt-2",onClick:E,disabled:S,children:"Open your existing copy"})]}):null,(0,e.jsxs)("div",{className:H("rounded-md border p-3",h>0?"border-amber-500/40 bg-amber-500/5":"border-line bg-bg-3/30"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-ink",children:[(0,e.jsx)(Mt,{className:"h-4 w-4 shrink-0"}),(0,e.jsx)("span",{children:Qn(h)})]}),h>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:k.map(j=>(0,e.jsx)("span",{className:"inline-flex items-center rounded-full border border-line bg-bg px-2 py-0.5 text-xs text-ink",children:j.name},j.id))}),(0,e.jsxs)("label",{className:"mt-3 flex items-start justify-between gap-3",children:[(0,e.jsxs)("span",{className:"text-sm",children:[(0,e.jsx)("span",{className:"font-medium text-ink",children:"Switch these agents to the copy"}),(0,e.jsx)("span",{className:"mt-0.5 block text-xs text-ink-3",children:c?"These agents will run your copy instead of the original.":"These agents keep running the original — your copy won't change what they do."})]}),(0,e.jsx)(Qs,{checked:c,onCheckedChange:u,disabled:S,"aria-label":"Switch these agents to the copy"})]})]}):(0,e.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"Nothing is assigned to it, so your copy won't change any agent's behaviour."})]}),(0,e.jsxs)(be,{children:[(0,e.jsx)(C,{type:"button",variant:"ghost",onClick:s(()=>o(!1),"onClick"),disabled:S,children:"Cancel"}),(0,e.jsxs)(C,{type:"button",variant:x?"secondary":"primary",onClick:s(()=>b.mutate(),"onClick"),disabled:S,children:[S?(0,e.jsx)(Ge,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,x?"Create another copy":D]})]})]})})}s(Wn,"ForkSkillDialog");function Jn({companyId:t,forkedFromSkillId:n}){const a=Y({queryKey:R.companySkills.detail(t,n??""),queryFn:s(()=>q.detail(t,n),"queryFn"),enabled:!!(t&&n),staleTime:6e4});if(!n)return null;const o=a.data,r=o?Vn(o):"the original skill";return(0,e.jsxs)(Fe,{to:le(n),className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-line bg-bg-3 px-2.5 py-0.5 text-xs text-ink-3 transition-colors hover:bg-bg-3 hover:text-ink",title:`Forked from ${r}`,children:[(0,e.jsx)(Re,{className:"h-3 w-3 shrink-0"}),(0,e.jsxs)("span",{className:"truncate",children:["Forked from ",(0,e.jsx)("span",{className:"font-medium text-ink",children:r})]})]})}s(Jn,"SkillLineageChip");function Xn({skill:t,onEditACopy:n}){const a=t.sourcePath??t.sourceLabel??"the project working tree";return(0,e.jsxs)("div",{className:"flex flex-wrap items-start gap-2 border-b border-line bg-bg-3/40 px-3 py-2 text-xs text-ink-3",children:[(0,e.jsx)(Fs,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("span",{children:["This skill lives in ",(0,e.jsx)("span",{className:"font-mono text-ink",children:a}),". Saves write to the project working tree and are not committed."]})," ",(0,e.jsx)(C,{type:"button",variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:n,children:"Edit a copy instead"})]})]})}s(Xn,"ProjectScanNotice");function Yt(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}s(Yt,"isScalar");function ve(t){return t==null?"":typeof t=="boolean"?t?"true":"false":String(t)}s(ve,"scalarToText");function Gt(t){return t===""?"":t==="true"?!0:t==="false"?!1:t==="null"||t==="~"?null:/^-?\d+(\.\d+)?$/u.test(t)?Number(t):t}s(Gt,"coerceScalar");function Hn(t){return wt(t)&&Object.values(t).every(Yt)}s(Hn,"isFlatScalarRecord");function dt(t){const n="allowed-tools"in t,a=t.metadata,o="metadata"in t,r=o&&Hn(a),l=r?Object.entries(a).map(([c,u],f)=>({id:`meta-${f}-${c}`,key:c,rawValue:u,text:ve(u),edited:!1})):[],i=as(t).map((c,u)=>{const f=t[c],m=Yt(f);return{id:`unknown-${u}-${c}`,key:c,rawValue:f,text:ve(f),edited:!1,editable:m}});return{hasName:"name"in t,name:typeof t.name=="string"?t.name:ve(t.name),hasDescription:"description"in t,description:typeof t.description=="string"?t.description:ve(t.description),allowedToolsPresent:n,allowedTools:n?Nt(t["allowed-tools"]):[],metadataPresent:o,metadataComplex:o&&!r?a:null,metaRows:l,unknown:i}}s(dt,"buildFormModel");function Zn(t){const n={};for(const a of t){const o=a.key.trim();o&&(n[o]=a.edited?Gt(a.text):a.rawValue)}return n}s(Zn,"scalarRowsToObject");function ut(t){const n={};t.hasName&&(n.name=t.name),t.hasDescription&&(n.description=t.description),t.allowedToolsPresent&&(n["allowed-tools"]=t.allowedTools??[]),t.metadataPresent&&(n.metadata=t.metadataComplex!==null?t.metadataComplex:Zn(t.metaRows));for(const a of t.unknown){const o=a.key.trim();o&&(n[o]=a.editable&&a.edited?Gt(a.text):a.rawValue)}return ls(n)}s(ut,"serializeForm");var ea=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function ta(t,n){const a=[],o=t.name.trim(),r=t.description.trim();return n&&!o&&a.push({field:"name",message:"SKILL.md needs a name."}),o&&!ea.test(o)&&a.push({field:"name",message:"Use lowercase letters, numbers and hyphens."}),n&&!r&&a.push({field:"description",message:"SKILL.md needs a description."}),t.allowedToolsPresent&&t.allowedTools===null&&a.push({field:"allowed-tools",message:"Expected a list — edit in YAML."}),a}s(ta,"collectValidation");function sa(t){return/(^|\/)skill\.md$/i.test(t)}s(sa,"isSkillMarkdown");function na({frontmatterText:t,hasFrontmatter:n,fileName:a,skillSlug:o,readOnly:r=!1,onChange:l,className:i}){const c=sa(a),[u,f]=(0,d.useState)(n),[m,k]=(0,d.useState)(t),h=(0,d.useMemo)(()=>it(t),[t]),[x,b]=(0,d.useState)(()=>dt(h.parsed)),[S,D]=(0,d.useState)(n&&h.canRoundTrip?"fields":"yaml"),[E,j]=(0,d.useState)(!1),N=(0,d.useMemo)(()=>it(m),[m]),w=u&&N.canRoundTrip,y=S==="fields"&&!w?"yaml":S,v=(0,d.useMemo)(()=>y==="fields"?ta(x,c):[],[y,x,c]),T=(0,d.useCallback)((P,O)=>{l({frontmatterText:P,hasFrontmatter:O})},[l]),$=(0,d.useCallback)(P=>{b(P);let O;try{O=ut(P)}catch{return}k(O),T(O,!0)},[T]),p=(0,d.useCallback)(P=>{k(P),T(P,!0)},[T]),L=(0,d.useCallback)(P=>{if(P==="fields"){if(!w)return;b(dt(is(m)))}D(P)},[w,m]),K=(0,d.useCallback)(()=>{const P={hasName:!0,name:c?(o??"").trim():"",hasDescription:c,description:"",allowedToolsPresent:!1,allowedTools:[],metadataPresent:!1,metadataComplex:null,metaRows:[],unknown:[]};f(!0),D("fields"),j(!0),b(P);const O=ut(P);k(O),T(O,!0)},[T,c,o]),I=(0,d.useMemo)(()=>aa(N.parsed),[N.parsed]),M=v.length,_=E?(0,e.jsx)(Ue,{className:"h-4 w-4 shrink-0 text-ink-3","aria-hidden":"true"}):(0,e.jsx)(fe,{className:"h-4 w-4 shrink-0 text-ink-3","aria-hidden":"true"});return(0,e.jsx)(je,{children:(0,e.jsxs)(xs,{open:E,onOpenChange:j,className:H("border-b border-line",i),"data-testid":"frontmatter-panel",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,e.jsxs)("button",{type:"button",onClick:s(()=>j(P=>!P),"onClick"),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left","aria-expanded":E,"aria-controls":"frontmatter-panel-body",children:[_,(0,e.jsx)("span",{className:"text-sm font-medium",children:"Frontmatter"}),!E&&u?(0,e.jsx)("span",{className:"truncate text-xs text-ink-3",children:I}):null,!E&&!u?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"None"}):null]}),u?(0,e.jsx)(Et,{value:y,onValueChange:s(P=>L(P),"onValueChange"),children:(0,e.jsxs)(Rt,{variant:"line",className:"h-7",children:[w?(0,e.jsx)(oe,{value:"fields",className:"px-2 py-0.5 text-xs",children:"Fields"}):(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsx)(oe,{value:"fields",disabled:!0,"aria-disabled":"true",className:"px-2 py-0.5 text-xs opacity-50",children:"Fields"})})}),(0,e.jsx)(W,{className:"max-w-60",children:"Switch to YAML to edit. This frontmatter uses YAML features the form can't safely round-trip (e.g. comments, anchors, or custom ordering). Editing here keeps it byte-for-byte."})]}),(0,e.jsx)(oe,{value:"yaml",className:"px-2 py-0.5 text-xs",children:"YAML"})]})}):r?null:(0,e.jsxs)(C,{variant:"ghost",size:"sm",onClick:K,"data-testid":"add-frontmatter",children:[(0,e.jsx)(ce,{className:"mr-1 h-3.5 w-3.5"}),"Add frontmatter"]}),u&&y==="fields"&&M>0?(0,e.jsxs)(ee,{variant:"outline",className:"gap-1 text-amber-500","data-testid":"frontmatter-warning-chip",children:[(0,e.jsx)(ae,{className:"h-3.5 w-3.5"}),M," ",M===1?"issue":"issues"]}):null]}),(0,e.jsx)(ms,{id:"frontmatter-panel-body",children:u?(0,e.jsx)("div",{className:"px-3 pb-3",children:y==="fields"?(0,e.jsx)(ia,{form:x,validation:v,readOnly:r,onCommit:$}):(0,e.jsx)(oa,{value:m,readOnly:r,canReturnToFields:w,parseError:u&&!N.canRoundTrip&&N.issues.length===0,onChange:p})}):(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-ink-3",children:"This file has no frontmatter."})})]})})}s(na,"FrontmatterPanel");function aa(t){const n=[];typeof t.name=="string"&&t.name.trim()&&n.push(t.name.trim());const a=Nt(t["allowed-tools"]);if(a&&a.length>0&&n.push(`${a.length} ${a.length===1?"tool":"tools"}`),wt(t.metadata)){const o=Object.keys(t.metadata).length;o>0&&n.push(`${o} metadata`)}return n.join(" · ")}s(aa,"buildSummary");function _e(t,n){return t.find(a=>a.field===n)?.message??null}s(_e,"fieldWarning");function mt({message:t}){return(0,e.jsxs)("p",{className:"mt-1 flex items-center gap-1 text-xs text-amber-500",children:[(0,e.jsx)(ae,{className:"h-3.5 w-3.5 shrink-0"}),t]})}s(mt,"FieldWarning");function ia({form:t,validation:n,readOnly:a,onCommit:o}){const r=_e(n,"name"),l=_e(n,"description"),i=_e(n,"allowed-tools");return(0,e.jsxs)("div",{className:"space-y-3 pt-1",children:[t.hasName?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{htmlFor:"fm-name",className:"text-xs text-ink-3",children:"name"}),(0,e.jsx)(X,{id:"fm-name",value:t.name,readOnly:a,"aria-invalid":!!r,onChange:s(c=>o({...t,name:c.target.value}),"onChange"),className:"mt-1"}),r?(0,e.jsx)(mt,{message:r}):null]}):null,t.hasDescription?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{htmlFor:"fm-description",className:"text-xs text-ink-3",children:"description"}),(0,e.jsx)(ie,{id:"fm-description",value:t.description,readOnly:a,rows:3,onChange:s(c=>o({...t,description:c.target.value}),"onChange"),className:"mt-1"}),l?(0,e.jsx)(mt,{message:l}):null]}):null,t.allowedToolsPresent?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{className:"text-xs text-ink-3",children:"allowed-tools"}),t.allowedTools===null?(0,e.jsx)("p",{className:"mt-1 text-xs text-amber-500",children:i??"Expected a list — edit in YAML."}):(0,e.jsx)(ra,{values:t.allowedTools,readOnly:a,placeholder:"Add a tool…",onChange:s(c=>o({...t,allowedTools:c}),"onChange")})]}):null,t.metadataPresent?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{className:"text-xs text-ink-3",children:"metadata"}),t.metadataComplex!==null?(0,e.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"Complex value — edit in YAML."}):(0,e.jsx)(la,{rows:t.metaRows,readOnly:a,onChange:s(c=>o({...t,metaRows:c}),"onChange")})]}):null,t.unknown.map((c,u)=>c.editable?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{htmlFor:`fm-unknown-${c.id}`,className:"text-xs text-ink-3",children:c.key}),(0,e.jsx)(X,{id:`fm-unknown-${c.id}`,value:c.text,readOnly:a,onChange:s(f=>{const m=t.unknown.slice();m[u]={...c,text:f.target.value,edited:!0},o({...t,unknown:m})},"onChange"),className:"mt-1"})]},c.id):(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{className:"text-xs text-ink-3",children:c.key}),(0,e.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"Complex value — edit in YAML."})]},c.id))]})}s(ia,"FieldsForm");function la({rows:t,readOnly:n,onChange:a}){const o=s((i,c)=>{const u=t.slice();u[i]={...u[i],...c,edited:!0},a(u)},"update"),r=s(i=>{a(t.filter((c,u)=>u!==i))},"remove"),l=s(()=>{a([...t,{id:`meta-new-${t.length}-${Date.now()}`,key:"",rawValue:"",text:"",edited:!0}])},"add");return(0,e.jsxs)("div",{className:"mt-1 space-y-1.5",children:[t.map((i,c)=>(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(X,{"aria-label":`Metadata key ${c+1}`,value:i.key,readOnly:n,placeholder:"key",onChange:s(u=>o(c,{key:u.target.value}),"onChange"),className:"h-8 flex-1 font-mono text-xs"}),(0,e.jsx)(X,{"aria-label":`Value for ${i.key||`field ${c+1}`}`,value:i.text,readOnly:n,placeholder:"value",onChange:s(u=>o(c,{text:u.target.value}),"onChange"),className:"h-8 flex-1 text-xs"}),n?null:(0,e.jsx)(C,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0","aria-label":`Remove ${i.key||`field ${c+1}`}`,onClick:s(()=>r(c),"onClick"),children:(0,e.jsx)(te,{className:"h-3.5 w-3.5"})})]},i.id)),n?null:(0,e.jsxs)(C,{variant:"ghost",size:"sm",onClick:l,className:"text-xs",children:[(0,e.jsx)(ce,{className:"mr-1 h-3.5 w-3.5"}),"add field"]})]})}s(la,"MetadataRows");function ra({values:t,readOnly:n,placeholder:a,onChange:o}){const[r,l]=(0,d.useState)(""),i=s(()=>{const c=r.trim();c&&(o([...t,c]),l(""))},"commit");return(0,e.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 rounded-md border border-line px-2 py-1.5",children:[t.map((c,u)=>(0,e.jsxs)(ee,{variant:"secondary",className:"gap-1",children:[c,n?null:(0,e.jsx)("button",{type:"button","aria-label":`Remove ${c}`,onClick:s(()=>o(t.filter((f,m)=>m!==u)),"onClick"),className:"hover:text-ink",children:(0,e.jsx)(Is,{className:"h-3 w-3"})})]},`${c}-${u}`)),n?null:(0,e.jsx)("input",{value:r,placeholder:t.length===0?a:void 0,onChange:s(c=>l(c.target.value),"onChange"),onKeyDown:s(c=>{c.key==="Enter"||c.key===","?(c.preventDefault(),i()):c.key==="Backspace"&&r===""&&t.length>0&&o(t.slice(0,-1))},"onKeyDown"),onBlur:i,"aria-label":"Add tool",className:"min-w-24 flex-1 bg-transparent text-xs outline-none"})]})}s(ra,"ChipInput");function oa({value:t,readOnly:n,canReturnToFields:a,parseError:o,onChange:r}){return(0,e.jsxs)("div",{className:"pt-1",children:[!a&&!o?(0,e.jsxs)("div",{className:"mb-1.5 flex items-start gap-2 rounded-md bg-bg-3/40 px-2 py-1.5 text-xs text-ink-3",children:[(0,e.jsx)(As,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:"Editing raw YAML to preserve formatting the form can't reconstruct."})]}):null,(0,e.jsx)(ie,{value:t,readOnly:n,spellCheck:!1,rows:Math.min(12,Math.max(3,t.split(`
1
+ var ns=Object.defineProperty;var s=(t,n)=>ns(t,"name",{value:n,configurable:!0});import{i as yt}from"./rolldown-runtime-ZpX3ckPj.js";import{O as ge,ai as as,ci as is,di as ls,f as vt,ii as Nt,l as H,na as rs,oi as wt,ri as it,si as lt,t as St,ta as os,ui as Ie}from"./createLucideIcon-DJi9suAC.js";import{h as cs,v as ds,y as Ct}from"./star-BZgQbzhV.js";import{X as Z,_ as B,t as R,v as Y}from"./queryKeys-DYV5MhM_.js";import{n as us}from"./CompanyContext-CSrVsSze.js";import{lt as Tt,o as Te,t as Fe,zt as ke}from"./router-2UfGeejU.js";import{n as ms,t as xs}from"./collapsible-CqjPlqOa.js";import{a as hs,n as ps,t as fs}from"./avatar-UO226cef.js";import{c as gs,i as Oe,p as Ft,r as At,t as Dt}from"./dropdown-menu-DEO3mF_E.js";import{t as U}from"./label-BPz3pg9_.js";import{i as oe,n as Me,r as Rt,t as Et}from"./tabs-B2Os_leL.js";import{c as q,t as js}from"./MarkdownEditor-DXD-Cu3u.js";import{o as bs,r as ks,t as ys}from"./popover-BhYHYj7q.js";import{t as vs}from"./arrow-left-Ce_LIut0.js";import{t as Ue}from"./chevron-down-BCvxsWfI.js";import{t as fe}from"./chevron-right-s7L6hXXq.js";import{t as Qe}from"./SearchableSelect-CIJ5K8ih.js";import{t as Ns}from"./AgentIconPicker-D87bSkxE.js";import{t as ws}from"./clock-CzrJT_cP.js";import{r as Ss,t as Ye}from"./MarkdownBody-BTjuUgFa.js";import{t as Pt}from"./copy-_wvZOjTe.js";import{t as Lt}from"./ellipsis-BTiLRUn4.js";import{t as Cs}from"./external-link-nl1b263c.js";import{t as It}from"./file-text-Cw7ntqRx.js";import{t as Ts}from"./flask-conical-CEYKkO5k.js";import{t as Fs}from"./folder-git-2-D2Hz-CeQ.js";import{t as As}from"./info-DXpx_HA2.js";import{r as Ge,t as C}from"./button-CMwV3L1P.js";import{t as Ds}from"./maximize-2-DgliXYEr.js";import{t as Rs,u as Es}from"./IssueThreadInteractionCard-wFidFTIh.js";import{t as Ps}from"./play-CJNuUj69.js";import{t as ce}from"./plus-C6fnr28l.js";import{t as Ls}from"./rotate-ccw-CQEJ4ewP.js";import{t as te}from"./trash-D7zTaHTj.js";import{t as ae}from"./triangle-alert-CBVKiaXB.js";import{t as Mt}from"./users-DyKzwIh4.js";import{t as Is}from"./x-DRDFdlYE.js";import{i as G,n as W,r as je,t as J}from"./tooltip-B5WQ3lq5.js";import{t as ee}from"./badge-DuA2EgZC.js";import{n as de}from"./ToastContext-DMdt9oTd.js";import{t as we}from"./agents-DmlgUVso.js";import{a as ue,i as be,n as me,r as xe,s as he,t as pe}from"./dialog-CKUblzlR.js";import{t as X}from"./input-DobnTAyB.js";import{n as Ms}from"./BreadcrumbContext-BVZDZoC0.js";import{a as $s,i as zs,o as qs,r as _s,s as Ks,t as Bs}from"./command-Ca3v36Mu.js";import{t as Ve}from"./AgentIdentity-I_kB4rMX.js";import{t as ie}from"./textarea-BRPEfJ-g.js";import{n as Os,r as Vs}from"./recent-selections-BnN_nb6Y.js";import{t as Us}from"./attachment-icon-4xDiQblX.js";import{t as Qs}from"./toggle-switch-BHxNtSq9.js";import{t as Ys}from"./clipboard-CTLKYvRL.js";import{t as Gs}from"./use-adapter-capabilities-Bu8XkVZ9.js";import{n as Ws}from"./use-copy-action-D5dEzo6L.js";import{o as Js,r as Xs,t as Ae}from"./card-Bru3x_SJ.js";import{Ea as Hs,Ja as $t,Q as zt,Ra as Zs,Sa as en,T as De,Z as qt,pn as _t,wa as Kt}from"./index-3AxqhPET.js";import{a as tn,c as sn,d as We,i as Je,n as nn,o as an,r as se,s as Xe,t as ln}from"./ImageGalleryModal-DzKBMOnu.js";import{t as rn}from"./FoldCurtain-DUAOdtCt.js";import{a as rt,i as on,n as cn,s as ot,t as Bt}from"./issue-output-CU3gasZ1.js";import{o as dn,r as un,s as mn,t as xn}from"./sheet-jd7y5x4-.js";import{a as ye,c as hn,i as pn,l as fn,n as gn,o as $e,r as jn,s as bn,t as kn}from"./SkillCardIcon-BTCafp8l.js";import{t as He}from"./EntityRow-BIfupmlZ.js";import{t as yn}from"./line-diff-DAcZgvm2.js";import{t as vn}from"./FilterBar-5ta25FCb.js";import{t as Nn}from"./SkillBinaryFile-DNe-MmCv.js";import{a as le,i as wn}from"./company-skill-routes-D5LJ1l8M.js";import{i as Sn,n as Cn,r as Re,t as Tn}from"./CompanySkills-BA_9Ztwj.js";import{n as ze,r as Fn,t as ct}from"./resizable-panels-Qjbo0P05.js";import{n as Ot,r as An,t as Dn}from"./IssueOutputSection-aSyiE1pg.js";var Vt={name:"file-plus",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]};Vt.node;var Ze=St(Vt),Ut={name:"folder-minus",size:24,node:[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};Ut.node;var Rn=St(Ut),d=yt(rs(),1),Qt="wardmote:recent-studio-skills";function En(){return Os(Qt)}s(En,"getRecentStudioSkillIds");function Pn(t){Vs(Qt,t)}s(Pn,"trackRecentStudioSkill");var e=yt(os(),1),qe="__latest__";function Ln({companyId:t,skill:n,canManage:a=!0}){const[o,r]=(0,d.useState)(!1),l=n.usedByAgents.length,i=`${l} ${l===1?"agent uses":"agents use"} this skill`;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",onClick:s(()=>r(!0),"onClick"),"aria-label":i,className:H("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors",l>0?"border-line bg-bg-3 text-ink hover:bg-bg-3":"border-line/60 bg-transparent text-ink-3 hover:bg-bg-3/50"),children:[(0,e.jsx)(Mt,{className:"h-3.5 w-3.5","aria-hidden":"true"}),l," ",l===1?"agent":"agents"]}),(0,e.jsx)(In,{open:o,onOpenChange:r,companyId:t,skill:n,canManage:a})]})}s(Ln,"AgentsUsingSkillBadge");function In({open:t,onOpenChange:n,companyId:a,skill:o,canManage:r=!0}){const l=Z(),i=de(),c=Gs(),[u,f]=(0,d.useState)(null),[m,k]=(0,d.useState)(null),h=o.currentVersion!==null,x=Y({queryKey:R.companySkills.versions(a,o.id),queryFn:s(()=>q.versions(a,o.id),"queryFn"),enabled:t&&h}),b=Y({queryKey:R.agents.list(a),queryFn:s(()=>we.list(a),"queryFn"),enabled:t});(0,d.useEffect)(()=>{t||k(null)},[t]);const S=(0,d.useMemo)(()=>[...x.data??[]].sort((p,L)=>L.revisionNumber-p.revisionNumber),[x.data]),D=o.currentVersion?.revisionNumber??null,E=(0,d.useMemo)(()=>new Map(S.map(p=>[p.id,p.revisionNumber])),[S]),j=(0,d.useMemo)(()=>new Map((b.data??[]).map(p=>[p.id,p])),[b.data]),N=(0,d.useMemo)(()=>new Set(o.usedByAgents.map(p=>p.id)),[o.usedByAgents]),w=(0,d.useMemo)(()=>(b.data??[]).filter(p=>!N.has(p.id)&&p.status!=="terminated"&&c(p.adapterType).supportsSkills).sort((p,L)=>p.name.localeCompare(L.name)),[b.data,N,c]),y=B({mutationFn:s(async({agent:p,change:L})=>{const K=o.key,I=await we.skills(p.id,a),M=I.desiredSkillEntries??I.desiredSkills.map(P=>({key:P,versionId:null})),_=[...M.filter(P=>P.key!==K)];if(L.kind!=="remove"){const P=L.kind==="pin"?L.versionId:null;_.push({key:K,versionId:P})}return zn(M,_)?{agentId:p.id,changed:!1}:(await we.syncSkills(p.id,_,"replace",a),{agentId:p.id,changed:!0})},"mutationFn"),onSuccess:s(async({agentId:p})=>{await Promise.all([l.invalidateQueries({queryKey:R.companySkills.detail(a,o.id)}),l.invalidateQueries({queryKey:R.companySkills.list(a)}),l.invalidateQueries({queryKey:R.agents.skills(p)})])},"onSuccess"),onError:s(p=>{const L=p instanceof Error?p.message:"Failed to update agent skills.";i?.pushToast({tone:"error",title:"Update failed",body:L.includes("403")?"You don't have permission to change this agent's skills.":L})},"onError")});async function v(p,L){f(p.id);try{await y.mutateAsync({agent:p,change:L}),k(null)}catch{}finally{f(null)}}s(v,"applyChange");const T=o.usedByAgents,$=T.length;return(0,e.jsx)(pe,{open:t,onOpenChange:n,children:(0,e.jsxs)(me,{className:"max-w-lg",children:[(0,e.jsxs)(ue,{children:[(0,e.jsxs)(he,{children:["Agents using ",o.name]}),(0,e.jsx)(xe,{children:$===0?"No agents have this skill assigned yet.":`${$} ${$===1?"agent has":"agents have"} this skill in their desired set.`})]}),(0,e.jsx)("div",{className:"max-h-80 overflow-y-auto",children:$===0?(0,e.jsx)("div",{className:"rounded-md border border-dashed border-line px-4 py-8 text-center text-sm text-ink-3",children:r?"Add an agent below to assign this skill.":"This skill isn't assigned to any agents."}):(0,e.jsx)("ul",{className:"divide-y divide-line",children:T.map(p=>(0,e.jsx)(Mn,{agent:p,icon:j.get(p.id)?.icon??null,canManage:r,hasVersions:h,versions:S,latestRevision:D,pinnedRevision:p.versionId?E.get(p.versionId)??null:null,busy:u===p.id,confirmingRemove:m===p.id,onRequestRemove:s(()=>k(p.id),"onRequestRemove"),onCancelRemove:s(()=>k(null),"onCancelRemove"),onRemove:s(()=>v(p,{kind:"remove"}),"onRemove"),onPin:s(L=>v(p,{kind:"pin",versionId:L}),"onPin")},p.id))})}),r?(0,e.jsxs)("div",{className:"flex items-center gap-2 border-t border-line pt-3",children:[(0,e.jsx)($n,{agents:w,loading:b.isLoading,disabled:y.isPending,onSelect:s(p=>v(p,{kind:"add"}),"onSelect")}),y.isPending?(0,e.jsx)(Ge,{className:"h-4 w-4 animate-spin text-ink-3","aria-hidden":"true"}):null]}):null]})})}s(In,"AgentsUsingSkillDialog");function Mn({agent:t,icon:n,canManage:a,hasVersions:o,versions:r,latestRevision:l,pinnedRevision:i,busy:c,confirmingRemove:u,onRequestRemove:f,onCancelRemove:m,onRemove:k,onPin:h}){const x=i!==null&&l!==null&&l>i?l-i:0;return(0,e.jsxs)("li",{className:"flex items-center gap-3 py-2.5",children:[(0,e.jsx)(Ns,{icon:n,className:"h-6 w-6 shrink-0 rounded-md text-ink-3"}),(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,e.jsx)(Fe,{to:`/agents/${t.urlKey}/skills`,className:"truncate text-sm font-medium text-ink hover:underline",children:t.name}),(0,e.jsx)("span",{className:"truncate text-(length:--text-micro) uppercase tracking-(--tracking-caps) text-ink-3",children:t.adapterType})]}),(0,e.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-0.5",children:[o?a?(0,e.jsxs)("select",{"aria-label":`${t.name} skill version`,value:t.versionId??qe,disabled:c,onChange:s(b=>h(b.target.value===qe?null:b.target.value),"onChange"),className:"h-8 rounded-md border border-line bg-bg px-2 text-xs text-ink disabled:opacity-60",children:[(0,e.jsxs)("option",{value:qe,children:["Latest",l!==null?` (v${l})`:""]}),r.map(b=>(0,e.jsxs)("option",{value:b.id,children:["v",b.revisionNumber,b.label?` · ${b.label}`:""]},b.id))]}):(0,e.jsx)("span",{className:"text-xs text-ink-3",children:t.versionId?`v${i??"?"}`:`Latest${l!==null?` (v${l})`:""}`}):(0,e.jsx)("span",{className:"text-sm text-ink-3","aria-label":`${t.name} version`,children:"—"}),x>0?(0,e.jsxs)("span",{className:"text-(length:--text-nano) text-amber-500",children:[x," version",x===1?"":"s"," behind latest"]}):null]}),a?u?(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,e.jsx)(C,{variant:"delete",size:"sm",onClick:k,disabled:c,"aria-label":`Confirm removing this skill from ${t.name}`,children:c?(0,e.jsx)(Ge,{className:"h-3.5 w-3.5 animate-spin"}):"Remove"}),(0,e.jsx)(C,{variant:"ghost",size:"sm",onClick:m,disabled:c,children:"Cancel"})]}):(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",onClick:f,disabled:c,className:"shrink-0","aria-label":`Remove this skill from ${t.name}`,children:(0,e.jsx)(te,{className:"h-4 w-4"})}):null]})}s(Mn,"AgentRow");function $n({agents:t,loading:n,disabled:a,onSelect:o}){const r=(0,d.useMemo)(()=>[{id:"agents",options:t.map(l=>({key:l.id,value:l.id,label:l.name,title:l.name,searchText:[l.name,l.adapterType].join(" "),agent:l}))}],[t]);return(0,e.jsx)(Qe,{value:"",groups:r,loading:n,loadingMessage:"Loading agents...",placeholder:"Add agent…",searchPlaceholder:"Search agents...",emptyMessage:"All eligible agents already have this skill.",disabled:a,onValueChange:s((l,i)=>(o(i.agent),{close:!0}),"onValueChange"),triggerClassName:"h-8 w-full justify-start",contentClassName:"w-72",renderValue:s(()=>(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-ink-3",children:[(0,e.jsx)(ce,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Add agent…"]}),"renderValue"),renderOption:s(l=>(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)("span",{className:"truncate",children:l.label}),(0,e.jsx)("span",{className:"truncate text-(length:--text-micro) uppercase tracking-(--tracking-caps) text-ink-3",children:l.agent.adapterType})]}),"renderOption")})}s($n,"AddAgentPicker");function zn(t,n){if(t.length!==n.length)return!1;const a=s(r=>`${r.key}\0${r.versionId??""}`,"encode"),o=new Set(t.map(a));return n.every(r=>o.has(a(r)))}s(zn,"desiredSetsEqual");function qn(t){if(!t)return null;const n=t.trim();return n?/^[0-9a-f]{8,40}$/i.test(n)?n.slice(0,7):n:null}s(qn,"shortSha");function _n(t){switch(t){case"github":return"GitHub";case"skills_sh":return"skills.sh";case"url":return"a URL";case"catalog":return"the catalog";case"local_path":return"a local path";default:return"its source"}}s(_n,"sourceTypeFallbackLabel");function Kn(t){let n=t.replace(/^git@github\.com:/i,"").replace(/^https?:\/\/github\.com\//i,"");n=n.split("#")[0].split("?")[0].replace(/\.git$/i,"");const a=n.split("/").filter(Boolean);return a.length>=2?`${a[0]}/${a[1]}`:null}s(Kn,"githubOwnerRepo");function Bn(t){return t.replace(/^https?:\/\//i,"").replace(/\/+$/,"")}s(Bn,"prettyUrl");function On(t){const n=t.sourceLocator?.trim()??"";return n?t.sourceType==="github"?Kn(n)??n:t.sourceType==="url"?Bn(n):n:_n(t.sourceType)}s(On,"formatForkSourceName");function Vn(t){const n=On(t),a=qn(t.sourceRef);return a?`${n} @ ${a}`:n}s(Vn,"formatLineageLabel");function Un(t){return t.find(n=>n.createdByCurrentActor&&!n.diverged)??null}s(Un,"pickReusableFork");function Qn(t){return t<=0?"No agents currently use this skill":`${t} ${t===1?"agent":"agents"} currently use${t===1?"s":""} this skill`}s(Qn,"agentUsageSentence");function Yn(t){return t.map(n=>n.id)}s(Yn,"reassignTargetIds");function Gn(t){if(!t||typeof t!="object")return!1;const n=t.sourceKind;return typeof n=="string"&&n.trim()==="project_scan"}s(Gn,"isProjectScanSkill");function Wn({companyId:t,skill:n,open:a,onOpenChange:o}){const r=Te(),l=Z(),i=de(),[c,u]=(0,d.useState)(!0),f=(0,d.useMemo)(()=>({skillId:n.id,original:{id:n.id,name:n.name,slug:n.slug,sourceType:n.sourceType,sourceLocator:n.sourceLocator,sourceRef:n.sourceRef},agentUsageCount:n.attachedAgentCount,usedByAgents:n.usedByAgents,existingForks:n.existingForks}),[n]),m=Y({queryKey:R.companySkills.forkPrecheck(t,n.id),queryFn:s(()=>q.forkPrecheck(t,n.id),"queryFn"),enabled:a&&!!(t&&n.id),initialData:f}).data??f,k=m.usedByAgents,h=m.agentUsageCount,x=(0,d.useMemo)(()=>Un(m.existingForks),[m.existingForks]);(0,d.useEffect)(()=>{a&&u(!0)},[a]);const b=B({mutationFn:s(()=>q.fork(t,n.id,{reassignAgentIds:c?Yn(k):[]}),"mutationFn"),onSuccess:s(j=>{l.invalidateQueries({queryKey:R.companySkills.list(t)}),l.invalidateQueries({queryKey:R.companySkills.detail(t,n.id)}),l.invalidateQueries({queryKey:R.agents.list(t)});for(const w of j.reassignments)l.invalidateQueries({queryKey:R.agents.skills(w.agentId)});const N=j.reassignments.length;i?.pushToast({tone:"success",title:"Editing a copy",body:N>0?`Created a copy of ${n.name} and switched ${N} ${N===1?"agent":"agents"} to it.`:`Created a copy of ${n.name}. It's now editable.`}),o(!1),r(le(j.skill.id))},"onSuccess"),onError:s(j=>{i?.pushToast({tone:"error",title:"Couldn't create a copy",body:j instanceof Error?j.message:"The fork request failed."})},"onError")}),S=b.isPending,D=c&&h>0?`Create copy & switch ${h} ${h===1?"agent":"agents"}`:"Create copy",E=s(()=>{x&&(o(!1),r(le(x.id)))},"openExisting");return(0,e.jsx)(pe,{open:a,onOpenChange:s(j=>S?void 0:o(j),"onOpenChange"),children:(0,e.jsxs)(me,{className:"sm:max-w-lg",children:[(0,e.jsxs)(ue,{children:[(0,e.jsxs)(he,{className:"flex items-center gap-2",children:[(0,e.jsx)(Re,{className:"h-4 w-4"}),"Edit a copy of ",n.name]}),(0,e.jsxs)(xe,{children:[n.name," is read-only because it comes from an external source. Creating a fully editable copy in your workspace leaves the original untouched and still updatable."]})]}),x?(0,e.jsxs)("div",{className:"rounded-md border border-accent/40 bg-accent/5 p-3 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-ink",children:"You already have a copy"}),(0,e.jsx)("p",{className:"mt-0.5 text-ink-3",children:"An unedited copy of this skill already exists. Open it instead of making another."}),(0,e.jsx)(C,{type:"button",size:"sm",className:"mt-2",onClick:E,disabled:S,children:"Open your existing copy"})]}):null,(0,e.jsxs)("div",{className:H("rounded-md border p-3",h>0?"border-amber-500/40 bg-amber-500/5":"border-line bg-bg-3/30"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-ink",children:[(0,e.jsx)(Mt,{className:"h-4 w-4 shrink-0"}),(0,e.jsx)("span",{children:Qn(h)})]}),h>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:k.map(j=>(0,e.jsx)("span",{className:"inline-flex items-center rounded-full border border-line bg-bg px-2 py-0.5 text-xs text-ink",children:j.name},j.id))}),(0,e.jsxs)("label",{className:"mt-3 flex items-start justify-between gap-3",children:[(0,e.jsxs)("span",{className:"text-sm",children:[(0,e.jsx)("span",{className:"font-medium text-ink",children:"Switch these agents to the copy"}),(0,e.jsx)("span",{className:"mt-0.5 block text-xs text-ink-3",children:c?"These agents will run your copy instead of the original.":"These agents keep running the original — your copy won't change what they do."})]}),(0,e.jsx)(Qs,{checked:c,onCheckedChange:u,disabled:S,"aria-label":"Switch these agents to the copy"})]})]}):(0,e.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"Nothing is assigned to it, so your copy won't change any agent's behaviour."})]}),(0,e.jsxs)(be,{children:[(0,e.jsx)(C,{type:"button",variant:"ghost",onClick:s(()=>o(!1),"onClick"),disabled:S,children:"Cancel"}),(0,e.jsxs)(C,{type:"button",variant:x?"secondary":"primary",onClick:s(()=>b.mutate(),"onClick"),disabled:S,children:[S?(0,e.jsx)(Ge,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,x?"Create another copy":D]})]})]})})}s(Wn,"ForkSkillDialog");function Jn({companyId:t,forkedFromSkillId:n}){const a=Y({queryKey:R.companySkills.detail(t,n??""),queryFn:s(()=>q.detail(t,n),"queryFn"),enabled:!!(t&&n),staleTime:6e4});if(!n)return null;const o=a.data,r=o?Vn(o):"the original skill";return(0,e.jsxs)(Fe,{to:le(n),className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-line bg-bg-3 px-2.5 py-0.5 text-xs text-ink-3 transition-colors hover:bg-bg-3 hover:text-ink",title:`Forked from ${r}`,children:[(0,e.jsx)(Re,{className:"h-3 w-3 shrink-0"}),(0,e.jsxs)("span",{className:"truncate",children:["Forked from ",(0,e.jsx)("span",{className:"font-medium text-ink",children:r})]})]})}s(Jn,"SkillLineageChip");function Xn({skill:t,onEditACopy:n}){const a=t.sourcePath??t.sourceLabel??"the project working tree";return(0,e.jsxs)("div",{className:"flex flex-wrap items-start gap-2 border-b border-line bg-bg-3/40 px-3 py-2 text-xs text-ink-3",children:[(0,e.jsx)(Fs,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("span",{children:["This skill lives in ",(0,e.jsx)("span",{className:"font-mono text-ink",children:a}),". Saves write to the project working tree and are not committed."]})," ",(0,e.jsx)(C,{type:"button",variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:n,children:"Edit a copy instead"})]})]})}s(Xn,"ProjectScanNotice");function Yt(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}s(Yt,"isScalar");function ve(t){return t==null?"":typeof t=="boolean"?t?"true":"false":String(t)}s(ve,"scalarToText");function Gt(t){return t===""?"":t==="true"?!0:t==="false"?!1:t==="null"||t==="~"?null:/^-?\d+(\.\d+)?$/u.test(t)?Number(t):t}s(Gt,"coerceScalar");function Hn(t){return wt(t)&&Object.values(t).every(Yt)}s(Hn,"isFlatScalarRecord");function dt(t){const n="allowed-tools"in t,a=t.metadata,o="metadata"in t,r=o&&Hn(a),l=r?Object.entries(a).map(([c,u],f)=>({id:`meta-${f}-${c}`,key:c,rawValue:u,text:ve(u),edited:!1})):[],i=as(t).map((c,u)=>{const f=t[c],m=Yt(f);return{id:`unknown-${u}-${c}`,key:c,rawValue:f,text:ve(f),edited:!1,editable:m}});return{hasName:"name"in t,name:typeof t.name=="string"?t.name:ve(t.name),hasDescription:"description"in t,description:typeof t.description=="string"?t.description:ve(t.description),allowedToolsPresent:n,allowedTools:n?Nt(t["allowed-tools"]):[],metadataPresent:o,metadataComplex:o&&!r?a:null,metaRows:l,unknown:i}}s(dt,"buildFormModel");function Zn(t){const n={};for(const a of t){const o=a.key.trim();o&&(n[o]=a.edited?Gt(a.text):a.rawValue)}return n}s(Zn,"scalarRowsToObject");function ut(t){const n={};t.hasName&&(n.name=t.name),t.hasDescription&&(n.description=t.description),t.allowedToolsPresent&&(n["allowed-tools"]=t.allowedTools??[]),t.metadataPresent&&(n.metadata=t.metadataComplex!==null?t.metadataComplex:Zn(t.metaRows));for(const a of t.unknown){const o=a.key.trim();o&&(n[o]=a.editable&&a.edited?Gt(a.text):a.rawValue)}return ls(n)}s(ut,"serializeForm");var ea=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function ta(t,n){const a=[],o=t.name.trim(),r=t.description.trim();return n&&!o&&a.push({field:"name",message:"SKILL.md needs a name."}),o&&!ea.test(o)&&a.push({field:"name",message:"Use lowercase letters, numbers and hyphens."}),n&&!r&&a.push({field:"description",message:"SKILL.md needs a description."}),t.allowedToolsPresent&&t.allowedTools===null&&a.push({field:"allowed-tools",message:"Expected a list — edit in YAML."}),a}s(ta,"collectValidation");function sa(t){return/(^|\/)skill\.md$/i.test(t)}s(sa,"isSkillMarkdown");function na({frontmatterText:t,hasFrontmatter:n,fileName:a,skillSlug:o,readOnly:r=!1,onChange:l,className:i}){const c=sa(a),[u,f]=(0,d.useState)(n),[m,k]=(0,d.useState)(t),h=(0,d.useMemo)(()=>it(t),[t]),[x,b]=(0,d.useState)(()=>dt(h.parsed)),[S,D]=(0,d.useState)(n&&h.canRoundTrip?"fields":"yaml"),[E,j]=(0,d.useState)(!1),N=(0,d.useMemo)(()=>it(m),[m]),w=u&&N.canRoundTrip,y=S==="fields"&&!w?"yaml":S,v=(0,d.useMemo)(()=>y==="fields"?ta(x,c):[],[y,x,c]),T=(0,d.useCallback)((P,O)=>{l({frontmatterText:P,hasFrontmatter:O})},[l]),$=(0,d.useCallback)(P=>{b(P);let O;try{O=ut(P)}catch{return}k(O),T(O,!0)},[T]),p=(0,d.useCallback)(P=>{k(P),T(P,!0)},[T]),L=(0,d.useCallback)(P=>{if(P==="fields"){if(!w)return;b(dt(is(m)))}D(P)},[w,m]),K=(0,d.useCallback)(()=>{const P={hasName:!0,name:c?(o??"").trim():"",hasDescription:c,description:"",allowedToolsPresent:!1,allowedTools:[],metadataPresent:!1,metadataComplex:null,metaRows:[],unknown:[]};f(!0),D("fields"),j(!0),b(P);const O=ut(P);k(O),T(O,!0)},[T,c,o]),I=(0,d.useMemo)(()=>aa(N.parsed),[N.parsed]),M=v.length,_=E?(0,e.jsx)(Ue,{className:"h-4 w-4 shrink-0 text-ink-3","aria-hidden":"true"}):(0,e.jsx)(fe,{className:"h-4 w-4 shrink-0 text-ink-3","aria-hidden":"true"});return(0,e.jsx)(je,{children:(0,e.jsxs)(xs,{open:E,onOpenChange:j,className:H("border-b border-line",i),"data-testid":"frontmatter-panel",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,e.jsxs)("button",{type:"button",onClick:s(()=>j(P=>!P),"onClick"),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left","aria-expanded":E,"aria-controls":"frontmatter-panel-body",children:[_,(0,e.jsx)("span",{className:"text-sm font-medium",children:"Frontmatter"}),!E&&u?(0,e.jsx)("span",{className:"truncate text-xs text-ink-3",children:I}):null,!E&&!u?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"None"}):null]}),u?(0,e.jsx)(Et,{value:y,onValueChange:s(P=>L(P),"onValueChange"),children:(0,e.jsxs)(Rt,{variant:"line",className:"h-7",children:[w?(0,e.jsx)(oe,{value:"fields",className:"px-2 py-0.5 text-xs",children:"Fields"}):(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsx)(oe,{value:"fields",disabled:!0,"aria-disabled":"true",className:"px-2 py-0.5 text-xs opacity-50",children:"Fields"})})}),(0,e.jsx)(W,{className:"max-w-60",children:"Switch to YAML to edit. This frontmatter uses YAML features the form can't safely round-trip (e.g. comments, anchors, or custom ordering). Editing here keeps it byte-for-byte."})]}),(0,e.jsx)(oe,{value:"yaml",className:"px-2 py-0.5 text-xs",children:"YAML"})]})}):r?null:(0,e.jsxs)(C,{variant:"ghost",size:"sm",onClick:K,"data-testid":"add-frontmatter",children:[(0,e.jsx)(ce,{className:"mr-1 h-3.5 w-3.5"}),"Add frontmatter"]}),u&&y==="fields"&&M>0?(0,e.jsxs)(ee,{variant:"outline",className:"gap-1 text-amber-500","data-testid":"frontmatter-warning-chip",children:[(0,e.jsx)(ae,{className:"h-3.5 w-3.5"}),M," ",M===1?"issue":"issues"]}):null]}),(0,e.jsx)(ms,{id:"frontmatter-panel-body",children:u?(0,e.jsx)("div",{className:"px-3 pb-3",children:y==="fields"?(0,e.jsx)(ia,{form:x,validation:v,readOnly:r,onCommit:$}):(0,e.jsx)(oa,{value:m,readOnly:r,canReturnToFields:w,parseError:u&&!N.canRoundTrip&&N.issues.length===0,onChange:p})}):(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-ink-3",children:"This file has no frontmatter."})})]})})}s(na,"FrontmatterPanel");function aa(t){const n=[];typeof t.name=="string"&&t.name.trim()&&n.push(t.name.trim());const a=Nt(t["allowed-tools"]);if(a&&a.length>0&&n.push(`${a.length} ${a.length===1?"tool":"tools"}`),wt(t.metadata)){const o=Object.keys(t.metadata).length;o>0&&n.push(`${o} metadata`)}return n.join(" · ")}s(aa,"buildSummary");function _e(t,n){return t.find(a=>a.field===n)?.message??null}s(_e,"fieldWarning");function mt({message:t}){return(0,e.jsxs)("p",{className:"mt-1 flex items-center gap-1 text-xs text-amber-500",children:[(0,e.jsx)(ae,{className:"h-3.5 w-3.5 shrink-0"}),t]})}s(mt,"FieldWarning");function ia({form:t,validation:n,readOnly:a,onCommit:o}){const r=_e(n,"name"),l=_e(n,"description"),i=_e(n,"allowed-tools");return(0,e.jsxs)("div",{className:"space-y-3 pt-1",children:[t.hasName?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{htmlFor:"fm-name",className:"text-xs text-ink-3",children:"name"}),(0,e.jsx)(X,{id:"fm-name",value:t.name,readOnly:a,"aria-invalid":!!r,onChange:s(c=>o({...t,name:c.target.value}),"onChange"),className:"mt-1"}),r?(0,e.jsx)(mt,{message:r}):null]}):null,t.hasDescription?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{htmlFor:"fm-description",className:"text-xs text-ink-3",children:"description"}),(0,e.jsx)(ie,{id:"fm-description",value:t.description,readOnly:a,rows:3,onChange:s(c=>o({...t,description:c.target.value}),"onChange"),className:"mt-1"}),l?(0,e.jsx)(mt,{message:l}):null]}):null,t.allowedToolsPresent?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{className:"text-xs text-ink-3",children:"allowed-tools"}),t.allowedTools===null?(0,e.jsx)("p",{className:"mt-1 text-xs text-amber-500",children:i??"Expected a list — edit in YAML."}):(0,e.jsx)(ra,{values:t.allowedTools,readOnly:a,placeholder:"Add a tool…",onChange:s(c=>o({...t,allowedTools:c}),"onChange")})]}):null,t.metadataPresent?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{className:"text-xs text-ink-3",children:"metadata"}),t.metadataComplex!==null?(0,e.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"Complex value — edit in YAML."}):(0,e.jsx)(la,{rows:t.metaRows,readOnly:a,onChange:s(c=>o({...t,metaRows:c}),"onChange")})]}):null,t.unknown.map((c,u)=>c.editable?(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{htmlFor:`fm-unknown-${c.id}`,className:"text-xs text-ink-3",children:c.key}),(0,e.jsx)(X,{id:`fm-unknown-${c.id}`,value:c.text,readOnly:a,onChange:s(f=>{const m=t.unknown.slice();m[u]={...c,text:f.target.value,edited:!0},o({...t,unknown:m})},"onChange"),className:"mt-1"})]},c.id):(0,e.jsxs)("div",{children:[(0,e.jsx)(U,{className:"text-xs text-ink-3",children:c.key}),(0,e.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"Complex value — edit in YAML."})]},c.id))]})}s(ia,"FieldsForm");function la({rows:t,readOnly:n,onChange:a}){const o=s((i,c)=>{const u=t.slice();u[i]={...u[i],...c,edited:!0},a(u)},"update"),r=s(i=>{a(t.filter((c,u)=>u!==i))},"remove"),l=s(()=>{a([...t,{id:`meta-new-${t.length}-${Date.now()}`,key:"",rawValue:"",text:"",edited:!0}])},"add");return(0,e.jsxs)("div",{className:"mt-1 space-y-1.5",children:[t.map((i,c)=>(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(X,{"aria-label":`Metadata key ${c+1}`,value:i.key,readOnly:n,placeholder:"key",onChange:s(u=>o(c,{key:u.target.value}),"onChange"),className:"h-8 flex-1 font-mono text-xs"}),(0,e.jsx)(X,{"aria-label":`Value for ${i.key||`field ${c+1}`}`,value:i.text,readOnly:n,placeholder:"value",onChange:s(u=>o(c,{text:u.target.value}),"onChange"),className:"h-8 flex-1 text-xs"}),n?null:(0,e.jsx)(C,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0","aria-label":`Remove ${i.key||`field ${c+1}`}`,onClick:s(()=>r(c),"onClick"),children:(0,e.jsx)(te,{className:"h-3.5 w-3.5"})})]},i.id)),n?null:(0,e.jsxs)(C,{variant:"ghost",size:"sm",onClick:l,className:"text-xs",children:[(0,e.jsx)(ce,{className:"mr-1 h-3.5 w-3.5"}),"add field"]})]})}s(la,"MetadataRows");function ra({values:t,readOnly:n,placeholder:a,onChange:o}){const[r,l]=(0,d.useState)(""),i=s(()=>{const c=r.trim();c&&(o([...t,c]),l(""))},"commit");return(0,e.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 rounded-md border border-line px-2 py-1.5",children:[t.map((c,u)=>(0,e.jsxs)(ee,{variant:"secondary",className:"gap-1",children:[c,n?null:(0,e.jsx)("button",{type:"button","aria-label":`Remove ${c}`,onClick:s(()=>o(t.filter((f,m)=>m!==u)),"onClick"),className:"hover:text-ink",children:(0,e.jsx)(Is,{className:"h-3 w-3"})})]},`${c}-${u}`)),n?null:(0,e.jsx)("input",{value:r,placeholder:t.length===0?a:void 0,onChange:s(c=>l(c.target.value),"onChange"),onKeyDown:s(c=>{c.key==="Enter"||c.key===","?(c.preventDefault(),i()):c.key==="Backspace"&&r===""&&t.length>0&&o(t.slice(0,-1))},"onKeyDown"),onBlur:i,"aria-label":"Add tool",className:"min-w-24 flex-1 bg-transparent text-xs outline-none"})]})}s(ra,"ChipInput");function oa({value:t,readOnly:n,canReturnToFields:a,parseError:o,onChange:r}){return(0,e.jsxs)("div",{className:"pt-1",children:[!a&&!o?(0,e.jsxs)("div",{className:"mb-1.5 flex items-start gap-2 rounded-md bg-bg-3/40 px-2 py-1.5 text-xs text-ink-3",children:[(0,e.jsx)(As,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:"Editing raw YAML to preserve formatting the form can't reconstruct."})]}):null,(0,e.jsx)(ie,{value:t,readOnly:n,spellCheck:!1,rows:Math.min(12,Math.max(3,t.split(`
2
2
  `).length)),onChange:s(l=>r(l.target.value),"onChange"),className:"font-mono text-xs","aria-label":"Frontmatter YAML"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"Raw YAML is the source of truth in this mode."})]})}s(oa,"YamlEditor");async function ca(t){const n=await fetch(t.contentPath,{headers:{Accept:"text/markdown,text/plain;q=0.9,*/*;q=0.1"}});if(!n.ok)throw new Error(`Unable to load attachment preview (${n.status})`);return n.text()}s(ca,"fetchAttachmentText");function et({attachment:t,onDelete:n,deletePending:a,onPreview:o}){const r=(0,d.useContext)(We),l=s(c=>{r&&Xe(t)&&!c.metaKey&&!c.ctrlKey&&!c.shiftKey&&!c.altKey&&(c.preventDefault(),r(t.id,se(t)))},"openInPanel"),i=se(t);return(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[o?(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",title:"Browse gallery","aria-label":`Browse ${i} in gallery`,onClick:s(()=>o(t),"onClick"),children:(0,e.jsx)(Ds,{className:"h-4 w-4"})}):null,(0,e.jsx)(C,{asChild:!0,variant:"ghost",size:"icon-sm",title:"Open in new tab",children:(0,e.jsx)("a",{href:Je(t),onClick:l,target:"_blank",rel:"noreferrer","aria-label":`Open ${i}`,children:(0,e.jsx)(Cs,{className:"h-4 w-4"})})}),(0,e.jsx)(C,{asChild:!0,variant:"ghost",size:"icon-sm",title:"Download",children:(0,e.jsx)("a",{href:nn(t),"aria-label":`Download ${i}`,children:(0,e.jsx)(Zs,{className:"h-4 w-4"})})}),n?(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",title:"Delete attachment",onClick:s(()=>n(t.id),"onClick"),disabled:a,children:(0,e.jsx)(te,{className:"h-4 w-4"})}):null]})}s(et,"AttachmentActions");function Wt({attachment:t}){return(0,e.jsxs)("p",{className:"mt-0.5 text-(length:--text-micro) text-ink-3",children:["Attachment · ",t.contentType," · ",Bt(t.byteSize)]})}s(Wt,"AttachmentMeta");function da({attachment:t,onDelete:n,deletePending:a}){const o=(0,d.useContext)(We),r=s(f=>{o&&Xe(t)&&!f.metaKey&&!f.ctrlKey&&!f.shiftKey&&!f.altKey&&(f.preventDefault(),o(t.id,se(t)))},"openInPanel"),l=se(t),{data:i,isLoading:c,error:u}=Y({queryKey:R.issues.attachmentPreview(t.id),queryFn:s(()=>ca(t),"queryFn")});return(0,e.jsxs)("div",{id:`attachment-${t.id}`,className:"scroll-mt-20 rounded-lg border border-line p-3",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(It,{className:"h-4 w-4 shrink-0 text-ink-3"}),(0,e.jsx)("a",{href:Je(t),onClick:r,className:"truncate text-sm font-medium hover:underline",title:l,children:l})]}),(0,e.jsx)(Wt,{attachment:t})]}),(0,e.jsx)(et,{attachment:t,onDelete:n,deletePending:a})]}),(0,e.jsx)("div",{className:"mt-3 rounded-md hover:bg-bg-3/10",children:c?(0,e.jsx)("p",{className:"px-1 py-2 text-xs text-ink-3",children:"Loading preview..."}):u?(0,e.jsx)("p",{className:"px-1 py-2 text-xs text-bad",children:"Could not load markdown preview."}):(0,e.jsx)(rn,{children:(0,e.jsx)(Ye,{className:"wardmote-edit-in-place-content min-h-(--sz-220px) text-sm leading-7",softBreaks:!1,children:i??""})})})]})}s(da,"MarkdownAttachmentCard");function ua({attachment:t,onDelete:n,deletePending:a,onPreview:o}){const r=se(t);return(0,e.jsxs)(Ae,{id:`attachment-${t.id}`,className:"block scroll-mt-20 overflow-hidden py-0",children:[(0,e.jsx)(An,{src:t.contentPath,title:r}),(0,e.jsxs)("div",{className:"flex flex-col gap-2 p-3 md:flex-row md:items-center md:justify-between",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("p",{className:"break-words text-sm font-semibold text-ink",children:r}),(0,e.jsx)(Wt,{attachment:t})]}),(0,e.jsx)(et,{attachment:t,onDelete:n,deletePending:a,onPreview:o})]})]})}s(ua,"VideoAttachmentCard");function ma({attachment:t,onDelete:n,deletePending:a}){const o=(0,d.useContext)(We),r=s(i=>{o&&Xe(t)&&!i.metaKey&&!i.ctrlKey&&!i.shiftKey&&!i.altKey&&(i.preventDefault(),o(t.id,se(t)))},"openInPanel"),l=se(t);return(0,e.jsxs)(Ae,{id:`attachment-${t.id}`,className:"flex-row scroll-mt-20 items-center gap-2.5 p-2",children:[(0,e.jsx)(Ot,{contentType:t.contentType}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("a",{href:Je(t),onClick:r,target:"_blank",rel:"noreferrer",className:"block truncate text-sm font-medium text-ink hover:underline",title:l,children:l}),(0,e.jsxs)("p",{className:"truncate text-(length:--text-micro) text-ink-3",children:["Attachment · ",t.contentType," · ",Bt(t.byteSize)]})]}),(0,e.jsx)(et,{attachment:t,onDelete:n,deletePending:a})]})}s(ma,"GenericAttachmentRow");function xa({attachment:t,onDelete:n,deletePending:a}){const o=se(t);return(0,e.jsxs)(Ae,{id:`attachment-${t.id}`,"data-purged-attachment":"",className:"flex-row scroll-mt-20 items-center gap-2.5 p-2",children:[(0,e.jsx)(Ot,{contentType:t.contentType}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("p",{className:"truncate text-sm font-medium text-ink-3",title:o,children:o}),(0,e.jsx)(Ss,{purgedAt:t.purgedAt,className:"mt-1"})]}),n?(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",title:"Delete attachment",onClick:s(()=>n(t.id),"onClick"),disabled:a,children:(0,e.jsx)(te,{className:"h-4 w-4"})}):null]})}s(xa,"PurgedAttachmentRow");function ha({attachments:t,uploadButton:n,error:a,dragActive:o=!1,deletePending:r=!1,onDelete:l,onImageClick:i,onDragEnter:c,onDragOver:u,onDragLeave:f,onDrop:m}){const[k,h]=(0,d.useState)(null),{imageAttachments:x,markdownAttachments:b,videoAttachments:S,genericAttachments:D,purgedAttachments:E}=(0,d.useMemo)(()=>{const w=[],y=[],v=[],T=[],$=[];for(const p of t)p.purgedAt?$.push(p):tn(p)?w.push(p):an(p)?y.push(p):sn(p)?v.push(p):T.push(p);return{imageAttachments:w,markdownAttachments:y,videoAttachments:v,genericAttachments:T,purgedAttachments:$}},[t]),j=s(w=>h(w),"requestDelete"),N=s(w=>{l&&(l(w),h(null))},"confirmDelete");return(0,e.jsxs)("div",{className:H("space-y-3 rounded-lg transition-colors",o&&"bg-accent/5"),onDragEnter:c,onDragOver:u,onDragLeave:f,onDrop:m,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Us,{className:"h-3.5 w-3.5 text-ink-3","aria-hidden":"true"}),(0,e.jsx)("h3",{className:"text-sm font-medium text-ink-3",children:"Attachments"}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:t.length})]}),n]}),a&&(0,e.jsx)("p",{className:"text-xs text-bad",children:a}),x.length>0&&(0,e.jsx)("div",{className:"grid grid-cols-4 gap-2",children:x.map(w=>(0,e.jsxs)("div",{id:`attachment-${w.id}`,className:"group relative aspect-square cursor-pointer scroll-mt-20 overflow-hidden rounded-lg border border-line bg-bg-3/10",onClick:s(()=>i(w),"onClick"),children:[(0,e.jsx)("img",{src:w.contentPath,alt:w.originalFilename??"attachment",className:"h-full w-full object-cover",loading:"lazy"}),(0,e.jsx)("div",{className:"absolute inset-0 bg-black/0 transition-colors group-hover:bg-black/30"}),l&&k===w.id?(0,e.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-1.5 bg-black/60",onClick:s(y=>y.stopPropagation(),"onClick"),children:[(0,e.jsx)("p",{className:"text-xs font-medium text-white",children:"Delete?"}),(0,e.jsxs)("div",{className:"flex gap-1.5",children:[(0,e.jsx)(C,{variant:"delete",size:"xs",type:"button",onClick:s(y=>{y.stopPropagation(),N(w.id)},"onClick"),disabled:r,children:"Yes"}),(0,e.jsx)("button",{type:"button",className:"rounded bg-bg-3 px-2 py-0.5 text-xs hover:bg-bg-3/80",onClick:s(y=>{y.stopPropagation(),h(null)},"onClick"),children:"No"})]})]}):l?(0,e.jsx)(C,{type:"button",variant:"delete",size:"icon-xs",className:"absolute right-1.5 top-1.5 opacity-0 group-hover:opacity-100 focus-visible:opacity-100",onClick:s(y=>{y.stopPropagation(),j(w.id)},"onClick"),title:"Delete attachment","aria-label":"Delete attachment",children:(0,e.jsx)(te,{className:"h-3.5 w-3.5"})}):null]},w.id))}),b.length>0&&(0,e.jsx)("div",{className:"space-y-3",children:b.map(w=>(0,e.jsx)(da,{attachment:w,onDelete:l?j:void 0,deletePending:r},w.id))}),S.length>0&&(0,e.jsx)("div",{className:"space-y-3",children:S.map(w=>(0,e.jsx)(ua,{attachment:w,onDelete:l?j:void 0,deletePending:r,onPreview:i},w.id))}),D.length>0&&(0,e.jsx)("div",{className:"space-y-2",children:D.map(w=>(0,e.jsx)(ma,{attachment:w,onDelete:l?j:void 0,deletePending:r},w.id))}),E.length>0&&(0,e.jsx)("div",{className:"space-y-2",children:E.map(w=>(0,e.jsx)(xa,{attachment:w,onDelete:l?j:void 0,deletePending:r},w.id))}),l&&k&&!x.some(w=>w.id===k)?(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-md border border-bad/20 bg-bad/5 px-4 py-3",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-bad",children:"Delete this attachment? This cannot be undone."}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,e.jsx)(C,{variant:"ghost",size:"sm",onClick:s(()=>h(null),"onClick"),disabled:r,children:"Cancel"}),(0,e.jsx)(C,{variant:"delete",size:"sm",onClick:s(()=>N(k),"onClick"),disabled:r,children:r?"Deleting...":"Delete"})]})]}):null]})}s(ha,"IssueAttachmentsSection");var pa=["succeeded","failed","cancelled"],Jt="built-in:default-test-template";function tt(t){return pa.includes(t)}s(tt,"isTerminalRunStatus");function Xt(t){return!tt(t)}s(Xt,"shouldPollRun");function fa(t){const n=!!(t.outputBody&&t.outputBody.trim().length>0);return tt(t.status)?t.status==="succeeded"?n?"output":"none":n?"draft":"none":n?"output":"pending"}s(fa,"runOutputMode");function ga(t){return t==="failed"}s(ga,"showRunErrorCard");function ja(t){return t.taskExpired||!t.harnessIssue?{enabled:!1,reason:"Test task expired"}:{enabled:!0,reason:null}}s(ja,"testTaskLinkState");function ba(t){return t.skillFileCount<=0?{disabled:!0,reason:"This skill has no files to test"}:t.hasAgent?t.hasInput?t.hasUnsavedSkillEdits?{disabled:!0,reason:"Save skill edits before running"}:t.runInFlight?{disabled:!0,reason:"A run is already in progress"}:{disabled:!1,reason:null}:{disabled:!0,reason:"Add or paste input text to run"}:{disabled:!0,reason:"Pick an agent to run"}}s(ba,"evaluateRunGate");var Ht={inputId:null,draft:"",baselineContent:""};function ka(t,n){return n?t.inputId!==n.id?{inputId:n.id,draft:n.content,baselineContent:n.content}:t.baselineContent===n.content?t:t.draft===t.baselineContent?{inputId:n.id,draft:n.content,baselineContent:n.content}:t:t.inputId===null?t:Ht}s(ka,"syncSavedInputDraftState");function ya(t,n){return n?t.inputId===n.id?t.draft:n.content:""}s(ya,"selectedSavedInputDraft");function va(t,n){return!!(n&&t.inputId===n.id&&t.draft!==n.content)}s(va,"savedInputDraftDirty");var Na=new Set(["ask_user_questions","request_confirmation"]);function Zt(t){return Na.has(t)?"inline":"fallback"}s(Zt,"routeInteraction");function wa(t){return Zt(t.kind)==="inline"&&t.status==="pending"}s(wa,"isInteractionAnswerable");function Sa(t){return t.status!=="paused"}s(Sa,"isAgentSelectable");function Ca(t){return`#${t.id.replace(/-/g,"").slice(0,7)}`}s(Ca,"runShortId");function Ta(t){return t===null?$t:t}s(Ta,"serializeRunTemplateSelection");function Fa(t){return t==="__wardmote_no_template__"?null:t&&t.trim()?t:Jt}s(Fa,"parseRunTemplateSelection");function Ke(t,n){if(t===null)return{selection:null,template:null,recovered:!1};const a=n.find(r=>r.id===t)??null;if(a)return{selection:t,template:a,recovered:!1};const o=n.find(r=>r.id==="built-in:default-test-template")??n[0]??null;return{selection:o?.id??null,template:o,recovered:!0}}s(Ke,"resolveRunTemplateSelection");function Aa(t){return{agentId:t.agentId,inputId:t.inputId,content:t.content,templateId:t.templateId}}s(Aa,"buildCreateRunRequest");function Da(t){return t==="expired"?"Test task expired":t==="deleted"?"Test task deleted":"Test task unavailable"}s(Da,"runHarnessUnavailableTitle");function Ra(t){return t.harnessContent.available?null:{title:Da(t.harnessContent.unavailableReason),body:"Stored run snapshots are still shown. Harness documents, attachments, and work products are no longer available."}}s(Ra,"runHarnessUnavailableCopy");function Ea(t){return t.harnessContent.documents.find(n=>n.key===t.outputDocumentKey)??null}s(Ea,"findRunOutputDocument");function Pa(t){const n=Ea(t);return t.harnessContent.documents.filter(a=>!(a.key===t.outputDocumentKey||n&&a.id===n.id))}s(Pa,"getRunAdditionalDocuments");function La(t){const n=on(t.harnessContent.workProducts);return t.harnessContent.attachments.filter(a=>!n.has(a.id))}s(La,"getRunRawAttachments");function Ia(t){const n=[],a=new Set,o=s((l,i)=>{l&&a.add(`attachment:${l}`),a.add(`content:${i}`)},"mark"),r=s((l,i)=>!!(l&&a.has(`attachment:${l}`))||a.has(`content:${i}`),"hasSeen");for(const l of t.harnessContent.attachments)!rt(l.contentType)&&!ot(l.contentType,l.originalFilename)||(n.push(l),o(l.id,l.contentPath));for(const l of cn(t.harnessContent.workProducts).items){const i=l.metadata;i&&(!(rt(i.contentType)||ot(i.contentType,i.originalFilename))||r(i.attachmentId,i.contentPath)||(n.push({id:`work-product-${l.id}`,contentPath:i.contentPath,openPath:i.openPath,downloadPath:i.downloadPath,contentType:i.contentType,originalFilename:i.originalFilename??l.title}),o(i.attachmentId,i.contentPath)))}return n}s(Ia,"getRunMediaGalleryItems");function Ma(t){return{agentId:t.agentId,inputId:t.inputId??void 0,content:t.inputId?void 0:t.inputSnapshot,skillVersionId:t.skillVersionId,templateSnapshot:{templateId:t.templateId,templateName:t.templateName,templateBody:t.templateBody}}}s(Ma,"buildReRunRequest");function $a(t,n,a=5){const o=new Map(t.map(i=>[i.id,i])),r=[],l=new Set;for(const i of n){if(l.has(i))continue;const c=o.get(i);if(c&&(r.push(c),l.add(i),r.length>=a))break}return r}s($a,"orderRecentlyVisitedSkills");function xt(t){const n=t.updatedAt,a=n instanceof Date?n.getTime():new Date(n).getTime();return Number.isNaN(a)?0:a}s(xt,"updatedAtMs");function za(t,n,a=10){const o=new Set(n);return t.filter(r=>!o.has(r.id)).slice().sort((r,l)=>{const i=xt(l)-xt(r);return i!==0?i:r.name.localeCompare(l.name)}).slice(0,a)}s(za,"orderRecentlyUpdatedSkills");function qa(t){const n=t.trim().split(/\s+/).filter(Boolean);return n.length===0?"?":n.length===1?n[0].slice(0,2).toUpperCase():(n[0][0]+n[n.length-1][0]).toUpperCase()}s(qa,"editorInitials");function _a(t){if(!t||t.kind!=="user")return null;const n=t.name?.trim()||"Unknown editor";return{name:n,imageUrl:t.imageUrl,initials:qa(n)}}s(_a,"skillEditorAvatar");var es="skillStudio.paneSizes",Ka="skillStudio.runTemplate",ht=900,st=2e3,Ba=[];function Ee(){const t=de();return(0,d.useCallback)(n=>a=>{const o=Tn(a);if(o){t?.pushToast({tone:"warn",title:o.title,body:o.remediation});return}const r=a instanceof Error&&a.message?a.message:"Please try again.";t?.pushToast({tone:"error",title:n,body:r})},[t])}s(Ee,"useMutationErrorToast");var pt={skill:37.5,input:25,runs:37.5};function Oa(){try{const t=localStorage.getItem(es);if(!t)return pt;const n=JSON.parse(t);if(typeof n?.skill=="number"&&typeof n?.input=="number"&&typeof n?.runs=="number")return{skill:n.skill,input:n.input,runs:n.runs}}catch{}return pt}s(Oa,"loadPaneLayout");function ts(t){return`${Ka}.${t}`}s(ts,"runTemplateStorageKey");function ft(t){try{return Fa(localStorage.getItem(ts(t)))}catch{return Jt}}s(ft,"loadRunTemplateSelection");function Va(t,n){try{localStorage.setItem(ts(t),Ta(n))}catch{}}s(Va,"persistRunTemplateSelection");function Ua(){const[t,n]=(0,d.useState)(()=>typeof window<"u"&&window.innerWidth<ht);return(0,d.useEffect)(()=>{const a=s(()=>n(window.innerWidth<ht),"onResize");return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),t}s(Ua,"useIsMobile");function Ml(){const{skillId:t=""}=ds(),n=cs(),[a]=Ct(),{selectedCompanyId:o}=us(),{setBreadcrumbs:r}=Ms(),l=Te(),i=o??"",c=n.pathname.replace(/\/+$/,"").endsWith("/skills/studio/new"),u=c&&a.get("forkFrom")?.trim()||null,f=c&&a.get("folderId")?.trim()||null,m=Y({queryKey:R.companySkills.list(i),queryFn:s(()=>q.list(i,{sort:"alphabetical"}),"queryFn"),enabled:!!i}),k=Y({queryKey:R.companySkills.detail(i,t),queryFn:s(()=>q.detail(i,t),"queryFn"),enabled:!!(i&&t&&!c)}),h=Y({queryKey:R.companySkills.detail(i,u??""),queryFn:s(()=>q.detail(i,u),"queryFn"),enabled:!!(i&&u)}),x=k.data??null;return(0,d.useEffect)(()=>{r(c?[{label:"Skills",href:"/skills"},{label:"Studio",href:"/skills/studio"},{label:"New skill"}]:x?[{label:"Skills",href:"/skills"},{label:"Studio",href:"/skills/studio"},{label:x.name}]:[{label:"Skills",href:"/skills"},{label:"Studio"}])},[c,r,x]),(0,d.useEffect)(()=>{x?.id&&Pn(x.id)},[x?.id]),i?c?(0,e.jsx)(Qa,{companyId:i,skills:m.data??[],skillsLoading:m.isLoading,forkFromSkillId:u,folderId:f,forkSkill:h.data??null,forkLoading:h.isLoading,forkError:h.isError,onSelectSkill:s(b=>l(le(b)),"onSelectSkill")}):t?k.isLoading?(0,e.jsx)(Se,{message:"Loading skill…"}):k.isError||!k.data?(0,e.jsx)(Se,{message:"Skill not found."}):(0,e.jsx)(Ha,{companyId:i,skill:k.data,skills:m.data??[],skillsLoading:m.isLoading}):(0,e.jsx)(Wa,{companyId:i,skills:m.data??[],skillsLoading:m.isLoading,onSelectSkill:s(b=>l(le(b)),"onSelectSkill"),onCreateNew:s(()=>l(wn()),"onCreateNew")}):(0,e.jsx)(Se,{message:"Select an organization to open Skill Studio."})}s(Ml,"SkillStudio");function Qa({companyId:t,skills:n,skillsLoading:a,forkFromSkillId:o,folderId:r,forkSkill:l,forkLoading:i,forkError:c,onSelectSkill:u}){return(0,e.jsx)(je,{delayDuration:200,children:(0,e.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,e.jsx)("header",{className:"flex items-center gap-3 border-b border-line px-3 py-2",children:(0,e.jsx)(Pe,{skill:null,skills:n,loading:a,onSelectSkill:u,emptyLabel:"New skill"})}),(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(0,e.jsx)(Ya,{companyId:t,forkFromSkillId:o,folderId:r,forkSkill:l,forkLoading:i,forkError:c})})]})})}s(Qa,"StudioCreateMode");function Ya({companyId:t,forkFromSkillId:n,folderId:a,forkSkill:o,forkLoading:r,forkError:l}){const i=Te(),c=Z(),u=de(),f=(0,d.useMemo)(()=>{const v=o?pn(o):jn();return a?{...v,folderId:a}:v},[o,a]),[m,k]=(0,d.useState)(f),[h,x]=(0,d.useState)(f.slug.trim().length>0),[b,S]=(0,d.useState)(f.categories.join(", ")),D=fn(b),E=m.slug.trim()||$e(m.name),j=m.name.trim().length>0;(0,d.useEffect)(()=>{k(f),x(f.slug.trim().length>0),S(f.categories.join(", "))},[f]);function N(v){k(T=>({...T,...v}))}s(N,"patchDraft");const w=B({mutationFn:s(()=>q.create(t,hn({...m,categories:D})),"mutationFn"),onSuccess:s(async v=>{await c.invalidateQueries({queryKey:R.companySkills.list(t)}),u?.pushToast({tone:"success",title:v.forkedFromSkillId?"Skill fork created":"Skill created",body:`${v.name} is now editable in the Wardmote workspace.`}),i(le(v.id))},"onSuccess"),onError:s(v=>{u?.pushToast({tone:"error",title:"Skill creation failed",body:v instanceof Error?v.message:"Failed to create skill."})},"onError")});if(n&&r)return(0,e.jsx)(Se,{message:"Loading fork source..."});const y={key:E||m.name||"new-skill",skillId:null,catalogRef:null,name:m.name||"New Skill",slug:E||"skill",author:"you",version:null,tagline:m.tagline||null,description:m.tagline,categories:D,iconUrl:null,color:m.color,starCount:0,agentCount:0,forkCount:0,installed:!1,required:!1,forkedFrom:!!m.forkedFromSkillId,updatedAt:Date.now()};return(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-6 px-4 py-6",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-ink",children:m.forkedFromSkillId?"Fork skill":"Create a new skill"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Create an editable organization skill and open it directly in Studio."})]}),m.forkedFromName?(0,e.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-line bg-bg-3/30 px-3 py-2 text-sm text-ink-3",children:[(0,e.jsx)(Re,{className:"h-4 w-4"}),"Forking ",m.forkedFromName]}):l?(0,e.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-bad/40 bg-bad/10 px-3 py-2 text-sm text-bad",children:[(0,e.jsx)(ae,{className:"h-4 w-4"}),"Fork source not found. You can still create a blank skill."]}):null,(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-ink",children:"Basics"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Name the skill and set the route-safe slug."})]}),(0,e.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(U,{htmlFor:"skill-name",children:"Name"}),(0,e.jsx)(X,{id:"skill-name",value:m.name,onChange:s(v=>{const T=v.target.value;N({name:T,slug:h?m.slug:$e(T),markdown:m.markdown===ye(m.name,m.tagline)?ye(T,m.tagline):m.markdown})},"onChange"),placeholder:"Code review"})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(U,{htmlFor:"skill-slug",children:"Slug"}),(0,e.jsx)(X,{id:"skill-slug",value:m.slug,onChange:s(v=>{const T=$e(v.target.value);x(T.length>0),N({slug:T})},"onChange"),placeholder:"code-review",className:"font-mono"})]})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(U,{htmlFor:"skill-tagline",children:"Tagline"}),(0,e.jsx)(ie,{id:"skill-tagline",value:m.tagline,onChange:s(v=>{const T=v.target.value;N({tagline:T,description:m.description?m.description:T,markdown:m.markdown===ye(m.name,m.tagline)?ye(m.name,T):m.markdown})},"onChange"),placeholder:"Review repository changes for correctness, tests, and maintainability.",className:"min-h-20"})]})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-ink",children:"Appearance"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Tune how the skill appears in the store and Studio switcher."})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(kn,{card:y,size:48}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"truncate text-sm font-medium",children:y.name}),(0,e.jsx)("div",{className:"truncate text-xs text-ink-3",children:m.tagline||"No tagline yet."})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(U,{children:"Color"}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[gn.map(v=>(0,e.jsx)("button",{type:"button",onClick:s(()=>N({color:v}),"onClick"),className:H("h-7 w-7 rounded-md border",m.color===v?"border-ink":"border-line"),style:{backgroundColor:v},"aria-label":`Use ${v}`},v)),(0,e.jsx)(X,{"aria-label":"Hex color",value:m.color,onChange:s(v=>N({color:v.target.value}),"onChange"),className:"h-7 w-28 font-mono text-xs"})]})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(U,{htmlFor:"skill-categories",children:"Categories"}),(0,e.jsx)(X,{id:"skill-categories",value:b,onChange:s(v=>S(v.target.value),"onChange"),placeholder:"engineering, review, memory"})]})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-ink",children:"Sharing"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Choose who can discover this skill inside Wardmote."})]}),(0,e.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3",children:[["company","private"].map(v=>(0,e.jsxs)("button",{type:"button",onClick:s(()=>N({sharingScope:v}),"onClick"),className:H("rounded-md border px-3 py-2 text-left text-sm",m.sharingScope===v?"border-ink bg-bg-3/50":"border-line"),children:[(0,e.jsx)("span",{className:"block font-medium",children:v==="company"?"Organization":"Private"}),(0,e.jsx)("span",{className:"mt-1 block text-xs text-ink-3",children:v==="company"?"Visible inside this organization.":"Only visible in your library."})]},v)),(0,e.jsxs)("button",{type:"button",disabled:!0,className:"rounded-md border border-dashed border-line px-3 py-2 text-left text-sm text-ink-3",children:[(0,e.jsx)("span",{className:"block font-medium",children:"Public"}),(0,e.jsx)("span",{className:"mt-1 block text-xs",children:"Coming later."})]})]})]}),(0,e.jsxs)("details",{className:"rounded-md border border-line px-3 py-2",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm font-medium text-ink",children:"Starter content"}),(0,e.jsx)(ie,{value:m.markdown,onChange:s(v=>N({markdown:v.target.value}),"onChange"),className:"mt-3 min-h-(--sz-22rem) resize-y font-mono text-xs"})]}),(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2 border-t border-line pt-4",children:[(0,e.jsx)(C,{variant:"ghost",onClick:s(()=>i("/skills/studio"),"onClick"),disabled:w.isPending,children:"Cancel"}),(0,e.jsxs)(C,{onClick:s(()=>w.mutate(),"onClick"),disabled:w.isPending||!j,children:[(0,e.jsx)(Ze,{className:"h-4 w-4"}),w.isPending?"Creating...":m.forkedFromSkillId?"Create fork":"Create skill"]})]})]})}s(Ya,"StudioNewSkillPanel");function Se({message:t}){return(0,e.jsx)("div",{className:"flex h-full min-h-(--sz-60vh) items-center justify-center text-sm text-ink-3",children:t})}s(Se,"StudioMessage");function Ga({skills:t,skillsLoading:n,onSelectSkill:a,onCreateNew:o}){return(0,e.jsx)(je,{delayDuration:200,children:(0,e.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,e.jsx)("header",{className:"flex items-center gap-3 border-b border-line px-3 py-2",children:(0,e.jsx)(Pe,{skill:null,skills:t,loading:n,onSelectSkill:a,emptyLabel:"Select skill"})}),(0,e.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,e.jsx)(De,{icon:Tt,message:n?"Loading skills...":"Select a skill to open Studio.",action:"Create a new skill",onAction:o})})]})})}s(Ga,"StudioEmptyState");function Wa({companyId:t,skills:n,skillsLoading:a,onSelectSkill:o,onCreateNew:r}){const l=Y({queryKey:R.companySkills.listRecent(t),queryFn:s(()=>q.list(t,{sort:"recent",include:["lastEditor"]}),"queryFn"),enabled:!!t}),i=l.data??[],c=(0,d.useMemo)(()=>$a(i,En()),[i]),u=(0,d.useMemo)(()=>za(i,c.map(f=>f.id)),[i,c]);return i.length===0?(0,e.jsx)(Ga,{skills:n,skillsLoading:a||l.isLoading,onSelectSkill:o,onCreateNew:r}):(0,e.jsx)(je,{delayDuration:200,children:(0,e.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,e.jsxs)("header",{className:"flex items-center gap-3 border-b border-line px-3 py-2",children:[(0,e.jsx)(Pe,{skill:null,skills:n,loading:a,onSelectSkill:o,emptyLabel:"Select skill"}),(0,e.jsxs)(C,{variant:"ghost",size:"sm",className:"ml-auto",onClick:r,children:[(0,e.jsx)(ce,{className:"mr-1.5 h-3.5 w-3.5"}),"New skill"]})]}),(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:(0,e.jsxs)("div",{className:"mx-auto w-full max-w-3xl space-y-8 px-4 py-8",children:[c.length>0?(0,e.jsx)(gt,{title:"Recently visited",skills:c,onSelectSkill:o}):null,(0,e.jsx)(gt,{title:"Recently updated",skills:u,onSelectSkill:o})]})})]})})}s(Wa,"StudioLanding");function gt({title:t,skills:n,onSelectSkill:a}){return n.length===0?null:(0,e.jsxs)("section",{className:"space-y-2",children:[(0,e.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-ink-3",children:t}),(0,e.jsx)("div",{className:"divide-y divide-line overflow-hidden rounded-md border border-line",children:n.map(o=>(0,e.jsx)(Ja,{skill:o,onSelect:s(()=>a(o.id),"onSelect")},o.id))})]})}s(gt,"StudioLandingSection");function Ja({skill:t,onSelect:n}){const a=_a(t.lastEditor);return(0,e.jsxs)("button",{type:"button",onClick:n,className:"flex w-full items-center gap-3 px-3 py-2.5 text-left hover:bg-bg-3",children:[(0,e.jsx)(Xa,{skill:t}),(0,e.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,e.jsx)("span",{className:"truncate text-sm font-medium",children:t.name}),t.tagline?(0,e.jsx)("span",{className:"truncate text-xs text-ink-3",children:t.tagline}):null]}),(0,e.jsxs)("span",{className:"shrink-0 text-xs text-ink-3",children:["updated ",ge(t.updatedAt)]}),a?(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsxs)(fs,{size:"xs",children:[a.imageUrl?(0,e.jsx)(hs,{src:a.imageUrl,alt:""}):null,(0,e.jsx)(ps,{children:a.initials})]})}),(0,e.jsx)(W,{children:a.name})]}):(0,e.jsx)("span",{className:"w-5 shrink-0","aria-hidden":"true"})]})}s(Ja,"StudioLandingRow");function Xa({skill:t}){if(t.iconUrl)return(0,e.jsx)("img",{src:t.iconUrl,alt:"",className:"h-9 w-9 shrink-0 rounded-md object-cover"});const n=bn(t.key,t.color),a=(t.slug||t.name||"?").trim().charAt(0).toUpperCase();return(0,e.jsx)("span",{"aria-hidden":"true",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-sm font-semibold text-white",style:{backgroundColor:n},children:a})}s(Xa,"SkillLandingIcon");function Ha({companyId:t,skill:n,skills:a,skillsLoading:o}){const r=n.id,l=Ua(),[i,c]=Ct(),u=Te(),f=Z(),[m,k]=(0,d.useState)(()=>i.get("input")),[h,x]=(0,d.useState)(()=>i.get("run")),[b,S]=(0,d.useState)(!1),[D,E]=(0,d.useState)(""),[j,N]=(0,d.useState)(null),[w,y]=(0,d.useState)(!1),[v,T]=(0,d.useState)(!1),[$,p]=(0,d.useState)(!1),L=(0,d.useRef)(Oa());(0,d.useEffect)(()=>{const g=new URLSearchParams(i);m?g.set("input",m):g.delete("input"),h?g.set("run",h):g.delete("run"),g.toString()!==i.toString()&&c(g,{replace:!0})},[m,h]);const K=Y({queryKey:R.companySkills.testInputs(t,r),queryFn:s(()=>q.testInputs(t,r),"queryFn"),enabled:!!(t&&r)}),I=(0,d.useCallback)(g=>{const z={skill:g.skill??L.current.skill,input:g.input??L.current.input,runs:g.runs??L.current.runs};L.current=z;try{localStorage.setItem(es,JSON.stringify(z))}catch{}},[]),M=K.data??[],_=M.find(g=>g.id===m)??null,P=(0,e.jsx)(ti,{companyId:t,skill:n,onDirtyChange:y,onEditACopy:s(()=>p(!0),"onEditACopy")}),O=Gn(n.metadata),Q=(0,e.jsx)(li,{companyId:t,skillId:r,inputs:M,loading:K.isLoading,selectedInputId:m,adHocMode:b,adHocContent:D,onAdHocChange:E,onSelectInput:s(g=>{k(g),S(!1)},"onSelectInput"),onSelectAdHoc:s(()=>{E(""),S(!0),k(null)},"onSelectAdHoc")}),F=(0,e.jsx)(oi,{companyId:t,skill:n,inputs:M,selectedInput:_,adHocMode:b,adHocContent:D,selectedRunId:h,onSelectRun:x,selectedAgentId:j,onSelectAgent:N,skillDirty:w,filterInput:_,onClearFilter:s(()=>k(null),"onClearFilter")});return(0,e.jsxs)(je,{delayDuration:200,children:[(0,e.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,e.jsx)(Za,{companyId:t,skill:n,skillDirty:w,skills:a,skillsLoading:o,onSelectSkill:s(g=>u(le(g)),"onSelectSkill"),onOpenVersions:s(()=>T(!0),"onOpenVersions")}),O?(0,e.jsx)(Xn,{skill:n,onEditACopy:s(()=>p(!0),"onEditACopy")}):null,l?(0,e.jsx)(ki,{skill:P,input:Q,runs:F}):(0,e.jsxs)(Fn,{className:"flex-1 min-h-0",defaultLayout:{skill:L.current.skill,input:L.current.input,runs:L.current.runs},onLayoutChanged:I,children:[(0,e.jsx)(ze,{id:"skill",minSize:"280px",className:"border-r border-line",children:P}),(0,e.jsx)(ct,{}),(0,e.jsx)(ze,{id:"input",minSize:"240px",collapsible:!0,collapsedSize:"40px",className:"border-r border-line",children:Q}),(0,e.jsx)(ct,{}),(0,e.jsx)(ze,{id:"runs",minSize:"360px",children:F})]})]}),(0,e.jsx)(bi,{open:v,onOpenChange:T,companyId:t,skill:n,onRestored:s(()=>{y(!1),f.invalidateQueries({queryKey:R.companySkills.detail(t,r)})},"onRestored"),onFilterRuns:s(g=>k(g),"onFilterRuns")}),(0,e.jsx)(Wn,{companyId:t,skill:n,open:$,onOpenChange:p})]})}s(Ha,"StudioShell");function Za({companyId:t,skill:n,skillDirty:a,skills:o,skillsLoading:r,onSelectSkill:l,onOpenVersions:i}){const c=n.currentVersion?.revisionNumber??null,u=de(),f=(0,d.useCallback)(()=>{const m=typeof window<"u"?window.location.href:"";Ys(m).then(()=>u?.pushToast({tone:"success",title:"Link copied",body:"Skill Studio link copied to clipboard."})).catch(k=>u?.pushToast({tone:"error",title:"Copy failed",body:k instanceof Error?k.message:"Could not copy the link."}))},[u]);return(0,e.jsxs)("header",{className:"flex items-center gap-3 border-b border-line px-3 py-2",children:[(0,e.jsx)(Pe,{skill:n,skills:o,loading:r,onSelectSkill:l}),c!==null&&(0,e.jsxs)("span",{className:"font-mono text-xs text-ink-3",children:["v",c]}),a?(0,e.jsx)(ee,{variant:"secondary",children:"Unsaved edits"}):null,n.editable?null:(0,e.jsx)(ee,{variant:"secondary",children:"Read-only"}),n.forkedFromSkillId?(0,e.jsx)(Jn,{companyId:t,forkedFromSkillId:n.forkedFromSkillId}):null,(0,e.jsx)(Ln,{companyId:t,skill:n}),(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,e.jsxs)(C,{variant:"ghost",size:"sm",onClick:i,children:[(0,e.jsx)(Kt,{className:"mr-1.5 h-3.5 w-3.5"}),"Version history"]}),(0,e.jsxs)(Dt,{children:[(0,e.jsx)(Ft,{asChild:!0,children:(0,e.jsx)(C,{variant:"ghost",size:"icon-sm","aria-label":"Studio menu",children:(0,e.jsx)(Lt,{className:"h-4 w-4"})})}),(0,e.jsx)(At,{align:"end",className:"w-52",children:(0,e.jsxs)(Oe,{onClick:f,children:[(0,e.jsx)(en,{className:"mr-2 h-4 w-4"})," Share link"]})})]})]})]})}s(Za,"StudioHeader");function Pe({skill:t,skills:n,loading:a,onSelectSkill:o,emptyLabel:r="Select skill"}){const l=(0,d.useMemo)(()=>[{id:"skills",options:ei(n,t).map(i=>({key:i.id,value:i.id,label:i.name,title:i.name,searchText:[i.name,i.slug,i.key,i.description??""].join(" "),skill:i}))}],[t,n]);return(0,e.jsx)(Qe,{value:t?.id??"",groups:l,loading:a,loadingMessage:"Loading skills...",placeholder:r,searchPlaceholder:"Search skills...",emptyMessage:"No matching skills.",onValueChange:s(i=>{i!==t?.id&&o(i)},"onValueChange"),triggerClassName:"h-8 w-64 border-0 bg-transparent px-0 text-base font-semibold shadow-none hover:bg-bg-3 md:w-80",contentClassName:"w-80",contentWidth:"auto",renderValue:s(i=>i?.label??t?.name??r,"renderValue"),renderOption:s((i,{selected:c})=>(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)("span",{className:H("truncate",c&&"font-medium"),children:i.label}),(0,e.jsx)("span",{className:"truncate text-(length:--text-micro) text-ink-3",children:i.skill.slug})]}),"renderOption")})}s(Pe,"SkillSwitcher");function ei(t,n){return n?t.some(a=>a.id===n.id)?t:[n,...t]:t}s(ei,"withCurrentSkill");function ti({companyId:t,skill:n,onDirtyChange:a,onEditACopy:o}){const r=n.id,l=Z(),i=Ee(),c=(0,d.useMemo)(()=>n.fileInventory.map(F=>F.path),[n.fileInventory]),[u,f]=(0,d.useState)(()=>c.find(F=>/skill\.md$/i.test(F))??c[0]??"SKILL.md"),[m,k]=(0,d.useState)(new Set),[h,x]=(0,d.useState)(""),[b,S]=(0,d.useState)(""),[D,E]=(0,d.useState)(null),[j,N]=(0,d.useState)(!1),w=(0,d.useRef)(!1),y=(0,d.useCallback)(()=>{w.current=!0},[]),v=(0,d.useMemo)(()=>zt(Object.fromEntries(c.map(F=>[F,""]))),[c]),T=Y({queryKey:R.companySkills.file(t,r,u),queryFn:s(()=>q.file(t,r,u),"queryFn"),enabled:!!(t&&r&&u)});(0,d.useEffect)(()=>{T.data&&(w.current=!1,x(T.data.content),S(T.data.content))},[T.data]);const $=h!==b,p=si(u),L=(0,d.useMemo)(()=>new Set(c),[c]);(0,d.useEffect)(()=>{a($)},[$,a]);const K=(0,d.useCallback)(F=>{F!==u&&($&&typeof window<"u"&&!window.confirm("Discard unsaved edits and switch files?")||f(F))},[$,u]),I=B({mutationFn:s(()=>q.updateFile(t,r,u,h),"mutationFn"),onSuccess:s(F=>{S(F.content),l.invalidateQueries({queryKey:R.companySkills.detail(t,r)}),l.invalidateQueries({queryKey:R.companySkills.list(t)}),l.invalidateQueries({queryKey:R.companySkills.versions(t,r)})},"onSuccess"),onError:i("Couldn't save file")}),M=B({mutationFn:s(({path:F,content:g})=>q.updateFile(t,r,F,g),"mutationFn"),onSuccess:s(F=>{f(F.path),x(F.content),S(F.content),E(null),l.invalidateQueries({queryKey:R.companySkills.detail(t,r)}),l.invalidateQueries({queryKey:R.companySkills.list(t)}),l.invalidateQueries({queryKey:R.companySkills.versions(t,r)})},"onSuccess"),onError:i("Couldn't create file")}),_=B({mutationFn:s(F=>q.deleteFile(t,r,F),"mutationFn"),onSuccess:s(F=>{const g=new Set(F.deletedPaths),z=c.filter(V=>!g.has(V));f(z.find(V=>/skill\.md$/i.test(V))??z[0]??"SKILL.md"),N(!1),l.invalidateQueries({queryKey:R.companySkills.detail(t,r)}),l.invalidateQueries({queryKey:R.companySkills.list(t)}),l.invalidateQueries({queryKey:R.companySkills.versions(t,r)})},"onSuccess"),onError:i("Couldn't delete file")}),P=n.editable===!1||T.data?.editable===!1;if(c.length===0)return(0,e.jsxs)(ne,{title:(0,e.jsx)(jt,{skillName:n.name,folder:"root"}),action:(0,e.jsx)(bt,{readOnly:P,selectedFile:u,currentFolder:"",canDeleteFile:!1,pending:M.isPending||_.isPending||$,onAddFile:s(()=>E("file"),"onAddFile"),onAddFolder:s(()=>E("folder"),"onAddFolder"),onDeleteFile:s(()=>{},"onDeleteFile"),onDeleteFolder:s(()=>N(!0),"onDeleteFolder")}),children:[(0,e.jsx)(De,{icon:Tt,message:"This skill has no files yet."}),(0,e.jsx)(kt,{mode:D,open:D!==null,onOpenChange:s(F=>{F||E(null)},"onOpenChange"),currentFolder:"",existingPaths:L,pending:M.isPending,onSubmit:s((F,g)=>M.mutate({path:F,content:g}),"onSubmit")})]});const O=T.data?.markdown??/\.md$/i.test(u),Q=O?Ie(h):null;return(0,e.jsxs)(ne,{title:(0,e.jsx)(jt,{skillName:n.name,folder:p||"root"}),action:(0,e.jsx)(bt,{readOnly:P,selectedFile:u,currentFolder:p,canDeleteFile:u!=="SKILL.md",pending:M.isPending||_.isPending||$,onAddFile:s(()=>E("file"),"onAddFile"),onAddFolder:s(()=>E("folder"),"onAddFolder"),onDeleteFile:s(()=>_.mutate({path:u,target:"file"}),"onDeleteFile"),onDeleteFolder:s(()=>N(!0),"onDeleteFolder")}),children:[(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[$&&!P?(0,e.jsxs)("div",{className:"flex items-start gap-2 border-b border-line bg-bg-3/40 px-3 py-2 text-xs text-ink-3",children:[(0,e.jsx)(ae,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500"}),(0,e.jsx)("span",{children:"Unsaved edits live only in this Studio session. Save to create the next version before running tests or switching files."})]}):null,(0,e.jsx)("div",{className:"max-h-(--sz-11_75rem) overflow-auto border-b border-line p-1",children:(0,e.jsx)(qt,{nodes:v,selectedFile:u,expandedDirs:m,onToggleDir:s(F=>k(g=>{const z=new Set(g);return z.has(F)?z.delete(F):z.add(F),z}),"onToggleDir"),onSelectFile:K,showCheckboxes:!1,ariaLabel:"Skill files"})}),(0,e.jsx)(Cn,{skill:n}),P&&(0,e.jsxs)("div",{className:"flex items-start gap-3 border-b border-line bg-bg-3/40 px-3 py-2.5 text-xs text-ink-3",children:[(0,e.jsx)(ae,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500"}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("p",{children:[n.metadata?.skillSourceId?"This skill is synced from GitHub and is read-only.":n.editableReason??"This skill is read-only because it comes from an external source."," ","Make an editable copy to change it — the original stays untouched."]}),(0,e.jsxs)(C,{type:"button",size:"sm",className:"mt-2",onClick:o,children:[(0,e.jsx)(Re,{className:"mr-1.5 h-3.5 w-3.5"}),"Make a copy"]})]})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5",children:[(0,e.jsxs)("span",{className:"truncate font-mono text-xs text-ink-3",children:[u,n.currentVersion?` · v${n.currentVersion.revisionNumber}`:""]}),(0,e.jsx)("div",{className:"flex items-center gap-2",children:P?(0,e.jsx)(ee,{variant:"secondary",children:"Read-only"}):(0,e.jsxs)(e.Fragment,{children:[$&&(0,e.jsx)(ee,{variant:"secondary",children:"Unsaved"}),(0,e.jsx)(C,{size:"sm",disabled:!$||I.isPending,onClick:s(()=>I.mutate(),"onClick"),children:I.isPending?"Saving…":"Save"})]})})]}),O&&Q?.hasFrontmatter?(0,e.jsx)(na,{frontmatterText:Q.frontmatterText,hasFrontmatter:Q.hasFrontmatter,fileName:u,skillSlug:n.slug,readOnly:P,onChange:s(F=>{x(g=>lt({frontmatterText:F.frontmatterText,body:Ie(g).body,hasFrontmatter:F.hasFrontmatter}))},"onChange")},`fm:${u}`):null,(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-auto px-3 pb-3",onBeforeInputCapture:y,onDropCapture:y,onInput:y,onKeyDownCapture:y,onPasteCapture:y,onPointerDownCapture:y,children:T.data?.encoding==="base64"?(0,e.jsx)(Nn,{file:T.data}):O&&Q?(0,e.jsx)(js,{value:Q.body,onChange:s(F=>{w.current&&x(g=>{const z=Ie(g);return lt({...z,body:F})})},"onChange"),bordered:!1,readOnly:P,className:"min-h-(--sz-320px)"},`body:${u}`):(0,e.jsx)(ie,{value:h,onChange:s(F=>x(F.target.value),"onChange"),readOnly:P,className:"min-h-(--sz-320px) font-mono text-xs",spellCheck:!1})})]}),(0,e.jsx)(kt,{mode:D,open:D!==null,onOpenChange:s(F=>{F||E(null)},"onOpenChange"),currentFolder:p,existingPaths:L,pending:M.isPending,onSubmit:s((F,g)=>M.mutate({path:F,content:g}),"onSubmit")}),(0,e.jsx)(ii,{open:j,onOpenChange:N,currentFolder:p,existingPaths:L,pending:_.isPending,onSubmit:s(F=>_.mutate({path:F,target:"folder"}),"onSubmit")})]})}s(ti,"SkillPane");function si(t){const n=t.split("/").filter(Boolean);return n.length<=1?"":n.slice(0,-1).join("/")}s(si,"parentFolder");function Ce(t){return t.replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"").split("/").filter(n=>n&&n!==".").join("/")}s(Ce,"normalizeStudioPath");function ni(t){return`${t}/README.md`}s(ni,"folderSeedFile");function ai(t){return`# ${t.split("/").filter(Boolean).at(-1)??"Folder"}
3
3
  `}s(ai,"folderSeedContent");function jt({skillName:t,folder:n}){return(0,e.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,e.jsx)("span",{className:"truncate",children:t}),(0,e.jsx)(fe,{className:"h-3 w-3 shrink-0"}),(0,e.jsx)("span",{className:"truncate font-mono normal-case tracking-normal",children:n})]})}s(jt,"SkillPaneTitle");function bt({readOnly:t,selectedFile:n,canDeleteFile:a,pending:o,onAddFile:r,onAddFolder:l,onDeleteFile:i,onDeleteFolder:c}){const u=t||o;return(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",disabled:u,onClick:r,"aria-label":"Add file",children:(0,e.jsx)(Ze,{className:"h-4 w-4"})})})}),(0,e.jsx)(W,{children:"Add file"})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",disabled:u,onClick:l,"aria-label":"Add folder",children:(0,e.jsx)(Sn,{className:"h-4 w-4"})})})}),(0,e.jsx)(W,{children:"Add folder"})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",disabled:u||!a,onClick:s(()=>{(typeof window>"u"||window.confirm(`Delete ${n}?`))&&i()},"onClick"),"aria-label":"Delete file",children:(0,e.jsx)(te,{className:"h-4 w-4"})})})}),(0,e.jsx)(W,{children:a?"Delete file":"SKILL.md cannot be deleted"})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",disabled:u,onClick:c,"aria-label":"Delete folder",children:(0,e.jsx)(Rn,{className:"h-4 w-4"})})})}),(0,e.jsx)(W,{children:"Delete folder"})]})]})}s(bt,"SkillFileActions");function kt({mode:t,open:n,onOpenChange:a,currentFolder:o,existingPaths:r,pending:l,onSubmit:i}){const[c,u]=(0,d.useState)(""),[f,m]=(0,d.useState)(null);(0,d.useEffect)(()=>{!n||!t||(u(Ce(t==="folder"?o?`${o}/new-folder`:"new-folder":o?`${o}/new-file.md`:"notes.md")),m(null))},[o,t,n]);const k=t==="folder"?"Add folder":"Add file",h=t==="folder"?"Folder path":"File path";function x(){if(!t)return;const b=Ce(c);if(!b){m(`${h} is required.`);return}if(t==="file"){if(r.has(b)){m("A file already exists at that path.");return}i(b,"");return}const S=b.replace(/\/+$/,"");if([...r].some(D=>D.startsWith(`${S}/`))){m("A folder already exists at that path.");return}i(ni(S),ai(S))}return s(x,"submit"),(0,e.jsx)(pe,{open:n,onOpenChange:a,children:(0,e.jsxs)(me,{children:[(0,e.jsxs)(ue,{children:[(0,e.jsx)(he,{children:k}),(0,e.jsx)(xe,{children:"Saved changes create a new version immediately. External sources are not updated until you publish or install an update."})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(U,{htmlFor:"skill-path-input",children:h}),(0,e.jsx)(X,{id:"skill-path-input",value:c,onChange:s(b=>{u(b.target.value),m(null)},"onChange"),placeholder:t==="folder"?"references/examples":"references/examples.md"}),t==="folder"?(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"A README.md seed file is created so the folder appears in the file tree."}):null,f?(0,e.jsx)("p",{className:"text-xs text-bad",children:f}):null]}),(0,e.jsxs)(be,{children:[(0,e.jsx)(C,{variant:"ghost",onClick:s(()=>a(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(C,{disabled:l,onClick:x,children:"Create"})]})]})})}s(kt,"SkillPathDialog");function ii({open:t,onOpenChange:n,currentFolder:a,existingPaths:o,pending:r,onSubmit:l}){const[i,c]=(0,d.useState)(""),[u,f]=(0,d.useState)(null);(0,d.useEffect)(()=>{t&&(c(a),f(null))},[a,t]);function m(){const k=Ce(i).replace(/\/+$/,"");if(!k){f("Folder path is required.");return}const h=[...o].filter(x=>x.startsWith(`${k}/`));if(h.length===0){f("No files exist under that folder.");return}if(h.includes("SKILL.md")){f("SKILL.md cannot be deleted.");return}l(k)}return s(m,"submit"),(0,e.jsx)(pe,{open:t,onOpenChange:n,children:(0,e.jsxs)(me,{children:[(0,e.jsxs)(ue,{children:[(0,e.jsx)(he,{children:"Delete folder"}),(0,e.jsx)(xe,{children:"This removes every skill file under the folder and saves the result as the next version."})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(U,{htmlFor:"skill-folder-delete",children:"Folder path"}),(0,e.jsx)(X,{id:"skill-folder-delete",value:i,onChange:s(k=>{c(k.target.value),f(null)},"onChange"),placeholder:"references/examples"}),u?(0,e.jsx)("p",{className:"text-xs text-bad",children:u}):null]}),(0,e.jsxs)(be,{children:[(0,e.jsx)(C,{variant:"ghost",onClick:s(()=>n(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(C,{variant:"delete",disabled:r,onClick:m,children:"Delete"})]})]})})}s(ii,"DeleteFolderDialog");function li({companyId:t,skillId:n,inputs:a,loading:o,selectedInputId:r,adHocMode:l,adHocContent:i,onAdHocChange:c,onSelectInput:u,onSelectAdHoc:f}){const m=Z(),k=Ee(),h=Ws(),[x,b]=(0,d.useState)(new Set),[S,D]=(0,d.useState)(Ht),[E,j]=(0,d.useState)(!1),[N,w]=(0,d.useState)(!1),y=a.find(g=>g.id===r)??null,v=ya(S,y),T=l?i:v,$=l?c:g=>{D(z=>({inputId:y?.id??z.inputId,draft:g,baselineContent:y?.content??z.baselineContent}))};(0,d.useEffect)(()=>{l||D(g=>ka(g,y))},[l,y?.content,y?.id]),(0,d.useEffect)(()=>{!o&&a.length===0&&!l&&!r&&f()},[l,a.length,o,f,r]);const p=(0,d.useMemo)(()=>new Map(a.map(g=>[g.name,g.id])),[a]),L=(0,d.useMemo)(()=>zt(Object.fromEntries(a.map(g=>[g.name,g.content]))),[a]),K=y?.name??null,I=!l&&va(S,y),M=!!(y&&I&&T.trim()),_=(0,d.useCallback)(()=>I?typeof window>"u"||window.confirm("Discard unsaved changes to this input?"):!0,[I]),P=(0,d.useCallback)(g=>{!l&&g===r||_()&&u(g)},[l,_,u,r]),O=(0,d.useCallback)(()=>{!l&&!_()||f()},[l,_,f]),Q=B({mutationFn:s(g=>q.updateTestInput(t,n,y.id,g),"mutationFn"),onSuccess:s(g=>{D({inputId:g.id,draft:g.content,baselineContent:g.content}),m.setQueryData(R.companySkills.testInputs(t,n),z=>z?.map(V=>V.id===g.id?g:V)),m.invalidateQueries({queryKey:R.companySkills.testInputs(t,n)})},"onSuccess"),onError:k("Couldn't save input")}),F=B({mutationFn:s(g=>q.deleteTestInput(t,n,g),"mutationFn"),onSuccess:s(g=>{g.id===r&&f(),m.invalidateQueries({queryKey:R.companySkills.testInputs(t,n)})},"onSuccess"),onError:k("Couldn't delete input")});return(0,e.jsxs)(ne,{title:(0,e.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)(C,{type:"button",variant:"ghost",size:"icon-xs","aria-label":N?"Expand input":"Collapse input",onClick:s(()=>w(g=>!g),"onClick"),children:N?(0,e.jsx)(fe,{className:"h-3.5 w-3.5"}):(0,e.jsx)(Ue,{className:"h-3.5 w-3.5"})})}),(0,e.jsx)(W,{children:N?"Expand input":"Collapse input"})]}),(0,e.jsx)("span",{children:"Input"})]}),action:(0,e.jsx)("div",{className:"flex items-center gap-1",children:(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)(C,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"New input",children:(0,e.jsx)(ce,{className:"h-4 w-4"})})}),(0,e.jsx)(W,{children:"New input"})]})}),children:[N?(0,e.jsxs)("button",{type:"button",className:"flex min-h-(--sz-32px) items-center gap-2 border-b border-line px-3 py-2 text-left text-xs text-ink-3 hover:bg-bg-3 hover:text-ink",onClick:s(()=>w(!1),"onClick"),children:[(0,e.jsx)(fe,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{children:"Input folded"})]}):(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[o||a.length>0?(0,e.jsx)("div",{className:"max-h-(--sz-11_75rem) overflow-auto border-b border-line p-1",children:o?(0,e.jsx)("div",{className:"p-3 text-xs text-ink-3",children:"Loading inputs…"}):(0,e.jsxs)(e.Fragment,{children:[l&&(0,e.jsxs)("div",{className:"flex items-center gap-2 rounded px-2 py-1.5 text-sm italic text-ink-3",children:[(0,e.jsx)(Ze,{className:"h-3.5 w-3.5"})," New input (not saved)"]}),(0,e.jsx)(qt,{nodes:L,selectedFile:K,expandedDirs:x,onToggleDir:s(g=>b(z=>{const V=new Set(z);return V.has(g)?V.delete(g):V.add(g),V}),"onToggleDir"),onSelectFile:s(g=>{const z=p.get(g);z&&P(z)},"onSelectFile"),showCheckboxes:!1,renderFileExtra:s(g=>{const z=p.get(g.path);return z?(0,e.jsxs)(Dt,{children:[(0,e.jsx)(Ft,{asChild:!0,children:(0,e.jsx)("button",{className:"rounded p-0.5 text-ink-3 hover:bg-bg-3 hover:text-ink","aria-label":`Input actions for ${g.name}`,onClick:s(V=>V.stopPropagation(),"onClick"),children:(0,e.jsx)(Lt,{className:"h-3.5 w-3.5"})})}),(0,e.jsxs)(At,{align:"end",className:"w-44",children:[(0,e.jsxs)(Oe,{onClick:s(()=>{const V=a.find(Le=>Le.id===z);V&&h(V.content,"Input content copied")},"onClick"),children:[(0,e.jsx)(Pt,{className:"mr-2 h-4 w-4"})," Copy content"]}),(0,e.jsx)(gs,{}),(0,e.jsxs)(Oe,{variant:"destructive",onClick:s(()=>F.mutate(z),"onClick"),children:[(0,e.jsx)(te,{className:"mr-2 h-4 w-4"})," Delete"]})]})]}):null},"renderFileExtra"),ariaLabel:"Test inputs"})]})}):null,(0,e.jsx)("div",{className:"flex min-h-0 flex-1",children:(0,e.jsx)("textarea",{value:T,onChange:s(g=>$(g.target.value),"onChange"),placeholder:"Paste text - treated as a new issue description.","aria-label":"Skill test input",className:"min-h-0 flex-1 resize-none border-0 bg-transparent px-3 py-3 text-sm leading-6 outline-none placeholder:text-ink-3 focus-visible:ring-0"})}),(0,e.jsxs)("div",{className:"flex items-center gap-2 border-t border-line px-3 py-2",children:[(0,e.jsxs)("div",{className:"mr-auto flex min-w-0 items-center gap-2 text-xs text-ink-3",children:[(0,e.jsx)("span",{className:"truncate",children:y?y.name:l?"New input":"No input selected"}),I?(0,e.jsx)(ee,{variant:"secondary",children:"Unsaved"}):null]}),y&&I?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(C,{variant:"ghost",size:"sm",disabled:Q.isPending,onClick:s(()=>D({inputId:y.id,draft:y.content,baselineContent:y.content}),"onClick"),children:"Revert"}),(0,e.jsx)(C,{variant:"secondary",size:"sm",disabled:!M||Q.isPending,onClick:s(()=>Q.mutate({content:T}),"onClick"),children:Q.isPending?"Saving...":"Save changes"})]}):null,(0,e.jsx)(C,{size:"sm",disabled:!T.trim(),onClick:s(()=>j(!0),"onClick"),children:"Save as input"})]})]}),(0,e.jsx)(ri,{open:E,onOpenChange:j,companyId:t,skillId:n,initialContent:T,onSaved:s(g=>{j(!1),u(g.id)},"onSaved")})]})}s(li,"InputPane");function ri({open:t,onOpenChange:n,companyId:a,skillId:o,initialContent:r,onSaved:l}){const i=Z(),[c,u]=(0,d.useState)(""),[f,m]=(0,d.useState)(r);(0,d.useEffect)(()=>{t&&(m(r),u(""))},[t,r]);const k=B({mutationFn:s(()=>q.createTestInput(a,o,{name:c.trim(),content:f}),"mutationFn"),onSuccess:s(h=>{i.setQueryData(R.companySkills.testInputs(a,o),x=>[...(x??[]).filter(b=>b.id!==h.id),h].sort((b,S)=>b.name.localeCompare(S.name)||Number(new Date(b.createdAt))-Number(new Date(S.createdAt)))),i.invalidateQueries({queryKey:R.companySkills.testInputs(a,o)}),l(h)},"onSuccess")});return(0,e.jsx)(pe,{open:t,onOpenChange:n,children:(0,e.jsxs)(me,{children:[(0,e.jsxs)(ue,{children:[(0,e.jsx)(he,{children:"Save test input"}),(0,e.jsx)(xe,{children:"Runs snapshot input at run time — editing later won't change past runs."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(U,{htmlFor:"input-name",children:"Name"}),(0,e.jsx)(X,{id:"input-name",value:c,onChange:s(h=>u(h.target.value),"onChange"),placeholder:"onboarding/happy-path"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Use “/” for folders, e.g. onboarding/happy-path"})]}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(U,{htmlFor:"input-content",children:"Content"}),(0,e.jsx)(ie,{id:"input-content",value:f,onChange:s(h=>m(h.target.value),"onChange"),className:"min-h-(--sz-160px)"})]})]}),(0,e.jsxs)(be,{children:[(0,e.jsx)(C,{variant:"ghost",onClick:s(()=>n(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(C,{disabled:!c.trim()||!f.trim()||k.isPending,onClick:s(()=>k.mutate(),"onClick"),children:"Save"})]})]})})}s(ri,"SaveInputDialog");function oi({companyId:t,skill:n,inputs:a,selectedInput:o,adHocMode:r,adHocContent:l,selectedRunId:i,onSelectRun:c,selectedAgentId:u,onSelectAgent:f,skillDirty:m,filterInput:k,onClearFilter:h}){const x=n.id,b=Z(),S=Ee(),D=de(),[E,j]=(0,d.useState)(!1),[N,w]=(0,d.useState)(()=>ft(t)),[y,v]=(0,d.useState)(null),T=Y({queryKey:R.agents.list(t),queryFn:s(()=>we.list(t),"queryFn"),enabled:!!t}).data??[],$=T.find(A=>A.id===u)??null;(0,d.useEffect)(()=>{w(ft(t))},[t]);const p=(0,d.useCallback)(A=>{w(A),Va(t,A)},[t]),L=Y({queryKey:R.companySkills.testRunTemplates(t),queryFn:s(()=>q.testRunTemplates(t),"queryFn"),enabled:!!t}),K=L.data??Ba;(0,d.useEffect)(()=>{if(!L.isSuccess)return;const A=Ke(N,K);A.recovered&&(p(A.selection),D?.pushToast({tone:"warn",title:"Run template reset",body:"The saved run template is no longer available. Default test template is selected.",dedupeKey:`skill-studio-template-reset:${t}`}))},[t,N,K,L.isSuccess,D,p]);const I=k?.id??null,M=Y({queryKey:R.companySkills.testRuns(t,x,I),queryFn:s(()=>q.testRuns(t,x,I?{inputId:I}:{}),"queryFn"),enabled:!!(t&&x),refetchInterval:s(A=>A.state.data?.some(re=>Xt(re.status))?st:!1,"refetchInterval")}),_=M.data??[],P=r?l.trim().length>0:!!o?.content.trim(),O=ba({hasAgent:!!$,hasInput:P,skillFileCount:n.fileInventory.length,hasUnsavedSkillEdits:m}),Q=L.isLoading?"Loading run templates":L.isError?"Run templates couldn't load":null,F=B({mutationFn:s(A=>q.createTestRunTemplate(t,A),"mutationFn"),onSuccess:s(A=>{v(null),p(A.id),b.invalidateQueries({queryKey:R.companySkills.testRunTemplates(t)}),D?.pushToast({tone:"success",title:"Template saved",body:`${A.name} is ready for Skills Studio runs.`})},"onSuccess"),onError:S("Couldn't save template")}),g=B({mutationFn:s(({templateId:A,payload:re})=>q.updateTestRunTemplate(t,A,re),"mutationFn"),onSuccess:s(A=>{v(null),p(A.id),b.invalidateQueries({queryKey:R.companySkills.testRunTemplates(t)}),D?.pushToast({tone:"success",title:"Template updated",body:`${A.name} is ready for Skills Studio runs.`})},"onSuccess"),onError:S("Couldn't update template")}),z=B({mutationFn:s(A=>q.deleteTestRunTemplate(t,A),"mutationFn"),onSuccess:s(A=>{const re=Ke(N,K.filter(ss=>ss.id!==A.id));(N===A.id||re.recovered)&&p(re.selection),b.invalidateQueries({queryKey:R.companySkills.testRunTemplates(t)}),D?.pushToast({tone:"success",title:"Template deleted",body:`${A.name} was removed from Skills Studio runs.`})},"onSuccess"),onError:S("Couldn't delete template")}),V=N===null?null:K.find(A=>A.id===N)??null,Le=N===null?"No template":V?.name??"Default test template",nt=O.reason??Q,at=B({mutationFn:s(()=>{if(!L.isSuccess)throw new Error(Q??"Run templates are not ready.");const A=Ke(N,K);if(A.recovered)throw p(A.selection),new Error("Selected run template is no longer available. The selection was reset.");return q.createTestRun(t,x,Aa({agentId:u,inputId:r?null:o?.id??null,content:r?l:o?null:l,templateId:A.selection}))},"mutationFn"),onSuccess:s(A=>{b.invalidateQueries({queryKey:R.companySkills.testRuns(t,x,I)}),c(A.id)},"onSuccess"),onError:S("Couldn't start run")});return i?(0,e.jsx)(pi,{companyId:t,skill:n,runId:i,agents:T,onBack:s(()=>c(null),"onBack"),onSelectRun:c}):(0,e.jsxs)(ne,{title:"Test runs",action:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(hi,{agents:T,selectedAgent:$,onSelect:f}),(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsxs)(C,{size:"sm",disabled:O.disabled||!!Q||at.isPending,onClick:s(()=>at.mutate(),"onClick"),children:[(0,e.jsx)(Ps,{className:"mr-1.5 h-3.5 w-3.5"})," Run"]})})}),nt&&(0,e.jsx)(W,{side:"bottom",children:nt})]})]}),children:[(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,e.jsx)(ui,{open:E,onOpenChange:j,templates:K,templatesLoading:L.isLoading,templatesError:L.isError,selectedTemplateId:N,selectedTemplate:V,selectedTemplateName:Le,onSelectTemplate:p,onCreateTemplate:s(()=>v({mode:"create"}),"onCreateTemplate"),onEditTemplate:s(A=>v({mode:"edit",source:A}),"onEditTemplate"),onDuplicateTemplate:s(A=>v({mode:"create",source:A}),"onDuplicateTemplate"),onDeleteTemplate:s(A=>{typeof window<"u"&&!window.confirm(`Delete run template "${A.name}"?`)||z.mutate(A.id)},"onDeleteTemplate"),deletingTemplateId:z.variables??null,actionPending:F.isPending||g.isPending||z.isPending}),k&&(0,e.jsx)("div",{className:"px-3 pt-2",children:(0,e.jsx)(vn,{filters:[{key:"input",label:"Input",value:k.name}],onRemove:h,onClear:h})}),(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:M.isLoading?(0,e.jsx)("div",{className:"text-xs text-ink-3",children:"Loading runs…"}):_.length===0?(0,e.jsx)(De,{icon:Ts,message:"No test runs yet. Pick an agent and Run."}):(0,e.jsx)("div",{className:"space-y-1 rounded-md border border-line p-1",children:_.map(A=>(0,e.jsx)(xi,{run:A,agents:T,onSelect:s(()=>c(A.id),"onSelect")},A.id))})})]}),(0,e.jsx)(mi,{state:y,pending:F.isPending||g.isPending,onOpenChange:s(A=>{A||v(null)},"onOpenChange"),onSubmit:s(A=>{y?.mode==="edit"?g.mutate({templateId:y.source.id,payload:A}):F.mutate(A)},"onSubmit")})]})}s(oi,"RunsPane");function ci(t){return t??"__wardmote_no_template__"}s(ci,"runTemplateOptionValue");function di(t){return t==="__wardmote_no_template__"?null:t}s(di,"runTemplateSelectionFromOption");function ui({open:t,onOpenChange:n,templates:a,templatesLoading:o,templatesError:r,selectedTemplateId:l,selectedTemplate:i,selectedTemplateName:c,onSelectTemplate:u,onCreateTemplate:f,onEditTemplate:m,onDuplicateTemplate:k,onDeleteTemplate:h,deletingTemplateId:x,actionPending:b}){const S=(0,d.useMemo)(()=>{const y={key:"no-template",value:$t,label:"No template",title:"No template",description:"Run only the input text.",builtIn:!0,searchText:"no template plain input"},v=s(p=>({key:p.id,value:p.id,label:p.name,title:p.name,description:p.description,builtIn:p.builtIn,searchText:[p.name,p.description??"",p.builtIn?"built in":"custom"].join(" ")}),"toOption"),T=a.filter(p=>p.builtIn).map(v),$=a.filter(p=>!p.builtIn).map(v);return[{id:"built-in",label:"Built in",options:[y,...T]},...$.length>0?[{id:"custom",label:"Custom",options:$}]:[]]},[a]),D=ci(l),E=l!==null&&!i&&!o,j=!!(i&&!i.builtIn),N=!!i,w=!!(i&&!i.builtIn);return(0,e.jsxs)("div",{className:"border-b border-line",children:[(0,e.jsxs)("button",{type:"button",className:"flex min-h-(--sz-32px) w-full items-center gap-2 px-3 py-2 text-left text-xs text-ink-3 hover:bg-bg-3 hover:text-ink",onClick:s(()=>n(!t),"onClick"),children:[t?(0,e.jsx)(Ue,{className:"h-3.5 w-3.5"}):(0,e.jsx)(fe,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{className:"font-semibold uppercase tracking-wide",children:"Advanced"}),(0,e.jsx)("span",{className:"ml-auto truncate",children:c})]}),t?(0,e.jsxs)("div",{className:"space-y-3 px-3 pb-3 pt-1",children:[(0,e.jsxs)("div",{className:"flex items-end gap-2",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,e.jsx)(U,{children:"Run template"}),(0,e.jsx)(Qe,{value:D,groups:S,loading:o,disabled:o||r,loadingMessage:"Loading templates...",placeholder:"Select template",searchPlaceholder:"Search templates...",emptyMessage:"No templates.",contentClassName:"w-(--sz-320px)",onValueChange:s(y=>u(di(y)),"onValueChange"),renderValue:s(y=>y?.label??c,"renderValue"),renderOption:s((y,{selected:v})=>(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)("span",{className:H("truncate",v&&"font-medium"),children:y.label}),(0,e.jsx)("span",{className:"truncate text-(length:--text-micro) text-ink-3",children:y.description??(y.builtIn?"Built in":"Custom")})]}),"renderOption")})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)(C,{type:"button",variant:"secondary",size:"icon-sm","aria-label":"Create run template",disabled:b,onClick:f,children:(0,e.jsx)(ce,{})})}),(0,e.jsx)(W,{children:"Create run template"})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsx)(C,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Edit run template",disabled:!j||b,onClick:s(()=>i&&m(i),"onClick"),children:(0,e.jsx)(Hs,{})})})}),(0,e.jsx)(W,{children:"Edit custom template"})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsx)(C,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Duplicate run template",disabled:!N||b,onClick:s(()=>i&&k(i),"onClick"),children:(0,e.jsx)(Pt,{})})})}),(0,e.jsx)(W,{children:i?.builtIn?"Duplicate built-in template":"Duplicate template"})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsx)(C,{type:"button",variant:"danger",size:"icon-sm","aria-label":"Delete run template",disabled:!w||b||x===i?.id,onClick:s(()=>i&&h(i),"onClick"),children:(0,e.jsx)(te,{})})})}),(0,e.jsx)(W,{children:"Delete custom template"})]})]}),r?(0,e.jsx)("p",{className:"text-xs text-bad",children:"Run templates could not load."}):l===null?(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Runs will use only the input text."}):E?(0,e.jsx)("p",{className:"text-xs text-bad",children:"Selected template is no longer available."}):i?(0,e.jsxs)("div",{className:"space-y-2",children:[i.description?(0,e.jsx)("p",{className:"text-xs text-ink-3",children:i.description}):null,(0,e.jsx)("pre",{className:"max-h-(--sz-240px) overflow-auto whitespace-pre-wrap rounded-md border border-line bg-bg-3/30 p-3 text-xs leading-5 text-ink-3",children:i.body})]}):(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Loading template..."})]}):null]})}s(ui,"RunTemplateAdvancedPanel");function mi({state:t,pending:n,onOpenChange:a,onSubmit:o}){const r=t?.source??null,[l,i]=(0,d.useState)(""),[c,u]=(0,d.useState)(""),[f,m]=(0,d.useState)("");(0,d.useEffect)(()=>{t&&(i(t.mode==="edit"?r?.name??"":r?`${r.name} copy`:""),u(r?.description??""),m(r?.body??""))},[r,t]);const k=t?.mode==="edit"?"Edit run template":r?.builtIn?"Duplicate built-in template":"Create run template",h=t?.mode==="edit"?"Update the custom run instructions used by Skills Studio.":"Save reusable run instructions for Skills Studio.";return(0,e.jsx)(pe,{open:!!t,onOpenChange:a,children:(0,e.jsxs)(me,{children:[(0,e.jsxs)(ue,{children:[(0,e.jsx)(he,{children:k}),(0,e.jsx)(xe,{children:h})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(U,{htmlFor:"run-template-name",children:"Name"}),(0,e.jsx)(X,{id:"run-template-name",value:l,onChange:s(x=>i(x.target.value),"onChange"),placeholder:"Focused smoke"})]}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(U,{htmlFor:"run-template-description",children:"Description"}),(0,e.jsx)(X,{id:"run-template-description",value:c,onChange:s(x=>u(x.target.value),"onChange"),placeholder:"Short instructions for common skill checks"})]}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(U,{htmlFor:"run-template-body",children:"Body"}),(0,e.jsx)(ie,{id:"run-template-body",value:f,onChange:s(x=>m(x.target.value),"onChange"),className:"min-h-(--sz-240px) font-mono text-xs leading-5"}),(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Placeholders: ","{{skillName}}",", ","{{skillKey}}",", ","{{skillInvocation}}",", ","{{skillVersion}}",", ","{{runId}}",", ","{{issueId}}",", ","{{outputDocumentKey}}","."]})]})]}),(0,e.jsxs)(be,{children:[(0,e.jsx)(C,{variant:"ghost",onClick:s(()=>a(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(C,{disabled:!l.trim()||!f.trim()||n,onClick:s(()=>o({name:l.trim(),description:c.trim()||null,body:f}),"onClick"),children:n?"Saving...":"Save template"})]})]})})}s(mi,"RunTemplateDialog");function xi({run:t,agents:n,onSelect:a}){const o=n.find(c=>c.id===t.agentId)??null,r=!o,l=t.agentConfigSnapshot?.name??"Agent",i=o?.name??l;return(0,e.jsx)(He,{leading:(0,e.jsx)(_t,{status:t.status}),identifier:Ca(t),title:r?`${i} (removed)`:i,subtitle:ge(t.createdAt),trailing:(0,e.jsx)("span",{className:"font-mono text-xs text-ink-3",children:vt(t.cost.costCents)}),onClick:a})}s(xi,"RunHistoryRow");function hi({agents:t,selectedAgent:n,onSelect:a}){const[o,r]=(0,d.useState)(!1);return(0,e.jsxs)(ys,{open:o,onOpenChange:r,children:[(0,e.jsx)(bs,{asChild:!0,children:(0,e.jsx)(C,{variant:"secondary",size:"sm",children:n?(0,e.jsx)(Ve,{agent:n,size:"xs"}):(0,e.jsx)("span",{className:"text-ink-3",children:"Pick an agent"})})}),(0,e.jsx)(ks,{align:"end",className:"w-64 p-0",children:(0,e.jsxs)(Bs,{children:[(0,e.jsx)($s,{placeholder:"Search agents…"}),(0,e.jsxs)(Ks,{children:[(0,e.jsx)(_s,{children:"No agents."}),(0,e.jsx)(zs,{children:t.map(l=>{const i=Sa(l);return(0,e.jsxs)(qs,{value:l.name,disabled:!i,onSelect:s(()=>{i&&(a(l.id),r(!1))},"onSelect"),className:H("flex items-center gap-2",!i&&"opacity-50"),children:[(0,e.jsx)("span",{className:H("h-2 w-2 rounded-full",i?"bg-green-500":"bg-orange-400"),"aria-hidden":!0}),(0,e.jsx)(Ve,{agent:l,size:"xs"}),!i&&(0,e.jsx)(ee,{variant:"secondary",className:"ml-auto",children:"Paused"})]},l.id)})})]})]})})]})}s(hi,"AgentPicker");function pi({companyId:t,skill:n,runId:a,agents:o,onBack:r,onSelectRun:l}){const i=n.id,c=Z(),u=Ee(),f=Y({queryKey:R.companySkills.testRunDetail(t,i,a),queryFn:s(()=>q.testRunDetail(t,i,a),"queryFn"),enabled:!!(t&&i&&a),refetchInterval:s(I=>{const M=I.state.data;return M&&Xt(M.status)?st:!1},"refetchInterval")}),m=B({mutationFn:s(()=>q.cancelTestRun(t,i,a),"mutationFn"),onSuccess:s(()=>c.invalidateQueries({queryKey:R.companySkills.testRunDetail(t,i,a)}),"onSuccess"),onError:u("Couldn't cancel run")}),k=B({mutationFn:s(()=>{const I=f.data;if(!I)throw new Error("Run details are still loading.");return q.createTestRun(t,i,Ma(I))},"mutationFn"),onSuccess:s(I=>{c.invalidateQueries({queryKey:["company-skills",t,i,"test-runs"]}),l(I.id)},"onSuccess"),onError:u("Couldn't re-run")}),h=B({mutationFn:s(()=>q.deleteTestRun(t,i,a),"mutationFn"),onSuccess:s(()=>{c.invalidateQueries({queryKey:["company-skills",t,i,"test-runs"]}),l(null)},"onSuccess"),onError:u("Couldn't delete run")}),x=f.data??null,b=(0,d.useMemo)(()=>x?Pa(x):[],[x]),S=(0,d.useMemo)(()=>x?La(x):[],[x]),D=(0,d.useMemo)(()=>x?Ra(x):null,[x]),E=(0,d.useMemo)(()=>x?Ia(x):[],[x]),[j,N]=(0,d.useState)(!1),[w,y]=(0,d.useState)(0);if(f.isLoading)return(0,e.jsx)(ne,{title:"Run",action:(0,e.jsx)(Be,{onBack:r}),children:(0,e.jsx)("div",{className:"p-3 text-xs text-ink-3",children:"Loading run…"})});if(!x)return(0,e.jsx)(ne,{title:"Run",action:(0,e.jsx)(Be,{onBack:r}),children:(0,e.jsx)("div",{className:"p-3 text-xs text-ink-3",children:"Run not found."})});const v=o.find(I=>I.id===x.agentId)??null,T=v?.name??x.agentConfigSnapshot?.name??"Agent",$=!v,p=fa(x),L=!tt(x.status),K=ja(x);return(0,e.jsx)(ne,{title:"Run",action:(0,e.jsx)(Be,{onBack:r}),children:(0,e.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 overflow-auto p-3",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(_t,{status:x.status}),(0,e.jsx)(Ve,{agent:v??{id:x.agentId,name:T},size:"xs"}),$&&(0,e.jsx)(ee,{variant:"secondary",children:"removed"}),(0,e.jsxs)("span",{className:"font-mono text-xs text-ink-3",children:["v",x.skillVersion.revisionNumber]}),(0,e.jsx)("span",{className:"ml-auto font-mono text-xs text-ink-3",children:vt(x.cost.costCents)})]}),(0,e.jsxs)("div",{className:"rounded-md border border-line text-xs",children:[(0,e.jsx)(Ne,{label:"Input",value:x.inputId?"saved input":"ad-hoc paste"}),(0,e.jsx)(Ne,{label:"Template",value:x.templateName??"No template"}),(0,e.jsx)(Ne,{label:"Skill version",value:`v${x.skillVersion.revisionNumber}`}),(0,e.jsx)(Ne,{label:"Created",value:ge(x.createdAt)})]}),ga(x.status)&&(0,e.jsxs)(Ae,{className:"border-bad/50",children:[(0,e.jsxs)(Js,{className:"flex-row items-center gap-2 space-y-0 pb-2",children:[(0,e.jsx)(ae,{className:"h-3.5 w-3.5 text-bad"}),(0,e.jsx)("span",{className:"text-sm font-medium",children:"Run failed"})]}),(0,e.jsx)(Xs,{className:"text-sm text-ink-3",children:x.error??"The test task ended with an error."})]}),p==="output"||p==="draft"?(0,e.jsxs)("section",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-ink-3",children:p==="draft"?"Draft at failure":"Output snapshot"}),(0,e.jsx)("div",{className:"rounded-md border border-line p-3",children:(0,e.jsx)(Ye,{children:x.outputBody||"_No output_"})})]}):p==="pending"?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-ink-3",children:[(0,e.jsx)(ws,{className:"h-3.5 w-3.5"})," Working… output will appear here."]}):null,D?(0,e.jsx)(fi,{copy:D}):null,b.length>0?(0,e.jsx)(gi,{documents:b}):null,(0,e.jsx)(Dn,{workProducts:x.harnessContent.workProducts,onMediaClick:s(I=>{const M=I.metadata;if(!M)return;const _=E.findIndex(P=>P.contentPath===M.contentPath||P.id===`work-product-${I.id}`||P.id===M.attachmentId);y(_>=0?_:0),N(!0)},"onMediaClick")}),S.length>0?(0,e.jsx)(ha,{attachments:S,onImageClick:s(I=>{const M=E.findIndex(_=>_.id===I.id||_.contentPath===I.contentPath);y(M>=0?M:0),N(!0)},"onImageClick")}):null,(0,e.jsx)(ji,{companyId:t,detail:x,agents:o,onAnswered:s(()=>c.invalidateQueries({queryKey:R.companySkills.testRunDetail(t,i,a)}),"onAnswered")}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-line pt-3",children:[(0,e.jsxs)(C,{variant:"secondary",size:"sm",disabled:k.isPending,onClick:s(()=>k.mutate(),"onClick"),children:[(0,e.jsx)(Ls,{className:"mr-1.5 h-3.5 w-3.5"})," Re-run"]}),L?(0,e.jsx)(C,{variant:"ghost",size:"sm",disabled:m.isPending,onClick:s(()=>m.mutate(),"onClick"),children:"Cancel"}):(0,e.jsxs)(C,{variant:"danger",size:"sm",disabled:h.isPending,onClick:s(()=>h.mutate(),"onClick"),children:[(0,e.jsx)(te,{className:"mr-1.5 h-3.5 w-3.5"})," Delete"]}),K.enabled&&x.harnessIssue?(0,e.jsx)(C,{variant:"link",size:"sm",asChild:!0,children:(0,e.jsx)(Fe,{to:`/issues/${x.harnessIssue.id}`,children:"Open test task ↗"})}):(0,e.jsxs)(J,{children:[(0,e.jsx)(G,{asChild:!0,children:(0,e.jsx)("span",{className:"cursor-not-allowed text-xs text-ink-3",children:"Open test task ↗"})}),(0,e.jsx)(W,{children:K.reason})]})]}),(0,e.jsx)(ln,{items:E,initialIndex:w,open:j,onOpenChange:N})]})})}s(pi,"RunDetailView");function fi({copy:t}){return(0,e.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-line bg-bg-3/30 p-3 text-xs",children:[(0,e.jsx)(ae,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsx)("p",{className:"font-medium text-ink",children:t.title}),(0,e.jsx)("p",{className:"text-ink-3",children:t.body})]})]})}s(fi,"RunHarnessUnavailableNotice");function gi({documents:t}){return(0,e.jsxs)("section",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(It,{className:"h-3.5 w-3.5 text-ink-3","aria-hidden":"true"}),(0,e.jsx)("h3",{className:"text-sm font-medium text-ink-3",children:"Documents"}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:t.length})]}),(0,e.jsx)("div",{className:"space-y-2",children:t.map(n=>(0,e.jsxs)("article",{className:"rounded-md border border-line p-3",children:[(0,e.jsxs)("div",{className:"mb-2 flex min-w-0 items-center gap-2 text-xs text-ink-3",children:[(0,e.jsx)("span",{className:"truncate font-medium text-ink",children:n.title??n.key}),(0,e.jsx)("span",{className:"ml-auto shrink-0",children:ge(n.updatedAt)})]}),(0,e.jsx)(Ye,{className:"wardmote-edit-in-place-content text-sm leading-7",softBreaks:!1,children:n.body})]},n.id))})]})}s(gi,"RunDocumentsSection");function ji({companyId:t,detail:n,agents:a,onAnswered:o}){const r=n.harnessIssue?.id??null,l=n.interactions.some(h=>wa(h)),i=Y({queryKey:["skill-studio","interactions",r],queryFn:s(()=>ke.listInteractions(r),"queryFn"),enabled:!!(r&&l),refetchInterval:s(h=>Es(h.state.data,l?st:!1),"refetchInterval")}),c=(0,d.useMemo)(()=>new Map((i.data??[]).map(h=>[h.id,h])),[i.data]),u=(0,d.useMemo)(()=>new Map(a.map(h=>[h.id,h])),[a]),f=B({mutationFn:s(h=>ke.acceptInteraction(r,h.interaction.id,{selectedOptionIds:h.optionIds,note:h.note}),"mutationFn"),onSuccess:o}),m=B({mutationFn:s(h=>ke.respondToInteraction(r,h.interaction.id,{answers:h.answers}),"mutationFn"),onSuccess:o}),k=B({mutationFn:s(h=>ke.rejectInteraction(r,h.interaction.id,h.reason,h.note),"mutationFn"),onSuccess:o});return n.interactions.length===0?null:(0,e.jsxs)("section",{children:[(0,e.jsx)("h3",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-ink-3",children:"Interactions"}),(0,e.jsx)("div",{className:"space-y-2",children:n.interactions.map(h=>{const x=Zt(h.kind)==="inline",b=c.get(h.id);return x&&b?(0,e.jsx)(Rs,{interaction:b,agentMap:u,onAcceptInteraction:s(async(S,D,E,j,N)=>{await f.mutateAsync({interaction:S,optionIds:E,note:N})},"onAcceptInteraction"),onRejectInteraction:s(async(S,D,E)=>{await k.mutateAsync({interaction:S,reason:D,note:E})},"onRejectInteraction"),onSubmitInteractionAnswers:s(async(S,D)=>{await m.mutateAsync({interaction:S,answers:D})},"onSubmitInteractionAnswers")},h.id):(0,e.jsx)(He,{title:h.title,subtitle:`${h.kind} · ${h.status}`,trailing:r?(0,e.jsx)(C,{variant:"link",size:"xs",asChild:!0,children:(0,e.jsx)(Fe,{to:`/issues/${r}`,children:"Open test task ↗"})}):null},h.id)})})]})}s(ji,"InteractionSection");function bi({open:t,onOpenChange:n,companyId:a,skill:o,onRestored:r,onFilterRuns:l}){const i=o.id,c=Z(),u=Y({queryKey:R.companySkills.versions(a,i),queryFn:s(()=>q.versions(a,i),"queryFn"),enabled:t&&!!(a&&i)}),f=u.data??[],[m,k]=(0,d.useState)(null),[h,x]=(0,d.useState)(null),b=B({mutationFn:s(async j=>{for(const N of j.fileInventory)await q.updateFile(a,i,N.path,N.content,{encoding:N.encoding,executable:N.executable??!1});return q.createVersion(a,i,{label:`Restore of v${j.revisionNumber}`})},"mutationFn"),onSuccess:s(()=>{c.invalidateQueries({queryKey:R.companySkills.versions(a,i)}),r()},"onSuccess")}),S=f.find(j=>j.id===m)??null,D=f.find(j=>j.id===h)??null,E=S&&D?yn(S.fileInventory.map(j=>`# ${j.path}${j.executable?" (executable)":""}
4
4
  ${j.encoding==="base64"?"[Binary asset]":j.content}`).join(`
@@ -1 +1 @@
1
- var S=Object.defineProperty;var s=(e,t)=>S(e,"name",{value:t,configurable:!0});import{i as y}from"./rolldown-runtime-ZpX3ckPj.js";import{h as M,l as u,na as $,ta as P}from"./createLucideIcon-DJi9suAC.js";import{a as O}from"./star-BZgQbzhV.js";import{X as H,_ as q,n as N,t as m}from"./queryKeys-DYV5MhM_.js";import{nt as L}from"./mention-chips-D8856Q0_.js";import{bt as D,t as U,xt as W,zt as z}from"./router-2UfGeejU.js";import{t as B}from"./badge-check-Bd7IYIB2.js";import{t as K}from"./circle-alert-C-L4OsHh.js";import{t as g}from"./clock-CzrJT_cP.js";import{t as Q}from"./info-DXpx_HA2.js";import{r as X,t as x}from"./button-CMwV3L1P.js";import{t as F}from"./rotate-ccw-CQEJ4ewP.js";import{t as V}from"./shield-alert-Be9GuMrS.js";import{t as j}from"./triangle-alert-CBVKiaXB.js";import{t as Y}from"./user-Ccom_Ph0.js";import{t as G}from"./x-DRDFdlYE.js";import{i as Z,n as J,t as ee}from"./tooltip-B5WQ3lq5.js";import{t as w}from"./badge-DuA2EgZC.js";import{t as te}from"./AgentAvatar-DgGEobSY.js";import{a as ne}from"./ToastContext-DMdt9oTd.js";import{t as re}from"./InlineBanner-VQ5mstsR.js";import{_ as ae}from"./issue-blockers-DLfa24KC.js";import{Dn as se}from"./index-DDoARkPG.js";import{n as ie}from"./runRetryState-BdjK4QQj.js";function Xe(e,t){return t==="operator_interrupted"?!0:!e||typeof e!="object"?!1:e.operatorInterrupted===!0?!0:e.interruptionSource==="issue_comment_interrupt"}s(Xe,"isOperatorInterruptedRun");function oe(e){switch(e){case"succeeded":return"text-green-700 dark:text-green-300";case"failed":case"error":return"text-red-700 dark:text-red-300";case"timed_out":return"text-orange-700 dark:text-orange-300";case"running":return"text-blue-700 dark:text-blue-300";case"queued":case"pending":return"text-amber-700 dark:text-amber-300";case"cancelled":return"text-ink-3";default:return"text-ink"}}s(oe,"runStatusClassName");function de(e,t={}){return e==="cancelled"&&t.operatorInterrupted?{label:"interrupted",className:"text-amber-700 dark:text-amber-300",srHint:"interrupted by board comment"}:{label:e==="timed_out"?"timed out":e.replace(/_/g," "),className:oe(e),srHint:null}}s(de,"resolveRunStatusPresentation");var A=/\[[^\]]*\]\(([^)]*)\)/g;function Fe(e){const t=[];if(!e)return t;for(const r of e.matchAll(A)){const a=r[1]??"",i=L(a);i?.agentId&&!t.includes(i.agentId)&&t.push(i.agentId)}return t}s(Fe,"extractAgentMentionIds");function le(e){return e.replace(A," ")}s(le,"plainTextOutsideLinks");function ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}s(ue,"escapeRegExp");function Ve(e,t){if(!e.trim()||t.length===0)return null;const r=le(e);let a=null;for(const i of t){const l=[i.name,i.role??""].filter(o=>o&&o.trim().length>=2);for(const o of l)new RegExp(`(?<![\\w@/])${ue(o)}(?![\\w/])`,"i").test(r)&&(!a||o.length>a.matchedText.length)&&(a={agentId:i.agentId,matchedText:o})}return a}s(Ve,"findPlainAgentNameCandidate");function ce(e){return!e||e==="__none__"?{kind:"none",id:null}:e.startsWith("agent:")?{kind:"agent",id:e.slice(6)||null}:e.startsWith("user:")?{kind:"user",id:e.slice(5)||null}:{kind:"none",id:null}}s(ce,"parseReassignValue");function Ye(e){if(e.reassignTarget!==e.currentAssigneeValue){const t=ce(e.reassignTarget);return t.kind==="agent"&&t.id?e.hasActiveRun?{kind:"interrupt_handoff_agent",tone:"neutral",text:"Interrupt current run, hand off to",chip:{kind:"agent",id:t.id}}:{kind:"wake_agent",tone:"neutral",text:"Wake",chip:{kind:"agent",id:t.id}}:t.kind==="user"&&t.id?{kind:"user_handoff",tone:"neutral",text:"Hand off to",chip:{kind:"user",id:t.id},suffix:"— no agent will be notified"}:{kind:"clear_assignee",tone:"neutral",text:"Clear responsible — no agent will be notified"}}return e.bodyHasAgentMention?{kind:"notify_agent",tone:"neutral",text:"Notify",chip:e.mentionedAgentId?{kind:"agent",id:e.mentionedAgentId}:void 0,suffix:e.mentionedAgentId?void 0:"the mentioned agent"}:e.plainNameCandidate?{kind:"plain_text_only",tone:"warn",text:"No agent will be notified. Use @ to mention an agent."}:{kind:"none",tone:"neutral",text:""}}s(Ye,"computeComposerHandoffPreview");function me(e,t={}){return e.agentId?{kind:"agent_wake",wakeText:`queued for ${t.agentName??"the responsible agent"}${t.interruptedRunAttached?" (interrupted run attached)":""}`}:e.userId?{kind:"user_handoff",wakeText:"not created — this is a handoff to a board user"}:{kind:"unassigned",wakeText:"not created — no agent selected. Mention @agent or pick a responsible to dispatch."}}s(me,"classifyAssigneeHandoff");function Ge(e={}){return{banner:`${e.runningAgentName?.trim()||"An agent"} is running — changing the responsible will interrupt this run.`,confirmTitle:"Interrupt the current run?",confirmAction:"Interrupt & assign",cancelAction:"Cancel"}}s(Ge,"describeReassignInterrupt");var n=y(P(),1);function _(e,t){return t.agentMap?.get(e)?.name??e.slice(0,8)}s(_,"agentName");function fe(e,t){const r=t.resolveUserLabel?.(e)??null??"Board";return t.currentUserId&&t.currentUserId===e?`${r} (you)`:r}s(fe,"userLabel");var h="inline-flex items-center gap-1 rounded-full border border-line bg-bg-3/40 px-2 py-0.5 text-xs";function I({assignee:e,resolvers:t,className:r}){return e.agentId?(0,n.jsxs)("span",{className:u(h,r),"data-testid":"handoff-assignee-chip","data-kind":"agent",children:[(0,n.jsx)("span",{className:"sr-only",children:"Agent "}),(0,n.jsx)(te,{agent:{...t.agentMap?.get(e.agentId),id:e.agentId},size:16}),(0,n.jsx)("span",{className:"max-w-(--sz-12rem) truncate",children:_(e.agentId,t)})]}):e.userId?(0,n.jsxs)("span",{className:u(h,r),"data-testid":"handoff-assignee-chip","data-kind":"user",children:[(0,n.jsx)("span",{className:"sr-only",children:"User "}),(0,n.jsx)(Y,{className:"h-3 w-3 shrink-0 text-ink-3"}),(0,n.jsx)("span",{className:"max-w-(--sz-12rem) truncate",children:fe(e.userId,t)})]}):(0,n.jsxs)("span",{className:u("text-xs italic text-ink-3",r),"data-testid":"handoff-assignee-chip","data-kind":"unassigned",children:[(0,n.jsx)("span",{className:"sr-only",children:"No responsible — "}),"Unassigned"]})}s(I,"AssigneeChip");function Ze({to:e,resolvers:t,interruptedRunAttached:r=!1}){const a=me(e,{agentName:e.agentId?_(e.agentId,t):null,interruptedRunAttached:r});return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-xs","data-testid":"handoff-wake-row","data-kind":a.kind,children:[(0,n.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider text-ink-3",children:"Wake"}),(0,n.jsx)("span",{className:u(a.kind==="agent_wake"?"text-ink":"text-ink-3"),children:a.wakeText})]})}s(Ze,"HandoffWakeRow");function Je({status:e,operatorInterrupted:t=!1,className:r}){const a=de(e,{operatorInterrupted:t});return(0,n.jsxs)("span",{className:u("font-medium",a.className,r),"data-testid":"run-status-badge","data-interrupted":t?"true":"false",children:[a.label,a.srHint?(0,n.jsxs)("span",{className:"sr-only",children:[" — ",a.srHint]}):null]})}s(Je,"RunStatusBadge");function xe({chip:e,resolvers:t}){return(0,n.jsx)(I,{assignee:e.kind==="agent"?{agentId:e.id,userId:null}:{agentId:null,userId:e.id},resolvers:t})}s(xe,"PreviewChip");function et({preview:e,resolvers:t}){return e.kind==="none"?null:(0,n.jsxs)("div",{className:u("flex flex-wrap items-center justify-end gap-1.5 text-xs",e.tone==="warn"?"text-amber-700 dark:text-amber-300":"text-ink-3"),"data-testid":"composer-handoff-preview","data-kind":e.kind,role:"status","aria-live":"polite",children:[(0,n.jsx)("span",{children:e.text}),e.chip?(0,n.jsx)(xe,{chip:e.chip,resolvers:t}):null,e.suffix?(0,n.jsx)("span",{children:e.suffix}):null]})}s(et,"ComposerHandoffPreviewRow");function tt({candidate:e,agentDisplayName:t,onInsert:r,onDismiss:a}){return(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-amber-300/40 bg-amber-50/70 px-2 py-1.5 text-xs text-amber-700 dark:bg-amber-500/10 dark:text-amber-300","data-testid":"composer-mention-coach",role:"alert","aria-live":"polite",children:[(0,n.jsx)(Q,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:["Did you mean ",(0,n.jsxs)("span",{className:"font-medium",children:["@",e.matchedText]}),"? Plain text won't notify or assign an agent."]}),(0,n.jsx)(x,{variant:"secondary",size:"xs",className:"shrink-0",type:"button",onClick:r,"aria-label":`Insert mention for ${t} into your comment`,children:"Insert mention"}),(0,n.jsx)("button",{type:"button",onClick:a,className:"shrink-0 rounded p-0.5 hover:bg-amber-100/60 dark:hover:bg-amber-500/20","aria-label":"Dismiss suggestion",children:(0,n.jsx)(G,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}s(tt,"ComposerMentionCoach");function nt({copy:e,className:t}){return(0,n.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"assignee-running-banner",className:u("flex items-start gap-1.5 rounded-md border border-amber-300/40 bg-amber-50/70 px-2 py-1.5 text-xs text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",t),children:[(0,n.jsx)(j,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,n.jsx)("span",{className:"min-w-0 flex-1",children:e.banner})]})}s(nt,"AssigneeRunningBanner");function rt({copy:e,to:t,resolvers:r,onConfirm:a,onCancel:i}){return(0,n.jsxs)("div",{"data-testid":"interrupt-assign-confirm",className:"space-y-2 rounded-md border border-amber-300/40 bg-amber-50/70 p-2 text-xs text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",children:[(0,n.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,n.jsx)(j,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,n.jsx)("p",{className:"font-medium",children:e.confirmTitle}),(0,n.jsxs)("p",{className:"flex flex-wrap items-center gap-1 text-amber-700/90 dark:text-amber-300/90",children:[(0,n.jsx)("span",{children:"Hand off to"}),(0,n.jsx)(I,{assignee:t,resolvers:r})]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(x,{variant:"secondary",size:"xs",type:"button",onClick:i,children:e.cancelAction}),(0,n.jsx)(x,{variant:"primary",size:"xs",type:"button",onClick:a,"data-testid":"interrupt-assign-confirm-action",children:e.confirmAction})]})]})}s(rt,"InterruptAssignConfirm");var pe=y($(),1);function b(e){return e instanceof N?typeof e.message=="string"&&e.message.trim().length>0?e.message:`Request failed (${e.status})`:e instanceof Error&&e.message?e.message:"The request failed. Try again in a moment."}s(b,"readErrorMessage");var k={promoted:"Retry promoted",already_promoted:"Retry already running",waiting:"Retry waiting",no_scheduled_retry:"No scheduled retry",gate_suppressed:"Couldn't retry now",blocked:"Couldn't retry now"};function ge(e,t){const r=D(e,t);return[...new Set([t,...r?W(r):[]])]}s(ge,"issueCacheRefs");function he(e){const t=H(),{pushToast:r}=ne(),a=q({mutationFn:s(()=>{if(!e)throw new Error("Missing issue id");return z.retryScheduledRetryNow(e)},"mutationFn"),onSuccess:s(d=>{if(e)for(const c of ge(t,e))t.invalidateQueries({queryKey:m.issues.detail(c)}),t.invalidateQueries({queryKey:m.issues.activity(c)}),t.invalidateQueries({queryKey:m.issues.runs(c)}),t.invalidateQueries({queryKey:m.issues.liveRuns(c)}),t.invalidateQueries({queryKey:m.issues.activeRun(c)});d.outcome==="promoted"?r({title:k.promoted,body:d.message,tone:"success"}):(d.outcome==="gate_suppressed"||d.outcome==="blocked")&&r({title:k[d.outcome],body:d.message,tone:"error"})},"onSuccess"),onError:s(d=>{r({title:"Couldn't retry now",body:b(d),tone:"error"})},"onError")}),i=a.reset,l=(0,pe.useCallback)(()=>i(),[i]),o=(()=>{if(a.error){const d=a.error instanceof N?a.error:null;return{message:b(a.error),outcomeMessage:null,status:d?.status??null}}return a.data&&(a.data.outcome==="gate_suppressed"||a.data.outcome==="blocked")?{message:a.data.message,outcomeMessage:a.data.message,status:null}:null})();return{...a,reset:l,lastError:o}}s(he,"useRetryNowMutation");var be="max_turns_continuation";function ke(e){return e===be}s(ke,"isContinuationReason");function ye(e){return typeof e=="string"&&e.length>=8?e.slice(0,8):e??""}s(ye,"shortRunId");function at({issueId:e,scheduledRetry:t}){const r=he(e);if(!t||!e||t.status!=="scheduled_retry")return null;if(t.scheduledRetryReason==="workspace_busy")return(0,n.jsx)(re,{tone:"info",icon:g,title:"Waiting for workspace",className:"mb-3",children:"Another task is using this workspace. Work starts automatically when it is available."});const a=ke(t.scheduledRetryReason),i=t.scheduledRetryAt?new Date(t.scheduledRetryAt).toISOString():null,l=i?ae(i):null,o=t.scheduledRetryAt?M(t.scheduledRetryAt):null,d=ie(t.scheduledRetryReason),c=typeof t.scheduledRetryAttempt=="number"&&Number.isFinite(t.scheduledRetryAttempt)&&t.scheduledRetryAttempt>0?t.scheduledRetryAttempt:null,v=a?"Continuation scheduled":"Retry scheduled",C=a?"Automatic continuation":"Automatic retry";let f;l==="now"?f="due now":l?f=l:f="pending schedule";const R=`${C} ${f}`,T=a?"Pulls continuation forward immediately":"Pulls retry forward immediately",E=r.isError||r.lastError!==null,p=r.isSuccess&&(r.data?.outcome==="promoted"||r.data?.outcome==="already_promoted");return(0,n.jsx)("div",{"data-testid":"issue-scheduled-retry-card",className:"mb-3 rounded-lg border border-blue-500/30 bg-blue-500/5 px-3 py-3",children:(0,n.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,n.jsxs)(w,{variant:"outline",className:"border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:[(0,n.jsx)(g,{className:"h-3 w-3","aria-hidden":"true"}),v]}),c!==null?(0,n.jsxs)("span",{className:"text-ink-3",children:["Attempt ",c]}):null,d?(0,n.jsx)("span",{className:"text-ink-3",children:d}):null]}),(0,n.jsx)("div",{className:"mt-1 text-sm font-medium text-ink",children:R}),o||t.retryOfRunId?(0,n.jsxs)("div",{className:"mt-0.5 text-xs text-ink-3",children:[o?(0,n.jsx)("span",{children:o}):null,o&&t.retryOfRunId?(0,n.jsx)("span",{children:" · "}):null,t.retryOfRunId?(0,n.jsxs)("span",{children:["Replaces run"," ",(0,n.jsx)(U,{to:`/agents/${t.agentId}/runs/${t.retryOfRunId}`,className:"font-mono text-ink hover:underline",children:ye(t.retryOfRunId)})]}):null]}):null,t.error?(0,n.jsxs)("div",{className:"mt-1 text-xs text-ink-3",children:["Last attempt failed: ",t.error,/[.!?]$/.test(t.error.trim())?"":"."," Wardmote will retry automatically."]}):null,E?(0,n.jsx)(Ne,{error:r.lastError,onRetry:s(()=>{r.reset(),r.mutate()},"onRetry")}):null]}),(0,n.jsxs)("div",{className:"flex flex-col items-stretch gap-1 sm:items-end",children:[(0,n.jsx)(x,{type:"button",variant:"secondary",size:"sm",className:"shrink-0 shadow-none",onClick:s(()=>r.mutate(),"onClick"),disabled:r.isPending||p,"data-testid":"issue-scheduled-retry-card-retry-now",children:r.isPending?(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,n.jsx)(X,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Retrying…"]}):p?(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,n.jsx)(O,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.data?.outcome==="already_promoted"?"Already promoted":"Promoted"]}):(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,n.jsx)(F,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Retry now"]})}),(0,n.jsx)("span",{className:"text-right text-xs text-ink-3 sm:max-w-(--sz-12rem)",children:r.isPending?"Promoting scheduled retry":p?r.data?.outcome==="already_promoted"?"Already promoted — run starting":"Promoted — run starting":r.data?.outcome==="waiting"&&r.data.scheduledRetry?.runId===t.runId?r.data.message:T})]})]})})}s(at,"IssueScheduledRetryCard");function Ne({error:e,onRetry:t,className:r}){return e?(0,n.jsxs)("div",{className:u("mt-2 flex items-start gap-2 rounded-md border border-rose-500/30 bg-rose-500/5 px-2 py-1.5 text-xs text-rose-700 dark:text-rose-300",r),role:"alert","data-testid":"issue-scheduled-retry-error-band",children:[(0,n.jsx)(K,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"font-medium",children:"Couldn't retry now"}),(0,n.jsx)("div",{className:"mt-0.5 text-ink-3",children:e.message})]}),(0,n.jsx)("button",{type:"button",onClick:t,className:"shrink-0 font-medium text-rose-700 hover:underline dark:text-rose-300",children:"Try again"})]}):null}s(Ne,"RetryErrorBand");function st({sourceTrust:e,artifactLabel:t="content",className:r}){const a=se(e);if(!a)return null;const i=e?.disposition==="promoted",l=i?`Promoted from low-trust${e.promotedAt?` on ${new Date(e.promotedAt).toLocaleString()}`:""}.`:`Authored by a low-trust review agent. Raw ${t} is not auto-shared with higher-trust agents.`;return(0,n.jsxs)(ee,{children:[(0,n.jsx)(Z,{asChild:!0,children:(0,n.jsxs)(w,{variant:"outline","aria-label":a,className:u("inline-flex items-center gap-1 whitespace-nowrap px-1.5 py-0 text-(length:--text-nano) font-medium tracking-normal",i?"border-line text-ink-3":"border-amber-500/40 text-amber-700 dark:text-amber-100",r),children:[i?(0,n.jsx)(B,{className:"h-3 w-3"}):(0,n.jsx)(V,{className:"h-3 w-3"}),a]})}),(0,n.jsx)(J,{className:"max-w-xs text-xs",children:l})]})}s(st,"SourceTrustBadge");export{I as a,tt as c,Je as d,Ye as f,Xe as g,Ve as h,he as i,Ze as l,Fe as m,at as n,nt as o,Ge as p,Ne as r,et as s,st as t,rt as u};
1
+ var S=Object.defineProperty;var s=(e,t)=>S(e,"name",{value:t,configurable:!0});import{i as y}from"./rolldown-runtime-ZpX3ckPj.js";import{h as M,l as u,na as $,ta as P}from"./createLucideIcon-DJi9suAC.js";import{a as O}from"./star-BZgQbzhV.js";import{X as H,_ as q,n as N,t as m}from"./queryKeys-DYV5MhM_.js";import{nt as L}from"./mention-chips-D8856Q0_.js";import{bt as D,t as U,xt as W,zt as z}from"./router-2UfGeejU.js";import{t as B}from"./badge-check-Bd7IYIB2.js";import{t as K}from"./circle-alert-C-L4OsHh.js";import{t as g}from"./clock-CzrJT_cP.js";import{t as Q}from"./info-DXpx_HA2.js";import{r as X,t as x}from"./button-CMwV3L1P.js";import{t as F}from"./rotate-ccw-CQEJ4ewP.js";import{t as V}from"./shield-alert-Be9GuMrS.js";import{t as j}from"./triangle-alert-CBVKiaXB.js";import{t as Y}from"./user-Ccom_Ph0.js";import{t as G}from"./x-DRDFdlYE.js";import{i as Z,n as J,t as ee}from"./tooltip-B5WQ3lq5.js";import{t as w}from"./badge-DuA2EgZC.js";import{t as te}from"./AgentAvatar-DgGEobSY.js";import{a as ne}from"./ToastContext-DMdt9oTd.js";import{t as re}from"./InlineBanner-VQ5mstsR.js";import{_ as ae}from"./issue-blockers-DLfa24KC.js";import{Dn as se}from"./index-3AxqhPET.js";import{n as ie}from"./runRetryState-BdjK4QQj.js";function Xe(e,t){return t==="operator_interrupted"?!0:!e||typeof e!="object"?!1:e.operatorInterrupted===!0?!0:e.interruptionSource==="issue_comment_interrupt"}s(Xe,"isOperatorInterruptedRun");function oe(e){switch(e){case"succeeded":return"text-green-700 dark:text-green-300";case"failed":case"error":return"text-red-700 dark:text-red-300";case"timed_out":return"text-orange-700 dark:text-orange-300";case"running":return"text-blue-700 dark:text-blue-300";case"queued":case"pending":return"text-amber-700 dark:text-amber-300";case"cancelled":return"text-ink-3";default:return"text-ink"}}s(oe,"runStatusClassName");function de(e,t={}){return e==="cancelled"&&t.operatorInterrupted?{label:"interrupted",className:"text-amber-700 dark:text-amber-300",srHint:"interrupted by board comment"}:{label:e==="timed_out"?"timed out":e.replace(/_/g," "),className:oe(e),srHint:null}}s(de,"resolveRunStatusPresentation");var A=/\[[^\]]*\]\(([^)]*)\)/g;function Fe(e){const t=[];if(!e)return t;for(const r of e.matchAll(A)){const a=r[1]??"",i=L(a);i?.agentId&&!t.includes(i.agentId)&&t.push(i.agentId)}return t}s(Fe,"extractAgentMentionIds");function le(e){return e.replace(A," ")}s(le,"plainTextOutsideLinks");function ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}s(ue,"escapeRegExp");function Ve(e,t){if(!e.trim()||t.length===0)return null;const r=le(e);let a=null;for(const i of t){const l=[i.name,i.role??""].filter(o=>o&&o.trim().length>=2);for(const o of l)new RegExp(`(?<![\\w@/])${ue(o)}(?![\\w/])`,"i").test(r)&&(!a||o.length>a.matchedText.length)&&(a={agentId:i.agentId,matchedText:o})}return a}s(Ve,"findPlainAgentNameCandidate");function ce(e){return!e||e==="__none__"?{kind:"none",id:null}:e.startsWith("agent:")?{kind:"agent",id:e.slice(6)||null}:e.startsWith("user:")?{kind:"user",id:e.slice(5)||null}:{kind:"none",id:null}}s(ce,"parseReassignValue");function Ye(e){if(e.reassignTarget!==e.currentAssigneeValue){const t=ce(e.reassignTarget);return t.kind==="agent"&&t.id?e.hasActiveRun?{kind:"interrupt_handoff_agent",tone:"neutral",text:"Interrupt current run, hand off to",chip:{kind:"agent",id:t.id}}:{kind:"wake_agent",tone:"neutral",text:"Wake",chip:{kind:"agent",id:t.id}}:t.kind==="user"&&t.id?{kind:"user_handoff",tone:"neutral",text:"Hand off to",chip:{kind:"user",id:t.id},suffix:"— no agent will be notified"}:{kind:"clear_assignee",tone:"neutral",text:"Clear responsible — no agent will be notified"}}return e.bodyHasAgentMention?{kind:"notify_agent",tone:"neutral",text:"Notify",chip:e.mentionedAgentId?{kind:"agent",id:e.mentionedAgentId}:void 0,suffix:e.mentionedAgentId?void 0:"the mentioned agent"}:e.plainNameCandidate?{kind:"plain_text_only",tone:"warn",text:"No agent will be notified. Use @ to mention an agent."}:{kind:"none",tone:"neutral",text:""}}s(Ye,"computeComposerHandoffPreview");function me(e,t={}){return e.agentId?{kind:"agent_wake",wakeText:`queued for ${t.agentName??"the responsible agent"}${t.interruptedRunAttached?" (interrupted run attached)":""}`}:e.userId?{kind:"user_handoff",wakeText:"not created — this is a handoff to a board user"}:{kind:"unassigned",wakeText:"not created — no agent selected. Mention @agent or pick a responsible to dispatch."}}s(me,"classifyAssigneeHandoff");function Ge(e={}){return{banner:`${e.runningAgentName?.trim()||"An agent"} is running — changing the responsible will interrupt this run.`,confirmTitle:"Interrupt the current run?",confirmAction:"Interrupt & assign",cancelAction:"Cancel"}}s(Ge,"describeReassignInterrupt");var n=y(P(),1);function _(e,t){return t.agentMap?.get(e)?.name??e.slice(0,8)}s(_,"agentName");function fe(e,t){const r=t.resolveUserLabel?.(e)??null??"Board";return t.currentUserId&&t.currentUserId===e?`${r} (you)`:r}s(fe,"userLabel");var h="inline-flex items-center gap-1 rounded-full border border-line bg-bg-3/40 px-2 py-0.5 text-xs";function I({assignee:e,resolvers:t,className:r}){return e.agentId?(0,n.jsxs)("span",{className:u(h,r),"data-testid":"handoff-assignee-chip","data-kind":"agent",children:[(0,n.jsx)("span",{className:"sr-only",children:"Agent "}),(0,n.jsx)(te,{agent:{...t.agentMap?.get(e.agentId),id:e.agentId},size:16}),(0,n.jsx)("span",{className:"max-w-(--sz-12rem) truncate",children:_(e.agentId,t)})]}):e.userId?(0,n.jsxs)("span",{className:u(h,r),"data-testid":"handoff-assignee-chip","data-kind":"user",children:[(0,n.jsx)("span",{className:"sr-only",children:"User "}),(0,n.jsx)(Y,{className:"h-3 w-3 shrink-0 text-ink-3"}),(0,n.jsx)("span",{className:"max-w-(--sz-12rem) truncate",children:fe(e.userId,t)})]}):(0,n.jsxs)("span",{className:u("text-xs italic text-ink-3",r),"data-testid":"handoff-assignee-chip","data-kind":"unassigned",children:[(0,n.jsx)("span",{className:"sr-only",children:"No responsible — "}),"Unassigned"]})}s(I,"AssigneeChip");function Ze({to:e,resolvers:t,interruptedRunAttached:r=!1}){const a=me(e,{agentName:e.agentId?_(e.agentId,t):null,interruptedRunAttached:r});return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-xs","data-testid":"handoff-wake-row","data-kind":a.kind,children:[(0,n.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider text-ink-3",children:"Wake"}),(0,n.jsx)("span",{className:u(a.kind==="agent_wake"?"text-ink":"text-ink-3"),children:a.wakeText})]})}s(Ze,"HandoffWakeRow");function Je({status:e,operatorInterrupted:t=!1,className:r}){const a=de(e,{operatorInterrupted:t});return(0,n.jsxs)("span",{className:u("font-medium",a.className,r),"data-testid":"run-status-badge","data-interrupted":t?"true":"false",children:[a.label,a.srHint?(0,n.jsxs)("span",{className:"sr-only",children:[" — ",a.srHint]}):null]})}s(Je,"RunStatusBadge");function xe({chip:e,resolvers:t}){return(0,n.jsx)(I,{assignee:e.kind==="agent"?{agentId:e.id,userId:null}:{agentId:null,userId:e.id},resolvers:t})}s(xe,"PreviewChip");function et({preview:e,resolvers:t}){return e.kind==="none"?null:(0,n.jsxs)("div",{className:u("flex flex-wrap items-center justify-end gap-1.5 text-xs",e.tone==="warn"?"text-amber-700 dark:text-amber-300":"text-ink-3"),"data-testid":"composer-handoff-preview","data-kind":e.kind,role:"status","aria-live":"polite",children:[(0,n.jsx)("span",{children:e.text}),e.chip?(0,n.jsx)(xe,{chip:e.chip,resolvers:t}):null,e.suffix?(0,n.jsx)("span",{children:e.suffix}):null]})}s(et,"ComposerHandoffPreviewRow");function tt({candidate:e,agentDisplayName:t,onInsert:r,onDismiss:a}){return(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-amber-300/40 bg-amber-50/70 px-2 py-1.5 text-xs text-amber-700 dark:bg-amber-500/10 dark:text-amber-300","data-testid":"composer-mention-coach",role:"alert","aria-live":"polite",children:[(0,n.jsx)(Q,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:["Did you mean ",(0,n.jsxs)("span",{className:"font-medium",children:["@",e.matchedText]}),"? Plain text won't notify or assign an agent."]}),(0,n.jsx)(x,{variant:"secondary",size:"xs",className:"shrink-0",type:"button",onClick:r,"aria-label":`Insert mention for ${t} into your comment`,children:"Insert mention"}),(0,n.jsx)("button",{type:"button",onClick:a,className:"shrink-0 rounded p-0.5 hover:bg-amber-100/60 dark:hover:bg-amber-500/20","aria-label":"Dismiss suggestion",children:(0,n.jsx)(G,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}s(tt,"ComposerMentionCoach");function nt({copy:e,className:t}){return(0,n.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"assignee-running-banner",className:u("flex items-start gap-1.5 rounded-md border border-amber-300/40 bg-amber-50/70 px-2 py-1.5 text-xs text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",t),children:[(0,n.jsx)(j,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,n.jsx)("span",{className:"min-w-0 flex-1",children:e.banner})]})}s(nt,"AssigneeRunningBanner");function rt({copy:e,to:t,resolvers:r,onConfirm:a,onCancel:i}){return(0,n.jsxs)("div",{"data-testid":"interrupt-assign-confirm",className:"space-y-2 rounded-md border border-amber-300/40 bg-amber-50/70 p-2 text-xs text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",children:[(0,n.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,n.jsx)(j,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,n.jsx)("p",{className:"font-medium",children:e.confirmTitle}),(0,n.jsxs)("p",{className:"flex flex-wrap items-center gap-1 text-amber-700/90 dark:text-amber-300/90",children:[(0,n.jsx)("span",{children:"Hand off to"}),(0,n.jsx)(I,{assignee:t,resolvers:r})]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(x,{variant:"secondary",size:"xs",type:"button",onClick:i,children:e.cancelAction}),(0,n.jsx)(x,{variant:"primary",size:"xs",type:"button",onClick:a,"data-testid":"interrupt-assign-confirm-action",children:e.confirmAction})]})]})}s(rt,"InterruptAssignConfirm");var pe=y($(),1);function b(e){return e instanceof N?typeof e.message=="string"&&e.message.trim().length>0?e.message:`Request failed (${e.status})`:e instanceof Error&&e.message?e.message:"The request failed. Try again in a moment."}s(b,"readErrorMessage");var k={promoted:"Retry promoted",already_promoted:"Retry already running",waiting:"Retry waiting",no_scheduled_retry:"No scheduled retry",gate_suppressed:"Couldn't retry now",blocked:"Couldn't retry now"};function ge(e,t){const r=D(e,t);return[...new Set([t,...r?W(r):[]])]}s(ge,"issueCacheRefs");function he(e){const t=H(),{pushToast:r}=ne(),a=q({mutationFn:s(()=>{if(!e)throw new Error("Missing issue id");return z.retryScheduledRetryNow(e)},"mutationFn"),onSuccess:s(d=>{if(e)for(const c of ge(t,e))t.invalidateQueries({queryKey:m.issues.detail(c)}),t.invalidateQueries({queryKey:m.issues.activity(c)}),t.invalidateQueries({queryKey:m.issues.runs(c)}),t.invalidateQueries({queryKey:m.issues.liveRuns(c)}),t.invalidateQueries({queryKey:m.issues.activeRun(c)});d.outcome==="promoted"?r({title:k.promoted,body:d.message,tone:"success"}):(d.outcome==="gate_suppressed"||d.outcome==="blocked")&&r({title:k[d.outcome],body:d.message,tone:"error"})},"onSuccess"),onError:s(d=>{r({title:"Couldn't retry now",body:b(d),tone:"error"})},"onError")}),i=a.reset,l=(0,pe.useCallback)(()=>i(),[i]),o=(()=>{if(a.error){const d=a.error instanceof N?a.error:null;return{message:b(a.error),outcomeMessage:null,status:d?.status??null}}return a.data&&(a.data.outcome==="gate_suppressed"||a.data.outcome==="blocked")?{message:a.data.message,outcomeMessage:a.data.message,status:null}:null})();return{...a,reset:l,lastError:o}}s(he,"useRetryNowMutation");var be="max_turns_continuation";function ke(e){return e===be}s(ke,"isContinuationReason");function ye(e){return typeof e=="string"&&e.length>=8?e.slice(0,8):e??""}s(ye,"shortRunId");function at({issueId:e,scheduledRetry:t}){const r=he(e);if(!t||!e||t.status!=="scheduled_retry")return null;if(t.scheduledRetryReason==="workspace_busy")return(0,n.jsx)(re,{tone:"info",icon:g,title:"Waiting for workspace",className:"mb-3",children:"Another task is using this workspace. Work starts automatically when it is available."});const a=ke(t.scheduledRetryReason),i=t.scheduledRetryAt?new Date(t.scheduledRetryAt).toISOString():null,l=i?ae(i):null,o=t.scheduledRetryAt?M(t.scheduledRetryAt):null,d=ie(t.scheduledRetryReason),c=typeof t.scheduledRetryAttempt=="number"&&Number.isFinite(t.scheduledRetryAttempt)&&t.scheduledRetryAttempt>0?t.scheduledRetryAttempt:null,v=a?"Continuation scheduled":"Retry scheduled",C=a?"Automatic continuation":"Automatic retry";let f;l==="now"?f="due now":l?f=l:f="pending schedule";const R=`${C} ${f}`,T=a?"Pulls continuation forward immediately":"Pulls retry forward immediately",E=r.isError||r.lastError!==null,p=r.isSuccess&&(r.data?.outcome==="promoted"||r.data?.outcome==="already_promoted");return(0,n.jsx)("div",{"data-testid":"issue-scheduled-retry-card",className:"mb-3 rounded-lg border border-blue-500/30 bg-blue-500/5 px-3 py-3",children:(0,n.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,n.jsxs)(w,{variant:"outline",className:"border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:[(0,n.jsx)(g,{className:"h-3 w-3","aria-hidden":"true"}),v]}),c!==null?(0,n.jsxs)("span",{className:"text-ink-3",children:["Attempt ",c]}):null,d?(0,n.jsx)("span",{className:"text-ink-3",children:d}):null]}),(0,n.jsx)("div",{className:"mt-1 text-sm font-medium text-ink",children:R}),o||t.retryOfRunId?(0,n.jsxs)("div",{className:"mt-0.5 text-xs text-ink-3",children:[o?(0,n.jsx)("span",{children:o}):null,o&&t.retryOfRunId?(0,n.jsx)("span",{children:" · "}):null,t.retryOfRunId?(0,n.jsxs)("span",{children:["Replaces run"," ",(0,n.jsx)(U,{to:`/agents/${t.agentId}/runs/${t.retryOfRunId}`,className:"font-mono text-ink hover:underline",children:ye(t.retryOfRunId)})]}):null]}):null,t.error?(0,n.jsxs)("div",{className:"mt-1 text-xs text-ink-3",children:["Last attempt failed: ",t.error,/[.!?]$/.test(t.error.trim())?"":"."," Wardmote will retry automatically."]}):null,E?(0,n.jsx)(Ne,{error:r.lastError,onRetry:s(()=>{r.reset(),r.mutate()},"onRetry")}):null]}),(0,n.jsxs)("div",{className:"flex flex-col items-stretch gap-1 sm:items-end",children:[(0,n.jsx)(x,{type:"button",variant:"secondary",size:"sm",className:"shrink-0 shadow-none",onClick:s(()=>r.mutate(),"onClick"),disabled:r.isPending||p,"data-testid":"issue-scheduled-retry-card-retry-now",children:r.isPending?(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,n.jsx)(X,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Retrying…"]}):p?(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,n.jsx)(O,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.data?.outcome==="already_promoted"?"Already promoted":"Promoted"]}):(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,n.jsx)(F,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Retry now"]})}),(0,n.jsx)("span",{className:"text-right text-xs text-ink-3 sm:max-w-(--sz-12rem)",children:r.isPending?"Promoting scheduled retry":p?r.data?.outcome==="already_promoted"?"Already promoted — run starting":"Promoted — run starting":r.data?.outcome==="waiting"&&r.data.scheduledRetry?.runId===t.runId?r.data.message:T})]})]})})}s(at,"IssueScheduledRetryCard");function Ne({error:e,onRetry:t,className:r}){return e?(0,n.jsxs)("div",{className:u("mt-2 flex items-start gap-2 rounded-md border border-rose-500/30 bg-rose-500/5 px-2 py-1.5 text-xs text-rose-700 dark:text-rose-300",r),role:"alert","data-testid":"issue-scheduled-retry-error-band",children:[(0,n.jsx)(K,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"font-medium",children:"Couldn't retry now"}),(0,n.jsx)("div",{className:"mt-0.5 text-ink-3",children:e.message})]}),(0,n.jsx)("button",{type:"button",onClick:t,className:"shrink-0 font-medium text-rose-700 hover:underline dark:text-rose-300",children:"Try again"})]}):null}s(Ne,"RetryErrorBand");function st({sourceTrust:e,artifactLabel:t="content",className:r}){const a=se(e);if(!a)return null;const i=e?.disposition==="promoted",l=i?`Promoted from low-trust${e.promotedAt?` on ${new Date(e.promotedAt).toLocaleString()}`:""}.`:`Authored by a low-trust review agent. Raw ${t} is not auto-shared with higher-trust agents.`;return(0,n.jsxs)(ee,{children:[(0,n.jsx)(Z,{asChild:!0,children:(0,n.jsxs)(w,{variant:"outline","aria-label":a,className:u("inline-flex items-center gap-1 whitespace-nowrap px-1.5 py-0 text-(length:--text-nano) font-medium tracking-normal",i?"border-line text-ink-3":"border-amber-500/40 text-amber-700 dark:text-amber-100",r),children:[i?(0,n.jsx)(B,{className:"h-3 w-3"}):(0,n.jsx)(V,{className:"h-3 w-3"}),a]})}),(0,n.jsx)(J,{className:"max-w-xs text-xs",children:l})]})}s(st,"SourceTrustBadge");export{I as a,tt as c,Je as d,Ye as f,Xe as g,Ve as h,he as i,Ze as l,Fe as m,at as n,nt as o,Ge as p,Ne as r,et as s,st as t,rt as u};