@inkeep/open-knowledge 0.45.0 → 0.45.2

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 (70) hide show
  1. package/dist/{acp-harness-probe-pxi823CF.mjs → acp-harness-probe-Us0IafTi.mjs} +2 -2
  2. package/dist/assets/skills/discovery/SKILL.md +1 -1
  3. package/dist/assets/skills/project/SKILL.md +1 -1
  4. package/dist/assets/skills/write-skill/SKILL.md +1 -1
  5. package/dist/cli.mjs +6 -6
  6. package/dist/constants-Dhlj1fLH.mjs +2 -0
  7. package/dist/index.mjs +1 -1
  8. package/dist/{init-CgNWpE2S.mjs → init-BGnjPIOd.mjs} +3 -3
  9. package/dist/init-D9AKwMxQ.mjs +1 -0
  10. package/dist/{launch-json-removal-OJNI-717.mjs → launch-json-removal-kW2xJOZl.mjs} +2 -2
  11. package/dist/{loader-EGm-qx5P.mjs → loader-CLBwZqWz.mjs} +2 -2
  12. package/dist/loader-CvbPsH4q.mjs +1 -0
  13. package/dist/preview-31FJ4eKI.mjs +1 -0
  14. package/dist/{preview-BPL7w_cV.mjs → preview-BOnPQ_VV.mjs} +2 -2
  15. package/dist/public/assets/{ActivityModeContent-CcG8767K.js → ActivityModeContent-B6-70ang.js} +1 -1
  16. package/dist/public/assets/{AgentDiffPane-D8YoofwF.js → AgentDiffPane-DeWSzAp-.js} +1 -1
  17. package/dist/public/assets/{BugReportHistory-B0qbbAw0.js → BugReportHistory-DrMLEEP8.js} +1 -1
  18. package/dist/public/assets/{BugReportHistoryDialog-Bp4PHyEI.js → BugReportHistoryDialog-Cf_ZrCjH.js} +1 -1
  19. package/dist/public/assets/{CodeMirrorPropInput-B4tL-3Ht.js → CodeMirrorPropInput-CUPvWzYm.js} +1 -1
  20. package/dist/public/assets/{DocumentContext-FCJwmuAo.js → DocumentContext-B-29n_HL.js} +1 -1
  21. package/dist/public/assets/{EditorModeToggle-DcuaOmV8.js → EditorModeToggle-CigjLJ2Z.js} +1 -1
  22. package/dist/public/assets/{EnableSyncConfirmDialog-CTsdvp_5.js → EnableSyncConfirmDialog-DTG7riiK.js} +1 -1
  23. package/dist/public/assets/FeedbackForm-BtkuXFGI.js +1 -0
  24. package/dist/public/assets/{LintConfigEditor-MRWig8E3.js → LintConfigEditor-ylJ89_uD.js} +1 -1
  25. package/dist/public/assets/{ManagedArtifactProperties-DIfvPtzN.js → ManagedArtifactProperties-D3xtiDXY.js} +1 -1
  26. package/dist/public/assets/{MermaidDocEditor-DsEY1FOt.js → MermaidDocEditor-R8D5JpPi.js} +1 -1
  27. package/dist/public/assets/{PropertyPanel-DA4qhX7-.js → PropertyPanel-H098JdnP.js} +1 -1
  28. package/dist/public/assets/{RegisteredAgentIcon-C2dU04N7.js → RegisteredAgentIcon-DplzDEhh.js} +1 -1
  29. package/dist/public/assets/{ReportBugDialogBody-CgzQLCKM.js → ReportBugDialogBody-DZFX9Uby.js} +2 -2
  30. package/dist/public/assets/{SchemaConfigEditor-BdzkNqsH.js → SchemaConfigEditor-BHuEU14f.js} +1 -1
  31. package/dist/public/assets/{SettingsDialogBody-B4PW-A-w.js → SettingsDialogBody-ZYeLdOBh.js} +1 -1
  32. package/dist/public/assets/{ShareReceiveMissDialog-_26zWSVZ.js → ShareReceiveMissDialog-CIsXJHV5.js} +1 -1
  33. package/dist/public/assets/{SkillEditorActions-CBKpfxev.js → SkillEditorActions-DesRWfir.js} +1 -1
  34. package/dist/public/assets/{SourceEditor-BcRIK3Uz.js → SourceEditor-Gg4gFBXn.js} +1 -1
  35. package/dist/public/assets/{TerminalSessionsHost-B0kLulV_.js → TerminalSessionsHost-BVUmqdhT.js} +2 -2
  36. package/dist/public/assets/{TerminalWindowApp-CMdYDyv_.js → TerminalWindowApp-BrV49Q8V.js} +1 -1
  37. package/dist/public/assets/{ThreadView-DQThTEIO.js → ThreadView-DouqkaQt.js} +1 -1
  38. package/dist/public/assets/{TimelineDiffPane-CsNp0WRG.js → TimelineDiffPane-DrdY8iSv.js} +1 -1
  39. package/dist/public/assets/{auth-state-cache-EkXfX8vV.js → auth-state-cache-DOwAr8pE.js} +1 -1
  40. package/dist/public/assets/{client-version-CVjSHBE0.js → client-version-CWjw2o37.js} +1 -1
  41. package/dist/public/assets/{config-provider-CvXAYjor.js → config-provider--LBV5X-F.js} +1 -1
  42. package/dist/public/assets/globals-BtCTpjIr.css +1 -0
  43. package/dist/public/assets/{index-Dw-K4FA8.js → index-D6QuW6BA.js} +7 -7
  44. package/dist/public/assets/{pending-receive-nav-store-Da_9JJXI.js → pending-receive-nav-store-B6dtzPFx.js} +1 -1
  45. package/dist/public/assets/{selection-context-np7NtN5p.js → selection-context-B2HcUOkN.js} +1 -1
  46. package/dist/public/assets/{skill-actions-BgdyM_G0.js → skill-actions-C5Jj4vq_.js} +1 -1
  47. package/dist/public/assets/{src-D452d0cv.js → src-CttimVGm.js} +1 -1
  48. package/dist/public/assets/{telemetry-impl-C8kYleYy.js → telemetry-impl-BFTBY40l.js} +1 -1
  49. package/dist/public/assets/{telemetry-startup-CEgptpjf.js → telemetry-startup-DI3YRseI.js} +1 -1
  50. package/dist/public/assets/{typing-burst-detector-rVKisiec.js → typing-burst-detector-ZNMuwopa.js} +1 -1
  51. package/dist/public/assets/{uninstall-DnE1CJ4K.js → uninstall-940RMTvq.js} +1 -1
  52. package/dist/public/assets/{use-activity-panel-D5Ud5rAK.js → use-activity-panel-BtuJNY3q.js} +1 -1
  53. package/dist/public/assets/{use-terminal-enabled-DLUyAvNx.js → use-terminal-enabled-U4ycZNGm.js} +1 -1
  54. package/dist/public/assets/{use-timeline-entry-diff-g0StQlEH.js → use-timeline-entry-diff-DIrGiWpg.js} +1 -1
  55. package/dist/public/index.html +16 -16
  56. package/dist/public/uninstall.html +3 -3
  57. package/dist/{repair-launch-json-tGZcW42t.mjs → repair-launch-json-CX2m7PDv.mjs} +2 -2
  58. package/dist/{repair-mcp-configs-DZYAXNdR.mjs → repair-mcp-configs-CsXz4Nl2.mjs} +2 -2
  59. package/dist/{src-BfF1eLC-.mjs → src-CeSYiPkq.mjs} +2 -2
  60. package/dist/{start-HwqGYVb8.mjs → start-Cfh9vjj8.mjs} +2 -2
  61. package/dist/start-SfQAws-j.mjs +1 -0
  62. package/package.json +4 -4
  63. package/dist/constants-C5VMTJt2.mjs +0 -2
  64. package/dist/init-BWMly0Jp.mjs +0 -1
  65. package/dist/loader-DQQn8OFp.mjs +0 -1
  66. package/dist/preview-C45NNSLa.mjs +0 -1
  67. package/dist/public/assets/FeedbackForm-DamXgXPd.js +0 -1
  68. package/dist/public/assets/globals-B1VH9dVh.css +0 -1
  69. package/dist/start-DqeJbIko.mjs +0 -1
  70. /package/dist/public/assets/{globals-DLE5hh7Z.js → globals-Dsi-fA9A.js} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./createLucideIcon-DAkhoPjT.js";import{t as s}from"./button-Gol9BgNB.js";import{c,d as l,i as u,n as d,o as f,p,s as m,t as h}from"./EnableSyncConfirmDialog-CTsdvp_5.js";import{t as g}from"./arrow-up-right-obRIg3Sv.js";import{t as _}from"./check-GqWaoTdV.js";import{t as v}from"./folder-open-wLd69QUc.js";import{t as y}from"./info-yKMseklR.js";import{t as b}from"./loader-circle-Cg5SU7AZ.js";import{n as x}from"./miss-dialog-store-Bx4JLuKB.js";import{t as S}from"./refresh-cw-BfeWGCsv.js";import{t as C}from"./triangle-alert-Clgvyc7B.js";import{n as w}from"./dist-BLAMau9Z.js";import{r as T,u as E,v as D}from"./doc-hash-BKfBCyjO.js";import{t as O}from"./external-link-T4Nj1gcG.js";var k=o(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),A=o(`file-question-mark`,[[`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:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),j=o(`file-x-corner`,[[`path`,{d:`M11 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5`,key:`1jo35a`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m15 17 5 5`,key:`36xl1x`}],[`path`,{d:`m20 17-5 5`,key:`vdz27y`}]]),M=a(),N=e(n(),1),P=t(),F=`https://git-scm.com/docs/git-push`;function I(e,t){return e===`empty`?!0:!(e!==`stale`&&e!==`absent`||e===`stale`&&t?.syncEnabled===!0)}function L(e){return e?e.state!==`dormant`&&e.state!==`disabled`&&e.state!==`auth-error`&&e.state!==`conflict`:!1}function R(e){let t=(0,M.c)(52),{freshness:n,status:a,kind:o}=e,{_:c}=i(),{confirmOpen:l,setConfirmOpen:p,onToggleRequest:m,onConfirm:v}=u(f()),[b,x]=(0,N.useState)(`idle`),w=(0,N.useRef)(null),T,E;if(t[0]!==a||t[1]!==b?(T=()=>{if(!(b!==`pending`||!a)){if(a.pushError||a.pushErrorCode){x(`idle`);return}(a.lastSyncUtc??null)!==w.current&&x(`synced`)}},E=[b,a],t[0]=a,t[1]=b,t[2]=T,t[3]=E):(T=t[2],E=t[3]),(0,N.useEffect)(T,E),!I(n,a))return null;if(n===`empty`){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(C,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),t[4]=e):e=t[4];let n;t[5]===c?n=t[6]:(n=c({id:`eazHgv`}),t[5]=c,t[6]=n);let r;return t[7]===n?r=t[8]:(r=(0,P.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[e,(0,P.jsx)(`span`,{children:n})]}),t[7]=n,t[8]=r),r}if(b===`synced`){let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[(0,P.jsx)(_,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{children:(0,P.jsx)(r,{id:`fxbCNQ`})})]}),t[9]=e):e=t[9],e}let D=a?.syncEnabled===!0,O=a?.pushPermission?.checkStatus===`denied`,k=!!(a?.pushError||a?.pushErrorCode),A=O||k,j=n===`absent`&&!D,R;if(n===`absent`&&!D){let e;t[10]!==c||t[11]!==o?(e=c(o===`folder`?{id:`PrJYSN`}:{id:`3BnyYc`}),t[10]=c,t[11]=o,t[12]=e):e=t[12],R=e}else if(n===`stale`){let e;t[13]!==c||t[14]!==o?(e=c(o===`folder`?{id:`Gt4gOO`}:{id:`2IYGkU`}),t[13]=c,t[14]=o,t[15]=e):e=t[15],R=e}else{let e;t[16]!==c||t[17]!==o?(e=c(o===`folder`?{id:`nqV0Kk`}:{id:`gwykHF`}),t[16]=c,t[17]=o,t[18]=e):e=t[18],R=e}let V;t[19]!==c||t[20]!==k||t[21]!==O?(V=O?c({id:`9OIqw4`}):k?c({id:`K6MQQk`}):null,t[19]=c,t[20]=k,t[21]=O,t[22]=V):V=t[22];let H=V,U;t[23]===a?.lastSyncUtc?U=t[24]:(U=()=>{w.current=a?.lastSyncUtc??null,x(`pending`),d(`sync`).catch(e=>{console.warn(`[share-freshness] sync trigger failed`,e instanceof Error?e.message:e),x(`idle`)})},t[23]=a?.lastSyncUtc,t[24]=U);let W=U,G=j?C:y,K;t[25]===G?K=t[26]:(K=(0,P.jsx)(G,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),t[25]=G,t[26]=K);let q;t[27]===R?q=t[28]:(q=(0,P.jsx)(`span`,{children:R}),t[27]=R,t[28]=q);let J;t[29]===H?J=t[30]:(J=H?(0,P.jsx)(`span`,{children:H}):null,t[29]=H,t[30]=J);let Y;t[31]!==A||t[32]!==W||t[33]!==m||t[34]!==a||t[35]!==D||t[36]!==b?(Y=A?null:D?L(a)?(0,P.jsx)(`div`,{children:b===`pending`?(0,P.jsxs)(s,{variant:`outline`,size:`xs`,disabled:!0,children:[(0,P.jsx)(S,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`EHu0x2`})]}):(0,P.jsx)(s,{variant:`outline`,size:`xs`,onClick:W,children:(0,P.jsx)(r,{id:`lb_UU4`})})}):null:(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,P.jsx)(s,{variant:`outline`,size:`xs`,onClick:()=>m(!0),children:(0,P.jsx)(r,{id:`XU0OXn`})}),(0,P.jsxs)(`a`,{href:F,target:`_blank`,rel:`noopener noreferrer`,onClick:B,onAuxClick:z,className:`inline-flex items-center gap-1 transition-colors hover:text-primary`,children:[(0,P.jsx)(r,{id:`GLxIKR`}),(0,P.jsx)(g,{className:`size-3 shrink-0`,"aria-hidden":`true`})]})]}),t[31]=A,t[32]=W,t[33]=m,t[34]=a,t[35]=D,t[36]=b,t[37]=Y):Y=t[37];let X;t[38]!==q||t[39]!==J||t[40]!==Y?(X=(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[q,J,Y]}),t[38]=q,t[39]=J,t[40]=Y,t[41]=X):X=t[41];let Z;t[42]!==K||t[43]!==X?(Z=(0,P.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[K,X]}),t[42]=K,t[43]=X,t[44]=Z):Z=t[44];let Q;t[45]!==l||t[46]!==v||t[47]!==p?(Q=(0,P.jsx)(h,{open:l,onOpenChange:p,onConfirm:v}),t[45]=l,t[46]=v,t[47]=p,t[48]=Q):Q=t[48];let $;return t[49]!==Z||t[50]!==Q?($=(0,P.jsxs)(P.Fragment,{children:[Z,Q]}),t[49]=Z,t[50]=Q,t[51]=$):$=t[51],$}function z(e){return O(e,F)}function B(e){return O(e,F)}function V(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function H(e){let t=(0,M.c)(13),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={phase:`pending`},t[0]=n):n=t[0];let[r,i]=(0,N.useState)(n),[a,o]=(0,N.useState)(0),s=e.branch,c;t[1]!==s||t[2]!==e.kind||t[3]!==e.path?(c=()=>{let t=window.okDesktop??null;if(!t||s===null){i({phase:`resolved`,resolution:{verdict:`unknown`}});return}let n=!1;return t.project.fetchTargetStatus({projectPath:t.config.projectPath,branch:s,path:e.path,kind:e.kind}).then(e=>{n||i({phase:`resolved`,resolution:e??{verdict:`unknown`}})}).catch(e=>{n||(console.warn(`[receive] miss target-status fetch failed`,e instanceof Error?e.message:e),i({phase:`resolved`,resolution:{verdict:`unknown`}}))}),()=>{n=!0}},t[1]=s,t[2]=e.kind,t[3]=e.path,t[4]=c):c=t[4];let l;t[5]!==s||t[6]!==a||t[7]!==e.kind||t[8]!==e.path?(l=[s,e.kind,e.path,a],t[5]=s,t[6]=a,t[7]=e.kind,t[8]=e.path,t[9]=l):l=t[9],(0,N.useEffect)(c,l);let u;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{i({phase:`pending`}),o(U)},t[10]=u):u=t[10];let d;return t[11]===r?d=t[12]:(d={state:r,refetch:u},t[11]=r,t[12]=d),d}function U(e){return e+1}function W(e){let t=(0,M.c)(15),{onEnabled:n}=e,i=f(),a;t[0]===n?a=t[1]:(a={onEnabled:n},t[0]=n,t[1]=a);let{confirmOpen:o,setConfirmOpen:c,onToggleRequest:l,onConfirm:d}=u(i,a),p;t[2]===l?p=t[3]:(p=()=>l(!0),t[2]=l,t[3]=p);let m,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,P.jsx)(S,{className:`size-4`,"aria-hidden":`true`}),g=(0,P.jsx)(r,{id:`XU0OXn`}),t[4]=m,t[5]=g):(m=t[4],g=t[5]);let _;t[6]===p?_=t[7]:(_=(0,P.jsxs)(s,{onClick:p,"data-testid":`share-receive-miss-enable-sync`,children:[m,g]}),t[6]=p,t[7]=_);let v;t[8]!==o||t[9]!==d||t[10]!==c?(v=(0,P.jsx)(h,{open:o,onOpenChange:c,onConfirm:d}),t[8]=o,t[9]=d,t[10]=c,t[11]=v):v=t[11];let y;return t[12]!==_||t[13]!==v?(y=(0,P.jsxs)(P.Fragment,{children:[_,v]}),t[12]=_,t[13]=v,t[14]=y):y=t[14],y}function G(e){let t=(0,M.c)(23),{status:n,onSyncCompleted:a}=e,{_:o}=i(),[c,l]=(0,N.useState)(!1),u=(0,N.useRef)(null),f;t[0]!==a||t[1]!==c||t[2]!==n.lastSyncUtc||t[3]!==n.pushError||t[4]!==n.pushErrorCode?(f=()=>{if(c){if(n.pushError||n.pushErrorCode){l(!1);return}(n.lastSyncUtc??null)!==u.current&&(l(!1),a?.())}},t[0]=a,t[1]=c,t[2]=n.lastSyncUtc,t[3]=n.pushError,t[4]=n.pushErrorCode,t[5]=f):f=t[5];let p;t[6]!==a||t[7]!==c||t[8]!==n?(p=[c,n,a],t[6]=a,t[7]=c,t[8]=n,t[9]=p):p=t[9],(0,N.useEffect)(f,p);let m;t[10]!==o||t[11]!==n.lastSyncUtc?(m=()=>{u.current=n.lastSyncUtc??null,l(!0),d(`sync`).catch(e=>{console.warn(`[receive] miss sync trigger failed`,e instanceof Error?e.message:e),l(!1),w.error(o({id:`1u-mAI`}))})},t[10]=o,t[11]=n.lastSyncUtc,t[12]=m):m=t[12];let h=m,g;t[13]!==h||t[14]!==c?(g=c?(0,P.jsxs)(s,{disabled:!0,"aria-busy":`true`,"data-testid":`share-receive-miss-sync-now`,children:[(0,P.jsx)(S,{className:`size-4 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`EHu0x2`})]}):(0,P.jsxs)(s,{onClick:h,"data-testid":`share-receive-miss-sync-now`,children:[(0,P.jsx)(S,{className:`size-4`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`lb_UU4`})]}),t[13]=h,t[14]=c,t[15]=g):g=t[15];let _;t[16]===c?_=t[17]:(_=c?(0,P.jsx)(r,{id:`dXOolp`}):null,t[16]=c,t[17]=_);let v;t[18]===_?v=t[19]:(v=(0,P.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`share-receive-miss-sync-status`,children:_}),t[18]=_,t[19]=v);let y;return t[20]!==g||t[21]!==v?(y=(0,P.jsxs)(P.Fragment,{children:[g,v]}),t[20]=g,t[21]=v,t[22]=y):y=t[22],y}var K=!1;function q(e){return!K&&e!==null&&e.syncEnabled!==!0}function J(e){return e===null?!1:e.hasRemote&&e.lastPullUtc!==void 0&&e.state!==`conflict`}function Y(e,t){let n=(0,M.c)(15),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(null),[s,c]=(0,N.useState)(!1),l=(0,N.useRef)(null),u,f;n[0]!==t||n[1]!==r||n[2]!==e?(u=()=>{if(!r||(e?.lastPullUtc??null)===l.current)return;i(!1);let n=e?.lastPullOutcome??null;if(n===null){t?.();return}switch(n){case`refused`:case`error`:o(n);return;case`succeeded`:case`up-to-date`:if(q(e)){K=!0,c(!0);return}t?.();return;case`conflict`:t?.();return;default:t?.();return}},f=[r,e,t],n[0]=t,n[1]=r,n[2]=e,n[3]=u,n[4]=f):(u=n[3],f=n[4]),(0,N.useEffect)(u,f);let p;n[5]===t?p=n[6]:(p=()=>{c(!1),t?.()},n[5]=t,n[6]=p);let m;n[7]===e?.lastPullUtc?m=n[8]:(m=()=>{l.current=e?.lastPullUtc??null,o(null),i(!0),d(`pull`).catch(e=>{console.warn(`[receive] miss pull trigger failed`,e instanceof Error?e.message:e),i(!1),o(`error`)})},n[7]=e?.lastPullUtc,n[8]=m);let h;return n[9]!==a||n[10]!==s||n[11]!==r||n[12]!==p||n[13]!==m?(h={pending:r,failure:a,offering:s,resolveOffer:p,start:m},n[9]=a,n[10]=s,n[11]=r,n[12]=p,n[13]=m,n[14]=h):h=n[14],h}function X(e){let t=(0,M.c)(10),{pending:n,onPull:i}=e,a;t[0]!==i||t[1]!==n?(a=n?(0,P.jsxs)(s,{disabled:!0,"aria-busy":`true`,"data-testid":`share-receive-miss-pull-now`,children:[(0,P.jsx)(S,{className:`size-4 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`4uNLmk`})]}):(0,P.jsxs)(s,{onClick:i,"data-testid":`share-receive-miss-pull-now`,children:[(0,P.jsx)(p,{className:`size-4`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`fevEu0`})]}),t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=n?(0,P.jsx)(r,{id:`glG1TR`}):null,t[3]=n,t[4]=o);let c;t[5]===o?c=t[6]:(c=(0,P.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`share-receive-miss-pull-status`,children:o}),t[5]=o,t[6]=c);let l;return t[7]!==a||t[8]!==c?(l=(0,P.jsxs)(P.Fragment,{children:[a,c]}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function Z(e){let t=(0,M.c)(18),{onResolve:n,strandedCommitCount:r}=e,i=c(),a=(0,N.useRef)(!1),o;t[0]===n?o=t[1]:(o=function(){a.current||(a.current=!0,n())},t[0]=n,t[1]=o);let s=o,l;t[2]===s?l=t[3]:(l={onApplied:s},t[2]=s,t[3]=l);let{confirmOpen:u,setConfirmOpen:d,onModeSelect:f,onConfirm:p}=m(i,`off`,l),g=(0,N.useRef)(!1),_,v;t[4]===f?(_=t[5],v=t[6]):(_=()=>{g.current||(g.current=!0,f(`follow`))},v=[f],t[4]=f,t[5]=_,t[6]=v),(0,N.useEffect)(_,v);let y;t[7]!==s||t[8]!==d?(y=e=>{d(e),e||s()},t[7]=s,t[8]=d,t[9]=y):y=t[9];let b;t[10]!==p||t[11]!==s?(b=()=>{p(),s()},t[10]=p,t[11]=s,t[12]=b):b=t[12];let x;return t[13]!==u||t[14]!==r||t[15]!==y||t[16]!==b?(x=(0,P.jsx)(h,{open:u,onOpenChange:y,onConfirm:b,variant:`follow`,strandedCommitCount:r}),t[13]=u,t[14]=r,t[15]=y,t[16]=b,t[17]=x):x=t[17],x}function Q(e){let t=(0,M.c)(89),{nav:n,state:a,onBrowseFolder:o,onOpenRenamed:c,onEnableAutoSync:u,onSyncCompleted:d,onPullApplied:f}=e,{_:m}=i(),h=l(),g=Y(h,f),_=n.branch,y;t[0]!==m||t[1]!==n.kind?(y=n.kind===`folder`?m({id:`ugoTXs`}):m({id:`XH30C4`}),t[0]=m,t[1]=n.kind,t[2]=y):y=t[2];let S=y;if(a.phase===`pending`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(b,{className:`size-5 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`c8jBgX`})]}),t[3]=e):e=t[3],e}let{resolution:C}=a,w,T;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,P.jsx)(v,{className:`size-4`,"aria-hidden":`true`}),T=(0,P.jsx)(r,{id:`hItdtk`}),t[4]=w,t[5]=T):(w=t[4],T=t[5]);let E;t[6]===o?E=t[7]:(E=(0,P.jsxs)(s,{variant:`outline`,onClick:o,"data-testid":`share-receive-miss-browse`,children:[w,T]}),t[6]=o,t[7]=E);let D=E,O,N,F,I=null;if(C.verdict===`renamed`){let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(x,{className:`size-9`,"aria-hidden":`true`}),t[8]=e):e=t[8],O=e;let n;t[9]!==C.renamedTo||t[10]!==S?(n={0:C.renamedTo,targetNoun:S},t[9]=C.renamedTo,t[10]=S,t[11]=n):n=t[11];let i;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})},t[12]=i):i=t[12];let a;t[13]===n?a=t[14]:(a=(0,P.jsx)(r,{id:`P0HC30`,values:n,components:i}),t[13]=n,t[14]=a),N=a;let o;t[15]!==c||t[16]!==C.renamedTo?(o=()=>c(C.renamedTo),t[15]=c,t[16]=C.renamedTo,t[17]=o):o=t[17];let l,u;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,P.jsx)(x,{className:`size-4`,"aria-hidden":`true`}),u=(0,P.jsx)(r,{id:`AItsE5`}),t[18]=l,t[19]=u):(l=t[18],u=t[19]);let d;t[20]===o?d=t[21]:(d=(0,P.jsxs)(s,{onClick:o,"data-testid":`share-receive-miss-open-renamed`,children:[l,u]}),t[20]=o,t[21]=d);let f;t[22]!==D||t[23]!==d?(f=(0,P.jsxs)(P.Fragment,{children:[d,D]}),t[22]=D,t[23]=d,t[24]=f):f=t[24],F=f}else if(C.verdict===`deleted`){let e;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(j,{className:`size-9`,"aria-hidden":`true`}),t[25]=e):e=t[25],O=e;let n;t[26]!==_||t[27]!==S?(n={targetNoun:S,branch:_},t[26]=_,t[27]=S,t[28]=n):n=t[28];let i;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})},t[29]=i):i=t[29];let a;t[30]===n?a=t[31]:(a=(0,P.jsx)(r,{id:`kpqWwG`,values:n,components:i}),t[30]=n,t[31]=a),N=a,F=D}else if(C.verdict===`never-on-branch`){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(A,{className:`size-9`,"aria-hidden":`true`}),t[32]=e):e=t[32],O=e;let n;t[33]!==_||t[34]!==S?(n={targetNoun:S,branch:_},t[33]=_,t[34]=S,t[35]=n):n=t[35];let i;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})},t[36]=i):i=t[36];let a;t[37]===n?a=t[38]:(a=(0,P.jsx)(r,{id:`i9TPUi`,values:n,components:i}),t[37]=n,t[38]=a),N=a,F=D}else if(C.verdict===`changed-locally`){let e;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(k,{className:`size-9`,"aria-hidden":`true`}),t[39]=e):e=t[39],O=e;let n=h?.syncEnabled===!0,i=h?.pushPermission?.checkStatus===`denied`||!!(h?.pushError||h?.pushErrorCode);if(n){let e;t[40]!==_||t[41]!==S?(e=_===null?(0,P.jsx)(r,{id:`RyIKxy`,values:{targetNoun:S}}):(0,P.jsx)(r,{id:`l6kpzR`,values:{targetNoun:S,branch:_},components:{0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[40]=_,t[41]=S,t[42]=e):e=t[42],N=e}else{let e;t[43]!==_||t[44]!==S?(e=_===null?(0,P.jsx)(r,{id:`UuYo7g`,values:{targetNoun:S}}):(0,P.jsx)(r,{id:`HoWElC`,values:{targetNoun:S,branch:_},components:{0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[43]=_,t[44]=S,t[45]=e):e=t[45],N=e}let a=null;if(h?.syncEnabled){if(L(h)&&!i){let e;t[46]!==d||t[47]!==h?(e=(0,P.jsx)(G,{status:h,onSyncCompleted:d}),t[46]=d,t[47]=h,t[48]=e):e=t[48],a=e}}else if(h!==null){let e;t[49]===u?e=t[50]:(e=(0,P.jsx)(W,{onEnabled:u}),t[49]=u,t[50]=e),a=e}let o;t[51]!==D||t[52]!==a?(o=(0,P.jsxs)(P.Fragment,{children:[a,D]}),t[51]=D,t[52]=a,t[53]=o):o=t[53],F=o}else{let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(p,{className:`size-9`,"aria-hidden":`true`}),t[54]=e):e=t[54],O=e;let n;t[55]===h?n=t[56]:(n=J(h),t[55]=h,t[56]=n);let i=n;if(i){let e;t[57]===_?e=t[58]:(e=_===null?(0,P.jsx)(r,{id:`gwEcOD`}):(0,P.jsx)(r,{id:`wvK7Ay`,values:{branch:_},components:{0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[57]=_,t[58]=e),N=e}else{let e;t[59]===_?e=t[60]:(e=_===null?(0,P.jsx)(r,{id:`Xewl6B`}):(0,P.jsx)(r,{id:`d1JjXo`,values:{branch:_},components:{0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[59]=_,t[60]=e),N=e}let a=g.failure===null?`sr-only`:`max-w-md text-balance text-1sm text-destructive`,o;t[61]===g.failure?o=t[62]:(o=g.failure===`refused`?(0,P.jsx)(r,{id:`Xp7Kq4`}):g.failure===`error`?(0,P.jsx)(r,{id:`JG_8KT`}):null,t[61]=g.failure,t[62]=o);let s;t[63]!==a||t[64]!==o?(s=(0,P.jsx)(`p`,{role:`alert`,className:a,"data-testid":`share-receive-miss-pull-error`,children:o}),t[63]=a,t[64]=o,t[65]=s):s=t[65],I=s;let c;t[66]!==i||t[67]!==g.pending||t[68]!==g.start?(c=i?(0,P.jsx)(X,{pending:g.pending,onPull:g.start}):null,t[66]=i,t[67]=g.pending,t[68]=g.start,t[69]=c):c=t[69];let l;t[70]!==g.offering||t[71]!==g.resolveOffer||t[72]!==h?.ahead?(l=g.offering?(0,P.jsx)(Z,{onResolve:g.resolveOffer,strandedCommitCount:h?.ahead??0}):null,t[70]=g.offering,t[71]=g.resolveOffer,t[72]=h?.ahead,t[73]=l):l=t[73];let u;t[74]!==D||t[75]!==c||t[76]!==l?(u=(0,P.jsxs)(P.Fragment,{children:[c,D,l]}),t[74]=D,t[75]=c,t[76]=l,t[77]=u):u=t[77],F=u}let R;t[78]===O?R=t[79]:(R=(0,P.jsx)(`div`,{className:`flex size-16 items-center justify-center rounded-full border bg-muted/40 text-muted-foreground`,children:O}),t[78]=O,t[79]=R);let z;t[80]===N?z=t[81]:(z=(0,P.jsx)(`p`,{className:`max-w-md text-balance text-base leading-6 text-foreground/90`,children:N}),t[80]=N,t[81]=z);let B;t[82]===F?B=t[83]:(B=(0,P.jsx)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:justify-center`,children:F}),t[82]=F,t[83]=B);let V;return t[84]!==I||t[85]!==R||t[86]!==z||t[87]!==B?(V=(0,P.jsxs)(P.Fragment,{children:[R,z,I,B]}),t[84]=I,t[85]=R,t[86]=z,t[87]=B,t[88]=V):V=t[88],V}function $(e){return e.replace(/^\/+|\/+$/g,``)}function ee(e,t){if(t.kind===`folder`){if(E(e))return $(t.path)===``;let n=T(e);return n!==null&&$(n)===$(t.path)}let n=T(e);return n===null?!1:D(n)===D(t.path)}function te(){let e=null,t=new Set,n=!1;function r(){for(let e of t)e()}function i(t){e!==t&&(e=t,r())}function a(){e!==null&&(ee(window.location.hash,e)||i(null))}function o(){n||typeof window>`u`||(n=!0,window.addEventListener(`hashchange`,a))}return{arm(e){o(),i(e)},clear(){i(null)},getSnapshot(){return e},subscribe(e){return t.add(e),()=>{t.delete(e)}},dispose(){n&&typeof window<`u`&&(window.removeEventListener(`hashchange`,a),n=!1),i(null)}}}var ne=te();function re(e,t){return e===null||e.kind!==`missing`||t===null||D(t.path)!==e.target?null:t}export{H as a,V as i,ne as n,R as o,Q as r,I as s,re as t};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./createLucideIcon-DAkhoPjT.js";import{t as s}from"./button-Gol9BgNB.js";import{c,d as l,i as u,n as d,o as f,p,s as m,t as h}from"./EnableSyncConfirmDialog-DTG7riiK.js";import{t as g}from"./arrow-up-right-obRIg3Sv.js";import{t as _}from"./check-GqWaoTdV.js";import{t as v}from"./folder-open-wLd69QUc.js";import{t as y}from"./info-yKMseklR.js";import{t as b}from"./loader-circle-Cg5SU7AZ.js";import{n as x}from"./miss-dialog-store-Bx4JLuKB.js";import{t as S}from"./refresh-cw-BfeWGCsv.js";import{t as C}from"./triangle-alert-Clgvyc7B.js";import{n as w}from"./dist-BLAMau9Z.js";import{r as T,u as E,v as D}from"./doc-hash-BKfBCyjO.js";import{t as O}from"./external-link-T4Nj1gcG.js";var k=o(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),A=o(`file-question-mark`,[[`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:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),j=o(`file-x-corner`,[[`path`,{d:`M11 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5`,key:`1jo35a`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m15 17 5 5`,key:`36xl1x`}],[`path`,{d:`m20 17-5 5`,key:`vdz27y`}]]),M=a(),N=e(n(),1),P=t(),F=`https://git-scm.com/docs/git-push`;function I(e,t){return e===`empty`?!0:!(e!==`stale`&&e!==`absent`||e===`stale`&&t?.syncEnabled===!0)}function L(e){return e?e.state!==`dormant`&&e.state!==`disabled`&&e.state!==`auth-error`&&e.state!==`conflict`:!1}function R(e){let t=(0,M.c)(52),{freshness:n,status:a,kind:o}=e,{_:c}=i(),{confirmOpen:l,setConfirmOpen:p,onToggleRequest:m,onConfirm:v}=u(f()),[b,x]=(0,N.useState)(`idle`),w=(0,N.useRef)(null),T,E;if(t[0]!==a||t[1]!==b?(T=()=>{if(!(b!==`pending`||!a)){if(a.pushError||a.pushErrorCode){x(`idle`);return}(a.lastSyncUtc??null)!==w.current&&x(`synced`)}},E=[b,a],t[0]=a,t[1]=b,t[2]=T,t[3]=E):(T=t[2],E=t[3]),(0,N.useEffect)(T,E),!I(n,a))return null;if(n===`empty`){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(C,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),t[4]=e):e=t[4];let n;t[5]===c?n=t[6]:(n=c({id:`eazHgv`}),t[5]=c,t[6]=n);let r;return t[7]===n?r=t[8]:(r=(0,P.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[e,(0,P.jsx)(`span`,{children:n})]}),t[7]=n,t[8]=r),r}if(b===`synced`){let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[(0,P.jsx)(_,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{children:(0,P.jsx)(r,{id:`fxbCNQ`})})]}),t[9]=e):e=t[9],e}let D=a?.syncEnabled===!0,O=a?.pushPermission?.checkStatus===`denied`,k=!!(a?.pushError||a?.pushErrorCode),A=O||k,j=n===`absent`&&!D,R;if(n===`absent`&&!D){let e;t[10]!==c||t[11]!==o?(e=c(o===`folder`?{id:`PrJYSN`}:{id:`3BnyYc`}),t[10]=c,t[11]=o,t[12]=e):e=t[12],R=e}else if(n===`stale`){let e;t[13]!==c||t[14]!==o?(e=c(o===`folder`?{id:`Gt4gOO`}:{id:`2IYGkU`}),t[13]=c,t[14]=o,t[15]=e):e=t[15],R=e}else{let e;t[16]!==c||t[17]!==o?(e=c(o===`folder`?{id:`nqV0Kk`}:{id:`gwykHF`}),t[16]=c,t[17]=o,t[18]=e):e=t[18],R=e}let V;t[19]!==c||t[20]!==k||t[21]!==O?(V=O?c({id:`9OIqw4`}):k?c({id:`K6MQQk`}):null,t[19]=c,t[20]=k,t[21]=O,t[22]=V):V=t[22];let H=V,U;t[23]===a?.lastSyncUtc?U=t[24]:(U=()=>{w.current=a?.lastSyncUtc??null,x(`pending`),d(`sync`).catch(e=>{console.warn(`[share-freshness] sync trigger failed`,e instanceof Error?e.message:e),x(`idle`)})},t[23]=a?.lastSyncUtc,t[24]=U);let W=U,G=j?C:y,K;t[25]===G?K=t[26]:(K=(0,P.jsx)(G,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),t[25]=G,t[26]=K);let q;t[27]===R?q=t[28]:(q=(0,P.jsx)(`span`,{children:R}),t[27]=R,t[28]=q);let J;t[29]===H?J=t[30]:(J=H?(0,P.jsx)(`span`,{children:H}):null,t[29]=H,t[30]=J);let Y;t[31]!==A||t[32]!==W||t[33]!==m||t[34]!==a||t[35]!==D||t[36]!==b?(Y=A?null:D?L(a)?(0,P.jsx)(`div`,{children:b===`pending`?(0,P.jsxs)(s,{variant:`outline`,size:`xs`,disabled:!0,children:[(0,P.jsx)(S,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`EHu0x2`})]}):(0,P.jsx)(s,{variant:`outline`,size:`xs`,onClick:W,children:(0,P.jsx)(r,{id:`lb_UU4`})})}):null:(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,P.jsx)(s,{variant:`outline`,size:`xs`,onClick:()=>m(!0),children:(0,P.jsx)(r,{id:`XU0OXn`})}),(0,P.jsxs)(`a`,{href:F,target:`_blank`,rel:`noopener noreferrer`,onClick:B,onAuxClick:z,className:`inline-flex items-center gap-1 transition-colors hover:text-primary`,children:[(0,P.jsx)(r,{id:`GLxIKR`}),(0,P.jsx)(g,{className:`size-3 shrink-0`,"aria-hidden":`true`})]})]}),t[31]=A,t[32]=W,t[33]=m,t[34]=a,t[35]=D,t[36]=b,t[37]=Y):Y=t[37];let X;t[38]!==q||t[39]!==J||t[40]!==Y?(X=(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[q,J,Y]}),t[38]=q,t[39]=J,t[40]=Y,t[41]=X):X=t[41];let Z;t[42]!==K||t[43]!==X?(Z=(0,P.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[K,X]}),t[42]=K,t[43]=X,t[44]=Z):Z=t[44];let Q;t[45]!==l||t[46]!==v||t[47]!==p?(Q=(0,P.jsx)(h,{open:l,onOpenChange:p,onConfirm:v}),t[45]=l,t[46]=v,t[47]=p,t[48]=Q):Q=t[48];let $;return t[49]!==Z||t[50]!==Q?($=(0,P.jsxs)(P.Fragment,{children:[Z,Q]}),t[49]=Z,t[50]=Q,t[51]=$):$=t[51],$}function z(e){return O(e,F)}function B(e){return O(e,F)}function V(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function H(e){let t=(0,M.c)(13),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={phase:`pending`},t[0]=n):n=t[0];let[r,i]=(0,N.useState)(n),[a,o]=(0,N.useState)(0),s=e.branch,c;t[1]!==s||t[2]!==e.kind||t[3]!==e.path?(c=()=>{let t=window.okDesktop??null;if(!t||s===null){i({phase:`resolved`,resolution:{verdict:`unknown`}});return}let n=!1;return t.project.fetchTargetStatus({projectPath:t.config.projectPath,branch:s,path:e.path,kind:e.kind}).then(e=>{n||i({phase:`resolved`,resolution:e??{verdict:`unknown`}})}).catch(e=>{n||(console.warn(`[receive] miss target-status fetch failed`,e instanceof Error?e.message:e),i({phase:`resolved`,resolution:{verdict:`unknown`}}))}),()=>{n=!0}},t[1]=s,t[2]=e.kind,t[3]=e.path,t[4]=c):c=t[4];let l;t[5]!==s||t[6]!==a||t[7]!==e.kind||t[8]!==e.path?(l=[s,e.kind,e.path,a],t[5]=s,t[6]=a,t[7]=e.kind,t[8]=e.path,t[9]=l):l=t[9],(0,N.useEffect)(c,l);let u;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{i({phase:`pending`}),o(U)},t[10]=u):u=t[10];let d;return t[11]===r?d=t[12]:(d={state:r,refetch:u},t[11]=r,t[12]=d),d}function U(e){return e+1}function W(e){let t=(0,M.c)(15),{onEnabled:n}=e,i=f(),a;t[0]===n?a=t[1]:(a={onEnabled:n},t[0]=n,t[1]=a);let{confirmOpen:o,setConfirmOpen:c,onToggleRequest:l,onConfirm:d}=u(i,a),p;t[2]===l?p=t[3]:(p=()=>l(!0),t[2]=l,t[3]=p);let m,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,P.jsx)(S,{className:`size-4`,"aria-hidden":`true`}),g=(0,P.jsx)(r,{id:`XU0OXn`}),t[4]=m,t[5]=g):(m=t[4],g=t[5]);let _;t[6]===p?_=t[7]:(_=(0,P.jsxs)(s,{onClick:p,"data-testid":`share-receive-miss-enable-sync`,children:[m,g]}),t[6]=p,t[7]=_);let v;t[8]!==o||t[9]!==d||t[10]!==c?(v=(0,P.jsx)(h,{open:o,onOpenChange:c,onConfirm:d}),t[8]=o,t[9]=d,t[10]=c,t[11]=v):v=t[11];let y;return t[12]!==_||t[13]!==v?(y=(0,P.jsxs)(P.Fragment,{children:[_,v]}),t[12]=_,t[13]=v,t[14]=y):y=t[14],y}function G(e){let t=(0,M.c)(23),{status:n,onSyncCompleted:a}=e,{_:o}=i(),[c,l]=(0,N.useState)(!1),u=(0,N.useRef)(null),f;t[0]!==a||t[1]!==c||t[2]!==n.lastSyncUtc||t[3]!==n.pushError||t[4]!==n.pushErrorCode?(f=()=>{if(c){if(n.pushError||n.pushErrorCode){l(!1);return}(n.lastSyncUtc??null)!==u.current&&(l(!1),a?.())}},t[0]=a,t[1]=c,t[2]=n.lastSyncUtc,t[3]=n.pushError,t[4]=n.pushErrorCode,t[5]=f):f=t[5];let p;t[6]!==a||t[7]!==c||t[8]!==n?(p=[c,n,a],t[6]=a,t[7]=c,t[8]=n,t[9]=p):p=t[9],(0,N.useEffect)(f,p);let m;t[10]!==o||t[11]!==n.lastSyncUtc?(m=()=>{u.current=n.lastSyncUtc??null,l(!0),d(`sync`).catch(e=>{console.warn(`[receive] miss sync trigger failed`,e instanceof Error?e.message:e),l(!1),w.error(o({id:`1u-mAI`}))})},t[10]=o,t[11]=n.lastSyncUtc,t[12]=m):m=t[12];let h=m,g;t[13]!==h||t[14]!==c?(g=c?(0,P.jsxs)(s,{disabled:!0,"aria-busy":`true`,"data-testid":`share-receive-miss-sync-now`,children:[(0,P.jsx)(S,{className:`size-4 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`EHu0x2`})]}):(0,P.jsxs)(s,{onClick:h,"data-testid":`share-receive-miss-sync-now`,children:[(0,P.jsx)(S,{className:`size-4`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`lb_UU4`})]}),t[13]=h,t[14]=c,t[15]=g):g=t[15];let _;t[16]===c?_=t[17]:(_=c?(0,P.jsx)(r,{id:`dXOolp`}):null,t[16]=c,t[17]=_);let v;t[18]===_?v=t[19]:(v=(0,P.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`share-receive-miss-sync-status`,children:_}),t[18]=_,t[19]=v);let y;return t[20]!==g||t[21]!==v?(y=(0,P.jsxs)(P.Fragment,{children:[g,v]}),t[20]=g,t[21]=v,t[22]=y):y=t[22],y}var K=!1;function q(e){return!K&&e!==null&&e.syncEnabled!==!0}function J(e){return e===null?!1:e.hasRemote&&e.lastPullUtc!==void 0&&e.state!==`conflict`}function Y(e,t){let n=(0,M.c)(15),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(null),[s,c]=(0,N.useState)(!1),l=(0,N.useRef)(null),u,f;n[0]!==t||n[1]!==r||n[2]!==e?(u=()=>{if(!r||(e?.lastPullUtc??null)===l.current)return;i(!1);let n=e?.lastPullOutcome??null;if(n===null){t?.();return}switch(n){case`refused`:case`error`:o(n);return;case`succeeded`:case`up-to-date`:if(q(e)){K=!0,c(!0);return}t?.();return;case`conflict`:t?.();return;default:t?.();return}},f=[r,e,t],n[0]=t,n[1]=r,n[2]=e,n[3]=u,n[4]=f):(u=n[3],f=n[4]),(0,N.useEffect)(u,f);let p;n[5]===t?p=n[6]:(p=()=>{c(!1),t?.()},n[5]=t,n[6]=p);let m;n[7]===e?.lastPullUtc?m=n[8]:(m=()=>{l.current=e?.lastPullUtc??null,o(null),i(!0),d(`pull`).catch(e=>{console.warn(`[receive] miss pull trigger failed`,e instanceof Error?e.message:e),i(!1),o(`error`)})},n[7]=e?.lastPullUtc,n[8]=m);let h;return n[9]!==a||n[10]!==s||n[11]!==r||n[12]!==p||n[13]!==m?(h={pending:r,failure:a,offering:s,resolveOffer:p,start:m},n[9]=a,n[10]=s,n[11]=r,n[12]=p,n[13]=m,n[14]=h):h=n[14],h}function X(e){let t=(0,M.c)(10),{pending:n,onPull:i}=e,a;t[0]!==i||t[1]!==n?(a=n?(0,P.jsxs)(s,{disabled:!0,"aria-busy":`true`,"data-testid":`share-receive-miss-pull-now`,children:[(0,P.jsx)(S,{className:`size-4 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`4uNLmk`})]}):(0,P.jsxs)(s,{onClick:i,"data-testid":`share-receive-miss-pull-now`,children:[(0,P.jsx)(p,{className:`size-4`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`fevEu0`})]}),t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=n?(0,P.jsx)(r,{id:`glG1TR`}):null,t[3]=n,t[4]=o);let c;t[5]===o?c=t[6]:(c=(0,P.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`share-receive-miss-pull-status`,children:o}),t[5]=o,t[6]=c);let l;return t[7]!==a||t[8]!==c?(l=(0,P.jsxs)(P.Fragment,{children:[a,c]}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function Z(e){let t=(0,M.c)(18),{onResolve:n,strandedCommitCount:r}=e,i=c(),a=(0,N.useRef)(!1),o;t[0]===n?o=t[1]:(o=function(){a.current||(a.current=!0,n())},t[0]=n,t[1]=o);let s=o,l;t[2]===s?l=t[3]:(l={onApplied:s},t[2]=s,t[3]=l);let{confirmOpen:u,setConfirmOpen:d,onModeSelect:f,onConfirm:p}=m(i,`off`,l),g=(0,N.useRef)(!1),_,v;t[4]===f?(_=t[5],v=t[6]):(_=()=>{g.current||(g.current=!0,f(`follow`))},v=[f],t[4]=f,t[5]=_,t[6]=v),(0,N.useEffect)(_,v);let y;t[7]!==s||t[8]!==d?(y=e=>{d(e),e||s()},t[7]=s,t[8]=d,t[9]=y):y=t[9];let b;t[10]!==p||t[11]!==s?(b=()=>{p(),s()},t[10]=p,t[11]=s,t[12]=b):b=t[12];let x;return t[13]!==u||t[14]!==r||t[15]!==y||t[16]!==b?(x=(0,P.jsx)(h,{open:u,onOpenChange:y,onConfirm:b,variant:`follow`,strandedCommitCount:r}),t[13]=u,t[14]=r,t[15]=y,t[16]=b,t[17]=x):x=t[17],x}function Q(e){let t=(0,M.c)(89),{nav:n,state:a,onBrowseFolder:o,onOpenRenamed:c,onEnableAutoSync:u,onSyncCompleted:d,onPullApplied:f}=e,{_:m}=i(),h=l(),g=Y(h,f),_=n.branch,y;t[0]!==m||t[1]!==n.kind?(y=n.kind===`folder`?m({id:`ugoTXs`}):m({id:`XH30C4`}),t[0]=m,t[1]=n.kind,t[2]=y):y=t[2];let S=y;if(a.phase===`pending`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(b,{className:`size-5 animate-spin`,"aria-hidden":`true`}),(0,P.jsx)(r,{id:`c8jBgX`})]}),t[3]=e):e=t[3],e}let{resolution:C}=a,w,T;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,P.jsx)(v,{className:`size-4`,"aria-hidden":`true`}),T=(0,P.jsx)(r,{id:`hItdtk`}),t[4]=w,t[5]=T):(w=t[4],T=t[5]);let E;t[6]===o?E=t[7]:(E=(0,P.jsxs)(s,{variant:`outline`,onClick:o,"data-testid":`share-receive-miss-browse`,children:[w,T]}),t[6]=o,t[7]=E);let D=E,O,N,F,I=null;if(C.verdict===`renamed`){let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(x,{className:`size-9`,"aria-hidden":`true`}),t[8]=e):e=t[8],O=e;let n;t[9]!==C.renamedTo||t[10]!==S?(n={0:C.renamedTo,targetNoun:S},t[9]=C.renamedTo,t[10]=S,t[11]=n):n=t[11];let i;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})},t[12]=i):i=t[12];let a;t[13]===n?a=t[14]:(a=(0,P.jsx)(r,{id:`P0HC30`,values:n,components:i}),t[13]=n,t[14]=a),N=a;let o;t[15]!==c||t[16]!==C.renamedTo?(o=()=>c(C.renamedTo),t[15]=c,t[16]=C.renamedTo,t[17]=o):o=t[17];let l,u;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,P.jsx)(x,{className:`size-4`,"aria-hidden":`true`}),u=(0,P.jsx)(r,{id:`AItsE5`}),t[18]=l,t[19]=u):(l=t[18],u=t[19]);let d;t[20]===o?d=t[21]:(d=(0,P.jsxs)(s,{onClick:o,"data-testid":`share-receive-miss-open-renamed`,children:[l,u]}),t[20]=o,t[21]=d);let f;t[22]!==D||t[23]!==d?(f=(0,P.jsxs)(P.Fragment,{children:[d,D]}),t[22]=D,t[23]=d,t[24]=f):f=t[24],F=f}else if(C.verdict===`deleted`){let e;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(j,{className:`size-9`,"aria-hidden":`true`}),t[25]=e):e=t[25],O=e;let n;t[26]!==_||t[27]!==S?(n={targetNoun:S,branch:_},t[26]=_,t[27]=S,t[28]=n):n=t[28];let i;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})},t[29]=i):i=t[29];let a;t[30]===n?a=t[31]:(a=(0,P.jsx)(r,{id:`kpqWwG`,values:n,components:i}),t[30]=n,t[31]=a),N=a,F=D}else if(C.verdict===`never-on-branch`){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(A,{className:`size-9`,"aria-hidden":`true`}),t[32]=e):e=t[32],O=e;let n;t[33]!==_||t[34]!==S?(n={targetNoun:S,branch:_},t[33]=_,t[34]=S,t[35]=n):n=t[35];let i;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})},t[36]=i):i=t[36];let a;t[37]===n?a=t[38]:(a=(0,P.jsx)(r,{id:`i9TPUi`,values:n,components:i}),t[37]=n,t[38]=a),N=a,F=D}else if(C.verdict===`changed-locally`){let e;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(k,{className:`size-9`,"aria-hidden":`true`}),t[39]=e):e=t[39],O=e;let n=h?.syncEnabled===!0,i=h?.pushPermission?.checkStatus===`denied`||!!(h?.pushError||h?.pushErrorCode);if(n){let e;t[40]!==_||t[41]!==S?(e=_===null?(0,P.jsx)(r,{id:`RyIKxy`,values:{targetNoun:S}}):(0,P.jsx)(r,{id:`l6kpzR`,values:{targetNoun:S,branch:_},components:{0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[40]=_,t[41]=S,t[42]=e):e=t[42],N=e}else{let e;t[43]!==_||t[44]!==S?(e=_===null?(0,P.jsx)(r,{id:`UuYo7g`,values:{targetNoun:S}}):(0,P.jsx)(r,{id:`HoWElC`,values:{targetNoun:S,branch:_},components:{0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[43]=_,t[44]=S,t[45]=e):e=t[45],N=e}let a=null;if(h?.syncEnabled){if(L(h)&&!i){let e;t[46]!==d||t[47]!==h?(e=(0,P.jsx)(G,{status:h,onSyncCompleted:d}),t[46]=d,t[47]=h,t[48]=e):e=t[48],a=e}}else if(h!==null){let e;t[49]===u?e=t[50]:(e=(0,P.jsx)(W,{onEnabled:u}),t[49]=u,t[50]=e),a=e}let o;t[51]!==D||t[52]!==a?(o=(0,P.jsxs)(P.Fragment,{children:[a,D]}),t[51]=D,t[52]=a,t[53]=o):o=t[53],F=o}else{let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(p,{className:`size-9`,"aria-hidden":`true`}),t[54]=e):e=t[54],O=e;let n;t[55]===h?n=t[56]:(n=J(h),t[55]=h,t[56]=n);let i=n;if(i){let e;t[57]===_?e=t[58]:(e=_===null?(0,P.jsx)(r,{id:`gwEcOD`}):(0,P.jsx)(r,{id:`wvK7Ay`,values:{branch:_},components:{0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[57]=_,t[58]=e),N=e}else{let e;t[59]===_?e=t[60]:(e=_===null?(0,P.jsx)(r,{id:`Xewl6B`}):(0,P.jsx)(r,{id:`d1JjXo`,values:{branch:_},components:{0:(0,P.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[59]=_,t[60]=e),N=e}let a=g.failure===null?`sr-only`:`max-w-md text-balance text-1sm text-destructive`,o;t[61]===g.failure?o=t[62]:(o=g.failure===`refused`?(0,P.jsx)(r,{id:`Xp7Kq4`}):g.failure===`error`?(0,P.jsx)(r,{id:`JG_8KT`}):null,t[61]=g.failure,t[62]=o);let s;t[63]!==a||t[64]!==o?(s=(0,P.jsx)(`p`,{role:`alert`,className:a,"data-testid":`share-receive-miss-pull-error`,children:o}),t[63]=a,t[64]=o,t[65]=s):s=t[65],I=s;let c;t[66]!==i||t[67]!==g.pending||t[68]!==g.start?(c=i?(0,P.jsx)(X,{pending:g.pending,onPull:g.start}):null,t[66]=i,t[67]=g.pending,t[68]=g.start,t[69]=c):c=t[69];let l;t[70]!==g.offering||t[71]!==g.resolveOffer||t[72]!==h?.ahead?(l=g.offering?(0,P.jsx)(Z,{onResolve:g.resolveOffer,strandedCommitCount:h?.ahead??0}):null,t[70]=g.offering,t[71]=g.resolveOffer,t[72]=h?.ahead,t[73]=l):l=t[73];let u;t[74]!==D||t[75]!==c||t[76]!==l?(u=(0,P.jsxs)(P.Fragment,{children:[c,D,l]}),t[74]=D,t[75]=c,t[76]=l,t[77]=u):u=t[77],F=u}let R;t[78]===O?R=t[79]:(R=(0,P.jsx)(`div`,{className:`flex size-16 items-center justify-center rounded-full border bg-muted/40 text-muted-foreground`,children:O}),t[78]=O,t[79]=R);let z;t[80]===N?z=t[81]:(z=(0,P.jsx)(`p`,{className:`max-w-md text-balance text-base leading-6 text-foreground/90`,children:N}),t[80]=N,t[81]=z);let B;t[82]===F?B=t[83]:(B=(0,P.jsx)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:justify-center`,children:F}),t[82]=F,t[83]=B);let V;return t[84]!==I||t[85]!==R||t[86]!==z||t[87]!==B?(V=(0,P.jsxs)(P.Fragment,{children:[R,z,I,B]}),t[84]=I,t[85]=R,t[86]=z,t[87]=B,t[88]=V):V=t[88],V}function $(e){return e.replace(/^\/+|\/+$/g,``)}function ee(e,t){if(t.kind===`folder`){if(E(e))return $(t.path)===``;let n=T(e);return n!==null&&$(n)===$(t.path)}let n=T(e);return n===null?!1:D(n)===D(t.path)}function te(){let e=null,t=new Set,n=!1;function r(){for(let e of t)e()}function i(t){e!==t&&(e=t,r())}function a(){e!==null&&(ee(window.location.hash,e)||i(null))}function o(){n||typeof window>`u`||(n=!0,window.addEventListener(`hashchange`,a))}return{arm(e){o(),i(e)},clear(){i(null)},getSnapshot(){return e},subscribe(e){return t.add(e),()=>{t.delete(e)}},dispose(){n&&typeof window<`u`&&(window.removeEventListener(`hashchange`,a),n=!1),i(null)}}}var ne=te();function re(e,t){return e===null||e.kind!==`missing`||t===null||D(t.path)!==e.target?null:t}export{H as a,V as i,ne as n,R as o,Q as r,I as s,re as t};
@@ -1,4 +1,4 @@
1
- import{T as e}from"./DocumentContext-FCJwmuAo.js";function t(e){return e.lineCount===1&&e.charLen<100?{kind:`inline`,markdown:e.markdown}:e.surface===`source`&&e.sourceLineStart!==void 0&&e.sourceLineEnd!==void 0?{kind:`lines`,startLine:e.sourceLineStart,endLine:e.sourceLineEnd}:{kind:`anchor`,markdown:e.markdown}}function n(e,t){return e.sourceLineStart!==void 0&&e.sourceLineEnd!==void 0?`${t} (${e.sourceLineStart===e.sourceLineEnd?`${e.sourceLineStart}`:`${e.sourceLineStart}-${e.sourceLineEnd}`})`:e.lineCount>1?`${t} (${e.lineCount} lines)`:`${t} (selection)`}function r(e){let t=e.replace(/\r\n/g,`
1
+ import{T as e}from"./DocumentContext-B-29n_HL.js";function t(e){return e.lineCount===1&&e.charLen<100?{kind:`inline`,markdown:e.markdown}:e.surface===`source`&&e.sourceLineStart!==void 0&&e.sourceLineEnd!==void 0?{kind:`lines`,startLine:e.sourceLineStart,endLine:e.sourceLineEnd}:{kind:`anchor`,markdown:e.markdown}}function n(e,t){return e.sourceLineStart!==void 0&&e.sourceLineEnd!==void 0?`${t} (${e.sourceLineStart===e.sourceLineEnd?`${e.sourceLineStart}`:`${e.sourceLineStart}-${e.sourceLineEnd}`})`:e.lineCount>1?`${t} (${e.lineCount} lines)`:`${t} (selection)`}function r(e){let t=e.replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `),n=[],r=!1;for(let e of t){let t=e.trim();if(/^(```|~~~)/.test(t)){r||n.push(`code`),r=!r;continue}if(r||t===``)continue;if(/^\|.*\|?$/.test(t)&&t.includes(`|`)){n[n.length-1]!==`table`&&n.push(`table`);continue}if(/^<\/?[A-Za-z]/.test(t)){n[n.length-1]!==`component`&&n.push(`component`);continue}let i=t.match(/^#{1,6}\s+(.*)$/);if(i){n.push(i[1]??``);continue}let a=t.match(/^[-*+]\s+(.*)$/);if(a){n.push(`• ${a[1]??``}`);continue}let o=t.match(/^\d+\.\s+(.*)$/);if(o){n.push(`• ${o[1]??``}`);continue}let s=t.match(/^>\s?(.*)$/);if(s){n.push(s[1]??``);continue}n.push(t)}return n.join(` `).replace(/\s+/g,` `).trim()}var i=new Map,a=new Set,o=(e,t)=>`${t}:${e}`;function s(){for(let e of a)e()}function c(e,t){return e.markdown===t.markdown&&e.sourceLineStart===t.sourceLineStart&&e.sourceLineEnd===t.sourceLineEnd}function l(e,t,n){let r=o(e,t);if(n===null){i.delete(r)&&s();return}let a=i.get(r);a&&c(a,n)||(i.set(r,n),s())}function u(e,t){return e===null?null:i.get(o(e,t))??null}function d(e){return a.add(e),()=>{a.delete(e)}}function f(t,n){if(t.state.selection.empty)return null;let r=e(t);return r.trim()?{surface:`wysiwyg`,docName:n,markdown:r,charLen:r.trim().length,lineCount:(r.match(/\n/g)?.length??0)+1}:null}function p(e,t){return e.trim()?{surface:`frontmatter`,docName:t,markdown:e,charLen:e.trim().length,lineCount:(e.match(/\n/g)?.length??0)+1}:null}function m(e,t){let n=[],r=1/0,i=-1;for(let t of e.state.selection.ranges)t.empty||(n.push(e.state.sliceDoc(t.from,t.to)),r=Math.min(r,t.from),i=Math.max(i,t.to));if(n.length===0)return null;let a=n.join(`
4
4
  `);if(!a.trim())return null;let o=e.state.doc.lineAt(r).number,s=e.state.doc.lineAt(i).number;return{surface:`source`,docName:t,markdown:a,charLen:a.trim().length,lineCount:s-o+1,sourceLineStart:o,sourceLineEnd:s}}export{p as a,t as c,n as i,d as l,r as n,m as o,l as r,f as s,u as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./createLucideIcon-DAkhoPjT.js";import{t as s}from"./button-Gol9BgNB.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dialog-TkFkuYVg.js";import{a as g,d as _,f as v,i as y,o as b,p as x,u as S}from"./dropdown-menu-xw8WTdb-.js";import{t as C}from"./label-DyipnO5I.js";import{C as w,a as T,f as E,h as D,m as O,n as k,o as A,p as j,r as M,s as N,t as P}from"./agent-visibility-CkDoRkF-.js";import{$t as F,Bt as I,Dn as L,En as R,I as z,On as B,Rt as V,Sn as H,Vt as U,bn as W,ct as G,in as K,kn as q,kt as ee,lt as te,on as ne,sn as re,vi as ie,wn as J,xn as ae,yn as oe}from"./dist-CYN1QNvi.js";import{t as Y}from"./RegisteredAgentIcon-C2dU04N7.js";import{a as se,d as ce,l as le,n as ue,r as de,t as fe,u as pe}from"./workspace-paths-C4Wwi52h.js";import{t as me}from"./copy-9EDFYcyR.js";import{t as he}from"./folder-open-wLd69QUc.js";import{t as ge}from"./loader-circle-Cg5SU7AZ.js";import{t as _e}from"./refresh-cw-BfeWGCsv.js";import{t as ve}from"./sliders-horizontal-34K0eDW2.js";import{t as ye}from"./trash-2-BUuL4OCw.js";import{n as X}from"./dist-BLAMau9Z.js";import{t as be}from"./input-D0ZW0Opq.js";import{t as xe}from"./dist-q14fBS3T.js";import{i as Se}from"./use-settings-route-Ch_E9Uw0.js";import{t as Ce}from"./parse-api-error-C_gwkKmG.js";import{c as we,l as Te}from"./documents-events-DUo-r8o3.js";import{n as Ee}from"./config-context-gd3BC-iY.js";import{t as De}from"./use-workspace-JeP_ExdS.js";import{n as Oe}from"./clipboard-adapter-Cxzkvc1d.js";import{a as ke,d as Ae,f as je,n as Me,s as Ne,t as Pe}from"./skills-api-CYCJlMKO.js";var Fe=o(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),Ie=o(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Le=o(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Re=o(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Z=t(),Q=e(n(),1),$=a();function ze(e){return{async install(t){let n;try{n=await e.buildAndOpen(t?.force?{force:!0}:void 0)}catch(e){return{ok:!1,reason:`bridge-error`,message:e instanceof Error?e.message:String(e)}}return n.ok?{ok:!0,path:n.path}:{ok:!1,reason:n.reason,message:n.message}}}}function Be(e={}){let t=e.fetch??globalThis.fetch,n=`${e.apiOrigin??``}/api/install-skill`;return{async install(e){let r;try{r=await t(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?.force?{force:!0}:{})})}catch(e){return{ok:!1,reason:`network-error`,message:e instanceof Error?e.message:String(e)}}if(!r.ok){let e=`HTTP ${r.status}`;try{let t=Ce(await r.json());t&&(e=t)}catch{}return{ok:!1,reason:`http-error`,message:e}}let i;try{i=await r.json()}catch(e){return{ok:!1,reason:`parse-error`,message:e instanceof Error?e.message:`Invalid server response`}}return!i||typeof i.status!=`string`?{ok:!1,reason:`parse-error`,message:`Invalid server response shape`}:i.status===`failed`?{ok:!1,reason:`build-failed`,message:i.buildError??`unknown build failure`}:{ok:!0,path:i.outputPath,handoffWarning:i.handoffError?.message}}}}function Ve(){if(typeof window>`u`)return null;let e=window.okDesktop?.skill;return e?ze(e):Be()}var He=`ok:skill:cowork:installed`,Ue=`1`,We=250,Ge=`/api/skill/install-state`;function Ke(e){return`${He}:v${e}`}var qe=new Map;async function Je(e={},t={}){let n=t.force?`__force__`:`__default__`,r=qe.get(n);if(r)return r;let i=Ye(e,t);return qe.set(n,i),i.finally(()=>{qe.get(n)===i&&qe.delete(n)}),i}async function Ye(e,t){let n=e.installer===void 0?Ve():e.installer,r=Xe(e.storage),i=e.fetchSnapshot??Qe,a=e.serverTimeoutMs??We,o=null;if(!t.force){try{o=await $e(i(),a)}catch(e){console.warn(`[cowork-skill] server install-state check failed; falling through:`,e)}if(o){let e=o.targets[`claude-cowork`]??null;if(e&&e.version===o.currentVersion)return{kind:`already-installed`,source:`server`}}}let s=Ke(o?.currentVersion??e.fallbackSkillVersion??Ze());if(!t.force&&r?.getItem(s)===Ue)return{kind:`already-installed`,source:`local`};if(!n)return{kind:`host-unsupported`};let c=await n.install({force:t.force??!1});if(!c.ok)return{kind:`install-failed`,reason:c.reason,message:c.message};try{r?.setItem(s,Ue)}catch(e){console.warn(`[cowork-skill] storage.setItem failed (guard will not persist):`,e)}return{kind:`installed-now`,path:c.path,handoffWarning:c.handoffWarning}}function Xe(e){if(e!==void 0)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Ze(){return typeof window>`u`?`unknown`:window.okDesktop?.appVersion??`unknown`}async function Qe(){let e;try{e=await fetch(Ge,{method:`GET`,cache:`no-store`})}catch{return null}if(!e.ok)return null;try{let t=await e.json();return typeof t?.currentVersion==`string`?t:null}catch{return null}}async function $e(e,t){return Promise.race([e,new Promise(e=>{setTimeout(()=>e(null),t)})])}function et(e){return Je({},e)}function tt(){return Je({},{force:!0})}async function nt(e,t){let n;try{n=await t(`/api/handoff`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}catch(e){return{ok:!1,reason:`dispatch-error`,detail:e instanceof Error?e.message:String(e)}}return n.status===200?{ok:!0}:n.status===404?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned 404`}:n.status===422?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned ${n.status}`}:{ok:!1,reason:`dispatch-error`,detail:`POST /api/handoff returned ${n.status}`}}async function rt(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis);switch(e.target){case`claude-cowork`:return nt({target:`claude-cowork`,url:K({mode:`cowork`},e)},n);case`claude-code`:return nt({target:`claude-code`,url:K({mode:`code`},e)},n);case`codex`:return nt({target:`codex`,url:ne(e)},n);case`cursor`:return nt({target:`cursor`,url:re(e),workspacePath:e.projectDir},n);case`copilot`:return{ok:!1,reason:`invalid-payload`,detail:`copilot is terminal-only; launch via requestTerminalLaunch`};case`opencode`:return{ok:!1,reason:`invalid-payload`,detail:`opencode is terminal-only; launch via requestTerminalLaunch`};case`pi`:return{ok:!1,reason:`invalid-payload`,detail:`pi is terminal-only; launch via requestTerminalLaunch`};case`antigravity`:return{ok:!1,reason:`invalid-payload`,detail:`antigravity is terminal-only; launch via requestTerminalLaunch`};case`openclaw`:return{ok:!1,reason:`invalid-payload`,detail:`openclaw is terminal-only; launch via requestTerminalLaunch`};case`hermes`:return{ok:!1,reason:`invalid-payload`,detail:`hermes is terminal-only; launch via requestTerminalLaunch`};default:{let t=e.target;return{ok:!1,reason:`invalid-payload`,detail:`unknown target: ${String(t)}`}}}}async function it(e,t={}){let n=t.okDesktop??(typeof window<`u`?window.okDesktop:void 0);if(n?.shell?.recordHandoff)try{await n.shell.recordHandoff(e)}catch(e){(t.warn??(e=>console.warn(e)))(`[handoff] recordHandoff IPC rejected (telemetry skipped): ${e instanceof Error?e.message:String(e)}`)}}var at=`open-knowledge:agent-thread-launch`;function ot(e,t=typeof window>`u`?new EventTarget:window){t.dispatchEvent(new CustomEvent(at,{detail:e}))}function st(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;n&&typeof n.agentId==`string`&&e(n)};return t.addEventListener(at,n),()=>t.removeEventListener(at,n)}function ct(e){if(!e.docName||!e.workspace)return null;let t=fe(e.docName),{contentDir:n,pathSeparator:r}=e.workspace;return{docContext:{relativePath:t},projectDir:n,docPath:ue(n,t,r)}}function lt(e){return e.workspace?.contentDir?{docContext:null,projectDir:e.workspace.contentDir,docPath:``}:null}function ut(e){return e.workspace?.contentDir?{docContext:null,createDescription:e.description,createScenario:e.scenario,createMentions:e.mentions,projectDir:e.workspace.contentDir,docPath:``}:null}function dt(e){return j(e.installUrl).then(()=>void 0)}function ft(e){return!e.workspace?.contentDir||!e.folderRelativePath?null:{docContext:null,folderRelativePath:e.folderRelativePath,projectDir:e.workspace.contentDir,docPath:``}}function pt(e){return!e.workspace?.contentDir||!e.skillName?null:{docContext:null,skill:{name:e.skillName,scope:e.scope},projectDir:e.workspace.contentDir,docPath:``}}function mt(e){if(!e.workspace?.contentDir)return null;let{contentDir:t,pathSeparator:n}=e.workspace;if(e.docName){let r=e.docRelativePath??fe(e.docName),i={scope:`doc`,docRelativePath:r,instruction:e.instruction,mentions:e.mentions};return{docContext:null,compose:e.selection===void 0?i:{...i,selection:e.selection},projectDir:t,docPath:ue(t,r,n)}}return e.folderRelativePath?{docContext:null,compose:{scope:`folder`,folderRelativePath:e.folderRelativePath,instruction:e.instruction,mentions:e.mentions},projectDir:t,docPath:``}:{docContext:null,compose:{scope:`project`,instruction:e.instruction,mentions:e.mentions},projectDir:t,docPath:``}}function ht(e){return`Opened in ${e}.`}function gt(e,t=1){return t>=3?`Couldn't reach ${e} — please try again later.`:t===2?`Still couldn't reach ${e} — try one more time?`:`Couldn't reach ${e} — try again?`}function _t(e){return e>=3?null:e===2?`Try one more time`:`Retry`}function vt(e,t,n,r,i){let a=i===void 0?{}:{scope:i};return t.ok?{target:e,host:n,outcome:`ok`,ts:r,...a}:{target:e,host:n,outcome:`error`,ts:r,reason:t.reason,...a}}function yt(e,t,n,r){if(e.scope===`doc`){let i={scope:`doc`,docRelativePath:e.docRelativePath,instruction:e.instruction,mentions:e.mentions,target:t,autoOpen:n,transport:r};return e.selection===void 0?i:{...i,selection:e.selection}}return e.scope===`folder`?{scope:`folder`,folderRelativePath:e.folderRelativePath,instruction:e.instruction,mentions:e.mentions,target:t,autoOpen:n,transport:r}:{scope:`project`,instruction:e.instruction,mentions:e.mentions,target:t,autoOpen:n,transport:r}}function bt(e,t,n,r){return e.compose?F(yt(e.compose,t,n,r)):e.selection?R({...e.selection,target:t,transport:r}):e.skill?L(e.skill.name,e.skill.scope,n):e.ask?oe(e.ask.relativePath,e.ask.instruction,n,t,r):ie(e.docContext===null?e.folderRelativePath?J(e.folderRelativePath,n,e.instruction,r):e.createDescription===void 0?ae(n,e.instruction,r):W(e.createDescription,n,e.createScenario??`new-project`,e.createMentions??[],r):H(e.docContext.relativePath,n,e.instruction,r))}function xt(e,t){let n=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||n?`${G} ${bt(e,I[t].handoffTarget,!1,`terminal`)}`:B(e.docContext?.relativePath??null)}function St(e){let t=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||t?`${te} ${bt(e,`claude-code`,!1,`terminal`)}`:q(e.docContext?.relativePath??null)}function Ct(e){let t=e.docContext?.relativePath;return typeof t!=`string`||t===``?null:t.replace(/\.(md|mdx)$/,``)}function wt(e){let t=[e.compose?.instruction,e.selection?.instruction,e.ask?.instruction,e.createDescription,e.instruction];for(let e of t)if(typeof e==`string`&&e.trim()!==``)return e;return null}function Tt(e,t){ot({agentSource:t?.agent?.source??`registry`,agentId:t?.agent?.id??``,prompt:St(e),docName:Ct(e),titleHint:wt(e)})}async function Et(e,t,n,r=1){if(e===`claude-cowork`&&r===1){let e;try{e=await n.ensureCoworkSkillInstalled()}catch(e){let t=e instanceof Error?e.message:String(e);return n.toast.error(`Couldn't install OpenKnowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-error: ${t}`}}if(e.kind===`installed-now`)return n.toast.success(`OpenKnowledge skill saved. Upload it in Claude Desktop, then click Cowork again.`),{ok:!0};if(e.kind===`install-failed`){let t=e.message??e.reason;return n.toast.error(`Couldn't install OpenKnowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-failed: ${t}`}}}let i={target:e,projectDir:t.projectDir,docPath:t.docPath,prompt:bt(t,e,n.autoOpen,`url`)},a=await n.dispatchHandoff(i),o=n.isElectronHost()?`electron`:`web`,s=n.now().toISOString(),c=t.compose,l=vt(e,a,o,s,t.selection!=null||c?.scope===`doc`&&c.selection!==void 0?`selection`:void 0);await n.recordHandoff(l);let u=n.getDisplayName(e);if(a.ok)n.toast.success(ht(u));else{let i=_t(r),a=gt(u,r);i===null?n.toast.error(a):n.toast.error(a,{action:{label:i,onClick:()=>{Et(e,t,n,r+1)}}})}return a}function Dt(e){return O.find(t=>t.id===e)?.displayName??e}function Ot(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function kt(){return{dispatchHandoff:rt,recordHandoff:it,toast:{success:e=>{X.success(e)},error:(e,t)=>{X.error(e,t?{action:t.action}:void 0)}},now:()=>new Date,isElectronHost:()=>Ot(),getDisplayName:Dt,ensureCoworkSkillInstalled:et,autoOpen:!0}}function At(){let e=(0,$.c)(2),{merged:t}=Ee(),n=t?.appearance?.preview?.autoOpen??!0,r;return e[0]===n?r=e[1]:(r={dispatch:(e,t)=>Et(e,t,{...kt(),autoOpen:n}),reinstallCoworkSkill:tt},e[0]=n,e[1]=r),r}var jt=[...new Set(O.flatMap(e=>e.schemes))];function Mt(e,t){let n=t.now?.()??Date.now(),r={};for(let t of O){let i=t.schemes[0],a=i===void 0?void 0:e[i];if(!a){r[t.id]={installed:null};continue}r[t.id]={installed:a.installed,...a.displayName===void 0?{}:{displayName:a.displayName},lastChecked:n}}return r}function Nt(e){return Mt({},e)}async function Pt(e){let t=e.schemes??jt,n=await Promise.all(t.map(async t=>{let n=t.replace(/:$/,``);try{return[t,await e.detectProtocol(n)]}catch{return[t,{installed:!1}]}}));return Object.fromEntries(n)}var Ft=Object.fromEntries(jt.map(e=>[e,{installed:!1}]));async function It(e){let t;try{t=await e.fetch(`/api/installed-agents`,{signal:e.signal,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return Ft}if(!t.ok)return Ft;let n;try{n=await t.json()}catch{return Ft}if(typeof n!=`object`||!n||Array.isArray(n))return Ft;let r=n,i={};for(let e of jt)i[e]={installed:r[e.replace(/:$/,``)]===!0};return i}function Lt(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.installed!==i.installed||n.displayName!==i.displayName)return!1}return!0}function Rt(e){let t=e.throttleMs??1e4,n=!1,r=null,i=null,a={},o=Nt({isElectronHost:e.isElectronHost(),now:e.now}),s=new Set,c=()=>{if(!n)for(let e of s)e(o)},l=()=>{o=Mt(a,{isElectronHost:e.isElectronHost(),now:e.now})};return{probe:async()=>{if(n)return;if(i)return i;if(r!==null&&e.now()-r<t)return;let o=(async()=>{try{let t=await e.probe();if(n)return;let i=!Lt(a,t);a=t,i&&(l(),c()),r=e.now()}catch{}finally{i=null}})();return i=o,o},getTargetStates:()=>o,subscribe:e=>(s.add(e),()=>{s.delete(e)}),cancel:()=>{n=!0,s.clear()}}}function zt(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function Bt(){let e=typeof window<`u`?window.okDesktop:void 0;if(e){let t=t=>e.shell.detectProtocol(t);return{probe:()=>Pt({detectProtocol:t}),isElectronHost:()=>!0,now:Date.now}}let t=globalThis.fetch.bind(globalThis);return{probe:()=>It({fetch:t}),isElectronHost:()=>!1,now:Date.now}}function Vt(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(Ht),r=(0,Q.useRef)(null),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=Rt(Bt());r.current=e;let t=e.subscribe(n);e.probe();let i=()=>{e.probe()};return window.addEventListener(`focus`,i),()=>{window.removeEventListener(`focus`,i),t(),e.cancel(),r.current=null}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),(0,Q.useEffect)(i,a);let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r.current?.probe()??Promise.resolve(),e[2]=o):o=e[2];let s;return e[3]===t?s=e[4]:(s={states:t,refresh:o},e[3]=t,e[4]=s),s}function Ht(){return Nt({isElectronHost:zt(),now:Date.now})}var Ut=(0,Q.createContext)(null);function Wt(e){let t=(0,$.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsx)(Ut,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function Gt(){return(0,Q.use)(Ut)}function Kt(e){let t=(0,$.c)(48),{itemName:n,isSubmitting:a,onDelete:o,customTitle:h,customDescription:g,customDetail:_,customConfirmLabel:v,customConfirmLabelBusy:y,children:b}=e,{_:x}=i(),S;t[0]!==x||t[1]!==n?(S=n??x({id:`L3CEC1`}),t[0]=x,t[1]=n,t[2]=S):S=t[2];let C=S,w;t[3]!==x||t[4]!==v?(w=v??x({id:`cnGeoo`}),t[3]=x,t[4]=v,t[5]=w):w=t[5];let T=w,E;t[6]!==x||t[7]!==v||t[8]!==y?(E=y??v??x({id:`s3caR3`}),t[6]=x,t[7]=v,t[8]=y,t[9]=E):E=t[9];let D=E,O;t[10]!==x||t[11]!==h||t[12]!==C?(O=h??x({id:`77SdEP`,values:{itemName:C}}),t[10]=x,t[11]=h,t[12]=C,t[13]=O):O=t[13];let k;t[14]===O?k=t[15]:(k=(0,Z.jsx)(l,{children:O}),t[14]=O,t[15]=k);let A;t[16]!==x||t[17]!==g||t[18]!==C?(A=g??x({id:`16D5Zj`,values:{itemName:C}}),t[16]=x,t[17]=g,t[18]=C,t[19]=A):A=t[19];let j;t[20]===A?j=t[21]:(j=(0,Z.jsx)(c,{className:`whitespace-pre-wrap`,children:A}),t[20]=A,t[21]=j);let M;t[22]===_?M=t[23]:(M=_?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`delete-confirmation-detail`,children:_}):null,t[22]=_,t[23]=M);let N;t[24]!==k||t[25]!==j||t[26]!==M?(N=(0,Z.jsxs)(m,{children:[k,j,M]}),t[24]=k,t[25]=j,t[26]=M,t[27]=N):N=t[27];let P;t[28]===b?P=t[29]:(P=b?(0,Z.jsx)(d,{children:b}):null,t[28]=b,t[29]=P);let F;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(r,{id:`dEgA5A`}),t[30]=F):F=t[30];let I;t[31]===a?I=t[32]:(I=(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(s,{variant:`outline`,disabled:a,children:F})}),t[31]=a,t[32]=I);let L;t[33]!==T||t[34]!==D||t[35]!==a?(L=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ge,{className:`size-4 animate-spin`}),` `,D]}):T,t[33]=T,t[34]=D,t[35]=a,t[36]=L):L=t[36];let R;t[37]!==a||t[38]!==o||t[39]!==L?(R=(0,Z.jsx)(s,{variant:`destructive`,onClick:o,disabled:a,children:L}),t[37]=a,t[38]=o,t[39]=L,t[40]=R):R=t[40];let z;t[41]!==I||t[42]!==R?(z=(0,Z.jsxs)(f,{children:[I,R]}),t[41]=I,t[42]=R,t[43]=z):z=t[43];let B;return t[44]!==P||t[45]!==z||t[46]!==N?(B=(0,Z.jsxs)(u,{children:[N,P,z]}),t[44]=P,t[45]=z,t[46]=N,t[47]=B):B=t[47],B}function qt(e){return e?xe._({id:`wTcjov`}):null}function Jt(e){let t=(0,$.c)(47),{_:n}=i(),a=de(),o=Gt(),s=w(),c=E();if(a)return null;let{input:l,installStates:u,dispatch:d,onBeforeLaunch:f}=e,p=l===null,m,h,C,O,j,F,L,R,z,B,V;if(t[0]!==n||t[1]!==d||t[2]!==l||t[3]!==p||t[4]!==u||t[5]!==f||t[6]!==c||t[7]!==s||t[8]!==o){let e=qt(p),i;t[20]===c?i=t[21]:(i=e=>P(c,e.id),t[20]=c,t[21]=i);let a=D.filter(i),w;t[22]===c?w=t[23]:(w=e=>k(c,e.source,e.id,!0,e.supported),t[22]=c,t[23]=w);let E=s.filter(w),H=o?U.filter(e=>M(c,e,o.installedClis)):[];C=a.length>0,O=o!==null&&H.length>0,j=E.length>0,h=_,t[24]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsxs)(x,{children:[(0,Z.jsx)(le,{"aria-hidden":`true`}),(0,Z.jsx)(r,{id:`O7_W_a`})]}),t[24]=V):V=t[24],m=v,F=`max-h-80`,L=j?(0,Z.jsxs)(y,{"aria-label":n({id:`vPKX2i`}),children:[(0,Z.jsxs)(b,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(r,{id:`RXEbZy`}),(0,Z.jsx)(N,{})]}),E.map(t=>{let i=t.name;return(0,Z.jsxs)(g,{onSelect:()=>{l!==null&&(f?.(),Tt(l,{agent:{source:t.source,id:t.id}}))},disabled:p,"data-testid":`file-tree-open-in-thread-${t.id}`,"aria-label":e?n({id:`gtGQ9S`,values:{agentName:i,hint:e}}):void 0,children:[(0,Z.jsx)(Y,{agentId:t.id,iconUrl:t.iconUrl,className:`size-4`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(r,{id:`5PrrYw`,values:{agentName:i}})}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},`${t.source}:${t.id}`)})]}):null,t[25]!==C||t[26]!==O||t[27]!==j?(R=j&&(O||C)?(0,Z.jsx)(S,{}):null,t[25]=C,t[26]=O,t[27]=j,t[28]=R):R=t[28],z=O?(0,Z.jsxs)(y,{"aria-label":n({id:`ALhMYW`}),children:[(0,Z.jsx)(b,{children:(0,Z.jsx)(r,{id:`ALhMYW`})}),H.map(t=>{let{displayName:r}=I[t];return(0,Z.jsxs)(g,{onSelect:()=>{l!==null&&(f?.(),o.launchInTerminal(l,t))},disabled:p,"data-testid":`file-tree-open-in-terminal-${t}`,"aria-label":n(e?{id:`AIn2Yv`,values:{displayName:r,hint:e}}:{id:`QYfQdv`,values:{displayName:r}}),children:[(0,Z.jsx)(A,{id:T(t),"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:r}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t)})]}):null,B=C?(0,Z.jsxs)(Z.Fragment,{children:[O?(0,Z.jsx)(S,{}):null,(0,Z.jsxs)(y,{"aria-label":n({id:`BBqGS9`}),children:[(0,Z.jsx)(b,{children:(0,Z.jsx)(r,{id:`BBqGS9`})}),a.map(t=>{let r=!p,{displayName:i}=t,a=n(e?{id:`1ZpfyB`,values:{displayName:i,hint:e}}:{id:`WqLq6M`,values:{displayName:i}});return(0,Z.jsxs)(g,{disabled:!r,onSelect:()=>{if(l){if(f?.(),u[t.id]?.installed!==!0){dt(t);return}d(t.id,l)}},"data-testid":`file-tree-open-in-${t.id}`,"aria-label":a,children:[(0,Z.jsx)(A,{id:t.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:t.displayName}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)})]})]}):null,t[0]=n,t[1]=d,t[2]=l,t[3]=p,t[4]=u,t[5]=f,t[6]=c,t[7]=s,t[8]=o,t[9]=m,t[10]=h,t[11]=C,t[12]=O,t[13]=j,t[14]=F,t[15]=L,t[16]=R,t[17]=z,t[18]=B,t[19]=V}else m=t[9],h=t[10],C=t[11],O=t[12],j=t[13],F=t[14],L=t[15],R=t[16],z=t[17],B=t[18],V=t[19];let H;t[29]!==C||t[30]!==O||t[31]!==j?(H=j||O||C?(0,Z.jsx)(S,{}):null,t[29]=C,t[30]=O,t[31]=j,t[32]=H):H=t[32];let W;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(ve,{"aria-hidden":`true`}),t[33]=W):W=t[33];let G;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsxs)(g,{onSelect:Se,"data-testid":`file-tree-open-in-settings`,children:[W,(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(r,{id:`jRAGrQ`})})]}),t[34]=G):G=t[34];let K;t[35]!==m||t[36]!==F||t[37]!==L||t[38]!==R||t[39]!==z||t[40]!==B||t[41]!==H?(K=(0,Z.jsxs)(m,{className:F,children:[L,R,z,B,H,G]}),t[35]=m,t[36]=F,t[37]=L,t[38]=R,t[39]=z,t[40]=B,t[41]=H,t[42]=K):K=t[42];let q;return t[43]!==h||t[44]!==V||t[45]!==K?(q=(0,Z.jsxs)(h,{children:[V,K]}),t[43]=h,t[44]=V,t[45]=K,t[46]=q):q=t[46],q}function Yt(e){let t=(0,$.c)(8),n=e?.enabled??!0,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={status:`idle`},t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(0),c,l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=()=>s($t),t=Te(e),n=we(t=>{t.includes(`files`)&&e()});return()=>{t(),n()}},l=[],t[1]=c,t[2]=l):(c=t[1],l=t[2]),(0,Q.useEffect)(c,l);let u;t[3]===n?u=t[4]:(u=()=>{if(!n)return;let e=!1;return a(Qt),fetch(`/api/skills`).then(Xt).then(t=>{if(e)return;let n=V.safeParse(t);if(!n.success){console.error(`[ok-skills] /api/skills response failed schema validation:`,n.error.issues),a({status:`error`,message:`Server returned an incomplete skills response.`});return}a({status:`ready`,data:n.data.skills})}).catch(t=>{e||a({status:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},t[3]=n,t[4]=u);let d;return t[5]!==n||t[6]!==o?(d=[o,n],t[5]=n,t[6]=o,t[7]=d):d=t[7],(0,Q.useEffect)(u,d),i}async function Xt(e){if(!e.ok){let t=await e.json().catch(Zt);throw Error(Ce(t)??`HTTP ${e.status}`)}return e.json()}function Zt(){return null}function Qt(e){return e.status===`ready`?e:{status:`loading`}}function $t(e){return e+1}function en(e){let t=(0,$.c)(16),{skill:n,onOpenChange:r,onDeleted:a}=e,{_:o}=i(),[s,c]=(0,Q.useState)(!1),l;t[0]!==o||t[1]!==a||t[2]!==r?(l=async function(e){c(!0);let t=await Pe(e.scope,e.name);if(c(!1),!t.ok){let{error:e}=t;X.error(o({id:`AtBdnD`,values:{error:e}}));return}X.success(o({id:`h9QFb9`,values:{0:e.name}})),a(),r(!1)},t[0]=o,t[1]=a,t[2]=r,t[3]=l):l=t[3];let u=l,d=n!==null,f;t[4]!==s||t[5]!==r?(f=e=>{!e&&!s&&r(!1)},t[4]=s,t[5]=r,t[6]=f):f=t[6];let p;t[7]!==o||t[8]!==s||t[9]!==u||t[10]!==n?(p=n?(0,Z.jsx)(Kt,{itemName:o({id:`ExUzM4`,values:{0:n.name}}),isSubmitting:s,onDelete:()=>u(n),customDescription:o({id:`E1Da_b`,values:{0:n.path}})}):null,t[7]=o,t[8]=s,t[9]=u,t[10]=n,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,Z.jsx)(h,{open:d,onOpenChange:f,children:p}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15],m}function tn(e){let t=(0,$.c)(68),{skill:n,existingNames:a,onOpenChange:o,onRenamed:d}=e,{_:p}=i(),g=n!==null,_=(0,Q.useId)(),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),S;t[0]===n?S=t[1]:(S=()=>{n&&y(n.name)},t[0]=n,t[1]=S);let w=n?.scope,T=n?.name,E;if(t[2]!==w||t[3]!==T?(E=[w,T],t[2]=w,t[3]=T,t[4]=E):E=t[4],(0,Q.useEffect)(S,E),!n)return null;let D,O,k,A;t[5]!==a||t[6]!==v||t[7]!==n.name?(k=v.trim(),A=k===n.name,D=k===``||!ee.test(k),O=!D&&!A&&a.has(k),t[5]=a,t[6]=v,t[7]=n.name,t[8]=D,t[9]=O,t[10]=k,t[11]=A):(D=t[8],O=t[9],k=t[10],A=t[11]);let j=O,M=!D&&!j&&!A&&!b,N;t[12]!==p||t[13]!==M||t[14]!==o||t[15]!==d||t[16]!==n||t[17]!==k?(N=async function(){if(!n||!M)return;x(!0);let e=await Ne({scope:n.scope,fromName:n.name,toName:k});if(x(!1),!e.ok){X.error(p({id:`zKxoPm`,values:{0:n.name,1:e.error}}));return}X.success(p({id:`dUCQo4`,values:{trimmed:k}})),d?.(k),o(!1)},t[12]=p,t[13]=M,t[14]=o,t[15]=d,t[16]=n,t[17]=k,t[18]=N):N=t[18];let P=N,F;t[19]===o?F=t[20]:(F=e=>e?null:o(!1),t[19]=o,t[20]=F);let I;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(l,{children:(0,Z.jsx)(r,{id:`dw_3cv`})}),t[21]=I):I=t[21];let L;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsxs)(m,{children:[I,(0,Z.jsx)(c,{children:(0,Z.jsx)(r,{id:`R9IDFz`})})]}),t[22]=L):L=t[22];let R;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(r,{id:`6YtxFj`}),t[23]=R):R=t[23];let z;t[24]===_?z=t[25]:(z=(0,Z.jsx)(C,{htmlFor:_,children:R}),t[24]=_,t[25]=z);let B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>y(e.target.value),t[26]=B):B=t[26];let V;t[27]===P?V=t[28]:(V=e=>{e.key===`Enter`&&P()},t[27]=P,t[28]=V);let H=D||j,U=D&&k!==``||j?`${_}-error`:void 0,W;t[29]!==_||t[30]!==v||t[31]!==V||t[32]!==H||t[33]!==U?(W=(0,Z.jsx)(be,{id:_,value:v,onChange:B,onKeyDown:V,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-invalid":H,"aria-describedby":U,className:`font-mono`}),t[29]=_,t[30]=v,t[31]=V,t[32]=H,t[33]=U,t[34]=W):W=t[34];let G;t[35]!==j||t[36]!==_||t[37]!==D||t[38]!==k?(G=D&&k!==``?(0,Z.jsx)(`p`,{id:`${_}-error`,className:`text-xs text-destructive`,children:(0,Z.jsx)(r,{id:`A50vr3`,components:{0:(0,Z.jsx)(`code`,{className:`font-mono`})}})}):j?(0,Z.jsx)(`p`,{id:`${_}-error`,className:`text-xs text-destructive`,children:(0,Z.jsx)(r,{id:`YJ1BTp`})}):null,t[35]=j,t[36]=_,t[37]=D,t[38]=k,t[39]=G):G=t[39];let K;t[40]!==z||t[41]!==W||t[42]!==G?(K=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[z,W,G]}),t[40]=z,t[41]=W,t[42]=G,t[43]=K):K=t[43];let q;t[44]===o?q=t[45]:(q=()=>o(!1),t[44]=o,t[45]=q);let te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(r,{id:`dEgA5A`}),t[46]=te):te=t[46];let ne;t[47]!==b||t[48]!==q?(ne=(0,Z.jsx)(s,{variant:`ghost`,onClick:q,disabled:b,children:te}),t[47]=b,t[48]=q,t[49]=ne):ne=t[49];let re;t[50]===P?re=t[51]:(re=()=>void P(),t[50]=P,t[51]=re);let ie=!M,J;t[52]===b?J=t[53]:(J=b?(0,Z.jsx)(r,{id:`tHKQ6j`}):(0,Z.jsx)(r,{id:`2wxgft`}),t[52]=b,t[53]=J);let ae;t[54]!==re||t[55]!==ie||t[56]!==J?(ae=(0,Z.jsx)(s,{onClick:re,disabled:ie,children:J}),t[54]=re,t[55]=ie,t[56]=J,t[57]=ae):ae=t[57];let oe;t[58]!==ne||t[59]!==ae?(oe=(0,Z.jsxs)(f,{children:[ne,ae]}),t[58]=ne,t[59]=ae,t[60]=oe):oe=t[60];let Y;t[61]!==K||t[62]!==oe?(Y=(0,Z.jsxs)(u,{children:[L,K,oe]}),t[61]=K,t[62]=oe,t[63]=Y):Y=t[63];let se;return t[64]!==g||t[65]!==Y||t[66]!==F?(se=(0,Z.jsx)(h,{open:g,onOpenChange:F,children:Y}),t[64]=g,t[65]=Y,t[66]=F,t[67]=se):se=t[67],se}function nn(e){let t=(0,$.c)(15),{skill:n,onOpenChange:a,onUpdated:o}=e,{_:g}=i(),[_,v]=(0,Q.useState)(!1),y;t[0]!==g||t[1]!==a||t[2]!==o?(y=async function(e){v(!0);let t=await je({scope:e.scope,name:e.name});v(!1);let n=se(e.name);if(!t.ok){X.error(g({id:`FRqZ9v`,values:{0:t.error}}));return}X.success(t.checkpointRef?g({id:`My9uXI`,values:{0:t.version,display:n}}):g({id:`mPneVR`,values:{0:t.version,display:n}})),o(),a(!1)},t[0]=g,t[1]=a,t[2]=o,t[3]=y):y=t[3];let b=y,x=n!==null,S;t[4]!==a||t[5]!==_?(S=e=>{!e&&!_&&a(!1)},t[4]=a,t[5]=_,t[6]=S):S=t[6];let C;t[7]!==b||t[8]!==n||t[9]!==_?(C=n?(0,Z.jsxs)(u,{className:`sm:max-w-lg`,children:[(0,Z.jsxs)(m,{children:[(0,Z.jsx)(l,{children:(0,Z.jsx)(r,{id:`iAoh55`,values:{0:se(n.name)}})}),(0,Z.jsx)(c,{children:n.installedVersion?(0,Z.jsx)(r,{id:`47EXvY`,values:{0:n.bundledVersion??``,1:n.installedVersion}}):(0,Z.jsx)(r,{id:`nD7Fx9`,values:{0:n.bundledVersion??``}})})]}),(0,Z.jsx)(d,{}),(0,Z.jsxs)(f,{children:[(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(s,{variant:`outline`,disabled:_,children:(0,Z.jsx)(r,{id:`dEgA5A`})})}),(0,Z.jsx)(s,{onClick:()=>void b(n),disabled:_,children:_?(0,Z.jsx)(r,{id:`JL3si7`}):(0,Z.jsx)(r,{id:`EkH9pt`})})]})]}):null,t[7]=b,t[8]=n,t[9]=_,t[10]=C):C=t[10];let w;return t[11]!==x||t[12]!==S||t[13]!==C?(w=(0,Z.jsx)(h,{open:x,onOpenChange:S,children:C}),t[11]=x,t[12]=S,t[13]=C,t[14]=w):w=t[14],w}function rn(){let e=(0,$.c)(30),{_:t}=i(),[n,r]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),d;e[0]===t?d=e[1]:(d=async function(e,n){u(e.name);let r=await ke({scope:e.scope,name:e.name,...n?{targets:[...n]}:{}});if(u(null),!r.ok)return X.error(t({id:`Mj8R8K`,values:{0:r.error}})),r;let i=an,a=new Set(r.hosts),o=r.hosts.filter(t=>!e.hosts.includes(t)),s=e.hosts.filter(e=>!a.has(e)),c=e=>{let t=r.warningCodes.indexOf(e);return t>=0?r.warnings[t]:void 0},l=c(`no-targets`);if(l)return X.warning(l),r;if(o.length>0){let e=c(`scripts-present`);e&&X.warning(e)}return r.hosts.length===0?X.success(t({id:`0LBDjY`,values:{0:e.name}})):o.length>0&&s.length===0?X.success(t({id:`PPFQ3o`,values:{0:e.name,1:i(o)}})):s.length>0&&o.length===0?X.success(t({id:`OOIVJo`,values:{0:e.name,1:i(s)}})):o.length>0&&s.length>0?X.success(t({id:`OxplNM`,values:{0:e.name,1:i(o),2:i(s)}})):X.success(t({id:`wDgmsr`,values:{0:e.name,1:i(r.hosts)}})),r},e[0]=t,e[1]=d);let f=d,p;e[2]===t?p=e[3]:(p=async function(e){u(e.name);let n=await Ae({scope:e.scope,name:e.name});return u(null),n.ok?X.success(t({id:`0LBDjY`,values:{0:e.name}})):X.error(t({id:`nJq7et`,values:{0:n.error}})),n},e[2]=t,e[3]=p);let m=p,h;e[4]===t?h=e[5]:(h=async function(e,n){let r=await Me({scope:e.scope,name:e.name,existingNames:n});if(!r.ok){X.error(t({id:`UPjaXD`,values:{0:e.name,1:r.error}}));return}X.success(t({id:`0g7rCZ`,values:{0:r.name}}))},e[4]=t,e[5]=h);let g=h,_,v;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{e||r(null)},v=()=>r(null),e[6]=_,e[7]=v):(_=e[6],v=e[7]);let y;e[8]===n?y=e[9]:(y=(0,Z.jsx)(en,{skill:n,onOpenChange:_,onDeleted:v}),e[8]=n,e[9]=y);let b=a?.skill??null,x=a?.existingNames??sn,S,C;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e||o(null)},C=()=>o(null),e[10]=S,e[11]=C):(S=e[10],C=e[11]);let w;e[12]!==b||e[13]!==x?(w=(0,Z.jsx)(tn,{skill:b,existingNames:x,onOpenChange:S,onRenamed:C}),e[12]=b,e[13]=x,e[14]=w):w=e[14];let T,E;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||c(null)},E=()=>c(null),e[15]=T,e[16]=E):(T=e[15],E=e[16]);let D;e[17]===s?D=e[18]:(D=(0,Z.jsx)(nn,{skill:s,onOpenChange:T,onUpdated:E}),e[17]=s,e[18]=D);let O;e[19]!==w||e[20]!==D||e[21]!==y?(O=(0,Z.jsxs)(Z.Fragment,{children:[y,w,D]}),e[19]=w,e[20]=D,e[21]=y,e[22]=O):O=e[22];let k=O,A;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(A=(e,t)=>o({skill:e,existingNames:t}),e[23]=A):A=e[23];let j;return e[24]!==k||e[25]!==g||e[26]!==f||e[27]!==l||e[28]!==m?(j={installingName:l,install:f,uninstall:m,duplicate:g,requestDelete:r,requestRename:A,requestUpdate:c,dialogs:k},e[24]=k,e[25]=g,e[26]=f,e[27]=l,e[28]=m,e[29]=j):j=e[29],j}function an(e){return e.map(on).join(`, `)}function on(e){return z[e]??e}var sn=new Set;function cn(e){let t=(0,$.c)(19),{skill:n,onEdit:i,onInstall:a,onUninstall:o,onDelete:s}=e,c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(pe,{"aria-hidden":!0}),l=(0,Z.jsx)(r,{id:`ePK91l`}),t[0]=c,t[1]=l):(c=t[0],l=t[1]);let u;t[2]===i?u=t[3]:(u=(0,Z.jsxs)(g,{onSelect:i,children:[c,l]}),t[2]=i,t[3]=u);let d;t[4]!==a||t[5]!==n.installed?(d=a&&!n.installed?(0,Z.jsxs)(g,{onSelect:a,children:[(0,Z.jsx)(Fe,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`TKQ7K-`})]}):null,t[4]=a,t[5]=n.installed,t[6]=d):d=t[6];let f;t[7]!==o||t[8]!==n.installed?(f=n.installed?(0,Z.jsxs)(g,{onSelect:o,children:[(0,Z.jsx)(Re,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`fo0VXg`})]}):null,t[7]=o,t[8]=n.installed,t[9]=f):f=t[9];let p,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(ye,{"aria-hidden":!0}),m=(0,Z.jsx)(r,{id:`cnGeoo`}),t[10]=p,t[11]=m):(p=t[10],m=t[11]);let h;t[12]===s?h=t[13]:(h=(0,Z.jsxs)(g,{variant:`destructive`,onSelect:s,children:[p,m]}),t[12]=s,t[13]=h);let _;return t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==h?(_=(0,Z.jsxs)(Z.Fragment,{children:[u,d,f,h]}),t[14]=u,t[15]=d,t[16]=f,t[17]=h,t[18]=_):_=t[18],_}function ln(e){let t=(0,$.c)(94),{skill:n,actions:a,existingNames:o}=e,{_:s}=i(),c=De(),l=Vt().states,{dispatch:u}=At(),d=typeof window<`u`?window.okDesktop:void 0,f=n.absolutePath,p;t[0]===s?p=t[1]:(p=async function(e){try{await Oe(e),X.success(s({id:`SXCSQd`}))}catch{X.error(s({id:`cRHuuI`}))}},t[0]=s,t[1]=p);let m=p;if(n.managed){let e,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(b,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Z.jsx)(Ie,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(r,{id:`VITWk5`})]}),i=(0,Z.jsx)(S,{}),t[2]=e,t[3]=i):(e=t[2],i=t[3]);let a;t[4]===f?a=t[5]:(a=d&&f?(0,Z.jsxs)(g,{onSelect:()=>void d.shell.showItemInFolder(f),children:[(0,Z.jsx)(he,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`LtSYdi`})]}):null,t[4]=f,t[5]=a);let o;t[6]!==n.name||t[7]!==n.scope||t[8]!==c?(o=pt({skillName:n.name,scope:n.scope,workspace:c}),t[6]=n.name,t[7]=n.scope,t[8]=c,t[9]=o):o=t[9];let s;t[10]!==u||t[11]!==l||t[12]!==o?(s=(0,Z.jsx)(Jt,{input:o,installStates:l,isElectronHost:d!=null,dispatch:u}),t[10]=u,t[11]=l,t[12]=o,t[13]=s):s=t[13];let p;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsxs)(x,{children:[(0,Z.jsx)(me,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`zd00pH`})]}),t[14]=p):p=t[14];let h;t[15]!==f||t[16]!==m?(h=f?(0,Z.jsx)(g,{onSelect:()=>void m(f),children:(0,Z.jsx)(r,{id:`z2funE`})}):null,t[15]=f,t[16]=m,t[17]=h):h=t[17];let y;t[18]!==m||t[19]!==n.path?(y=()=>void m(n.path),t[18]=m,t[19]=n.path,t[20]=y):y=t[20];let C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(r,{id:`xloBjn`}),t[21]=C):C=t[21];let w;t[22]===y?w=t[23]:(w=(0,Z.jsx)(g,{onSelect:y,children:C}),t[22]=y,t[23]=w);let T;t[24]!==w||t[25]!==h?(T=(0,Z.jsxs)(_,{children:[p,(0,Z.jsxs)(v,{children:[h,w]})]}),t[24]=w,t[25]=h,t[26]=T):T=t[26];let E;return t[27]!==T||t[28]!==a||t[29]!==s?(E=(0,Z.jsxs)(Z.Fragment,{children:[e,i,a,s,T]}),t[27]=T,t[28]=a,t[29]=s,t[30]=E):E=t[30],E}let h;t[31]===f?h=t[32]:(h=d&&f?(0,Z.jsxs)(g,{onSelect:()=>void d.shell.showItemInFolder(f),children:[(0,Z.jsx)(he,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`LtSYdi`})]}):null,t[31]=f,t[32]=h);let y;t[33]!==n.name||t[34]!==n.scope||t[35]!==c?(y=pt({skillName:n.name,scope:n.scope,workspace:c}),t[33]=n.name,t[34]=n.scope,t[35]=c,t[36]=y):y=t[36];let C;t[37]!==u||t[38]!==l||t[39]!==y?(C=(0,Z.jsx)(Jt,{input:y,installStates:l,isElectronHost:d!=null,dispatch:u}),t[37]=u,t[38]=l,t[39]=y,t[40]=C):C=t[40];let w;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsxs)(x,{children:[(0,Z.jsx)(me,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`zd00pH`})]}),t[41]=w):w=t[41];let T;t[42]!==f||t[43]!==m?(T=f?(0,Z.jsx)(g,{onSelect:()=>void m(f),children:(0,Z.jsx)(r,{id:`z2funE`})}):null,t[42]=f,t[43]=m,t[44]=T):T=t[44];let E;t[45]!==m||t[46]!==n.path?(E=()=>void m(n.path),t[45]=m,t[46]=n.path,t[47]=E):E=t[47];let D;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(r,{id:`xloBjn`}),t[48]=D):D=t[48];let O;t[49]===E?O=t[50]:(O=(0,Z.jsx)(g,{onSelect:E,children:D}),t[49]=E,t[50]=O);let k;t[51]!==T||t[52]!==O?(k=(0,Z.jsxs)(_,{children:[w,(0,Z.jsxs)(v,{children:[T,O]})]}),t[51]=T,t[52]=O,t[53]=k):k=t[53];let A;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(S,{}),t[54]=A):A=t[54];let j;t[55]!==a||t[56]!==o||t[57]!==n?(j=()=>void a.duplicate(n,o),t[55]=a,t[56]=o,t[57]=n,t[58]=j):j=t[58];let M,N;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(ce,{"aria-hidden":!0}),N=(0,Z.jsx)(r,{id:`euc6Ns`}),t[59]=M,t[60]=N):(M=t[59],N=t[60]);let P;t[61]===j?P=t[62]:(P=(0,Z.jsxs)(g,{onSelect:j,children:[M,N]}),t[61]=j,t[62]=P);let F;t[63]!==a||t[64]!==o||t[65]!==n?(F=()=>a.requestRename(n,o),t[63]=a,t[64]=o,t[65]=n,t[66]=F):F=t[66];let I,L;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(Le,{"aria-hidden":!0}),L=(0,Z.jsx)(r,{id:`2wxgft`}),t[67]=I,t[68]=L):(I=t[67],L=t[68]);let R;t[69]===F?R=t[70]:(R=(0,Z.jsxs)(g,{onSelect:F,children:[I,L]}),t[69]=F,t[70]=R);let z;t[71]!==a||t[72]!==n?(z=n.updateAvailable?(0,Z.jsxs)(g,{onSelect:()=>a.requestUpdate(n),children:[(0,Z.jsx)(_e,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`6g2jsp`})]}):null,t[71]=a,t[72]=n,t[73]=z):z=t[73];let B;t[74]!==a||t[75]!==n?(B=n.installed?(0,Z.jsxs)(g,{onSelect:()=>void a.uninstall(n),children:[(0,Z.jsx)(Re,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`fo0VXg`})]}):(0,Z.jsxs)(g,{onSelect:()=>void a.install(n),children:[(0,Z.jsx)(Fe,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`TKQ7K-`})]}),t[74]=a,t[75]=n,t[76]=B):B=t[76];let V;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(S,{}),t[77]=V):V=t[77];let H;t[78]!==a||t[79]!==n?(H=()=>a.requestDelete(n),t[78]=a,t[79]=n,t[80]=H):H=t[80];let U,W;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(ye,{"aria-hidden":!0}),W=(0,Z.jsx)(r,{id:`cnGeoo`}),t[81]=U,t[82]=W):(U=t[81],W=t[82]);let G;t[83]===H?G=t[84]:(G=(0,Z.jsxs)(g,{variant:`destructive`,onSelect:H,children:[U,W]}),t[83]=H,t[84]=G);let K;return t[85]!==k||t[86]!==P||t[87]!==R||t[88]!==h||t[89]!==z||t[90]!==B||t[91]!==G||t[92]!==C?(K=(0,Z.jsxs)(Z.Fragment,{children:[h,C,k,A,P,R,z,B,V,G]}),t[85]=k,t[86]=P,t[87]=R,t[88]=h,t[89]=z,t[90]=B,t[91]=G,t[92]=C,t[93]=K):K=t[93],K}export{Fe as C,Ie as S,Dt as _,Jt as a,At as b,Gt as c,ut as d,ft as f,xt as g,pt as h,Yt as i,Vt as l,lt as m,ln as n,Kt as o,ct as p,rn as r,Wt as s,cn as t,mt as u,dt as v,st as x,Tt as y};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./createLucideIcon-DAkhoPjT.js";import{t as s}from"./button-Gol9BgNB.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dialog-TkFkuYVg.js";import{a as g,d as _,f as v,i as y,o as b,p as x,u as S}from"./dropdown-menu-xw8WTdb-.js";import{t as C}from"./label-DyipnO5I.js";import{C as w,a as T,f as E,h as D,m as O,n as k,o as A,p as j,r as M,s as N,t as P}from"./agent-visibility-CkDoRkF-.js";import{$t as F,Bt as I,Dn as L,En as R,I as z,On as B,Rt as V,Sn as H,Vt as U,bn as W,ct as G,in as K,kn as q,kt as ee,lt as te,on as ne,sn as re,vi as ie,wn as J,xn as ae,yn as oe}from"./dist-CYN1QNvi.js";import{t as Y}from"./RegisteredAgentIcon-DplzDEhh.js";import{a as se,d as ce,l as le,n as ue,r as de,t as fe,u as pe}from"./workspace-paths-C4Wwi52h.js";import{t as me}from"./copy-9EDFYcyR.js";import{t as he}from"./folder-open-wLd69QUc.js";import{t as ge}from"./loader-circle-Cg5SU7AZ.js";import{t as _e}from"./refresh-cw-BfeWGCsv.js";import{t as ve}from"./sliders-horizontal-34K0eDW2.js";import{t as ye}from"./trash-2-BUuL4OCw.js";import{n as X}from"./dist-BLAMau9Z.js";import{t as be}from"./input-D0ZW0Opq.js";import{t as xe}from"./dist-q14fBS3T.js";import{i as Se}from"./use-settings-route-Ch_E9Uw0.js";import{t as Ce}from"./parse-api-error-C_gwkKmG.js";import{c as we,l as Te}from"./documents-events-DUo-r8o3.js";import{n as Ee}from"./config-context-gd3BC-iY.js";import{t as De}from"./use-workspace-JeP_ExdS.js";import{n as Oe}from"./clipboard-adapter-Cxzkvc1d.js";import{a as ke,d as Ae,f as je,n as Me,s as Ne,t as Pe}from"./skills-api-CYCJlMKO.js";var Fe=o(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),Ie=o(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Le=o(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Re=o(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Z=t(),Q=e(n(),1),$=a();function ze(e){return{async install(t){let n;try{n=await e.buildAndOpen(t?.force?{force:!0}:void 0)}catch(e){return{ok:!1,reason:`bridge-error`,message:e instanceof Error?e.message:String(e)}}return n.ok?{ok:!0,path:n.path}:{ok:!1,reason:n.reason,message:n.message}}}}function Be(e={}){let t=e.fetch??globalThis.fetch,n=`${e.apiOrigin??``}/api/install-skill`;return{async install(e){let r;try{r=await t(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?.force?{force:!0}:{})})}catch(e){return{ok:!1,reason:`network-error`,message:e instanceof Error?e.message:String(e)}}if(!r.ok){let e=`HTTP ${r.status}`;try{let t=Ce(await r.json());t&&(e=t)}catch{}return{ok:!1,reason:`http-error`,message:e}}let i;try{i=await r.json()}catch(e){return{ok:!1,reason:`parse-error`,message:e instanceof Error?e.message:`Invalid server response`}}return!i||typeof i.status!=`string`?{ok:!1,reason:`parse-error`,message:`Invalid server response shape`}:i.status===`failed`?{ok:!1,reason:`build-failed`,message:i.buildError??`unknown build failure`}:{ok:!0,path:i.outputPath,handoffWarning:i.handoffError?.message}}}}function Ve(){if(typeof window>`u`)return null;let e=window.okDesktop?.skill;return e?ze(e):Be()}var He=`ok:skill:cowork:installed`,Ue=`1`,We=250,Ge=`/api/skill/install-state`;function Ke(e){return`${He}:v${e}`}var qe=new Map;async function Je(e={},t={}){let n=t.force?`__force__`:`__default__`,r=qe.get(n);if(r)return r;let i=Ye(e,t);return qe.set(n,i),i.finally(()=>{qe.get(n)===i&&qe.delete(n)}),i}async function Ye(e,t){let n=e.installer===void 0?Ve():e.installer,r=Xe(e.storage),i=e.fetchSnapshot??Qe,a=e.serverTimeoutMs??We,o=null;if(!t.force){try{o=await $e(i(),a)}catch(e){console.warn(`[cowork-skill] server install-state check failed; falling through:`,e)}if(o){let e=o.targets[`claude-cowork`]??null;if(e&&e.version===o.currentVersion)return{kind:`already-installed`,source:`server`}}}let s=Ke(o?.currentVersion??e.fallbackSkillVersion??Ze());if(!t.force&&r?.getItem(s)===Ue)return{kind:`already-installed`,source:`local`};if(!n)return{kind:`host-unsupported`};let c=await n.install({force:t.force??!1});if(!c.ok)return{kind:`install-failed`,reason:c.reason,message:c.message};try{r?.setItem(s,Ue)}catch(e){console.warn(`[cowork-skill] storage.setItem failed (guard will not persist):`,e)}return{kind:`installed-now`,path:c.path,handoffWarning:c.handoffWarning}}function Xe(e){if(e!==void 0)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Ze(){return typeof window>`u`?`unknown`:window.okDesktop?.appVersion??`unknown`}async function Qe(){let e;try{e=await fetch(Ge,{method:`GET`,cache:`no-store`})}catch{return null}if(!e.ok)return null;try{let t=await e.json();return typeof t?.currentVersion==`string`?t:null}catch{return null}}async function $e(e,t){return Promise.race([e,new Promise(e=>{setTimeout(()=>e(null),t)})])}function et(e){return Je({},e)}function tt(){return Je({},{force:!0})}async function nt(e,t){let n;try{n=await t(`/api/handoff`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}catch(e){return{ok:!1,reason:`dispatch-error`,detail:e instanceof Error?e.message:String(e)}}return n.status===200?{ok:!0}:n.status===404?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned 404`}:n.status===422?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned ${n.status}`}:{ok:!1,reason:`dispatch-error`,detail:`POST /api/handoff returned ${n.status}`}}async function rt(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis);switch(e.target){case`claude-cowork`:return nt({target:`claude-cowork`,url:K({mode:`cowork`},e)},n);case`claude-code`:return nt({target:`claude-code`,url:K({mode:`code`},e)},n);case`codex`:return nt({target:`codex`,url:ne(e)},n);case`cursor`:return nt({target:`cursor`,url:re(e),workspacePath:e.projectDir},n);case`copilot`:return{ok:!1,reason:`invalid-payload`,detail:`copilot is terminal-only; launch via requestTerminalLaunch`};case`opencode`:return{ok:!1,reason:`invalid-payload`,detail:`opencode is terminal-only; launch via requestTerminalLaunch`};case`pi`:return{ok:!1,reason:`invalid-payload`,detail:`pi is terminal-only; launch via requestTerminalLaunch`};case`antigravity`:return{ok:!1,reason:`invalid-payload`,detail:`antigravity is terminal-only; launch via requestTerminalLaunch`};case`openclaw`:return{ok:!1,reason:`invalid-payload`,detail:`openclaw is terminal-only; launch via requestTerminalLaunch`};case`hermes`:return{ok:!1,reason:`invalid-payload`,detail:`hermes is terminal-only; launch via requestTerminalLaunch`};default:{let t=e.target;return{ok:!1,reason:`invalid-payload`,detail:`unknown target: ${String(t)}`}}}}async function it(e,t={}){let n=t.okDesktop??(typeof window<`u`?window.okDesktop:void 0);if(n?.shell?.recordHandoff)try{await n.shell.recordHandoff(e)}catch(e){(t.warn??(e=>console.warn(e)))(`[handoff] recordHandoff IPC rejected (telemetry skipped): ${e instanceof Error?e.message:String(e)}`)}}var at=`open-knowledge:agent-thread-launch`;function ot(e,t=typeof window>`u`?new EventTarget:window){t.dispatchEvent(new CustomEvent(at,{detail:e}))}function st(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;n&&typeof n.agentId==`string`&&e(n)};return t.addEventListener(at,n),()=>t.removeEventListener(at,n)}function ct(e){if(!e.docName||!e.workspace)return null;let t=fe(e.docName),{contentDir:n,pathSeparator:r}=e.workspace;return{docContext:{relativePath:t},projectDir:n,docPath:ue(n,t,r)}}function lt(e){return e.workspace?.contentDir?{docContext:null,projectDir:e.workspace.contentDir,docPath:``}:null}function ut(e){return e.workspace?.contentDir?{docContext:null,createDescription:e.description,createScenario:e.scenario,createMentions:e.mentions,projectDir:e.workspace.contentDir,docPath:``}:null}function dt(e){return j(e.installUrl).then(()=>void 0)}function ft(e){return!e.workspace?.contentDir||!e.folderRelativePath?null:{docContext:null,folderRelativePath:e.folderRelativePath,projectDir:e.workspace.contentDir,docPath:``}}function pt(e){return!e.workspace?.contentDir||!e.skillName?null:{docContext:null,skill:{name:e.skillName,scope:e.scope},projectDir:e.workspace.contentDir,docPath:``}}function mt(e){if(!e.workspace?.contentDir)return null;let{contentDir:t,pathSeparator:n}=e.workspace;if(e.docName){let r=e.docRelativePath??fe(e.docName),i={scope:`doc`,docRelativePath:r,instruction:e.instruction,mentions:e.mentions};return{docContext:null,compose:e.selection===void 0?i:{...i,selection:e.selection},projectDir:t,docPath:ue(t,r,n)}}return e.folderRelativePath?{docContext:null,compose:{scope:`folder`,folderRelativePath:e.folderRelativePath,instruction:e.instruction,mentions:e.mentions},projectDir:t,docPath:``}:{docContext:null,compose:{scope:`project`,instruction:e.instruction,mentions:e.mentions},projectDir:t,docPath:``}}function ht(e){return`Opened in ${e}.`}function gt(e,t=1){return t>=3?`Couldn't reach ${e} — please try again later.`:t===2?`Still couldn't reach ${e} — try one more time?`:`Couldn't reach ${e} — try again?`}function _t(e){return e>=3?null:e===2?`Try one more time`:`Retry`}function vt(e,t,n,r,i){let a=i===void 0?{}:{scope:i};return t.ok?{target:e,host:n,outcome:`ok`,ts:r,...a}:{target:e,host:n,outcome:`error`,ts:r,reason:t.reason,...a}}function yt(e,t,n,r){if(e.scope===`doc`){let i={scope:`doc`,docRelativePath:e.docRelativePath,instruction:e.instruction,mentions:e.mentions,target:t,autoOpen:n,transport:r};return e.selection===void 0?i:{...i,selection:e.selection}}return e.scope===`folder`?{scope:`folder`,folderRelativePath:e.folderRelativePath,instruction:e.instruction,mentions:e.mentions,target:t,autoOpen:n,transport:r}:{scope:`project`,instruction:e.instruction,mentions:e.mentions,target:t,autoOpen:n,transport:r}}function bt(e,t,n,r){return e.compose?F(yt(e.compose,t,n,r)):e.selection?R({...e.selection,target:t,transport:r}):e.skill?L(e.skill.name,e.skill.scope,n):e.ask?oe(e.ask.relativePath,e.ask.instruction,n,t,r):ie(e.docContext===null?e.folderRelativePath?J(e.folderRelativePath,n,e.instruction,r):e.createDescription===void 0?ae(n,e.instruction,r):W(e.createDescription,n,e.createScenario??`new-project`,e.createMentions??[],r):H(e.docContext.relativePath,n,e.instruction,r))}function xt(e,t){let n=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||n?`${G} ${bt(e,I[t].handoffTarget,!1,`terminal`)}`:B(e.docContext?.relativePath??null)}function St(e){let t=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||t?`${te} ${bt(e,`claude-code`,!1,`terminal`)}`:q(e.docContext?.relativePath??null)}function Ct(e){let t=e.docContext?.relativePath;return typeof t!=`string`||t===``?null:t.replace(/\.(md|mdx)$/,``)}function wt(e){let t=[e.compose?.instruction,e.selection?.instruction,e.ask?.instruction,e.createDescription,e.instruction];for(let e of t)if(typeof e==`string`&&e.trim()!==``)return e;return null}function Tt(e,t){ot({agentSource:t?.agent?.source??`registry`,agentId:t?.agent?.id??``,prompt:St(e),docName:Ct(e),titleHint:wt(e)})}async function Et(e,t,n,r=1){if(e===`claude-cowork`&&r===1){let e;try{e=await n.ensureCoworkSkillInstalled()}catch(e){let t=e instanceof Error?e.message:String(e);return n.toast.error(`Couldn't install OpenKnowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-error: ${t}`}}if(e.kind===`installed-now`)return n.toast.success(`OpenKnowledge skill saved. Upload it in Claude Desktop, then click Cowork again.`),{ok:!0};if(e.kind===`install-failed`){let t=e.message??e.reason;return n.toast.error(`Couldn't install OpenKnowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-failed: ${t}`}}}let i={target:e,projectDir:t.projectDir,docPath:t.docPath,prompt:bt(t,e,n.autoOpen,`url`)},a=await n.dispatchHandoff(i),o=n.isElectronHost()?`electron`:`web`,s=n.now().toISOString(),c=t.compose,l=vt(e,a,o,s,t.selection!=null||c?.scope===`doc`&&c.selection!==void 0?`selection`:void 0);await n.recordHandoff(l);let u=n.getDisplayName(e);if(a.ok)n.toast.success(ht(u));else{let i=_t(r),a=gt(u,r);i===null?n.toast.error(a):n.toast.error(a,{action:{label:i,onClick:()=>{Et(e,t,n,r+1)}}})}return a}function Dt(e){return O.find(t=>t.id===e)?.displayName??e}function Ot(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function kt(){return{dispatchHandoff:rt,recordHandoff:it,toast:{success:e=>{X.success(e)},error:(e,t)=>{X.error(e,t?{action:t.action}:void 0)}},now:()=>new Date,isElectronHost:()=>Ot(),getDisplayName:Dt,ensureCoworkSkillInstalled:et,autoOpen:!0}}function At(){let e=(0,$.c)(2),{merged:t}=Ee(),n=t?.appearance?.preview?.autoOpen??!0,r;return e[0]===n?r=e[1]:(r={dispatch:(e,t)=>Et(e,t,{...kt(),autoOpen:n}),reinstallCoworkSkill:tt},e[0]=n,e[1]=r),r}var jt=[...new Set(O.flatMap(e=>e.schemes))];function Mt(e,t){let n=t.now?.()??Date.now(),r={};for(let t of O){let i=t.schemes[0],a=i===void 0?void 0:e[i];if(!a){r[t.id]={installed:null};continue}r[t.id]={installed:a.installed,...a.displayName===void 0?{}:{displayName:a.displayName},lastChecked:n}}return r}function Nt(e){return Mt({},e)}async function Pt(e){let t=e.schemes??jt,n=await Promise.all(t.map(async t=>{let n=t.replace(/:$/,``);try{return[t,await e.detectProtocol(n)]}catch{return[t,{installed:!1}]}}));return Object.fromEntries(n)}var Ft=Object.fromEntries(jt.map(e=>[e,{installed:!1}]));async function It(e){let t;try{t=await e.fetch(`/api/installed-agents`,{signal:e.signal,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return Ft}if(!t.ok)return Ft;let n;try{n=await t.json()}catch{return Ft}if(typeof n!=`object`||!n||Array.isArray(n))return Ft;let r=n,i={};for(let e of jt)i[e]={installed:r[e.replace(/:$/,``)]===!0};return i}function Lt(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.installed!==i.installed||n.displayName!==i.displayName)return!1}return!0}function Rt(e){let t=e.throttleMs??1e4,n=!1,r=null,i=null,a={},o=Nt({isElectronHost:e.isElectronHost(),now:e.now}),s=new Set,c=()=>{if(!n)for(let e of s)e(o)},l=()=>{o=Mt(a,{isElectronHost:e.isElectronHost(),now:e.now})};return{probe:async()=>{if(n)return;if(i)return i;if(r!==null&&e.now()-r<t)return;let o=(async()=>{try{let t=await e.probe();if(n)return;let i=!Lt(a,t);a=t,i&&(l(),c()),r=e.now()}catch{}finally{i=null}})();return i=o,o},getTargetStates:()=>o,subscribe:e=>(s.add(e),()=>{s.delete(e)}),cancel:()=>{n=!0,s.clear()}}}function zt(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function Bt(){let e=typeof window<`u`?window.okDesktop:void 0;if(e){let t=t=>e.shell.detectProtocol(t);return{probe:()=>Pt({detectProtocol:t}),isElectronHost:()=>!0,now:Date.now}}let t=globalThis.fetch.bind(globalThis);return{probe:()=>It({fetch:t}),isElectronHost:()=>!1,now:Date.now}}function Vt(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(Ht),r=(0,Q.useRef)(null),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=Rt(Bt());r.current=e;let t=e.subscribe(n);e.probe();let i=()=>{e.probe()};return window.addEventListener(`focus`,i),()=>{window.removeEventListener(`focus`,i),t(),e.cancel(),r.current=null}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),(0,Q.useEffect)(i,a);let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r.current?.probe()??Promise.resolve(),e[2]=o):o=e[2];let s;return e[3]===t?s=e[4]:(s={states:t,refresh:o},e[3]=t,e[4]=s),s}function Ht(){return Nt({isElectronHost:zt(),now:Date.now})}var Ut=(0,Q.createContext)(null);function Wt(e){let t=(0,$.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsx)(Ut,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function Gt(){return(0,Q.use)(Ut)}function Kt(e){let t=(0,$.c)(48),{itemName:n,isSubmitting:a,onDelete:o,customTitle:h,customDescription:g,customDetail:_,customConfirmLabel:v,customConfirmLabelBusy:y,children:b}=e,{_:x}=i(),S;t[0]!==x||t[1]!==n?(S=n??x({id:`L3CEC1`}),t[0]=x,t[1]=n,t[2]=S):S=t[2];let C=S,w;t[3]!==x||t[4]!==v?(w=v??x({id:`cnGeoo`}),t[3]=x,t[4]=v,t[5]=w):w=t[5];let T=w,E;t[6]!==x||t[7]!==v||t[8]!==y?(E=y??v??x({id:`s3caR3`}),t[6]=x,t[7]=v,t[8]=y,t[9]=E):E=t[9];let D=E,O;t[10]!==x||t[11]!==h||t[12]!==C?(O=h??x({id:`77SdEP`,values:{itemName:C}}),t[10]=x,t[11]=h,t[12]=C,t[13]=O):O=t[13];let k;t[14]===O?k=t[15]:(k=(0,Z.jsx)(l,{children:O}),t[14]=O,t[15]=k);let A;t[16]!==x||t[17]!==g||t[18]!==C?(A=g??x({id:`16D5Zj`,values:{itemName:C}}),t[16]=x,t[17]=g,t[18]=C,t[19]=A):A=t[19];let j;t[20]===A?j=t[21]:(j=(0,Z.jsx)(c,{className:`whitespace-pre-wrap`,children:A}),t[20]=A,t[21]=j);let M;t[22]===_?M=t[23]:(M=_?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`delete-confirmation-detail`,children:_}):null,t[22]=_,t[23]=M);let N;t[24]!==k||t[25]!==j||t[26]!==M?(N=(0,Z.jsxs)(m,{children:[k,j,M]}),t[24]=k,t[25]=j,t[26]=M,t[27]=N):N=t[27];let P;t[28]===b?P=t[29]:(P=b?(0,Z.jsx)(d,{children:b}):null,t[28]=b,t[29]=P);let F;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(r,{id:`dEgA5A`}),t[30]=F):F=t[30];let I;t[31]===a?I=t[32]:(I=(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(s,{variant:`outline`,disabled:a,children:F})}),t[31]=a,t[32]=I);let L;t[33]!==T||t[34]!==D||t[35]!==a?(L=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ge,{className:`size-4 animate-spin`}),` `,D]}):T,t[33]=T,t[34]=D,t[35]=a,t[36]=L):L=t[36];let R;t[37]!==a||t[38]!==o||t[39]!==L?(R=(0,Z.jsx)(s,{variant:`destructive`,onClick:o,disabled:a,children:L}),t[37]=a,t[38]=o,t[39]=L,t[40]=R):R=t[40];let z;t[41]!==I||t[42]!==R?(z=(0,Z.jsxs)(f,{children:[I,R]}),t[41]=I,t[42]=R,t[43]=z):z=t[43];let B;return t[44]!==P||t[45]!==z||t[46]!==N?(B=(0,Z.jsxs)(u,{children:[N,P,z]}),t[44]=P,t[45]=z,t[46]=N,t[47]=B):B=t[47],B}function qt(e){return e?xe._({id:`wTcjov`}):null}function Jt(e){let t=(0,$.c)(47),{_:n}=i(),a=de(),o=Gt(),s=w(),c=E();if(a)return null;let{input:l,installStates:u,dispatch:d,onBeforeLaunch:f}=e,p=l===null,m,h,C,O,j,F,L,R,z,B,V;if(t[0]!==n||t[1]!==d||t[2]!==l||t[3]!==p||t[4]!==u||t[5]!==f||t[6]!==c||t[7]!==s||t[8]!==o){let e=qt(p),i;t[20]===c?i=t[21]:(i=e=>P(c,e.id),t[20]=c,t[21]=i);let a=D.filter(i),w;t[22]===c?w=t[23]:(w=e=>k(c,e.source,e.id,!0,e.supported),t[22]=c,t[23]=w);let E=s.filter(w),H=o?U.filter(e=>M(c,e,o.installedClis)):[];C=a.length>0,O=o!==null&&H.length>0,j=E.length>0,h=_,t[24]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsxs)(x,{children:[(0,Z.jsx)(le,{"aria-hidden":`true`}),(0,Z.jsx)(r,{id:`O7_W_a`})]}),t[24]=V):V=t[24],m=v,F=`max-h-80`,L=j?(0,Z.jsxs)(y,{"aria-label":n({id:`vPKX2i`}),children:[(0,Z.jsxs)(b,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(r,{id:`RXEbZy`}),(0,Z.jsx)(N,{})]}),E.map(t=>{let i=t.name;return(0,Z.jsxs)(g,{onSelect:()=>{l!==null&&(f?.(),Tt(l,{agent:{source:t.source,id:t.id}}))},disabled:p,"data-testid":`file-tree-open-in-thread-${t.id}`,"aria-label":e?n({id:`gtGQ9S`,values:{agentName:i,hint:e}}):void 0,children:[(0,Z.jsx)(Y,{agentId:t.id,iconUrl:t.iconUrl,className:`size-4`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(r,{id:`5PrrYw`,values:{agentName:i}})}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},`${t.source}:${t.id}`)})]}):null,t[25]!==C||t[26]!==O||t[27]!==j?(R=j&&(O||C)?(0,Z.jsx)(S,{}):null,t[25]=C,t[26]=O,t[27]=j,t[28]=R):R=t[28],z=O?(0,Z.jsxs)(y,{"aria-label":n({id:`ALhMYW`}),children:[(0,Z.jsx)(b,{children:(0,Z.jsx)(r,{id:`ALhMYW`})}),H.map(t=>{let{displayName:r}=I[t];return(0,Z.jsxs)(g,{onSelect:()=>{l!==null&&(f?.(),o.launchInTerminal(l,t))},disabled:p,"data-testid":`file-tree-open-in-terminal-${t}`,"aria-label":n(e?{id:`AIn2Yv`,values:{displayName:r,hint:e}}:{id:`QYfQdv`,values:{displayName:r}}),children:[(0,Z.jsx)(A,{id:T(t),"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:r}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t)})]}):null,B=C?(0,Z.jsxs)(Z.Fragment,{children:[O?(0,Z.jsx)(S,{}):null,(0,Z.jsxs)(y,{"aria-label":n({id:`BBqGS9`}),children:[(0,Z.jsx)(b,{children:(0,Z.jsx)(r,{id:`BBqGS9`})}),a.map(t=>{let r=!p,{displayName:i}=t,a=n(e?{id:`1ZpfyB`,values:{displayName:i,hint:e}}:{id:`WqLq6M`,values:{displayName:i}});return(0,Z.jsxs)(g,{disabled:!r,onSelect:()=>{if(l){if(f?.(),u[t.id]?.installed!==!0){dt(t);return}d(t.id,l)}},"data-testid":`file-tree-open-in-${t.id}`,"aria-label":a,children:[(0,Z.jsx)(A,{id:t.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:t.displayName}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)})]})]}):null,t[0]=n,t[1]=d,t[2]=l,t[3]=p,t[4]=u,t[5]=f,t[6]=c,t[7]=s,t[8]=o,t[9]=m,t[10]=h,t[11]=C,t[12]=O,t[13]=j,t[14]=F,t[15]=L,t[16]=R,t[17]=z,t[18]=B,t[19]=V}else m=t[9],h=t[10],C=t[11],O=t[12],j=t[13],F=t[14],L=t[15],R=t[16],z=t[17],B=t[18],V=t[19];let H;t[29]!==C||t[30]!==O||t[31]!==j?(H=j||O||C?(0,Z.jsx)(S,{}):null,t[29]=C,t[30]=O,t[31]=j,t[32]=H):H=t[32];let W;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(ve,{"aria-hidden":`true`}),t[33]=W):W=t[33];let G;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsxs)(g,{onSelect:Se,"data-testid":`file-tree-open-in-settings`,children:[W,(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(r,{id:`jRAGrQ`})})]}),t[34]=G):G=t[34];let K;t[35]!==m||t[36]!==F||t[37]!==L||t[38]!==R||t[39]!==z||t[40]!==B||t[41]!==H?(K=(0,Z.jsxs)(m,{className:F,children:[L,R,z,B,H,G]}),t[35]=m,t[36]=F,t[37]=L,t[38]=R,t[39]=z,t[40]=B,t[41]=H,t[42]=K):K=t[42];let q;return t[43]!==h||t[44]!==V||t[45]!==K?(q=(0,Z.jsxs)(h,{children:[V,K]}),t[43]=h,t[44]=V,t[45]=K,t[46]=q):q=t[46],q}function Yt(e){let t=(0,$.c)(8),n=e?.enabled??!0,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={status:`idle`},t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(0),c,l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=()=>s($t),t=Te(e),n=we(t=>{t.includes(`files`)&&e()});return()=>{t(),n()}},l=[],t[1]=c,t[2]=l):(c=t[1],l=t[2]),(0,Q.useEffect)(c,l);let u;t[3]===n?u=t[4]:(u=()=>{if(!n)return;let e=!1;return a(Qt),fetch(`/api/skills`).then(Xt).then(t=>{if(e)return;let n=V.safeParse(t);if(!n.success){console.error(`[ok-skills] /api/skills response failed schema validation:`,n.error.issues),a({status:`error`,message:`Server returned an incomplete skills response.`});return}a({status:`ready`,data:n.data.skills})}).catch(t=>{e||a({status:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},t[3]=n,t[4]=u);let d;return t[5]!==n||t[6]!==o?(d=[o,n],t[5]=n,t[6]=o,t[7]=d):d=t[7],(0,Q.useEffect)(u,d),i}async function Xt(e){if(!e.ok){let t=await e.json().catch(Zt);throw Error(Ce(t)??`HTTP ${e.status}`)}return e.json()}function Zt(){return null}function Qt(e){return e.status===`ready`?e:{status:`loading`}}function $t(e){return e+1}function en(e){let t=(0,$.c)(16),{skill:n,onOpenChange:r,onDeleted:a}=e,{_:o}=i(),[s,c]=(0,Q.useState)(!1),l;t[0]!==o||t[1]!==a||t[2]!==r?(l=async function(e){c(!0);let t=await Pe(e.scope,e.name);if(c(!1),!t.ok){let{error:e}=t;X.error(o({id:`AtBdnD`,values:{error:e}}));return}X.success(o({id:`h9QFb9`,values:{0:e.name}})),a(),r(!1)},t[0]=o,t[1]=a,t[2]=r,t[3]=l):l=t[3];let u=l,d=n!==null,f;t[4]!==s||t[5]!==r?(f=e=>{!e&&!s&&r(!1)},t[4]=s,t[5]=r,t[6]=f):f=t[6];let p;t[7]!==o||t[8]!==s||t[9]!==u||t[10]!==n?(p=n?(0,Z.jsx)(Kt,{itemName:o({id:`ExUzM4`,values:{0:n.name}}),isSubmitting:s,onDelete:()=>u(n),customDescription:o({id:`E1Da_b`,values:{0:n.path}})}):null,t[7]=o,t[8]=s,t[9]=u,t[10]=n,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,Z.jsx)(h,{open:d,onOpenChange:f,children:p}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15],m}function tn(e){let t=(0,$.c)(68),{skill:n,existingNames:a,onOpenChange:o,onRenamed:d}=e,{_:p}=i(),g=n!==null,_=(0,Q.useId)(),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),S;t[0]===n?S=t[1]:(S=()=>{n&&y(n.name)},t[0]=n,t[1]=S);let w=n?.scope,T=n?.name,E;if(t[2]!==w||t[3]!==T?(E=[w,T],t[2]=w,t[3]=T,t[4]=E):E=t[4],(0,Q.useEffect)(S,E),!n)return null;let D,O,k,A;t[5]!==a||t[6]!==v||t[7]!==n.name?(k=v.trim(),A=k===n.name,D=k===``||!ee.test(k),O=!D&&!A&&a.has(k),t[5]=a,t[6]=v,t[7]=n.name,t[8]=D,t[9]=O,t[10]=k,t[11]=A):(D=t[8],O=t[9],k=t[10],A=t[11]);let j=O,M=!D&&!j&&!A&&!b,N;t[12]!==p||t[13]!==M||t[14]!==o||t[15]!==d||t[16]!==n||t[17]!==k?(N=async function(){if(!n||!M)return;x(!0);let e=await Ne({scope:n.scope,fromName:n.name,toName:k});if(x(!1),!e.ok){X.error(p({id:`zKxoPm`,values:{0:n.name,1:e.error}}));return}X.success(p({id:`dUCQo4`,values:{trimmed:k}})),d?.(k),o(!1)},t[12]=p,t[13]=M,t[14]=o,t[15]=d,t[16]=n,t[17]=k,t[18]=N):N=t[18];let P=N,F;t[19]===o?F=t[20]:(F=e=>e?null:o(!1),t[19]=o,t[20]=F);let I;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(l,{children:(0,Z.jsx)(r,{id:`dw_3cv`})}),t[21]=I):I=t[21];let L;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsxs)(m,{children:[I,(0,Z.jsx)(c,{children:(0,Z.jsx)(r,{id:`R9IDFz`})})]}),t[22]=L):L=t[22];let R;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(r,{id:`6YtxFj`}),t[23]=R):R=t[23];let z;t[24]===_?z=t[25]:(z=(0,Z.jsx)(C,{htmlFor:_,children:R}),t[24]=_,t[25]=z);let B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>y(e.target.value),t[26]=B):B=t[26];let V;t[27]===P?V=t[28]:(V=e=>{e.key===`Enter`&&P()},t[27]=P,t[28]=V);let H=D||j,U=D&&k!==``||j?`${_}-error`:void 0,W;t[29]!==_||t[30]!==v||t[31]!==V||t[32]!==H||t[33]!==U?(W=(0,Z.jsx)(be,{id:_,value:v,onChange:B,onKeyDown:V,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-invalid":H,"aria-describedby":U,className:`font-mono`}),t[29]=_,t[30]=v,t[31]=V,t[32]=H,t[33]=U,t[34]=W):W=t[34];let G;t[35]!==j||t[36]!==_||t[37]!==D||t[38]!==k?(G=D&&k!==``?(0,Z.jsx)(`p`,{id:`${_}-error`,className:`text-xs text-destructive`,children:(0,Z.jsx)(r,{id:`A50vr3`,components:{0:(0,Z.jsx)(`code`,{className:`font-mono`})}})}):j?(0,Z.jsx)(`p`,{id:`${_}-error`,className:`text-xs text-destructive`,children:(0,Z.jsx)(r,{id:`YJ1BTp`})}):null,t[35]=j,t[36]=_,t[37]=D,t[38]=k,t[39]=G):G=t[39];let K;t[40]!==z||t[41]!==W||t[42]!==G?(K=(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[z,W,G]}),t[40]=z,t[41]=W,t[42]=G,t[43]=K):K=t[43];let q;t[44]===o?q=t[45]:(q=()=>o(!1),t[44]=o,t[45]=q);let te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(r,{id:`dEgA5A`}),t[46]=te):te=t[46];let ne;t[47]!==b||t[48]!==q?(ne=(0,Z.jsx)(s,{variant:`ghost`,onClick:q,disabled:b,children:te}),t[47]=b,t[48]=q,t[49]=ne):ne=t[49];let re;t[50]===P?re=t[51]:(re=()=>void P(),t[50]=P,t[51]=re);let ie=!M,J;t[52]===b?J=t[53]:(J=b?(0,Z.jsx)(r,{id:`tHKQ6j`}):(0,Z.jsx)(r,{id:`2wxgft`}),t[52]=b,t[53]=J);let ae;t[54]!==re||t[55]!==ie||t[56]!==J?(ae=(0,Z.jsx)(s,{onClick:re,disabled:ie,children:J}),t[54]=re,t[55]=ie,t[56]=J,t[57]=ae):ae=t[57];let oe;t[58]!==ne||t[59]!==ae?(oe=(0,Z.jsxs)(f,{children:[ne,ae]}),t[58]=ne,t[59]=ae,t[60]=oe):oe=t[60];let Y;t[61]!==K||t[62]!==oe?(Y=(0,Z.jsxs)(u,{children:[L,K,oe]}),t[61]=K,t[62]=oe,t[63]=Y):Y=t[63];let se;return t[64]!==g||t[65]!==Y||t[66]!==F?(se=(0,Z.jsx)(h,{open:g,onOpenChange:F,children:Y}),t[64]=g,t[65]=Y,t[66]=F,t[67]=se):se=t[67],se}function nn(e){let t=(0,$.c)(15),{skill:n,onOpenChange:a,onUpdated:o}=e,{_:g}=i(),[_,v]=(0,Q.useState)(!1),y;t[0]!==g||t[1]!==a||t[2]!==o?(y=async function(e){v(!0);let t=await je({scope:e.scope,name:e.name});v(!1);let n=se(e.name);if(!t.ok){X.error(g({id:`FRqZ9v`,values:{0:t.error}}));return}X.success(t.checkpointRef?g({id:`My9uXI`,values:{0:t.version,display:n}}):g({id:`mPneVR`,values:{0:t.version,display:n}})),o(),a(!1)},t[0]=g,t[1]=a,t[2]=o,t[3]=y):y=t[3];let b=y,x=n!==null,S;t[4]!==a||t[5]!==_?(S=e=>{!e&&!_&&a(!1)},t[4]=a,t[5]=_,t[6]=S):S=t[6];let C;t[7]!==b||t[8]!==n||t[9]!==_?(C=n?(0,Z.jsxs)(u,{className:`sm:max-w-lg`,children:[(0,Z.jsxs)(m,{children:[(0,Z.jsx)(l,{children:(0,Z.jsx)(r,{id:`iAoh55`,values:{0:se(n.name)}})}),(0,Z.jsx)(c,{children:n.installedVersion?(0,Z.jsx)(r,{id:`47EXvY`,values:{0:n.bundledVersion??``,1:n.installedVersion}}):(0,Z.jsx)(r,{id:`nD7Fx9`,values:{0:n.bundledVersion??``}})})]}),(0,Z.jsx)(d,{}),(0,Z.jsxs)(f,{children:[(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(s,{variant:`outline`,disabled:_,children:(0,Z.jsx)(r,{id:`dEgA5A`})})}),(0,Z.jsx)(s,{onClick:()=>void b(n),disabled:_,children:_?(0,Z.jsx)(r,{id:`JL3si7`}):(0,Z.jsx)(r,{id:`EkH9pt`})})]})]}):null,t[7]=b,t[8]=n,t[9]=_,t[10]=C):C=t[10];let w;return t[11]!==x||t[12]!==S||t[13]!==C?(w=(0,Z.jsx)(h,{open:x,onOpenChange:S,children:C}),t[11]=x,t[12]=S,t[13]=C,t[14]=w):w=t[14],w}function rn(){let e=(0,$.c)(30),{_:t}=i(),[n,r]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),d;e[0]===t?d=e[1]:(d=async function(e,n){u(e.name);let r=await ke({scope:e.scope,name:e.name,...n?{targets:[...n]}:{}});if(u(null),!r.ok)return X.error(t({id:`Mj8R8K`,values:{0:r.error}})),r;let i=an,a=new Set(r.hosts),o=r.hosts.filter(t=>!e.hosts.includes(t)),s=e.hosts.filter(e=>!a.has(e)),c=e=>{let t=r.warningCodes.indexOf(e);return t>=0?r.warnings[t]:void 0},l=c(`no-targets`);if(l)return X.warning(l),r;if(o.length>0){let e=c(`scripts-present`);e&&X.warning(e)}return r.hosts.length===0?X.success(t({id:`0LBDjY`,values:{0:e.name}})):o.length>0&&s.length===0?X.success(t({id:`PPFQ3o`,values:{0:e.name,1:i(o)}})):s.length>0&&o.length===0?X.success(t({id:`OOIVJo`,values:{0:e.name,1:i(s)}})):o.length>0&&s.length>0?X.success(t({id:`OxplNM`,values:{0:e.name,1:i(o),2:i(s)}})):X.success(t({id:`wDgmsr`,values:{0:e.name,1:i(r.hosts)}})),r},e[0]=t,e[1]=d);let f=d,p;e[2]===t?p=e[3]:(p=async function(e){u(e.name);let n=await Ae({scope:e.scope,name:e.name});return u(null),n.ok?X.success(t({id:`0LBDjY`,values:{0:e.name}})):X.error(t({id:`nJq7et`,values:{0:n.error}})),n},e[2]=t,e[3]=p);let m=p,h;e[4]===t?h=e[5]:(h=async function(e,n){let r=await Me({scope:e.scope,name:e.name,existingNames:n});if(!r.ok){X.error(t({id:`UPjaXD`,values:{0:e.name,1:r.error}}));return}X.success(t({id:`0g7rCZ`,values:{0:r.name}}))},e[4]=t,e[5]=h);let g=h,_,v;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{e||r(null)},v=()=>r(null),e[6]=_,e[7]=v):(_=e[6],v=e[7]);let y;e[8]===n?y=e[9]:(y=(0,Z.jsx)(en,{skill:n,onOpenChange:_,onDeleted:v}),e[8]=n,e[9]=y);let b=a?.skill??null,x=a?.existingNames??sn,S,C;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e||o(null)},C=()=>o(null),e[10]=S,e[11]=C):(S=e[10],C=e[11]);let w;e[12]!==b||e[13]!==x?(w=(0,Z.jsx)(tn,{skill:b,existingNames:x,onOpenChange:S,onRenamed:C}),e[12]=b,e[13]=x,e[14]=w):w=e[14];let T,E;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||c(null)},E=()=>c(null),e[15]=T,e[16]=E):(T=e[15],E=e[16]);let D;e[17]===s?D=e[18]:(D=(0,Z.jsx)(nn,{skill:s,onOpenChange:T,onUpdated:E}),e[17]=s,e[18]=D);let O;e[19]!==w||e[20]!==D||e[21]!==y?(O=(0,Z.jsxs)(Z.Fragment,{children:[y,w,D]}),e[19]=w,e[20]=D,e[21]=y,e[22]=O):O=e[22];let k=O,A;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(A=(e,t)=>o({skill:e,existingNames:t}),e[23]=A):A=e[23];let j;return e[24]!==k||e[25]!==g||e[26]!==f||e[27]!==l||e[28]!==m?(j={installingName:l,install:f,uninstall:m,duplicate:g,requestDelete:r,requestRename:A,requestUpdate:c,dialogs:k},e[24]=k,e[25]=g,e[26]=f,e[27]=l,e[28]=m,e[29]=j):j=e[29],j}function an(e){return e.map(on).join(`, `)}function on(e){return z[e]??e}var sn=new Set;function cn(e){let t=(0,$.c)(19),{skill:n,onEdit:i,onInstall:a,onUninstall:o,onDelete:s}=e,c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(pe,{"aria-hidden":!0}),l=(0,Z.jsx)(r,{id:`ePK91l`}),t[0]=c,t[1]=l):(c=t[0],l=t[1]);let u;t[2]===i?u=t[3]:(u=(0,Z.jsxs)(g,{onSelect:i,children:[c,l]}),t[2]=i,t[3]=u);let d;t[4]!==a||t[5]!==n.installed?(d=a&&!n.installed?(0,Z.jsxs)(g,{onSelect:a,children:[(0,Z.jsx)(Fe,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`TKQ7K-`})]}):null,t[4]=a,t[5]=n.installed,t[6]=d):d=t[6];let f;t[7]!==o||t[8]!==n.installed?(f=n.installed?(0,Z.jsxs)(g,{onSelect:o,children:[(0,Z.jsx)(Re,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`fo0VXg`})]}):null,t[7]=o,t[8]=n.installed,t[9]=f):f=t[9];let p,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(ye,{"aria-hidden":!0}),m=(0,Z.jsx)(r,{id:`cnGeoo`}),t[10]=p,t[11]=m):(p=t[10],m=t[11]);let h;t[12]===s?h=t[13]:(h=(0,Z.jsxs)(g,{variant:`destructive`,onSelect:s,children:[p,m]}),t[12]=s,t[13]=h);let _;return t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==h?(_=(0,Z.jsxs)(Z.Fragment,{children:[u,d,f,h]}),t[14]=u,t[15]=d,t[16]=f,t[17]=h,t[18]=_):_=t[18],_}function ln(e){let t=(0,$.c)(94),{skill:n,actions:a,existingNames:o}=e,{_:s}=i(),c=De(),l=Vt().states,{dispatch:u}=At(),d=typeof window<`u`?window.okDesktop:void 0,f=n.absolutePath,p;t[0]===s?p=t[1]:(p=async function(e){try{await Oe(e),X.success(s({id:`SXCSQd`}))}catch{X.error(s({id:`cRHuuI`}))}},t[0]=s,t[1]=p);let m=p;if(n.managed){let e,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(b,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Z.jsx)(Ie,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(r,{id:`VITWk5`})]}),i=(0,Z.jsx)(S,{}),t[2]=e,t[3]=i):(e=t[2],i=t[3]);let a;t[4]===f?a=t[5]:(a=d&&f?(0,Z.jsxs)(g,{onSelect:()=>void d.shell.showItemInFolder(f),children:[(0,Z.jsx)(he,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`LtSYdi`})]}):null,t[4]=f,t[5]=a);let o;t[6]!==n.name||t[7]!==n.scope||t[8]!==c?(o=pt({skillName:n.name,scope:n.scope,workspace:c}),t[6]=n.name,t[7]=n.scope,t[8]=c,t[9]=o):o=t[9];let s;t[10]!==u||t[11]!==l||t[12]!==o?(s=(0,Z.jsx)(Jt,{input:o,installStates:l,isElectronHost:d!=null,dispatch:u}),t[10]=u,t[11]=l,t[12]=o,t[13]=s):s=t[13];let p;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsxs)(x,{children:[(0,Z.jsx)(me,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`zd00pH`})]}),t[14]=p):p=t[14];let h;t[15]!==f||t[16]!==m?(h=f?(0,Z.jsx)(g,{onSelect:()=>void m(f),children:(0,Z.jsx)(r,{id:`z2funE`})}):null,t[15]=f,t[16]=m,t[17]=h):h=t[17];let y;t[18]!==m||t[19]!==n.path?(y=()=>void m(n.path),t[18]=m,t[19]=n.path,t[20]=y):y=t[20];let C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(r,{id:`xloBjn`}),t[21]=C):C=t[21];let w;t[22]===y?w=t[23]:(w=(0,Z.jsx)(g,{onSelect:y,children:C}),t[22]=y,t[23]=w);let T;t[24]!==w||t[25]!==h?(T=(0,Z.jsxs)(_,{children:[p,(0,Z.jsxs)(v,{children:[h,w]})]}),t[24]=w,t[25]=h,t[26]=T):T=t[26];let E;return t[27]!==T||t[28]!==a||t[29]!==s?(E=(0,Z.jsxs)(Z.Fragment,{children:[e,i,a,s,T]}),t[27]=T,t[28]=a,t[29]=s,t[30]=E):E=t[30],E}let h;t[31]===f?h=t[32]:(h=d&&f?(0,Z.jsxs)(g,{onSelect:()=>void d.shell.showItemInFolder(f),children:[(0,Z.jsx)(he,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`LtSYdi`})]}):null,t[31]=f,t[32]=h);let y;t[33]!==n.name||t[34]!==n.scope||t[35]!==c?(y=pt({skillName:n.name,scope:n.scope,workspace:c}),t[33]=n.name,t[34]=n.scope,t[35]=c,t[36]=y):y=t[36];let C;t[37]!==u||t[38]!==l||t[39]!==y?(C=(0,Z.jsx)(Jt,{input:y,installStates:l,isElectronHost:d!=null,dispatch:u}),t[37]=u,t[38]=l,t[39]=y,t[40]=C):C=t[40];let w;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsxs)(x,{children:[(0,Z.jsx)(me,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`zd00pH`})]}),t[41]=w):w=t[41];let T;t[42]!==f||t[43]!==m?(T=f?(0,Z.jsx)(g,{onSelect:()=>void m(f),children:(0,Z.jsx)(r,{id:`z2funE`})}):null,t[42]=f,t[43]=m,t[44]=T):T=t[44];let E;t[45]!==m||t[46]!==n.path?(E=()=>void m(n.path),t[45]=m,t[46]=n.path,t[47]=E):E=t[47];let D;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(r,{id:`xloBjn`}),t[48]=D):D=t[48];let O;t[49]===E?O=t[50]:(O=(0,Z.jsx)(g,{onSelect:E,children:D}),t[49]=E,t[50]=O);let k;t[51]!==T||t[52]!==O?(k=(0,Z.jsxs)(_,{children:[w,(0,Z.jsxs)(v,{children:[T,O]})]}),t[51]=T,t[52]=O,t[53]=k):k=t[53];let A;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(S,{}),t[54]=A):A=t[54];let j;t[55]!==a||t[56]!==o||t[57]!==n?(j=()=>void a.duplicate(n,o),t[55]=a,t[56]=o,t[57]=n,t[58]=j):j=t[58];let M,N;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(ce,{"aria-hidden":!0}),N=(0,Z.jsx)(r,{id:`euc6Ns`}),t[59]=M,t[60]=N):(M=t[59],N=t[60]);let P;t[61]===j?P=t[62]:(P=(0,Z.jsxs)(g,{onSelect:j,children:[M,N]}),t[61]=j,t[62]=P);let F;t[63]!==a||t[64]!==o||t[65]!==n?(F=()=>a.requestRename(n,o),t[63]=a,t[64]=o,t[65]=n,t[66]=F):F=t[66];let I,L;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(Le,{"aria-hidden":!0}),L=(0,Z.jsx)(r,{id:`2wxgft`}),t[67]=I,t[68]=L):(I=t[67],L=t[68]);let R;t[69]===F?R=t[70]:(R=(0,Z.jsxs)(g,{onSelect:F,children:[I,L]}),t[69]=F,t[70]=R);let z;t[71]!==a||t[72]!==n?(z=n.updateAvailable?(0,Z.jsxs)(g,{onSelect:()=>a.requestUpdate(n),children:[(0,Z.jsx)(_e,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`6g2jsp`})]}):null,t[71]=a,t[72]=n,t[73]=z):z=t[73];let B;t[74]!==a||t[75]!==n?(B=n.installed?(0,Z.jsxs)(g,{onSelect:()=>void a.uninstall(n),children:[(0,Z.jsx)(Re,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`fo0VXg`})]}):(0,Z.jsxs)(g,{onSelect:()=>void a.install(n),children:[(0,Z.jsx)(Fe,{"aria-hidden":!0}),(0,Z.jsx)(r,{id:`TKQ7K-`})]}),t[74]=a,t[75]=n,t[76]=B):B=t[76];let V;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(S,{}),t[77]=V):V=t[77];let H;t[78]!==a||t[79]!==n?(H=()=>a.requestDelete(n),t[78]=a,t[79]=n,t[80]=H):H=t[80];let U,W;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(ye,{"aria-hidden":!0}),W=(0,Z.jsx)(r,{id:`cnGeoo`}),t[81]=U,t[82]=W):(U=t[81],W=t[82]);let G;t[83]===H?G=t[84]:(G=(0,Z.jsxs)(g,{variant:`destructive`,onSelect:H,children:[U,W]}),t[83]=H,t[84]=G);let K;return t[85]!==k||t[86]!==P||t[87]!==R||t[88]!==h||t[89]!==z||t[90]!==B||t[91]!==G||t[92]!==C?(K=(0,Z.jsxs)(Z.Fragment,{children:[h,C,k,A,P,R,z,B,V,G]}),t[85]=k,t[86]=P,t[87]=R,t[88]=h,t[89]=z,t[90]=B,t[91]=G,t[92]=C,t[93]=K):K=t[93],K}export{Fe as C,Ie as S,Dt as _,Jt as a,At as b,Gt as c,ut as d,ft as f,xt as g,pt as h,Yt as i,Vt as l,lt as m,ln as n,Kt as o,ct as p,rn as r,Wt as s,cn as t,mt as u,dt as v,st as x,Tt as y};
@@ -1,2 +1,2 @@
1
- import{H as e}from"./CodeMirrorPropInput-B4tL-3Ht.js";import{$ as t,B as n,C as r,N as i,S as a,V as o,et as s,f as c,v as l,y as u,z as d}from"./config-provider-CvXAYjor.js";import{$ as f,Dt as p,J as m,Mt as h,Q as g,St as _,X as v,kt as y}from"./dist-DNwOaDhC.js";var b=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:i(this.yanchor),yhead:i(this.yhead)}}static fromJSON(t){return new e(a(t.yanchor),a(t.yhead))}},x=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new c(e)}toYPos(e,t=0){return r(this.ytext,e,t)}fromYPos(e){let t=u(a(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new b(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?p.cursor(n.pos,n.assoc):p.range(t.pos,n.pos)}},S=y.define({combine(e){return e[e.length-1]}}),C=_.define(),w=class{constructor(e){this.view=e,this.conf=e.state.facet(S),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[C.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(C)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
1
+ import{H as e}from"./CodeMirrorPropInput-CUPvWzYm.js";import{$ as t,B as n,C as r,N as i,S as a,V as o,et as s,f as c,v as l,y as u,z as d}from"./config-provider--LBV5X-F.js";import{$ as f,Dt as p,J as m,Mt as h,Q as g,St as _,X as v,kt as y}from"./dist-DNwOaDhC.js";var b=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:i(this.yanchor),yhead:i(this.yhead)}}static fromJSON(t){return new e(a(t.yanchor),a(t.yhead))}},x=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new c(e)}toYPos(e,t=0){return r(this.ytext,e,t)}fromYPos(e){let t=u(a(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new b(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?p.cursor(n.pos,n.assoc):p.range(t.pos,n.pos)}},S=y.define({combine(e){return e[e.length-1]}}),C=_.define(),w=class{constructor(e){this.view=e,this.conf=e.state.facet(S),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[C.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(C)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
2
2
  `);e!==r&&t.delete(e+n,r-e),s.length>0&&t.insert(e+n,s),n+=s.length-(r-e)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}},T=g.fromClass(w),E=v.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:`0px 2px 0px 4px`},".cm-ySelectionCaret":{position:`relative`,borderLeft:`1px solid black`,borderRight:`1px solid black`,marginLeft:`-1px`,marginRight:`-1px`,boxSizing:`border-box`,display:`inline`},".cm-ySelectionCaretDot":{borderRadius:`50%`,position:`absolute`,width:`.4em`,height:`.4em`,top:`-.2em`,left:`-.2em`,backgroundColor:`inherit`,transition:`transform .3s ease-in-out`,boxSizing:`border-box`},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:`bottom center`,transform:`scale(0)`},".cm-ySelectionInfo":{position:`absolute`,top:`-1.05em`,left:`-1px`,fontSize:`.75em`,fontFamily:`serif`,fontStyle:`normal`,fontWeight:`normal`,lineHeight:`normal`,userSelect:`none`,color:`white`,paddingLeft:`2px`,paddingRight:`2px`,zIndex:101,transition:`opacity .3s ease-in-out`,backgroundColor:`inherit`,opacity:0,transitionDelay:`0s`,whiteSpace:`nowrap`},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:`0s`}}),D=_.define(),O=class extends f{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return d(`span`,[o(`class`,`cm-ySelectionCaret`),o(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[n(`⁠`),d(`div`,[o(`class`,`cm-ySelectionCaretDot`)]),n(`⁠`),d(`div`,[o(`class`,`cm-ySelectionInfo`)],[n(this.name)]),n(`⁠`)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},k=class{constructor(e){this.conf=e.state.facet(S),this._listener=({added:t,updated:n,removed:r},i,a)=>{t.concat(n).concat(r).findIndex(e=>e!==this.conf.awareness.doc.clientID)>=0&&e.dispatch({annotations:[D.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=h.of([])}destroy(){this._awareness.off(`change`,this._listener)}update(e){let n=this.conf.ytext,i=n.doc,o=this.conf.awareness,c=[],d=this.conf.awareness.getLocalState();if(d!=null){let t=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),i=t?e.state.selection.main:null,s=d.cursor==null?null:a(d.cursor.anchor),c=d.cursor==null?null:a(d.cursor.head);if(i!=null){let e=r(n,i.anchor),t=r(n,i.head);(d.cursor==null||!l(s,e)||!l(c,t))&&o.setLocalStateField(`cursor`,{anchor:e,head:t})}else d.cursor!=null&&t&&o.setLocalStateField(`cursor`,null)}o.getStates().forEach((r,a)=>{if(a===o.doc.clientID)return;let l=r.cursor;if(l==null||l.anchor==null||l.head==null)return;let d=u(l.anchor,i),f=u(l.head,i);if(d==null||f==null||d.type!==n||f.type!==n)return;let{color:p=`#30bced`,name:h=`Anonymous`}=r.user||{},g=r.user&&r.user.colorLight||p+`33`,_=s(d.index,f.index),v=t(d.index,f.index),y=e.view.state.doc.lineAt(_),b=e.view.state.doc.lineAt(v);if(y.number===b.number)c.push({from:_,to:v,value:m.mark({attributes:{style:`background-color: ${g}`},class:`cm-ySelection`})});else{c.push({from:_,to:y.from+y.length,value:m.mark({attributes:{style:`background-color: ${g}`},class:`cm-ySelection`})}),c.push({from:b.from,to:v,value:m.mark({attributes:{style:`background-color: ${g}`},class:`cm-ySelection`})});for(let t=y.number+1;t<b.number;t++){let n=e.view.state.doc.line(t).from;c.push({from:n,to:n,value:m.line({attributes:{style:`background-color: ${g}`,class:`cm-yLineSelection`}})})}}c.push({from:f.index,to:f.index,value:m.widget({side:f.index-d.index>0?-1:1,block:!1,widget:new O(p,h)})})}),this.decorations=m.set(c,!0)}},A=g.fromClass(k,{decorations:e=>e.decorations}),j=class{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}},M=y.define({combine(e){return e[e.length-1]}});_.define();var N=class{constructor(t){this.view=t,this.conf=t.state.facet(M),this._undoManager=this.conf.undoManager,this.syncConf=t.state.facet(S),this._beforeChangeSelection=null,this._mux=e(),this._onStackItemAdded=({stackItem:e,changedParentTypes:t})=>{t.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!e.meta.has(this)&&e.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:e})=>{let n=e.meta.get(this);if(n){let e=this.syncConf.fromYRange(n);t.dispatch(t.state.update({selection:e,effects:[v.scrollIntoView(e)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on(`stack-item-added`,this._onStackItemAdded),this._undoManager.on(`stack-item-popped`,this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){e.selectionSet&&(e.transactions.length===0||e.transactions[0].annotation(C)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off(`stack-item-added`,this._onStackItemAdded),this._undoManager.off(`stack-item-popped`,this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}},P=g.fromClass(N),F=({state:e,dispatch:t})=>e.facet(M).undo()||!0,I=({state:e,dispatch:t})=>e.facet(M).redo()||!0,L=[{key:`Mod-z`,run:F,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:I,preventDefault:!0},{key:`Mod-Shift-z`,run:I,preventDefault:!0}],R=(e,t,{undoManager:n=new c(e)}={})=>{let r=new x(e,t),i=[S.of(r),T];return t&&i.push(E,A),n!==!1&&i.push(M.of(new j(n)),P,v.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?F(t):e.inputType===`historyRedo`?I(t):!1}})),i};export{L as n,R as t};