@inkeep/open-knowledge 0.46.0-beta.35 → 0.46.0-beta.36

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 (55) hide show
  1. package/dist/{acp-harness-probe-BSVTFfrJ.mjs → acp-harness-probe-CgCKbOa6.mjs} +2 -2
  2. package/dist/cli.mjs +6 -6
  3. package/dist/constants-CBsX6VmY.mjs +2 -0
  4. package/dist/index.mjs +1 -1
  5. package/dist/init-AwNwaz8S.mjs +1 -0
  6. package/dist/{init-V4vD94bb.mjs → init-BP8ZrhT6.mjs} +3 -3
  7. package/dist/{launch-json-removal-DbXAmKSE.mjs → launch-json-removal-BRIDVSx6.mjs} +2 -2
  8. package/dist/{loader-BedgCIcG.mjs → loader-Bu-tFAqG.mjs} +2 -2
  9. package/dist/loader-CKek7Fd1.mjs +1 -0
  10. package/dist/{preview-CQbhUHvT.mjs → preview-BokOfu_R.mjs} +2 -2
  11. package/dist/preview-pqKTi4EF.mjs +1 -0
  12. package/dist/public/assets/{ActivityModeContent-1W0E_TW_.js → ActivityModeContent-P4Zf22Bs.js} +1 -1
  13. package/dist/public/assets/{AgentDiffPane-Dctk3kCy.js → AgentDiffPane-DgyWl0LY.js} +1 -1
  14. package/dist/public/assets/{ChangedOutsideBadge-BAgxWMg1.js → ChangedOutsideBadge-D93fNuY2.js} +1 -1
  15. package/dist/public/assets/{DocumentContext-CY-aaPA2.js → DocumentContext-UuXLA8HR.js} +20 -20
  16. package/dist/public/assets/FeedbackForm-CLVnd8qb.js +1 -0
  17. package/dist/public/assets/{ImportSkillDialog-zuUSp64v.js → ImportSkillDialog-B9pptBBF.js} +1 -1
  18. package/dist/public/assets/ManagedArtifactProperties-CQnVDYPq.js +8 -0
  19. package/dist/public/assets/ManagedArtifactProperties-yxP1OknU.js +1 -0
  20. package/dist/public/assets/{SessionsHost-CkTxH_pH.js → SessionsHost-nrZvn3uC.js} +2 -2
  21. package/dist/public/assets/{SettingsDialogBody-CMYkLlDK.js → SettingsDialogBody-DHPy1zCt.js} +1 -1
  22. package/dist/public/assets/{SkillToolbarControls-CzMUJTsR.js → SkillToolbarControls-DHRQ4dll.js} +1 -1
  23. package/dist/public/assets/{SourceEditor-CmON1zaL.js → SourceEditor-aduzr_jn.js} +1 -1
  24. package/dist/public/assets/{TerminalWindowApp-Hea18ovV.js → TerminalWindowApp-bYE3Rjzk.js} +1 -1
  25. package/dist/public/assets/{ThreadView-xDncqlbd.js → ThreadView-C_yxiTQA.js} +1 -1
  26. package/dist/public/assets/{TimelineDiffPane-DK9DjRu2.js → TimelineDiffPane-DxGmoF4_.js} +1 -1
  27. package/dist/public/assets/{agent-diff-store-BtmgOmDH.js → agent-diff-store-Dm4Wpsrw.js} +1 -1
  28. package/dist/public/assets/{auth-state-cache-C-699iSE.js → auth-state-cache-CIkP8Gql.js} +2 -2
  29. package/dist/public/assets/{globals-Cidq7GOk.js → globals-BJVupD3F.js} +1 -1
  30. package/dist/public/assets/index-BG8TFON5.js +2092 -0
  31. package/dist/public/assets/{selection-context-C8jYfARa.js → selection-context-FnWC5AlG.js} +1 -1
  32. package/dist/public/assets/{skill-actions-CgxRJiS9.js → skill-actions-WkDFXDFg.js} +2 -2
  33. package/dist/public/assets/{typing-burst-detector-By5ThDd8.js → typing-burst-detector-BmD9Pa7E.js} +2 -2
  34. package/dist/public/assets/{uninstall-sgFzlxFm.js → uninstall-D5OFbWn8.js} +1 -1
  35. package/dist/public/assets/{use-activity-panel-ZHwYErFx.js → use-activity-panel-GOEuTVxn.js} +1 -1
  36. package/dist/public/assets/{use-open-skill-DF4PdWu_.js → use-open-skill-HTbCYiG5.js} +1 -1
  37. package/dist/public/assets/{use-skill-directory-uITBGO9Q.js → use-skill-directory-GoiBc97k.js} +1 -1
  38. package/dist/public/assets/{use-timeline-entry-diff-CJle_iXu.js → use-timeline-entry-diff-DxzRyFwn.js} +1 -1
  39. package/dist/public/index.html +12 -12
  40. package/dist/public/uninstall.html +2 -2
  41. package/dist/{repair-launch-json-C1mipcEl.mjs → repair-launch-json-Bh35PlKJ.mjs} +2 -2
  42. package/dist/{repair-mcp-configs-xAZRxGTM.mjs → repair-mcp-configs-DC7eb95K.mjs} +2 -2
  43. package/dist/{src-CsTKBeVf.mjs → src-BkdDdMKI.mjs} +2 -2
  44. package/dist/start-CkuVRQqr.mjs +1 -0
  45. package/dist/{start-D6JW3eRX.mjs → start-DlDxpLrm.mjs} +2 -2
  46. package/package.json +4 -4
  47. package/dist/constants-CfgzW6eO.mjs +0 -2
  48. package/dist/init-BnJLvdAH.mjs +0 -1
  49. package/dist/loader-Bb8dIYfj.mjs +0 -1
  50. package/dist/preview-CIOq8C9I.mjs +0 -1
  51. package/dist/public/assets/FeedbackForm-D5_jriQK.js +0 -1
  52. package/dist/public/assets/ManagedArtifactProperties-BEA8rfna.js +0 -8
  53. package/dist/public/assets/ManagedArtifactProperties-Wt4jiRF7.js +0 -1
  54. package/dist/public/assets/index-ByDq_yHG.js +0 -2092
  55. package/dist/start-EaZ9lKkR.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{E as e}from"./DocumentContext-CY-aaPA2.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{E as e}from"./DocumentContext-UuXLA8HR.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,2 +1,2 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{F as n,I as r,Nn as i,P as a,gn as o,i as s}from"./DocumentContext-CY-aaPA2.js";import{t as c}from"./react-f2sANaYj.js";import{n as l,r as u}from"./dist-Nvb76hAm.js";import{t as d}from"./compiler-runtime-BfE3aGVn.js";import{l as f}from"./terminal-input-events-BGPQuYMh.js";import{t as p}from"./use-workspace-C_kPbTuK.js";import{c as m,i as h,n as g,o as _,s as v,t as y}from"./ChangedOutsideBadge-BAgxWMg1.js";import{t as b}from"./button-RQ5o7P7w.js";import{i as x,n as S,t as C}from"./tooltip-x7BNUa3s.js";import{a as w,c as T,i as E,n as D,o as O,r as k,s as ee,t as A}from"./dialog-FGMqkFjm.js";import{a as j,d as M,f as N,i as P,n as F,o as I,p as L,u as R}from"./dropdown-menu-AlVJ7dJz.js";import{t as te}from"./label-G0lbYOgL.js";import{C as z,a as B,f as V,h as H,m as U,n as W,o as G,p as K,r as q,s as J,t as Y}from"./agent-visibility-DvaU093e.js";import{$t as ne,Dt as X,Ia as re,Kt as ie,Mt as ae,Ra as oe,Sn as se,Va as ce,Zt as le,_n as ue,bn as de,en as fe,fn as pe,hn as me,jt as he,mn as ge,nt as _e,pa as ve,pn as ye,ri as be,tt as xe,xn as Se,xt as Ce,yn as we,yr as Te}from"./dist-OxboORfH2.js";import{t as Ee}from"./createLucideIcon-DihYAFEK.js";import{t as De}from"./RegisteredAgentIcon-DGE6x9DL.js";import{n as Oe,r as ke}from"./ManagedArtifactProperties-BEA8rfna.js";import{n as Ae}from"./CopyButton-D6N3opvE.js";import{t as je}from"./folder-open-Ceue91os.js";import{t as Me}from"./folder-DcWlgZbb.js";import{t as Ne}from"./trash-2-WxyktwvM.js";import{n as Z}from"./dist-uN7pEWl0.js";import{t as Pe}from"./input-Cm94Cun3.js";import{t as Fe}from"./dist-CzC3AWOn.js";import{i as Ie}from"./use-settings-route-CIJMHLaP.js";import{t as Le}from"./parse-api-error-Dmlzsw8v.js";import{G as Re,O as ze,W as Be}from"./navigation-targets-GzXvLoSC.js";import{c as Ve,n as He,o as Ue}from"./documents-events-5TI0rZAg.js";import{d as We,n as Ge,r as Ke,s as qe}from"./skill-scope-CmujX5gW.js";import{A as Je,D as Ye,O as Xe,S as Ze,_ as Qe,c as $e,f as et,i as tt,n as nt,t as rt,v as it,x as at,y as ot}from"./skills-api-BeHeMfn9.js";import{n as st}from"./config-context-CYNq8R6z.js";import{t as ct}from"./use-skills-C2EtCeGb.js";import{t as lt}from"./use-open-skill-DF4PdWu_.js";import{n as ut}from"./clipboard-adapter-DdkYoUY3.js";import{t as dt}from"./DiffView-CiVa7sAS.js";var ft=Ee(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),pt=Ee(`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`}]]),mt=Ee(`list-plus`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]),ht=Ee(`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`}]]),gt=Ee(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Q=t(),$=e(c(),1),_t=d();function vt(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 yt(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=Le(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 bt(){if(typeof window>`u`)return null;let e=window.okDesktop?.skill;return e?vt(e):yt()}var xt=`ok:skill:cowork:installed`,St=`1`,Ct=250,wt=`/api/skill/install-state`;function Tt(e){return`${xt}:v${e}`}var Et=new Map;async function Dt(e={},t={}){let n=t.force?`__force__`:`__default__`,r=Et.get(n);if(r)return r;let i=Ot(e,t);return Et.set(n,i),i.finally(()=>{Et.get(n)===i&&Et.delete(n)}),i}async function Ot(e,t){let n=e.installer===void 0?bt():e.installer,r=kt(e.storage),i=e.fetchSnapshot??jt,a=e.serverTimeoutMs??Ct,o=null;if(!t.force){try{o=await Mt(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=Tt(o?.currentVersion??e.fallbackSkillVersion??At());if(!t.force&&r?.getItem(s)===St)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,St)}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 kt(e){if(e!==void 0)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function At(){return typeof window>`u`?`unknown`:window.okDesktop?.appVersion??`unknown`}async function jt(){let e;try{e=await fetch(wt,{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 Mt(e,t){return Promise.race([e,new Promise(e=>{setTimeout(()=>e(null),t)})])}function Nt(e){return Dt({},e)}function Pt(){return Dt({},{force:!0})}async function Ft(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 It(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis);switch(e.target){case`claude-cowork`:return Ft({target:`claude-cowork`,url:le({mode:`cowork`},e)},n);case`claude-code`:return Ft({target:`claude-code`,url:le({mode:`code`},e)},n);case`codex`:return Ft({target:`codex`,url:ne(e)},n);case`cursor`:return Ft({target:`cursor`,url:fe(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 Lt(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 Rt=`open-knowledge:agent-thread-launch`;function zt(e,t=typeof window>`u`?new EventTarget:window){t.dispatchEvent(new CustomEvent(Rt,{detail:e}))}function Bt(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(Rt,n),()=>t.removeEventListener(Rt,n)}function Vt(e){if(!e.docName||!e.workspace)return null;let t=a(e.docName),{contentDir:r,pathSeparator:i}=e.workspace;return{docContext:{relativePath:t},projectDir:r,docPath:n(r,t,i)}}function Ht(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 Wt(e){return K(e.installUrl).then(()=>void 0)}function Gt(e){return!e.workspace?.contentDir||!e.folderRelativePath?null:{docContext:null,folderRelativePath:e.folderRelativePath,projectDir:e.workspace.contentDir,docPath:``}}function Kt(e){return!e.workspace?.contentDir||!e.skillName?null:{docContext:null,skill:{name:e.skillName,scope:e.scope},projectDir:e.workspace.contentDir,docPath:``}}function qt(e){if(!e.workspace?.contentDir)return null;let{contentDir:t,pathSeparator:r}=e.workspace;if(e.docName){let i=e.docRelativePath??a(e.docName),o={scope:`doc`,docRelativePath:i,instruction:e.instruction,mentions:e.mentions};return{docContext:null,compose:e.selection===void 0?o:{...o,selection:e.selection},projectDir:t,docPath:n(t,i,r)}}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 Jt(e){return`Opened in ${e}.`}function Yt(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 Xt(e){return e>=3?null:e===2?`Try one more time`:`Retry`}function Zt(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 Qt(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 $t(e,t,n,r){return e.compose?ie(Qt(e.compose,t,n,r)):e.selection?we({...e.selection,target:t,transport:r}):e.skill?de(e.skill.name,e.skill.scope,n):e.ask?pe(e.ask.relativePath,e.ask.instruction,n,t,r):be(e.docContext===null?e.folderRelativePath?ue(e.folderRelativePath,n,e.instruction,r):e.createDescription===void 0?ge(n,e.instruction,r):ye(e.createDescription,n,e.createScenario??`new-project`,e.createMentions??[],r):me(e.docContext.relativePath,n,e.instruction,r))}function en(e,t){let n=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||n?`${xe} ${$t(e,he[t].handoffTarget,!1,`terminal`)}`:Se(e.docContext?.relativePath??null)}function tn(e){let t=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||t?`${_e} ${$t(e,`claude-code`,!1,`terminal`)}`:se(e.docContext?.relativePath??null)}function nn(e){let t=e.docContext?.relativePath;return typeof t!=`string`||t===``?null:t.replace(/\.(md|mdx)$/,``)}function rn(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 an(e,t){zt({agentSource:t?.agent?.source??`registry`,agentId:t?.agent?.id??``,prompt:tn(e),docName:nn(e),titleHint:rn(e)})}async function on(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:$t(t,e,n.autoOpen,`url`)},a=await n.dispatchHandoff(i),o=n.isElectronHost()?`electron`:`web`,s=n.now().toISOString(),c=t.compose,l=Zt(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(Jt(u));else{let i=Xt(r),a=Yt(u,r);i===null?n.toast.error(a):n.toast.error(a,{action:{label:i,onClick:()=>{on(e,t,n,r+1)}}})}return a}function sn(e){return U.find(t=>t.id===e)?.displayName??e}function cn(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function ln(){return{dispatchHandoff:It,recordHandoff:Lt,toast:{success:e=>{Z.success(e)},error:(e,t)=>{Z.error(e,t?{action:t.action}:void 0)}},now:()=>new Date,isElectronHost:()=>cn(),getDisplayName:sn,ensureCoworkSkillInstalled:Nt,autoOpen:!0}}function un(){let e=(0,_t.c)(2),{merged:t}=st(),n=t?.appearance?.preview?.autoOpen??!0,r;return e[0]===n?r=e[1]:(r={dispatch:(e,t)=>on(e,t,{...ln(),autoOpen:n}),reinstallCoworkSkill:Pt},e[0]=n,e[1]=r),r}var dn=Object.freeze({hosts:null,source:null}),fn=new Map,pn=new Map;function mn(e,t){return`${e}:${t}`}function hn(e){return fn.get(e)??dn}function gn(e,t){let n=pn.get(e)??new Set;return pn.set(e,n),n.add(t),()=>{n.delete(t),n.size===0&&pn.delete(e)}}function _n(e,t){let n=hn(e),r={...n,...t};if(!(r.hosts===n.hosts&&r.source===n.source)){r.hosts===null&&r.source===null?fn.delete(e):fn.set(e,r);for(let t of pn.get(e)??[])t()}}var vn=X.options,yn=`min-w-[24rem]`;function bn(e,t){let n=(0,_t.c)(45),r=t.installingName===e.name,i=(0,$.useRef)(e),[a,o]=(0,$.useState)(!1),s=(0,$.useRef)(!1),c,l;n[0]===r?(c=n[1],l=n[2]):(c=()=>{s.current&&!r&&o(!0),s.current=r},l=[r],n[0]=r,n[1]=c,n[2]=l),(0,$.useEffect)(c,l);let u,d;n[3]===e?(u=n[4],d=n[5]):(u=()=>{e!==i.current&&(i.current=e,o(!1))},d=[e],n[3]=e,n[4]=u,n[5]=d),(0,$.useEffect)(u,d);let f=r||a,p;n[6]!==e.name||n[7]!==e.scope?(p=mn(e.scope,e.name),n[6]=e.name,n[7]=e.scope,n[8]=p):p=n[8];let m=p,h,g;n[9]===m?(h=n[10],g=n[11]):(h=e=>gn(m,e),g=()=>hn(m),n[9]=m,n[10]=h,n[11]=g);let _=(0,$.useSyncExternalStore)(h,g),v=_.hosts,y=_.source,b,x;n[12]!==y||n[13]!==m||n[14]!==e.hosts?(b=()=>{y!==null&&e.hosts[0]===y&&_n(m,{source:null})},x=[e.hosts,y,m],n[12]=y,n[13]=m,n[14]=e.hosts,n[15]=b,n[16]=x):(b=n[15],x=n[16]),(0,$.useEffect)(b,x);let S=e.linkMode===!0,C=v??e.hosts,w;n[17]===C?w=n[18]:(w=new Set(C),n[17]=C,n[18]=w);let T=w,E=v?v.length>0:e.installed,D=(0,$.useRef)(e.hosts),O,k;n[19]!==v||n[20]!==e.hosts?(O=()=>{v===null&&(D.current=e.hosts)},k=[v,e.hosts],n[19]=v,n[20]=e.hosts,n[21]=O,n[22]=k):(O=n[21],k=n[22]),(0,$.useEffect)(O,k);let ee;n[23]===e.hosts?ee=n[24]:(ee=[...e.hosts].sort().join(`,`),n[23]=e.hosts,n[24]=ee);let A=ee,j,M;n[25]!==m||n[26]!==A?(j=()=>{let e=hn(m).hosts;e&&[...e].sort().join(`,`)===A&&_n(m,{hosts:null})},M=[A,m],n[25]=m,n[26]=A,n[27]=j,n[28]=M):(j=n[27],M=n[28]),(0,$.useEffect)(j,M);let N=(0,$.useRef)(null),P=(0,$.useRef)(null),F,I;n[29]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>()=>{N.current&&clearTimeout(N.current),P.current?.(),P.current=null},I=[],n[29]=F,n[30]=I):(F=n[29],I=n[30]),(0,$.useEffect)(F,I);let L;n[31]!==t||n[32]!==m||n[33]!==e?(L=function(n,r){D.current=n,_n(m,{hosts:n}),N.current&&clearTimeout(N.current);let i=async()=>{P.current=null,N.current=null;let r=await t.install(e,n.filter(Te));if(!r.ok){_n(m,{hosts:null});return}D.current=[...r.hosts],_n(m,{hosts:[...r.hosts]})};r?(P.current=()=>void i(),N.current=setTimeout(()=>void i(),350)):(P.current=null,i())},n[31]=t,n[32]=m,n[33]=e,n[34]=L):L=n[34];let R=L,te;return n[35]!==t||n[36]!==R||n[37]!==T||n[38]!==E||n[39]!==f||n[40]!==y||n[41]!==m||n[42]!==S||n[43]!==e?(te={hostSet:T,installed:E,installing:f,toggleEditor(e,t){let n=new Set(D.current);t?n.add(e):n.delete(e),R([...n],!0)},installAll(){let t=D.current.filter(Cn),n=e.installableEditors??vn,r=vn.filter(e=>n.includes(e)||D.current.includes(e));R([...t,...r],!1)},linkMode:S,sourceHost:y??e.hosts[0],placeAt(n,r){t.runLocationWrite(e,()=>it({scope:e.scope,name:e.name,dir:n,mode:r})).then(Sn)},unplaceAt(n){t.runLocationWrite(e,()=>Xe({scope:e.scope,name:e.name,path:n})).then(xn)},setSource(n){_n(m,{source:n}),t.runLocationWrite(e,()=>Ye({scope:e.scope,name:e.name,target:n})).then(e=>{e.ok||(_n(m,{source:null}),Z.error(e.error))})},convertLocation(n,r){t.convertLocations(e,[{target:n,mode:r}])},convertLocations(n){t.convertLocations(e,n)}},n[35]=t,n[36]=R,n[37]=T,n[38]=E,n[39]=f,n[40]=y,n[41]=m,n[42]=S,n[43]=e,n[44]=te):te=n[44],te}function xn(e){e.ok||Z.error(e.error)}function Sn(e){e.ok||Z.error(e.error)}function Cn(e){return!vn.includes(e)}function wn(e){let t=(0,_t.c)(7),{hint:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,Q.jsx)(x,{asChild:!0,children:r}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,Q.jsx)(S,{side:`right`,className:`max-w-xs`,children:n}),t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(C,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Tn(e){let t=(0,_t.c)(155),{toggles:n,skill:r,onResolveFork:i,onRunStart:a}=e,{_:o}=u(),{hostSet:s,toggleEditor:c,installAll:d}=n,f;t[0]===r?f=t[1]:(f=e=>r?`${qe(e,r.scope)}/${r.name}`:null,t[0]=r,t[1]=f);let p=f,m=ct(),h;t[2]!==m.data||t[3]!==m.status||t[4]!==r?(h=r!==void 0&&((r.hosts??[]).includes(`agents`)||m.status===`ready`&&m.data.some(Ln)),t[2]=m.data,t[3]=m.status,t[4]=r,t[5]=h):h=t[5];let _=h,v;t[6]!==m.data||t[7]!==m.status||t[8]!==r?(v=r?.hostAliases??(r&&m.status===`ready`?Object.assign({},...m.data.filter(e=>e.scope===r.scope).map(In)):{}),t[6]=m.data,t[7]=m.status,t[8]=r,t[9]=v):v=t[9];let x=v,S;t[10]!==m.data||t[11]!==m.status||t[12]!==r?(S=r?.installableEditors??(r&&m.status===`ready`?m.data.find(e=>e.scope===r.scope)?.installableEditors:void 0),t[10]=m.data,t[11]=m.status,t[12]=r,t[13]=S):S=t[13];let C=S,w,T,E,D,O,k,ee;if(t[14]!==o||t[15]!==x||t[16]!==m.data||t[17]!==m.status||t[18]!==s||t[19]!==_||t[20]!==d||t[21]!==C||t[22]!==i||t[23]!==a||t[24]!==p||t[25]!==r||t[26]!==c||t[27]!==n){let e=C?new Set(C):null,u;t[35]===x?u=t[36]:(u=e=>!(e in x),t[35]=x,t[36]=u);let f=(_?[`agents`,...vn]:vn).filter(u).filter(t=>t===`agents`||e===null||e.has(t)||s.has(t)),h;t[37]===p?h=t[38]:(h=e=>p(e),t[37]=p,t[38]=h);let v=new Set(f.map(h)),S=r?.scope===`global`?`~/`:``,A;t[39]!==S||t[40]!==r?(A=r?.path?.includes(`/`)?`${S}${r.path.replace(/\/SKILL\.mdx?$/i,``)}`:null,t[39]=S,t[40]=r,t[41]=A):A=t[41];let j=A,M=j!==null&&!v.has(j)?j:null,N=M===null?n.sourceHost??r?.hosts?.[0]:void 0,P;t[42]===x?P=t[43]:(P=e=>Ge(x,e),t[42]=x,t[43]=P);let L=P,R=Fn,te;t[44]!==o||t[45]!==L?(te=e=>{let t=L(e);return t.length===0?!0:window.confirm(o({id:`Uobeu9`,values:{0:t.map(R).join(`, `),rootRel:e}}))},t[44]=o,t[45]=L,t[46]=te):te=t[46];let z=te,B;t[47]!==o||t[48]!==r?(B=(e,t)=>{let n=e.includes(`/`)?e:qe(e,r?.scope??`project`);return(0,Q.jsx)(wn,{hint:o({id:`0dslv8`,values:{0:R(e),1:R(e),2:r?.name??``,poolRootRel:t,subRoot:n}}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-4 shrink-0 px-0`,"aria-label":o({id:`G6Lrs_`,values:{0:R(e)}}),onClick:i=>{i.preventDefault(),i.stopPropagation(),window.confirm(o({id:`iiqOKM`,values:{0:R(e),1:r.name,2:R(e),subRoot:n,poolRootRel:t}}))&&ot({scope:r.scope,root:n,action:`unlink`,exclude:[r.name]}).then(e=>{e.ok?Ue():Z.error(o({id:`PRgIJh`,values:{0:e.error,subRoot:n}}))})},"data-testid":`skill-audience-unfollow-${e}`,children:(0,Q.jsx)(g,{host:e,"aria-hidden":!0,className:`size-3.5`})})},e)},t[47]=o,t[48]=r,t[49]=B):B=t[49];let V=B,H;t[50]===r?.conflictHosts?H=t[51]:(H=r?.conflictHosts??[],t[50]=r?.conflictHosts,t[51]=H);let U;t[52]===H?U=t[53]:(U=new Set(H),t[52]=H,t[53]=U);let W=U,G;t[54]===r?.driftPaths?G=t[55]:(G=r?.driftPaths??[],t[54]=r?.driftPaths,t[55]=G);let K;t[56]===G?K=t[57]:(K=new Set(G),t[56]=G,t[57]=K);let q=K;w=n.installing;let J=Pn,Y;t[58]===r?.symlinkedHosts?Y=t[59]:(Y=r?.symlinkedHosts??[],t[58]=r?.symlinkedHosts,t[59]=Y);let ne;t[60]===Y?ne=t[61]:(ne=new Set(Y),t[60]=Y,t[61]=ne);let X=ne,re=[...[...s].filter(e=>e!==N&&!(e in x)&&!W.has(e)&&!e.includes(`/`)).map(e=>X.has(e)?`link`:`copy`),...(r?.customPlacements??[]).map(Nn)],ie=re.filter(Mn).length;E=re.length===0?n.linkMode?`link`:`copy`:ie*2>=re.length?`link`:`copy`;let ae;t[62]!==x||t[63]!==W||t[64]!==s||t[65]!==X||t[66]!==p||t[67]!==N?(ae=[...s].filter(e=>e!==N&&!(e in x)&&!W.has(e)&&!e.includes(`/`)).map(e=>({target:e,display:p(e)??R(e),mode:X.has(e)?`link`:`copy`})),t[62]=x,t[63]=W,t[64]=s,t[65]=X,t[66]=p,t[67]=N,t[68]=ae):ae=t[68];let oe;t[69]===r?.customPlacements?oe=t[70]:(oe=r?.customPlacements??[],t[69]=r?.customPlacements,t[70]=oe);let se;if(t[71]!==S||t[72]!==ae||t[73]!==oe){let e;t[75]===S?e=t[76]:(e=e=>({target:Ke(e),display:`${S}${e.path}`,mode:e.mode}),t[75]=S,t[76]=e),se=[...ae,...oe.map(e)],t[71]=S,t[72]=ae,t[73]=oe,t[74]=se}else se=t[74];T=se;let ce;t[77]!==o||t[78]!==a||t[79]!==n?(ce=(e,t,r)=>{let i=r===`link`?`copy`:`link`;return(0,Q.jsx)(wn,{hint:o(r===`link`?{id:`FeXcUS`,values:{display:t}}:{id:`ugQcJX`,values:{display:t}}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-yellow-500/40 bg-yellow-500/10 px-1 font-normal text-[10px] text-yellow-600 uppercase tracking-wide hover:bg-yellow-500/20`,onClick:r=>{r.preventDefault(),r.stopPropagation(),window.confirm(o(i===`link`?{id:`m0eHej`,values:{display:t}}:{id:`HbcQYf`,values:{display:t}}))&&(a?.(),n.convertLocation?.(e,i))},"data-testid":`skill-convert-${e}`,children:r===`link`?(0,Q.jsx)(l,{id:`uUCrBv`}):(0,Q.jsx)(l,{id:`iaPtht`})})})},t[77]=o,t[78]=a,t[79]=n,t[80]=ce):ce=t[80];let le=ce,ue;t[81]===r?.customPlacements?ue=t[82]:(ue=r?.customPlacements??[],t[81]=r?.customPlacements,t[82]=ue);let de=new Map(ue.map(jn)),fe=new Set(de.keys());if(m.status===`ready`&&r){for(let e of m.data)if(e.scope===r.scope)for(let t of e.customPlacements??[]){let e=Ke(t);e!==``&&fe.add(e)}}let pe=r===void 0?[]:[...fe].sort().map(e=>({root:e,display:`${S}${e}/${r.name}`,placed:de.get(e)??null})).filter(e=>!v.has(e.display)&&e.display!==j&&!(e.root in x)),me;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Q.jsx)(l,{id:`npcziF`}),t[83]=me):me=t[83];let he;t[84]===o?he=t[85]:(he=o({id:`6f_UX4`}),t[84]=o,t[85]=he);let ge;t[86]===d?ge=t[87]:(ge=()=>d(),t[86]=d,t[87]=ge);let _e;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Q.jsx)(l,{id:`N40H-G`}),t[88]=_e):_e=t[88];let ye;t[89]!==w||t[90]!==ge?(ye=(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 px-1.5 font-normal text-[11px] text-muted-foreground hover:text-foreground`,disabled:w,onClick:ge,"data-testid":`skill-install-all`,children:_e}),t[89]=w,t[90]=ge,t[91]=ye):ye=t[91],t[92]!==he||t[93]!==ye?(D=(0,Q.jsxs)(I,{className:`flex items-center justify-between gap-2`,children:[me,(0,Q.jsx)(wn,{hint:he,children:ye})]}),t[92]=he,t[93]=ye,t[94]=D):D=t[94],t[95]!==o||t[96]!==V||t[97]!==w||t[98]!==M||t[99]!==L?(O=M===null?null:(0,Q.jsx)(wn,{hint:o({id:`pXB6SL`}),children:(0,Q.jsxs)(F,{disabled:w,checked:!0,onSelect:An,"data-testid":`skill-source-row`,children:[(0,Q.jsx)(Me,{"aria-hidden":!0,className:`size-4 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:M}),(()=>{let e=J(M).split(`/`).slice(0,-1).join(`/`),t=L(e);return t.length>0?(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-testid":`skill-row-audience-source`,children:t.map(t=>V(t,e))}):null})(),(0,Q.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded border border-border/60 px-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:(0,Q.jsx)(l,{id:`tiFPjk`})})]})]})}),t[95]=o,t[96]=V,t[97]=w,t[98]=M,t[99]=L,t[100]=O):O=t[100];let be;t[101]!==o||t[102]!==V||t[103]!==w||t[104]!==z||t[105]!==W||t[106]!==le||t[107]!==q||t[108]!==E||t[109]!==s||t[110]!==X||t[111]!==i||t[112]!==p||t[113]!==r?.hosts||t[114]!==N||t[115]!==L||t[116]!==c||t[117]!==n?(be=e=>{let t=p(e),a=e===`agents`?`.agents`:ve[e],u=J(t).split(`/`).slice(0,-1).join(`/`),d=L(u);return(0,Q.jsx)(wn,{hint:W.has(e)?o({id:`8HvJlU`,values:{0:t??a}}):e===N?t?o({id:`ssk6rl`,values:{path:t}}):a:s.has(e)?o(t?{id:`9ieZhu`,values:{path:t}}:{id:`n3T3EE`,values:{label:a}}):o(t?E===`link`?{id:`1LtA5r`,values:{path:t}}:{id:`opPbzN`,values:{path:t}}:{id:`Pp0Vgd`,values:{label:a}}),children:(0,Q.jsxs)(F,{disabled:w,checked:s.has(e),onCheckedChange:t=>{W.has(e)||t===!0&&!z(u)||c(e,t===!0)},onSelect:kn,className:`group`,"data-testid":`skill-install-editor-${e}`,children:[(0,Q.jsx)(g,{host:e,"aria-hidden":!0,className:`size-4`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t??a}),d.length>0?(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-testid":`skill-row-audience-${e}`,children:d.map(e=>V(e,u))}):null,W.has(e)?(0,Q.jsx)(wn,{hint:o({id:`_O7dJS`}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-yellow-500/40 bg-yellow-500/10 px-1 text-[10px] text-yellow-600 uppercase tracking-wide hover:bg-yellow-500/20`,onClick:t=>{t.preventDefault(),i?.(e)},"data-testid":`skill-fork-chip-${e}`,children:(0,Q.jsx)(l,{id:`jng7Ko`})})}):e===N?(0,Q.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded border border-border/60 px-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:(0,Q.jsx)(l,{id:`tiFPjk`})}):s.has(e)&&r?.hosts?(0,Q.jsxs)(Q.Fragment,{children:[!w&&(X.has(e)?`link`:`copy`)!==E?le(e,t??a,X.has(e)?`link`:`copy`):null,(0,Q.jsx)(wn,{hint:o({id:`nBgzKO`}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-border/60 px-1 font-normal text-[10px] text-muted-foreground uppercase tracking-wide opacity-0 focus-visible:opacity-100 group-hover:opacity-100 hover:border-foreground/40 hover:text-foreground`,onClick:t=>{t.preventDefault(),t.stopPropagation(),n.setSource?.(e)},"data-testid":`skill-set-source-${e}`,children:(0,Q.jsx)(l,{id:`VNNRfN`})})})]}):null,!w&&q.has(J(t))?(0,Q.jsx)(wn,{hint:o({id:`iz1LdD`}),children:(0,Q.jsx)(y,{testId:`skill-drift-${e}`})}):null]})]})},e)},t[101]=o,t[102]=V,t[103]=w,t[104]=z,t[105]=W,t[106]=le,t[107]=q,t[108]=E,t[109]=s,t[110]=X,t[111]=i,t[112]=p,t[113]=r?.hosts,t[114]=N,t[115]=L,t[116]=c,t[117]=n,t[118]=be):be=t[118],k=f.map(be);let xe;t[119]!==o||t[120]!==V||t[121]!==w||t[122]!==z||t[123]!==le||t[124]!==q||t[125]!==E||t[126]!==L||t[127]!==n?(xe=e=>(0,Q.jsx)(wn,{hint:e.placed===null?o(E===`link`?{id:`ybWWR2`,values:{0:e.display}}:{id:`fDjZxw`,values:{0:e.display}}):o({id:`C0cll5`,values:{0:e.display}}),children:(0,Q.jsxs)(F,{disabled:w,checked:e.placed!==null,onCheckedChange:t=>{if(t===!0&&e.placed===null){if(!z(e.root))return;n.placeAt(e.root,E)}else e.placed!==null&&n.unplaceAt?.(e.placed.path)},onSelect:On,className:`group`,"data-testid":`skill-custom-root-${e.root}`,children:[e.root===`.agents/skills`?(0,Q.jsx)(g,{host:`agents`,"aria-hidden":!0,className:`size-4`}):(0,Q.jsx)(Me,{"aria-hidden":!0,className:`size-4 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.display}),L(e.root).length>0?(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-testid":`skill-row-audience-custom-${e.root}`,children:L(e.root).map(t=>V(t,e.root))}):null,!w&&e.placed!==null&&q.has(e.placed.path)?(0,Q.jsx)(wn,{hint:o({id:`iz1LdD`}),children:(0,Q.jsx)(y,{testId:`skill-drift-custom-${e.root}`})}):e.placed===null?null:(0,Q.jsxs)(Q.Fragment,{children:[!w&&e.placed.mode!==E?le(e.root,e.display,e.placed.mode):null,(0,Q.jsx)(wn,{hint:o({id:`nBgzKO`}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-border/60 px-1 font-normal text-[10px] text-muted-foreground uppercase tracking-wide opacity-0 focus-visible:opacity-100 group-hover:opacity-100 hover:border-foreground/40 hover:text-foreground`,onClick:t=>{t.preventDefault(),t.stopPropagation(),n.setSource?.(e.root)},"data-testid":`skill-set-source-custom-${e.root}`,children:(0,Q.jsx)(l,{id:`VNNRfN`})})})]})]})]})},e.root),t[119]=o,t[120]=V,t[121]=w,t[122]=z,t[123]=le,t[124]=q,t[125]=E,t[126]=L,t[127]=n,t[128]=xe):xe=t[128],ee=pe.map(xe),t[14]=o,t[15]=x,t[16]=m.data,t[17]=m.status,t[18]=s,t[19]=_,t[20]=d,t[21]=C,t[22]=i,t[23]=a,t[24]=p,t[25]=r,t[26]=c,t[27]=n,t[28]=w,t[29]=T,t[30]=E,t[31]=D,t[32]=O,t[33]=k,t[34]=ee}else w=t[28],T=t[29],E=t[30],D=t[31],O=t[32],k=t[33],ee=t[34];let A;t[129]!==o||t[130]!==w||t[131]!==T||t[132]!==E||t[133]!==a||t[134]!==n?(A=T.length>0&&n.convertLocations?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-1 pb-1.5`,children:[(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-auto whitespace-normal p-0 text-left font-normal text-[11px] text-muted-foreground leading-snug hover:bg-transparent hover:text-foreground`,onClick:e=>{e.preventDefault();let t=E===`link`?`copy`:`link`,r=T.filter(e=>e.mode!==t);if(r.length===0)return;let i=o(t===`copy`?{id:`iOAsF1`}:{id:`MS8lMS`}),s=o(t===`copy`?{id:`gZiT5e`}:{id:`PhIa-X`}),c=r.map(Dn).join(`
2
- `);window.confirm(`${i}\n\n${s}\n\n${c}\n\n${o({id:`Cu6GXQ`})}`)&&(a?.(),n.convertLocations?.(r.map(e=>({target:e.target,mode:t}))))},disabled:w,"data-testid":`skill-convert-all`,children:E===`link`?(0,Q.jsx)(l,{id:`rcJmK8`}):(0,Q.jsx)(l,{id:`LBv_TR`})}),(0,Q.jsx)(wn,{hint:o({id:`0J6nhG`}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,"aria-label":o({id:`qJSo0_`}),className:`size-4 shrink-0 rounded-full border border-border/60 p-0 font-normal text-[9px] text-muted-foreground hover:border-foreground/40 hover:bg-transparent hover:text-foreground`,onClick:En,"data-testid":`skill-convert-all-help`,children:`?`})})]}):null,t[129]=o,t[130]=w,t[131]=T,t[132]=E,t[133]=a,t[134]=n,t[135]=A):A=t[135];let M;t[136]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(R,{}),t[136]=M):M=t[136];let N;t[137]===o?N=t[138]:(N=o({id:`jqe7Yq`}),t[137]=o,t[138]=N);let P;t[139]===r?.scope?P=t[140]:(P=()=>{window.location.hash=r?.scope===`global`?`#settings/user-skills`:`#settings/skills`},t[139]=r?.scope,t[140]=P);let L,te;t[141]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(gt,{"aria-hidden":!0}),te=(0,Q.jsx)(l,{id:`ZBF9fn`}),t[141]=L,t[142]=te):(L=t[141],te=t[142]);let z;t[143]===P?z=t[144]:(z=(0,Q.jsxs)(j,{onSelect:P,children:[L,te]}),t[143]=P,t[144]=z);let B;t[145]!==N||t[146]!==z?(B=(0,Q.jsx)(wn,{hint:N,children:z}),t[145]=N,t[146]=z,t[147]=B):B=t[147];let V;return t[148]!==B||t[149]!==D||t[150]!==O||t[151]!==k||t[152]!==ee||t[153]!==A?(V=(0,Q.jsxs)(Q.Fragment,{children:[D,O,k,ee,A,M,B]}),t[148]=B,t[149]=D,t[150]=O,t[151]=k,t[152]=ee,t[153]=A,t[154]=V):V=t[154],V}function En(e){return e.preventDefault()}function Dn(e){return e.display}function On(e){return e.preventDefault()}function kn(e){return e.preventDefault()}function An(e){return e.preventDefault()}function jn(e){return[Ke(e),e]}function Mn(e){return e===`link`}function Nn(e){return e.mode}function Pn(e){return(e??``).replace(/^~\//,``)}function Fn(e){return e===`agents`?`.agents`:ve[e]??e}function In(e){return e.hostAliases??{}}function Ln(e){return e.hosts.includes(`agents`)||e.path.startsWith(`.agents/`)}function Rn(e){let t=(0,_t.c)(10),{onAddProperty:n,className:r}=e,{_:i}=u(),a;t[0]===i?a=t[1]:(a=i({id:`81H_23`}),t[0]=i,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(x,{children:(0,Q.jsx)(mt,{})}),t[2]=o):o=t[2];let s;t[3]!==r||t[4]!==n||t[5]!==a?(s=(0,Q.jsx)(b,{variant:`ghost`,size:`icon`,"aria-label":a,onClick:n,"data-testid":`add-properties-button`,className:r,asChild:!0,children:o}),t[3]=r,t[4]=n,t[5]=a,t[6]=s):s=t[6];let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(S,{side:`bottom`,children:(0,Q.jsx)(l,{id:`81H_23`})}),t[7]=c):c=t[7];let d;return t[8]===s?d=t[9]:(d=(0,Q.jsxs)(C,{children:[s,c]}),t[8]=s,t[9]=d),d}function zn(e){return e?Fe._({id:`wTcjov`}):null}function Bn(e){let t=(0,_t.c)(47),{_:n}=u(),i=r(),a=_(),s=z(),c=V();if(i)return null;let{input:d,installStates:p,dispatch:m,onBeforeLaunch:h}=e,g=d===null,v,y,b,x,S,C,w,T,E,D,O;if(t[0]!==n||t[1]!==m||t[2]!==d||t[3]!==g||t[4]!==p||t[5]!==h||t[6]!==c||t[7]!==s||t[8]!==a){let e=zn(g),r;t[20]===c?r=t[21]:(r=e=>Y(c,e.id),t[20]=c,t[21]=r);let i=H.filter(r),u;t[22]===c?u=t[23]:(u=e=>W(c,e.source,e.id,!0,e.supported),t[22]=c,t[23]=u);let f=s.filter(u),_=a?ae.filter(e=>q(c,e,a.installedClis)):[];b=i.length>0,x=a!==null&&_.length>0,S=f.length>0,y=M,t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(o,{"aria-hidden":`true`}),(0,Q.jsx)(l,{id:`O7_W_a`})]}),t[24]=O):O=t[24],v=N,C=`max-h-80`,w=S?(0,Q.jsxs)(P,{"aria-label":n({id:`vPKX2i`}),children:[(0,Q.jsxs)(I,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(l,{id:`RXEbZy`}),(0,Q.jsx)(J,{})]}),f.map(t=>{let r=t.name;return(0,Q.jsxs)(j,{onSelect:()=>{d!==null&&(h?.(),an(d,{agent:{source:t.source,id:t.id}}))},disabled:g,"data-testid":`file-tree-open-in-thread-${t.id}`,"aria-label":e?n({id:`gtGQ9S`,values:{agentName:r,hint:e}}):void 0,children:[(0,Q.jsx)(De,{agentId:t.id,iconUrl:t.iconUrl,className:`size-4`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:(0,Q.jsx)(l,{id:`5PrrYw`,values:{agentName:r}})}),e?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},`${t.source}:${t.id}`)})]}):null,t[25]!==b||t[26]!==x||t[27]!==S?(T=S&&(x||b)?(0,Q.jsx)(R,{}):null,t[25]=b,t[26]=x,t[27]=S,t[28]=T):T=t[28],E=x?(0,Q.jsxs)(P,{"aria-label":n({id:`ALhMYW`}),children:[(0,Q.jsx)(I,{children:(0,Q.jsx)(l,{id:`ALhMYW`})}),_.map(t=>{let{displayName:r}=he[t];return(0,Q.jsxs)(j,{onSelect:()=>{d!==null&&(h?.(),a.launchInTerminal(d,t))},disabled:g,"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,Q.jsx)(G,{id:B(t),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:r}),e?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t)})]}):null,D=b?(0,Q.jsxs)(Q.Fragment,{children:[x?(0,Q.jsx)(R,{}):null,(0,Q.jsxs)(P,{"aria-label":n({id:`BBqGS9`}),children:[(0,Q.jsx)(I,{children:(0,Q.jsx)(l,{id:`BBqGS9`})}),i.map(t=>{let r=!g,{displayName:i}=t,a=n(e?{id:`1ZpfyB`,values:{displayName:i,hint:e}}:{id:`WqLq6M`,values:{displayName:i}});return(0,Q.jsxs)(j,{disabled:!r,onSelect:()=>{if(d){if(h?.(),p[t.id]?.installed!==!0){Wt(t);return}m(t.id,d)}},"data-testid":`file-tree-open-in-${t.id}`,"aria-label":a,children:[(0,Q.jsx)(G,{id:t.id,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:t.displayName}),e?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)})]})]}):null,t[0]=n,t[1]=m,t[2]=d,t[3]=g,t[4]=p,t[5]=h,t[6]=c,t[7]=s,t[8]=a,t[9]=v,t[10]=y,t[11]=b,t[12]=x,t[13]=S,t[14]=C,t[15]=w,t[16]=T,t[17]=E,t[18]=D,t[19]=O}else v=t[9],y=t[10],b=t[11],x=t[12],S=t[13],C=t[14],w=t[15],T=t[16],E=t[17],D=t[18],O=t[19];let k;t[29]!==b||t[30]!==x||t[31]!==S?(k=S||x||b?(0,Q.jsx)(R,{}):null,t[29]=b,t[30]=x,t[31]=S,t[32]=k):k=t[32];let ee;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Q.jsx)(f,{"aria-hidden":`true`}),t[33]=ee):ee=t[33];let A;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsxs)(j,{onSelect:Ie,"data-testid":`file-tree-open-in-settings`,children:[ee,(0,Q.jsx)(`span`,{className:`flex-1`,children:(0,Q.jsx)(l,{id:`jRAGrQ`})})]}),t[34]=A):A=t[34];let F;t[35]!==v||t[36]!==C||t[37]!==w||t[38]!==T||t[39]!==E||t[40]!==D||t[41]!==k?(F=(0,Q.jsxs)(v,{className:C,children:[w,T,E,D,k,A]}),t[35]=v,t[36]=C,t[37]=w,t[38]=T,t[39]=E,t[40]=D,t[41]=k,t[42]=F):F=t[42];let te;return t[43]!==y||t[44]!==O||t[45]!==F?(te=(0,Q.jsxs)(y,{children:[O,F]}),t[43]=y,t[44]=O,t[45]=F,t[46]=te):te=t[46],te}function Vn(e){let t=oe(e);if(t)return{scope:`project`,name:t.name,rel:t.rel};let n=re(e);return n?{scope:`global`,name:n.name,rel:n.rel}:null}function Hn(e,t,n){return e.filter(e=>{let r=ze(e);if(r.kind===`skill-file`)return r.scope===t&&r.name===n;if(r.kind!==`doc`)return!1;let i=Vn(r.docName);return i?.scope===t&&i.name===n})}function Un(e,t){let n=new Map(t.map(e=>[`${e.scope}\u0000${e.name}`,e])),r=[];for(let t of e){let e=Vn(t);if(!e||n.has(`${e.scope}\u0000${e.name}`))continue;let i=e.scope===`project`?`global`:`project`,a=n.get(`${i}\u0000${e.name}`);e.rel===null&&a!==void 0?r.push({kind:`retarget`,fromDocName:t,toDocName:Re(a)}):r.push({kind:`close`,docName:t})}return r}function Wn(){let e=(0,_t.c)(15),{openTabs:t,closeDocument:n}=s(),r=Oe(),i;e[0]===t?i=e[1]:(i=t.some(Kn),e[0]=t,e[1]=i);let a=i,o;e[2]===a?o=e[3]:(o={enabled:a},e[2]=a,e[3]=o);let c=ct(o),l=(0,$.useRef)(null),u;e[4]!==n||e[5]!==t||e[6]!==r||e[7]!==c.data||e[8]!==c.status?(u=()=>{if(c.status!==`ready`)return;let e=c.data,i=`${t.join(``)}\u0002${e.map(Gn).sort().join(``)}`;if(l.current===i)return;l.current=i;let a=Un(t,e);for(let e of a)e.kind===`retarget`?r(e.fromDocName,e.toDocName):n(e.docName)},e[4]=n,e[5]=t,e[6]=r,e[7]=c.data,e[8]=c.status,e[9]=u):u=e[9];let d;e[10]!==n||e[11]!==t||e[12]!==r||e[13]!==c?(d=[c,t,r,n],e[10]=n,e[11]=t,e[12]=r,e[13]=c,e[14]=d):d=e[14],(0,$.useEffect)(u,d)}function Gn(e){return`${e.scope}\u0000${e.name}`}function Kn(e){return Vn(e)!==null}function qn(e){let t=(0,_t.c)(19),{skill:n,onOpenChange:r,onDeleted:i}=e,{_:a}=u(),{setSkillsSidebar:o,closeTabs:c,openTabs:l}=s(),[d,f]=(0,$.useState)(!1),p;t[0]!==a||t[1]!==c||t[2]!==i||t[3]!==r||t[4]!==l||t[5]!==o?(p=async function(e){o(!0),f(!0);let t=await nt(e.scope,e.name);if(f(!1),!t.ok){let{error:e}=t;Z.error(a({id:`AtBdnD`,values:{error:e}}));return}Z.success(a({id:`h9QFb9`,values:{0:e.name}})),c(Hn(l,e.scope,e.name),{force:!0}),i(),r(!1)},t[0]=a,t[1]=c,t[2]=i,t[3]=r,t[4]=l,t[5]=o,t[6]=p):p=t[6];let m=p,g=n!==null,_;t[7]!==d||t[8]!==r?(_=e=>{!e&&!d&&r(!1)},t[7]=d,t[8]=r,t[9]=_):_=t[9];let v;t[10]!==a||t[11]!==d||t[12]!==m||t[13]!==n?(v=n?(0,Q.jsx)(h,{itemName:a({id:`ExUzM4`,values:{0:n.name}}),isSubmitting:d,onDelete:()=>m(n),customDescription:n.origin?.source&&/\/plugins\/(?:cache|marketplaces)\//.test(n.origin.source)?a({id:`WnsbUT`,values:{0:n.path}}):a({id:`E1Da_b`,values:{0:n.path}})}):null,t[10]=a,t[11]=d,t[12]=m,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==g||t[16]!==_||t[17]!==v?(y=(0,Q.jsx)(A,{open:g,onOpenChange:_,children:v}),t[15]=g,t[16]=_,t[17]=v,t[18]=y):y=t[18],y}function Jn(e){let t=e.split(`/`);return t.some(e=>e===``||e===`.`||e===`..`)||t.length===0||t.length===1&&t[0].toLowerCase()===`skill.md`?!1:!/\s/.test(e)}function Yn(e){let t=(0,_t.c)(66),{target:n,onOpenChange:r}=e,{_:i}=u(),{openTarget:a}=s(),o=(0,$.useId)(),[c,d]=(0,$.useState)(``),[f,p]=(0,$.useState)(!1),m;t[0]===n?m=t[1]:(m=()=>{n&&d(n.prefix??`references/`)},t[0]=n,t[1]=m);let h=n?.skill.scope,g=n?.skill.name,_=n?.prefix,v;if(t[2]!==h||t[3]!==g||t[4]!==_?(v=[h,g,_],t[2]=h,t[3]=g,t[4]=_,t[5]=v):v=t[5],(0,$.useEffect)(m,v),!n)return null;let y,x,S,C;t[6]!==c||t[7]!==f?(C=c.trim(),x=C===``||!Jn(C),y=!x&&!f,S=C.includes(`/`)?C.split(`/`).slice(0,-1).join(`/`):null,t[6]=c,t[7]=f,t[8]=y,t[9]=x,t[10]=S,t[11]=C):(y=t[8],x=t[9],S=t[10],C=t[11]);let D=S,k;t[12]!==i||t[13]!==y||t[14]!==r||t[15]!==a||t[16]!==n||t[17]!==C?(k=async function(){if(!n||!y)return;p(!0);let e=/\.mdx?$/i.test(C),t=await Je({scope:n.skill.scope,name:n.skill.name,path:C,content:e?`# ${C.split(`/`).pop()?.replace(/\.mdx?$/i,``)??``}\n`:``});if(p(!1),!t.ok){Z.error(i({id:`a_2_uB`,values:{0:t.error,trimmed:C}}));return}if(Z.success(i({id:`MXSt4t`,values:{0:t.path}})),e){let e=Be(n.skill,C);a({kind:`doc`,target:e,docName:e})}r(!1)},t[12]=i,t[13]=y,t[14]=r,t[15]=a,t[16]=n,t[17]=C,t[18]=k):k=t[18];let j=k,M;t[19]!==r||t[20]!==f?(M=e=>{!e&&!f&&r(!1)},t[19]=r,t[20]=f,t[21]=M):M=t[21];let N;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`wQvvZY`})}),t[22]=N):N=t[22];let P;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsxs)(ee,{children:[N,(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`lM4c-I`})})]}),t[23]=P):P=t[23];let F;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Q.jsx)(l,{id:`I6gXOa`}),t[24]=F):F=t[24];let I;t[25]===o?I=t[26]:(I=(0,Q.jsx)(te,{htmlFor:o,children:F}),t[25]=o,t[26]=I);let L;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>d(e.target.value),t[27]=L):L=t[27];let R=x&&C!==``,z;t[28]===j?z=t[29]:(z=e=>{e.key===`Enter`&&j()},t[28]=j,t[29]=z);let B;t[30]!==o||t[31]!==c||t[32]!==R||t[33]!==z?(B=(0,Q.jsx)(Pe,{id:o,value:c,onChange:L,placeholder:`references/notes.md`,"aria-invalid":R,onKeyDown:z}),t[30]=o,t[31]=c,t[32]=R,t[33]=z,t[34]=B):B=t[34];let V;t[35]!==D||t[36]!==x||t[37]!==C?(V=x&&C!==``?(0,Q.jsx)(`p`,{className:`text-destructive text-xs`,children:(0,Q.jsx)(l,{id:`fVzizW`})}):D?(0,Q.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:(0,Q.jsx)(l,{id:`9lso1Y`,values:{folderPart:D},components:{0:(0,Q.jsx)(`span`,{className:`font-mono text-foreground/80`})}})}):null,t[35]=D,t[36]=x,t[37]=C,t[38]=V):V=t[38];let H;t[39]!==I||t[40]!==B||t[41]!==V?(H=(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[I,B,V]}),t[39]=I,t[40]=B,t[41]=V,t[42]=H):H=t[42];let U;t[43]===r?U=t[44]:(U=()=>r(!1),t[43]=r,t[44]=U);let W;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Q.jsx)(l,{id:`dEgA5A`}),t[45]=W):W=t[45];let G;t[46]!==f||t[47]!==U?(G=(0,Q.jsx)(b,{variant:`outline`,onClick:U,disabled:f,children:W}),t[46]=f,t[47]=U,t[48]=G):G=t[48];let K;t[49]===j?K=t[50]:(K=()=>void j(),t[49]=j,t[50]=K);let q=!y,J;t[51]===f?J=t[52]:(J=f?(0,Q.jsx)(l,{id:`E9bKSA`}):(0,Q.jsx)(l,{id:`hYgDIe`}),t[51]=f,t[52]=J);let Y;t[53]!==K||t[54]!==q||t[55]!==J?(Y=(0,Q.jsx)(b,{onClick:K,disabled:q,children:J}),t[53]=K,t[54]=q,t[55]=J,t[56]=Y):Y=t[56];let ne;t[57]!==G||t[58]!==Y?(ne=(0,Q.jsxs)(O,{children:[G,Y]}),t[57]=G,t[58]=Y,t[59]=ne):ne=t[59];let X;t[60]!==H||t[61]!==ne?(X=(0,Q.jsxs)(E,{className:`sm:max-w-md`,children:[P,H,ne]}),t[60]=H,t[61]=ne,t[62]=X):X=t[62];let re;return t[63]!==X||t[64]!==M?(re=(0,Q.jsx)(A,{open:!0,onOpenChange:M,children:X}),t[63]=X,t[64]=M,t[65]=re):re=t[65],re}function Xn(e){let t=(0,_t.c)(64),{target:n,onOpenChange:r}=e,{_:i}=u(),a=Oe(),o=(0,$.useId)(),[s,c]=(0,$.useState)(``),[d,f]=(0,$.useState)(!1),p;t[0]===n?p=t[1]:(p=()=>{n&&c(n.filePath)},t[0]=n,t[1]=p);let m=n?.skill.scope,h=n?.skill.name,g=n?.filePath,_;if(t[2]!==m||t[3]!==h||t[4]!==g?(_=[m,h,g],t[2]=m,t[3]=h,t[4]=g,t[5]=_):_=t[5],(0,$.useEffect)(p,_),!n)return null;let v,y,x;t[6]!==s||t[7]!==n.filePath?(y=s.trim(),x=y===n.filePath,v=y===``||!Jn(y),t[6]=s,t[7]=n.filePath,t[8]=v,t[9]=y,t[10]=x):(v=t[8],y=t[9],x=t[10]);let S=v,C=!S&&!x&&!d,D;t[11]!==i||t[12]!==C||t[13]!==r||t[14]!==a||t[15]!==n||t[16]!==y?(D=async function(){if(!n||!C)return;f(!0);let e=await at({scope:n.skill.scope,name:n.skill.name,from:n.filePath,to:y});if(f(!1),!e.ok){Z.error(i({id:`11ukmX`,values:{0:e.error}}));return}e.fromDocName!==void 0&&e.toDocName!==void 0&&a(e.fromDocName,e.toDocName),Z.success(i({id:`XszXjc`,values:{0:e.to}})),r(!1)},t[11]=i,t[12]=C,t[13]=r,t[14]=a,t[15]=n,t[16]=y,t[17]=D):D=t[17];let k=D,j;t[18]!==r||t[19]!==d?(j=e=>{!e&&!d&&r(!1)},t[18]=r,t[19]=d,t[20]=j):j=t[20];let M;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`yckias`})}),t[21]=M):M=t[21];let N;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsxs)(ee,{children:[M,(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`HzVAoz`})})]}),t[22]=N):N=t[22];let P;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(l,{id:`I6gXOa`}),t[23]=P):P=t[23];let F;t[24]===o?F=t[25]:(F=(0,Q.jsx)(te,{htmlFor:o,children:P}),t[24]=o,t[25]=F);let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>c(e.target.value),t[26]=I):I=t[26];let L=S&&y!==``,R;t[27]===k?R=t[28]:(R=e=>{e.key===`Enter`&&k()},t[27]=k,t[28]=R);let z;t[29]!==o||t[30]!==s||t[31]!==L||t[32]!==R?(z=(0,Q.jsx)(Pe,{id:o,value:s,onChange:I,"aria-invalid":L,onKeyDown:R}),t[29]=o,t[30]=s,t[31]=L,t[32]=R,t[33]=z):z=t[33];let B;t[34]!==S||t[35]!==y?(B=S&&y!==``?(0,Q.jsx)(`p`,{className:`text-destructive text-xs`,children:(0,Q.jsx)(l,{id:`fVzizW`})}):null,t[34]=S,t[35]=y,t[36]=B):B=t[36];let V;t[37]!==F||t[38]!==z||t[39]!==B?(V=(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[F,z,B]}),t[37]=F,t[38]=z,t[39]=B,t[40]=V):V=t[40];let H;t[41]===r?H=t[42]:(H=()=>r(!1),t[41]=r,t[42]=H);let U;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(l,{id:`dEgA5A`}),t[43]=U):U=t[43];let W;t[44]!==d||t[45]!==H?(W=(0,Q.jsx)(b,{variant:`outline`,onClick:H,disabled:d,children:U}),t[44]=d,t[45]=H,t[46]=W):W=t[46];let G;t[47]===k?G=t[48]:(G=()=>void k(),t[47]=k,t[48]=G);let K=!C,q;t[49]===d?q=t[50]:(q=d?(0,Q.jsx)(l,{id:`tHKQ6j`}):(0,Q.jsx)(l,{id:`2wxgft`}),t[49]=d,t[50]=q);let J;t[51]!==G||t[52]!==K||t[53]!==q?(J=(0,Q.jsx)(b,{onClick:G,disabled:K,children:q}),t[51]=G,t[52]=K,t[53]=q,t[54]=J):J=t[54];let Y;t[55]!==W||t[56]!==J?(Y=(0,Q.jsxs)(O,{children:[W,J]}),t[55]=W,t[56]=J,t[57]=Y):Y=t[57];let ne;t[58]!==V||t[59]!==Y?(ne=(0,Q.jsxs)(E,{className:`sm:max-w-md`,children:[N,V,Y]}),t[58]=V,t[59]=Y,t[60]=ne):ne=t[60];let X;return t[61]!==ne||t[62]!==j?(X=(0,Q.jsx)(A,{open:!0,onOpenChange:j,children:ne}),t[61]=ne,t[62]=j,t[63]=X):X=t[63],X}function Zn(e){let t=(0,_t.c)(59),{target:n,onOpenChange:r}=e,{_:i}=u(),a=(0,$.useId)(),[o,s]=(0,$.useState)(null),[c,d]=(0,$.useState)(null),[f,p]=(0,$.useState)(!1),[m,h]=(0,$.useState)(!1),[g,_]=(0,$.useState)(``),[v,y]=(0,$.useState)(!1),x;t[0]===n?x=t[1]:(x=()=>{if(s(null),d(null),p(!1),h(!1),!n)return;let{skill:e,editor:t}=n,r=e.absolutePath?.slice(0,-`/${e.path}`.length)??null;if(r===null){p(!0);return}let i=`${r}/${e.path.replace(/\/SKILL\.mdx?$/i,``)}`,a=`${r}/${qe(t,e.scope)}/${e.name}`,o=new AbortController;for(let[t,n]of[[i,d],[a,s]])$e({source:t,name:e.name},o.signal).then(e=>{o.signal.aborted||(e.ok?n(e.skillMd):p(!0))}).catch(()=>{o.signal.aborted||p(!0)});return()=>o.abort()},t[0]=n,t[1]=x);let S=n?.skill.scope,C=n?.skill.name,k=n?.editor,j;if(t[2]!==S||t[3]!==C||t[4]!==k?(j=[S,C,k],t[2]=S,t[3]=C,t[4]=k,t[5]=j):j=t[5],(0,$.useEffect)(x,j),!n)return null;let{skill:M,editor:N}=n,P;t[6]!==i||t[7]!==N||t[8]!==r||t[9]!==M.name||t[10]!==M.scope||t[11]!==n||t[12]!==g?(P=async function(e){if(!n)return;y(!0);let t=await Ze({scope:M.scope,name:M.name,editor:N,action:e,...e===`rename`?{toName:g.trim()}:{}});if(y(!1),!t.ok){Z.error(i({id:`MIF36T`,values:{0:t.error}}));return}Z.success(i(e===`align`?{id:`QKgePK`,values:{editor:N}}:e===`make-source`?{id:`It9oAP`,values:{editor:N}}:{id:`b2ezG_`,values:{0:g.trim()}})),r(!1)},t[6]=i,t[7]=N,t[8]=r,t[9]=M.name,t[10]=M.scope,t[11]=n,t[12]=g,t[13]=P):P=t[13];let F=P,I,L;t[14]!==M.name||t[15]!==g?(L=g.trim(),I=L===``||!Ce.test(L)||L===M.name,t[14]=M.name,t[15]=g,t[16]=I,t[17]=L):(I=t[16],L=t[17]);let R=I,z;t[18]!==v||t[19]!==r?(z=e=>{!e&&!v&&r(!1)},t[18]=v,t[19]=r,t[20]=z):z=t[20];let B;t[21]!==N||t[22]!==M.name?(B=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`q8aCbb`,values:{0:M.name,editor:N}})}),t[21]=N,t[22]=M.name,t[23]=B):B=t[23];let V;t[24]===N?V=t[25]:(V=(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`QASTNu`,values:{editor:N}})}),t[24]=N,t[25]=V);let H;t[26]!==V||t[27]!==B?(H=(0,Q.jsxs)(ee,{children:[B,V]}),t[26]=V,t[27]=B,t[28]=H):H=t[28];let U;t[29]!==c||t[30]!==o||t[31]!==f?(U=c!==null&&o!==null?(0,Q.jsx)(dt,{oldContent:c,newContent:o,layout:`unified`}):f?(0,Q.jsx)(`div`,{className:`flex min-h-56 items-center justify-center px-6 text-center text-muted-foreground text-sm`,children:(0,Q.jsx)(l,{id:`5BlXTD`})}):(0,Q.jsx)(`div`,{className:`flex min-h-56 items-center justify-center text-muted-foreground text-sm`,children:(0,Q.jsx)(l,{id:`1V17kO`})}),t[29]=c,t[30]=o,t[31]=f,t[32]=U):U=t[32];let W;t[33]!==F||t[34]!==N||t[35]!==a||t[36]!==R||t[37]!==m||t[38]!==M.name||t[39]!==g||t[40]!==L?(W=m?(0,Q.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,Q.jsx)(te,{htmlFor:a,children:(0,Q.jsx)(l,{id:`pSimwP`,values:{editor:N}})}),(0,Q.jsx)(Pe,{id:a,value:g,onChange:e=>_(e.target.value),placeholder:`${M.name}-${N}`,"aria-invalid":R&&L!==``,onKeyDown:e=>{e.key===`Enter`&&!R&&F(`rename`)}})]}):null,t[33]=F,t[34]=N,t[35]=a,t[36]=R,t[37]=m,t[38]=M.name,t[39]=g,t[40]=L,t[41]=W):W=t[41];let G;t[42]!==U||t[43]!==W?(G=(0,Q.jsxs)(D,{className:`min-h-0 flex-1 overflow-auto`,children:[U,W]}),t[42]=U,t[43]=W,t[44]=G):G=t[44];let K;t[45]!==F||t[46]!==v||t[47]!==N||t[48]!==R||t[49]!==m||t[50]!==M.name?(K=(0,Q.jsx)(O,{children:m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{variant:`outline`,onClick:()=>h(!1),disabled:v,children:(0,Q.jsx)(l,{id:`iH8pgl`})}),(0,Q.jsx)(b,{onClick:()=>void F(`rename`),disabled:v||R,children:(0,Q.jsx)(l,{id:`AT0e50`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{variant:`outline`,onClick:()=>{_(`${M.name}-${N}`),h(!0)},disabled:v,children:(0,Q.jsx)(l,{id:`AT0e50`})}),(0,Q.jsx)(b,{variant:`outline`,onClick:()=>void F(`make-source`),disabled:v,children:(0,Q.jsx)(l,{id:`xWomUD`,values:{editor:N}})}),(0,Q.jsx)(b,{onClick:()=>void F(`align`),disabled:v,children:(0,Q.jsx)(l,{id:`PZn2LP`})})]})}),t[45]=F,t[46]=v,t[47]=N,t[48]=R,t[49]=m,t[50]=M.name,t[51]=K):K=t[51];let q;t[52]!==H||t[53]!==G||t[54]!==K?(q=(0,Q.jsxs)(E,{className:`flex max-h-[85vh] w-full max-w-3xl flex-col`,children:[H,G,K]}),t[52]=H,t[53]=G,t[54]=K,t[55]=q):q=t[55];let J;return t[56]!==q||t[57]!==z?(J=(0,Q.jsx)(A,{open:!0,onOpenChange:z,children:q}),t[56]=q,t[57]=z,t[58]=J):J=t[58],J}function Qn(e){let t=(0,_t.c)(75),{skill:n,existingNames:r,onOpenChange:i,onRenamed:a}=e,o=ke(),s=n!==null,c=(0,$.useId)(),[u,d]=(0,$.useState)(``),[f,p]=(0,$.useState)(!1),m;t[0]===n?m=t[1]:(m=()=>{n&&d(n.name)},t[0]=n,t[1]=m);let h=n?.scope,g=n?.name,_;if(t[2]!==h||t[3]!==g?(_=[h,g],t[2]=h,t[3]=g,t[4]=_):_=t[4],(0,$.useEffect)(m,_),!n)return null;let v,y,x,S,C,D;if(t[5]!==r||t[6]!==u||t[7]!==n.name){C=u.trim(),D=C===n.name;let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\s/,t[14]=e):e=t[14];let i;t[15]===u?i=t[16]:(i=e.test(u),t[15]=u,t[16]=i),v=i,S=C.length>64,y=C===``||!Ce.test(C)||S,x=!y&&!D&&r.has(C),t[5]=r,t[6]=u,t[7]=n.name,t[8]=v,t[9]=y,t[10]=x,t[11]=S,t[12]=C,t[13]=D}else v=t[8],y=t[9],x=t[10],S=t[11],C=t[12],D=t[13];let k=x,j=!y&&!k&&!D&&!f,M;t[17]!==j||t[18]!==i||t[19]!==a||t[20]!==o||t[21]!==n||t[22]!==C?(M=async function(){if(!n||!j)return;p(!0);let e=await o({scope:n.scope,name:n.name},C);p(!1),e.ok&&(a?.(C),i(!1))},t[17]=j,t[18]=i,t[19]=a,t[20]=o,t[21]=n,t[22]=C,t[23]=M):M=t[23];let N=M,P;t[24]===i?P=t[25]:(P=e=>e?null:i(!1),t[24]=i,t[25]=P);let F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`dw_3cv`})}),t[26]=F):F=t[26];let I;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsxs)(ee,{children:[F,(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`R9IDFz`})})]}),t[27]=I):I=t[27];let L;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(l,{id:`6YtxFj`}),t[28]=L):L=t[28];let R;t[29]===c?R=t[30]:(R=(0,Q.jsx)(te,{htmlFor:c,children:L}),t[29]=c,t[30]=R);let z;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>d(e.target.value),t[31]=z):z=t[31];let B;t[32]===N?B=t[33]:(B=e=>{e.key===`Enter`&&N()},t[32]=N,t[33]=B);let V=y||k,H=y&&C!==``||k?`${c}-error`:void 0,U;t[34]!==c||t[35]!==u||t[36]!==B||t[37]!==V||t[38]!==H?(U=(0,Q.jsx)(Pe,{id:c,value:u,onChange:z,onKeyDown:B,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,maxLength:64,"aria-invalid":V,"aria-describedby":H,className:`font-mono`}),t[34]=c,t[35]=u,t[36]=B,t[37]=V,t[38]=H,t[39]=U):U=t[39];let W;t[40]!==k||t[41]!==v||t[42]!==c||t[43]!==y||t[44]!==S||t[45]!==C?(W=y&&C!==``?(0,Q.jsx)(`p`,{id:`${c}-error`,className:`text-xs text-destructive`,children:v?(0,Q.jsx)(l,{id:`iUwpZI`,components:{0:(0,Q.jsx)(`code`,{className:`font-mono`})}}):S?(0,Q.jsx)(l,{id:`lK9c4T`}):(0,Q.jsx)(l,{id:`A50vr3`,components:{0:(0,Q.jsx)(`code`,{className:`font-mono`})}})}):k?(0,Q.jsx)(`p`,{id:`${c}-error`,className:`text-xs text-destructive`,children:(0,Q.jsx)(l,{id:`YJ1BTp`})}):null,t[40]=k,t[41]=v,t[42]=c,t[43]=y,t[44]=S,t[45]=C,t[46]=W):W=t[46];let G;t[47]!==R||t[48]!==U||t[49]!==W?(G=(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[R,U,W]}),t[47]=R,t[48]=U,t[49]=W,t[50]=G):G=t[50];let K;t[51]===i?K=t[52]:(K=()=>i(!1),t[51]=i,t[52]=K);let q;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(l,{id:`dEgA5A`}),t[53]=q):q=t[53];let J;t[54]!==f||t[55]!==K?(J=(0,Q.jsx)(b,{variant:`outline`,className:`font-mono uppercase`,onClick:K,disabled:f,children:q}),t[54]=f,t[55]=K,t[56]=J):J=t[56];let Y;t[57]===N?Y=t[58]:(Y=()=>void N(),t[57]=N,t[58]=Y);let ne=!j,X;t[59]===f?X=t[60]:(X=f?(0,Q.jsx)(l,{id:`tHKQ6j`}):(0,Q.jsx)(l,{id:`2wxgft`}),t[59]=f,t[60]=X);let re;t[61]!==Y||t[62]!==ne||t[63]!==X?(re=(0,Q.jsx)(b,{onClick:Y,disabled:ne,children:X}),t[61]=Y,t[62]=ne,t[63]=X,t[64]=re):re=t[64];let ie;t[65]!==J||t[66]!==re?(ie=(0,Q.jsxs)(O,{children:[J,re]}),t[65]=J,t[66]=re,t[67]=ie):ie=t[67];let ae;t[68]!==G||t[69]!==ie?(ae=(0,Q.jsxs)(E,{children:[I,G,ie]}),t[68]=G,t[69]=ie,t[70]=ae):ae=t[70];let oe;return t[71]!==s||t[72]!==ae||t[73]!==P?(oe=(0,Q.jsx)(A,{open:s,onOpenChange:P,children:ae}),t[71]=s,t[72]=ae,t[73]=P,t[74]=oe):oe=t[74],oe}function $n(){let e=(0,_t.c)(5),{_:t}=u(),n=We(),r=Oe(),i=ct(),a;return e[0]!==t||e[1]!==r||e[2]!==n||e[3]!==i?(a=async(e,a)=>{if(a===e.scope)return!1;He(e.scope,e.name);let o=await Qe({name:e.name,fromScope:e.scope,toScope:a});if(Ve(e.scope,e.name),!o.ok)return Z.error(t({id:`07eGJB`,values:{0:o.error}})),!1;Z.success(t({id:`yhI6P0`,values:{0:e.name,1:n[a]}}));let s=i.status===`ready`?i.data.find(t=>t.scope===e.scope&&t.name===e.name):void 0;return r(s?Re(s):ce(e.scope,e.name),a===`project`&&o.path!==void 0?`${o.path.replace(/\/+$/,``)}/SKILL`:ce(a,e.name)),!0},e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=a):a=e[4],a}function er(e){let t=(0,_t.c)(38),{target:n,onOpenChange:r}=e,i=We(),a=$n(),[o,s]=(0,$.useState)(!1);if(!n)return null;let{scope:c,name:u,toScope:d}=n,f;t[0]!==o||t[1]!==r?(f=e=>!e&&!o&&r(!1),t[0]=o,t[1]=r,t[2]=f):f=t[2];let p=i[d],m;t[3]===p?m=t[4]:(m=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`SXEdCq`,values:{0:p}})}),t[3]=p,t[4]=m);let h=i[c],g=i[d],_=i[d],v;t[5]!==u||t[6]!==h||t[7]!==g||t[8]!==_?(v={0:h,1:g,2:_,name:u},t[5]=u,t[6]=h,t[7]=g,t[8]=_,t[9]=v):v=t[9];let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y={0:(0,Q.jsx)(`code`,{className:`font-mono`})},t[10]=y):y=t[10];let x;t[11]===v?x=t[12]:(x=(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`7bIiJ7`,values:v,components:y})}),t[11]=v,t[12]=x);let S;t[13]!==m||t[14]!==x?(S=(0,Q.jsxs)(ee,{children:[m,x]}),t[13]=m,t[14]=x,t[15]=S):S=t[15];let C;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(l,{id:`dEgA5A`}),t[16]=C):C=t[16];let D;t[17]===o?D=t[18]:(D=(0,Q.jsx)(k,{asChild:!0,children:(0,Q.jsx)(b,{variant:`outline`,disabled:o,children:C})}),t[17]=o,t[18]=D);let j;t[19]!==a||t[20]!==u||t[21]!==r||t[22]!==c||t[23]!==d?(j=async()=>{s(!0),await a({scope:c,name:u},d),s(!1),r(!1)},t[19]=a,t[20]=u,t[21]=r,t[22]=c,t[23]=d,t[24]=j):j=t[24];let M;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(l,{id:`QWdKwH`}),t[25]=M):M=t[25];let N;t[26]!==o||t[27]!==j?(N=(0,Q.jsx)(b,{"data-testid":`skill-scope-move-confirm`,disabled:o,onClick:j,children:M}),t[26]=o,t[27]=j,t[28]=N):N=t[28];let P;t[29]!==D||t[30]!==N?(P=(0,Q.jsxs)(O,{children:[D,N]}),t[29]=D,t[30]=N,t[31]=P):P=t[31];let F;t[32]!==S||t[33]!==P?(F=(0,Q.jsxs)(E,{className:`sm:max-w-md`,children:[S,P]}),t[32]=S,t[33]=P,t[34]=F):F=t[34];let I;return t[35]!==f||t[36]!==F?(I=(0,Q.jsx)(A,{open:!0,onOpenChange:f,children:F}),t[35]=f,t[36]=F,t[37]=I):I=t[37],I}function tr(){let e=(0,_t.c)(45),{_:t}=u(),n=lt(),[r,i]=(0,$.useState)(null),[a,o]=(0,$.useState)(null),[s,c]=(0,$.useState)(null),[l,d]=(0,$.useState)(null),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(null),[g,_]=(0,$.useState)(null),v;e[0]===t?v=e[1]:(v=async function(e,n,r){_(e.name);let i=await et({scope:e.scope,name:e.name,...n?{targets:[...n]}:{},...r?.linkMode===void 0?{}:{linkMode:r.linkMode}});if(_(null),!i.ok)return Z.error(t({id:`Mj8R8K`,values:{0:i.error}})),i;let a=nr,o=new Set(i.hosts),s=i.hosts.filter(t=>!e.hosts.includes(t)),c=e.hosts.filter(e=>!o.has(e)),l=e=>{let t=i.warningCodes.indexOf(e);return t>=0?i.warnings[t]:void 0},u=l(`no-targets`);if(u)return Z.warning(u),i;if(s.length>0){let e=l(`scripts-present`);e&&Z.warning(e);let t=l(`no-description`);t&&Z.warning(t)}return i.hosts.length===0?Z.success(t({id:`4pDZ2N`,values:{0:e.name}})):s.length>0&&c.length===0?Z.success(t({id:`PPFQ3o`,values:{0:e.name,1:a(s)}})):c.length>0&&s.length===0?Z.success(t({id:`OOIVJo`,values:{0:e.name,1:a(c)}})):s.length>0&&c.length>0?Z.success(t({id:`OxplNM`,values:{0:e.name,1:a(s),2:a(c)}})):Z.success(t({id:`wDgmsr`,values:{0:e.name,1:a(i.hosts)}})),i},e[0]=t,e[1]=v);let y=v,b;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=async function(e,t){if(t.length!==0){_(e.name);for(let{target:n,mode:r}of t){let t=await rt({scope:e.scope,name:e.name,target:n,mode:r});if(!t.ok){Z.error(t.error);break}}_(null)}},e[2]=b):b=e[2];let x=b,S;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=async function(e,t){_(e.name);let n=await t();return _(null),n},e[3]=S):S=e[3];let C=S,w;e[4]!==t||e[5]!==n?(w=async function(e,r){let i=await tt({scope:e.scope,name:e.name,existingNames:r});if(!i.ok){Z.error(t({id:`UPjaXD`,values:{0:e.name,1:i.error}}));return}Z.success(t({id:`0g7rCZ`,values:{0:i.name}})),n(e.scope,i.name)},e[4]=t,e[5]=n,e[6]=w):w=e[6];let T=w,E,D;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>{e||i(null)},D=()=>i(null),e[7]=E,e[8]=D):(E=e[7],D=e[8]);let O;e[9]===r?O=e[10]:(O=(0,Q.jsx)(qn,{skill:r,onOpenChange:E,onDeleted:D}),e[9]=r,e[10]=O);let k=a?.skill??null,ee=a?.existingNames??ir,A,j;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{e||o(null)},A=()=>o(null),e[11]=A,e[12]=j):(A=e[11],j=e[12]);let M;e[13]!==k||e[14]!==ee?(M=(0,Q.jsx)(Qn,{skill:k,existingNames:ee,onOpenChange:j,onRenamed:A}),e[13]=k,e[14]=ee,e[15]=M):M=e[15];let N;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{e||c(null)},e[16]=N):N=e[16];let P;e[17]===s?P=e[18]:(P=(0,Q.jsx)(er,{target:s,onOpenChange:N}),e[17]=s,e[18]=P);let F;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{e||d(null)},e[19]=F):F=e[19];let I;e[20]===l?I=e[21]:(I=(0,Q.jsx)(Xn,{target:l,onOpenChange:F}),e[20]=l,e[21]=I);let L;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{e||p(null)},e[22]=L):L=e[22];let R;e[23]===f?R=e[24]:(R=(0,Q.jsx)(Yn,{target:f,onOpenChange:L}),e[23]=f,e[24]=R);let te;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{e||h(null)},e[25]=te):te=e[25];let z;e[26]===m?z=e[27]:(z=(0,Q.jsx)(Zn,{target:m,onOpenChange:te}),e[26]=m,e[27]=z);let B;e[28]!==M||e[29]!==P||e[30]!==I||e[31]!==R||e[32]!==z||e[33]!==O?(B=(0,Q.jsxs)(Q.Fragment,{children:[O,M,P,I,R,z]}),e[28]=M,e[29]=P,e[30]=I,e[31]=R,e[32]=z,e[33]=O,e[34]=B):B=e[34];let V=B,H,U,W,G,K;e[35]===Symbol.for(`react.memo_cache_sentinel`)?(H=(e,t)=>o({skill:e,existingNames:t}),U=(e,t)=>c({scope:e.scope,name:e.name,toScope:t}),W=(e,t)=>d({skill:e,filePath:t}),G=(e,t)=>p(t===void 0?{skill:e}:{skill:e,prefix:t}),K=(e,t)=>h({skill:e,editor:t}),e[35]=H,e[36]=U,e[37]=W,e[38]=G,e[39]=K):(H=e[35],U=e[36],W=e[37],G=e[38],K=e[39]);let q;return e[40]!==V||e[41]!==T||e[42]!==y||e[43]!==g?(q={installingName:g,install:y,convertLocations:x,runLocationWrite:C,duplicate:T,requestDelete:i,requestRename:H,requestScopeMove:U,requestFileRename:W,requestFileCreate:G,requestForkResolve:K,dialogs:V},e[40]=V,e[41]=T,e[42]=y,e[43]=g,e[44]=q):q=e[44],q}function nr(e){return e.map(rr).join(`, `)}function rr(e){return ve[e]??e}var ir=new Set;function ar(e){let t=(0,_t.c)(29),{skill:n,filePath:r,actions:i}=e,{_:a}=u(),o=typeof window<`u`?window.okDesktop:void 0,s=n.absolutePath?`${n.absolutePath}/${r}`:void 0,c=`${n.path}/${r}`,d;t[0]===a?d=t[1]:(d=async function(e){try{await ut(e),Z.success(a({id:`SXCSQd`}))}catch{Z.error(a({id:`cRHuuI`}))}},t[0]=a,t[1]=d);let f=d,p;t[2]!==i||t[3]!==r||t[4]!==n?(p=()=>i.requestFileRename(n,r),t[2]=i,t[3]=r,t[4]=n,t[5]=p):p=t[5];let m,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(ht,{"aria-hidden":!0}),h=(0,Q.jsx)(l,{id:`2wxgft`}),t[6]=m,t[7]=h):(m=t[6],h=t[7]);let g;t[8]===p?g=t[9]:(g=(0,Q.jsxs)(j,{onSelect:p,children:[m,h]}),t[8]=p,t[9]=g);let _;t[10]===s?_=t[11]:(_=o&&s?(0,Q.jsxs)(j,{onSelect:()=>void o.shell.showItemInFolder(s),children:[(0,Q.jsx)(je,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`LtSYdi`})]}):null,t[10]=s,t[11]=_);let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(Ae,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`zd00pH`})]}),t[12]=v):v=t[12];let y;t[13]!==s||t[14]!==f?(y=s?(0,Q.jsx)(j,{onSelect:()=>void f(s),children:(0,Q.jsx)(l,{id:`z2funE`})}):null,t[13]=s,t[14]=f,t[15]=y):y=t[15];let b;t[16]!==f||t[17]!==c?(b=()=>void f(c),t[16]=f,t[17]=c,t[18]=b):b=t[18];let x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(l,{id:`xloBjn`}),t[19]=x):x=t[19];let S;t[20]===b?S=t[21]:(S=(0,Q.jsx)(j,{onSelect:b,children:x}),t[20]=b,t[21]=S);let C;t[22]!==S||t[23]!==y?(C=(0,Q.jsxs)(M,{children:[v,(0,Q.jsxs)(N,{children:[y,S]})]}),t[22]=S,t[23]=y,t[24]=C):C=t[24];let w;return t[25]!==C||t[26]!==g||t[27]!==_?(w=(0,Q.jsxs)(Q.Fragment,{children:[g,_,C]}),t[25]=C,t[26]=g,t[27]=_,t[28]=w):w=t[28],w}function or(e){let t=(0,_t.c)(86),{skill:n,actions:r,existingNames:a}=e,{_:o}=u(),s=p(),c=We(),d=v().states,{dispatch:f}=un(),h=bn(n,r),g=typeof window<`u`?window.okDesktop:void 0,_=n.absolutePath,y;t[0]===o?y=t[1]:(y=async function(e){try{await ut(e),Z.success(o({id:`SXCSQd`}))}catch{Z.error(o({id:`cRHuuI`}))}},t[0]=o,t[1]=y);let b=y,x;t[2]===_?x=t[3]:(x=g&&_?(0,Q.jsxs)(j,{onSelect:()=>void g.shell.showItemInFolder(_),children:[(0,Q.jsx)(je,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`LtSYdi`})]}):null,t[2]=_,t[3]=x);let S;t[4]!==n.name||t[5]!==n.scope||t[6]!==s?(S=Kt({skillName:n.name,scope:n.scope,workspace:s}),t[4]=n.name,t[5]=n.scope,t[6]=s,t[7]=S):S=t[7];let C;t[8]!==f||t[9]!==d||t[10]!==S?(C=(0,Q.jsx)(Bn,{input:S,installStates:d,isElectronHost:g!=null,dispatch:f}),t[8]=f,t[9]=d,t[10]=S,t[11]=C):C=t[11];let w;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(Ae,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`zd00pH`})]}),t[12]=w):w=t[12];let T;t[13]!==_||t[14]!==b?(T=_?(0,Q.jsx)(j,{onSelect:()=>void b(_),children:(0,Q.jsx)(l,{id:`z2funE`})}):null,t[13]=_,t[14]=b,t[15]=T):T=t[15];let E;t[16]!==b||t[17]!==n.path?(E=()=>void b(n.path),t[16]=b,t[17]=n.path,t[18]=E):E=t[18];let D;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Q.jsx)(l,{id:`xloBjn`}),t[19]=D):D=t[19];let O;t[20]===E?O=t[21]:(O=(0,Q.jsx)(j,{onSelect:E,children:D}),t[20]=E,t[21]=O);let k;t[22]!==T||t[23]!==O?(k=(0,Q.jsxs)(M,{children:[w,(0,Q.jsxs)(N,{children:[T,O]})]}),t[22]=T,t[23]=O,t[24]=k):k=t[24];let ee;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Q.jsx)(R,{}),t[25]=ee):ee=t[25];let A;t[26]!==r||t[27]!==a||t[28]!==n?(A=()=>void r.duplicate(n,a),t[26]=r,t[27]=a,t[28]=n,t[29]=A):A=t[29];let P,F;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(i,{"aria-hidden":!0}),F=(0,Q.jsx)(l,{id:`euc6Ns`}),t[30]=P,t[31]=F):(P=t[30],F=t[31]);let I;t[32]===A?I=t[33]:(I=(0,Q.jsxs)(j,{onSelect:A,children:[P,F]}),t[32]=A,t[33]=I);let te;t[34]!==r||t[35]!==a||t[36]!==n?(te=()=>r.requestRename(n,a),t[34]=r,t[35]=a,t[36]=n,t[37]=te):te=t[37];let z,B;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Q.jsx)(ht,{"aria-hidden":!0}),B=(0,Q.jsx)(l,{id:`2wxgft`}),t[38]=z,t[39]=B):(z=t[38],B=t[39]);let V;t[40]===te?V=t[41]:(V=(0,Q.jsxs)(j,{onSelect:te,children:[z,B]}),t[40]=te,t[41]=V);let H;t[42]!==r||t[43]!==n?(H=()=>r.requestFileCreate(n),t[42]=r,t[43]=n,t[44]=H):H=t[44];let U,W;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(m,{"aria-hidden":!0}),W=(0,Q.jsx)(l,{id:`HdkSiO`}),t[45]=U,t[46]=W):(U=t[45],W=t[46]);let G;t[47]===H?G=t[48]:(G=(0,Q.jsxs)(j,{onSelect:H,children:[U,W]}),t[47]=H,t[48]=G);let K;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(pt,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`TKQ7K-`})]}),t[49]=K):K=t[49];let q;t[50]!==r||t[51]!==n?(q=e=>r.requestForkResolve(n,e),t[50]=r,t[51]=n,t[52]=q):q=t[52];let J;t[53]!==h||t[54]!==n||t[55]!==q?(J=(0,Q.jsxs)(M,{children:[K,(0,Q.jsx)(N,{className:yn,children:(0,Q.jsx)(Tn,{toggles:h,skill:n,onResolveFork:q})})]}),t[53]=h,t[54]=n,t[55]=q,t[56]=J):J=t[56];let Y;t[57]!==r||t[58]!==n?(Y=()=>r.requestScopeMove(n,n.scope===`project`?`global`:`project`),t[57]=r,t[58]=n,t[59]=Y):Y=t[59];let ne;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Q.jsx)(ft,{"aria-hidden":!0}),t[60]=ne):ne=t[60];let X;t[61]!==c.global||t[62]!==c.project||t[63]!==n.scope?(X=n.scope===`project`?(0,Q.jsx)(l,{id:`bpytj4`,values:{0:c.global}}):(0,Q.jsx)(l,{id:`bpytj4`,values:{0:c.project}}),t[61]=c.global,t[62]=c.project,t[63]=n.scope,t[64]=X):X=t[64];let re;t[65]!==Y||t[66]!==X?(re=(0,Q.jsxs)(j,{onSelect:Y,children:[ne,X]}),t[65]=Y,t[66]=X,t[67]=re):re=t[67];let ie;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(R,{}),t[68]=ie):ie=t[68];let ae;t[69]!==r||t[70]!==n?(ae=()=>r.requestDelete(n),t[69]=r,t[70]=n,t[71]=ae):ae=t[71];let oe,se;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Q.jsx)(Ne,{"aria-hidden":!0}),se=(0,Q.jsx)(l,{id:`cnGeoo`}),t[72]=oe,t[73]=se):(oe=t[72],se=t[73]);let ce;t[74]===ae?ce=t[75]:(ce=(0,Q.jsxs)(j,{variant:`destructive`,onSelect:ae,children:[oe,se]}),t[74]=ae,t[75]=ce);let le;return t[76]!==k||t[77]!==I||t[78]!==V||t[79]!==x||t[80]!==G||t[81]!==J||t[82]!==re||t[83]!==ce||t[84]!==C?(le=(0,Q.jsxs)(Q.Fragment,{children:[x,C,k,ee,I,V,G,J,re,ie,ce]}),t[76]=k,t[77]=I,t[78]=V,t[79]=x,t[80]=G,t[81]=J,t[82]=re,t[83]=ce,t[84]=C,t[85]=le):le=t[85],le}export{gt as C,Bt as S,ft as T,en as _,Wn as a,an as b,vn as c,bn as d,qt as f,Ht as g,Vt as h,er as i,yn as l,Gt as m,ar as n,Bn as o,Ut as p,tr as r,Rn as s,or as t,Tn as u,sn as v,mt as w,un as x,Wt as y};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{F as n,I as r,P as i,Pn as a,_n as o,i as s}from"./DocumentContext-UuXLA8HR.js";import{t as c}from"./react-f2sANaYj.js";import{n as l,r as u}from"./dist-Nvb76hAm.js";import{t as d}from"./compiler-runtime-BfE3aGVn.js";import{l as f}from"./terminal-input-events-BGPQuYMh.js";import{t as p}from"./use-workspace-C_kPbTuK.js";import{c as m,i as h,n as g,o as _,s as v,t as y}from"./ChangedOutsideBadge-D93fNuY2.js";import{t as b}from"./button-RQ5o7P7w.js";import{i as x,n as S,t as C}from"./tooltip-x7BNUa3s.js";import{a as w,c as T,i as E,n as D,o as O,r as k,s as ee,t as A}from"./dialog-FGMqkFjm.js";import{a as j,d as M,f as N,i as P,n as F,o as I,p as L,u as R}from"./dropdown-menu-AlVJ7dJz.js";import{t as te}from"./label-G0lbYOgL.js";import{C as z,a as B,f as V,h as H,m as U,n as W,o as G,p as K,r as q,s as J,t as Y}from"./agent-visibility-DvaU093e.js";import{$t as ne,Dt as X,Ia as re,Kt as ie,Mt as ae,Ra as oe,Sn as se,Va as ce,Zt as le,_n as ue,bn as de,en as fe,fn as pe,hn as me,jt as he,mn as ge,nt as _e,pa as ve,pn as ye,ri as be,tt as xe,xn as Se,xt as Ce,yn as we,yr as Te}from"./dist-OxboORfH2.js";import{t as Ee}from"./createLucideIcon-DihYAFEK.js";import{t as De}from"./RegisteredAgentIcon-DGE6x9DL.js";import{n as Oe,r as ke}from"./ManagedArtifactProperties-CQnVDYPq.js";import{n as Ae}from"./CopyButton-D6N3opvE.js";import{t as je}from"./folder-open-Ceue91os.js";import{t as Me}from"./folder-DcWlgZbb.js";import{t as Ne}from"./trash-2-WxyktwvM.js";import{n as Z}from"./dist-uN7pEWl0.js";import{t as Pe}from"./input-Cm94Cun3.js";import{t as Fe}from"./dist-CzC3AWOn.js";import{i as Ie}from"./use-settings-route-CIJMHLaP.js";import{t as Le}from"./parse-api-error-Dmlzsw8v.js";import{G as Re,O as ze,W as Be}from"./navigation-targets-GzXvLoSC.js";import{c as Ve,n as He,o as Ue}from"./documents-events-5TI0rZAg.js";import{d as We,n as Ge,r as Ke,s as qe}from"./skill-scope-CmujX5gW.js";import{A as Je,D as Ye,O as Xe,S as Ze,_ as Qe,c as $e,f as et,i as tt,n as nt,t as rt,v as it,x as at,y as ot}from"./skills-api-BeHeMfn9.js";import{n as st}from"./config-context-CYNq8R6z.js";import{t as ct}from"./use-skills-C2EtCeGb.js";import{t as lt}from"./use-open-skill-HTbCYiG5.js";import{n as ut}from"./clipboard-adapter-DdkYoUY3.js";import{t as dt}from"./DiffView-CiVa7sAS.js";var ft=Ee(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),pt=Ee(`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`}]]),mt=Ee(`list-plus`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]),ht=Ee(`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`}]]),gt=Ee(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Q=t(),$=e(c(),1),_t=d();function vt(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 yt(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=Le(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 bt(){if(typeof window>`u`)return null;let e=window.okDesktop?.skill;return e?vt(e):yt()}var xt=`ok:skill:cowork:installed`,St=`1`,Ct=250,wt=`/api/skill/install-state`;function Tt(e){return`${xt}:v${e}`}var Et=new Map;async function Dt(e={},t={}){let n=t.force?`__force__`:`__default__`,r=Et.get(n);if(r)return r;let i=Ot(e,t);return Et.set(n,i),i.finally(()=>{Et.get(n)===i&&Et.delete(n)}),i}async function Ot(e,t){let n=e.installer===void 0?bt():e.installer,r=kt(e.storage),i=e.fetchSnapshot??jt,a=e.serverTimeoutMs??Ct,o=null;if(!t.force){try{o=await Mt(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=Tt(o?.currentVersion??e.fallbackSkillVersion??At());if(!t.force&&r?.getItem(s)===St)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,St)}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 kt(e){if(e!==void 0)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function At(){return typeof window>`u`?`unknown`:window.okDesktop?.appVersion??`unknown`}async function jt(){let e;try{e=await fetch(wt,{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 Mt(e,t){return Promise.race([e,new Promise(e=>{setTimeout(()=>e(null),t)})])}function Nt(e){return Dt({},e)}function Pt(){return Dt({},{force:!0})}async function Ft(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 It(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis);switch(e.target){case`claude-cowork`:return Ft({target:`claude-cowork`,url:le({mode:`cowork`},e)},n);case`claude-code`:return Ft({target:`claude-code`,url:le({mode:`code`},e)},n);case`codex`:return Ft({target:`codex`,url:ne(e)},n);case`cursor`:return Ft({target:`cursor`,url:fe(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 Lt(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 Rt=`open-knowledge:agent-thread-launch`;function zt(e,t=typeof window>`u`?new EventTarget:window){t.dispatchEvent(new CustomEvent(Rt,{detail:e}))}function Bt(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(Rt,n),()=>t.removeEventListener(Rt,n)}function Vt(e){if(!e.docName||!e.workspace)return null;let t=i(e.docName),{contentDir:r,pathSeparator:a}=e.workspace;return{docContext:{relativePath:t},projectDir:r,docPath:n(r,t,a)}}function Ht(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 Wt(e){return K(e.installUrl).then(()=>void 0)}function Gt(e){return!e.workspace?.contentDir||!e.folderRelativePath?null:{docContext:null,folderRelativePath:e.folderRelativePath,projectDir:e.workspace.contentDir,docPath:``}}function Kt(e){return!e.workspace?.contentDir||!e.skillName?null:{docContext:null,skill:{name:e.skillName,scope:e.scope},projectDir:e.workspace.contentDir,docPath:``}}function qt(e){if(!e.workspace?.contentDir)return null;let{contentDir:t,pathSeparator:r}=e.workspace;if(e.docName){let a=e.docRelativePath??i(e.docName),o={scope:`doc`,docRelativePath:a,instruction:e.instruction,mentions:e.mentions};return{docContext:null,compose:e.selection===void 0?o:{...o,selection:e.selection},projectDir:t,docPath:n(t,a,r)}}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 Jt(e){return`Opened in ${e}.`}function Yt(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 Xt(e){return e>=3?null:e===2?`Try one more time`:`Retry`}function Zt(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 Qt(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 $t(e,t,n,r){return e.compose?ie(Qt(e.compose,t,n,r)):e.selection?we({...e.selection,target:t,transport:r}):e.skill?de(e.skill.name,e.skill.scope,n):e.ask?pe(e.ask.relativePath,e.ask.instruction,n,t,r):be(e.docContext===null?e.folderRelativePath?ue(e.folderRelativePath,n,e.instruction,r):e.createDescription===void 0?ge(n,e.instruction,r):ye(e.createDescription,n,e.createScenario??`new-project`,e.createMentions??[],r):me(e.docContext.relativePath,n,e.instruction,r))}function en(e,t){let n=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||n?`${xe} ${$t(e,he[t].handoffTarget,!1,`terminal`)}`:Se(e.docContext?.relativePath??null)}function tn(e){let t=typeof e.instruction==`string`&&e.instruction.trim()!==``;return e.compose!==void 0||e.createDescription!==void 0||t?`${_e} ${$t(e,`claude-code`,!1,`terminal`)}`:se(e.docContext?.relativePath??null)}function nn(e){let t=e.docContext?.relativePath;return typeof t!=`string`||t===``?null:t.replace(/\.(md|mdx)$/,``)}function rn(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 an(e,t){zt({agentSource:t?.agent?.source??`registry`,agentId:t?.agent?.id??``,prompt:tn(e),docName:nn(e),titleHint:rn(e)})}async function on(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:$t(t,e,n.autoOpen,`url`)},a=await n.dispatchHandoff(i),o=n.isElectronHost()?`electron`:`web`,s=n.now().toISOString(),c=t.compose,l=Zt(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(Jt(u));else{let i=Xt(r),a=Yt(u,r);i===null?n.toast.error(a):n.toast.error(a,{action:{label:i,onClick:()=>{on(e,t,n,r+1)}}})}return a}function sn(e){return U.find(t=>t.id===e)?.displayName??e}function cn(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function ln(){return{dispatchHandoff:It,recordHandoff:Lt,toast:{success:e=>{Z.success(e)},error:(e,t)=>{Z.error(e,t?{action:t.action}:void 0)}},now:()=>new Date,isElectronHost:()=>cn(),getDisplayName:sn,ensureCoworkSkillInstalled:Nt,autoOpen:!0}}function un(){let e=(0,_t.c)(2),{merged:t}=st(),n=t?.appearance?.preview?.autoOpen??!0,r;return e[0]===n?r=e[1]:(r={dispatch:(e,t)=>on(e,t,{...ln(),autoOpen:n}),reinstallCoworkSkill:Pt},e[0]=n,e[1]=r),r}var dn=Object.freeze({hosts:null,source:null}),fn=new Map,pn=new Map;function mn(e,t){return`${e}:${t}`}function hn(e){return fn.get(e)??dn}function gn(e,t){let n=pn.get(e)??new Set;return pn.set(e,n),n.add(t),()=>{n.delete(t),n.size===0&&pn.delete(e)}}function _n(e,t){let n=hn(e),r={...n,...t};if(!(r.hosts===n.hosts&&r.source===n.source)){r.hosts===null&&r.source===null?fn.delete(e):fn.set(e,r);for(let t of pn.get(e)??[])t()}}var vn=X.options,yn=`min-w-[24rem]`;function bn(e,t){let n=(0,_t.c)(45),r=t.installingName===e.name,i=(0,$.useRef)(e),[a,o]=(0,$.useState)(!1),s=(0,$.useRef)(!1),c,l;n[0]===r?(c=n[1],l=n[2]):(c=()=>{s.current&&!r&&o(!0),s.current=r},l=[r],n[0]=r,n[1]=c,n[2]=l),(0,$.useEffect)(c,l);let u,d;n[3]===e?(u=n[4],d=n[5]):(u=()=>{e!==i.current&&(i.current=e,o(!1))},d=[e],n[3]=e,n[4]=u,n[5]=d),(0,$.useEffect)(u,d);let f=r||a,p;n[6]!==e.name||n[7]!==e.scope?(p=mn(e.scope,e.name),n[6]=e.name,n[7]=e.scope,n[8]=p):p=n[8];let m=p,h,g;n[9]===m?(h=n[10],g=n[11]):(h=e=>gn(m,e),g=()=>hn(m),n[9]=m,n[10]=h,n[11]=g);let _=(0,$.useSyncExternalStore)(h,g),v=_.hosts,y=_.source,b,x;n[12]!==y||n[13]!==m||n[14]!==e.hosts?(b=()=>{y!==null&&e.hosts[0]===y&&_n(m,{source:null})},x=[e.hosts,y,m],n[12]=y,n[13]=m,n[14]=e.hosts,n[15]=b,n[16]=x):(b=n[15],x=n[16]),(0,$.useEffect)(b,x);let S=e.linkMode===!0,C=v??e.hosts,w;n[17]===C?w=n[18]:(w=new Set(C),n[17]=C,n[18]=w);let T=w,E=v?v.length>0:e.installed,D=(0,$.useRef)(e.hosts),O,k;n[19]!==v||n[20]!==e.hosts?(O=()=>{v===null&&(D.current=e.hosts)},k=[v,e.hosts],n[19]=v,n[20]=e.hosts,n[21]=O,n[22]=k):(O=n[21],k=n[22]),(0,$.useEffect)(O,k);let ee;n[23]===e.hosts?ee=n[24]:(ee=[...e.hosts].sort().join(`,`),n[23]=e.hosts,n[24]=ee);let A=ee,j,M;n[25]!==m||n[26]!==A?(j=()=>{let e=hn(m).hosts;e&&[...e].sort().join(`,`)===A&&_n(m,{hosts:null})},M=[A,m],n[25]=m,n[26]=A,n[27]=j,n[28]=M):(j=n[27],M=n[28]),(0,$.useEffect)(j,M);let N=(0,$.useRef)(null),P=(0,$.useRef)(null),F,I;n[29]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>()=>{N.current&&clearTimeout(N.current),P.current?.(),P.current=null},I=[],n[29]=F,n[30]=I):(F=n[29],I=n[30]),(0,$.useEffect)(F,I);let L;n[31]!==t||n[32]!==m||n[33]!==e?(L=function(n,r){D.current=n,_n(m,{hosts:n}),N.current&&clearTimeout(N.current);let i=async()=>{P.current=null,N.current=null;let r=await t.install(e,n.filter(Te));if(!r.ok){_n(m,{hosts:null});return}D.current=[...r.hosts],_n(m,{hosts:[...r.hosts]})};r?(P.current=()=>void i(),N.current=setTimeout(()=>void i(),350)):(P.current=null,i())},n[31]=t,n[32]=m,n[33]=e,n[34]=L):L=n[34];let R=L,te;return n[35]!==t||n[36]!==R||n[37]!==T||n[38]!==E||n[39]!==f||n[40]!==y||n[41]!==m||n[42]!==S||n[43]!==e?(te={hostSet:T,installed:E,installing:f,toggleEditor(e,t){let n=new Set(D.current);t?n.add(e):n.delete(e),R([...n],!0)},installAll(){let t=D.current.filter(Cn),n=e.installableEditors??vn,r=vn.filter(e=>n.includes(e)||D.current.includes(e));R([...t,...r],!1)},linkMode:S,sourceHost:y??e.hosts[0],placeAt(n,r){t.runLocationWrite(e,()=>it({scope:e.scope,name:e.name,dir:n,mode:r})).then(Sn)},unplaceAt(n){t.runLocationWrite(e,()=>Xe({scope:e.scope,name:e.name,path:n})).then(xn)},setSource(n){_n(m,{source:n}),t.runLocationWrite(e,()=>Ye({scope:e.scope,name:e.name,target:n})).then(e=>{e.ok||(_n(m,{source:null}),Z.error(e.error))})},convertLocation(n,r){t.convertLocations(e,[{target:n,mode:r}])},convertLocations(n){t.convertLocations(e,n)}},n[35]=t,n[36]=R,n[37]=T,n[38]=E,n[39]=f,n[40]=y,n[41]=m,n[42]=S,n[43]=e,n[44]=te):te=n[44],te}function xn(e){e.ok||Z.error(e.error)}function Sn(e){e.ok||Z.error(e.error)}function Cn(e){return!vn.includes(e)}function wn(e){let t=(0,_t.c)(7),{hint:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,Q.jsx)(x,{asChild:!0,children:r}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,Q.jsx)(S,{side:`right`,className:`max-w-xs`,children:n}),t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(C,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Tn(e){let t=(0,_t.c)(155),{toggles:n,skill:r,onResolveFork:i,onRunStart:a}=e,{_:o}=u(),{hostSet:s,toggleEditor:c,installAll:d}=n,f;t[0]===r?f=t[1]:(f=e=>r?`${qe(e,r.scope)}/${r.name}`:null,t[0]=r,t[1]=f);let p=f,m=ct(),h;t[2]!==m.data||t[3]!==m.status||t[4]!==r?(h=r!==void 0&&((r.hosts??[]).includes(`agents`)||m.status===`ready`&&m.data.some(Ln)),t[2]=m.data,t[3]=m.status,t[4]=r,t[5]=h):h=t[5];let _=h,v;t[6]!==m.data||t[7]!==m.status||t[8]!==r?(v=r?.hostAliases??(r&&m.status===`ready`?Object.assign({},...m.data.filter(e=>e.scope===r.scope).map(In)):{}),t[6]=m.data,t[7]=m.status,t[8]=r,t[9]=v):v=t[9];let x=v,S;t[10]!==m.data||t[11]!==m.status||t[12]!==r?(S=r?.installableEditors??(r&&m.status===`ready`?m.data.find(e=>e.scope===r.scope)?.installableEditors:void 0),t[10]=m.data,t[11]=m.status,t[12]=r,t[13]=S):S=t[13];let C=S,w,T,E,D,O,k,ee;if(t[14]!==o||t[15]!==x||t[16]!==m.data||t[17]!==m.status||t[18]!==s||t[19]!==_||t[20]!==d||t[21]!==C||t[22]!==i||t[23]!==a||t[24]!==p||t[25]!==r||t[26]!==c||t[27]!==n){let e=C?new Set(C):null,u;t[35]===x?u=t[36]:(u=e=>!(e in x),t[35]=x,t[36]=u);let f=(_?[`agents`,...vn]:vn).filter(u).filter(t=>t===`agents`||e===null||e.has(t)||s.has(t)),h;t[37]===p?h=t[38]:(h=e=>p(e),t[37]=p,t[38]=h);let v=new Set(f.map(h)),S=r?.scope===`global`?`~/`:``,A;t[39]!==S||t[40]!==r?(A=r?.path?.includes(`/`)?`${S}${r.path.replace(/\/SKILL\.mdx?$/i,``)}`:null,t[39]=S,t[40]=r,t[41]=A):A=t[41];let j=A,M=j!==null&&!v.has(j)?j:null,N=M===null?n.sourceHost??r?.hosts?.[0]:void 0,P;t[42]===x?P=t[43]:(P=e=>Ge(x,e),t[42]=x,t[43]=P);let L=P,R=Fn,te;t[44]!==o||t[45]!==L?(te=e=>{let t=L(e);return t.length===0?!0:window.confirm(o({id:`Uobeu9`,values:{0:t.map(R).join(`, `),rootRel:e}}))},t[44]=o,t[45]=L,t[46]=te):te=t[46];let z=te,B;t[47]!==o||t[48]!==r?(B=(e,t)=>{let n=e.includes(`/`)?e:qe(e,r?.scope??`project`);return(0,Q.jsx)(wn,{hint:o({id:`0dslv8`,values:{0:R(e),1:R(e),2:r?.name??``,poolRootRel:t,subRoot:n}}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-4 shrink-0 px-0`,"aria-label":o({id:`G6Lrs_`,values:{0:R(e)}}),onClick:i=>{i.preventDefault(),i.stopPropagation(),window.confirm(o({id:`iiqOKM`,values:{0:R(e),1:r.name,2:R(e),subRoot:n,poolRootRel:t}}))&&ot({scope:r.scope,root:n,action:`unlink`,exclude:[r.name]}).then(e=>{e.ok?Ue():Z.error(o({id:`PRgIJh`,values:{0:e.error,subRoot:n}}))})},"data-testid":`skill-audience-unfollow-${e}`,children:(0,Q.jsx)(g,{host:e,"aria-hidden":!0,className:`size-3.5`})})},e)},t[47]=o,t[48]=r,t[49]=B):B=t[49];let V=B,H;t[50]===r?.conflictHosts?H=t[51]:(H=r?.conflictHosts??[],t[50]=r?.conflictHosts,t[51]=H);let U;t[52]===H?U=t[53]:(U=new Set(H),t[52]=H,t[53]=U);let W=U,G;t[54]===r?.driftPaths?G=t[55]:(G=r?.driftPaths??[],t[54]=r?.driftPaths,t[55]=G);let K;t[56]===G?K=t[57]:(K=new Set(G),t[56]=G,t[57]=K);let q=K;w=n.installing;let J=Pn,Y;t[58]===r?.symlinkedHosts?Y=t[59]:(Y=r?.symlinkedHosts??[],t[58]=r?.symlinkedHosts,t[59]=Y);let ne;t[60]===Y?ne=t[61]:(ne=new Set(Y),t[60]=Y,t[61]=ne);let X=ne,re=[...[...s].filter(e=>e!==N&&!(e in x)&&!W.has(e)&&!e.includes(`/`)).map(e=>X.has(e)?`link`:`copy`),...(r?.customPlacements??[]).map(Nn)],ie=re.filter(Mn).length;E=re.length===0?n.linkMode?`link`:`copy`:ie*2>=re.length?`link`:`copy`;let ae;t[62]!==x||t[63]!==W||t[64]!==s||t[65]!==X||t[66]!==p||t[67]!==N?(ae=[...s].filter(e=>e!==N&&!(e in x)&&!W.has(e)&&!e.includes(`/`)).map(e=>({target:e,display:p(e)??R(e),mode:X.has(e)?`link`:`copy`})),t[62]=x,t[63]=W,t[64]=s,t[65]=X,t[66]=p,t[67]=N,t[68]=ae):ae=t[68];let oe;t[69]===r?.customPlacements?oe=t[70]:(oe=r?.customPlacements??[],t[69]=r?.customPlacements,t[70]=oe);let se;if(t[71]!==S||t[72]!==ae||t[73]!==oe){let e;t[75]===S?e=t[76]:(e=e=>({target:Ke(e),display:`${S}${e.path}`,mode:e.mode}),t[75]=S,t[76]=e),se=[...ae,...oe.map(e)],t[71]=S,t[72]=ae,t[73]=oe,t[74]=se}else se=t[74];T=se;let ce;t[77]!==o||t[78]!==a||t[79]!==n?(ce=(e,t,r)=>{let i=r===`link`?`copy`:`link`;return(0,Q.jsx)(wn,{hint:o(r===`link`?{id:`FeXcUS`,values:{display:t}}:{id:`ugQcJX`,values:{display:t}}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-yellow-500/40 bg-yellow-500/10 px-1 font-normal text-[10px] text-yellow-600 uppercase tracking-wide hover:bg-yellow-500/20`,onClick:r=>{r.preventDefault(),r.stopPropagation(),window.confirm(o(i===`link`?{id:`m0eHej`,values:{display:t}}:{id:`HbcQYf`,values:{display:t}}))&&(a?.(),n.convertLocation?.(e,i))},"data-testid":`skill-convert-${e}`,children:r===`link`?(0,Q.jsx)(l,{id:`uUCrBv`}):(0,Q.jsx)(l,{id:`iaPtht`})})})},t[77]=o,t[78]=a,t[79]=n,t[80]=ce):ce=t[80];let le=ce,ue;t[81]===r?.customPlacements?ue=t[82]:(ue=r?.customPlacements??[],t[81]=r?.customPlacements,t[82]=ue);let de=new Map(ue.map(jn)),fe=new Set(de.keys());if(m.status===`ready`&&r){for(let e of m.data)if(e.scope===r.scope)for(let t of e.customPlacements??[]){let e=Ke(t);e!==``&&fe.add(e)}}let pe=r===void 0?[]:[...fe].sort().map(e=>({root:e,display:`${S}${e}/${r.name}`,placed:de.get(e)??null})).filter(e=>!v.has(e.display)&&e.display!==j&&!(e.root in x)),me;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Q.jsx)(l,{id:`npcziF`}),t[83]=me):me=t[83];let he;t[84]===o?he=t[85]:(he=o({id:`6f_UX4`}),t[84]=o,t[85]=he);let ge;t[86]===d?ge=t[87]:(ge=()=>d(),t[86]=d,t[87]=ge);let _e;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Q.jsx)(l,{id:`N40H-G`}),t[88]=_e):_e=t[88];let ye;t[89]!==w||t[90]!==ge?(ye=(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 px-1.5 font-normal text-[11px] text-muted-foreground hover:text-foreground`,disabled:w,onClick:ge,"data-testid":`skill-install-all`,children:_e}),t[89]=w,t[90]=ge,t[91]=ye):ye=t[91],t[92]!==he||t[93]!==ye?(D=(0,Q.jsxs)(I,{className:`flex items-center justify-between gap-2`,children:[me,(0,Q.jsx)(wn,{hint:he,children:ye})]}),t[92]=he,t[93]=ye,t[94]=D):D=t[94],t[95]!==o||t[96]!==V||t[97]!==w||t[98]!==M||t[99]!==L?(O=M===null?null:(0,Q.jsx)(wn,{hint:o({id:`pXB6SL`}),children:(0,Q.jsxs)(F,{disabled:w,checked:!0,onSelect:An,"data-testid":`skill-source-row`,children:[(0,Q.jsx)(Me,{"aria-hidden":!0,className:`size-4 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:M}),(()=>{let e=J(M).split(`/`).slice(0,-1).join(`/`),t=L(e);return t.length>0?(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-testid":`skill-row-audience-source`,children:t.map(t=>V(t,e))}):null})(),(0,Q.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded border border-border/60 px-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:(0,Q.jsx)(l,{id:`tiFPjk`})})]})]})}),t[95]=o,t[96]=V,t[97]=w,t[98]=M,t[99]=L,t[100]=O):O=t[100];let be;t[101]!==o||t[102]!==V||t[103]!==w||t[104]!==z||t[105]!==W||t[106]!==le||t[107]!==q||t[108]!==E||t[109]!==s||t[110]!==X||t[111]!==i||t[112]!==p||t[113]!==r?.hosts||t[114]!==N||t[115]!==L||t[116]!==c||t[117]!==n?(be=e=>{let t=p(e),a=e===`agents`?`.agents`:ve[e],u=J(t).split(`/`).slice(0,-1).join(`/`),d=L(u);return(0,Q.jsx)(wn,{hint:W.has(e)?o({id:`8HvJlU`,values:{0:t??a}}):e===N?t?o({id:`ssk6rl`,values:{path:t}}):a:s.has(e)?o(t?{id:`9ieZhu`,values:{path:t}}:{id:`n3T3EE`,values:{label:a}}):o(t?E===`link`?{id:`1LtA5r`,values:{path:t}}:{id:`opPbzN`,values:{path:t}}:{id:`Pp0Vgd`,values:{label:a}}),children:(0,Q.jsxs)(F,{disabled:w,checked:s.has(e),onCheckedChange:t=>{W.has(e)||t===!0&&!z(u)||c(e,t===!0)},onSelect:kn,className:`group`,"data-testid":`skill-install-editor-${e}`,children:[(0,Q.jsx)(g,{host:e,"aria-hidden":!0,className:`size-4`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t??a}),d.length>0?(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-testid":`skill-row-audience-${e}`,children:d.map(e=>V(e,u))}):null,W.has(e)?(0,Q.jsx)(wn,{hint:o({id:`_O7dJS`}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-yellow-500/40 bg-yellow-500/10 px-1 text-[10px] text-yellow-600 uppercase tracking-wide hover:bg-yellow-500/20`,onClick:t=>{t.preventDefault(),i?.(e)},"data-testid":`skill-fork-chip-${e}`,children:(0,Q.jsx)(l,{id:`jng7Ko`})})}):e===N?(0,Q.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded border border-border/60 px-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:(0,Q.jsx)(l,{id:`tiFPjk`})}):s.has(e)&&r?.hosts?(0,Q.jsxs)(Q.Fragment,{children:[!w&&(X.has(e)?`link`:`copy`)!==E?le(e,t??a,X.has(e)?`link`:`copy`):null,(0,Q.jsx)(wn,{hint:o({id:`nBgzKO`}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-border/60 px-1 font-normal text-[10px] text-muted-foreground uppercase tracking-wide opacity-0 focus-visible:opacity-100 group-hover:opacity-100 hover:border-foreground/40 hover:text-foreground`,onClick:t=>{t.preventDefault(),t.stopPropagation(),n.setSource?.(e)},"data-testid":`skill-set-source-${e}`,children:(0,Q.jsx)(l,{id:`VNNRfN`})})})]}):null,!w&&q.has(J(t))?(0,Q.jsx)(wn,{hint:o({id:`iz1LdD`}),children:(0,Q.jsx)(y,{testId:`skill-drift-${e}`})}):null]})]})},e)},t[101]=o,t[102]=V,t[103]=w,t[104]=z,t[105]=W,t[106]=le,t[107]=q,t[108]=E,t[109]=s,t[110]=X,t[111]=i,t[112]=p,t[113]=r?.hosts,t[114]=N,t[115]=L,t[116]=c,t[117]=n,t[118]=be):be=t[118],k=f.map(be);let xe;t[119]!==o||t[120]!==V||t[121]!==w||t[122]!==z||t[123]!==le||t[124]!==q||t[125]!==E||t[126]!==L||t[127]!==n?(xe=e=>(0,Q.jsx)(wn,{hint:e.placed===null?o(E===`link`?{id:`ybWWR2`,values:{0:e.display}}:{id:`fDjZxw`,values:{0:e.display}}):o({id:`C0cll5`,values:{0:e.display}}),children:(0,Q.jsxs)(F,{disabled:w,checked:e.placed!==null,onCheckedChange:t=>{if(t===!0&&e.placed===null){if(!z(e.root))return;n.placeAt(e.root,E)}else e.placed!==null&&n.unplaceAt?.(e.placed.path)},onSelect:On,className:`group`,"data-testid":`skill-custom-root-${e.root}`,children:[e.root===`.agents/skills`?(0,Q.jsx)(g,{host:`agents`,"aria-hidden":!0,className:`size-4`}):(0,Q.jsx)(Me,{"aria-hidden":!0,className:`size-4 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.display}),L(e.root).length>0?(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-testid":`skill-row-audience-custom-${e.root}`,children:L(e.root).map(t=>V(t,e.root))}):null,!w&&e.placed!==null&&q.has(e.placed.path)?(0,Q.jsx)(wn,{hint:o({id:`iz1LdD`}),children:(0,Q.jsx)(y,{testId:`skill-drift-custom-${e.root}`})}):e.placed===null?null:(0,Q.jsxs)(Q.Fragment,{children:[!w&&e.placed.mode!==E?le(e.root,e.display,e.placed.mode):null,(0,Q.jsx)(wn,{hint:o({id:`nBgzKO`}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-5 shrink-0 rounded border border-border/60 px-1 font-normal text-[10px] text-muted-foreground uppercase tracking-wide opacity-0 focus-visible:opacity-100 group-hover:opacity-100 hover:border-foreground/40 hover:text-foreground`,onClick:t=>{t.preventDefault(),t.stopPropagation(),n.setSource?.(e.root)},"data-testid":`skill-set-source-custom-${e.root}`,children:(0,Q.jsx)(l,{id:`VNNRfN`})})})]})]})]})},e.root),t[119]=o,t[120]=V,t[121]=w,t[122]=z,t[123]=le,t[124]=q,t[125]=E,t[126]=L,t[127]=n,t[128]=xe):xe=t[128],ee=pe.map(xe),t[14]=o,t[15]=x,t[16]=m.data,t[17]=m.status,t[18]=s,t[19]=_,t[20]=d,t[21]=C,t[22]=i,t[23]=a,t[24]=p,t[25]=r,t[26]=c,t[27]=n,t[28]=w,t[29]=T,t[30]=E,t[31]=D,t[32]=O,t[33]=k,t[34]=ee}else w=t[28],T=t[29],E=t[30],D=t[31],O=t[32],k=t[33],ee=t[34];let A;t[129]!==o||t[130]!==w||t[131]!==T||t[132]!==E||t[133]!==a||t[134]!==n?(A=T.length>0&&n.convertLocations?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-1 pb-1.5`,children:[(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,className:`h-auto whitespace-normal p-0 text-left font-normal text-[11px] text-muted-foreground leading-snug hover:bg-transparent hover:text-foreground`,onClick:e=>{e.preventDefault();let t=E===`link`?`copy`:`link`,r=T.filter(e=>e.mode!==t);if(r.length===0)return;let i=o(t===`copy`?{id:`iOAsF1`}:{id:`MS8lMS`}),s=o(t===`copy`?{id:`gZiT5e`}:{id:`PhIa-X`}),c=r.map(Dn).join(`
2
+ `);window.confirm(`${i}\n\n${s}\n\n${c}\n\n${o({id:`Cu6GXQ`})}`)&&(a?.(),n.convertLocations?.(r.map(e=>({target:e.target,mode:t}))))},disabled:w,"data-testid":`skill-convert-all`,children:E===`link`?(0,Q.jsx)(l,{id:`rcJmK8`}):(0,Q.jsx)(l,{id:`LBv_TR`})}),(0,Q.jsx)(wn,{hint:o({id:`0J6nhG`}),children:(0,Q.jsx)(b,{variant:`ghost`,size:`sm`,"aria-label":o({id:`qJSo0_`}),className:`size-4 shrink-0 rounded-full border border-border/60 p-0 font-normal text-[9px] text-muted-foreground hover:border-foreground/40 hover:bg-transparent hover:text-foreground`,onClick:En,"data-testid":`skill-convert-all-help`,children:`?`})})]}):null,t[129]=o,t[130]=w,t[131]=T,t[132]=E,t[133]=a,t[134]=n,t[135]=A):A=t[135];let M;t[136]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(R,{}),t[136]=M):M=t[136];let N;t[137]===o?N=t[138]:(N=o({id:`jqe7Yq`}),t[137]=o,t[138]=N);let P;t[139]===r?.scope?P=t[140]:(P=()=>{window.location.hash=r?.scope===`global`?`#settings/user-skills`:`#settings/skills`},t[139]=r?.scope,t[140]=P);let L,te;t[141]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(gt,{"aria-hidden":!0}),te=(0,Q.jsx)(l,{id:`ZBF9fn`}),t[141]=L,t[142]=te):(L=t[141],te=t[142]);let z;t[143]===P?z=t[144]:(z=(0,Q.jsxs)(j,{onSelect:P,children:[L,te]}),t[143]=P,t[144]=z);let B;t[145]!==N||t[146]!==z?(B=(0,Q.jsx)(wn,{hint:N,children:z}),t[145]=N,t[146]=z,t[147]=B):B=t[147];let V;return t[148]!==B||t[149]!==D||t[150]!==O||t[151]!==k||t[152]!==ee||t[153]!==A?(V=(0,Q.jsxs)(Q.Fragment,{children:[D,O,k,ee,A,M,B]}),t[148]=B,t[149]=D,t[150]=O,t[151]=k,t[152]=ee,t[153]=A,t[154]=V):V=t[154],V}function En(e){return e.preventDefault()}function Dn(e){return e.display}function On(e){return e.preventDefault()}function kn(e){return e.preventDefault()}function An(e){return e.preventDefault()}function jn(e){return[Ke(e),e]}function Mn(e){return e===`link`}function Nn(e){return e.mode}function Pn(e){return(e??``).replace(/^~\//,``)}function Fn(e){return e===`agents`?`.agents`:ve[e]??e}function In(e){return e.hostAliases??{}}function Ln(e){return e.hosts.includes(`agents`)||e.path.startsWith(`.agents/`)}function Rn(e){let t=(0,_t.c)(10),{onAddProperty:n,className:r}=e,{_:i}=u(),a;t[0]===i?a=t[1]:(a=i({id:`81H_23`}),t[0]=i,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(x,{children:(0,Q.jsx)(mt,{})}),t[2]=o):o=t[2];let s;t[3]!==r||t[4]!==n||t[5]!==a?(s=(0,Q.jsx)(b,{variant:`ghost`,size:`icon`,"aria-label":a,onClick:n,"data-testid":`add-properties-button`,className:r,asChild:!0,children:o}),t[3]=r,t[4]=n,t[5]=a,t[6]=s):s=t[6];let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(S,{side:`bottom`,children:(0,Q.jsx)(l,{id:`81H_23`})}),t[7]=c):c=t[7];let d;return t[8]===s?d=t[9]:(d=(0,Q.jsxs)(C,{children:[s,c]}),t[8]=s,t[9]=d),d}function zn(e){return e?Fe._({id:`wTcjov`}):null}function Bn(e){let t=(0,_t.c)(47),{_:n}=u(),i=r(),a=_(),s=z(),c=V();if(i)return null;let{input:d,installStates:p,dispatch:m,onBeforeLaunch:h}=e,g=d===null,v,y,b,x,S,C,w,T,E,D,O;if(t[0]!==n||t[1]!==m||t[2]!==d||t[3]!==g||t[4]!==p||t[5]!==h||t[6]!==c||t[7]!==s||t[8]!==a){let e=zn(g),r;t[20]===c?r=t[21]:(r=e=>Y(c,e.id),t[20]=c,t[21]=r);let i=H.filter(r),u;t[22]===c?u=t[23]:(u=e=>W(c,e.source,e.id,!0,e.supported),t[22]=c,t[23]=u);let f=s.filter(u),_=a?ae.filter(e=>q(c,e,a.installedClis)):[];b=i.length>0,x=a!==null&&_.length>0,S=f.length>0,y=M,t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(o,{"aria-hidden":`true`}),(0,Q.jsx)(l,{id:`O7_W_a`})]}),t[24]=O):O=t[24],v=N,C=`max-h-80`,w=S?(0,Q.jsxs)(P,{"aria-label":n({id:`vPKX2i`}),children:[(0,Q.jsxs)(I,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(l,{id:`RXEbZy`}),(0,Q.jsx)(J,{})]}),f.map(t=>{let r=t.name;return(0,Q.jsxs)(j,{onSelect:()=>{d!==null&&(h?.(),an(d,{agent:{source:t.source,id:t.id}}))},disabled:g,"data-testid":`file-tree-open-in-thread-${t.id}`,"aria-label":e?n({id:`gtGQ9S`,values:{agentName:r,hint:e}}):void 0,children:[(0,Q.jsx)(De,{agentId:t.id,iconUrl:t.iconUrl,className:`size-4`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:(0,Q.jsx)(l,{id:`5PrrYw`,values:{agentName:r}})}),e?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},`${t.source}:${t.id}`)})]}):null,t[25]!==b||t[26]!==x||t[27]!==S?(T=S&&(x||b)?(0,Q.jsx)(R,{}):null,t[25]=b,t[26]=x,t[27]=S,t[28]=T):T=t[28],E=x?(0,Q.jsxs)(P,{"aria-label":n({id:`ALhMYW`}),children:[(0,Q.jsx)(I,{children:(0,Q.jsx)(l,{id:`ALhMYW`})}),_.map(t=>{let{displayName:r}=he[t];return(0,Q.jsxs)(j,{onSelect:()=>{d!==null&&(h?.(),a.launchInTerminal(d,t))},disabled:g,"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,Q.jsx)(G,{id:B(t),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:r}),e?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t)})]}):null,D=b?(0,Q.jsxs)(Q.Fragment,{children:[x?(0,Q.jsx)(R,{}):null,(0,Q.jsxs)(P,{"aria-label":n({id:`BBqGS9`}),children:[(0,Q.jsx)(I,{children:(0,Q.jsx)(l,{id:`BBqGS9`})}),i.map(t=>{let r=!g,{displayName:i}=t,a=n(e?{id:`1ZpfyB`,values:{displayName:i,hint:e}}:{id:`WqLq6M`,values:{displayName:i}});return(0,Q.jsxs)(j,{disabled:!r,onSelect:()=>{if(d){if(h?.(),p[t.id]?.installed!==!0){Wt(t);return}m(t.id,d)}},"data-testid":`file-tree-open-in-${t.id}`,"aria-label":a,children:[(0,Q.jsx)(G,{id:t.id,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:t.displayName}),e?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)})]})]}):null,t[0]=n,t[1]=m,t[2]=d,t[3]=g,t[4]=p,t[5]=h,t[6]=c,t[7]=s,t[8]=a,t[9]=v,t[10]=y,t[11]=b,t[12]=x,t[13]=S,t[14]=C,t[15]=w,t[16]=T,t[17]=E,t[18]=D,t[19]=O}else v=t[9],y=t[10],b=t[11],x=t[12],S=t[13],C=t[14],w=t[15],T=t[16],E=t[17],D=t[18],O=t[19];let k;t[29]!==b||t[30]!==x||t[31]!==S?(k=S||x||b?(0,Q.jsx)(R,{}):null,t[29]=b,t[30]=x,t[31]=S,t[32]=k):k=t[32];let ee;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Q.jsx)(f,{"aria-hidden":`true`}),t[33]=ee):ee=t[33];let A;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsxs)(j,{onSelect:Ie,"data-testid":`file-tree-open-in-settings`,children:[ee,(0,Q.jsx)(`span`,{className:`flex-1`,children:(0,Q.jsx)(l,{id:`jRAGrQ`})})]}),t[34]=A):A=t[34];let F;t[35]!==v||t[36]!==C||t[37]!==w||t[38]!==T||t[39]!==E||t[40]!==D||t[41]!==k?(F=(0,Q.jsxs)(v,{className:C,children:[w,T,E,D,k,A]}),t[35]=v,t[36]=C,t[37]=w,t[38]=T,t[39]=E,t[40]=D,t[41]=k,t[42]=F):F=t[42];let te;return t[43]!==y||t[44]!==O||t[45]!==F?(te=(0,Q.jsxs)(y,{children:[O,F]}),t[43]=y,t[44]=O,t[45]=F,t[46]=te):te=t[46],te}function Vn(e){let t=oe(e);if(t)return{scope:`project`,name:t.name,rel:t.rel};let n=re(e);return n?{scope:`global`,name:n.name,rel:n.rel}:null}function Hn(e,t,n){return e.filter(e=>{let r=ze(e);if(r.kind===`skill-file`)return r.scope===t&&r.name===n;if(r.kind!==`doc`)return!1;let i=Vn(r.docName);return i?.scope===t&&i.name===n})}function Un(e,t){let n=new Map(t.map(e=>[`${e.scope}\u0000${e.name}`,e])),r=[];for(let t of e){let e=Vn(t);if(!e||n.has(`${e.scope}\u0000${e.name}`))continue;let i=e.scope===`project`?`global`:`project`,a=n.get(`${i}\u0000${e.name}`);e.rel===null&&a!==void 0?r.push({kind:`retarget`,fromDocName:t,toDocName:Re(a)}):r.push({kind:`close`,docName:t})}return r}function Wn(){let e=(0,_t.c)(15),{openTabs:t,closeDocument:n}=s(),r=Oe(),i;e[0]===t?i=e[1]:(i=t.some(Kn),e[0]=t,e[1]=i);let a=i,o;e[2]===a?o=e[3]:(o={enabled:a},e[2]=a,e[3]=o);let c=ct(o),l=(0,$.useRef)(null),u;e[4]!==n||e[5]!==t||e[6]!==r||e[7]!==c.data||e[8]!==c.status?(u=()=>{if(c.status!==`ready`)return;let e=c.data,i=`${t.join(``)}\u0002${e.map(Gn).sort().join(``)}`;if(l.current===i)return;l.current=i;let a=Un(t,e);for(let e of a)e.kind===`retarget`?r(e.fromDocName,e.toDocName):n(e.docName)},e[4]=n,e[5]=t,e[6]=r,e[7]=c.data,e[8]=c.status,e[9]=u):u=e[9];let d;e[10]!==n||e[11]!==t||e[12]!==r||e[13]!==c?(d=[c,t,r,n],e[10]=n,e[11]=t,e[12]=r,e[13]=c,e[14]=d):d=e[14],(0,$.useEffect)(u,d)}function Gn(e){return`${e.scope}\u0000${e.name}`}function Kn(e){return Vn(e)!==null}function qn(e){let t=(0,_t.c)(19),{skill:n,onOpenChange:r,onDeleted:i}=e,{_:a}=u(),{setSkillsSidebar:o,closeTabs:c,openTabs:l}=s(),[d,f]=(0,$.useState)(!1),p;t[0]!==a||t[1]!==c||t[2]!==i||t[3]!==r||t[4]!==l||t[5]!==o?(p=async function(e){o(!0),f(!0);let t=await nt(e.scope,e.name);if(f(!1),!t.ok){let{error:e}=t;Z.error(a({id:`AtBdnD`,values:{error:e}}));return}Z.success(a({id:`h9QFb9`,values:{0:e.name}})),c(Hn(l,e.scope,e.name),{force:!0}),i(),r(!1)},t[0]=a,t[1]=c,t[2]=i,t[3]=r,t[4]=l,t[5]=o,t[6]=p):p=t[6];let m=p,g=n!==null,_;t[7]!==d||t[8]!==r?(_=e=>{!e&&!d&&r(!1)},t[7]=d,t[8]=r,t[9]=_):_=t[9];let v;t[10]!==a||t[11]!==d||t[12]!==m||t[13]!==n?(v=n?(0,Q.jsx)(h,{itemName:a({id:`ExUzM4`,values:{0:n.name}}),isSubmitting:d,onDelete:()=>m(n),customDescription:n.origin?.source&&/\/plugins\/(?:cache|marketplaces)\//.test(n.origin.source)?a({id:`WnsbUT`,values:{0:n.path}}):a({id:`E1Da_b`,values:{0:n.path}})}):null,t[10]=a,t[11]=d,t[12]=m,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==g||t[16]!==_||t[17]!==v?(y=(0,Q.jsx)(A,{open:g,onOpenChange:_,children:v}),t[15]=g,t[16]=_,t[17]=v,t[18]=y):y=t[18],y}function Jn(e){let t=e.split(`/`);return t.some(e=>e===``||e===`.`||e===`..`)||t.length===0||t.length===1&&t[0].toLowerCase()===`skill.md`?!1:!/\s/.test(e)}function Yn(e){let t=(0,_t.c)(66),{target:n,onOpenChange:r}=e,{_:i}=u(),{openTarget:a}=s(),o=(0,$.useId)(),[c,d]=(0,$.useState)(``),[f,p]=(0,$.useState)(!1),m;t[0]===n?m=t[1]:(m=()=>{n&&d(n.prefix??`references/`)},t[0]=n,t[1]=m);let h=n?.skill.scope,g=n?.skill.name,_=n?.prefix,v;if(t[2]!==h||t[3]!==g||t[4]!==_?(v=[h,g,_],t[2]=h,t[3]=g,t[4]=_,t[5]=v):v=t[5],(0,$.useEffect)(m,v),!n)return null;let y,x,S,C;t[6]!==c||t[7]!==f?(C=c.trim(),x=C===``||!Jn(C),y=!x&&!f,S=C.includes(`/`)?C.split(`/`).slice(0,-1).join(`/`):null,t[6]=c,t[7]=f,t[8]=y,t[9]=x,t[10]=S,t[11]=C):(y=t[8],x=t[9],S=t[10],C=t[11]);let D=S,k;t[12]!==i||t[13]!==y||t[14]!==r||t[15]!==a||t[16]!==n||t[17]!==C?(k=async function(){if(!n||!y)return;p(!0);let e=/\.mdx?$/i.test(C),t=await Je({scope:n.skill.scope,name:n.skill.name,path:C,content:e?`# ${C.split(`/`).pop()?.replace(/\.mdx?$/i,``)??``}\n`:``});if(p(!1),!t.ok){Z.error(i({id:`a_2_uB`,values:{0:t.error,trimmed:C}}));return}if(Z.success(i({id:`MXSt4t`,values:{0:t.path}})),e){let e=Be(n.skill,C);a({kind:`doc`,target:e,docName:e})}r(!1)},t[12]=i,t[13]=y,t[14]=r,t[15]=a,t[16]=n,t[17]=C,t[18]=k):k=t[18];let j=k,M;t[19]!==r||t[20]!==f?(M=e=>{!e&&!f&&r(!1)},t[19]=r,t[20]=f,t[21]=M):M=t[21];let N;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`wQvvZY`})}),t[22]=N):N=t[22];let P;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsxs)(ee,{children:[N,(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`lM4c-I`})})]}),t[23]=P):P=t[23];let F;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Q.jsx)(l,{id:`I6gXOa`}),t[24]=F):F=t[24];let I;t[25]===o?I=t[26]:(I=(0,Q.jsx)(te,{htmlFor:o,children:F}),t[25]=o,t[26]=I);let L;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>d(e.target.value),t[27]=L):L=t[27];let R=x&&C!==``,z;t[28]===j?z=t[29]:(z=e=>{e.key===`Enter`&&j()},t[28]=j,t[29]=z);let B;t[30]!==o||t[31]!==c||t[32]!==R||t[33]!==z?(B=(0,Q.jsx)(Pe,{id:o,value:c,onChange:L,placeholder:`references/notes.md`,"aria-invalid":R,onKeyDown:z}),t[30]=o,t[31]=c,t[32]=R,t[33]=z,t[34]=B):B=t[34];let V;t[35]!==D||t[36]!==x||t[37]!==C?(V=x&&C!==``?(0,Q.jsx)(`p`,{className:`text-destructive text-xs`,children:(0,Q.jsx)(l,{id:`fVzizW`})}):D?(0,Q.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:(0,Q.jsx)(l,{id:`9lso1Y`,values:{folderPart:D},components:{0:(0,Q.jsx)(`span`,{className:`font-mono text-foreground/80`})}})}):null,t[35]=D,t[36]=x,t[37]=C,t[38]=V):V=t[38];let H;t[39]!==I||t[40]!==B||t[41]!==V?(H=(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[I,B,V]}),t[39]=I,t[40]=B,t[41]=V,t[42]=H):H=t[42];let U;t[43]===r?U=t[44]:(U=()=>r(!1),t[43]=r,t[44]=U);let W;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Q.jsx)(l,{id:`dEgA5A`}),t[45]=W):W=t[45];let G;t[46]!==f||t[47]!==U?(G=(0,Q.jsx)(b,{variant:`outline`,onClick:U,disabled:f,children:W}),t[46]=f,t[47]=U,t[48]=G):G=t[48];let K;t[49]===j?K=t[50]:(K=()=>void j(),t[49]=j,t[50]=K);let q=!y,J;t[51]===f?J=t[52]:(J=f?(0,Q.jsx)(l,{id:`E9bKSA`}):(0,Q.jsx)(l,{id:`hYgDIe`}),t[51]=f,t[52]=J);let Y;t[53]!==K||t[54]!==q||t[55]!==J?(Y=(0,Q.jsx)(b,{onClick:K,disabled:q,children:J}),t[53]=K,t[54]=q,t[55]=J,t[56]=Y):Y=t[56];let ne;t[57]!==G||t[58]!==Y?(ne=(0,Q.jsxs)(O,{children:[G,Y]}),t[57]=G,t[58]=Y,t[59]=ne):ne=t[59];let X;t[60]!==H||t[61]!==ne?(X=(0,Q.jsxs)(E,{className:`sm:max-w-md`,children:[P,H,ne]}),t[60]=H,t[61]=ne,t[62]=X):X=t[62];let re;return t[63]!==X||t[64]!==M?(re=(0,Q.jsx)(A,{open:!0,onOpenChange:M,children:X}),t[63]=X,t[64]=M,t[65]=re):re=t[65],re}function Xn(e){let t=(0,_t.c)(64),{target:n,onOpenChange:r}=e,{_:i}=u(),a=Oe(),o=(0,$.useId)(),[s,c]=(0,$.useState)(``),[d,f]=(0,$.useState)(!1),p;t[0]===n?p=t[1]:(p=()=>{n&&c(n.filePath)},t[0]=n,t[1]=p);let m=n?.skill.scope,h=n?.skill.name,g=n?.filePath,_;if(t[2]!==m||t[3]!==h||t[4]!==g?(_=[m,h,g],t[2]=m,t[3]=h,t[4]=g,t[5]=_):_=t[5],(0,$.useEffect)(p,_),!n)return null;let v,y,x;t[6]!==s||t[7]!==n.filePath?(y=s.trim(),x=y===n.filePath,v=y===``||!Jn(y),t[6]=s,t[7]=n.filePath,t[8]=v,t[9]=y,t[10]=x):(v=t[8],y=t[9],x=t[10]);let S=v,C=!S&&!x&&!d,D;t[11]!==i||t[12]!==C||t[13]!==r||t[14]!==a||t[15]!==n||t[16]!==y?(D=async function(){if(!n||!C)return;f(!0);let e=await at({scope:n.skill.scope,name:n.skill.name,from:n.filePath,to:y});if(f(!1),!e.ok){Z.error(i({id:`11ukmX`,values:{0:e.error}}));return}e.fromDocName!==void 0&&e.toDocName!==void 0&&a(e.fromDocName,e.toDocName),Z.success(i({id:`XszXjc`,values:{0:e.to}})),r(!1)},t[11]=i,t[12]=C,t[13]=r,t[14]=a,t[15]=n,t[16]=y,t[17]=D):D=t[17];let k=D,j;t[18]!==r||t[19]!==d?(j=e=>{!e&&!d&&r(!1)},t[18]=r,t[19]=d,t[20]=j):j=t[20];let M;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`yckias`})}),t[21]=M):M=t[21];let N;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsxs)(ee,{children:[M,(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`HzVAoz`})})]}),t[22]=N):N=t[22];let P;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(l,{id:`I6gXOa`}),t[23]=P):P=t[23];let F;t[24]===o?F=t[25]:(F=(0,Q.jsx)(te,{htmlFor:o,children:P}),t[24]=o,t[25]=F);let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>c(e.target.value),t[26]=I):I=t[26];let L=S&&y!==``,R;t[27]===k?R=t[28]:(R=e=>{e.key===`Enter`&&k()},t[27]=k,t[28]=R);let z;t[29]!==o||t[30]!==s||t[31]!==L||t[32]!==R?(z=(0,Q.jsx)(Pe,{id:o,value:s,onChange:I,"aria-invalid":L,onKeyDown:R}),t[29]=o,t[30]=s,t[31]=L,t[32]=R,t[33]=z):z=t[33];let B;t[34]!==S||t[35]!==y?(B=S&&y!==``?(0,Q.jsx)(`p`,{className:`text-destructive text-xs`,children:(0,Q.jsx)(l,{id:`fVzizW`})}):null,t[34]=S,t[35]=y,t[36]=B):B=t[36];let V;t[37]!==F||t[38]!==z||t[39]!==B?(V=(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[F,z,B]}),t[37]=F,t[38]=z,t[39]=B,t[40]=V):V=t[40];let H;t[41]===r?H=t[42]:(H=()=>r(!1),t[41]=r,t[42]=H);let U;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(l,{id:`dEgA5A`}),t[43]=U):U=t[43];let W;t[44]!==d||t[45]!==H?(W=(0,Q.jsx)(b,{variant:`outline`,onClick:H,disabled:d,children:U}),t[44]=d,t[45]=H,t[46]=W):W=t[46];let G;t[47]===k?G=t[48]:(G=()=>void k(),t[47]=k,t[48]=G);let K=!C,q;t[49]===d?q=t[50]:(q=d?(0,Q.jsx)(l,{id:`tHKQ6j`}):(0,Q.jsx)(l,{id:`2wxgft`}),t[49]=d,t[50]=q);let J;t[51]!==G||t[52]!==K||t[53]!==q?(J=(0,Q.jsx)(b,{onClick:G,disabled:K,children:q}),t[51]=G,t[52]=K,t[53]=q,t[54]=J):J=t[54];let Y;t[55]!==W||t[56]!==J?(Y=(0,Q.jsxs)(O,{children:[W,J]}),t[55]=W,t[56]=J,t[57]=Y):Y=t[57];let ne;t[58]!==V||t[59]!==Y?(ne=(0,Q.jsxs)(E,{className:`sm:max-w-md`,children:[N,V,Y]}),t[58]=V,t[59]=Y,t[60]=ne):ne=t[60];let X;return t[61]!==ne||t[62]!==j?(X=(0,Q.jsx)(A,{open:!0,onOpenChange:j,children:ne}),t[61]=ne,t[62]=j,t[63]=X):X=t[63],X}function Zn(e){let t=(0,_t.c)(59),{target:n,onOpenChange:r}=e,{_:i}=u(),a=(0,$.useId)(),[o,s]=(0,$.useState)(null),[c,d]=(0,$.useState)(null),[f,p]=(0,$.useState)(!1),[m,h]=(0,$.useState)(!1),[g,_]=(0,$.useState)(``),[v,y]=(0,$.useState)(!1),x;t[0]===n?x=t[1]:(x=()=>{if(s(null),d(null),p(!1),h(!1),!n)return;let{skill:e,editor:t}=n,r=e.absolutePath?.slice(0,-`/${e.path}`.length)??null;if(r===null){p(!0);return}let i=`${r}/${e.path.replace(/\/SKILL\.mdx?$/i,``)}`,a=`${r}/${qe(t,e.scope)}/${e.name}`,o=new AbortController;for(let[t,n]of[[i,d],[a,s]])$e({source:t,name:e.name},o.signal).then(e=>{o.signal.aborted||(e.ok?n(e.skillMd):p(!0))}).catch(()=>{o.signal.aborted||p(!0)});return()=>o.abort()},t[0]=n,t[1]=x);let S=n?.skill.scope,C=n?.skill.name,k=n?.editor,j;if(t[2]!==S||t[3]!==C||t[4]!==k?(j=[S,C,k],t[2]=S,t[3]=C,t[4]=k,t[5]=j):j=t[5],(0,$.useEffect)(x,j),!n)return null;let{skill:M,editor:N}=n,P;t[6]!==i||t[7]!==N||t[8]!==r||t[9]!==M.name||t[10]!==M.scope||t[11]!==n||t[12]!==g?(P=async function(e){if(!n)return;y(!0);let t=await Ze({scope:M.scope,name:M.name,editor:N,action:e,...e===`rename`?{toName:g.trim()}:{}});if(y(!1),!t.ok){Z.error(i({id:`MIF36T`,values:{0:t.error}}));return}Z.success(i(e===`align`?{id:`QKgePK`,values:{editor:N}}:e===`make-source`?{id:`It9oAP`,values:{editor:N}}:{id:`b2ezG_`,values:{0:g.trim()}})),r(!1)},t[6]=i,t[7]=N,t[8]=r,t[9]=M.name,t[10]=M.scope,t[11]=n,t[12]=g,t[13]=P):P=t[13];let F=P,I,L;t[14]!==M.name||t[15]!==g?(L=g.trim(),I=L===``||!Ce.test(L)||L===M.name,t[14]=M.name,t[15]=g,t[16]=I,t[17]=L):(I=t[16],L=t[17]);let R=I,z;t[18]!==v||t[19]!==r?(z=e=>{!e&&!v&&r(!1)},t[18]=v,t[19]=r,t[20]=z):z=t[20];let B;t[21]!==N||t[22]!==M.name?(B=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`q8aCbb`,values:{0:M.name,editor:N}})}),t[21]=N,t[22]=M.name,t[23]=B):B=t[23];let V;t[24]===N?V=t[25]:(V=(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`QASTNu`,values:{editor:N}})}),t[24]=N,t[25]=V);let H;t[26]!==V||t[27]!==B?(H=(0,Q.jsxs)(ee,{children:[B,V]}),t[26]=V,t[27]=B,t[28]=H):H=t[28];let U;t[29]!==c||t[30]!==o||t[31]!==f?(U=c!==null&&o!==null?(0,Q.jsx)(dt,{oldContent:c,newContent:o,layout:`unified`}):f?(0,Q.jsx)(`div`,{className:`flex min-h-56 items-center justify-center px-6 text-center text-muted-foreground text-sm`,children:(0,Q.jsx)(l,{id:`5BlXTD`})}):(0,Q.jsx)(`div`,{className:`flex min-h-56 items-center justify-center text-muted-foreground text-sm`,children:(0,Q.jsx)(l,{id:`1V17kO`})}),t[29]=c,t[30]=o,t[31]=f,t[32]=U):U=t[32];let W;t[33]!==F||t[34]!==N||t[35]!==a||t[36]!==R||t[37]!==m||t[38]!==M.name||t[39]!==g||t[40]!==L?(W=m?(0,Q.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,Q.jsx)(te,{htmlFor:a,children:(0,Q.jsx)(l,{id:`pSimwP`,values:{editor:N}})}),(0,Q.jsx)(Pe,{id:a,value:g,onChange:e=>_(e.target.value),placeholder:`${M.name}-${N}`,"aria-invalid":R&&L!==``,onKeyDown:e=>{e.key===`Enter`&&!R&&F(`rename`)}})]}):null,t[33]=F,t[34]=N,t[35]=a,t[36]=R,t[37]=m,t[38]=M.name,t[39]=g,t[40]=L,t[41]=W):W=t[41];let G;t[42]!==U||t[43]!==W?(G=(0,Q.jsxs)(D,{className:`min-h-0 flex-1 overflow-auto`,children:[U,W]}),t[42]=U,t[43]=W,t[44]=G):G=t[44];let K;t[45]!==F||t[46]!==v||t[47]!==N||t[48]!==R||t[49]!==m||t[50]!==M.name?(K=(0,Q.jsx)(O,{children:m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{variant:`outline`,onClick:()=>h(!1),disabled:v,children:(0,Q.jsx)(l,{id:`iH8pgl`})}),(0,Q.jsx)(b,{onClick:()=>void F(`rename`),disabled:v||R,children:(0,Q.jsx)(l,{id:`AT0e50`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{variant:`outline`,onClick:()=>{_(`${M.name}-${N}`),h(!0)},disabled:v,children:(0,Q.jsx)(l,{id:`AT0e50`})}),(0,Q.jsx)(b,{variant:`outline`,onClick:()=>void F(`make-source`),disabled:v,children:(0,Q.jsx)(l,{id:`xWomUD`,values:{editor:N}})}),(0,Q.jsx)(b,{onClick:()=>void F(`align`),disabled:v,children:(0,Q.jsx)(l,{id:`PZn2LP`})})]})}),t[45]=F,t[46]=v,t[47]=N,t[48]=R,t[49]=m,t[50]=M.name,t[51]=K):K=t[51];let q;t[52]!==H||t[53]!==G||t[54]!==K?(q=(0,Q.jsxs)(E,{className:`flex max-h-[85vh] w-full max-w-3xl flex-col`,children:[H,G,K]}),t[52]=H,t[53]=G,t[54]=K,t[55]=q):q=t[55];let J;return t[56]!==q||t[57]!==z?(J=(0,Q.jsx)(A,{open:!0,onOpenChange:z,children:q}),t[56]=q,t[57]=z,t[58]=J):J=t[58],J}function Qn(e){let t=(0,_t.c)(75),{skill:n,existingNames:r,onOpenChange:i,onRenamed:a}=e,o=ke(),s=n!==null,c=(0,$.useId)(),[u,d]=(0,$.useState)(``),[f,p]=(0,$.useState)(!1),m;t[0]===n?m=t[1]:(m=()=>{n&&d(n.name)},t[0]=n,t[1]=m);let h=n?.scope,g=n?.name,_;if(t[2]!==h||t[3]!==g?(_=[h,g],t[2]=h,t[3]=g,t[4]=_):_=t[4],(0,$.useEffect)(m,_),!n)return null;let v,y,x,S,C,D;if(t[5]!==r||t[6]!==u||t[7]!==n.name){C=u.trim(),D=C===n.name;let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\s/,t[14]=e):e=t[14];let i;t[15]===u?i=t[16]:(i=e.test(u),t[15]=u,t[16]=i),v=i,S=C.length>64,y=C===``||!Ce.test(C)||S,x=!y&&!D&&r.has(C),t[5]=r,t[6]=u,t[7]=n.name,t[8]=v,t[9]=y,t[10]=x,t[11]=S,t[12]=C,t[13]=D}else v=t[8],y=t[9],x=t[10],S=t[11],C=t[12],D=t[13];let k=x,j=!y&&!k&&!D&&!f,M;t[17]!==j||t[18]!==i||t[19]!==a||t[20]!==o||t[21]!==n||t[22]!==C?(M=async function(){if(!n||!j)return;p(!0);let e=await o({scope:n.scope,name:n.name},C);p(!1),e.ok&&(a?.(C),i(!1))},t[17]=j,t[18]=i,t[19]=a,t[20]=o,t[21]=n,t[22]=C,t[23]=M):M=t[23];let N=M,P;t[24]===i?P=t[25]:(P=e=>e?null:i(!1),t[24]=i,t[25]=P);let F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`dw_3cv`})}),t[26]=F):F=t[26];let I;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsxs)(ee,{children:[F,(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`R9IDFz`})})]}),t[27]=I):I=t[27];let L;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(l,{id:`6YtxFj`}),t[28]=L):L=t[28];let R;t[29]===c?R=t[30]:(R=(0,Q.jsx)(te,{htmlFor:c,children:L}),t[29]=c,t[30]=R);let z;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>d(e.target.value),t[31]=z):z=t[31];let B;t[32]===N?B=t[33]:(B=e=>{e.key===`Enter`&&N()},t[32]=N,t[33]=B);let V=y||k,H=y&&C!==``||k?`${c}-error`:void 0,U;t[34]!==c||t[35]!==u||t[36]!==B||t[37]!==V||t[38]!==H?(U=(0,Q.jsx)(Pe,{id:c,value:u,onChange:z,onKeyDown:B,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,maxLength:64,"aria-invalid":V,"aria-describedby":H,className:`font-mono`}),t[34]=c,t[35]=u,t[36]=B,t[37]=V,t[38]=H,t[39]=U):U=t[39];let W;t[40]!==k||t[41]!==v||t[42]!==c||t[43]!==y||t[44]!==S||t[45]!==C?(W=y&&C!==``?(0,Q.jsx)(`p`,{id:`${c}-error`,className:`text-xs text-destructive`,children:v?(0,Q.jsx)(l,{id:`iUwpZI`,components:{0:(0,Q.jsx)(`code`,{className:`font-mono`})}}):S?(0,Q.jsx)(l,{id:`lK9c4T`}):(0,Q.jsx)(l,{id:`A50vr3`,components:{0:(0,Q.jsx)(`code`,{className:`font-mono`})}})}):k?(0,Q.jsx)(`p`,{id:`${c}-error`,className:`text-xs text-destructive`,children:(0,Q.jsx)(l,{id:`YJ1BTp`})}):null,t[40]=k,t[41]=v,t[42]=c,t[43]=y,t[44]=S,t[45]=C,t[46]=W):W=t[46];let G;t[47]!==R||t[48]!==U||t[49]!==W?(G=(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[R,U,W]}),t[47]=R,t[48]=U,t[49]=W,t[50]=G):G=t[50];let K;t[51]===i?K=t[52]:(K=()=>i(!1),t[51]=i,t[52]=K);let q;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(l,{id:`dEgA5A`}),t[53]=q):q=t[53];let J;t[54]!==f||t[55]!==K?(J=(0,Q.jsx)(b,{variant:`outline`,className:`font-mono uppercase`,onClick:K,disabled:f,children:q}),t[54]=f,t[55]=K,t[56]=J):J=t[56];let Y;t[57]===N?Y=t[58]:(Y=()=>void N(),t[57]=N,t[58]=Y);let ne=!j,X;t[59]===f?X=t[60]:(X=f?(0,Q.jsx)(l,{id:`tHKQ6j`}):(0,Q.jsx)(l,{id:`2wxgft`}),t[59]=f,t[60]=X);let re;t[61]!==Y||t[62]!==ne||t[63]!==X?(re=(0,Q.jsx)(b,{onClick:Y,disabled:ne,children:X}),t[61]=Y,t[62]=ne,t[63]=X,t[64]=re):re=t[64];let ie;t[65]!==J||t[66]!==re?(ie=(0,Q.jsxs)(O,{children:[J,re]}),t[65]=J,t[66]=re,t[67]=ie):ie=t[67];let ae;t[68]!==G||t[69]!==ie?(ae=(0,Q.jsxs)(E,{children:[I,G,ie]}),t[68]=G,t[69]=ie,t[70]=ae):ae=t[70];let oe;return t[71]!==s||t[72]!==ae||t[73]!==P?(oe=(0,Q.jsx)(A,{open:s,onOpenChange:P,children:ae}),t[71]=s,t[72]=ae,t[73]=P,t[74]=oe):oe=t[74],oe}function $n(){let e=(0,_t.c)(5),{_:t}=u(),n=We(),r=Oe(),i=ct(),a;return e[0]!==t||e[1]!==r||e[2]!==n||e[3]!==i?(a=async(e,a)=>{if(a===e.scope)return!1;He(e.scope,e.name);let o=await Qe({name:e.name,fromScope:e.scope,toScope:a});if(Ve(e.scope,e.name),!o.ok)return Z.error(t({id:`07eGJB`,values:{0:o.error}})),!1;Z.success(t({id:`yhI6P0`,values:{0:e.name,1:n[a]}}));let s=i.status===`ready`?i.data.find(t=>t.scope===e.scope&&t.name===e.name):void 0;return r(s?Re(s):ce(e.scope,e.name),a===`project`&&o.path!==void 0?`${o.path.replace(/\/+$/,``)}/SKILL`:ce(a,e.name)),!0},e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=a):a=e[4],a}function er(e){let t=(0,_t.c)(38),{target:n,onOpenChange:r}=e,i=We(),a=$n(),[o,s]=(0,$.useState)(!1);if(!n)return null;let{scope:c,name:u,toScope:d}=n,f;t[0]!==o||t[1]!==r?(f=e=>!e&&!o&&r(!1),t[0]=o,t[1]=r,t[2]=f):f=t[2];let p=i[d],m;t[3]===p?m=t[4]:(m=(0,Q.jsx)(T,{children:(0,Q.jsx)(l,{id:`SXEdCq`,values:{0:p}})}),t[3]=p,t[4]=m);let h=i[c],g=i[d],_=i[d],v;t[5]!==u||t[6]!==h||t[7]!==g||t[8]!==_?(v={0:h,1:g,2:_,name:u},t[5]=u,t[6]=h,t[7]=g,t[8]=_,t[9]=v):v=t[9];let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y={0:(0,Q.jsx)(`code`,{className:`font-mono`})},t[10]=y):y=t[10];let x;t[11]===v?x=t[12]:(x=(0,Q.jsx)(w,{children:(0,Q.jsx)(l,{id:`7bIiJ7`,values:v,components:y})}),t[11]=v,t[12]=x);let S;t[13]!==m||t[14]!==x?(S=(0,Q.jsxs)(ee,{children:[m,x]}),t[13]=m,t[14]=x,t[15]=S):S=t[15];let C;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(l,{id:`dEgA5A`}),t[16]=C):C=t[16];let D;t[17]===o?D=t[18]:(D=(0,Q.jsx)(k,{asChild:!0,children:(0,Q.jsx)(b,{variant:`outline`,disabled:o,children:C})}),t[17]=o,t[18]=D);let j;t[19]!==a||t[20]!==u||t[21]!==r||t[22]!==c||t[23]!==d?(j=async()=>{s(!0),await a({scope:c,name:u},d),s(!1),r(!1)},t[19]=a,t[20]=u,t[21]=r,t[22]=c,t[23]=d,t[24]=j):j=t[24];let M;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(l,{id:`QWdKwH`}),t[25]=M):M=t[25];let N;t[26]!==o||t[27]!==j?(N=(0,Q.jsx)(b,{"data-testid":`skill-scope-move-confirm`,disabled:o,onClick:j,children:M}),t[26]=o,t[27]=j,t[28]=N):N=t[28];let P;t[29]!==D||t[30]!==N?(P=(0,Q.jsxs)(O,{children:[D,N]}),t[29]=D,t[30]=N,t[31]=P):P=t[31];let F;t[32]!==S||t[33]!==P?(F=(0,Q.jsxs)(E,{className:`sm:max-w-md`,children:[S,P]}),t[32]=S,t[33]=P,t[34]=F):F=t[34];let I;return t[35]!==f||t[36]!==F?(I=(0,Q.jsx)(A,{open:!0,onOpenChange:f,children:F}),t[35]=f,t[36]=F,t[37]=I):I=t[37],I}function tr(){let e=(0,_t.c)(45),{_:t}=u(),n=lt(),[r,i]=(0,$.useState)(null),[a,o]=(0,$.useState)(null),[s,c]=(0,$.useState)(null),[l,d]=(0,$.useState)(null),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(null),[g,_]=(0,$.useState)(null),v;e[0]===t?v=e[1]:(v=async function(e,n,r){_(e.name);let i=await et({scope:e.scope,name:e.name,...n?{targets:[...n]}:{},...r?.linkMode===void 0?{}:{linkMode:r.linkMode}});if(_(null),!i.ok)return Z.error(t({id:`Mj8R8K`,values:{0:i.error}})),i;let a=nr,o=new Set(i.hosts),s=i.hosts.filter(t=>!e.hosts.includes(t)),c=e.hosts.filter(e=>!o.has(e)),l=e=>{let t=i.warningCodes.indexOf(e);return t>=0?i.warnings[t]:void 0},u=l(`no-targets`);if(u)return Z.warning(u),i;if(s.length>0){let e=l(`scripts-present`);e&&Z.warning(e);let t=l(`no-description`);t&&Z.warning(t)}return i.hosts.length===0?Z.success(t({id:`4pDZ2N`,values:{0:e.name}})):s.length>0&&c.length===0?Z.success(t({id:`PPFQ3o`,values:{0:e.name,1:a(s)}})):c.length>0&&s.length===0?Z.success(t({id:`OOIVJo`,values:{0:e.name,1:a(c)}})):s.length>0&&c.length>0?Z.success(t({id:`OxplNM`,values:{0:e.name,1:a(s),2:a(c)}})):Z.success(t({id:`wDgmsr`,values:{0:e.name,1:a(i.hosts)}})),i},e[0]=t,e[1]=v);let y=v,b;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=async function(e,t){if(t.length!==0){_(e.name);for(let{target:n,mode:r}of t){let t=await rt({scope:e.scope,name:e.name,target:n,mode:r});if(!t.ok){Z.error(t.error);break}}_(null)}},e[2]=b):b=e[2];let x=b,S;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=async function(e,t){_(e.name);let n=await t();return _(null),n},e[3]=S):S=e[3];let C=S,w;e[4]!==t||e[5]!==n?(w=async function(e,r){let i=await tt({scope:e.scope,name:e.name,existingNames:r});if(!i.ok){Z.error(t({id:`UPjaXD`,values:{0:e.name,1:i.error}}));return}Z.success(t({id:`0g7rCZ`,values:{0:i.name}})),n(e.scope,i.name)},e[4]=t,e[5]=n,e[6]=w):w=e[6];let T=w,E,D;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>{e||i(null)},D=()=>i(null),e[7]=E,e[8]=D):(E=e[7],D=e[8]);let O;e[9]===r?O=e[10]:(O=(0,Q.jsx)(qn,{skill:r,onOpenChange:E,onDeleted:D}),e[9]=r,e[10]=O);let k=a?.skill??null,ee=a?.existingNames??ir,A,j;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{e||o(null)},A=()=>o(null),e[11]=A,e[12]=j):(A=e[11],j=e[12]);let M;e[13]!==k||e[14]!==ee?(M=(0,Q.jsx)(Qn,{skill:k,existingNames:ee,onOpenChange:j,onRenamed:A}),e[13]=k,e[14]=ee,e[15]=M):M=e[15];let N;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{e||c(null)},e[16]=N):N=e[16];let P;e[17]===s?P=e[18]:(P=(0,Q.jsx)(er,{target:s,onOpenChange:N}),e[17]=s,e[18]=P);let F;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{e||d(null)},e[19]=F):F=e[19];let I;e[20]===l?I=e[21]:(I=(0,Q.jsx)(Xn,{target:l,onOpenChange:F}),e[20]=l,e[21]=I);let L;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{e||p(null)},e[22]=L):L=e[22];let R;e[23]===f?R=e[24]:(R=(0,Q.jsx)(Yn,{target:f,onOpenChange:L}),e[23]=f,e[24]=R);let te;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{e||h(null)},e[25]=te):te=e[25];let z;e[26]===m?z=e[27]:(z=(0,Q.jsx)(Zn,{target:m,onOpenChange:te}),e[26]=m,e[27]=z);let B;e[28]!==M||e[29]!==P||e[30]!==I||e[31]!==R||e[32]!==z||e[33]!==O?(B=(0,Q.jsxs)(Q.Fragment,{children:[O,M,P,I,R,z]}),e[28]=M,e[29]=P,e[30]=I,e[31]=R,e[32]=z,e[33]=O,e[34]=B):B=e[34];let V=B,H,U,W,G,K;e[35]===Symbol.for(`react.memo_cache_sentinel`)?(H=(e,t)=>o({skill:e,existingNames:t}),U=(e,t)=>c({scope:e.scope,name:e.name,toScope:t}),W=(e,t)=>d({skill:e,filePath:t}),G=(e,t)=>p(t===void 0?{skill:e}:{skill:e,prefix:t}),K=(e,t)=>h({skill:e,editor:t}),e[35]=H,e[36]=U,e[37]=W,e[38]=G,e[39]=K):(H=e[35],U=e[36],W=e[37],G=e[38],K=e[39]);let q;return e[40]!==V||e[41]!==T||e[42]!==y||e[43]!==g?(q={installingName:g,install:y,convertLocations:x,runLocationWrite:C,duplicate:T,requestDelete:i,requestRename:H,requestScopeMove:U,requestFileRename:W,requestFileCreate:G,requestForkResolve:K,dialogs:V},e[40]=V,e[41]=T,e[42]=y,e[43]=g,e[44]=q):q=e[44],q}function nr(e){return e.map(rr).join(`, `)}function rr(e){return ve[e]??e}var ir=new Set;function ar(e){let t=(0,_t.c)(29),{skill:n,filePath:r,actions:i}=e,{_:a}=u(),o=typeof window<`u`?window.okDesktop:void 0,s=n.absolutePath?`${n.absolutePath}/${r}`:void 0,c=`${n.path}/${r}`,d;t[0]===a?d=t[1]:(d=async function(e){try{await ut(e),Z.success(a({id:`SXCSQd`}))}catch{Z.error(a({id:`cRHuuI`}))}},t[0]=a,t[1]=d);let f=d,p;t[2]!==i||t[3]!==r||t[4]!==n?(p=()=>i.requestFileRename(n,r),t[2]=i,t[3]=r,t[4]=n,t[5]=p):p=t[5];let m,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(ht,{"aria-hidden":!0}),h=(0,Q.jsx)(l,{id:`2wxgft`}),t[6]=m,t[7]=h):(m=t[6],h=t[7]);let g;t[8]===p?g=t[9]:(g=(0,Q.jsxs)(j,{onSelect:p,children:[m,h]}),t[8]=p,t[9]=g);let _;t[10]===s?_=t[11]:(_=o&&s?(0,Q.jsxs)(j,{onSelect:()=>void o.shell.showItemInFolder(s),children:[(0,Q.jsx)(je,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`LtSYdi`})]}):null,t[10]=s,t[11]=_);let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(Ae,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`zd00pH`})]}),t[12]=v):v=t[12];let y;t[13]!==s||t[14]!==f?(y=s?(0,Q.jsx)(j,{onSelect:()=>void f(s),children:(0,Q.jsx)(l,{id:`z2funE`})}):null,t[13]=s,t[14]=f,t[15]=y):y=t[15];let b;t[16]!==f||t[17]!==c?(b=()=>void f(c),t[16]=f,t[17]=c,t[18]=b):b=t[18];let x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(l,{id:`xloBjn`}),t[19]=x):x=t[19];let S;t[20]===b?S=t[21]:(S=(0,Q.jsx)(j,{onSelect:b,children:x}),t[20]=b,t[21]=S);let C;t[22]!==S||t[23]!==y?(C=(0,Q.jsxs)(M,{children:[v,(0,Q.jsxs)(N,{children:[y,S]})]}),t[22]=S,t[23]=y,t[24]=C):C=t[24];let w;return t[25]!==C||t[26]!==g||t[27]!==_?(w=(0,Q.jsxs)(Q.Fragment,{children:[g,_,C]}),t[25]=C,t[26]=g,t[27]=_,t[28]=w):w=t[28],w}function or(e){let t=(0,_t.c)(86),{skill:n,actions:r,existingNames:i}=e,{_:o}=u(),s=p(),c=We(),d=v().states,{dispatch:f}=un(),h=bn(n,r),g=typeof window<`u`?window.okDesktop:void 0,_=n.absolutePath,y;t[0]===o?y=t[1]:(y=async function(e){try{await ut(e),Z.success(o({id:`SXCSQd`}))}catch{Z.error(o({id:`cRHuuI`}))}},t[0]=o,t[1]=y);let b=y,x;t[2]===_?x=t[3]:(x=g&&_?(0,Q.jsxs)(j,{onSelect:()=>void g.shell.showItemInFolder(_),children:[(0,Q.jsx)(je,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`LtSYdi`})]}):null,t[2]=_,t[3]=x);let S;t[4]!==n.name||t[5]!==n.scope||t[6]!==s?(S=Kt({skillName:n.name,scope:n.scope,workspace:s}),t[4]=n.name,t[5]=n.scope,t[6]=s,t[7]=S):S=t[7];let C;t[8]!==f||t[9]!==d||t[10]!==S?(C=(0,Q.jsx)(Bn,{input:S,installStates:d,isElectronHost:g!=null,dispatch:f}),t[8]=f,t[9]=d,t[10]=S,t[11]=C):C=t[11];let w;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(Ae,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`zd00pH`})]}),t[12]=w):w=t[12];let T;t[13]!==_||t[14]!==b?(T=_?(0,Q.jsx)(j,{onSelect:()=>void b(_),children:(0,Q.jsx)(l,{id:`z2funE`})}):null,t[13]=_,t[14]=b,t[15]=T):T=t[15];let E;t[16]!==b||t[17]!==n.path?(E=()=>void b(n.path),t[16]=b,t[17]=n.path,t[18]=E):E=t[18];let D;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Q.jsx)(l,{id:`xloBjn`}),t[19]=D):D=t[19];let O;t[20]===E?O=t[21]:(O=(0,Q.jsx)(j,{onSelect:E,children:D}),t[20]=E,t[21]=O);let k;t[22]!==T||t[23]!==O?(k=(0,Q.jsxs)(M,{children:[w,(0,Q.jsxs)(N,{children:[T,O]})]}),t[22]=T,t[23]=O,t[24]=k):k=t[24];let ee;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Q.jsx)(R,{}),t[25]=ee):ee=t[25];let A;t[26]!==r||t[27]!==i||t[28]!==n?(A=()=>void r.duplicate(n,i),t[26]=r,t[27]=i,t[28]=n,t[29]=A):A=t[29];let P,F;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(a,{"aria-hidden":!0}),F=(0,Q.jsx)(l,{id:`euc6Ns`}),t[30]=P,t[31]=F):(P=t[30],F=t[31]);let I;t[32]===A?I=t[33]:(I=(0,Q.jsxs)(j,{onSelect:A,children:[P,F]}),t[32]=A,t[33]=I);let te;t[34]!==r||t[35]!==i||t[36]!==n?(te=()=>r.requestRename(n,i),t[34]=r,t[35]=i,t[36]=n,t[37]=te):te=t[37];let z,B;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Q.jsx)(ht,{"aria-hidden":!0}),B=(0,Q.jsx)(l,{id:`2wxgft`}),t[38]=z,t[39]=B):(z=t[38],B=t[39]);let V;t[40]===te?V=t[41]:(V=(0,Q.jsxs)(j,{onSelect:te,children:[z,B]}),t[40]=te,t[41]=V);let H;t[42]!==r||t[43]!==n?(H=()=>r.requestFileCreate(n),t[42]=r,t[43]=n,t[44]=H):H=t[44];let U,W;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(m,{"aria-hidden":!0}),W=(0,Q.jsx)(l,{id:`HdkSiO`}),t[45]=U,t[46]=W):(U=t[45],W=t[46]);let G;t[47]===H?G=t[48]:(G=(0,Q.jsxs)(j,{onSelect:H,children:[U,W]}),t[47]=H,t[48]=G);let K;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(pt,{"aria-hidden":!0}),(0,Q.jsx)(l,{id:`TKQ7K-`})]}),t[49]=K):K=t[49];let q;t[50]!==r||t[51]!==n?(q=e=>r.requestForkResolve(n,e),t[50]=r,t[51]=n,t[52]=q):q=t[52];let J;t[53]!==h||t[54]!==n||t[55]!==q?(J=(0,Q.jsxs)(M,{children:[K,(0,Q.jsx)(N,{className:yn,children:(0,Q.jsx)(Tn,{toggles:h,skill:n,onResolveFork:q})})]}),t[53]=h,t[54]=n,t[55]=q,t[56]=J):J=t[56];let Y;t[57]!==r||t[58]!==n?(Y=()=>r.requestScopeMove(n,n.scope===`project`?`global`:`project`),t[57]=r,t[58]=n,t[59]=Y):Y=t[59];let ne;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Q.jsx)(ft,{"aria-hidden":!0}),t[60]=ne):ne=t[60];let X;t[61]!==c.global||t[62]!==c.project||t[63]!==n.scope?(X=n.scope===`project`?(0,Q.jsx)(l,{id:`bpytj4`,values:{0:c.global}}):(0,Q.jsx)(l,{id:`bpytj4`,values:{0:c.project}}),t[61]=c.global,t[62]=c.project,t[63]=n.scope,t[64]=X):X=t[64];let re;t[65]!==Y||t[66]!==X?(re=(0,Q.jsxs)(j,{onSelect:Y,children:[ne,X]}),t[65]=Y,t[66]=X,t[67]=re):re=t[67];let ie;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(R,{}),t[68]=ie):ie=t[68];let ae;t[69]!==r||t[70]!==n?(ae=()=>r.requestDelete(n),t[69]=r,t[70]=n,t[71]=ae):ae=t[71];let oe,se;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Q.jsx)(Ne,{"aria-hidden":!0}),se=(0,Q.jsx)(l,{id:`cnGeoo`}),t[72]=oe,t[73]=se):(oe=t[72],se=t[73]);let ce;t[74]===ae?ce=t[75]:(ce=(0,Q.jsxs)(j,{variant:`destructive`,onSelect:ae,children:[oe,se]}),t[74]=ae,t[75]=ce);let le;return t[76]!==k||t[77]!==I||t[78]!==V||t[79]!==x||t[80]!==G||t[81]!==J||t[82]!==re||t[83]!==ce||t[84]!==C?(le=(0,Q.jsxs)(Q.Fragment,{children:[x,C,k,ee,I,V,G,J,re,ie,ce]}),t[76]=k,t[77]=I,t[78]=V,t[79]=x,t[80]=G,t[81]=J,t[82]=re,t[83]=ce,t[84]=C,t[85]=le):le=t[85],le}export{gt as C,Bt as S,ft as T,en as _,Wn as a,an as b,vn as c,bn as d,qt as f,Ht as g,Vt as h,er as i,yn as l,Gt as m,ar as n,Bn as o,Ut as p,tr as r,Rn as s,or as t,Tn as u,sn as v,mt as w,un as x,Wt as y};
@@ -1,6 +1,6 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{$ as n,Ht as r,It as i,Pt as a,Tn as o,dt as s,et as c,gn as l,ht as u,i as d,lt as f,w as p,yt as m}from"./DocumentContext-CY-aaPA2.js";import{t as h}from"./react-f2sANaYj.js";import{n as g,r as _}from"./dist-Nvb76hAm.js";import{r as v,t as y}from"./useQuery-ZeEDLtxh.js";import{t as b}from"./compiler-runtime-BfE3aGVn.js";import{t as x}from"./utils-CPqDy6Hr.js";import{t as S}from"./button-RQ5o7P7w.js";import{i as C,n as w,t as T}from"./tooltip-x7BNUa3s.js";import{n as E,r as D,t as O}from"./collapsible-OhEmjTXw.js";import{A as k,E as A,j,ot as M}from"./CodeMirrorPropInput-DTaNg1-M.js";import{n as N,t as P}from"./toggle-group-Cnezoq-B.js";import{Bt as F,En as I,Ma as L,P as R,Tn as z,Ua as B,Vr as V,Vt as H,_a as U,ct as W,ft as G}from"./dist-OxboORfH2.js";import{t as ee}from"./createLucideIcon-DihYAFEK.js";import{t as te}from"./chevron-right-CABnKLlm.js";import{r as K}from"./CopyButton-D6N3opvE.js";import{i as q,r as ne}from"./prop-types-ZLa1Cj_J.js";import{t as re}from"./refresh-cw-CTfHLdRW.js";import{t as J}from"./triangle-alert-C2yId37R.js";import{t as ie}from"./wrench-BvqzH63x.js";import{n as Y}from"./dist-uN7pEWl0.js";import{t as ae}from"./dist-CzC3AWOn.js";import{f as oe,u as se}from"./doc-paths-lZOQ-mhw.js";import{o as ce}from"./use-settings-route-CIJMHLaP.js";import{d as le}from"./documents-events-5TI0rZAg.js";import{a as ue,i as de}from"./startup-marks-B88RuIAa.js";import{t as X}from"./badge-C21d8Yhu.js";import{C as fe,y as pe}from"./config-provider-CswKxDa9.js";import{Dt as me,Ft as he,It as ge,J as _e,Q as ve,X as ye}from"./dist-BNDNcytQ.js";import{a as be,c as xe,i as Se,n as Ce,r as we,s as Te,t as Ee}from"./panel-Boo96yEj.js";import{t as De}from"./lint-plugin-meta-7A6ZrPoH.js";import{t as Oe}from"./skeleton-CD1oYYfF.js";import{a as ke,c as Ae,d as je}from"./lint-config-client-CGN8hOQ_.js";var Me=ee(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Ne=ee(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Pe=56,Fe=2,Ie=150,Le=2e3;function Re(e,t,n){return e.top+e.height/2-(n+t)/2}function ze(e,t){let n=Math.max(0,t.scrollHeight-t.clientHeight);return Math.max(0,Math.min(e,n))}function Be(e){let{docName:t,container:n,measureTarget:r,placement:i,intent:a,grade:o,landedMode:c,transition:l,onOutcome:d,onDiscardQueuedTarget:f,toolbarOffset:p=Pe,driftThresholdPx:h=Fe,quietMs:g=Ie,abandonAfterMs:_=Le}=e,v=e.contentColumn??n.firstElementChild,y=s(t),b=u(t,{yieldsToNavigation:a===`toggle`,supersede:()=>P(`superseded`)}),x=n.style.overflowAnchor;n.style.overflowAnchor=`none`,l&&ue(`ok/mode-switch/transition`,{from:l.from,to:l.to,grade:o});let S=!1,C=null,w,T,E=0,D,O=()=>{let e=r();return e===null?null:ze(i===`center`?Re(e,n.clientHeight,p):e.top-p,n)},k=()=>{let e=O();if(e===null)return{measurable:!1,moved:!1};C=e;let t=Math.abs(n.scrollTop-e)>h;return t&&(n.scrollTop=e),{measurable:!0,moved:t}},A=()=>n.scrollTop-(O()??C??n.scrollTop),j=()=>{w&&clearTimeout(w),T&&clearTimeout(T),E&&cancelAnimationFrame(E),D?.disconnect(),n.removeEventListener(`wheel`,I),n.removeEventListener(`touchstart`,I),n.removeEventListener(`contentvisibilityautostatechange`,L,!0),n.style.overflowAnchor=x,y.release(),b.release()},M=()=>{if(S)return;S=!0;let e;try{k(),e=A(),C!==null&&m({docName:t,container:n,targetScrollTop:n.scrollTop,mode:c})}finally{j()}ue(`ok/landing/land`,{grade:o,delta:e}),d?.({status:`landed`,delta:e})},N=()=>{if(S)return;S=!0;let e=C??n.scrollTop,t;try{t=A()}finally{j()}ue(`ok/landing/abandoned`,{grade:o,target:e,delta:t}),d?.({status:`abandoned`,delta:t})},P=e=>{S||(S=!0,j(),e===`mode-flip`&&f?.(),d?.({status:`cancelled`,reason:e}))},F=()=>{w&&clearTimeout(w),w=setTimeout(M,g)};function I(){P(`user-scroll`)}function L(){if(S)return;let{measurable:e,moved:t}=k();e&&(t||w===void 0)&&F()}try{k().measurable&&F(),n.addEventListener(`contentvisibilityautostatechange`,L,!0),n.addEventListener(`wheel`,I,{passive:!0}),n.addEventListener(`touchstart`,I,{passive:!0}),typeof ResizeObserver<`u`&&v&&(D=new ResizeObserver(L),D.observe(v)),E=requestAnimationFrame(L),T=setTimeout(N,_)}catch(e){throw S=!0,j(),e}return{cancel:P}}function Ve(e){switch(e){case`bulletList`:case`orderedList`:case`taskList`:case`list`:return`list`;case`codeBlock`:case`code`:return`code`;case`horizontalRule`:case`thematicBreak`:return`thematicBreak`;case`jsxComponent`:case`mdxJsxFlowElement`:case`mdxJsxTextElement`:return`jsx`;case`htmlBlock`:case`html`:return`html`;default:return e}}function He(e){return typeof e!=`object`||!e?``:`value`in e&&typeof e.value==`string`?e.value:`children`in e&&Array.isArray(e.children)?e.children.map(He).join(``):``}function Ue(e,t){let{frontmatter:n,body:r}=B(e),i=n===``?0:n.split(`
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{$ as n,En as r,Ft as i,Lt as a,Ut as o,_n as s,bt as c,et as l,ft as u,gt as d,i as f,ut as p,w as m}from"./DocumentContext-UuXLA8HR.js";import{t as h}from"./react-f2sANaYj.js";import{n as g,r as _}from"./dist-Nvb76hAm.js";import{r as v,t as y}from"./useQuery-ZeEDLtxh.js";import{t as b}from"./compiler-runtime-BfE3aGVn.js";import{t as x}from"./utils-CPqDy6Hr.js";import{t as S}from"./button-RQ5o7P7w.js";import{i as C,n as w,t as T}from"./tooltip-x7BNUa3s.js";import{n as E,r as D,t as O}from"./collapsible-OhEmjTXw.js";import{A as k,E as A,j,ot as M}from"./CodeMirrorPropInput-DTaNg1-M.js";import{n as N,t as P}from"./toggle-group-Cnezoq-B.js";import{Bt as F,En as I,Ma as L,P as R,Tn as z,Ua as B,Vr as V,Vt as H,_a as U,ct as W,ft as G}from"./dist-OxboORfH2.js";import{t as ee}from"./createLucideIcon-DihYAFEK.js";import{t as te}from"./chevron-right-CABnKLlm.js";import{r as K}from"./CopyButton-D6N3opvE.js";import{i as q,r as ne}from"./prop-types-ZLa1Cj_J.js";import{t as re}from"./refresh-cw-CTfHLdRW.js";import{t as J}from"./triangle-alert-C2yId37R.js";import{t as ie}from"./wrench-BvqzH63x.js";import{n as Y}from"./dist-uN7pEWl0.js";import{t as ae}from"./dist-CzC3AWOn.js";import{f as oe,u as se}from"./doc-paths-lZOQ-mhw.js";import{o as ce}from"./use-settings-route-CIJMHLaP.js";import{d as le}from"./documents-events-5TI0rZAg.js";import{a as ue,i as de}from"./startup-marks-B88RuIAa.js";import{t as X}from"./badge-C21d8Yhu.js";import{C as fe,y as pe}from"./config-provider-CswKxDa9.js";import{Dt as me,Ft as he,It as ge,J as _e,Q as ve,X as ye}from"./dist-BNDNcytQ.js";import{a as be,c as xe,i as Se,n as Ce,r as we,s as Te,t as Ee}from"./panel-Boo96yEj.js";import{t as De}from"./lint-plugin-meta-7A6ZrPoH.js";import{t as Oe}from"./skeleton-CD1oYYfF.js";import{a as ke,c as Ae,d as je}from"./lint-config-client-CGN8hOQ_.js";var Me=ee(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Ne=ee(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Pe=56,Fe=2,Ie=150,Le=2e3;function Re(e,t,n){return e.top+e.height/2-(n+t)/2}function ze(e,t){let n=Math.max(0,t.scrollHeight-t.clientHeight);return Math.max(0,Math.min(e,n))}function Be(e){let{docName:t,container:n,measureTarget:r,placement:i,intent:a,grade:o,landedMode:s,transition:l,onOutcome:f,onDiscardQueuedTarget:p,toolbarOffset:m=Pe,driftThresholdPx:h=Fe,quietMs:g=Ie,abandonAfterMs:_=Le}=e,v=e.contentColumn??n.firstElementChild,y=u(t),b=d(t,{yieldsToNavigation:a===`toggle`,supersede:()=>P(`superseded`)}),x=n.style.overflowAnchor;n.style.overflowAnchor=`none`,l&&ue(`ok/mode-switch/transition`,{from:l.from,to:l.to,grade:o});let S=!1,C=null,w,T,E=0,D,O=()=>{let e=r();return e===null?null:ze(i===`center`?Re(e,n.clientHeight,m):e.top-m,n)},k=()=>{let e=O();if(e===null)return{measurable:!1,moved:!1};C=e;let t=Math.abs(n.scrollTop-e)>h;return t&&(n.scrollTop=e),{measurable:!0,moved:t}},A=()=>n.scrollTop-(O()??C??n.scrollTop),j=()=>{w&&clearTimeout(w),T&&clearTimeout(T),E&&cancelAnimationFrame(E),D?.disconnect(),n.removeEventListener(`wheel`,I),n.removeEventListener(`touchstart`,I),n.removeEventListener(`contentvisibilityautostatechange`,L,!0),n.style.overflowAnchor=x,y.release(),b.release()},M=()=>{if(S)return;S=!0;let e;try{k(),e=A(),C!==null&&c({docName:t,container:n,targetScrollTop:n.scrollTop,mode:s})}finally{j()}ue(`ok/landing/land`,{grade:o,delta:e}),f?.({status:`landed`,delta:e})},N=()=>{if(S)return;S=!0;let e=C??n.scrollTop,t;try{t=A()}finally{j()}ue(`ok/landing/abandoned`,{grade:o,target:e,delta:t}),f?.({status:`abandoned`,delta:t})},P=e=>{S||(S=!0,j(),e===`mode-flip`&&p?.(),f?.({status:`cancelled`,reason:e}))},F=()=>{w&&clearTimeout(w),w=setTimeout(M,g)};function I(){P(`user-scroll`)}function L(){if(S)return;let{measurable:e,moved:t}=k();e&&(t||w===void 0)&&F()}try{k().measurable&&F(),n.addEventListener(`contentvisibilityautostatechange`,L,!0),n.addEventListener(`wheel`,I,{passive:!0}),n.addEventListener(`touchstart`,I,{passive:!0}),typeof ResizeObserver<`u`&&v&&(D=new ResizeObserver(L),D.observe(v)),E=requestAnimationFrame(L),T=setTimeout(N,_)}catch(e){throw S=!0,j(),e}return{cancel:P}}function Ve(e){switch(e){case`bulletList`:case`orderedList`:case`taskList`:case`list`:return`list`;case`codeBlock`:case`code`:return`code`;case`horizontalRule`:case`thematicBreak`:return`thematicBreak`;case`jsxComponent`:case`mdxJsxFlowElement`:case`mdxJsxTextElement`:return`jsx`;case`htmlBlock`:case`html`:return`html`;default:return e}}function He(e){return typeof e!=`object`||!e?``:`value`in e&&typeof e.value==`string`?e.value:`children`in e&&Array.isArray(e.children)?e.children.map(He).join(``):``}function Ue(e,t){let{frontmatter:n,body:r}=B(e),i=n===``?0:n.split(`
2
2
  `).length-1;try{return{blocks:t.parseToEditorMdast(r).children.map(e=>({start:(e.position?.start.line??1/0)+i,end:(e.position?.end.line??-1/0)+i,kind:Ve(e.type),text:He(e)})),fmLineCount:i}}catch{return performance.mark(`ok/block-spans/parse-failed`),{blocks:[],fmLineCount:i}}}function We(e,t){let{blocks:n,fmLineCount:r}=Ue(e,t);return{spans:n.map(e=>({start:e.start,end:e.end})),fmLineCount:r}}function Ge(e,t){if(e.length===0)return null;let n=0,r=e.length-1,i=e.length-1;for(;n<=r;){let a=n+r>>1,o=e[a];o!==void 0&&o.end>=t?(i=a,r=a-1):n=a+1}return i}function Ke(e){let t=e.childCount>0?e.child(e.childCount-1):null;return t!==null&&t.type.name===`paragraph`&&t.content.size===0?e.childCount-1:e.childCount}function qe(e,t,n){let r=e.childCount,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));if(a<=i)return null;let o=0;for(let t=0;t<i;t++)o+=e.child(t).nodeSize;let s=o;for(let t=i;t<a;t++)o+=e.child(t).nodeSize;let c=o,l=e.content.size,u=Math.max(0,Math.min(s,l)),d=Math.max(u,Math.min(c,l));return d<=u?null:{from:u,to:d}}function Je(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
3
- `&&t.push(n+1);return t}function Ye(e,t,n){return t<=1?0:t-1>=e.length?n:e[t-1]??n}function Xe(e,t){let n=0,r=e.length-1,i=1;for(;n<=r;){let a=n+r>>1;(e[a]??0)<=t?(i=a+1,n=a+1):r=a-1}return i}function Ze(e,t,n){return Math.max(t,Math.min(e,n))}function Qe(e,t){let n=e=>e.replace(/\s+/g,` `).trim();return n(e)===n(t)}function $e(e,t){return t.inRange?t.tripwireOk?Qe(e.content,t.text)?`exact`:e.kind===t.kind?`same-type-ordinal`:`ordinal`:`ordinal`:`clamped`}function et(e){let t=null,n=null;function r(r){return n!==null&&t===r?n:(n={blocks:Ue(r,e).blocks,lineStarts:Je(r)},t=r,n)}return{captureFromWysiwyg(e,t,n){if(e.childCount===0)return null;let r=Ze(t,0,e.content.size),i=0,a=e.childCount-1,o=0;for(let t=0;t<e.childCount;t++){let n=e.child(t).nodeSize;if(r<i+n){a=t,o=i+1;break}i+=n,o=i+1}let s=e.child(a),c={blockIndex:a,kind:Ve(s.type.name),content:s.textContent};return n?.refine&&(c.selectionInBlock=Math.max(0,r-o)),c},captureFromSource(e,t,n){let{blocks:i,lineStarts:a}=r(e);if(i.length===0)return null;let o=Ze(t,0,e.length),s=Ge(i,Xe(a,o));if(s===null)return null;let c=i[s];if(!c)return null;let l={blockIndex:s,kind:c.kind,content:c.text};if(n?.refine){let t=Ye(a,c.start,e.length);l.selectionInBlock=Math.max(0,o-t)}return l},resolveInSource(e,{source:t,doc:n}){let{blocks:i,lineStarts:a}=r(t);if(i.length===0)return null;let o=e.blockIndex>=0&&e.blockIndex<i.length,s=Ke(n)===i.length,c=i[Ze(e.blockIndex,0,i.length-1)],l=Ye(a,c.start,t.length),u=Math.min(Ye(a,c.end+1,t.length),t.length),d=$e(e,{inRange:o,tripwireOk:s,kind:c.kind,text:c.text}),f=l;return d===`exact`&&e.selectionInBlock!==void 0&&(f=Ze(l+e.selectionInBlock,l,u)),{blockStart:l,blockEnd:u,point:f,confidence:d}},resolveInWysiwyg(e,{source:t,doc:n}){let i=Ke(n);if(i===0)return null;let{blocks:a}=r(t),o=e.blockIndex>=0&&e.blockIndex<i,s=i===a.length,c=Ze(e.blockIndex,0,i-1),l=qe(n,c,c+1);if(l===null)return null;let u=n.child(c),d=$e(e,{inRange:o,tripwireOk:s,kind:Ve(u.type.name),text:u.textContent});return{blockStart:l.from,blockEnd:l.to,point:l.from,confidence:d}}}}var tt=he.define(),nt=he.define(),rt=_e.mark({class:n}),it=ge.define({create(){return _e.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(tt)?n=_e.set([rt.range(e.value.from,e.value.to)]):e.is(nt)&&(n=_e.none);return n},provide:e=>ye.decorations.from(e)}),at=new WeakMap,ot=ve.define(e=>({destroy(){let t=at.get(e);t!==void 0&&(clearTimeout(t),at.delete(e))}}));function st(e,t,n,r){let i=c(e.state.doc.length,t,n,r);if(!i)return;e.dispatch({effects:tt.of(i)});let a=at.get(e);a!==void 0&&clearTimeout(a);let o=setTimeout(()=>{at.delete(e),e.dispatch({effects:nt.of(null)})},R);at.set(e,o)}function ct(){return[it,ot]}var lt=3e4;function ut(){let e=new Map,t=e=>e?Date.now()-e.rememberedAt>lt?null:e.navigation:null;return{remember(t,n){e.set(t,{navigation:n,rememberedAt:Date.now()})},peek(n){return t(e.get(n))},consume(n){let r=e.get(n);return e.delete(n),t(r)},clear(t){e.delete(t)},clearForTest(){e.clear()}}}var dt=ut(),ft=ut(),pt=dt.remember,mt=dt.peek,ht=dt.consume,gt=dt.clear;dt.clearForTest;var _t=ft.remember,vt=ft.peek,yt=ft.consume,bt=ft.clear;ft.clearForTest;function xt(e,t,n){return{start:fe(e,t),end:fe(e,n)}}function St(e,t){let n=pe(e.start,t),r=pe(e.end,t);return n===null||r===null||r.index<=n.index?null:n.index}var Ct=`open-knowledge:view-in-source`,wt=56,Tt=null;function Et(){return Tt??=et(k()),Tt}function Dt(e,t,n,r,i=`toggle`){let a=r.captureFromWysiwyg(e,t,{refine:i===`jump`});if(!a)return null;let o=r.resolveInSource(a,{source:n.toString(),doc:e});return{kind:`selection-offset`,intent:i,anchor:a,pin:o?xt(n,o.blockStart,o.blockEnd):void 0}}function Ot(e){let{editor:t,docName:n,ytext:r}=e,i=A(t);if(!i)return;let a=i.state.selection.from,o=Dt(i.state.doc,a,r,Et(),`jump`);o&&pt(n,o),window.dispatchEvent(new CustomEvent(Ct,{detail:{docName:n}}))}function kt(e,t,n,r,i){let a=r.captureFromSource(e,t);if(!a)return null;let o=i?r.resolveInSource(a,{source:e,doc:i}):null;return{kind:`selection-offset`,anchor:a,pin:o?xt(n,o.blockStart,o.blockEnd):void 0}}function At(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=St(e.pin,i);if(t===null){let t=a.resolveInWysiwyg(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInWysiwyg(o,{source:n,doc:r})}return a.resolveInWysiwyg(e.anchor,{source:n,doc:r})}function jt(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=St(e.pin,i);if(t===null){let t=a.resolveInSource(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInSource(o,{source:n,doc:r})}return a.resolveInSource(e.anchor,{source:n,doc:r})}function Mt(e,t){try{return e.coordsAtPos(t)}catch{return null}}function Nt(e,t,n){let r=Math.max(0,Math.min(n,e.state.doc.length)),i=t.getBoundingClientRect().top,a=Mt(e,r);if(a)return{top:a.top-i+t.scrollTop,height:a.bottom-a.top};try{let n=e.lineBlockAt(r);return{top:e.documentTop-i+t.scrollTop+n.top,height:n.height}}catch{return null}}function Pt(e,t){if(e.isDestroyed)return null;try{let n=e.nodeDOM(t);if(n instanceof HTMLElement)return n;let{node:r}=e.domAtPos(t);return r instanceof HTMLElement?r:r.parentElement}catch{return null}}function Ft(e,t,n){if(e.isDestroyed)return null;let r=Pt(e,Math.max(0,Math.min(n,e.state.doc.content.size)));if(!r)return null;let i=r.getBoundingClientRect(),a=t.getBoundingClientRect().top;return{top:i.top-a+t.scrollTop,height:i.height}}function It(){return typeof document>`u`?null:f()}function Lt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2;for(let t of[wt+1,wt+12,wt+40]){let i=e.posAtCoords({left:r,top:n.top+t});if(i)return i.pos}return null}function Rt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2;for(let t of[wt+1,wt+12,wt+40]){let i=e.posAtCoords({x:r,y:n.top+t});if(i!==null)return i}return null}function zt(e){let{from:t,to:n,docName:r,ytext:i}=e;t===`wysiwyg`&&n===`source`?Bt(r,i):t===`source`&&n===`wysiwyg`&&Vt(r,i)}function Bt(e,t){let n=mt(e);if(n&&n.kind!==`selection-offset`)return;let i=r(e);if(!i)return;let a=A(i);if(!a)return;let o=It();if(!o)return;let s=Lt(a,o);if(s===null)return;let c=Dt(a.state.doc,s,t,Et());c&&pt(e,c)}function Vt(e,t){let n=a(e);if(!n)return;let i=It();if(!i)return;let o=Rt(n,i);if(o===null)return;let s=r(e),c=s?A(s)?.state.doc:void 0,l=kt(t.toString(),o,t,Et(),c);l&&_t(e,l)}function Ht(e){let{view:t,docName:n,navigation:i,ydoc:a,transition:o}=e,s=r(n),c=s?A(s)?.state.doc:void 0;if(!c)return null;let l=jt(i,{source:t.state.doc.toString(),pmDoc:c,ydoc:a,resolver:Et()});if(!l)return null;let d=It();if(!d)return null;let f=l,p=i.intent===`jump`,m=p?f.point:f.blockStart;t.dispatch({effects:ye.scrollIntoView(m,{y:`start`})});let h=!1,g=null,_=u(n,{yieldsToNavigation:!p,supersede:()=>{h=!0,_.release()}}),v=e=>{if(!h){if(Mt(t,m)===null&&e<8){requestAnimationFrame(()=>v(e+1));return}try{p&&(t.dispatch({selection:me.cursor(m)}),t.focus())}finally{_.release()}g=Be({docName:n,container:d,contentColumn:t.contentDOM,measureTarget:()=>Nt(t,d,m),placement:p?`center`:`top`,intent:p?`jump`:`toggle`,grade:f.confidence,landedMode:`source`,transition:o,toolbarOffset:wt,onOutcome:p?e=>{e.status===`landed`&&st(t,f.blockStart,f.blockEnd,f.confidence)}:void 0,onDiscardQueuedTarget:()=>gt(n)})}};return v(0),{cancel:e=>{h=!0,_.release(),g?.cancel(e)}}}function Ut(e){let{editor:t,docName:n,navigation:r,ydoc:i,transition:a}=e,o=A(t);if(!o)return null;let s=At(r,{source:i.getText(`source`).toString(),pmDoc:o.state.doc,ydoc:i,resolver:Et()});if(!s)return null;let c=It();if(!c)return null;let l=s;return Be({docName:n,container:c,contentColumn:o.dom,measureTarget:()=>Ft(o,c,l.point),placement:`top`,intent:`toggle`,grade:l.confidence,landedMode:`wysiwyg`,transition:a,toolbarOffset:wt,onDiscardQueuedTarget:()=>bt(n)})}var Z=e(h(),1),Q=b(),$=t();function Wt(e){let t=(0,Q.c)(14),{scope:n,onScopeChange:r,projectLabel:i}=e,{_:a}=_(),o;t[0]===r?o=t[1]:(o=e=>{e&&r(e)},t[0]=r,t[1]=o);let s;t[2]===a?s=t[3]:(s=a({id:`aBgwis`}),t[2]=a,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(N,{value:`doc`,className:`flex-1`,"data-testid":`panel-scope-doc`,children:(0,$.jsx)(g,{id:`UpCz01`})}),t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i??(0,$.jsx)(g,{id:`e0NrBM`}),t[5]=i,t[6]=l);let u;t[7]===l?u=t[8]:(u=(0,$.jsx)(N,{value:`project`,className:`flex-1`,"data-testid":`panel-scope-project`,children:l}),t[7]=l,t[8]=u);let d;return t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2`,children:(0,$.jsxs)(P,{type:`single`,variant:`segmented`,size:`sm`,spacing:1,value:n,onValueChange:o,"aria-label":s,className:`w-full rounded-md bg-muted p-0.5 dark:bg-background`,children:[c,u]})}),t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}var Gt=null,Kt=[];function qt(e){if(e===Gt)return Kt;let t=Jt(e);return Gt=e,Kt=t,t}function Jt(e){let t=[],n=new Map,r=I();for(let i=Yt(e);i<=e.lines;i++){let a=e.line(i);if(r(a.text))continue;let o=V(a.text,n);o&&t.push({slug:o.slug,from:a.from})}return t}function Yt(e){if(!Xt(e.line(1).text))return 1;for(let t=2;t<=e.lines;t++)if(Xt(e.line(t).text))return t+1;return 1}function Xt(e){return U.test(e.endsWith(`\r`)?e.slice(0,-1):e)}function Zt(e){let t=document.getElementById(e);return t?t.getBoundingClientRect().top:null}function Qt(e){let t=new Map;for(let n of qt(e.state.doc))t.set(n.slug,n.from);let n=e.documentTop;return r=>{let i=t.get(r);return i===void 0?null:n+e.lineBlockAt(i).top}}function $t(e,t){let n=(0,Q.c)(9),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{isSourceMode:o,docName:s}=r,c=o===void 0?!1:o,[l,u]=(0,Z.useState)(void 0),d=(0,Z.useRef)(null),f;n[2]===s?f=n[3]:(f=()=>s?a(s):null,n[2]=s,n[3]=f);let p=(0,Z.useSyncExternalStore)(i,f,en),m,h;return n[4]!==c||n[5]!==e||n[6]!==p?(m=()=>{if(e.length===0||c&&!p){u(void 0);return}let t=function(){let t=c&&p?Qt(p):Zt,n=window.innerHeight/2,r,i;for(let a of e){let e=t(a);e!==null&&(e<0?r=a:i===void 0&&e<n&&(i=a))}u(i??r??e[0])},n=function(){d.current===null&&(d.current=requestAnimationFrame(()=>{d.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)}},h=[e,c,p],n[4]=c,n[5]=e,n[6]=p,n[7]=m,n[8]=h):(m=n[7],h=n[8]),(0,Z.useEffect)(m,h),l}function en(){return null}var tn=300;async function nn(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new j(ae._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=G.safeParse(n);throw e.success?Error(e.data.title):new j(ae._({id:`zlErBl`}),{status:t.status})}let r=W.safeParse(n);if(!r.success)throw new j(ae._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var rn=32,an=12,on=6,sn=`open-knowledge:outline-nav`;function cn(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(de,{name:`outline-panel`,children:(0,$.jsx)(ln,{...e})}),t[0]=e,t[1]=n),n}function ln(e){let t=(0,Q.c)(53),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{_:o}=_(),{pages:s,loading:c}=q(),l=v(),{activeProvider:u,activeDocName:f}=d(),p,m;t[0]===n?(p=t[1],m=t[2]):(p=[`page-headings`,n],m=()=>nn(n),t[0]=n,t[1]=p,t[2]=m);let h;t[3]!==n||t[4]!==c||t[5]!==s?(h=!c&&(s.has(n)||L(n)),t[3]=n,t[4]=c,t[5]=s,t[6]=h):h=t[6];let b;t[7]!==p||t[8]!==m||t[9]!==h?(b={queryKey:p,queryFn:m,enabled:h,staleTime:1/0},t[7]=p,t[8]=m,t[9]=h,t[10]=b):b=t[10];let{data:S,isLoading:C,error:w}=y(b),T;t[11]===S?T=t[12]:(T=S===void 0?[]:S,t[11]=S,t[12]=T);let E=T,D,O;t[13]!==f||t[14]!==u||t[15]!==n||t[16]!==l?(D=()=>{if(!u||f!==n)return;let e=u.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,l.invalidateQueries({queryKey:[`page-headings`,n]})},tn)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},O=[u,f,n,l],t[13]=f,t[14]=u,t[15]=n,t[16]=l,t[17]=D,t[18]=O):(D=t[17],O=t[18]),(0,Z.useEffect)(D,O);let k;t[19]===E?k=t[20]:(k=E.map(un),t[19]=E,t[20]=k);let A=k,j;t[21]!==n||t[22]!==r?(j={isSourceMode:r,docName:n},t[21]=n,t[22]=r,t[23]=j):j=t[23];let M=$t(A,j),N;t[24]!==M||t[25]!==E?(N=M?E.findIndex(e=>e.slug===M):-1,t[24]=M,t[25]=E,t[26]=N):N=t[26];let P=N,F;t[27]!==n||t[28]!==r?(F=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&pt(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(sn,{detail:i}))},t[27]=n,t[28]=r,t[29]=F):F=t[29];let I=F,R=((P>=0?E[P].level:1)-1)*an+(an-on)/2,z=P*rn+(rn-on)/2,B;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(xe,{children:(0,$.jsx)(g,{id:`dD7NPy`})}),t[30]=B):B=t[30];let V;t[31]!==E.length||t[32]!==C?(V=!C&&(0,$.jsx)(we,{children:E.length}),t[31]=E.length,t[32]=C,t[33]=V):V=t[33];let H;t[34]===V?H=t[35]:(H=(0,$.jsxs)(Te,{children:[B,V]}),t[34]=V,t[35]=H);let U;t[36]!==o||t[37]!==P||t[38]!==M||t[39]!==w||t[40]!==I||t[41]!==E||t[42]!==C||t[43]!==R||t[44]!==z?(U=w?(0,$.jsx)(be,{className:`px-2`,children:w instanceof Error?w.message:o({id:`GuqOb1`})}):E.length===0&&!C?(0,$.jsx)(Se,{className:`px-2`,children:(0,$.jsx)(g,{id:`0BB9ID`})}):(0,$.jsxs)(`nav`,{"aria-label":o({id:`BymzO4`}),className:`relative`,children:[P>=0&&(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:on,height:on,transform:`translate(${R}px, ${z}px)`}}),E.map((e,t)=>{let n=e.slug===M;return(0,$.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>I(t,e.slug),className:x(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*an+20}px`},title:e.text,children:e.text},t)})]}),t[36]=o,t[37]=P,t[38]=M,t[39]=w,t[40]=I,t[41]=E,t[42]=C,t[43]=R,t[44]=z,t[45]=U):U=t[45];let W;t[46]!==C||t[47]!==U?(W=(0,$.jsx)(Ce,{className:`px-3 py-2`,"aria-busy":C,children:U}),t[46]=C,t[47]=U,t[48]=W):W=t[48];let G;return t[49]!==a||t[50]!==H||t[51]!==W?(G=(0,$.jsxs)(Ee,{className:a,children:[H,W]}),t[49]=a,t[50]=H,t[51]=W,t[52]=G):G=t[52],G}function un(e){return e.slug}function dn(e){return Math.min(50,Math.max(1,Math.ceil(e/10)))}function fn(e,t){return e===t||e%dn(t)===0}var pn=[250,500,1e3,2e3,4e3];function mn(e){return e.status===503&&e.problemType===`urn:ok:error:too-many-agent-sessions`}async function hn(e,t){let n=await t.fixItem(e);for(let r of pn){if(n.ok||!mn(n)||!t.shouldContinue()||(console.debug(`[sweep] capacity refusal, backing off %dms`,r),await t.sleep(r),!t.shouldContinue()))break;n=await t.fixItem(e)}return n}async function gn(e){let t=e.items.length,n=[];for(let[r,i]of e.items.entries()){if(r>0&&(await e.sleep(15),!e.shouldContinue()))return{failures:n,cancelled:!0};let a=await hn(i,e);if(a.ok||n.push({item:i,detail:a.errorDetail}),!e.shouldContinue())return{failures:n,cancelled:!0};let o=r+1;fn(o,t)&&e.onProgress(o,t)}return{failures:n,cancelled:!1}}function _n(e){return new Promise(t=>setTimeout(t,e))}var vn=`audit-superseded`;async function yn(e={kind:`project`}){return xn(e,H,!1)}async function bn(e={kind:`project`},t){return xn(e,F,!0,t)}async function xn(e,t,n,r){try{let i=new URLSearchParams;e.kind===`path`?i.set(`path`,e.path):e.kind===`doc`&&i.set(`doc`,e.docName),n&&i.set(`counts`,`1`);let a=i.size===0?``:`?${i}`,o=await fetch(`/api/audit${a}`,r===void 0?void 0:{signal:r});if(!o.ok)return o.status===409?vn:(console.warn(`[audit] request failed`,o.status,o.statusText),null);let s;try{s=await o.json()}catch{return r?.aborted===!0||console.warn(`[audit] response body is not valid JSON`),null}let c=t.safeParse(s);return c.success?c.data:(console.warn(`[audit] response failed schema validation`,c.error.issues),null)}catch(e){return r?.aborted===!0||console.warn(`[audit] fetch threw`,e),null}}function Sn(e){let t=(0,Q.c)(4),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let[r,i]=(0,Z.useState)(n),a,o;return t[1]===e?(a=t[2],o=t[3]):(a=()=>{if(i(Tn),e===null)return;let t=!1,n=()=>{yn({kind:`doc`,docName:e}).then(e=>{if(t||e===null||e===`audit-superseded`)return;let n=e.files.flatMap(wn).filter(Cn);i(e=>e.length===0&&n.length===0?e:n)})};n();let r=le(e=>{e.includes(`backlinks`)&&n()});return()=>{t=!0,r()}},o=[e],t[1]=e,t[2]=a,t[3]=o),(0,Z.useEffect)(a,o),r}function Cn(e){return e.source===`links`}function wn(e){return e.diagnostics}function Tn(e){return e.length===0?e:[]}var En={errorCount:0,warningCount:0},Dn=new Map,On=new Set,kn=new Map;function An(){let e=new Map;for(let[t,n]of Dn){let r=n.lint.errorCount+n.links.errorCount,i=n.lint.warningCount+n.links.warningCount;r===0&&i===0||e.set(t,{errorCount:r,warningCount:i})}kn=e;for(let e of On)e()}var jn=z;function Mn(e){return On.add(e),()=>{On.delete(e)}}function Nn(){return kn}function Pn(e){Dn.clear();for(let t of e)Dn.set(se(t.file),jn(t.diagnostics));An()}function Fn(e){Dn.clear();for(let t of e)Dn.set(se(t.file),{lint:t.lint,links:t.links});An()}function In(e,t){Dn.set(e,jn(t)),An()}function Ln(e,t,n){let r=Dn.get(e)??{lint:En,links:En},i=r[t];i.errorCount===n.errorCount&&i.warningCount===n.warningCount||(Dn.set(e,{...r,[t]:n}),An())}var Rn=`open-knowledge:lint-nav`;function zn(e,t){return e.range.start.line-t.range.start.line||e.range.start.character-t.range.start.character}function Bn(e){return{line:e.range.start.line+1,column:e.range.start.character+1}}function Vn(e){let t=(0,Q.c)(35),{diagnostic:n,instanceCount:r}=e,{_:i}=_(),a=n.severity===`error`?K:J,s=n.range.start.line+1,c=n.source===`links`,l=r!==void 0&&r>1,u=n.severity===`error`?`text-destructive`:`text-amber-500`,d;t[0]===u?d=t[1]:(d=x(`mt-0.5 size-3.5 shrink-0`,u),t[0]=u,t[1]=d);let f;t[2]!==a||t[3]!==d?(f=(0,$.jsx)(a,{"aria-hidden":`true`,className:d}),t[2]=a,t[3]=d,t[4]=f):f=t[4];let p;t[5]===n.message?p=t[6]:(p=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:n.message}),t[5]=n.message,t[6]=p);let m;t[7]!==l||t[8]!==r?(m=l?(0,$.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(X,{variant:`gray`,"data-testid":`problems-instance-count`,className:`h-4 px-1 font-sans text-[10px] leading-none`,children:(0,$.jsx)(g,{id:`iZCZmF`,values:{instanceCount:r}})}),(0,$.jsx)(te,{"aria-hidden":`true`,className:`size-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none`})]}):null,t[7]=l,t[8]=r,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==p||t[12]!==m?(h=(0,$.jsxs)(`span`,{className:`flex items-start gap-1.5 text-sm`,children:[f,p,m]}),t[10]=f,t[11]=p,t[12]=m,t[13]=h):h=t[13];let v=c&&`gap-0.5`,y;t[14]===v?y=t[15]:(y=x(`h-4 shrink-0 px-1 font-sans text-[10px] uppercase leading-none`,v),t[14]=v,t[15]=y);let b;t[16]===c?b=t[17]:(b=c?(0,$.jsx)(o,{"aria-hidden":`true`,className:`size-2.5`}):null,t[16]=c,t[17]=b);let S;t[18]!==n.source||t[19]!==y||t[20]!==b?(S=(0,$.jsxs)(X,{variant:`gray`,"data-testid":`problems-source-tag`,className:y,children:[b,n.source]}),t[18]=n.source,t[19]=y,t[20]=b,t[21]=S):S=t[21];let C;t[22]!==i||t[23]!==n.code||t[24]!==s||t[25]!==l?(C=l?n.code:`${n.code} · ${i({id:`enPTnx`,values:{displayLine:s}})}`,t[22]=i,t[23]=n.code,t[24]=s,t[25]=l,t[26]=C):C=t[26];let w;t[27]===C?w=t[28]:(w=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:C}),t[27]=C,t[28]=w);let T;t[29]!==S||t[30]!==w?(T=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 ps-5 font-mono text-xs text-muted-foreground`,children:[S,w]}),t[29]=S,t[30]=w,t[31]=T):T=t[31];let E;return t[32]!==T||t[33]!==h?(E=(0,$.jsxs)($.Fragment,{children:[h,T]}),t[32]=T,t[33]=h,t[34]=E):E=t[34],E}function Hn(e){let t=new Map;for(let n of e){let e=`${n.source}/${n.code}\u0000${n.linkTarget??``}\u0000${n.message}`,r=t.get(e);r===void 0?t.set(e,{key:e,instances:[n]}):r.instances.push(n)}return[...t.values()]}function Un(e){let t=(0,Q.c)(43),{group:n,onNavigate:r,navTitle:i,renderActions:a}=e,{_:o}=_(),s=n.instances[0];if(n.instances.length===1){let e;t[0]!==s||t[1]!==a?(e=a(s),t[0]=s,t[1]=a,t[2]=e):e=t[2];let n=e,o;t[3]!==s||t[4]!==r?(o=()=>r(s),t[3]=s,t[4]=r,t[5]=o):o=t[5];let c;t[6]!==s||t[7]!==i?(c=i(s),t[6]=s,t[7]=i,t[8]=c):c=t[8];let l;t[9]===s?l=t[10]:(l=(0,$.jsx)(Vn,{diagnostic:s}),t[9]=s,t[10]=l);let u;t[11]!==o||t[12]!==c||t[13]!==l?(u=(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left`,title:c,children:l}),t[11]=o,t[12]=c,t[13]=l,t[14]=u):u=t[14];let d;t[15]===n?d=t[16]:(d=n===null?null:(0,$.jsx)(`div`,{className:`absolute bottom-1 right-1 flex items-center gap-1 rounded bg-muted opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none`,children:n}),t[15]=n,t[16]=d);let f;return t[17]!==u||t[18]!==d?(f=(0,$.jsxs)(`li`,{className:`group relative rounded transition-colors hover:bg-muted`,children:[u,d]}),t[17]=u,t[18]=d,t[19]=f):f=t[19],f}let c;t[20]!==s||t[21]!==n.instances.length?(c=(0,$.jsx)(D,{className:`group flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,children:(0,$.jsx)(Vn,{diagnostic:s,instanceCount:n.instances.length})}),t[20]=s,t[21]=n.instances.length,t[22]=c):c=t[22];let l;t[23]!==o||t[24]!==s.message?(l=o({id:`EUiJEM`,values:{0:s.message}}),t[23]=o,t[24]=s.message,t[25]=l):l=t[25];let u;if(t[26]!==o||t[27]!==n.instances||t[28]!==i||t[29]!==r||t[30]!==a){let e;t[32]!==o||t[33]!==i||t[34]!==r||t[35]!==a?(e=e=>{let t=a(e),n=e.range.start.line+1;return(0,$.jsxs)(`li`,{className:`group relative rounded transition-colors hover:bg-muted`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`flex w-full cursor-pointer rounded px-2 py-1 text-left font-mono text-xs text-muted-foreground`,title:i(e),"aria-label":o({id:`uCe4AX`,values:{0:e.message,displayLine:n}}),children:o({id:`enPTnx`,values:{displayLine:n}})}),t===null?null:(0,$.jsx)(`div`,{className:`absolute bottom-0.5 right-1 flex items-center gap-1 rounded bg-muted opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none`,children:t})]},Wn(e))},t[32]=o,t[33]=i,t[34]=r,t[35]=a,t[36]=e):e=t[36],u=n.instances.map(e),t[26]=o,t[27]=n.instances,t[28]=i,t[29]=r,t[30]=a,t[31]=u}else u=t[31];let d;t[37]!==l||t[38]!==u?(d=(0,$.jsx)(E,{className:`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in] motion-reduce:animate-none`,children:(0,$.jsx)(`ul`,{"aria-label":l,className:`flex flex-col gap-0.5 pb-1 ps-5`,"data-testid":`problems-duplicate-instances`,children:u})}),t[37]=l,t[38]=u,t[39]=d):d=t[39];let f;return t[40]!==c||t[41]!==d?(f=(0,$.jsx)(`li`,{className:`rounded`,"data-testid":`problems-duplicate-group`,children:(0,$.jsxs)(O,{children:[c,d]})}),t[40]=c,t[41]=d,t[42]=f):f=t[42],f}function Wn(e){return`${e.source}/${e.code}-${e.range.start.line}-${e.range.start.character}-${e.message}`}function Gn(e){return e.reduce((e,t)=>e+ +((t.fixes?.length??0)>0),0)}function Kn(e){let t=(0,Q.c)(11),{target:n,creating:r,disabled:i,onCreate:a}=e,{_:o}=_(),s;t[0]!==o||t[1]!==n?(s=o({id:`oWsZk8`,values:{target:n}}),t[0]=o,t[1]=n,t[2]=s):s=t[2];let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(M,{"aria-hidden":`true`,className:`size-3`}),t[3]=c):c=t[3];let l;t[4]===r?l=t[5]:(l=r?(0,$.jsx)(g,{id:`E9bKSA`}):(0,$.jsx)(g,{id:`XRuL0i`}),t[4]=r,t[5]=l);let u;return t[6]!==i||t[7]!==a||t[8]!==s||t[9]!==l?(u=(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:i,onClick:a,"aria-label":s,"data-testid":`problems-create-page`,children:[c,l]}),t[6]=i,t[7]=a,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function qn(e){let t=(0,Q.c)(8),{tip:n,testId:r,children:i}=e,a;t[0]===i?a=t[1]:(a=(0,$.jsx)(C,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0`,children:i})}),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==n?(o=(0,$.jsx)(w,{"data-testid":r,children:n}),t[2]=r,t[3]=n,t[4]=o):o=t[4];let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(T,{children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Jn(e){let t=(0,Q.c)(21),{count:n,problemCount:r,aiAvailable:i,disabled:a,onClick:o,children:s}=e,{_:c}=_(),l;t[0]!==i||t[1]!==n||t[2]!==r?(l=n>0?(0,$.jsx)(g,{id:`vjwsDi`,values:{count:n}}):r===0?(0,$.jsx)(g,{id:`gAhHu7`}):i?(0,$.jsx)(g,{id:`zA9zRL`}):(0,$.jsx)(g,{id:`X3MMeA`}),t[0]=i,t[1]=n,t[2]=r,t[3]=l):l=t[3];let u;t[4]!==c||t[5]!==s||t[6]!==n||t[7]!==r?(u=s===void 0?r===0?c({id:`4m-xuX`}):n===0?c({id:`SqIoy_`}):void 0:void 0,t[4]=c,t[5]=s,t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(ie,{"aria-hidden":`true`,className:`size-3`}),t[9]=d):d=t[9];let f;t[10]!==s||t[11]!==n?(f=s??(0,$.jsx)(g,{id:`RZXTlY`,values:{count:n}}),t[10]=s,t[11]=n,t[12]=f):f=t[12];let p;t[13]!==a||t[14]!==o||t[15]!==u||t[16]!==f?(p=(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:a,onClick:o,"aria-label":u,"data-testid":`problems-auto-fix`,children:[d,f]}),t[13]=a,t[14]=o,t[15]=u,t[16]=f,t[17]=p):p=t[17];let m;return t[18]!==l||t[19]!==p?(m=(0,$.jsx)(qn,{testId:`problems-auto-fix-tip`,tip:l,children:p}),t[18]=l,t[19]=p,t[20]=m):m=t[20],m}function Yn(e){let t=(0,Q.c)(12),{count:n,disabled:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(g,{id:`mgDKWS`,values:{count:n}}),t[0]=n,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(l,{"aria-hidden":`true`,className:`size-3`}),t[2]=o):o=t[2];let s;t[3]===n?s=t[4]:(s=(0,$.jsx)(g,{id:`gyHDWC`,values:{count:n}}),t[3]=n,t[4]=s);let c;t[5]!==r||t[6]!==i||t[7]!==s?(c=(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:r,onClick:i,"data-testid":`problems-fix-with-ai`,children:[o,s]}),t[5]=r,t[6]=i,t[7]=s,t[8]=c):c=t[8];let u;return t[9]!==a||t[10]!==c?(u=(0,$.jsx)(qn,{testId:`problems-fix-with-ai-tip`,tip:a,children:c}),t[9]=a,t[10]=c,t[11]=u):u=t[11],u}function Xn(e){let t=(0,Q.c)(19),{docName:n,diagnostics:r,onFix:i,onAutoFix:a,onAskAi:o,onFixWithAi:s}=e,{_:c}=_(),[u,d]=(0,Z.useState)(`doc`),{data:f}=je(),m=f===null?null:f.effective.enabled?De.filter(e=>f.effective.plugins[e.id].enabled):[],h=m!==null&&m.length===0,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v={status:`idle`},t[0]=v):v=t[0];let[y,b]=(0,Z.useState)(v),[x,E]=(0,Z.useState)(null),D=ne(),[O,k]=(0,Z.useState)(null),A=(0,Z.useRef)(!0),j=(0,Z.useRef)(!1),M,N;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>(A.current=!0,()=>{A.current=!1}),N=[],t[1]=M,t[2]=N):(M=t[1],N=t[2]),(0,Z.useEffect)(M,N);let P=(0,Z.useRef)(ir),F;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(F={status:`idle`},t[3]=F):F=t[3];let I=(0,Z.useRef)(F),L;t[4]===y?L=t[5]:(L=()=>{y.status!==`loading`&&(I.current=y)},t[4]=y,t[5]=L),(0,Z.useEffect)(L);let R=(0,Z.useRef)(0),z=[...r].sort(zn),B=Gn(z),V=async function(e){let t=e.linkTarget;if(!(t===void 0||O!==null||D===null)){k(t);try{await p({initialDir:``,suggestedName:t},{addPage:D.addPage})}catch(e){let t=e;Y.error(t instanceof Error?t.message:c({id:`tfi40B`})),A.current&&k(null);return}Y.success(c({id:`EWCJFu`,values:{target:t}})),A.current&&k(null),A.current&&y.status===`loaded`&&await H()}};async function H(){R.current+=1;let e=R.current,t=I.current;b({status:`loading`});let n=await yn();if(n===`audit-superseded`){R.current===e&&A.current&&b(t.status===`idle`?{status:`failed`}:t);return}n!==null&&Pn(n.files),A.current&&b(n===null?{status:`failed`}:{status:`loaded`,result:n})}let U=y.status===`loaded`?y.result.files.filter(nr):[],W;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(W=function(){j.current=!0},t[6]=W):W=t[6];let G=W,ee=async function(){if(x!==null||U.length===0)return;let e=U.length;j.current=!1,E({done:0,total:e});let{failures:t,cancelled:n}=await gn({items:U,fixItem:tr,sleep:_n,onProgress:e=>E(t=>t===null?t:{...t,done:e}),shouldContinue:()=>A.current&&!j.current});if(!(n&&!A.current)){if(E(null),t.length>0&&(console.warn(`[lint] fix-all: ${t.length} of ${U.length} files failed`,t.map(er)),!n)){let e=t[0];Y.error(c({id:`fru3T7`,values:{0:t.length,1:U.length}}),{description:e===void 0?void 0:`${e.item.file}${e.detail===null?``:` — ${e.detail}`}`})}n&&Y.info(c({id:`H1TmTu`}));try{await H()}catch{A.current&&b({status:`failed`})}}},te=function(e){d(e),e===`project`&&y.status===`idle`&&H()};(0,Z.useEffect)(()=>{P.current=()=>{y.status===`idle`||y.status===`failed`||H()}});let K;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(K=[],t[7]=K):K=t[7],(0,Z.useEffect)(()=>Ae(()=>P.current()),K);let q;t[8]===n?q=t[9]:(q=function(e){let t=Bn(e);pt(n,{kind:`lint`,detail:t}),window.dispatchEvent(new CustomEvent(Rn,{detail:t}))},t[8]=n,t[9]=q);let re=q,J;t[10]!==n||t[11]!==re?(J=function(e,t){let r=se(e);if(r===n){re(t);return}pt(r,{kind:`lint`,detail:Bn(t)}),window.location.hash=oe(r)},t[10]=n,t[11]=re,t[12]=J):J=t[12];let ae=J,le=function(e){let t=i!==void 0&&(e.fixes?.length??0)>0,n=e.linkTarget!==void 0&&D!==null;if(!t&&!n&&o===void 0)return null;let r=`${e.source}/${e.code}`;return(0,$.jsxs)($.Fragment,{children:[n?(0,$.jsx)(Kn,{target:e.linkTarget??``,creating:O===e.linkTarget,disabled:O!==null,onCreate:()=>void V(e)}):null,t?(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>i?.(e),"aria-label":c({id:`fZj9em`,values:{flatId:r}}),"data-testid":`problems-fix`,children:[(0,$.jsx)(ie,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(g,{id:`c4fVUV`})]}):null,o===void 0?null:(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>o(e),"aria-label":c({id:`hh4mVC`,values:{flatId:r}}),"data-testid":`problems-ask-ai`,children:[(0,$.jsx)(l,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(g,{id:`xWEvuo`})]})]})},ue;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(xe,{children:(0,$.jsx)(g,{id:`OXdGnd`})}),t[13]=ue):ue=t[13];let de=m!==null&&m.length>0&&(0,$.jsxs)(T,{children:[(0,$.jsx)(C,{className:`shrink-0 cursor-default rounded-md bg-muted-foreground/5 px-2 py-1 font-mono text-xs text-muted-foreground`,"data-testid":`problems-active-plugins`,children:(0,$.jsx)(g,{id:`yxF19Y`,values:{0:m.length}})}),(0,$.jsx)(w,{"data-testid":`problems-active-plugins-tooltip`,children:(0,$.jsx)(g,{id:`ws5o1F`,values:{0:m.map($n).join(`, `)}})})]}),X;t[14]===de?X=t[15]:(X=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[ue,de]}),t[14]=de,t[15]=X);let fe=u===`doc`&&z.length>0&&(0,$.jsx)(we,{children:z.length}),pe;return t[16]!==X||t[17]!==fe?(pe=(0,$.jsxs)(Te,{children:[X,fe]}),t[16]=X,t[17]=fe,t[18]=pe):pe=t[18],(0,$.jsxs)(Ee,{children:[pe,(0,$.jsx)(Wt,{scope:u,onScopeChange:te}),u===`doc`?(0,$.jsx)(Ce,{className:`px-2 py-2`,children:z.length===0?h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Se,{className:`px-2`,"data-testid":`problems-no-plugins`,children:(0,$.jsx)(g,{id:`Hngy37`})}),(0,$.jsx)(`div`,{className:`px-2 pt-2`,children:(0,$.jsx)(S,{variant:`outline`,size:`sm`,onClick:ce,"data-testid":`problems-enable-plugins`,children:(0,$.jsx)(g,{id:`rnX-1S`})})})]}):(0,$.jsx)(Se,{className:`px-2`,children:(0,$.jsx)(g,{id:`ZI8uvA`})}):(0,$.jsxs)($.Fragment,{children:[a!==void 0||s!==void 0?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1 px-2 pb-1`,children:[a!==void 0&&(0,$.jsx)(Jn,{count:B,problemCount:z.length,aiAvailable:s!==void 0,disabled:B===0,onClick:a}),s!==void 0&&(0,$.jsx)(Yn,{count:z.length,disabled:!1,onClick:()=>s(`doc`)})]}):null,(0,$.jsx)(`ul`,{"aria-label":c({id:`OXdGnd`}),className:`flex flex-col gap-0.5`,children:Hn(z).map(e=>(0,$.jsx)(Un,{group:e,onNavigate:re,navTitle:e=>c({id:`vbMHjo`,values:{0:e.range.start.line+1}}),renderActions:le},e.key))})]})}):(0,$.jsx)(ar,{audit:y,onRefresh:()=>void H(),onNavigate:ae,fixableCount:U.reduce(Qn,0),problemCount:y.status===`loaded`?y.result.files.reduce(Zn,0):0,fixing:x,onAutoFix:()=>void ee(),onCancelFix:G,onFixWithAi:s===void 0||y.status!==`loaded`?void 0:()=>s(`project`),onCreateTarget:D===null?void 0:e=>void V(e),creatingTarget:O})]})}function Zn(e,t){return e+t.diagnostics.length}function Qn(e,t){return e+Gn(t.diagnostics)}function $n(e){return e.label}function er(e){return{file:e.item.file,detail:e.detail}}function tr(e){return ke(se(e.file))}function nr(e){return e.diagnostics.some(rr)}function rr(e){return(e.fixes?.length??0)>0}function ir(){}function ar(e){let t=(0,Q.c)(81),{audit:n,onRefresh:r,onNavigate:i,fixableCount:a,problemCount:o,fixing:s,onAutoFix:c,onCancelFix:l,onFixWithAi:u,onCreateTarget:d,creatingTarget:f}=e,{_:p}=_(),m=n.status===`loading`||n.status===`idle`,h;t[0]!==n.result||t[1]!==n.status?(h=n.status===`loaded`?n.result.files:[],t[0]=n.result,t[1]=n.status,t[2]=h):h=t[2];let v=h,[y,b]=(0,Z.useState)(cr),x;t[3]!==y||t[4]!==v?(x=v.length>0&&v.every(e=>y.has(e.file)),t[3]=y,t[4]=v,t[5]=x):x=t[5];let E=x,D;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(D=function(e,t){b(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},t[6]=D):D=t[6];let O=D,k;t[7]!==E||t[8]!==v?(k=function(){b(E?new Set:new Set(v.map(sr)))},t[7]=E,t[8]=v,t[9]=k):k=t[9];let A=k,j;t[10]!==n.result||t[11]!==n.status?(j=n.status===`loaded`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{id:`DsDwR-`,values:{0:n.result.errorCount}}),` · `,(0,$.jsx)(g,{id:`W1SI2K`,values:{0:n.result.warningCount}})]}),t[10]=n.result,t[11]=n.status,t[12]=j):j=t[12];let M;t[13]===j?M=t[14]:(M=(0,$.jsx)(`p`,{className:`min-w-0 truncate text-xs text-muted-foreground`,"data-testid":`problems-audit-summary`,children:j}),t[13]=j,t[14]=M);let N;t[15]!==p||t[16]!==E||t[17]!==v.length||t[18]!==A?(N=v.length>0?(0,$.jsxs)(T,{children:[(0,$.jsx)(C,{asChild:!0,children:(0,$.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":p(E?{id:`I4LGsH`}:{id:`Ugvy4O`}),"data-testid":`problems-audit-expand-toggle`,onClick:A,children:E?(0,$.jsx)(Me,{"aria-hidden":`true`,className:`size-3.5`}):(0,$.jsx)(Ne,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,$.jsx)(w,{"data-testid":`problems-audit-expand-toggle-tooltip`,children:E?(0,$.jsx)(g,{id:`I4LGsH`}):(0,$.jsx)(g,{id:`Ugvy4O`})})]}):null,t[15]=p,t[16]=E,t[17]=v.length,t[18]=A,t[19]=N):N=t[19];let P;t[20]===p?P=t[21]:(P=p({id:`I7y_vn`}),t[20]=p,t[21]=P);let F=m||s!==null,I;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(re,{"aria-hidden":`true`,className:`size-3.5`}),t[22]=I):I=t[22];let L;t[23]!==r||t[24]!==P||t[25]!==F?(L=(0,$.jsx)(C,{asChild:!0,children:(0,$.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":P,"data-testid":`problems-audit-refresh`,disabled:F,onClick:r,children:I})}),t[23]=r,t[24]=P,t[25]=F,t[26]=L):L=t[26];let R;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(w,{"data-testid":`problems-audit-refresh-tooltip`,children:(0,$.jsx)(g,{id:`I7y_vn`})}),t[27]=R):R=t[27];let z;t[28]===L?z=t[29]:(z=(0,$.jsxs)(T,{children:[L,R]}),t[28]=L,t[29]=z);let B;t[30]!==z||t[31]!==N?(B=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[N,z]}),t[30]=z,t[31]=N,t[32]=B):B=t[32];let V;t[33]!==B||t[34]!==M?(V=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[M,B]}),t[33]=B,t[34]=M,t[35]=V):V=t[35];let H;t[36]!==p||t[37]!==s?(H=s===null?null:(0,$.jsx)(`span`,{className:`sr-only`,role:`status`,children:p({id:`gZElfU`,values:{0:s.done,1:s.total}})}),t[36]=p,t[37]=s,t[38]=H):H=t[38];let U;t[39]!==p||t[40]!==s||t[41]!==l?(U=s===null?null:(0,$.jsxs)(T,{children:[(0,$.jsx)(C,{asChild:!0,children:(0,$.jsx)(S,{variant:`ghost`,size:`sm`,className:`h-6 shrink-0 px-2 text-muted-foreground`,"aria-label":p({id:`q2cLM6`}),"data-testid":`problems-cancel-fix`,onClick:l,children:(0,$.jsx)(g,{id:`ygCKqB`})})}),(0,$.jsx)(w,{"data-testid":`problems-cancel-fix-tooltip`,children:(0,$.jsx)(g,{id:`yvSAuM`})})]}),t[39]=p,t[40]=s,t[41]=l,t[42]=U):U=t[42];let W=u!==void 0,G=m||s!==null||a===0,ee;t[43]===s?ee=t[44]:(ee=s===null?void 0:(0,$.jsx)(g,{id:`S9t1PI`,values:{0:s.done,1:s.total}}),t[43]=s,t[44]=ee);let te;t[45]!==a||t[46]!==c||t[47]!==o||t[48]!==W||t[49]!==G||t[50]!==ee?(te=(0,$.jsx)(Jn,{count:a,problemCount:o,aiAvailable:W,disabled:G,onClick:c,children:ee}),t[45]=a,t[46]=c,t[47]=o,t[48]=W,t[49]=G,t[50]=ee,t[51]=te):te=t[51];let K;t[52]!==s||t[53]!==u||t[54]!==o?(K=u!==void 0&&o>0?(0,$.jsx)(Yn,{count:o,disabled:s!==null,onClick:u}):null,t[52]=s,t[53]=u,t[54]=o,t[55]=K):K=t[55];let q;t[56]!==H||t[57]!==U||t[58]!==te||t[59]!==K?(q=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[H,U,te,K]}),t[56]=H,t[57]=U,t[58]=te,t[59]=K,t[60]=q):q=t[60];let ne;t[61]!==V||t[62]!==q?(ne=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-2 pb-1`,children:[V,q]}),t[61]=V,t[62]=q,t[63]=ne):ne=t[63];let J;t[64]!==p||t[65]!==m?(J=m&&(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,role:`status`,"aria-busy":`true`,"aria-label":p({id:`dx-TwN`}),children:[1,2,3].map(or)}),t[64]=p,t[65]=m,t[66]=J):J=t[66];let ie;t[67]===n.status?ie=t[68]:(ie=n.status===`failed`&&(0,$.jsx)(be,{className:`px-2 text-xs`,children:(0,$.jsx)(g,{id:`IFezUv`})}),t[67]=n.status,t[68]=ie);let Y;t[69]!==n.result||t[70]!==n.status||t[71]!==f||t[72]!==y||t[73]!==d||t[74]!==i?(Y=n.status===`loaded`&&(0,$.jsx)(lr,{result:n.result,onNavigate:i,onCreateTarget:d,creatingTarget:f,expandedFiles:y,onToggleFile:O}),t[69]=n.result,t[70]=n.status,t[71]=f,t[72]=y,t[73]=d,t[74]=i,t[75]=Y):Y=t[75];let ae;return t[76]!==ne||t[77]!==J||t[78]!==ie||t[79]!==Y?(ae=(0,$.jsxs)(Ce,{className:`px-2 py-2`,"data-testid":`problems-project-scope`,children:[ne,J,ie,Y]}),t[76]=ne,t[77]=J,t[78]=ie,t[79]=Y,t[80]=ae):ae=t[80],ae}function or(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2 py-1.5`,children:[(0,$.jsx)(Oe,{className:`mt-0.5 size-3.5 shrink-0 rounded`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(Oe,{className:`h-3 w-28`}),(0,$.jsx)(Oe,{className:`h-3 w-40`})]})]},e)}function sr(e){return e.file}function cr(){return new Set}function lr(e){let t=(0,Q.c)(14),{result:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,expandedFiles:o,onToggleFile:s}=e,{_:c}=_(),l;t[0]!==c||t[1]!==n.warnings?(l=n.warnings.length>0&&(0,$.jsx)(`ul`,{"aria-label":c({id:`Rsdhj9`}),className:`flex flex-col gap-0.5 pb-1`,children:n.warnings.map(ur)}),t[0]=c,t[1]=n.warnings,t[2]=l):l=t[2];let u;t[3]!==a||t[4]!==o||t[5]!==i||t[6]!==r||t[7]!==s||t[8]!==n.fileCount||t[9]!==n.files?(u=n.files.length===0?(0,$.jsx)(Se,{className:`px-2`,children:(0,$.jsx)(g,{id:`k_Dqw1`,values:{0:n.fileCount}})}):n.files.map(e=>(0,$.jsx)(dr,{file:e,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o.has(e.file),onOpenChange:t=>s(e.file,t)},e.file)),t[3]=a,t[4]=o,t[5]=i,t[6]=r,t[7]=s,t[8]=n.fileCount,t[9]=n.files,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function ur(e,t){return(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 px-2 text-xs`,children:[(0,$.jsx)(J,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-amber-500`}),(0,$.jsx)(`span`,{className:`min-w-0 text-foreground`,children:e})]},`${t}-${e}`)}function dr(e){let t=(0,Q.c)(45),{file:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o,onOpenChange:s}=e,{_:c}=_(),l,u,d,f,p,m,h,g,v,y;if(t[0]!==c||t[1]!==a||t[2]!==n.diagnostics||t[3]!==n.file||t[4]!==i||t[5]!==r||t[6]!==s||t[7]!==o){let e=[...n.diagnostics].sort(zn);u=O,h=o,g=s,v=`problems-audit-group`;let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(te,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none`}),t[18]=_):_=t[18];let b;t[19]===n.file?b=t[20]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,title:n.file,children:n.file}),t[19]=n.file,t[20]=b),y=(0,$.jsxs)(D,{className:`group flex w-full cursor-pointer items-center gap-1.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,children:[_,b,(0,$.jsx)(X,{variant:`gray`,"data-testid":`problems-audit-file-count`,className:`shrink-0`,children:e.length})]}),l=E,m=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in] motion-reduce:animate-none`,t[21]!==c||t[22]!==n.file?(d=c({id:`zAJzIg`,values:{0:n.file}}),t[21]=c,t[22]=n.file,t[23]=d):d=t[23],f=`flex flex-col gap-0.5 pb-1 ps-3`;let x;t[24]!==c||t[25]!==a||t[26]!==n.file||t[27]!==i||t[28]!==r?(x=e=>(0,$.jsx)(Un,{group:e,onNavigate:e=>r(n.file,e),navTitle:e=>c({id:`xKDsGS`,values:{0:e.range.start.line+1,1:n.file}}),renderActions:e=>e.linkTarget===void 0||i===void 0?null:(0,$.jsx)(Kn,{target:e.linkTarget,creating:a===e.linkTarget,disabled:a!==null,onCreate:()=>i(e)})},e.key),t[24]=c,t[25]=a,t[26]=n.file,t[27]=i,t[28]=r,t[29]=x):x=t[29],p=Hn(e).map(x),t[0]=c,t[1]=a,t[2]=n.diagnostics,t[3]=n.file,t[4]=i,t[5]=r,t[6]=s,t[7]=o,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=v,t[17]=y}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],v=t[16],y=t[17];let b;t[30]!==d||t[31]!==f||t[32]!==p?(b=(0,$.jsx)(`ul`,{"aria-label":d,className:f,children:p}),t[30]=d,t[31]=f,t[32]=p,t[33]=b):b=t[33];let x;t[34]!==l||t[35]!==m||t[36]!==b?(x=(0,$.jsx)(l,{className:m,children:b}),t[34]=l,t[35]=m,t[36]=b,t[37]=x):x=t[37];let S;return t[38]!==u||t[39]!==x||t[40]!==h||t[41]!==g||t[42]!==v||t[43]!==y?(S=(0,$.jsxs)(u,{open:h,onOpenChange:g,"data-testid":v,children:[y,x]}),t[38]=u,t[39]=x,t[40]=h,t[41]=g,t[42]=v,t[43]=y,t[44]=S):S=t[44],S}var fr={words:0,chars:0,tokens:0},pr=/[ -〿぀-ゟ゠-ヿ㐀-䶿一-鿿豈-﫿＀-￯฀-๿ក-៿]/,mr=/[\p{L}\p{N}]/u,hr=new Set([`text`,`inlineCode`,`code`,`tag`]),gr=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),_r=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function vr(e,t){if(!e)return;let n=e.type;if(!gr.has(n)){if(hr.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
3
+ `&&t.push(n+1);return t}function Ye(e,t,n){return t<=1?0:t-1>=e.length?n:e[t-1]??n}function Xe(e,t){let n=0,r=e.length-1,i=1;for(;n<=r;){let a=n+r>>1;(e[a]??0)<=t?(i=a+1,n=a+1):r=a-1}return i}function Ze(e,t,n){return Math.max(t,Math.min(e,n))}function Qe(e,t){let n=e=>e.replace(/\s+/g,` `).trim();return n(e)===n(t)}function $e(e,t){return t.inRange?t.tripwireOk?Qe(e.content,t.text)?`exact`:e.kind===t.kind?`same-type-ordinal`:`ordinal`:`ordinal`:`clamped`}function et(e){let t=null,n=null;function r(r){return n!==null&&t===r?n:(n={blocks:Ue(r,e).blocks,lineStarts:Je(r)},t=r,n)}return{captureFromWysiwyg(e,t,n){if(e.childCount===0)return null;let r=Ze(t,0,e.content.size),i=0,a=e.childCount-1,o=0;for(let t=0;t<e.childCount;t++){let n=e.child(t).nodeSize;if(r<i+n){a=t,o=i+1;break}i+=n,o=i+1}let s=e.child(a),c={blockIndex:a,kind:Ve(s.type.name),content:s.textContent};return n?.refine&&(c.selectionInBlock=Math.max(0,r-o)),c},captureFromSource(e,t,n){let{blocks:i,lineStarts:a}=r(e);if(i.length===0)return null;let o=Ze(t,0,e.length),s=Ge(i,Xe(a,o));if(s===null)return null;let c=i[s];if(!c)return null;let l={blockIndex:s,kind:c.kind,content:c.text};if(n?.refine){let t=Ye(a,c.start,e.length);l.selectionInBlock=Math.max(0,o-t)}return l},resolveInSource(e,{source:t,doc:n}){let{blocks:i,lineStarts:a}=r(t);if(i.length===0)return null;let o=e.blockIndex>=0&&e.blockIndex<i.length,s=Ke(n)===i.length,c=i[Ze(e.blockIndex,0,i.length-1)],l=Ye(a,c.start,t.length),u=Math.min(Ye(a,c.end+1,t.length),t.length),d=$e(e,{inRange:o,tripwireOk:s,kind:c.kind,text:c.text}),f=l;return d===`exact`&&e.selectionInBlock!==void 0&&(f=Ze(l+e.selectionInBlock,l,u)),{blockStart:l,blockEnd:u,point:f,confidence:d}},resolveInWysiwyg(e,{source:t,doc:n}){let i=Ke(n);if(i===0)return null;let{blocks:a}=r(t),o=e.blockIndex>=0&&e.blockIndex<i,s=i===a.length,c=Ze(e.blockIndex,0,i-1),l=qe(n,c,c+1);if(l===null)return null;let u=n.child(c),d=$e(e,{inRange:o,tripwireOk:s,kind:Ve(u.type.name),text:u.textContent});return{blockStart:l.from,blockEnd:l.to,point:l.from,confidence:d}}}}var tt=he.define(),nt=he.define(),rt=_e.mark({class:n}),it=ge.define({create(){return _e.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(tt)?n=_e.set([rt.range(e.value.from,e.value.to)]):e.is(nt)&&(n=_e.none);return n},provide:e=>ye.decorations.from(e)}),at=new WeakMap,ot=ve.define(e=>({destroy(){let t=at.get(e);t!==void 0&&(clearTimeout(t),at.delete(e))}}));function st(e,t,n,r){let i=l(e.state.doc.length,t,n,r);if(!i)return;e.dispatch({effects:tt.of(i)});let a=at.get(e);a!==void 0&&clearTimeout(a);let o=setTimeout(()=>{at.delete(e),e.dispatch({effects:nt.of(null)})},R);at.set(e,o)}function ct(){return[it,ot]}var lt=3e4;function ut(){let e=new Map,t=e=>e?Date.now()-e.rememberedAt>lt?null:e.navigation:null;return{remember(t,n){e.set(t,{navigation:n,rememberedAt:Date.now()})},peek(n){return t(e.get(n))},consume(n){let r=e.get(n);return e.delete(n),t(r)},clear(t){e.delete(t)},clearForTest(){e.clear()}}}var dt=ut(),ft=ut(),pt=dt.remember,mt=dt.peek,ht=dt.consume,gt=dt.clear;dt.clearForTest;var _t=ft.remember,vt=ft.peek,yt=ft.consume,bt=ft.clear;ft.clearForTest;function xt(e,t,n){return{start:fe(e,t),end:fe(e,n)}}function St(e,t){let n=pe(e.start,t),r=pe(e.end,t);return n===null||r===null||r.index<=n.index?null:n.index}var Ct=`open-knowledge:view-in-source`,wt=56,Tt=null;function Et(){return Tt??=et(k()),Tt}function Dt(e,t,n,r,i=`toggle`){let a=r.captureFromWysiwyg(e,t,{refine:i===`jump`});if(!a)return null;let o=r.resolveInSource(a,{source:n.toString(),doc:e});return{kind:`selection-offset`,intent:i,anchor:a,pin:o?xt(n,o.blockStart,o.blockEnd):void 0}}function Ot(e){let{editor:t,docName:n,ytext:r}=e,i=A(t);if(!i)return;let a=i.state.selection.from,o=Dt(i.state.doc,a,r,Et(),`jump`);o&&pt(n,o),window.dispatchEvent(new CustomEvent(Ct,{detail:{docName:n}}))}function kt(e,t,n,r,i){let a=r.captureFromSource(e,t);if(!a)return null;let o=i?r.resolveInSource(a,{source:e,doc:i}):null;return{kind:`selection-offset`,anchor:a,pin:o?xt(n,o.blockStart,o.blockEnd):void 0}}function At(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=St(e.pin,i);if(t===null){let t=a.resolveInWysiwyg(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInWysiwyg(o,{source:n,doc:r})}return a.resolveInWysiwyg(e.anchor,{source:n,doc:r})}function jt(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=St(e.pin,i);if(t===null){let t=a.resolveInSource(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInSource(o,{source:n,doc:r})}return a.resolveInSource(e.anchor,{source:n,doc:r})}function Mt(e,t){try{return e.coordsAtPos(t)}catch{return null}}function Nt(e,t,n){let r=Math.max(0,Math.min(n,e.state.doc.length)),i=t.getBoundingClientRect().top,a=Mt(e,r);if(a)return{top:a.top-i+t.scrollTop,height:a.bottom-a.top};try{let n=e.lineBlockAt(r);return{top:e.documentTop-i+t.scrollTop+n.top,height:n.height}}catch{return null}}function Pt(e,t){if(e.isDestroyed)return null;try{let n=e.nodeDOM(t);if(n instanceof HTMLElement)return n;let{node:r}=e.domAtPos(t);return r instanceof HTMLElement?r:r.parentElement}catch{return null}}function Ft(e,t,n){if(e.isDestroyed)return null;let r=Pt(e,Math.max(0,Math.min(n,e.state.doc.content.size)));if(!r)return null;let i=r.getBoundingClientRect(),a=t.getBoundingClientRect().top;return{top:i.top-a+t.scrollTop,height:i.height}}function It(){return typeof document>`u`?null:p()}function Lt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2;for(let t of[wt+1,wt+12,wt+40]){let i=e.posAtCoords({left:r,top:n.top+t});if(i)return i.pos}return null}function Rt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2;for(let t of[wt+1,wt+12,wt+40]){let i=e.posAtCoords({x:r,y:n.top+t});if(i!==null)return i}return null}function zt(e){let{from:t,to:n,docName:r,ytext:i}=e;t===`wysiwyg`&&n===`source`?Bt(r,i):t===`source`&&n===`wysiwyg`&&Vt(r,i)}function Bt(e,t){let n=mt(e);if(n&&n.kind!==`selection-offset`)return;let r=o(e);if(!r)return;let i=A(r);if(!i)return;let a=It();if(!a)return;let s=Lt(i,a);if(s===null)return;let c=Dt(i.state.doc,s,t,Et());c&&pt(e,c)}function Vt(e,t){let n=i(e);if(!n)return;let r=It();if(!r)return;let a=Rt(n,r);if(a===null)return;let s=o(e),c=s?A(s)?.state.doc:void 0,l=kt(t.toString(),a,t,Et(),c);l&&_t(e,l)}function Ht(e){let{view:t,docName:n,navigation:r,ydoc:i,transition:a}=e,s=o(n),c=s?A(s)?.state.doc:void 0;if(!c)return null;let l=jt(r,{source:t.state.doc.toString(),pmDoc:c,ydoc:i,resolver:Et()});if(!l)return null;let u=It();if(!u)return null;let f=l,p=r.intent===`jump`,m=p?f.point:f.blockStart;t.dispatch({effects:ye.scrollIntoView(m,{y:`start`})});let h=!1,g=null,_=d(n,{yieldsToNavigation:!p,supersede:()=>{h=!0,_.release()}}),v=e=>{if(!h){if(Mt(t,m)===null&&e<8){requestAnimationFrame(()=>v(e+1));return}try{p&&(t.dispatch({selection:me.cursor(m)}),t.focus())}finally{_.release()}g=Be({docName:n,container:u,contentColumn:t.contentDOM,measureTarget:()=>Nt(t,u,m),placement:p?`center`:`top`,intent:p?`jump`:`toggle`,grade:f.confidence,landedMode:`source`,transition:a,toolbarOffset:wt,onOutcome:p?e=>{e.status===`landed`&&st(t,f.blockStart,f.blockEnd,f.confidence)}:void 0,onDiscardQueuedTarget:()=>gt(n)})}};return v(0),{cancel:e=>{h=!0,_.release(),g?.cancel(e)}}}function Ut(e){let{editor:t,docName:n,navigation:r,ydoc:i,transition:a}=e,o=A(t);if(!o)return null;let s=At(r,{source:i.getText(`source`).toString(),pmDoc:o.state.doc,ydoc:i,resolver:Et()});if(!s)return null;let c=It();if(!c)return null;let l=s;return Be({docName:n,container:c,contentColumn:o.dom,measureTarget:()=>Ft(o,c,l.point),placement:`top`,intent:`toggle`,grade:l.confidence,landedMode:`wysiwyg`,transition:a,toolbarOffset:wt,onDiscardQueuedTarget:()=>bt(n)})}var Z=e(h(),1),Q=b(),$=t();function Wt(e){let t=(0,Q.c)(14),{scope:n,onScopeChange:r,projectLabel:i}=e,{_:a}=_(),o;t[0]===r?o=t[1]:(o=e=>{e&&r(e)},t[0]=r,t[1]=o);let s;t[2]===a?s=t[3]:(s=a({id:`aBgwis`}),t[2]=a,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(N,{value:`doc`,className:`flex-1`,"data-testid":`panel-scope-doc`,children:(0,$.jsx)(g,{id:`UpCz01`})}),t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i??(0,$.jsx)(g,{id:`e0NrBM`}),t[5]=i,t[6]=l);let u;t[7]===l?u=t[8]:(u=(0,$.jsx)(N,{value:`project`,className:`flex-1`,"data-testid":`panel-scope-project`,children:l}),t[7]=l,t[8]=u);let d;return t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2`,children:(0,$.jsxs)(P,{type:`single`,variant:`segmented`,size:`sm`,spacing:1,value:n,onValueChange:o,"aria-label":s,className:`w-full rounded-md bg-muted p-0.5 dark:bg-background`,children:[c,u]})}),t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}var Gt=null,Kt=[];function qt(e){if(e===Gt)return Kt;let t=Jt(e);return Gt=e,Kt=t,t}function Jt(e){let t=[],n=new Map,r=I();for(let i=Yt(e);i<=e.lines;i++){let a=e.line(i);if(r(a.text))continue;let o=V(a.text,n);o&&t.push({slug:o.slug,from:a.from})}return t}function Yt(e){if(!Xt(e.line(1).text))return 1;for(let t=2;t<=e.lines;t++)if(Xt(e.line(t).text))return t+1;return 1}function Xt(e){return U.test(e.endsWith(`\r`)?e.slice(0,-1):e)}function Zt(e){let t=document.getElementById(e);return t?t.getBoundingClientRect().top:null}function Qt(e){let t=new Map;for(let n of qt(e.state.doc))t.set(n.slug,n.from);let n=e.documentTop;return r=>{let i=t.get(r);return i===void 0?null:n+e.lineBlockAt(i).top}}function $t(e,t){let n=(0,Q.c)(9),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{isSourceMode:o,docName:s}=r,c=o===void 0?!1:o,[l,u]=(0,Z.useState)(void 0),d=(0,Z.useRef)(null),f;n[2]===s?f=n[3]:(f=()=>s?i(s):null,n[2]=s,n[3]=f);let p=(0,Z.useSyncExternalStore)(a,f,en),m,h;return n[4]!==c||n[5]!==e||n[6]!==p?(m=()=>{if(e.length===0||c&&!p){u(void 0);return}let t=function(){let t=c&&p?Qt(p):Zt,n=window.innerHeight/2,r,i;for(let a of e){let e=t(a);e!==null&&(e<0?r=a:i===void 0&&e<n&&(i=a))}u(i??r??e[0])},n=function(){d.current===null&&(d.current=requestAnimationFrame(()=>{d.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)}},h=[e,c,p],n[4]=c,n[5]=e,n[6]=p,n[7]=m,n[8]=h):(m=n[7],h=n[8]),(0,Z.useEffect)(m,h),l}function en(){return null}var tn=300;async function nn(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new j(ae._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=G.safeParse(n);throw e.success?Error(e.data.title):new j(ae._({id:`zlErBl`}),{status:t.status})}let r=W.safeParse(n);if(!r.success)throw new j(ae._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var rn=32,an=12,on=6,sn=`open-knowledge:outline-nav`;function cn(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(de,{name:`outline-panel`,children:(0,$.jsx)(ln,{...e})}),t[0]=e,t[1]=n),n}function ln(e){let t=(0,Q.c)(53),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{_:o}=_(),{pages:s,loading:c}=q(),l=v(),{activeProvider:u,activeDocName:d}=f(),p,m;t[0]===n?(p=t[1],m=t[2]):(p=[`page-headings`,n],m=()=>nn(n),t[0]=n,t[1]=p,t[2]=m);let h;t[3]!==n||t[4]!==c||t[5]!==s?(h=!c&&(s.has(n)||L(n)),t[3]=n,t[4]=c,t[5]=s,t[6]=h):h=t[6];let b;t[7]!==p||t[8]!==m||t[9]!==h?(b={queryKey:p,queryFn:m,enabled:h,staleTime:1/0},t[7]=p,t[8]=m,t[9]=h,t[10]=b):b=t[10];let{data:S,isLoading:C,error:w}=y(b),T;t[11]===S?T=t[12]:(T=S===void 0?[]:S,t[11]=S,t[12]=T);let E=T,D,O;t[13]!==d||t[14]!==u||t[15]!==n||t[16]!==l?(D=()=>{if(!u||d!==n)return;let e=u.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,l.invalidateQueries({queryKey:[`page-headings`,n]})},tn)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},O=[u,d,n,l],t[13]=d,t[14]=u,t[15]=n,t[16]=l,t[17]=D,t[18]=O):(D=t[17],O=t[18]),(0,Z.useEffect)(D,O);let k;t[19]===E?k=t[20]:(k=E.map(un),t[19]=E,t[20]=k);let A=k,j;t[21]!==n||t[22]!==r?(j={isSourceMode:r,docName:n},t[21]=n,t[22]=r,t[23]=j):j=t[23];let M=$t(A,j),N;t[24]!==M||t[25]!==E?(N=M?E.findIndex(e=>e.slug===M):-1,t[24]=M,t[25]=E,t[26]=N):N=t[26];let P=N,F;t[27]!==n||t[28]!==r?(F=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&pt(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(sn,{detail:i}))},t[27]=n,t[28]=r,t[29]=F):F=t[29];let I=F,R=((P>=0?E[P].level:1)-1)*an+(an-on)/2,z=P*rn+(rn-on)/2,B;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(xe,{children:(0,$.jsx)(g,{id:`dD7NPy`})}),t[30]=B):B=t[30];let V;t[31]!==E.length||t[32]!==C?(V=!C&&(0,$.jsx)(we,{children:E.length}),t[31]=E.length,t[32]=C,t[33]=V):V=t[33];let H;t[34]===V?H=t[35]:(H=(0,$.jsxs)(Te,{children:[B,V]}),t[34]=V,t[35]=H);let U;t[36]!==o||t[37]!==P||t[38]!==M||t[39]!==w||t[40]!==I||t[41]!==E||t[42]!==C||t[43]!==R||t[44]!==z?(U=w?(0,$.jsx)(be,{className:`px-2`,children:w instanceof Error?w.message:o({id:`GuqOb1`})}):E.length===0&&!C?(0,$.jsx)(Se,{className:`px-2`,children:(0,$.jsx)(g,{id:`0BB9ID`})}):(0,$.jsxs)(`nav`,{"aria-label":o({id:`BymzO4`}),className:`relative`,children:[P>=0&&(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:on,height:on,transform:`translate(${R}px, ${z}px)`}}),E.map((e,t)=>{let n=e.slug===M;return(0,$.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>I(t,e.slug),className:x(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*an+20}px`},title:e.text,children:e.text},t)})]}),t[36]=o,t[37]=P,t[38]=M,t[39]=w,t[40]=I,t[41]=E,t[42]=C,t[43]=R,t[44]=z,t[45]=U):U=t[45];let W;t[46]!==C||t[47]!==U?(W=(0,$.jsx)(Ce,{className:`px-3 py-2`,"aria-busy":C,children:U}),t[46]=C,t[47]=U,t[48]=W):W=t[48];let G;return t[49]!==a||t[50]!==H||t[51]!==W?(G=(0,$.jsxs)(Ee,{className:a,children:[H,W]}),t[49]=a,t[50]=H,t[51]=W,t[52]=G):G=t[52],G}function un(e){return e.slug}function dn(e){return Math.min(50,Math.max(1,Math.ceil(e/10)))}function fn(e,t){return e===t||e%dn(t)===0}var pn=[250,500,1e3,2e3,4e3];function mn(e){return e.status===503&&e.problemType===`urn:ok:error:too-many-agent-sessions`}async function hn(e,t){let n=await t.fixItem(e);for(let r of pn){if(n.ok||!mn(n)||!t.shouldContinue()||(console.debug(`[sweep] capacity refusal, backing off %dms`,r),await t.sleep(r),!t.shouldContinue()))break;n=await t.fixItem(e)}return n}async function gn(e){let t=e.items.length,n=[];for(let[r,i]of e.items.entries()){if(r>0&&(await e.sleep(15),!e.shouldContinue()))return{failures:n,cancelled:!0};let a=await hn(i,e);if(a.ok||n.push({item:i,detail:a.errorDetail}),!e.shouldContinue())return{failures:n,cancelled:!0};let o=r+1;fn(o,t)&&e.onProgress(o,t)}return{failures:n,cancelled:!1}}function _n(e){return new Promise(t=>setTimeout(t,e))}var vn=`audit-superseded`;async function yn(e={kind:`project`}){return xn(e,H,!1)}async function bn(e={kind:`project`},t){return xn(e,F,!0,t)}async function xn(e,t,n,r){try{let i=new URLSearchParams;e.kind===`path`?i.set(`path`,e.path):e.kind===`doc`&&i.set(`doc`,e.docName),n&&i.set(`counts`,`1`);let a=i.size===0?``:`?${i}`,o=await fetch(`/api/audit${a}`,r===void 0?void 0:{signal:r});if(!o.ok)return o.status===409?vn:(console.warn(`[audit] request failed`,o.status,o.statusText),null);let s;try{s=await o.json()}catch{return r?.aborted===!0||console.warn(`[audit] response body is not valid JSON`),null}let c=t.safeParse(s);return c.success?c.data:(console.warn(`[audit] response failed schema validation`,c.error.issues),null)}catch(e){return r?.aborted===!0||console.warn(`[audit] fetch threw`,e),null}}function Sn(e){let t=(0,Q.c)(4),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let[r,i]=(0,Z.useState)(n),a,o;return t[1]===e?(a=t[2],o=t[3]):(a=()=>{if(i(Tn),e===null)return;let t=!1,n=()=>{yn({kind:`doc`,docName:e}).then(e=>{if(t||e===null||e===`audit-superseded`)return;let n=e.files.flatMap(wn).filter(Cn);i(e=>e.length===0&&n.length===0?e:n)})};n();let r=le(e=>{e.includes(`backlinks`)&&n()});return()=>{t=!0,r()}},o=[e],t[1]=e,t[2]=a,t[3]=o),(0,Z.useEffect)(a,o),r}function Cn(e){return e.source===`links`}function wn(e){return e.diagnostics}function Tn(e){return e.length===0?e:[]}var En={errorCount:0,warningCount:0},Dn=new Map,On=new Set,kn=new Map;function An(){let e=new Map;for(let[t,n]of Dn){let r=n.lint.errorCount+n.links.errorCount,i=n.lint.warningCount+n.links.warningCount;r===0&&i===0||e.set(t,{errorCount:r,warningCount:i})}kn=e;for(let e of On)e()}var jn=z;function Mn(e){return On.add(e),()=>{On.delete(e)}}function Nn(){return kn}function Pn(e){Dn.clear();for(let t of e)Dn.set(se(t.file),jn(t.diagnostics));An()}function Fn(e){Dn.clear();for(let t of e)Dn.set(se(t.file),{lint:t.lint,links:t.links});An()}function In(e,t){Dn.set(e,jn(t)),An()}function Ln(e,t,n){let r=Dn.get(e)??{lint:En,links:En},i=r[t];i.errorCount===n.errorCount&&i.warningCount===n.warningCount||(Dn.set(e,{...r,[t]:n}),An())}var Rn=`open-knowledge:lint-nav`;function zn(e,t){return e.range.start.line-t.range.start.line||e.range.start.character-t.range.start.character}function Bn(e){return{line:e.range.start.line+1,column:e.range.start.character+1}}function Vn(e){let t=(0,Q.c)(35),{diagnostic:n,instanceCount:i}=e,{_:a}=_(),o=n.severity===`error`?K:J,s=n.range.start.line+1,c=n.source===`links`,l=i!==void 0&&i>1,u=n.severity===`error`?`text-destructive`:`text-amber-500`,d;t[0]===u?d=t[1]:(d=x(`mt-0.5 size-3.5 shrink-0`,u),t[0]=u,t[1]=d);let f;t[2]!==o||t[3]!==d?(f=(0,$.jsx)(o,{"aria-hidden":`true`,className:d}),t[2]=o,t[3]=d,t[4]=f):f=t[4];let p;t[5]===n.message?p=t[6]:(p=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:n.message}),t[5]=n.message,t[6]=p);let m;t[7]!==l||t[8]!==i?(m=l?(0,$.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(X,{variant:`gray`,"data-testid":`problems-instance-count`,className:`h-4 px-1 font-sans text-[10px] leading-none`,children:(0,$.jsx)(g,{id:`iZCZmF`,values:{instanceCount:i}})}),(0,$.jsx)(te,{"aria-hidden":`true`,className:`size-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none`})]}):null,t[7]=l,t[8]=i,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==p||t[12]!==m?(h=(0,$.jsxs)(`span`,{className:`flex items-start gap-1.5 text-sm`,children:[f,p,m]}),t[10]=f,t[11]=p,t[12]=m,t[13]=h):h=t[13];let v=c&&`gap-0.5`,y;t[14]===v?y=t[15]:(y=x(`h-4 shrink-0 px-1 font-sans text-[10px] uppercase leading-none`,v),t[14]=v,t[15]=y);let b;t[16]===c?b=t[17]:(b=c?(0,$.jsx)(r,{"aria-hidden":`true`,className:`size-2.5`}):null,t[16]=c,t[17]=b);let S;t[18]!==n.source||t[19]!==y||t[20]!==b?(S=(0,$.jsxs)(X,{variant:`gray`,"data-testid":`problems-source-tag`,className:y,children:[b,n.source]}),t[18]=n.source,t[19]=y,t[20]=b,t[21]=S):S=t[21];let C;t[22]!==a||t[23]!==n.code||t[24]!==s||t[25]!==l?(C=l?n.code:`${n.code} · ${a({id:`enPTnx`,values:{displayLine:s}})}`,t[22]=a,t[23]=n.code,t[24]=s,t[25]=l,t[26]=C):C=t[26];let w;t[27]===C?w=t[28]:(w=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:C}),t[27]=C,t[28]=w);let T;t[29]!==S||t[30]!==w?(T=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 ps-5 font-mono text-xs text-muted-foreground`,children:[S,w]}),t[29]=S,t[30]=w,t[31]=T):T=t[31];let E;return t[32]!==T||t[33]!==h?(E=(0,$.jsxs)($.Fragment,{children:[h,T]}),t[32]=T,t[33]=h,t[34]=E):E=t[34],E}function Hn(e){let t=new Map;for(let n of e){let e=`${n.source}/${n.code}\u0000${n.linkTarget??``}\u0000${n.message}`,r=t.get(e);r===void 0?t.set(e,{key:e,instances:[n]}):r.instances.push(n)}return[...t.values()]}function Un(e){let t=(0,Q.c)(43),{group:n,onNavigate:r,navTitle:i,renderActions:a}=e,{_:o}=_(),s=n.instances[0];if(n.instances.length===1){let e;t[0]!==s||t[1]!==a?(e=a(s),t[0]=s,t[1]=a,t[2]=e):e=t[2];let n=e,o;t[3]!==s||t[4]!==r?(o=()=>r(s),t[3]=s,t[4]=r,t[5]=o):o=t[5];let c;t[6]!==s||t[7]!==i?(c=i(s),t[6]=s,t[7]=i,t[8]=c):c=t[8];let l;t[9]===s?l=t[10]:(l=(0,$.jsx)(Vn,{diagnostic:s}),t[9]=s,t[10]=l);let u;t[11]!==o||t[12]!==c||t[13]!==l?(u=(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left`,title:c,children:l}),t[11]=o,t[12]=c,t[13]=l,t[14]=u):u=t[14];let d;t[15]===n?d=t[16]:(d=n===null?null:(0,$.jsx)(`div`,{className:`absolute bottom-1 right-1 flex items-center gap-1 rounded bg-muted opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none`,children:n}),t[15]=n,t[16]=d);let f;return t[17]!==u||t[18]!==d?(f=(0,$.jsxs)(`li`,{className:`group relative rounded transition-colors hover:bg-muted`,children:[u,d]}),t[17]=u,t[18]=d,t[19]=f):f=t[19],f}let c;t[20]!==s||t[21]!==n.instances.length?(c=(0,$.jsx)(D,{className:`group flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,children:(0,$.jsx)(Vn,{diagnostic:s,instanceCount:n.instances.length})}),t[20]=s,t[21]=n.instances.length,t[22]=c):c=t[22];let l;t[23]!==o||t[24]!==s.message?(l=o({id:`EUiJEM`,values:{0:s.message}}),t[23]=o,t[24]=s.message,t[25]=l):l=t[25];let u;if(t[26]!==o||t[27]!==n.instances||t[28]!==i||t[29]!==r||t[30]!==a){let e;t[32]!==o||t[33]!==i||t[34]!==r||t[35]!==a?(e=e=>{let t=a(e),n=e.range.start.line+1;return(0,$.jsxs)(`li`,{className:`group relative rounded transition-colors hover:bg-muted`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`flex w-full cursor-pointer rounded px-2 py-1 text-left font-mono text-xs text-muted-foreground`,title:i(e),"aria-label":o({id:`uCe4AX`,values:{0:e.message,displayLine:n}}),children:o({id:`enPTnx`,values:{displayLine:n}})}),t===null?null:(0,$.jsx)(`div`,{className:`absolute bottom-0.5 right-1 flex items-center gap-1 rounded bg-muted opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none`,children:t})]},Wn(e))},t[32]=o,t[33]=i,t[34]=r,t[35]=a,t[36]=e):e=t[36],u=n.instances.map(e),t[26]=o,t[27]=n.instances,t[28]=i,t[29]=r,t[30]=a,t[31]=u}else u=t[31];let d;t[37]!==l||t[38]!==u?(d=(0,$.jsx)(E,{className:`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in] motion-reduce:animate-none`,children:(0,$.jsx)(`ul`,{"aria-label":l,className:`flex flex-col gap-0.5 pb-1 ps-5`,"data-testid":`problems-duplicate-instances`,children:u})}),t[37]=l,t[38]=u,t[39]=d):d=t[39];let f;return t[40]!==c||t[41]!==d?(f=(0,$.jsx)(`li`,{className:`rounded`,"data-testid":`problems-duplicate-group`,children:(0,$.jsxs)(O,{children:[c,d]})}),t[40]=c,t[41]=d,t[42]=f):f=t[42],f}function Wn(e){return`${e.source}/${e.code}-${e.range.start.line}-${e.range.start.character}-${e.message}`}function Gn(e){return e.reduce((e,t)=>e+ +((t.fixes?.length??0)>0),0)}function Kn(e){let t=(0,Q.c)(11),{target:n,creating:r,disabled:i,onCreate:a}=e,{_:o}=_(),s;t[0]!==o||t[1]!==n?(s=o({id:`oWsZk8`,values:{target:n}}),t[0]=o,t[1]=n,t[2]=s):s=t[2];let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(M,{"aria-hidden":`true`,className:`size-3`}),t[3]=c):c=t[3];let l;t[4]===r?l=t[5]:(l=r?(0,$.jsx)(g,{id:`E9bKSA`}):(0,$.jsx)(g,{id:`XRuL0i`}),t[4]=r,t[5]=l);let u;return t[6]!==i||t[7]!==a||t[8]!==s||t[9]!==l?(u=(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:i,onClick:a,"aria-label":s,"data-testid":`problems-create-page`,children:[c,l]}),t[6]=i,t[7]=a,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function qn(e){let t=(0,Q.c)(8),{tip:n,testId:r,children:i}=e,a;t[0]===i?a=t[1]:(a=(0,$.jsx)(C,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0`,children:i})}),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==n?(o=(0,$.jsx)(w,{"data-testid":r,children:n}),t[2]=r,t[3]=n,t[4]=o):o=t[4];let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(T,{children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Jn(e){let t=(0,Q.c)(21),{count:n,problemCount:r,aiAvailable:i,disabled:a,onClick:o,children:s}=e,{_:c}=_(),l;t[0]!==i||t[1]!==n||t[2]!==r?(l=n>0?(0,$.jsx)(g,{id:`vjwsDi`,values:{count:n}}):r===0?(0,$.jsx)(g,{id:`gAhHu7`}):i?(0,$.jsx)(g,{id:`zA9zRL`}):(0,$.jsx)(g,{id:`X3MMeA`}),t[0]=i,t[1]=n,t[2]=r,t[3]=l):l=t[3];let u;t[4]!==c||t[5]!==s||t[6]!==n||t[7]!==r?(u=s===void 0?r===0?c({id:`4m-xuX`}):n===0?c({id:`SqIoy_`}):void 0:void 0,t[4]=c,t[5]=s,t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(ie,{"aria-hidden":`true`,className:`size-3`}),t[9]=d):d=t[9];let f;t[10]!==s||t[11]!==n?(f=s??(0,$.jsx)(g,{id:`RZXTlY`,values:{count:n}}),t[10]=s,t[11]=n,t[12]=f):f=t[12];let p;t[13]!==a||t[14]!==o||t[15]!==u||t[16]!==f?(p=(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:a,onClick:o,"aria-label":u,"data-testid":`problems-auto-fix`,children:[d,f]}),t[13]=a,t[14]=o,t[15]=u,t[16]=f,t[17]=p):p=t[17];let m;return t[18]!==l||t[19]!==p?(m=(0,$.jsx)(qn,{testId:`problems-auto-fix-tip`,tip:l,children:p}),t[18]=l,t[19]=p,t[20]=m):m=t[20],m}function Yn(e){let t=(0,Q.c)(12),{count:n,disabled:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(g,{id:`mgDKWS`,values:{count:n}}),t[0]=n,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(s,{"aria-hidden":`true`,className:`size-3`}),t[2]=o):o=t[2];let c;t[3]===n?c=t[4]:(c=(0,$.jsx)(g,{id:`gyHDWC`,values:{count:n}}),t[3]=n,t[4]=c);let l;t[5]!==r||t[6]!==i||t[7]!==c?(l=(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:r,onClick:i,"data-testid":`problems-fix-with-ai`,children:[o,c]}),t[5]=r,t[6]=i,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==a||t[10]!==l?(u=(0,$.jsx)(qn,{testId:`problems-fix-with-ai-tip`,tip:a,children:l}),t[9]=a,t[10]=l,t[11]=u):u=t[11],u}function Xn(e){let t=(0,Q.c)(19),{docName:n,diagnostics:r,onFix:i,onAutoFix:a,onAskAi:o,onFixWithAi:c}=e,{_:l}=_(),[u,d]=(0,Z.useState)(`doc`),{data:f}=je(),p=f===null?null:f.effective.enabled?De.filter(e=>f.effective.plugins[e.id].enabled):[],h=p!==null&&p.length===0,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v={status:`idle`},t[0]=v):v=t[0];let[y,b]=(0,Z.useState)(v),[x,E]=(0,Z.useState)(null),D=ne(),[O,k]=(0,Z.useState)(null),A=(0,Z.useRef)(!0),j=(0,Z.useRef)(!1),M,N;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>(A.current=!0,()=>{A.current=!1}),N=[],t[1]=M,t[2]=N):(M=t[1],N=t[2]),(0,Z.useEffect)(M,N);let P=(0,Z.useRef)(ir),F;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(F={status:`idle`},t[3]=F):F=t[3];let I=(0,Z.useRef)(F),L;t[4]===y?L=t[5]:(L=()=>{y.status!==`loading`&&(I.current=y)},t[4]=y,t[5]=L),(0,Z.useEffect)(L);let R=(0,Z.useRef)(0),z=[...r].sort(zn),B=Gn(z),V=async function(e){let t=e.linkTarget;if(!(t===void 0||O!==null||D===null)){k(t);try{await m({initialDir:``,suggestedName:t},{addPage:D.addPage})}catch(e){let t=e;Y.error(t instanceof Error?t.message:l({id:`tfi40B`})),A.current&&k(null);return}Y.success(l({id:`EWCJFu`,values:{target:t}})),A.current&&k(null),A.current&&y.status===`loaded`&&await H()}};async function H(){R.current+=1;let e=R.current,t=I.current;b({status:`loading`});let n=await yn();if(n===`audit-superseded`){R.current===e&&A.current&&b(t.status===`idle`?{status:`failed`}:t);return}n!==null&&Pn(n.files),A.current&&b(n===null?{status:`failed`}:{status:`loaded`,result:n})}let U=y.status===`loaded`?y.result.files.filter(nr):[],W;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(W=function(){j.current=!0},t[6]=W):W=t[6];let G=W,ee=async function(){if(x!==null||U.length===0)return;let e=U.length;j.current=!1,E({done:0,total:e});let{failures:t,cancelled:n}=await gn({items:U,fixItem:tr,sleep:_n,onProgress:e=>E(t=>t===null?t:{...t,done:e}),shouldContinue:()=>A.current&&!j.current});if(!(n&&!A.current)){if(E(null),t.length>0&&(console.warn(`[lint] fix-all: ${t.length} of ${U.length} files failed`,t.map(er)),!n)){let e=t[0];Y.error(l({id:`fru3T7`,values:{0:t.length,1:U.length}}),{description:e===void 0?void 0:`${e.item.file}${e.detail===null?``:` — ${e.detail}`}`})}n&&Y.info(l({id:`H1TmTu`}));try{await H()}catch{A.current&&b({status:`failed`})}}},te=function(e){d(e),e===`project`&&y.status===`idle`&&H()};(0,Z.useEffect)(()=>{P.current=()=>{y.status===`idle`||y.status===`failed`||H()}});let K;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(K=[],t[7]=K):K=t[7],(0,Z.useEffect)(()=>Ae(()=>P.current()),K);let q;t[8]===n?q=t[9]:(q=function(e){let t=Bn(e);pt(n,{kind:`lint`,detail:t}),window.dispatchEvent(new CustomEvent(Rn,{detail:t}))},t[8]=n,t[9]=q);let re=q,J;t[10]!==n||t[11]!==re?(J=function(e,t){let r=se(e);if(r===n){re(t);return}pt(r,{kind:`lint`,detail:Bn(t)}),window.location.hash=oe(r)},t[10]=n,t[11]=re,t[12]=J):J=t[12];let ae=J,le=function(e){let t=i!==void 0&&(e.fixes?.length??0)>0,n=e.linkTarget!==void 0&&D!==null;if(!t&&!n&&o===void 0)return null;let r=`${e.source}/${e.code}`;return(0,$.jsxs)($.Fragment,{children:[n?(0,$.jsx)(Kn,{target:e.linkTarget??``,creating:O===e.linkTarget,disabled:O!==null,onCreate:()=>void V(e)}):null,t?(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>i?.(e),"aria-label":l({id:`fZj9em`,values:{flatId:r}}),"data-testid":`problems-fix`,children:[(0,$.jsx)(ie,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(g,{id:`c4fVUV`})]}):null,o===void 0?null:(0,$.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>o(e),"aria-label":l({id:`hh4mVC`,values:{flatId:r}}),"data-testid":`problems-ask-ai`,children:[(0,$.jsx)(s,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(g,{id:`xWEvuo`})]})]})},ue;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(xe,{children:(0,$.jsx)(g,{id:`OXdGnd`})}),t[13]=ue):ue=t[13];let de=p!==null&&p.length>0&&(0,$.jsxs)(T,{children:[(0,$.jsx)(C,{className:`shrink-0 cursor-default rounded-md bg-muted-foreground/5 px-2 py-1 font-mono text-xs text-muted-foreground`,"data-testid":`problems-active-plugins`,children:(0,$.jsx)(g,{id:`yxF19Y`,values:{0:p.length}})}),(0,$.jsx)(w,{"data-testid":`problems-active-plugins-tooltip`,children:(0,$.jsx)(g,{id:`ws5o1F`,values:{0:p.map($n).join(`, `)}})})]}),X;t[14]===de?X=t[15]:(X=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[ue,de]}),t[14]=de,t[15]=X);let fe=u===`doc`&&z.length>0&&(0,$.jsx)(we,{children:z.length}),pe;return t[16]!==X||t[17]!==fe?(pe=(0,$.jsxs)(Te,{children:[X,fe]}),t[16]=X,t[17]=fe,t[18]=pe):pe=t[18],(0,$.jsxs)(Ee,{children:[pe,(0,$.jsx)(Wt,{scope:u,onScopeChange:te}),u===`doc`?(0,$.jsx)(Ce,{className:`px-2 py-2`,children:z.length===0?h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Se,{className:`px-2`,"data-testid":`problems-no-plugins`,children:(0,$.jsx)(g,{id:`Hngy37`})}),(0,$.jsx)(`div`,{className:`px-2 pt-2`,children:(0,$.jsx)(S,{variant:`outline`,size:`sm`,onClick:ce,"data-testid":`problems-enable-plugins`,children:(0,$.jsx)(g,{id:`rnX-1S`})})})]}):(0,$.jsx)(Se,{className:`px-2`,children:(0,$.jsx)(g,{id:`ZI8uvA`})}):(0,$.jsxs)($.Fragment,{children:[a!==void 0||c!==void 0?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1 px-2 pb-1`,children:[a!==void 0&&(0,$.jsx)(Jn,{count:B,problemCount:z.length,aiAvailable:c!==void 0,disabled:B===0,onClick:a}),c!==void 0&&(0,$.jsx)(Yn,{count:z.length,disabled:!1,onClick:()=>c(`doc`)})]}):null,(0,$.jsx)(`ul`,{"aria-label":l({id:`OXdGnd`}),className:`flex flex-col gap-0.5`,children:Hn(z).map(e=>(0,$.jsx)(Un,{group:e,onNavigate:re,navTitle:e=>l({id:`vbMHjo`,values:{0:e.range.start.line+1}}),renderActions:le},e.key))})]})}):(0,$.jsx)(ar,{audit:y,onRefresh:()=>void H(),onNavigate:ae,fixableCount:U.reduce(Qn,0),problemCount:y.status===`loaded`?y.result.files.reduce(Zn,0):0,fixing:x,onAutoFix:()=>void ee(),onCancelFix:G,onFixWithAi:c===void 0||y.status!==`loaded`?void 0:()=>c(`project`),onCreateTarget:D===null?void 0:e=>void V(e),creatingTarget:O})]})}function Zn(e,t){return e+t.diagnostics.length}function Qn(e,t){return e+Gn(t.diagnostics)}function $n(e){return e.label}function er(e){return{file:e.item.file,detail:e.detail}}function tr(e){return ke(se(e.file))}function nr(e){return e.diagnostics.some(rr)}function rr(e){return(e.fixes?.length??0)>0}function ir(){}function ar(e){let t=(0,Q.c)(81),{audit:n,onRefresh:r,onNavigate:i,fixableCount:a,problemCount:o,fixing:s,onAutoFix:c,onCancelFix:l,onFixWithAi:u,onCreateTarget:d,creatingTarget:f}=e,{_:p}=_(),m=n.status===`loading`||n.status===`idle`,h;t[0]!==n.result||t[1]!==n.status?(h=n.status===`loaded`?n.result.files:[],t[0]=n.result,t[1]=n.status,t[2]=h):h=t[2];let v=h,[y,b]=(0,Z.useState)(cr),x;t[3]!==y||t[4]!==v?(x=v.length>0&&v.every(e=>y.has(e.file)),t[3]=y,t[4]=v,t[5]=x):x=t[5];let E=x,D;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(D=function(e,t){b(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},t[6]=D):D=t[6];let O=D,k;t[7]!==E||t[8]!==v?(k=function(){b(E?new Set:new Set(v.map(sr)))},t[7]=E,t[8]=v,t[9]=k):k=t[9];let A=k,j;t[10]!==n.result||t[11]!==n.status?(j=n.status===`loaded`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{id:`DsDwR-`,values:{0:n.result.errorCount}}),` · `,(0,$.jsx)(g,{id:`W1SI2K`,values:{0:n.result.warningCount}})]}),t[10]=n.result,t[11]=n.status,t[12]=j):j=t[12];let M;t[13]===j?M=t[14]:(M=(0,$.jsx)(`p`,{className:`min-w-0 truncate text-xs text-muted-foreground`,"data-testid":`problems-audit-summary`,children:j}),t[13]=j,t[14]=M);let N;t[15]!==p||t[16]!==E||t[17]!==v.length||t[18]!==A?(N=v.length>0?(0,$.jsxs)(T,{children:[(0,$.jsx)(C,{asChild:!0,children:(0,$.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":p(E?{id:`I4LGsH`}:{id:`Ugvy4O`}),"data-testid":`problems-audit-expand-toggle`,onClick:A,children:E?(0,$.jsx)(Me,{"aria-hidden":`true`,className:`size-3.5`}):(0,$.jsx)(Ne,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,$.jsx)(w,{"data-testid":`problems-audit-expand-toggle-tooltip`,children:E?(0,$.jsx)(g,{id:`I4LGsH`}):(0,$.jsx)(g,{id:`Ugvy4O`})})]}):null,t[15]=p,t[16]=E,t[17]=v.length,t[18]=A,t[19]=N):N=t[19];let P;t[20]===p?P=t[21]:(P=p({id:`I7y_vn`}),t[20]=p,t[21]=P);let F=m||s!==null,I;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(re,{"aria-hidden":`true`,className:`size-3.5`}),t[22]=I):I=t[22];let L;t[23]!==r||t[24]!==P||t[25]!==F?(L=(0,$.jsx)(C,{asChild:!0,children:(0,$.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":P,"data-testid":`problems-audit-refresh`,disabled:F,onClick:r,children:I})}),t[23]=r,t[24]=P,t[25]=F,t[26]=L):L=t[26];let R;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(w,{"data-testid":`problems-audit-refresh-tooltip`,children:(0,$.jsx)(g,{id:`I7y_vn`})}),t[27]=R):R=t[27];let z;t[28]===L?z=t[29]:(z=(0,$.jsxs)(T,{children:[L,R]}),t[28]=L,t[29]=z);let B;t[30]!==z||t[31]!==N?(B=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[N,z]}),t[30]=z,t[31]=N,t[32]=B):B=t[32];let V;t[33]!==B||t[34]!==M?(V=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[M,B]}),t[33]=B,t[34]=M,t[35]=V):V=t[35];let H;t[36]!==p||t[37]!==s?(H=s===null?null:(0,$.jsx)(`span`,{className:`sr-only`,role:`status`,children:p({id:`gZElfU`,values:{0:s.done,1:s.total}})}),t[36]=p,t[37]=s,t[38]=H):H=t[38];let U;t[39]!==p||t[40]!==s||t[41]!==l?(U=s===null?null:(0,$.jsxs)(T,{children:[(0,$.jsx)(C,{asChild:!0,children:(0,$.jsx)(S,{variant:`ghost`,size:`sm`,className:`h-6 shrink-0 px-2 text-muted-foreground`,"aria-label":p({id:`q2cLM6`}),"data-testid":`problems-cancel-fix`,onClick:l,children:(0,$.jsx)(g,{id:`ygCKqB`})})}),(0,$.jsx)(w,{"data-testid":`problems-cancel-fix-tooltip`,children:(0,$.jsx)(g,{id:`yvSAuM`})})]}),t[39]=p,t[40]=s,t[41]=l,t[42]=U):U=t[42];let W=u!==void 0,G=m||s!==null||a===0,ee;t[43]===s?ee=t[44]:(ee=s===null?void 0:(0,$.jsx)(g,{id:`S9t1PI`,values:{0:s.done,1:s.total}}),t[43]=s,t[44]=ee);let te;t[45]!==a||t[46]!==c||t[47]!==o||t[48]!==W||t[49]!==G||t[50]!==ee?(te=(0,$.jsx)(Jn,{count:a,problemCount:o,aiAvailable:W,disabled:G,onClick:c,children:ee}),t[45]=a,t[46]=c,t[47]=o,t[48]=W,t[49]=G,t[50]=ee,t[51]=te):te=t[51];let K;t[52]!==s||t[53]!==u||t[54]!==o?(K=u!==void 0&&o>0?(0,$.jsx)(Yn,{count:o,disabled:s!==null,onClick:u}):null,t[52]=s,t[53]=u,t[54]=o,t[55]=K):K=t[55];let q;t[56]!==H||t[57]!==U||t[58]!==te||t[59]!==K?(q=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[H,U,te,K]}),t[56]=H,t[57]=U,t[58]=te,t[59]=K,t[60]=q):q=t[60];let ne;t[61]!==V||t[62]!==q?(ne=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-2 pb-1`,children:[V,q]}),t[61]=V,t[62]=q,t[63]=ne):ne=t[63];let J;t[64]!==p||t[65]!==m?(J=m&&(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,role:`status`,"aria-busy":`true`,"aria-label":p({id:`dx-TwN`}),children:[1,2,3].map(or)}),t[64]=p,t[65]=m,t[66]=J):J=t[66];let ie;t[67]===n.status?ie=t[68]:(ie=n.status===`failed`&&(0,$.jsx)(be,{className:`px-2 text-xs`,children:(0,$.jsx)(g,{id:`IFezUv`})}),t[67]=n.status,t[68]=ie);let Y;t[69]!==n.result||t[70]!==n.status||t[71]!==f||t[72]!==y||t[73]!==d||t[74]!==i?(Y=n.status===`loaded`&&(0,$.jsx)(lr,{result:n.result,onNavigate:i,onCreateTarget:d,creatingTarget:f,expandedFiles:y,onToggleFile:O}),t[69]=n.result,t[70]=n.status,t[71]=f,t[72]=y,t[73]=d,t[74]=i,t[75]=Y):Y=t[75];let ae;return t[76]!==ne||t[77]!==J||t[78]!==ie||t[79]!==Y?(ae=(0,$.jsxs)(Ce,{className:`px-2 py-2`,"data-testid":`problems-project-scope`,children:[ne,J,ie,Y]}),t[76]=ne,t[77]=J,t[78]=ie,t[79]=Y,t[80]=ae):ae=t[80],ae}function or(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2 py-1.5`,children:[(0,$.jsx)(Oe,{className:`mt-0.5 size-3.5 shrink-0 rounded`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(Oe,{className:`h-3 w-28`}),(0,$.jsx)(Oe,{className:`h-3 w-40`})]})]},e)}function sr(e){return e.file}function cr(){return new Set}function lr(e){let t=(0,Q.c)(14),{result:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,expandedFiles:o,onToggleFile:s}=e,{_:c}=_(),l;t[0]!==c||t[1]!==n.warnings?(l=n.warnings.length>0&&(0,$.jsx)(`ul`,{"aria-label":c({id:`Rsdhj9`}),className:`flex flex-col gap-0.5 pb-1`,children:n.warnings.map(ur)}),t[0]=c,t[1]=n.warnings,t[2]=l):l=t[2];let u;t[3]!==a||t[4]!==o||t[5]!==i||t[6]!==r||t[7]!==s||t[8]!==n.fileCount||t[9]!==n.files?(u=n.files.length===0?(0,$.jsx)(Se,{className:`px-2`,children:(0,$.jsx)(g,{id:`k_Dqw1`,values:{0:n.fileCount}})}):n.files.map(e=>(0,$.jsx)(dr,{file:e,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o.has(e.file),onOpenChange:t=>s(e.file,t)},e.file)),t[3]=a,t[4]=o,t[5]=i,t[6]=r,t[7]=s,t[8]=n.fileCount,t[9]=n.files,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function ur(e,t){return(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 px-2 text-xs`,children:[(0,$.jsx)(J,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-amber-500`}),(0,$.jsx)(`span`,{className:`min-w-0 text-foreground`,children:e})]},`${t}-${e}`)}function dr(e){let t=(0,Q.c)(45),{file:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o,onOpenChange:s}=e,{_:c}=_(),l,u,d,f,p,m,h,g,v,y;if(t[0]!==c||t[1]!==a||t[2]!==n.diagnostics||t[3]!==n.file||t[4]!==i||t[5]!==r||t[6]!==s||t[7]!==o){let e=[...n.diagnostics].sort(zn);u=O,h=o,g=s,v=`problems-audit-group`;let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(te,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none`}),t[18]=_):_=t[18];let b;t[19]===n.file?b=t[20]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,title:n.file,children:n.file}),t[19]=n.file,t[20]=b),y=(0,$.jsxs)(D,{className:`group flex w-full cursor-pointer items-center gap-1.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,children:[_,b,(0,$.jsx)(X,{variant:`gray`,"data-testid":`problems-audit-file-count`,className:`shrink-0`,children:e.length})]}),l=E,m=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in] motion-reduce:animate-none`,t[21]!==c||t[22]!==n.file?(d=c({id:`zAJzIg`,values:{0:n.file}}),t[21]=c,t[22]=n.file,t[23]=d):d=t[23],f=`flex flex-col gap-0.5 pb-1 ps-3`;let x;t[24]!==c||t[25]!==a||t[26]!==n.file||t[27]!==i||t[28]!==r?(x=e=>(0,$.jsx)(Un,{group:e,onNavigate:e=>r(n.file,e),navTitle:e=>c({id:`xKDsGS`,values:{0:e.range.start.line+1,1:n.file}}),renderActions:e=>e.linkTarget===void 0||i===void 0?null:(0,$.jsx)(Kn,{target:e.linkTarget,creating:a===e.linkTarget,disabled:a!==null,onCreate:()=>i(e)})},e.key),t[24]=c,t[25]=a,t[26]=n.file,t[27]=i,t[28]=r,t[29]=x):x=t[29],p=Hn(e).map(x),t[0]=c,t[1]=a,t[2]=n.diagnostics,t[3]=n.file,t[4]=i,t[5]=r,t[6]=s,t[7]=o,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=v,t[17]=y}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],v=t[16],y=t[17];let b;t[30]!==d||t[31]!==f||t[32]!==p?(b=(0,$.jsx)(`ul`,{"aria-label":d,className:f,children:p}),t[30]=d,t[31]=f,t[32]=p,t[33]=b):b=t[33];let x;t[34]!==l||t[35]!==m||t[36]!==b?(x=(0,$.jsx)(l,{className:m,children:b}),t[34]=l,t[35]=m,t[36]=b,t[37]=x):x=t[37];let S;return t[38]!==u||t[39]!==x||t[40]!==h||t[41]!==g||t[42]!==v||t[43]!==y?(S=(0,$.jsxs)(u,{open:h,onOpenChange:g,"data-testid":v,children:[y,x]}),t[38]=u,t[39]=x,t[40]=h,t[41]=g,t[42]=v,t[43]=y,t[44]=S):S=t[44],S}var fr={words:0,chars:0,tokens:0},pr=/[ -〿぀-ゟ゠-ヿ㐀-䶿一-鿿豈-﫿＀-￯฀-๿ក-៿]/,mr=/[\p{L}\p{N}]/u,hr=new Set([`text`,`inlineCode`,`code`,`tag`]),gr=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),_r=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function vr(e,t){if(!e)return;let n=e.type;if(!gr.has(n)){if(hr.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
4
4
  `));return}if(n===`wikiLink`||n===`wikiLinkEmbed`){let n=e.data?.alias??e.value??``;n&&t.push(n);return}if(Array.isArray(e.children)){for(let n of e.children)vr(n,t);if(_r.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
5
5
  `)&&t.push(`
6
6
  `)}}}}function yr(e){try{let t=k().parseToMdast(e),n=[];return vr(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function br(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))mr.test(n)&&t++;return t}function xr(e){let t=globalThis.Intl.Segmenter;if(!t)return br(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function Sr(e){let t=pr.test(e)?1.5:4;return Math.ceil(e.length/t)}function Cr(e){return e?{words:pr.test(e)?xr(e):br(e),chars:e.length,tokens:Sr(e)}:{words:0,chars:0,tokens:0}}function wr(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=B(e);return t.trim()?Cr(yr(t)):{words:0,chars:0,tokens:0}}function Tr(e,{isMarkdown:t}){let n=e.trim();return n?Cr(t?yr(e):n):fr}var Er=new Map,Dr=new Set,Or=(e,t)=>`${t}:${e}`;function kr(){for(let e of Dr)e()}function Ar(e,t,n){let r=Or(e,t);if(n===null){Er.delete(r)&&kr();return}let i=Er.get(r);i&&i.words===n.words&&i.chars===n.chars&&i.tokens===n.tokens||(Er.set(r,n),kr())}function jr(e,t){return e===null?null:Er.get(Or(e,t))??null}function Mr(e){return Dr.add(e),()=>{Dr.delete(e)}}function Nr(e){let{from:t,to:n,empty:r}=e.state.selection;if(r)return null;let i=e.state.doc.textBetween(t,n,`