crewx 0.9.0-rc.184 → 0.9.0-rc.185

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 (93) hide show
  1. package/dist/assets/{DocSyncTextDiff-BYqzcYlT.js → DocSyncTextDiff-sWtWwmBE.js} +1 -1
  2. package/dist/assets/{GitDiffEditor-BFOz1aKk.js → GitDiffEditor-B91JE2n9.js} +1 -1
  3. package/dist/assets/MarketPage-0XzMzzVM.js +41 -0
  4. package/dist/assets/{MonacoDiffSurface-xxuXxN2r.js → MonacoDiffSurface-DeQWTrw_.js} +7 -7
  5. package/dist/assets/{PromptTab-CsrEBoJL.js → PromptTab-PSapRYsa.js} +4 -4
  6. package/dist/assets/{abnfDiagram-VCTEODGH-D8ys4BIw.js → abnfDiagram-VCTEODGH-BDUlwjoF.js} +1 -1
  7. package/dist/assets/{arc-DqLWFbqJ.js → arc-DocxLwxW.js} +1 -1
  8. package/dist/assets/{architectureDiagram-5GKGNRK7-Xf-qhu8_.js → architectureDiagram-5GKGNRK7-CeUPCEAX.js} +1 -1
  9. package/dist/assets/{blockDiagram-I7D4REHJ-CyKa0hUz.js → blockDiagram-I7D4REHJ-CcJG8YFU.js} +1 -1
  10. package/dist/assets/{c4Diagram-7LVT6UL2-qcj8mkfa.js → c4Diagram-7LVT6UL2-CJTSq_xH.js} +1 -1
  11. package/dist/assets/channel-DDHYK7UI.js +1 -0
  12. package/dist/assets/{chunk-2Q5K7J3B-KihmhJzG.js → chunk-2Q5K7J3B-Cpc_1Tjd.js} +1 -1
  13. package/dist/assets/{chunk-5VM5RSS4-CNrZpQng.js → chunk-5VM5RSS4-CQUoFQZf.js} +1 -1
  14. package/dist/assets/{chunk-F27PBJKO-BAvZ48MX.js → chunk-F27PBJKO-BLf5Bt6k.js} +1 -1
  15. package/dist/assets/{chunk-IMKFNOWR-k94Vw1Pq.js → chunk-IMKFNOWR-BX0qx3TL.js} +1 -1
  16. package/dist/assets/{chunk-JWPE2WC7-DAxVFJee.js → chunk-JWPE2WC7-BghJ_V2L.js} +1 -1
  17. package/dist/assets/{chunk-POPQ4Y6H-DVqR_mlV.js → chunk-POPQ4Y6H-CZlkNgK1.js} +1 -1
  18. package/dist/assets/{chunk-SVP7TREG-BPGymXLl.js → chunk-SVP7TREG-BuMu3cIF.js} +1 -1
  19. package/dist/assets/{chunk-TICWLB2K-DUQb2Oi2.js → chunk-TICWLB2K-BmMljiJQ.js} +1 -1
  20. package/dist/assets/{chunk-XXDRQBXY-BVN6gmlQ.js → chunk-XXDRQBXY-dPxk2FdZ.js} +1 -1
  21. package/dist/assets/classDiagram-ZZMXUADV-6xPZolkm.js +1 -0
  22. package/dist/assets/classDiagram-v2-VYDZK3BY-6xPZolkm.js +1 -0
  23. package/dist/assets/{cose-bilkent-JH36ORCC-DJSvEgbZ.js → cose-bilkent-JH36ORCC-DYn4kY5U.js} +1 -1
  24. package/dist/assets/{cssMode-CbFiDcPh.js → cssMode-Cy87Gq9g.js} +1 -1
  25. package/dist/assets/{cynefin-OW5HDTMX-oBdJ1L4P.js → cynefin-OW5HDTMX-BZY-T1l5.js} +1 -1
  26. package/dist/assets/{cynefinDiagram-5FMLGOSQ-CQSxw3pF.js → cynefinDiagram-5FMLGOSQ-Cd3dMaVH.js} +1 -1
  27. package/dist/assets/{dagre-GXQ25YYZ-B9Ny8j7s.js → dagre-GXQ25YYZ-mn8i_YDK.js} +1 -1
  28. package/dist/assets/{diagram-S7CK7UJ4-DojnoCLD.js → diagram-S7CK7UJ4-BknNEu_0.js} +1 -1
  29. package/dist/assets/{diagram-UQ7AKVKN-B31bLfvE.js → diagram-UQ7AKVKN-BYprBZAU.js} +1 -1
  30. package/dist/assets/{diagram-VSXAHHWV-1YReVrxh.js → diagram-VSXAHHWV-BV1t70MK.js} +1 -1
  31. package/dist/assets/{diagram-VX7I27RA-C7AASWQP.js → diagram-VX7I27RA-CAq6Yx67.js} +1 -1
  32. package/dist/assets/{diagram-Z3DM3KII-BT1BIHBe.js → diagram-Z3DM3KII-DJvJVcfJ.js} +1 -1
  33. package/dist/assets/{ebnfDiagram-PWID7BFC-Dq5Sa9Hd.js → ebnfDiagram-PWID7BFC-JZs43JZY.js} +1 -1
  34. package/dist/assets/{erDiagram-RLTQ6QDP-DK6zYsSS.js → erDiagram-RLTQ6QDP-CFytuGUY.js} +1 -1
  35. package/dist/assets/{flowDiagram-HODETNUW-DMPrx-_m.js → flowDiagram-HODETNUW-CHa5hTwh.js} +1 -1
  36. package/dist/assets/{freemarker2-djxR2dvL.js → freemarker2-BPSPfpzr.js} +1 -1
  37. package/dist/assets/{ganttDiagram-EL5Y4UJY-SGjvQBB2.js → ganttDiagram-EL5Y4UJY-CiIG1UJi.js} +3 -3
  38. package/dist/assets/{gitGraphDiagram-WWUBYQGX-CAA84Ivp.js → gitGraphDiagram-WWUBYQGX-D2dIAMJM.js} +1 -1
  39. package/dist/assets/{handlebars-CXqX7a5Q.js → handlebars-DNLrYaP9.js} +1 -1
  40. package/dist/assets/{html-DtvYfI7t.js → html-BS1KfpZd.js} +1 -1
  41. package/dist/assets/{htmlMode-3BMuKcE4.js → htmlMode-DMOL6ZZ8.js} +1 -1
  42. package/dist/assets/{infoDiagram-27XIBGKW-BGm_3tT-.js → infoDiagram-27XIBGKW-C7mby_UQ.js} +1 -1
  43. package/dist/assets/{ishikawaDiagram-5VMMS53U-CP8FRl0Y.js → ishikawaDiagram-5VMMS53U-CKoAmp3r.js} +1 -1
  44. package/dist/assets/{javascript-DxN_Zhmw.js → javascript-MUkO1ZlO.js} +1 -1
  45. package/dist/assets/{journeyDiagram-3NMN7TZE-BcalK113.js → journeyDiagram-3NMN7TZE-ZButrkrc.js} +1 -1
  46. package/dist/assets/{jsonMode-mwcyw9gP.js → jsonMode-BdabUg6K.js} +1 -1
  47. package/dist/assets/{kanban-definition-UXKFOSKX-pbhL8hUu.js → kanban-definition-UXKFOSKX-CL0MUqfn.js} +1 -1
  48. package/dist/assets/{layout-BhzHABFO.js → layout-BB2FuR9q.js} +1 -1
  49. package/dist/assets/{linear-5yISNnhL.js → linear-DaMhmF_j.js} +1 -1
  50. package/dist/assets/{liquid-BPYfnSFt.js → liquid-qKPAEGx4.js} +1 -1
  51. package/dist/assets/main-B33Kdita.css +10 -0
  52. package/dist/assets/{main-CxlijODv.js → main-CymCGBjE.js} +552 -552
  53. package/dist/assets/{mdx-DBqG1wHB.js → mdx-D6gJQuW7.js} +1 -1
  54. package/dist/assets/{mindmap-definition-YA3MSWOX-BBh1aw3T.js → mindmap-definition-YA3MSWOX-B9XCI7j2.js} +1 -1
  55. package/dist/assets/{pegDiagram-XKGWAZYB-BeDoshss.js → pegDiagram-XKGWAZYB-xelbkxv3.js} +1 -1
  56. package/dist/assets/{pieDiagram-E7YTZNPT-BR04OSiI.js → pieDiagram-E7YTZNPT-DTuUtdN9.js} +1 -1
  57. package/dist/assets/{python-Ddi57cf7.js → python-N6Jsdkb0.js} +1 -1
  58. package/dist/assets/{quadrantDiagram-AXDQQJYC-BDDaOGkG.js → quadrantDiagram-AXDQQJYC-B2FhzPs0.js} +1 -1
  59. package/dist/assets/{railroadDiagram-O6MQD6OU-BqaY2YPC.js → railroadDiagram-O6MQD6OU-BinYpPqV.js} +1 -1
  60. package/dist/assets/{razor-DrZpnk6M.js → razor-DcDMySKQ.js} +1 -1
  61. package/dist/assets/{requirementDiagram-BXWQKSXE-43BH11Ae.js → requirementDiagram-BXWQKSXE-CfikyqMh.js} +1 -1
  62. package/dist/assets/{sankeyDiagram-P5KCCOFB-C2L0p81g.js → sankeyDiagram-P5KCCOFB-WD0GrUF2.js} +2 -2
  63. package/dist/assets/{sequenceDiagram-WJ2MYXX4-CXF5x8ev.js → sequenceDiagram-WJ2MYXX4-ipcOJU9J.js} +1 -1
  64. package/dist/assets/{sizeCapture-INFHLROL-CjI-_lPR.js → sizeCapture-INFHLROL-CCbtUSZ4.js} +1 -1
  65. package/dist/assets/{stateDiagram-D77RDMKH-D3vjJ4g2.js → stateDiagram-D77RDMKH-Bhr6Bt8N.js} +1 -1
  66. package/dist/assets/stateDiagram-v2-MP3YSRHH-zu3H4ELi.js +1 -0
  67. package/dist/assets/{swimlanes-42K2YHIH-CYHpXdSf.js → swimlanes-42K2YHIH-BimQGb6L.js} +1 -1
  68. package/dist/assets/swimlanesDiagram-VR7AAH4N-BMmIVgDz.js +8 -0
  69. package/dist/assets/{timeline-definition-24CTP7MA-BPha40QA.js → timeline-definition-24CTP7MA-FCbEWebc.js} +1 -1
  70. package/dist/assets/{transformers.web-BDUO5uMG.js → transformers.web-BXqZNltD.js} +1 -1
  71. package/dist/assets/{tsMode-BbLr9eeK.js → tsMode-D7wEqxYM.js} +1 -1
  72. package/dist/assets/{typescript-jUHKT-MM.js → typescript-BZlhocTO.js} +1 -1
  73. package/dist/assets/{vennDiagram-4TSXK5OY-DydXxzDZ.js → vennDiagram-4TSXK5OY-PWf-TgJR.js} +1 -1
  74. package/dist/assets/{wardleyDiagram-VM6X3IG4-Bw5YkjvZ.js → wardleyDiagram-VM6X3IG4-B2KvgvnU.js} +1 -1
  75. package/dist/assets/{xml-BVmzC676.js → xml-BkdBykv0.js} +1 -1
  76. package/dist/assets/{xychartDiagram-S5SC5T6Z-BPuoRFVq.js → xychartDiagram-S5SC5T6Z-BSDwvGQR.js} +1 -1
  77. package/dist/assets/{yaml-DHERhSxW.js → yaml-DOVav427.js} +1 -1
  78. package/dist/index.html +3 -3
  79. package/dist/ui-build.json +1 -1
  80. package/dist-server/common/cache/provider-limit-cache.js +1 -1
  81. package/dist-server/domain/task/task-requested-effort.js +1 -1
  82. package/dist-server/domain/usage/antigravity-quota.client.js +2 -0
  83. package/dist-server/domain/usage/usage.controller.js +1 -1
  84. package/dist-server/domain/usage/usage.service.js +1 -1
  85. package/package.json +17 -17
  86. package/packages/cli/package.json +1 -1
  87. package/dist/assets/MarketPage-CQOXvd6k.js +0 -41
  88. package/dist/assets/channel-DlK_dXjA.js +0 -1
  89. package/dist/assets/classDiagram-ZZMXUADV-CiLuYlwT.js +0 -1
  90. package/dist/assets/classDiagram-v2-VYDZK3BY-CiLuYlwT.js +0 -1
  91. package/dist/assets/main-Dgopf2tt.css +0 -10
  92. package/dist/assets/stateDiagram-v2-MP3YSRHH-z8JTjeHq.js +0 -1
  93. package/dist/assets/swimlanesDiagram-VR7AAH4N-CMosvQLY.js +0 -8
@@ -1 +1 @@
1
- import{aC as w,aD as e,aE as g}from"./main-CxlijODv.js";import{M as j}from"./MonacoDiffSurface-xxuXxN2r.js";function p(n){const t=/^---\r?\n[\s\S]*?\r?\n---(?=\r?\n|$)/.exec(n);if(!t)return null;const r=t[0].split(/\r?\n/);return{text:t[0],endLine:r.length,summary:r[1]??r[0]}}function b(n,t){const r=n.split(/\r?\n/),a=Math.max(0,Math.min(r.length-1,t-1));let s=null,i=null;for(let l=a;l>=0&&(!s||!i);l-=1){const c=r[l].trimEnd();!s&&/^##\s+/.test(c)&&(s=c),!i&&/^-\s+/.test(c)&&(i=c)}return{heading:s,listItem:i}}function L(n,t,r){var i,l;const a=new Set,s=[];for(const c of r){const h=[b(n,c.originalStartLineNumber),b(t,c.modifiedStartLineNumber)],u=((i=h.find(f=>f.heading))==null?void 0:i.heading)??null,x=((l=h.find(f=>f.listItem))==null?void 0:l.listItem)??null;if(!u&&!x)continue;const m=JSON.stringify([u,x]);a.has(m)||(a.add(m),s.push({heading:u,listItem:x}))}return s}function v(n){if(!n)return null;const t=new Date(n);return Number.isNaN(t.getTime())?n:t.toISOString()}function y({side:n,label:t,fileVersion:r}){const{t:a}=w(),s=v(n.modifiedAt),i=n.revision===null?null:String(n.revision);return e.jsxs("section",{className:"min-w-0 rounded-md border border-gray-200 bg-gray-50 px-3 py-2","aria-label":t,children:[e.jsx("h3",{className:"truncate text-sm font-semibold text-gray-900",children:t}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-gray-600",children:[s?e.jsxs("span",{children:[a("threadAppWorkspace.resultShare.docSync.modifiedAt")," ",e.jsx("time",{dateTime:s,children:s})]}):null,i?e.jsxs("span",{children:[a("threadAppWorkspace.resultShare.docSync.version")," ",i]}):null]}),e.jsx("code",{className:"mt-1 block max-w-full break-all text-[11px] text-gray-500","data-testid":"doc-sync-file-version",children:r??n.hash})]})}function D({filepath:n,original:t,modified:r,originalLabel:a,modifiedLabel:s,originalVersion:i}){const[l,c]=g.useState([]),h=g.useRef(null),u=p(t.text),x=p(r.text),m=(u==null?void 0:u.text)===(x==null?void 0:x.text)?u:null,f=g.useMemo(()=>L(t.text,r.text,l),[l,r.text,t.text]);return e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(y,{side:t,label:a,fileVersion:i}),e.jsx(y,{side:r,label:s})]}),f.length>0?e.jsx("div",{className:"flex min-w-0 flex-col gap-1","aria-label":a,children:f.map((d,o)=>e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-x-2 rounded-md bg-blue-50 px-3 py-1.5 text-xs text-blue-900",children:[d.heading?e.jsx("span",{className:"break-words font-semibold",children:d.heading}):null,d.listItem?e.jsx("span",{className:"break-words",children:d.listItem}):null]},`${d.heading??""}:${d.listItem??""}:${o}`))}):null,m?e.jsxs("details",{className:"min-w-0 rounded-md border border-gray-200 bg-gray-50 text-xs text-gray-600","data-testid":"doc-sync-frontmatter",children:[e.jsx("summary",{className:"cursor-pointer truncate px-3 py-2",children:m.summary}),e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-words border-t border-gray-200 px-3 py-2 font-mono text-[11px] leading-relaxed text-gray-700","data-testid":"doc-sync-frontmatter-text",children:m.text})]}):null,e.jsx("div",{className:"h-[min(45vh,24rem)] min-h-64 min-w-0 shrink-0 overflow-hidden rounded-md border border-gray-200 bg-white",children:e.jsx(j,{filepath:n,original:t.text,modified:r.text,language:"plaintext",theme:"vs",renderSideBySide:!1,options:{automaticLayout:!0,readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",hideUnchangedRegions:{enabled:!1}},onDiffChange:d=>{c(d.map(o=>({originalStartLineNumber:o.originalStartLineNumber,originalEndLineNumber:o.originalEndLineNumber,modifiedStartLineNumber:o.modifiedStartLineNumber,modifiedEndLineNumber:o.modifiedEndLineNumber}))),window.requestAnimationFrame(()=>{const o=h.current;if(!o)return;const N=m&&m.endLine>2?[{startLineNumber:2,startColumn:1,endLineNumber:m.endLine,endColumn:1}]:[];for(const S of[o.getOriginalEditor(),o.getModifiedEditor()])S.setHiddenAreas(N)})},onEditorReady:d=>{h.current=d}})})]})}export{y as DocSyncSideMetadata,D as DocSyncTextDiff,L as buildDocSyncHunkContexts};
1
+ import{aC as w,aD as e,aE as g}from"./main-CymCGBjE.js";import{M as j}from"./MonacoDiffSurface-DeQWTrw_.js";function p(n){const t=/^---\r?\n[\s\S]*?\r?\n---(?=\r?\n|$)/.exec(n);if(!t)return null;const r=t[0].split(/\r?\n/);return{text:t[0],endLine:r.length,summary:r[1]??r[0]}}function b(n,t){const r=n.split(/\r?\n/),a=Math.max(0,Math.min(r.length-1,t-1));let s=null,i=null;for(let l=a;l>=0&&(!s||!i);l-=1){const c=r[l].trimEnd();!s&&/^##\s+/.test(c)&&(s=c),!i&&/^-\s+/.test(c)&&(i=c)}return{heading:s,listItem:i}}function L(n,t,r){var i,l;const a=new Set,s=[];for(const c of r){const h=[b(n,c.originalStartLineNumber),b(t,c.modifiedStartLineNumber)],u=((i=h.find(f=>f.heading))==null?void 0:i.heading)??null,x=((l=h.find(f=>f.listItem))==null?void 0:l.listItem)??null;if(!u&&!x)continue;const m=JSON.stringify([u,x]);a.has(m)||(a.add(m),s.push({heading:u,listItem:x}))}return s}function v(n){if(!n)return null;const t=new Date(n);return Number.isNaN(t.getTime())?n:t.toISOString()}function y({side:n,label:t,fileVersion:r}){const{t:a}=w(),s=v(n.modifiedAt),i=n.revision===null?null:String(n.revision);return e.jsxs("section",{className:"min-w-0 rounded-md border border-gray-200 bg-gray-50 px-3 py-2","aria-label":t,children:[e.jsx("h3",{className:"truncate text-sm font-semibold text-gray-900",children:t}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-gray-600",children:[s?e.jsxs("span",{children:[a("threadAppWorkspace.resultShare.docSync.modifiedAt")," ",e.jsx("time",{dateTime:s,children:s})]}):null,i?e.jsxs("span",{children:[a("threadAppWorkspace.resultShare.docSync.version")," ",i]}):null]}),e.jsx("code",{className:"mt-1 block max-w-full break-all text-[11px] text-gray-500","data-testid":"doc-sync-file-version",children:r??n.hash})]})}function D({filepath:n,original:t,modified:r,originalLabel:a,modifiedLabel:s,originalVersion:i}){const[l,c]=g.useState([]),h=g.useRef(null),u=p(t.text),x=p(r.text),m=(u==null?void 0:u.text)===(x==null?void 0:x.text)?u:null,f=g.useMemo(()=>L(t.text,r.text,l),[l,r.text,t.text]);return e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(y,{side:t,label:a,fileVersion:i}),e.jsx(y,{side:r,label:s})]}),f.length>0?e.jsx("div",{className:"flex min-w-0 flex-col gap-1","aria-label":a,children:f.map((d,o)=>e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-x-2 rounded-md bg-blue-50 px-3 py-1.5 text-xs text-blue-900",children:[d.heading?e.jsx("span",{className:"break-words font-semibold",children:d.heading}):null,d.listItem?e.jsx("span",{className:"break-words",children:d.listItem}):null]},`${d.heading??""}:${d.listItem??""}:${o}`))}):null,m?e.jsxs("details",{className:"min-w-0 rounded-md border border-gray-200 bg-gray-50 text-xs text-gray-600","data-testid":"doc-sync-frontmatter",children:[e.jsx("summary",{className:"cursor-pointer truncate px-3 py-2",children:m.summary}),e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-words border-t border-gray-200 px-3 py-2 font-mono text-[11px] leading-relaxed text-gray-700","data-testid":"doc-sync-frontmatter-text",children:m.text})]}):null,e.jsx("div",{className:"h-[min(45vh,24rem)] min-h-64 min-w-0 shrink-0 overflow-hidden rounded-md border border-gray-200 bg-white",children:e.jsx(j,{filepath:n,original:t.text,modified:r.text,language:"plaintext",theme:"vs",renderSideBySide:!1,options:{automaticLayout:!0,readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",hideUnchangedRegions:{enabled:!1}},onDiffChange:d=>{c(d.map(o=>({originalStartLineNumber:o.originalStartLineNumber,originalEndLineNumber:o.originalEndLineNumber,modifiedStartLineNumber:o.modifiedStartLineNumber,modifiedEndLineNumber:o.modifiedEndLineNumber}))),window.requestAnimationFrame(()=>{const o=h.current;if(!o)return;const N=m&&m.endLine>2?[{startLineNumber:2,startColumn:1,endLineNumber:m.endLine,endColumn:1}]:[];for(const S of[o.getOriginalEditor(),o.getModifiedEditor()])S.setHiddenAreas(N)})},onEditorReady:d=>{h.current=d}})})]})}export{y as DocSyncSideMetadata,D as DocSyncTextDiff,L as buildDocSyncHunkContexts};
@@ -1,4 +1,4 @@
1
- import{bd as z,be as R,aE as a,aC as L,bf as O,bg as A,aD as c,bh as C}from"./main-CxlijODv.js";import{l as b,M as B}from"./MonacoDiffSurface-xxuXxN2r.js";/**
1
+ import{bd as z,be as R,aE as a,aC as L,bf as O,bg as A,aD as c,bh as C}from"./main-CymCGBjE.js";import{l as b,M as B}from"./MonacoDiffSurface-DeQWTrw_.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,41 @@
1
+ import{bd as B,bi as K,aC as U,bj as Ae,bk as P,aE as n,bl as Tt,bm as Re,bn as V,bo as lt,bp as T,bq as Ot,br as Ut,bs as Ft,aD as e,bt as O,bh as pe,bu as $t,bv as ze,bw as Vt,bx as ot,by as Bt,bz as Ze,bA as Ht,bB as et,bC as qt,bD as Wt,bE as Kt,bF as Ee,bG as te,bH as tt,bI as Gt,bJ as ct,bK as Qt,bL as Yt,bM as Jt,bN as Xt,bO as dt,bP as ut,bQ as mt,bR as Me,bS as se,bT as Zt,bU as xt,bV as pt,bW as gt,bX as es,bY as ts,bZ as ss}from"./main-CymCGBjE.js";/**
2
+ * @license lucide-react v0.563.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const rs=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],as=B("badge-check",rs);/**
7
+ * @license lucide-react v0.563.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ns=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],is=B("cloud-upload",ns);/**
12
+ * @license lucide-react v0.563.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ls=[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]],ht=B("layout-template",ls);/**
17
+ * @license lucide-react v0.563.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const os=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],cs=B("package-check",os);/**
22
+ * @license lucide-react v0.563.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const ds=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],ft=B("plug",ds);/**
27
+ * @license lucide-react v0.563.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const us=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],bt=B("puzzle",us);/**
32
+ * @license lucide-react v0.563.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const ms=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]],xs=B("scale",ms);/**
37
+ * @license lucide-react v0.563.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const ps=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],yt=B("shopping-bag",ps),gs={SESSION_REFRESH_UNAVAILABLE:"ACCOUNT_SESSION_REFRESH_UNAVAILABLE"};function hs(t){return t instanceof K?t.status===403&&t.code==="GRANT_REVOKED"?"grantRevoked":t.status===403&&t.code==="SHARING_OWNER_RECIPIENT_LIMIT_REACHED"?"ownerRecipientLimit":t.status===404&&t.code==="INVITE_NOT_FOUND"?"notFound":t.status===409&&t.code==="INVITE_USED"?"used":t.status===410&&t.code==="INVITE_REVOKED"?"revoked":t.status===410&&t.code==="INVITE_EXPIRED"?"expired":"generic":"generic"}function st(t){return t instanceof K&&t.status===401&&t.code==="NOT_LOGGED_IN"}function rt(t){return typeof t=="object"&&t!==null}function at(t){return!rt(t)||!Array.isArray(t.findings)?[]:t.findings.filter(i=>rt(i)&&typeof i.path=="string"&&typeof i.line=="number"&&typeof i.rule=="string")}function fs(t){return{name:typeof t.name=="string"?t.name:"",version:typeof t.version=="string"?t.version:""}}const bs={[gs.SESSION_REFRESH_UNAVAILABLE]:{titleKey:"market.publish.failure.sessionRefreshUnavailable.title",descriptionKey:"market.publish.failure.sessionRefreshUnavailable.description",ctaKey:"market.publish.failure.sessionRefreshUnavailable.settingsCta",action:"settings"},PUBLISH_MARKETPLACE_UNAVAILABLE:{titleKey:"market.publish.failure.remoteUnavailable.title",descriptionKey:"market.publish.failure.remoteUnavailable.description",ctaKey:"market.publish.failure.retry",action:"retry"}},ys=6e4,ks=3e3;function js(){const{t}=U(),i=Ae(),o=P(r=>r.currentWorkspaceSlug),[l,u]=n.useState({kind:"checkingAuth"}),y=n.useRef({kind:"checkingAuth"});y.current=l;const[m,w]=n.useState(!1),C=n.useRef(null),c=n.useRef(null),S=n.useRef(new Set),v=n.useRef(!1),f=n.useCallback(r=>{r.finished||(r.finished=!0,S.current.delete(r),c.current===r&&(c.current=null,C.current=null),r.owner.dispose())},[]),L=n.useCallback(r=>{!r||r.finished||(r.retired=!0,v.current=!0,S.current.add(r),c.current===r&&(c.current=null,C.current=null),r.owner.dispose(),r.restSettled&&f(r))},[f]),A=n.useCallback(r=>(r.settlement||(r.settlement=(async()=>{try{const a=await r.promise;if(!r.isCurrent())return;u(x=>x.kind==="running"||x.kind==="succeeded"?{kind:"succeeded",result:a}:x)}catch(a){if(!r.isCurrent())return;const x=a instanceof K&&a.code?a.code:"PUBLISH_FAILED",j=a instanceof K?at(a.body):[];u(p=>p.kind==="running"?{kind:"failed",code:x,findings:j}:p),st(a)&&(r.signOutCheck??(r.signOutCheck=Tt(r.owner,{confirmLoggedOut:Re.getState().confirmLoggedOut,showLogin:()=>u({kind:"failed",code:"NOT_LOGGED_IN",findings:[]})},r.isCurrent)),await r.signOutCheck)}finally{f(r)}})()),r.settlement),[f]);n.useEffect(()=>()=>{L(c.current)},[L]);const R=n.useRef(0),I=n.useCallback(async()=>{const r=++R.current,a=P.getState().currentWorkspaceSlug,x=T(),j=()=>r===R.current&&P.getState().currentWorkspaceSlug===a&&T()===x;u({kind:"loadingPlan"});try{const p=await V.getPublishPlan();if(!j())return;u({kind:"prepared",plan:p})}catch{if(!j())return;u({kind:"planLoadFailed"})}},[]);n.useEffect(()=>{let r=!1;const a=T();return(async()=>{let x=!1;try{x=(await V.getAccountStatus()).loggedIn}catch{x=!1}if(!(r||a!==T()||P.getState().currentWorkspaceSlug!==o)){if(!x){u({kind:"notLoggedIn"});return}await I()}})(),()=>{r=!0}},[I,o]);const z=n.useRef(o);n.useEffect(()=>{if(z.current===o)return;z.current=o,R.current+=1;const r=c.current;L(r),u({kind:"checkingAuth"})},[L,o]);const b=n.useCallback(()=>{const r=y.current;if(r.kind!=="prepared")return;const a=r.plan,x=P.getState().currentWorkspaceSlug,j=T();let p;const G=lt(()=>{if(c.current!==p)return;L(p);const _=Re.getState().snapshot;u(_!=null&&_.loggedIn?{kind:"prepared",plan:a}:{kind:"notLoggedIn"})});u({kind:"running",plan:a,step:"packing"});const H=V.runPublish();C.current=H,p={owner:G,promise:H,plan:a,workspaceSlug:x,workspaceEpoch:j,isCurrent:()=>c.current===p&&G.isCurrent()&&P.getState().currentWorkspaceSlug===x&&T()===j,terminalEventSeen:!1,sseAmbiguous:v.current,restSettled:!1,retired:!1,finished:!1,settlement:null,signOutCheck:null},c.current=p,H.then(()=>{if(p.restSettled=!0,p.retired){f(p);return}if(p.sseAmbiguous||v.current){A(p);return}p.terminalEventSeen&&queueMicrotask(()=>{c.current!==p||p.settlement!==null||f(p)})},_=>{if(p.restSettled=!0,p.retired){f(p);return}if(st(_)||p.sseAmbiguous||v.current){A(p);return}p.terminalEventSeen&&queueMicrotask(()=>{c.current!==p||p.settlement!==null||f(p)})})},[f,L,A]),D=n.useCallback(async()=>{const r=c.current,a=C.current;!r||!a||r.promise!==a||!r.isCurrent()||y.current.kind!=="running"||(!r.sseAmbiguous&&!v.current&&V.getPublishPlan().then(x=>{r.isCurrent()&&u(j=>j.kind==="running"?{...j,plan:x}:j)}).catch(()=>{}),await A(r))},[A]),ae=n.useMemo(()=>({"publish.step_changed":r=>{const a=c.current;!a||a.sseAmbiguous||v.current||!a.isCurrent()||u(x=>x.kind==="running"?{...x,step:r.step}:x)},"publish.succeeded":r=>{const a=c.current;!a||a.sseAmbiguous||v.current||!a.isCurrent()||(a.terminalEventSeen=!0,u(x=>x.kind==="running"?{kind:"succeeded",result:{tgzPath:"",fileCount:0,totalBytes:0,manifest:x.plan.manifest,slug:r.slug,version:r.version,artifactChecksum:"",artifactSizeBytes:0,submitOutcome:"created"}}:x),a.promise.then(x=>{a.isCurrent()&&(u(j=>j.kind==="succeeded"?{kind:"succeeded",result:x}:j),queueMicrotask(()=>{c.current!==a||a.settlement!==null||f(a)}))}).catch(()=>{}))},"publish.failed":r=>{const a=c.current;!a||a.sseAmbiguous||v.current||!a.isCurrent()||(a.terminalEventSeen=!0,u({kind:"failed",code:r.code,findings:[]}),a.promise.catch(x=>{if(a.isCurrent()){if(x instanceof K){const j=at(x.body);j.length>0&&u(p=>p.kind==="failed"&&p.code===r.code?{...p,findings:j}:p)}queueMicrotask(()=>{c.current!==a||a.settlement!==null||f(a)})}}))}}),[f]),{connected:k}=Ot(o,ae),M=Ut(()=>{D()},ks),ne=n.useRef(k);if(n.useEffect(()=>{const r=k&&!ne.current;ne.current=k,r&&l.kind==="running"&&M()},[k,l.kind,M]),Ft(M,{interval:ys,enabled:l.kind==="running",invokeOnResume:!0}),l.kind==="checkingAuth"||l.kind==="loadingPlan")return e.jsx("div",{className:"flex min-h-[320px] items-center justify-center rounded-2xl border border-gray-200 bg-white p-8 shadow-sm",children:e.jsx(O,{size:22,className:"animate-spin text-gray-400"})});if(l.kind==="notLoggedIn")return e.jsxs("div",{className:"flex min-h-[320px] flex-col items-center justify-center gap-4 rounded-2xl border border-gray-200 bg-white p-8 text-center shadow-sm",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700",children:t("market.publish.notLoggedIn.title")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("market.publish.notLoggedIn.description")}),e.jsx("button",{type:"button",onClick:()=>i("/settings#account"),className:"inline-flex items-center gap-1.5 rounded-lg bg-blue-500 px-3 py-2 text-sm font-medium text-white transition hover:bg-blue-600",children:t("market.publish.notLoggedIn.loginCta")})]});if(l.kind==="planLoadFailed")return e.jsxs("div",{className:"flex items-start gap-3 rounded-2xl border border-red-200 bg-red-50 p-4 shadow-sm",children:[e.jsx(pe,{size:18,className:"mt-0.5 shrink-0 text-red-700"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-red-700",children:t("market.publish.errors.planLoadFailed")}),e.jsx("button",{type:"button",onClick:()=>void I(),className:"mt-2 rounded-lg border border-red-300 bg-white px-3 py-1.5 text-xs font-medium text-red-700 transition hover:bg-red-100",children:t("market.publish.failure.retry")})]})]});if(l.kind==="failed"){if(l.code==="SECRET_FINDINGS")return e.jsxs("div",{className:"space-y-3 rounded-2xl border border-red-300 bg-red-50 p-4 shadow-sm",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(pe,{size:18,className:"mt-0.5 shrink-0 text-red-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-red-800",children:t("market.publish.failure.secretFindings.title")}),e.jsx("p",{className:"mt-1 text-xs text-red-700",children:t("market.publish.failure.secretFindings.description")})]})]}),e.jsx("ul",{className:"space-y-1 rounded-lg border border-red-200 bg-white p-3 text-xs text-red-800",children:l.findings.map((a,x)=>e.jsxs("li",{className:"font-mono",children:[a.path,":",a.line," (",a.rule,")"]},`${a.path}:${a.line}:${x}`))}),e.jsxs("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"inline-flex cursor-not-allowed items-center gap-1.5 rounded-lg border border-red-300 bg-white px-3 py-2 text-sm font-medium text-red-400",children:[e.jsx($t,{size:14}),t("market.publish.failure.secretFindings.locked")]})]});if(l.code==="NOT_LOGGED_IN")return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 rounded-2xl border border-red-200 bg-red-50 p-8 text-center shadow-sm",children:[e.jsx(pe,{size:22,className:"text-red-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-red-800",children:t("market.publish.failure.notLoggedIn.title")}),e.jsx("p",{className:"mt-1 text-xs text-red-700",children:t("market.publish.failure.notLoggedIn.description")})]}),e.jsx("button",{type:"button",onClick:()=>i("/settings#account"),className:"inline-flex items-center gap-1.5 rounded-lg bg-blue-500 px-3 py-2 text-sm font-medium text-white transition hover:bg-blue-600",children:t("market.publish.failure.notLoggedIn.loginCta")})]});const r=bs[l.code];return e.jsxs("div",{className:"flex items-start gap-3 rounded-2xl border border-red-200 bg-red-50 p-4 shadow-sm",children:[e.jsx(pe,{size:18,className:"mt-0.5 shrink-0 text-red-700"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-red-800",children:t(r?r.titleKey:"market.publish.failure.generic.title")}),r?e.jsx("p",{className:"mt-1 text-xs text-red-700",children:t(r.descriptionKey)}):e.jsx("p",{className:"mt-1 text-xs font-mono text-red-700",children:l.code}),e.jsx("button",{type:"button",onClick:(r==null?void 0:r.action)==="settings"?()=>i("/settings#account"):()=>void I(),className:(r==null?void 0:r.action)==="settings"?"mt-2 inline-flex items-center gap-1.5 rounded-lg bg-blue-500 px-3 py-2 text-sm font-medium text-white transition hover:bg-blue-600":"mt-2 rounded-lg border border-red-300 bg-white px-3 py-1.5 text-xs font-medium text-red-700 transition hover:bg-red-100",children:t(r?r.ctaKey:"market.publish.failure.retry")})]})]})}if(l.kind==="succeeded"){const{slug:r,version:a,artifactChecksum:x}=l.result;return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 rounded-2xl border border-green-200 bg-green-50 p-8 text-center shadow-sm",children:[e.jsx(ze,{size:28,className:"text-green-600"}),e.jsx("p",{className:"text-sm font-semibold text-green-800",children:t("market.publish.success.title")}),e.jsxs("dl",{className:"w-full max-w-sm space-y-1 rounded-lg border border-green-200 bg-white p-3 text-left text-xs text-gray-700",children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("dt",{className:"font-medium text-gray-500",children:t("market.publish.success.slugLabel")}),e.jsx("dd",{className:"font-mono",children:r})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("dt",{className:"font-medium text-gray-500",children:t("market.publish.success.versionLabel")}),e.jsx("dd",{className:"font-mono",children:a})]}),e.jsxs("div",{className:"flex justify-between gap-2 break-all",children:[e.jsx("dt",{className:"shrink-0 font-medium text-gray-500",children:t("market.publish.success.checksumLabel")}),e.jsx("dd",{className:"font-mono",children:x})]})]})]})}const{name:he,version:J}=fs(l.plan.manifest),X=l.plan.excluded.length;return e.jsxs("div",{className:"space-y-4 rounded-2xl border border-gray-200 bg-white p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-900",children:t("market.publish.prepare.title",{name:he,version:J})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-gray-500",children:[e.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 font-medium text-gray-700",children:[t("market.publish.prepare.visibilityLabel"),": ",t("market.publish.prepare.visibilityPrivate")]}),e.jsx("span",{children:t("market.publish.prepare.includedCount",{count:l.plan.included.length})}),e.jsx("span",{children:t("market.publish.prepare.excludedCount",{count:X})})]})]}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>w(r=>!r),className:"inline-flex items-center gap-1 text-xs font-medium text-gray-600 hover:text-gray-900",children:[m?e.jsx(Vt,{size:14}):e.jsx(ot,{size:14}),t(m?"market.publish.prepare.excludedHide":"market.publish.prepare.excludedShow")]}),m?e.jsx("ul",{className:"mt-2 space-y-1 rounded-lg border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600",children:X===0?e.jsx("li",{className:"text-gray-400",children:t("market.publish.prepare.excludedEmpty")}):l.plan.excluded.map((r,a)=>e.jsxs("li",{className:"font-mono",children:[r.path," (",r.rule,")"]},`${r.path}:${a}`))}):null]}),l.kind==="running"?e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-blue-200 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:[e.jsx(O,{size:16,className:"animate-spin"}),l.step==="packing"?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(cs,{size:14}),t("market.publish.progress.steps.packing")]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(is,{size:14}),t("market.publish.progress.steps.uploading")]})]}):e.jsx("button",{type:"button",onClick:b,className:"inline-flex items-center justify-center gap-2 rounded-xl bg-blue-500 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-blue-600",children:t("market.publish.prepare.submit")})]})}const re=new Map;function _e(t){!t.settled||t.consumers>0||t.continuations>0||(re.get(t.key)===t&&re.delete(t.key),t.ownerDisposed||(t.ownerDisposed=!0,t.owner.dispose()))}function Se(t){t.continuations+=1;let i=!1;return()=>{i||(i=!0,t.continuations-=1,_e(t))}}function Ns(t){const i=P.getState().currentWorkspaceSlug,o=T(),l=JSON.stringify([t,i,o]),u=re.get(l);if(u)return u;const y=lt(),m={key:l,owner:y,workspaceSlug:i,workspaceEpoch:o,promise:V.acceptMarketplaceInvite(t),consumers:0,continuations:0,settled:!1,ownerDisposed:!1,isCurrent:()=>y.isCurrent()&&P.getState().currentWorkspaceSlug===i&&T()===o};re.set(l,m);const w=()=>{m.settled=!0,_e(m)};return m.promise.then(w,w),m}function kt(t,i){if(!t)return null;const o=new Date(t);return Number.isNaN(o.getTime())?null:new Intl.DateTimeFormat(i,{year:"numeric",month:"short",day:"numeric"}).format(o)}function vs(t,i){return kt(t,i)??"—"}function ws(t,i){if(!t)return null;const o=new Date(t);if(Number.isNaN(o.getTime()))return null;const l=o.getTime()-Date.now(),u=[{unit:"year",ms:1e3*60*60*24*365},{unit:"month",ms:1e3*60*60*24*30},{unit:"week",ms:1e3*60*60*24*7},{unit:"day",ms:1e3*60*60*24},{unit:"hour",ms:1e3*60*60},{unit:"minute",ms:1e3*60}],y=new Intl.RelativeTimeFormat(i,{numeric:"auto"});for(const m of u)if(Math.abs(l)>=m.ms||m.unit==="minute")return y.format(Math.round(l/m.ms),m.unit);return null}function nt(t,i){return typeof t!="number"?"—":new Intl.NumberFormat(i,{notation:"compact",compactDisplay:"short",maximumFractionDigits:1}).format(t)}function jt(t){var l,u,y;const i=(l=t.sourceRepoUrl)==null?void 0:l.trim(),o=(u=t.packageRootPath)==null?void 0:u.trim();if(!i||!o)return null;try{const m=new URL(i);if(m.protocol!=="https:"||m.hostname.toLowerCase()!=="github.com")return null;const w=m.pathname.split("/").filter(Boolean);if(w.length!==2)return null;const C=w[0],c=(y=w[1])==null?void 0:y.replace(/\.git$/i,"");if(o.startsWith("/"))return null;const S=o.split("/");if(S.some(f=>f==="."||f===".."))return null;const v=S.filter(Boolean).map(encodeURIComponent).join("/");return!C||!c||!v?null:`${m.origin}/${encodeURIComponent(C)}/${encodeURIComponent(c)}/tree/HEAD/${v}`}catch{return null}}function Nt(t){return t.installSource==="custom"}function Cs(t){const i={agents:t.agents,executableSkills:t.executableSkills,mcpServers:t.mcpServers,lifecycleScripts:t.lifecycleScripts,nonRegistryDependencies:t.nonRegistryDependencies,skillRegistries:t.skillRegistries};return Object.values(i).every(o=>o.length===0)}function Is(t){return t.overwrites.length>0||t.requiredEnv.length>0||!Cs(t.permissions)}const Ss={INSTALL_PLAN_EXPIRED:"market.installPlan.expired",PACKAGE_VERIFICATION_FAILED:"market.installPlan.packageVerificationFailed",INSTALL_ROLLBACK_FAILED:"market.installPlan.rollbackFailed",PACKAGE_ARCHIVE_ENTRY_FORBIDDEN:"market.installPlan.archiveEntryForbidden"};function Le(t,i){const o=t instanceof K?t.code:null;return i(Ss[o??""]??"market.errors.install")}function Ls(t){return t.slug?{ref:t.slug,name:t.name,displayName:t.displayName||t.name,version:t.version}:null}function De(t){switch(t==null?void 0:t.toLowerCase()){case"app":return"app";case"template":return"template";case"agent":return"agent";case"workflow":return"workflow";case"plugin":return"plugin";default:return"skill"}}function Pe({type:t}){const{t:i}=U(),o=De(t),l={app:"bg-violet-50 text-violet-700",skill:"bg-violet-50 text-violet-700",template:"bg-amber-50 text-amber-700",agent:"bg-emerald-50 text-emerald-700",workflow:"bg-cyan-50 text-cyan-700",plugin:"bg-rose-50 text-rose-700"},u={app:gt,skill:bt,template:ht,agent:pt,workflow:xt,plugin:ft},y={app:i("market.types.app"),skill:i("market.types.skill"),template:i("market.types.template"),agent:i("market.types.agent"),workflow:i("market.types.workflow"),plugin:i("market.types.plugin")},m=u[o];return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${l[o]}`,children:[e.jsx(m,{size:12}),y[o]]})}const Rs={trusted:{bg:"bg-green-50",text:"text-green-700",icon:ss,label:"market.badges.trusted"},verified:{bg:"bg-blue-50",text:"text-blue-700",icon:as,label:"market.badges.verified"},unverified:{bg:"bg-gray-50",text:"text-gray-500",icon:se,label:"market.badges.unverified"}};function vt({level:t,compact:i=!1}){const{t:o}=U(),l=Rs[t],u=l.icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md ${i?"px-1.5 py-0.5 text-[10px]":"rounded-full px-2.5 py-1 text-xs"} font-medium ${l.bg} ${l.text}`,children:[e.jsx(u,{size:i?11:13}),o(l.label)]})}function Te(t){if(t.trustLevel==="unverified"){if(t.type==="plugin")return{allowed:!1,reason:"market.trust.blockedPlugin"};if(t.type==="exec")return{allowed:!1,reason:"market.trust.blockedExec"}}return t.trustLevel==="verified"&&t.type==="plugin"?{allowed:!0,needsConfirm:!0}:{allowed:!0}}function Es({itemName:t,onConfirm:i,onCancel:o}){const{t:l}=U();return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"w-full max-w-md overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[e.jsxs("div",{className:"border-b border-gray-200 px-6 py-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:l("market.pluginDialog.title")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:l("market.pluginDialog.description")})]}),e.jsxs("div",{className:"space-y-3 px-6 py-5",children:[e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 px-4 py-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:t}),e.jsx("p",{className:"mt-1 text-sm text-amber-800",children:l("market.pluginDialog.warning")})]}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-600",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(se,{size:14,className:"shrink-0 text-amber-500"}),l("market.pluginDialog.perm1")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(se,{size:14,className:"shrink-0 text-amber-500"}),l("market.pluginDialog.perm2")]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 px-6 py-4",children:[e.jsx("button",{type:"button",onClick:o,className:"rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:l("market.actions.cancel")}),e.jsx("button",{type:"button",onClick:i,className:"rounded-lg bg-red-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-red-600",children:l("market.actions.install")})]})]})})}function it({skill:t,onSelect:i,busy:o,canInstall:l,onInstall:u,onUninstall:y}){const{t:m,i18n:w}=U(),C=ws(t.updatedAt,w.language),c=jt(t),S=Nt(t),v=t.registryName||t.author||m(S?"market.card.localSource":"market.card.unknownAuthor"),f=De(t.type),L={app:gt,skill:bt,template:ht,agent:pt,workflow:xt,plugin:ft},A={app:t.isInstalled?"bg-violet-200 text-violet-800":"bg-violet-100 text-violet-700",skill:t.isInstalled?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500",template:"bg-amber-100 text-amber-700",agent:"bg-emerald-100 text-emerald-700",workflow:"bg-cyan-100 text-cyan-700",plugin:"bg-rose-100 text-rose-700"},R=L[f],I=S?es:ts,z=t.displayName||t.name,b=Te(t);return e.jsxs("article",{className:"group flex h-[232px] min-w-0 flex-col overflow-hidden rounded-[14px] border border-gray-200 bg-white shadow-sm transition hover:-translate-y-0.5 hover:border-blue-200 hover:shadow-lg",children:[e.jsxs("button",{type:"button",onClick:()=>i(t.name),"aria-label":`${z} ${m("market.card.viewDetails")}`,className:"flex min-h-0 w-full flex-1 flex-col overflow-hidden bg-white px-3.5 py-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-inset",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-[11px] ${A[f]}`,"aria-hidden":"true",children:e.jsx(R,{size:19})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-tight text-gray-900",children:z}),e.jsxs("span",{className:"shrink-0 rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-bold text-gray-600",children:["v",t.version]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[e.jsx(Pe,{type:t.type}),!S&&e.jsx(vt,{level:t.trustLevel,compact:!0}),t.isInstalled&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-green-100 px-1.5 py-0.5 text-[10px] font-semibold text-green-700",children:[e.jsx(ze,{size:11}),m("market.badges.installed")]}),t.hasUpdate&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-orange-200 bg-orange-50 px-1.5 py-0.5 text-[10px] font-semibold text-orange-700",children:[e.jsx(dt,{size:11}),m("market.badges.updateAvailable",{version:t.remoteVersion})]})]})]})]}),e.jsx("p",{className:"mt-2.5 h-[34px] overflow-hidden text-[11.5px] leading-[1.5] text-gray-500 line-clamp-2",children:t.description||m("market.card.noDescription")}),e.jsx("div",{className:"mt-2 flex min-h-[19px] gap-1 overflow-hidden",children:t.tags.slice(0,3).map(D=>e.jsxs("span",{className:"shrink-0 rounded-full border border-gray-200 bg-gray-50 px-2 py-0.5 text-[10px] text-gray-500",children:["#",D]},D))}),e.jsxs("div",{className:"mt-auto flex min-w-0 items-center gap-1 text-[10px] text-gray-400",children:[e.jsx(I,{size:12,className:"shrink-0","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:[v,C?` · ${m("market.list.updatedLabel",{time:C})}`:""]})]})]}),e.jsxs("div",{className:"flex min-h-[47px] flex-none items-center justify-between gap-2 border-t border-gray-100 bg-gray-50/50 px-3 py-2",children:[c?e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer","aria-label":m("market.card.sourceLink"),className:"inline-flex min-w-0 items-center gap-1 text-[10.5px] font-semibold text-blue-600 hover:underline",children:[e.jsx(ut,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:m("market.card.sourceLink")})]}):e.jsx("span",{className:"truncate text-[10.5px] text-gray-400",children:S?m("market.card.localSource"):v}),t.isInstalled?e.jsxs("button",{type:"button",onClick:()=>y(t.name),disabled:o,className:"inline-flex min-h-[30px] shrink-0 items-center justify-center gap-1.5 rounded-lg bg-red-50 px-3 py-1.5 text-[11.5px] font-bold text-red-600 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[o?e.jsx(O,{size:13,className:"animate-spin"}):e.jsx(mt,{size:13}),m("market.actions.uninstall")]}):b.allowed?e.jsxs("button",{type:"button",onClick:()=>u(t),disabled:o||!l,className:"inline-flex min-h-[30px] shrink-0 items-center justify-center gap-1.5 rounded-lg bg-blue-500 px-3 py-1.5 text-[11.5px] font-bold text-white transition-colors hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50",children:[o?e.jsx(O,{size:13,className:"animate-spin"}):e.jsx(Me,{size:13}),m("market.actions.install")]}):e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-lg bg-gray-100 px-2.5 py-1.5 text-[10.5px] font-bold text-gray-400",children:[e.jsx(se,{size:13}),m(b.reason)]})]})]})}function ge({icon:t,label:i,value:o}){return e.jsxs("div",{className:"rounded-xl border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{className:"text-gray-400",children:t}),e.jsx("span",{children:i})]}),e.jsx("p",{className:"mt-2 text-sm font-semibold text-gray-900",children:o})]})}function As({skill:t,markdownBody:i,descriptionLoading:o,descriptionError:l,busy:u,canInstall:y,onInstall:m,onUninstall:w,onRefresh:C}){var z;const{t:c,i18n:S}=U(),v=jt(t),f=Nt(t),L=t.registryName||t.author||(f?null:c("market.card.unknownAuthor")),A=kt(t.updatedAt,S.language),R=typeof t.installCount=="number"&&!(t.registryOrigin==="github"&&t.installCount===0),I=[];return typeof t.stars=="number"&&I.push(e.jsx(ge,{icon:e.jsx(Yt,{size:14}),label:c("market.detail.stats.stars"),value:nt(t.stars,S.language)},"stars")),R&&I.push(e.jsx(ge,{icon:e.jsx(Jt,{size:14}),label:c("market.detail.stats.installs"),value:nt(t.installCount,S.language)},"installs")),(z=t.license)!=null&&z.trim()&&I.push(e.jsx(ge,{icon:e.jsx(xs,{size:14}),label:c("market.detail.stats.license"),value:t.license.trim()},"license")),A&&I.push(e.jsx(ge,{icon:e.jsx(Xt,{size:14}),label:c("market.detail.stats.updatedAt"),value:A},"updatedAt")),e.jsxs("section",{className:"flex h-full min-h-[520px] flex-col rounded-2xl border border-gray-200 bg-white p-6 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-gray-200 pb-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:t.displayName||t.name}),e.jsxs("span",{className:"rounded-full bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-600",children:["v",t.version]}),t.hasUpdate&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-orange-50 px-2.5 py-1 text-xs font-medium text-orange-700",children:[e.jsx(dt,{size:12}),c("market.badges.updateAvailable",{version:t.remoteVersion})]}),e.jsx(Pe,{type:t.type}),!f&&e.jsx(vt,{level:t.trustLevel})]}),(L||v)&&e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-gray-500",children:[L&&e.jsx("span",{children:L}),v&&e.jsxs("a",{href:v,target:"_blank",rel:"noopener noreferrer","aria-label":c("market.card.sourceLink"),className:"inline-flex items-center gap-1 font-medium text-blue-600 transition-colors hover:text-blue-700",children:[e.jsx(ut,{size:14}),c("market.card.sourceLink")]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.isInstalled?e.jsxs("button",{type:"button",onClick:()=>w(t.name),disabled:u,className:"inline-flex items-center gap-2 rounded-lg bg-red-50 px-4 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[u?e.jsx(O,{size:16,className:"animate-spin"}):e.jsx(mt,{size:16}),c("market.actions.uninstall")]}):(()=>{const b=Te(t);return b.allowed?e.jsxs("button",{type:"button",onClick:()=>m(t),disabled:u||!y,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50",children:[u?e.jsx(O,{size:16,className:"animate-spin"}):e.jsx(Me,{size:16}),c("market.actions.install")]}):e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-400",children:[e.jsx(se,{size:16}),c(b.reason)]})})(),e.jsxs("button",{type:"button",onClick:C,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[e.jsx(Ee,{size:16}),c("market.actions.checkUpdates")]})]})]}),e.jsxs("div",{className:"space-y-6 py-6",children:[t.isCustomized&&t.hasUpdate&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3",children:[e.jsx(te,{size:16,className:"mt-0.5 shrink-0 text-amber-600"}),e.jsx("p",{className:"text-sm text-amber-800",children:c("market.badges.customizedWarning")})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:c("market.detail.description")}),e.jsxs("div",{className:"mt-2",children:[t.description&&e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-6 text-gray-600",children:t.description}),o?e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(O,{size:16,className:"animate-spin"}),e.jsx("span",{children:c("market.detail.loadingBody")})]}):i!=null&&i.trim()?e.jsx("div",{className:t.description?"mt-3 border-t border-gray-100 pt-3":"",children:e.jsx(Zt,{content:i,className:"text-sm"})}):e.jsxs(e.Fragment,{children:[l&&e.jsx("div",{className:"mt-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800",children:l}),!t.description&&e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-6 text-gray-600",children:c("market.card.noDescription")})]})]})]}),t.tags.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:c("market.detail.tags")}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:t.tags.map(b=>e.jsxs("span",{className:"rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-600",children:["#",b]},b))})]}),t.authors&&t.authors.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:c("market.detail.developers")}),e.jsx("div",{className:"mt-3 space-y-3",children:t.authors.map(b=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:b.avatarUrl,alt:`@${b.login}`,className:"h-8 w-8 rounded-full border border-gray-200 object-cover"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-gray-900",children:b.name||b.login}),e.jsxs("div",{className:"text-xs text-gray-500",children:["@",b.login]})]}),typeof b.contributions=="number"&&e.jsx("div",{className:"text-xs text-gray-400",children:c("market.detail.contributions",{count:b.contributions})})]},`${t.name}-${b.login}`))})]})]}),I.length>0&&e.jsx("div",{className:"mt-auto grid gap-3 border-t border-gray-200 pt-6 sm:grid-cols-2 xl:grid-cols-4",children:I})]})}function zs({item:t,update:i,installing:o,onInstall:l}){const{t:u,i18n:y}=U();return e.jsx("article",{className:"rounded-xl border border-gray-200 bg-white p-4 shadow-sm",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-gray-900",children:t.displayName||t.name}),e.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-medium text-gray-600",children:["v",t.version]}),i&&e.jsx("span",{className:"rounded-full bg-blue-50 px-2 py-0.5 text-[10px] font-medium text-blue-700",children:u("market.shared.card.newVersion",{version:i.latestVersion})}),e.jsx(Pe,{type:t.type})]}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-gray-500",children:t.description||u("market.card.noDescription")}),e.jsxs("p",{className:"mt-2 text-[11px] text-gray-400",children:[t.author||u("market.card.unknownAuthor")," · ",u("market.shared.card.grantedAt",{date:vs(t.grant.grantedAt,y.language)})]})]}),e.jsxs("button",{type:"button",disabled:o,onClick:()=>l(t),"aria-busy":o,className:`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors ${o?"cursor-not-allowed bg-gray-100 text-gray-400":"bg-blue-500 text-white hover:bg-blue-600"}`,children:[o?e.jsx(O,{size:14,className:"animate-spin"}):e.jsx(Me,{size:14}),u(o?"market.shared.card.installing":"market.shared.card.install")]})]})})}function Ms({items:t,loading:i,error:o,notLoggedIn:l,updateSlugs:u,installingRef:y,onInstall:m}){const{t:w}=U(),C=Ae();return l?e.jsxs("div",{className:"flex min-h-[320px] flex-col items-center justify-center gap-4 rounded-2xl border border-gray-200 bg-white p-8 text-center shadow-sm",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700",children:w("market.shared.notLoggedIn.title")}),e.jsx("button",{type:"button",onClick:()=>C("/settings#account"),className:"inline-flex items-center gap-1.5 rounded-lg bg-blue-500 px-3 py-2 text-sm font-medium text-white transition hover:bg-blue-600",children:w("market.shared.notLoggedIn.loginCta")})]}):i?e.jsx("div",{className:"flex min-h-[320px] items-center justify-center rounded-2xl border border-gray-200 bg-white p-8 shadow-sm",children:e.jsx(ct,{size:40,delayMs:300})}):o?e.jsxs("div",{className:"flex items-start gap-3 rounded-2xl border border-red-200 bg-red-50 p-4 shadow-sm",children:[e.jsx(te,{size:18,className:"mt-0.5 shrink-0 text-red-700"}),e.jsx("p",{className:"text-sm text-red-700",children:o})]}):t.length===0?e.jsxs("div",{className:"rounded-2xl border border-dashed border-gray-300 bg-white px-4 py-16 text-center shadow-sm",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(yt,{size:18})}),e.jsx("h3",{className:"mt-3 text-sm font-semibold text-gray-900",children:w("market.shared.empty.title")}),e.jsx("p",{className:"mt-2 text-xs leading-5 text-gray-500",children:w("market.shared.empty.description")})]}):e.jsx("div",{className:"space-y-3 rounded-2xl border border-gray-200 bg-white p-4 shadow-sm",children:t.map(c=>e.jsx(zs,{item:c,update:u.get(c.slug),installing:y===c.slug,onInstall:m},c.slug))})}function Ds(){var Ye;const{t}=U(),{setPageHeader:i}=Bt(),o=Ae(),[l,u]=n.useState(!1),[y,m]=n.useState(!1),[w,C]=n.useState({}),[c,S]=n.useState(null),[v,f]=n.useState(null),[L,A]=n.useState(null),[R,I]=n.useState(null),[z,b]=n.useState(null),[D,ae]=n.useState(null),[k,M]=n.useState(()=>Ze()?{kind:"accepting"}:{kind:"idle"}),[ne,he]=n.useState(null),J=n.useRef(null),X=n.useRef(null),r=n.useRef(null),a=P(s=>s.currentWorkspaceSlug),x=n.useRef(a);n.useEffect(()=>()=>{const s=r.current;r.current=null,s==null||s.release()},[]),n.useEffect(()=>{if(x.current===a)return;x.current=a;const s=r.current;r.current=null,s==null||s.release()},[a]);const{initialized:j,registryQuery:p,catalogQuery:G,installedQuery:H,loading:_,mutatingItemName:ie,error:Oe,officialRegistryId:q,allItems:F,activeFilter:E,searchQuery:fe,selectedItemName:le,sharedItems:wt,sharedUpdateSlugs:Ct,sharedLoading:It,sharedError:St,sharedNotLoggedIn:Lt,setActiveFilter:$,setSearchQuery:Rt,setSelectedItem:oe,initialize:Ue,refresh:ce,retry:Et,installItem:Fe,planTemplateInstall:$e,applyTemplateInstall:Ve,uninstallItem:Be,loadShared:de,clearError:ue}=Ht(),At=n.useCallback(s=>{$(s),m(!1)},[$]),zt=n.useCallback(s=>{$(s),m(!1),u(!1)},[$]),He=n.useCallback(()=>{$("all"),m(!1),u(!1)},[$]),qe=n.useCallback(s=>{oe(s),m(!0)},[oe]);n.useEffect(()=>{const s=Ze(),d=s===null?null:JSON.stringify([s,a,T()]);if(!s||X.current===d&&!re.has(d))return;X.current=d;let N=!0;M({kind:"accepting"});const h=Ns(s);h.consumers+=1;let Y=!1;const Je=()=>{Y||(Y=!0,h.consumers-=1,_e(h))},Xe=h.owner.onInvalidate(()=>{N&&M({kind:"idle"})}),Dt=Se(h);return h.promise.then(W=>{var xe;if(!(!N||!h.isCurrent()))if(et(),qt(W.contentId),he(W.contentId),M({kind:"success"}),E==="shared"){const Pt=Se(h);de(h.owner).finally(Pt).catch(()=>{})}else(xe=r.current)==null||xe.release(),r.current={owner:h.owner,isCurrent:h.isCurrent,release:Se(h)},$("shared")}).catch(async W=>{if(!(!N||!h.isCurrent())){if(W instanceof K&&W.status===401){if(M({kind:"loginRequired"}),W.code==="NOT_LOGGED_IN"){h.signOutCheck??(h.signOutCheck=Wt(h.owner,h.isCurrent));const xe=await h.signOutCheck;if(!N||!xe||!h.isCurrent())return;Kt({isCurrent:()=>N&&h.isCurrent(),confirmLoggedOut:Re.getState().confirmLoggedOut,showLogin:()=>M({kind:"loginRequired"})})}return}et(),M({kind:"failure",reason:hs(W)})}}).finally(()=>{Xe(),Dt(),Je()}),()=>{N=!1,Xe(),Je()}},[E,a,de,$]),n.useEffect(()=>{j||Ue().catch(()=>{})},[j,Ue]),n.useEffect(()=>{if(E!=="shared"){const N=r.current;r.current=null,N==null||N.release();return}const s=r.current;if(r.current=null,s&&!s.isCurrent()){s.release();return}const d=de(s==null?void 0:s.owner);s?d.finally(s.release).catch(()=>{}):d.catch(()=>{})},[E,de]);const We=n.useMemo(()=>F.filter(s=>s.isInstalled).length,[F]),be=G.hasData&&H.hasData,Z=(Ye=[G,H,p].find(s=>s.error))==null?void 0:Ye.error,Mt=!be&&!Z&&(!j||_),Ke=(s,d,N)=>s.hasData?t(d,{count:N}):t(s.status==="error"?"market.firstLoad.unavailable":"market.firstLoad.checking"),Ge=be?t("market.subtitle.summary",{total:F.length,installed:We}):t("market.firstLoad.summary",{installed:Ke(H,"market.firstLoad.installedCount",We),total:Ke(G,"market.firstLoad.totalCount",F.length)}),Q=n.useMemo(()=>{const s=fe.trim().toLowerCase();return F.filter(d=>E==="installed"&&!d.isInstalled||E!=="all"&&E!=="installed"&&De(d.type)!==E?!1:s?[d.displayName,d.name,d.description,d.author,d.registryName,...d.tags].filter(N=>!!N).some(N=>N.toLowerCase().includes(s)):!0)},[E,F,fe]),g=n.useMemo(()=>Q.find(s=>s.name===le)??Q[0]??null,[Q,le]),ye=g?w[g.name]:void 0;n.useEffect(()=>{const s=(g==null?void 0:g.name)??null;s!==le&&oe(s)},[g,le,oe]),n.useEffect(()=>{if(!g)return;if(ye!==void 0){f(null);return}let s=!1;const d=g.name;return S(d),f(null),(g.isInstalled?V.getInstalledMarketDetail(d).then(h=>h.body??""):(()=>{const h=g.registryId??q;return h?V.getRemoteMarketDetail(h,d).then(Y=>Y.body??""):Promise.resolve("")})()).then(h=>{s||C(Y=>({...Y,[d]:h}))}).catch(()=>{if(!s){if(!g.isInstalled){C(h=>({...h,[d]:""}));return}f(t("market.errors.detailLoad"))}}).finally(()=>{s||S(h=>h===d?null:h)}),()=>{s=!0}},[g==null?void 0:g.isInstalled,g==null?void 0:g.name,g==null?void 0:g.registryId,ye,q,t]);const ke=n.useCallback(s=>{s&&C(d=>{if(!(s in d))return d;const N={...d};return delete N[s],N})},[]);n.useEffect(()=>{i({title:t("market.title"),subtitle:Ge,actions:e.jsxs("button",{type:"button",onClick:()=>{ue(),ke((g==null?void 0:g.name)??null),ce().catch(()=>{})},className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-3 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[e.jsx(Ee,{size:16,className:_?"animate-spin":""}),t("market.actions.refresh")]})})},[Ge,ue,_,ce,ke,g==null?void 0:g.name,i,t]);const Qe=n.useCallback(s=>{const d=s.registryId??q;d&&Fe(d,s.name).catch(()=>{})},[Fe,q]),ee=n.useCallback(s=>{J.current=null,ae(d=>d===s?null:d)},[]),je=n.useCallback(async(s,d)=>{try{await Ve(d.installId,s.name),I(null)}catch(N){I(null),b(Le(N,t))}finally{ee(s.ref)}},[Ve,ee,t]),me=n.useCallback(async s=>{if(!J.current){J.current=s.ref,ae(s.ref),b(null);try{const d=await $e(s.ref,s.name);if(!Is(d)){await je(s,d);return}I({item:s,plan:d})}catch(d){b(Le(d,t)),ee(s.ref)}}},[je,ee,$e,t]),Ne=n.useCallback(s=>{if(s.slug){const d=Ls(s);d&&me(d);return}Qe(s)},[Qe,me]),_t=n.useCallback(s=>{me({ref:s.slug,name:s.name,displayName:s.displayName||s.name,version:s.version})},[me]),ve=n.useCallback(s=>{const d=Te(s);if(d.allowed){if(d.needsConfirm){A(s);return}Ne(s)}},[Ne]),we=n.useCallback(s=>{window.confirm(t("market.actions.confirmUninstall",{name:s}))&&Be(s).catch(()=>{})},[t,Be]),Ce=Q.filter(s=>s.isInstalled),Ie=Q.filter(s=>!s.isInstalled);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6",children:[k.kind!=="idle"&&e.jsxs("div",{"data-testid":k.kind==="failure"?`market-invite-failure-${k.reason}`:`market-invite-${k.kind}`,role:k.kind==="accepting"?"status":"alert",className:`flex items-start gap-3 rounded-xl border px-4 py-3 text-sm ${k.kind==="success"?"border-green-200 bg-green-50 text-green-800":k.kind==="accepting"?"border-blue-200 bg-blue-50 text-blue-800":k.kind==="loginRequired"?"border-amber-200 bg-amber-50 text-amber-800":"border-red-200 bg-red-50 text-red-800"}`,children:[k.kind==="accepting"&&e.jsx(O,{size:18,className:"mt-0.5 shrink-0 animate-spin","aria-hidden":"true"}),k.kind==="success"&&e.jsx(ze,{size:18,className:"mt-0.5 shrink-0","aria-hidden":"true"}),k.kind==="failure"&&e.jsx(te,{size:18,className:"mt-0.5 shrink-0","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[k.kind==="accepting"&&e.jsx("p",{children:t("market.invite.accepting")}),k.kind==="success"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium",children:t("market.invite.success.title")}),e.jsx("p",{className:"mt-1",children:t("market.invite.success.description")}),ne!==null&&e.jsx("button",{type:"button","data-testid":"market-invite-open-received-apps",onClick:()=>o("/apps?tab=received"),className:"mt-3 rounded-lg bg-green-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-green-700",children:t("market.invite.success.openReceivedApps")})]}),k.kind==="loginRequired"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium",children:t("market.invite.loginRequired.title")}),e.jsx("p",{className:"mt-1",children:t("market.invite.loginRequired.description")}),e.jsx("button",{type:"button",onClick:()=>o("/settings#account"),className:"mt-3 rounded-lg bg-amber-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-amber-600",children:t("market.invite.loginRequired.cta")})]}),k.kind==="failure"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium",children:t(`market.invite.failure.${k.reason}.title`)}),e.jsx("p",{className:"mt-1",children:t(`market.invite.failure.${k.reason}.description`)})]})]})]}),z&&e.jsx("div",{role:"alert",className:"rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800",children:z}),Oe&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-red-700",children:[e.jsx(te,{size:18,className:"mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t("market.errors.bannerTitle")}),e.jsx("p",{className:"mt-1 break-words text-sm",children:Oe})]}),e.jsx("button",{type:"button",onClick:()=>{ue(),ce().catch(()=>{})},className:"shrink-0 rounded-md bg-red-100 px-3 py-1.5 text-xs font-medium text-red-700 transition-colors hover:bg-red-200",children:t("market.actions.retry")})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-gray-200 bg-white p-4 shadow-sm lg:flex-row lg:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tt,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search",value:fe,onChange:s=>{Rt(s.target.value),m(!1)},placeholder:t("market.searchPlaceholder"),className:"w-full rounded-xl border border-gray-300 py-2.5 pl-10 pr-4 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button","aria-expanded":l,"aria-haspopup":"menu","aria-label":t("market.myMarket.title"),onClick:()=>u(s=>!s),className:"inline-flex items-center justify-center gap-2 rounded-xl border border-gray-200 bg-gray-50 px-4 py-2.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100",children:[e.jsx(yt,{size:16}),t("market.myMarket.title"),e.jsx(ot,{size:15,"aria-hidden":"true"})]}),l&&e.jsxs("div",{role:"menu","aria-label":t("market.myMarket.menuLabel"),className:"absolute right-0 top-full z-20 mt-2 min-w-48 overflow-hidden rounded-xl border border-gray-200 bg-white p-1 shadow-lg",children:[["shared","publish"].map(s=>e.jsx("button",{type:"button",role:"menuitem",onClick:()=>zt(s),className:"flex w-full items-center rounded-lg px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-gray-50",children:t(`market.filters.${s}`)},s)),e.jsx("button",{type:"button",role:"menuitem",onClick:()=>{u(!1),o("/apps?tab=manage")},className:"flex w-full items-center rounded-lg px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-gray-50",children:t("market.myMarket.manageApps")})]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",role:"tablist","aria-label":t("market.filters.label"),children:["all","installed","app","skill"].map(s=>e.jsx("button",{type:"button",onClick:()=>At(s),className:`rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${E===s?"border-blue-500 bg-blue-500 text-white":"border-gray-200 bg-white text-gray-600 hover:bg-gray-50"}`,children:t(`market.filters.${s}`)},s))}),E!=="shared"&&E!=="publish"&&Z&&e.jsxs("div",{role:"alert",className:"flex min-h-[260px] flex-col items-center justify-center rounded-2xl border border-gray-200 bg-white px-5 py-8 text-center shadow-sm",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-50 text-red-500",children:e.jsx(te,{size:22,"aria-hidden":"true"})}),e.jsx("h3",{className:"mt-4 text-sm font-semibold text-gray-900",children:t("market.firstLoad.failureTitle")}),e.jsx("p",{className:"mt-2 max-w-md whitespace-pre-line text-sm leading-6 text-gray-500",children:Z.kind==="http"?t("market.firstLoad.httpFailureDescription",{status:Z.status}):t("market.firstLoad.failureDescription")}),e.jsxs("button",{type:"button",onClick:()=>{Et().catch(()=>{})},className:"mt-4 inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600",children:[e.jsx(Ee,{size:16,"aria-hidden":"true"}),t("market.actions.retry")]})]}),_&&be&&E!=="shared"&&E!=="publish"&&e.jsx("p",{role:"status","aria-live":"polite",className:"text-sm text-gray-500",children:t("market.firstLoad.refreshing")}),E==="shared"?e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",onClick:He,className:"inline-flex items-center rounded-lg px-2 py-1.5 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900",children:t("market.myMarket.back")}),e.jsx(Ms,{items:wt,loading:It,error:St,notLoggedIn:Lt,updateSlugs:Ct,installingRef:D,onInstall:_t})]}):E==="publish"?e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",onClick:He,className:"inline-flex items-center rounded-lg px-2 py-1.5 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900",children:t("market.myMarket.back")}),e.jsx(js,{})]}):y&&g?e.jsxs("div",{"data-testid":"market-detail-view",className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:()=>m(!1),className:"inline-flex items-center gap-1.5 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900",children:[e.jsx(Gt,{size:15,"aria-hidden":"true"}),t("market.detail.backToList")]}),e.jsx(As,{skill:g,markdownBody:ye,descriptionLoading:c===g.name,descriptionError:v,busy:ie===g.name||(g.slug?D===g.slug:!1),canInstall:!!(g.registryId??q),onInstall:ve,onUninstall:we,onRefresh:()=>{ue(),ke(g.name),ce().catch(()=>{})}})]}):e.jsx("div",{"data-testid":"market-catalog-grid",className:"space-y-8",children:Mt?e.jsx("div",{className:"flex min-h-[300px] items-center justify-center rounded-2xl border border-gray-200 bg-white px-5 shadow-sm [&_.cx-loader-label]:whitespace-pre-line [&_.cx-loader-label]:leading-6",children:e.jsx(ct,{size:40,delayMs:300,label:t("market.firstLoad.loadingLabel"),slowLabel:t("market.firstLoad.slowLabel")})}):Q.length===0?Z?null:e.jsx("div",{className:"grid min-h-[300px] place-items-center rounded-2xl border border-dashed border-gray-300 bg-white text-center",children:e.jsxs("div",{className:"px-4",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(tt,{size:18})}),e.jsx("h3",{className:"mt-3 text-sm font-semibold text-gray-900",children:t(F.length===0?"market.firstLoad.emptyTitle":"market.empty.filteredTitle")}),e.jsx("p",{className:"mt-2 text-xs leading-5 text-gray-500",children:t(F.length===0?"market.firstLoad.emptyDescription":"market.empty.filteredDescription")})]})}):e.jsxs(e.Fragment,{children:[Ce.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[e.jsx("h2",{className:"text-[15px] font-semibold tracking-tight text-gray-900",children:t("market.list.installedHeading")}),e.jsx("p",{className:"text-[11px] text-gray-400",children:t("market.list.installedDescription",{count:Ce.length})})]}),e.jsx("div",{className:"grid grid-cols-1 gap-3.5 md:grid-cols-2 xl:grid-cols-3",children:Ce.map(s=>e.jsx(it,{skill:s,onSelect:qe,busy:ie===s.name||(s.slug?D===s.slug:!1),canInstall:!!(s.registryId??q),onInstall:ve,onUninstall:we},`${s.registryId??"_"}:${s.name}`))})]}),Ie.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[e.jsx("h2",{className:"text-[15px] font-semibold tracking-tight text-gray-900",children:t("market.list.availableHeading")}),e.jsx("p",{className:"text-[11px] text-gray-400",children:t("market.list.availableDescription",{count:Ie.length})})]}),e.jsx("div",{className:"grid grid-cols-1 gap-3.5 md:grid-cols-2 xl:grid-cols-3",children:Ie.map(s=>e.jsx(it,{skill:s,onSelect:qe,busy:ie===s.name||(s.slug?D===s.slug:!1),canInstall:!!(s.registryId??q),onInstall:ve,onUninstall:we},`${s.registryId??"_"}:${s.name}`))})]})]})})]}),L&&e.jsx(Es,{itemName:L.displayName||L.name,onConfirm:()=>{Ne(L),A(null)},onCancel:()=>A(null)}),R&&e.jsx(Qt,{itemName:R.item.displayName||R.item.name,itemVersion:R.item.version,plan:R.plan,applying:ie===R.item.name,onCancel:()=>{const s=R;I(null),ee(s.item.ref),V.cancelTemplateInstall(s.plan.installId).catch(d=>{b(Le(d,t))})},onConfirm:()=>je(R.item,R.plan)})]})}export{Ds as default,jt as getGitHubSourceUrl,Is as hasNoticeableFacts};