@inkeep/open-knowledge 0.9.0-beta.33 → 0.9.0-beta.34
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.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +3 -1
- package/dist/cli.mjs +4 -4
- package/dist/constants-CVf7CAf-.mjs +2 -0
- package/dist/{dist-qvP8X1Cn.mjs → dist-BNqM3Q9P.mjs} +1 -1
- package/dist/{dist-DnMeF_Yx.mjs → dist-DeQtb-TH.mjs} +7 -7
- package/dist/{gh-detect-DjaWa-fV.mjs → gh-detect-D3EaYkiE.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{init-B9QZkZWz.mjs → init-Bo84hmNW.mjs} +4 -4
- package/dist/init-DCc-vLg8.mjs +1 -0
- package/dist/{loader-Q9XLUMGN.mjs → loader-DcRPCz_p.mjs} +2 -2
- package/dist/loader-DfepLqZv.mjs +1 -0
- package/dist/preview-Cwq0RyYG.mjs +1 -0
- package/dist/{preview-CMR5yKXH.mjs → preview-DIgwrffB.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-CpmvH1z9.js → ActivityModeContent-BGnNOoN_.js} +1 -1
- package/dist/public/assets/{DocumentContext-Kqlx8YjN.js → DocumentContext-BSv1OatI.js} +1 -1
- package/dist/public/assets/{GraphPanel-yD7w8P9H.js → GraphPanel-BfhS6QMn.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-BuGhPBlG.js → SettingsDialogBody-BviDVGKy.js} +1 -1
- package/dist/public/assets/{SourceEditor-BKjAFaVa.js → SourceEditor-2q3FCJqZ.js} +1 -1
- package/dist/public/assets/{config-validation-events-CweQkDns.js → config-validation-events-zeI4vX-S.js} +1 -1
- package/dist/public/assets/{index-BV-BpS9G.js → index-DHnO3NcZ.js} +4 -4
- package/dist/public/assets/{prop-types-Bi80b84t.js → prop-types-54PkbD7b.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-JrEW3Jod.js → target-navigation-intent-YeYpKBFl.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-CIMc3LFE.js → typing-burst-detector-821VNlg2.js} +1 -1
- package/dist/public/index.html +6 -6
- package/dist/{repair-launch-json-BMyYnRp2.mjs → repair-launch-json-C2gaD3gB.mjs} +2 -2
- package/dist/{repair-mcp-configs-CoO4C1K5.mjs → repair-mcp-configs-BiXTTTVp.mjs} +2 -2
- package/dist/repair-skills-BEvrRG9M.mjs +1 -0
- package/dist/{repair-skills-BXs2xVWf.mjs → repair-skills-BGPqLLPt.mjs} +2 -2
- package/dist/{server-lock-BpjJj3OD-BpdqozwH.mjs → server-lock-BpjJj3OD-D9FMFKPA.mjs} +2 -2
- package/dist/server-lock-CyhBidkz-CxEJuFC3.mjs +1 -0
- package/dist/{src-DGiW_9Ll.mjs → src-ClkLa20g.mjs} +2 -2
- package/dist/{start-BOSVZEJO.mjs → start-CPcnpWPQ.mjs} +2 -2
- package/dist/start-zgOTUt2r.mjs +1 -0
- package/dist/{write-project-skill-DHCorqwq.mjs → write-project-skill-ZPEnzf-i.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-CbvHeCMM.mjs +0 -2
- package/dist/init-CokDu2De.mjs +0 -1
- package/dist/loader-BmBXaL6j.mjs +0 -1
- package/dist/preview-DFKhDNPF.mjs +0 -1
- package/dist/repair-skills-BVyYoufY.mjs +0 -1
- package/dist/server-lock-CyhBidkz-IWbRJ4RD.mjs +0 -1
- package/dist/start-BOC1TWY0.mjs +0 -1
package/dist/public/assets/{typing-burst-detector-CIMc3LFE.js → typing-burst-detector-821VNlg2.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,i as n,o as r,r as i,t as a}from"./compiler-runtime-Cs91PcD2.js";import{En as o,G as s,K as c,W as l,dt as u,n as d}from"./DocumentContext-Kqlx8YjN.js";import{a as f,c as ee,i as te,n as ne,o as re,r as ie,s as ae,t as oe,u as se}from"./panel-BNBODYwB.js";import{Qt as p,Ui as m,Yt as h,u as ce}from"./prop-types-Bi80b84t.js";import{S as le}from"./button-DenIdY-r.js";import{$ as g,At as _,Bt as v,Dt as y,E as b,Et as x,Ft as S,Ht as C,J as w,Mt as T,N as E,Ot as D,Pt as O,Q as k,Rt as A,Ut as j,X as M,_ as ue,_t as de,ct as N,dt as P,et as F,f as I,gt as L,ht as R,l as fe,lt as pe,mt as me,nt as he,ot as ge,rt as _e,st as ve,tt as ye,ut as be,wt as z,y as xe,yt as B,zt as Se}from"./dist-D2RGH7XO.js";import{i as Ce,n as we,o as Te,r as Ee}from"./dist-Cp-iTcML.js";var De=e(t(),1),Oe=a(),ke=new Map;function Ae(e,t){ke.set(e,t)}function je(e){let t=ke.get(e)??null;return ke.delete(e),t}function Me(e){ke.delete(e)}function Ne(e,t){let n=(0,Oe.c)(4),r=t===void 0?!1:t,[i,a]=(0,De.useState)(void 0),o=(0,De.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,De.useEffect)(s,c),i}var V=r(),Pe=300;async function Fe(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new u(m._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=p.safeParse(n);throw e.success?Error(e.data.title):new u(m._({id:`zlErBl`}),{status:t.status})}let r=h.safeParse(n);if(!r.success)throw new u(m._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var Ie=32,Le=12,Re=6,ze=`open-knowledge:outline-nav`;function Be(e){let t=(0,Oe.c)(2),n;return t[0]===e?n=t[1]:(n=(0,V.jsx)(o,{name:`outline-panel`,children:(0,V.jsx)(Ve,{...e})}),t[0]=e,t[1]=n),n}function Ve(e){let t=(0,Oe.c)(50),{docName:r,isSourceMode:a,className:o}=e,s=o===void 0?``:o,{_:c}=n(),{pages:l,loading:u}=ce(),p=se(),{activeProvider:m,activeDocName:h}=d(),g,_;t[0]===r?(g=t[1],_=t[2]):(g=[`page-headings`,r],_=()=>Fe(r),t[0]=r,t[1]=g,t[2]=_);let v;t[3]!==r||t[4]!==u||t[5]!==l?(v=!u&&l.has(r),t[3]=r,t[4]=u,t[5]=l,t[6]=v):v=t[6];let y;t[7]!==g||t[8]!==_||t[9]!==v?(y={queryKey:g,queryFn:_,enabled:v,staleTime:1/0},t[7]=g,t[8]=_,t[9]=v,t[10]=y):y=t[10];let{data:b,isLoading:x,error:S}=ee(y),C;t[11]===b?C=t[12]:(C=b===void 0?[]:b,t[11]=b,t[12]=C);let w=C,T,E;t[13]!==h||t[14]!==m||t[15]!==r||t[16]!==p?(T=()=>{if(!m||h!==r)return;let e=m.document,t=null,n=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,p.invalidateQueries({queryKey:[`page-headings`,r]})},Pe)};return e.on(`update`,n),()=>{e.off(`update`,n),t!==null&&clearTimeout(t)}},E=[m,h,r,p],t[13]=h,t[14]=m,t[15]=r,t[16]=p,t[17]=T,t[18]=E):(T=t[17],E=t[18]),(0,De.useEffect)(T,E);let D;t[19]===w?D=t[20]:(D=w.map(He),t[19]=w,t[20]=D);let O=Ne(D,a),k;t[21]!==O||t[22]!==w?(k=O?w.findIndex(e=>e.slug===O):-1,t[21]=O,t[22]=w,t[23]=k):k=t[23];let A=k,j;t[24]!==r||t[25]!==a?(j=function(e,t){let n={index:e,slug:t,mode:a?`source`:`wysiwyg`};n.mode===`source`&&Ae(r,{kind:`outline`,detail:n}),window.dispatchEvent(new CustomEvent(ze,{detail:n}))},t[24]=r,t[25]=a,t[26]=j):j=t[26];let M=j,ue=((A>=0?w[A].level:1)-1)*Le+(Le-Re)/2,de=A*Ie+(Ie-Re)/2,N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,V.jsx)(ae,{children:(0,V.jsx)(i,{id:`dD7NPy`})}),t[27]=N):N=t[27];let P;t[28]!==w.length||t[29]!==x?(P=!x&&(0,V.jsx)(ie,{children:w.length}),t[28]=w.length,t[29]=x,t[30]=P):P=t[30];let F;t[31]===P?F=t[32]:(F=(0,V.jsxs)(re,{children:[N,P]}),t[31]=P,t[32]=F);let I;t[33]!==c||t[34]!==A||t[35]!==O||t[36]!==S||t[37]!==M||t[38]!==w||t[39]!==x||t[40]!==ue||t[41]!==de?(I=S?(0,V.jsx)(f,{className:`px-2`,children:S instanceof Error?S.message:c({id:`GuqOb1`})}):w.length===0&&!x?(0,V.jsx)(te,{className:`px-2`,children:(0,V.jsx)(i,{id:`0BB9ID`})}):(0,V.jsxs)(`nav`,{"aria-label":c({id:`BymzO4`}),className:`relative`,children:[A>=0&&(0,V.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:Re,height:Re,transform:`translate(${ue}px, ${de}px)`}}),w.map((e,t)=>{let n=e.slug===O;return(0,V.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>M(t,e.slug),className:le(`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)*Le+20}px`},title:e.text,children:e.text},t)})]}),t[33]=c,t[34]=A,t[35]=O,t[36]=S,t[37]=M,t[38]=w,t[39]=x,t[40]=ue,t[41]=de,t[42]=I):I=t[42];let L;t[43]!==x||t[44]!==I?(L=(0,V.jsx)(ne,{className:`px-3 py-2`,"aria-busy":x,children:I}),t[43]=x,t[44]=I,t[45]=L):L=t[45];let R;return t[46]!==s||t[47]!==F||t[48]!==L?(R=(0,V.jsxs)(oe,{className:s,children:[F,L]}),t[46]=s,t[47]=F,t[48]=L,t[49]=R):R=t[49],R}function He(e){return e.slug}var Ue=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,H=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Ue(e)):Ue,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return A(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=j(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Se(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(H.prototype[Symbol.iterator]=function(){return this});var We={from:-1,to:-1,match:/.*/.exec(``)},Ge=`gm`+(/x/.unicode==null?``:`u`),Ke=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=We,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Ye(e,t,n,r,i);this.re=new RegExp(t,Ge+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=Ze(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Ze(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},qe=new WeakMap,Je=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=qe.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return qe.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),qe.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Ye=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=We,this.matchPos=Ze(e,r),this.re=new RegExp(t,Ge+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Je.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=Ze(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Je.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Ke.prototype[Symbol.iterator]=Ye.prototype[Symbol.iterator]=function(){return this});function Xe(e){try{return new RegExp(e,Ge),!0}catch{return!1}}function Ze(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Qe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=L(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),ee=x.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,M.scrollIntoView(ee.from,{y:`center`})],selection:ee})}),!0},$e={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},et=D.define({combine(e){return v(e,$e,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function tt(e){let t=[st,ot];return e&&t.push(et.of(e)),t}var nt=w.mark({class:`cm-selectionMatch`}),rt=w.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function it(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=z.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=z.Word)}function at(e,t,n,r){return e(t.sliceDoc(n,n+1))==z.Word&&e(t.sliceDoc(r-1,r))==z.Word}var ot=k.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(et),{state:n}=e,r=n.selection;if(r.ranges.length>1)return w.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return w.none;let e=n.wordAt(i.head);if(!e)return w.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return w.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(it(o,n,i.from,i.to)&&at(o,n,i.from,i.to)))return w.none}else if(a=n.sliceDoc(i.from,i.to),!a)return w.none}let s=[];for(let r of e.visibleRanges){let e=new H(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||it(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(rt.range(r,a)):(r>=i.to||a<=i.from)&&s.push(nt.range(r,a)),s.length>t.maxMatches))return w.none}}return w.set(s)}},{decorations:e=>e.decorations}),st=M.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),ct=({state:e,dispatch:t})=>{let{selection:n}=e,r=x.create(n.ranges.map(t=>e.wordAt(t.head)||x.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function lt(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new H(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new H(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var ut=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return ct({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=lt(e,r);return i?(t(e.update({selection:e.selection.addRange(x.range(i.from,i.to),!1),effects:M.scrollIntoView(i.to)})),!0):!1},U=D.define({combine(e){return v(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new zt(e),scrollToMatch:e=>M.scrollIntoView(e)})}}),dt=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Xe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,i as n,o as r,r as i,t as a}from"./compiler-runtime-Cs91PcD2.js";import{En as o,G as s,K as c,W as l,dt as u,n as d}from"./DocumentContext-BSv1OatI.js";import{a as f,c as ee,i as te,n as ne,o as re,r as ie,s as ae,t as oe,u as se}from"./panel-BNBODYwB.js";import{Qt as p,Ui as m,Yt as h,u as ce}from"./prop-types-54PkbD7b.js";import{S as le}from"./button-DenIdY-r.js";import{$ as g,At as _,Bt as v,Dt as y,E as b,Et as x,Ft as S,Ht as C,J as w,Mt as T,N as E,Ot as D,Pt as O,Q as k,Rt as A,Ut as j,X as M,_ as ue,_t as de,ct as N,dt as P,et as F,f as I,gt as L,ht as R,l as fe,lt as pe,mt as me,nt as he,ot as ge,rt as _e,st as ve,tt as ye,ut as be,wt as z,y as xe,yt as B,zt as Se}from"./dist-D2RGH7XO.js";import{i as Ce,n as we,o as Te,r as Ee}from"./dist-Cp-iTcML.js";var De=e(t(),1),Oe=a(),ke=new Map;function Ae(e,t){ke.set(e,t)}function je(e){let t=ke.get(e)??null;return ke.delete(e),t}function Me(e){ke.delete(e)}function Ne(e,t){let n=(0,Oe.c)(4),r=t===void 0?!1:t,[i,a]=(0,De.useState)(void 0),o=(0,De.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,De.useEffect)(s,c),i}var V=r(),Pe=300;async function Fe(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new u(m._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=p.safeParse(n);throw e.success?Error(e.data.title):new u(m._({id:`zlErBl`}),{status:t.status})}let r=h.safeParse(n);if(!r.success)throw new u(m._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var Ie=32,Le=12,Re=6,ze=`open-knowledge:outline-nav`;function Be(e){let t=(0,Oe.c)(2),n;return t[0]===e?n=t[1]:(n=(0,V.jsx)(o,{name:`outline-panel`,children:(0,V.jsx)(Ve,{...e})}),t[0]=e,t[1]=n),n}function Ve(e){let t=(0,Oe.c)(50),{docName:r,isSourceMode:a,className:o}=e,s=o===void 0?``:o,{_:c}=n(),{pages:l,loading:u}=ce(),p=se(),{activeProvider:m,activeDocName:h}=d(),g,_;t[0]===r?(g=t[1],_=t[2]):(g=[`page-headings`,r],_=()=>Fe(r),t[0]=r,t[1]=g,t[2]=_);let v;t[3]!==r||t[4]!==u||t[5]!==l?(v=!u&&l.has(r),t[3]=r,t[4]=u,t[5]=l,t[6]=v):v=t[6];let y;t[7]!==g||t[8]!==_||t[9]!==v?(y={queryKey:g,queryFn:_,enabled:v,staleTime:1/0},t[7]=g,t[8]=_,t[9]=v,t[10]=y):y=t[10];let{data:b,isLoading:x,error:S}=ee(y),C;t[11]===b?C=t[12]:(C=b===void 0?[]:b,t[11]=b,t[12]=C);let w=C,T,E;t[13]!==h||t[14]!==m||t[15]!==r||t[16]!==p?(T=()=>{if(!m||h!==r)return;let e=m.document,t=null,n=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,p.invalidateQueries({queryKey:[`page-headings`,r]})},Pe)};return e.on(`update`,n),()=>{e.off(`update`,n),t!==null&&clearTimeout(t)}},E=[m,h,r,p],t[13]=h,t[14]=m,t[15]=r,t[16]=p,t[17]=T,t[18]=E):(T=t[17],E=t[18]),(0,De.useEffect)(T,E);let D;t[19]===w?D=t[20]:(D=w.map(He),t[19]=w,t[20]=D);let O=Ne(D,a),k;t[21]!==O||t[22]!==w?(k=O?w.findIndex(e=>e.slug===O):-1,t[21]=O,t[22]=w,t[23]=k):k=t[23];let A=k,j;t[24]!==r||t[25]!==a?(j=function(e,t){let n={index:e,slug:t,mode:a?`source`:`wysiwyg`};n.mode===`source`&&Ae(r,{kind:`outline`,detail:n}),window.dispatchEvent(new CustomEvent(ze,{detail:n}))},t[24]=r,t[25]=a,t[26]=j):j=t[26];let M=j,ue=((A>=0?w[A].level:1)-1)*Le+(Le-Re)/2,de=A*Ie+(Ie-Re)/2,N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,V.jsx)(ae,{children:(0,V.jsx)(i,{id:`dD7NPy`})}),t[27]=N):N=t[27];let P;t[28]!==w.length||t[29]!==x?(P=!x&&(0,V.jsx)(ie,{children:w.length}),t[28]=w.length,t[29]=x,t[30]=P):P=t[30];let F;t[31]===P?F=t[32]:(F=(0,V.jsxs)(re,{children:[N,P]}),t[31]=P,t[32]=F);let I;t[33]!==c||t[34]!==A||t[35]!==O||t[36]!==S||t[37]!==M||t[38]!==w||t[39]!==x||t[40]!==ue||t[41]!==de?(I=S?(0,V.jsx)(f,{className:`px-2`,children:S instanceof Error?S.message:c({id:`GuqOb1`})}):w.length===0&&!x?(0,V.jsx)(te,{className:`px-2`,children:(0,V.jsx)(i,{id:`0BB9ID`})}):(0,V.jsxs)(`nav`,{"aria-label":c({id:`BymzO4`}),className:`relative`,children:[A>=0&&(0,V.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:Re,height:Re,transform:`translate(${ue}px, ${de}px)`}}),w.map((e,t)=>{let n=e.slug===O;return(0,V.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>M(t,e.slug),className:le(`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)*Le+20}px`},title:e.text,children:e.text},t)})]}),t[33]=c,t[34]=A,t[35]=O,t[36]=S,t[37]=M,t[38]=w,t[39]=x,t[40]=ue,t[41]=de,t[42]=I):I=t[42];let L;t[43]!==x||t[44]!==I?(L=(0,V.jsx)(ne,{className:`px-3 py-2`,"aria-busy":x,children:I}),t[43]=x,t[44]=I,t[45]=L):L=t[45];let R;return t[46]!==s||t[47]!==F||t[48]!==L?(R=(0,V.jsxs)(oe,{className:s,children:[F,L]}),t[46]=s,t[47]=F,t[48]=L,t[49]=R):R=t[49],R}function He(e){return e.slug}var Ue=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,H=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Ue(e)):Ue,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return A(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=j(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Se(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(H.prototype[Symbol.iterator]=function(){return this});var We={from:-1,to:-1,match:/.*/.exec(``)},Ge=`gm`+(/x/.unicode==null?``:`u`),Ke=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=We,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Ye(e,t,n,r,i);this.re=new RegExp(t,Ge+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=Ze(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Ze(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},qe=new WeakMap,Je=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=qe.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return qe.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),qe.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Ye=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=We,this.matchPos=Ze(e,r),this.re=new RegExp(t,Ge+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Je.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=Ze(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Je.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Ke.prototype[Symbol.iterator]=Ye.prototype[Symbol.iterator]=function(){return this});function Xe(e){try{return new RegExp(e,Ge),!0}catch{return!1}}function Ze(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Qe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=L(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),ee=x.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,M.scrollIntoView(ee.from,{y:`center`})],selection:ee})}),!0},$e={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},et=D.define({combine(e){return v(e,$e,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function tt(e){let t=[st,ot];return e&&t.push(et.of(e)),t}var nt=w.mark({class:`cm-selectionMatch`}),rt=w.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function it(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=z.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=z.Word)}function at(e,t,n,r){return e(t.sliceDoc(n,n+1))==z.Word&&e(t.sliceDoc(r-1,r))==z.Word}var ot=k.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(et),{state:n}=e,r=n.selection;if(r.ranges.length>1)return w.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return w.none;let e=n.wordAt(i.head);if(!e)return w.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return w.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(it(o,n,i.from,i.to)&&at(o,n,i.from,i.to)))return w.none}else if(a=n.sliceDoc(i.from,i.to),!a)return w.none}let s=[];for(let r of e.visibleRanges){let e=new H(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||it(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(rt.range(r,a)):(r>=i.to||a<=i.from)&&s.push(nt.range(r,a)),s.length>t.maxMatches))return w.none}}return w.set(s)}},{decorations:e=>e.decorations}),st=M.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),ct=({state:e,dispatch:t})=>{let{selection:n}=e,r=x.create(n.ranges.map(t=>e.wordAt(t.head)||x.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function lt(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new H(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new H(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var ut=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return ct({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=lt(e,r);return i?(t(e.update({selection:e.selection.addRange(x.range(i.from,i.to),!1),effects:M.scrollIntoView(i.to)})),!0):!1},U=D.define({combine(e){return v(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new zt(e),scrollToMatch:e=>M.scrollIntoView(e)})}}),dt=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Xe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
2
2
|
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new bt(this):new ht(this)}getCursor(e,t=0,n){let r=e.doc?e:y.create({doc:e});return n??=r.doc.length,this.regexp?G(this,r,t,n):W(this,r,t,n)}},ft=class{constructor(e){this.spec=e}};function pt(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function W(e,t,n,r){let i;return e.wholeWord&&(i=mt(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=pt(e.test,t,i)),new H(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function mt(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(_t(i,n-a))!=z.Word||t(vt(i,n-a))!=z.Word)&&(t(vt(i,r-a))!=z.Word||t(_t(i,r-a))!=z.Word))}var ht=class extends ft{constructor(e){super(e)}nextMatch(e,t,n){let r=W(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=W(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=W(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=W(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=W(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function gt(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function G(e,t,n,r){let i;return e.wholeWord&&(i=yt(t.charCategorizer(t.selection.main.head))),e.test&&(i=gt(e.test,t,i)),new Ke(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function _t(e,t){return e.slice(C(e,t,!1),t)}function vt(e,t){return e.slice(t,C(e,t))}function yt(e){return(t,n,r)=>!r[0].length||(e(_t(r.input,r.index))!=z.Word||e(vt(r.input,r.index))!=z.Word)&&(e(vt(r.input,r.index+r[0].length))!=z.Word||e(_t(r.input,r.index+r[0].length))!=z.Word)}var bt=class extends ft{nextMatch(e,t,n){let r=G(this.spec,e,n,e.doc.length).next();return r.done&&(r=G(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=G(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=G(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=G(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},K=O.define(),xt=O.define(),q=S.define({create(e){return new St(Nt(e).create(),null)},update(e,t){for(let n of t.effects)n.is(K)?e=new St(n.value.create(),e.panel):n.is(xt)&&(e=new St(e.query,n.value?Mt:null));return e},provide:e=>de.from(e,e=>e.panel)}),St=class{constructor(e,t){this.query=e,this.panel=t}},Ct=w.mark({class:`cm-searchMatch`}),wt=w.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Tt=k.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(q))}update(e){let t=e.state.field(q);(t!=e.startState.field(q)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return w.none;let{view:n}=this,r=new T;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?wt:Ct)})}return r.finish()}},{decorations:e=>e.decorations});function J(e){return t=>{let n=t.state.field(q,!1);return n&&n.query.spec.valid?e(t,n):It(t)}}var Et=J((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=x.single(r.from,r.to),a=e.state.facet(U);return e.dispatch({selection:i,effects:[Ht(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),Ft(e),!0}),Dt=J((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=x.single(i.from,i.to),o=e.state.facet(U);return e.dispatch({selection:a,effects:[Ht(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),Ft(e),!0}),Ot=J((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:x.create(n.map(e=>x.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),kt=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new H(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(x.range(t.value.from,t.value.to))}return t(e.update({selection:x.create(a,o),userEvent:`select.search.matches`})),!0},At=J((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(M.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=x.single(o.from,o.to).map(d),u.push(Ht(e,o)),u.push(n.facet(U).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),jt=J((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:M.announce.of(r),userEvent:`input.replace.all`}),!0});function Mt(e){return e.state.facet(U).createPanel(e)}function Nt(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(U);return new dt({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function Pt(e){let t=_e(e,Mt);return t&&t.dom.querySelector(`[main-field]`)}function Ft(e){let t=Pt(e);t&&t==e.root.activeElement&&t.select()}var It=e=>{let t=e.state.field(q,!1);if(t&&t.panel){let n=Pt(e);if(n&&n!=e.root.activeElement){let r=Nt(e.state,t.query.spec);r.valid&&e.dispatch({effects:K.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[xt.of(!0),t?K.of(Nt(e.state,t.query.spec)):O.appendConfig.of(Wt)]});return!0},Lt=e=>{let t=e.state.field(q,!1);if(!t||!t.panel)return!1;let n=_e(e,Mt);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:xt.of(!1)}),!0},Rt=[{key:`Mod-f`,run:It,scope:`editor search-panel`},{key:`F3`,run:Et,shift:Dt,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Et,shift:Dt,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Lt,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:kt},{key:`Mod-Alt-g`,run:Qe},{key:`Mod-d`,run:ut,preventDefault:!0}],zt=class{constructor(e){this.view=e;let t=this.query=e.state.field(q).query.spec;this.commit=this.commit.bind(this),this.searchField=B(`input`,{value:t.search,placeholder:Y(e,`Find`),"aria-label":Y(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=B(`input`,{value:t.replace,placeholder:Y(e,`Replace`),"aria-label":Y(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=B(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=B(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=B(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return B(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=B(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Et(e),[Y(e,`next`)]),n(`prev`,()=>Dt(e),[Y(e,`previous`)]),n(`select`,()=>Ot(e),[Y(e,`all`)]),B(`label`,null,[this.caseField,Y(e,`match case`)]),B(`label`,null,[this.reField,Y(e,`regexp`)]),B(`label`,null,[this.wordField,Y(e,`by word`)]),...e.state.readOnly?[]:[B(`br`),this.replaceField,n(`replace`,()=>At(e),[Y(e,`replace`)]),n(`replaceAll`,()=>jt(e),[Y(e,`replace all`)])],B(`button`,{name:`close`,onclick:()=>Lt(e),"aria-label":Y(e,`close`),type:`button`},[`×`])])}commit(){let e=new dt({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:K.of(e)}))}keydown(e){R(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Dt:Et)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),At(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(K)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(U).top}};function Y(e,t){return e.state.phrase(t)}var Bt=30,Vt=/[\s\.,:;?!]/;function Ht(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-Bt),o=Math.min(i,n+Bt),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Bt;e++)if(!Vt.test(s[e+1])&&Vt.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Bt;e--)if(!Vt.test(s[e-1])&&Vt.test(s[e])){s=s.slice(0,e);break}}return M.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Ut=M.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Wt=[q,_.low(Tt),Ut],Gt=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},X=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet($).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new T,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=mn(s);if(i)o.add(n,n,w.widget({widget:new sn(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,w.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,Z(f))}};function Z(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new Gt(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Gt(r.from,n,r.diagnostic)}),r}function Kt(e,t){let n=t.pos,r=t.end||n,i=e.state.facet($).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(Jt))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function qt(e,t){return e.field(Q,!1)?t:t.concat(O.appendConfig.of(hn))}var Jt=O.define(),Yt=O.define(),Xt=O.define(),Q=S.define({create(){return new X(w.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Z(n,e.selected.diagnostic,i)||Z(n,null,i)}!n.size&&i&&t.state.facet($).autoPanel&&(i=null),e=new X(n,i,r)}for(let n of t.effects)if(n.is(Jt)){let r=t.state.facet($).autoPanel?n.value.length?ln.open:null:e.panel;e=X.init(n.value,r,t.state)}else n.is(Yt)?e=new X(e.diagnostics,n.value?ln.open:null,e.selected):n.is(Xt)&&(e=new X(e.diagnostics,e.panel,n.value));return e},provide:e=>[de.from(e,e=>e.panel),M.decorations.from(e,e=>e.diagnostics)]}),Zt=w.mark({class:`cm-lintRange cm-lintRange-active`});function Qt(e,t,n){let{diagnostics:r}=e.state.field(Q),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet($).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:$t(e,i)}}}:null}function $t(e,t){return B(`ul`,{class:`cm-tooltip-lint`},t.map(t=>on(e,t,!1)))}var en=e=>{let t=e.state.field(Q,!1);(!t||!t.panel)&&e.dispatch({effects:qt(e.state,[Yt.of(!0)])});let n=_e(e,ln.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},tn=e=>{let t=e.state.field(Q,!1);return!t||!t.panel?!1:(e.dispatch({effects:Yt.of(!1)}),!0)},nn=[{key:`Mod-Shift-m`,run:en,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Q,!1);if(!t)return!1;let n=e.state.selection.main,r=Z(t.diagnostics,null,n.to+1);return!r&&(r=Z(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],$=D.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...v(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:rn,tooltipFilter:rn,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function rn(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function an(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function on(e,t,n){let r=n?an(t.actions):[];return B(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},B(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Z(e.state.field(Q).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),B(`u`,s.slice(c,c+1)),s.slice(c+1)];return B(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&B(`div`,{class:`cm-diagnosticSource`},t.source))}var sn=class extends g{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return B(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},cn=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=on(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},ln=class e{constructor(e){this.view=e,this.items=[],this.list=B(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)tn(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=an(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=Z(this.view.state.field(Q).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=B(`div`,{class:`cm-panel-lint`},this.list,B(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>tn(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Q).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Q),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new cn(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new cn(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Z(this.view.state.field(Q).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Xt.of(t)})}static open(t){return new e(t)}};function un(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function dn(e){return un(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var fn=M.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:dn(`#d11`)},".cm-lintRange-warning":{backgroundImage:dn(`orange`)},".cm-lintRange-info":{backgroundImage:dn(`#999`)},".cm-lintRange-hint":{backgroundImage:dn(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function pn(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function mn(e){let t=`hint`,n=1;for(let r of e){let e=pn(r.severity);e>n&&(n=e,t=r.severity)}return t}var hn=[Q,M.decorations.compute([Q],e=>{let{selected:t,panel:n}=e.field(Q);return!t||!n||t.from==t.to?w.none:w.set([Zt.range(t.from,t.to)])}),pe(Qt,{hideOn:Kt}),fn],gn=[P(),ve(),N(),s(),ue(),ye(),he(),y.allowMultipleSelections.of(!0),b(),E(I,{fallback:!0}),fe(),Ee(),we(),me(),F(),ge(),tt(),be.of([...Ce,...l,...Rt,...c,...xe,...Te,...nn])];N(),s(),ye(),E(I,{fallback:!0}),be.of([...l,...c]);export{je as a,Me as i,ze as n,Ae as o,Be as r,gn as t};
|
package/dist/public/index.html
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
-->
|
|
49
49
|
<script>(() => { let t = 'system'; try { const r = localStorage.getItem('ok-theme-v1'); if (r === 'light' || r === 'dark' || r === 'system') t = r; } catch {} let dark = t === 'dark'; if (t === 'system') { try { dark = window.matchMedia('(prefers-color-scheme: dark)').matches; } catch {} } if (dark) document.documentElement.classList.add('dark'); if (window.okDesktop) document.documentElement.classList.add('electron-mode'); })();</script>
|
|
50
50
|
<style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
|
|
51
|
-
<script type="module" crossorigin src="./assets/index-
|
|
51
|
+
<script type="module" crossorigin src="./assets/index-DHnO3NcZ.js"></script>
|
|
52
52
|
<link rel="modulepreload" crossorigin href="./assets/chunk-CFjPhJqf.js">
|
|
53
53
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-2ej06EnG.js">
|
|
54
54
|
<link rel="modulepreload" crossorigin href="./assets/w3c-keyname-B5t0fahT.js">
|
|
@@ -61,22 +61,22 @@
|
|
|
61
61
|
<link rel="modulepreload" crossorigin href="./assets/compiler-runtime-Cs91PcD2.js">
|
|
62
62
|
<link rel="modulepreload" crossorigin href="./assets/trace-api-CiCjX4Sz.js">
|
|
63
63
|
<link rel="modulepreload" crossorigin href="./assets/button-DenIdY-r.js">
|
|
64
|
-
<link rel="modulepreload" crossorigin href="./assets/prop-types-
|
|
64
|
+
<link rel="modulepreload" crossorigin href="./assets/prop-types-54PkbD7b.js">
|
|
65
65
|
<link rel="modulepreload" crossorigin href="./assets/propagation-api-3kmMXRwS.js">
|
|
66
66
|
<link rel="modulepreload" crossorigin href="./assets/collapsible-BhpeB6tu.js">
|
|
67
67
|
<link rel="modulepreload" crossorigin href="./assets/dist-DicqJavT.js">
|
|
68
68
|
<link rel="modulepreload" crossorigin href="./assets/dialog-B1es0EvU.js">
|
|
69
|
-
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-
|
|
69
|
+
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-BSv1OatI.js">
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/panel-BNBODYwB.js">
|
|
71
|
-
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-
|
|
71
|
+
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-821VNlg2.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/checkbox-Co7Tjlri.js">
|
|
73
73
|
<link rel="modulepreload" crossorigin href="./assets/label-DwEePOBC.js">
|
|
74
74
|
<link rel="modulepreload" crossorigin href="./assets/dist-P7DYrfOB.js">
|
|
75
75
|
<link rel="modulepreload" crossorigin href="./assets/textarea-luaT-nOK.js">
|
|
76
76
|
<link rel="modulepreload" crossorigin href="./assets/toggle-group-Cs-1L92l.js">
|
|
77
|
-
<link rel="modulepreload" crossorigin href="./assets/config-validation-events-
|
|
77
|
+
<link rel="modulepreload" crossorigin href="./assets/config-validation-events-zeI4vX-S.js">
|
|
78
78
|
<link rel="modulepreload" crossorigin href="./assets/agent-presence-DxGcS3q2.js">
|
|
79
|
-
<link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-
|
|
79
|
+
<link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-YeYpKBFl.js">
|
|
80
80
|
<link rel="modulepreload" crossorigin href="./assets/project-paths-CsGHlmFh.js">
|
|
81
81
|
<link rel="modulepreload" crossorigin href="./assets/mcp-consent-store-CijO54Jd.js">
|
|
82
82
|
<link rel="stylesheet" crossorigin href="./assets/DocumentContext-B0sQn39F.css">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as e,n as t}from"./init-
|
|
2
|
-
//# sourceMappingURL=repair-launch-json-
|
|
1
|
+
import{h as e,n as t}from"./init-Bo84hmNW.mjs";import{t as n}from"./is-object-C-4FJ0rP.mjs";import{join as r}from"node:path";import{existsSync as i,readFileSync as a}from"node:fs";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],t];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))return`legacy-bare`}return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(t){let o=t.logger??u,c=r(t.projectDir,`.claude`,`launch.json`);if(t.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!i(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=a(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=e(t.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
|
|
2
|
+
//# sourceMappingURL=repair-launch-json-C2gaD3gB.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{D as e,d as t,g as n,j as r,k as i}from"./init-
|
|
2
|
-
//# sourceMappingURL=repair-mcp-configs-
|
|
1
|
+
import{D as e,d as t,g as n,j as r,k as i}from"./init-Bo84hmNW.mjs";import{t as a}from"./mcp-migrate-event-BF8ILHwp.mjs";import{homedir as o}from"node:os";function s(t){let n=t.logger??u,r=t.home??o(),a=[];if(t.reclaimDisableEnv===`1`)return n({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of e){let e=i[o],s=c(()=>e.configPath(``,r));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:e,home:r,cwd:``,configPath:s,configPathOverride:void 0,logger:n})),e.projectConfigPath){let r=e.projectConfigPath,i=c(()=>r(t.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:e,home:void 0,cwd:t.projectDir,configPath:i,configPathOverride:i,logger:n}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(e){let i={scope:e.scope,editorId:e.editorId,configPath:e.configPath},o=t(e.target,e.cwd,e.home,e.configPathOverride);if(o===null)return{...i,outcome:`no-entry`};if(r(o))return{...i,outcome:`canonical`};e.logger(a({scope:e.scope,surface:`cli-repair`,editorId:e.editorId,configPath:e.configPath,priorEntry:o}));let s=n(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(s.action===`failed`){let t=s.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:t}),{...i,outcome:`write-failed`,error:t}}return{...i,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
|
|
2
|
+
//# sourceMappingURL=repair-mcp-configs-BiXTTTVp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./repair-skills-BGPqLLPt.mjs";export{e as repairSkills};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./esm-CEs3LWY3.mjs";import{bi as t,cr as n,fr as r,ir as i,vr as a}from"./dist-
|
|
1
|
+
import{t as e}from"./esm-CEs3LWY3.mjs";import{bi as t,cr as n,fr as r,ir as i,vr as a}from"./dist-DeQtb-TH.mjs";import{t as o}from"./write-project-skill-ZPEnzf-i.mjs";import{dirname as s,join as c,resolve as l}from"node:path";import{existsSync as u,mkdirSync as d,readFileSync as f,readdirSync as p,rmSync as m,statSync as h,writeFileSync as g}from"node:fs";import{homedir as _}from"node:os";const v=[{hostDir:`.claude`,editorId:`claude`},{hostDir:`.cursor`,editorId:`cursor`},{hostDir:`.agents`,editorId:`codex`}],y=`open-knowledge-discovery`,b=[`.agents`,`skills`,y],x={existsSync:e=>u(e),isDirectory:e=>{try{return h(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>p(e),readFileSync:e=>f(e),writeFileSync:(e,t)=>{g(e,t)},mkdirSync:(e,t)=>{d(e,t)},rmSync:(e,t)=>{m(e,t)}},S={resolveProjectBundledSkillDir:()=>a(`project`,{checkDesktop:!1}),resolveDiscoveryBundledSkillDir:()=>a(`discovery`,{checkDesktop:!1}),readBundledVersion:()=>i(),readRecordedVersion:e=>n(e,`cli-hosts`),writeRecordedVersion:(e,n)=>t(e,`cli-hosts`,n,`cli-start`),recordEvent:e=>r(e)};function C(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function w(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(s(t),{recursive:!0}),T(e,t,n)}function T(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=c(e,r),a=c(t,r);n.isDirectory(i)?T(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function E(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of v){let s=c(e,t.hostDir,`skills`,`open-knowledge`),l=c(s,`SKILL.md`);if(!n.existsSync(l)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:s,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:s});continue}try{o(s,e),w(i,s,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:s,outcome:`reclaimed`}),r({event:`project-skill-reclaim-reclaimed`,scope:`project`,editorId:t.editorId,path:s})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:s,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:s,error:n})}}return{outcome:`done`,entries:a}}async function D(e,t,n,r){let i=e=>{t.recordEvent(e).catch(()=>{})},a=()=>new Date().toISOString(),o;try{o=await t.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let s;try{s=await t.readRecordedVersion(e)}catch(e){r({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),s=null}if(s!==null&&s===o)return r({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:o}),{outcome:`skipped`,reason:`version-current`};let l;try{l=t.resolveDiscoveryBundledSkillDir()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`bundle-missing:${t}`}),{outcome:`skipped`,reason:`bundle-missing`}}let u=[],d=c(e,...b),f=n.existsSync(d);try{w(l,d,n),u.push({kind:`central`,path:d,outcome:f?`overwritten`:`written`}),r({event:`user-skill-reclaim-central-written`,scope:`user`,path:d,preexisting:f,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);u.push({kind:`central`,path:d,outcome:`failed`,error:t}),r({event:`user-skill-reclaim-central-failed`,scope:`user`,path:d,error:t})}for(let t of v){let i=c(e,t.hostDir),a=c(i,`skills`,y);if(a===d){u.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-collapsed-with-central`});continue}if(!n.existsSync(i)){u.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-host-absent`});continue}let s=n.existsSync(a);try{w(l,a,n),u.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:s?`overwritten`:`written`}),r({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,preexisting:s,version:o})}catch(e){let n=e instanceof Error?e.message:String(e);u.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`failed`,error:n}),r({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,error:n})}}let p=u.find(e=>e.kind===`central`);if(p?.outcome===`written`||p?.outcome===`overwritten`){let n=null;try{await t.writeRecordedVersion(e,o),r({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:o})}catch(e){n=e instanceof Error?e.message:String(e),r({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:o,error:n})}i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:n===null?`installed`:`failed`,version:o,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=u.some(e=>e.kind===`host`&&e.outcome===`failed`);i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,version:o,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:o,entries:u}}async function O(e){let t=e.logger??C,n=e.fs??x,r=e.home??_(),i={...S,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:E(e.projectDir,i,n,t),user:await D(r,i,n,t)}}function k(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function A(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`no-token`).length,i=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} no-token, ${i} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
|
|
2
2
|
`)}function j(){return new e(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").action(async()=>{let e=await O({projectDir:l(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${A(e)}\n`),process.exitCode=k(e)})}export{j as n,O as t};
|
|
3
|
-
//# sourceMappingURL=repair-skills-
|
|
3
|
+
//# sourceMappingURL=repair-skills-BGPqLLPt.mjs.map
|
|
@@ -424,5 +424,5 @@ $2`).split(`
|
|
|
424
424
|
`;return l.join(f)},table(e,t,n,r){let i=n.enter(`table`),a=[],o=[],s=e.children??[];for(let e of s){let t=e.children??[],i=[],s=[];for(let e of t){let t=n.enter(`tableCell`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,{...r,before:` `,after:` `});a(),t(),i.push(o);let c=e.data?.sourcePadding;s.push(c&&typeof c.left==`number`&&typeof c.right==`number`?{left:c.left,right:c.right}:null)}a.push(i),o.push(s)}i();let c=e.align??[],l=e.data?.sourceDashCounts,u=a[0]?.length??0,d=a.slice(1).reduce((e,t)=>Math.max(e,t.length),0),f=Math.max(u,d,c.length),p=[];for(let e=0;e<f;e++){let t=c[e],n=``,r=``;t===`center`?(n=`:`,r=`:`):t===`left`?n=`:`:t===`right`&&(r=`:`);let i=l?.[e],a=typeof i==`number`&&i>=1?i:1;p.push(n+`-`.repeat(a)+r)}let m=(e,t)=>{let n=[];for(let r=0;r<f;r++){let i=e[r]??``,a=t[r]??{left:1,right:1};n.push(` `.repeat(a.left)+i+` `.repeat(a.right))}return`|${n.join(`|`)}|`},h=Array.from({length:f},()=>null);if(a.length===0)return m(p,h);let g=[];g.push(m(a[0],o[0]??[])),g.push(m(p,h));for(let e=1;e<a.length;e++)g.push(m(a[e],o[e]??[]));return g.join(`
|
|
425
425
|
`)},mdxJsxFlowElement(e,t,n,r){let i=e,a=i.data?.sourceRaw;if(typeof a==`string`)return a;let o=i.data?.htmlBoundary;if(o&&typeof o.opener==`string`&&typeof o.closer==`string`){let e=n.containerFlow({type:`root`,children:i.children??[]},r);return`${o.opener}\n\n${e}\n\n${o.closer}`}let s=i.name??``,c=OZ(i.attributes??[]);if(!i.children||i.children.length===0)return s?c?`<${s} ${c} />`:`<${s} />`:``;let l=c?`<${s} ${c}>`:`<${s}>`,u=`</${s}>`;return`${l}\n\n${n.containerFlow({type:`root`,children:i.children},r)}\n\n${u}`},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),o+=i.move(`==`),a(),o},comment(e,t,n,r){let i=e.data?.sourceForm,a=i===`html`?`<!-- `:`%%`,o=i===`html`?` -->`:`%%`,s=n.createTracker(r),c=n.enter(`comment`),l=s.move(a);return l+=n.containerPhrasing(e,{before:l,after:o,...s.current()}),l+=s.move(o),c(),l},commentBlock(e,t,n,r){let i=n.createTracker(r),a=n.enter(`commentBlock`),o=e.children??[],s=e.data?.sourceForm,c=e.data?.sourceLayout,l=o.length===1&&o[0]?.type===`paragraph`;if(s===`html`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`<!-- `,after:` -->`,...i.current()});return a(),`<!-- ${t} -->`}if(c===`inline`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`%% `,after:` %%`,...i.current()});return a(),`%% ${t} %%`}let u=n.containerFlow(e,i.current());return a(),`%%\n\n${u}\n\n%%`},mdxJsxTextElement(e){let t=e.data?.sourceRaw;if(typeof t==`string`)return t;let n=e.name??``,r=OZ(e.attributes??[]);return r?`<${n} ${r} />`:`<${n}/>`},rawMdxFallback(e){return e.value??``},blockquote(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.containerFlow(e,a.current());i();let s=e.data?.sourceMarkerSpacings,c=0;return n.indentLines(o,(e,t,n)=>n?`>`:s?.[c++]===`none`?`>${e}`:`> ${e}`)}};function OZ(e){let t=[];for(let n of e){if(n.type===`mdxJsxExpressionAttribute`){t.push(`{${n.value}}`);continue}let e=n.name;if(n.value===null||n.value===void 0){t.push(e);continue}if(typeof n.value==`string`){if(n.value.includes(`"`)){let r=n.value.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`);t.push(`${e}={"${r}"}`)}else t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function kZ(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function AZ(e){if(!e)return``;let t=0,n=!0;for(let r of e)r===`(`?t++:r===`)`&&(t--,t<0&&(n=!1));return t!==0&&(n=!1),n?e:e.replace(/[\\()]/g,`\\$&`)}function jZ(e){return e.replace(/(?<!\\)&(?=[A-Za-z][A-Za-z0-9]*;|#[0-9]+;|#[xX][0-9A-Fa-f]+;)/g,`\\&`)}function MZ(e,t,n){let r=e.unsafe;e.unsafe=r.filter(e=>!(e.character===`&`&&e.after===`[#A-Za-z]`||e.character===`<`||e.character===`[`||e.character===`(`||e.character==="`"));let i;try{i=e.safe(t,n)}finally{e.unsafe=r}return jZ(i)}function NZ(e){if(!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KiB`,`MiB`,`GiB`,`TiB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(1).replace(/\.0$/,``)} ${t[r]}`}var PZ=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};constructor(e){this.schema=Fy(e.extensions),this.handlers=WZ(this.schema,this.parseCtx);let{nodeHandlers:t,markHandlers:n}=GZ(this.schema);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=vZ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=yZ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers,toMarkdownHandlers:DZ})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return bZ(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?xZ(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?qJ(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e){let t;try{t=this.schema.nodeFromJSON(e)}catch(t){let n=`MarkdownManager.serialize() failed: schema rejected JSONContent (type=${e.type}, childCount=${e.content?.length??0})`;throw Error(n,{cause:t})}return SZ(t,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}};const FZ=IJ();function IZ(e,t){let n=new Map;for(let e of t)n.set(e.name,e);let r={};for(let t of e){if(t.type===`mdxJsxExpressionAttribute`)continue;let e=t.name,i=n.get(e);if(t.value===null||t.value===void 0){r[e]=!0;continue}if(typeof t.value==`string`){if(i?.type===`number`){let n=Number(t.value);r[e]=Number.isNaN(n)?t.value:n}else i?.type===`boolean`?r[e]=t.value===`true`:r[e]=t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function LZ(e){let t=!1;return e.descendants(e=>t||e.type.name===`jsxInline`?!1:e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function RZ(e){return e.attrs.sourceDirty||LZ(e)}function zZ(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0?!0:t.every(e=>e.type===`text`&&e.value===``)}function BZ(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),Object.keys(n).length===0?e:{...e,data:n}}function VZ(e,t){if(e.length===0)return BZ({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return BZ({type:`inlineCode`,value:e.map(e=>e.value).join(``)},t);if(e.length===1&&`children`in e[0]){let n=e[0];return{...n,children:[VZ(n.children,t)]}}return BZ({type:`inlineCode`,value:HZ(e)},t)}function HZ(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=HZ(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const UZ=zG;function WZ(e,t){let n=e.nodes,r=e.marks,i={};n.paragraph&&(i.paragraph=(e,t,r)=>{let i=r.all(e).flat(),a=i.some(e=>e?.isBlock&&!e?.isInline),o=i.some(e=>e?.isInline||e?.isText||e?.isTextblock);if(a&&!o)return i.length===1?i[0]:i;if(a&&o){let e=i.filter(e=>!e?.isBlock||e?.isInline),t=i.filter(e=>e?.isBlock&&!e?.isInline),r=[],a=n.paragraph.createAndFill(null,e.length>0?e:null);return a&&r.push(a),r.push(...t),r.length===1?r[0]:r}return n.paragraph.createAndFill(null,i.length>0?i:null)}),n.blockquote&&(i.blockquote=KL(n.blockquote,e=>({sourceMarkerSpacings:e.data?.sourceMarkerSpacings??null}))),n.tableCell&&(i.tableCell=(e=>(t,r,i)=>{let a=i.all(t).flat();if(a.length>0&&n.paragraph){let t=n.paragraph.create(null,a);return e.createAndFill(null,[t])}return e.createAndFill(null,null)})(n.tableCell)),n.tableRow&&(i.tableRow=KL(n.tableRow)),n.table&&n.tableRow&&n.tableCell&&(i.table=(e,t,r)=>{let i=e.align??[],a=e.children??[],o=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type!==`tableRow`)continue;let s=t.children??[],c=[];for(let t=0;t<s.length;t++){let a=s[t];if(a.type!==`tableCell`)continue;let o=r.all(a).flat(),l=o.length>0&&n.paragraph?[n.paragraph.create(null,o)]:null,u=i[t]??null,d=e===0&&n.tableHeader?n.tableHeader:n.tableCell,f=a.data?.sourcePadding??null,p=d.createAndFill({align:u,sourcePadding:f},l);p&&c.push(p)}let l=n.tableRow.createAndFill(null,c.length>0?c:null);l&&o.push(l)}let s=e.data?.sourceDashCounts??null;return n.table.createAndFill({sourceDashCounts:s},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=EZ(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r})},n.imageReference?i.imageReference=e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):i.imageReference=e=>n.image.createAndFill({src:``,alt:e.alt??null,title:null})),r.escapeMark&&(i.text=t=>{let n=t.value??``,i=typeof t.data?.sourceRaw==`string`?t.data.sourceRaw:null;if(!n&&!i)return null;if(i){let t=n.replaceAll(`\xA0`,` `);return r.sourceLiteral?e.text(t,[r.sourceLiteral.create({sourceRaw:i})]):e.text(t)}let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n.replaceAll(`\xA0`,` `));let s=[...(a??[]).map(e=>({kind:`escape`,offset:e.offset,length:1})),...(o??[]).map(e=>({kind:`entity`,offset:e.offset,length:e.length,raw:e.raw}))];s.sort((e,t)=>e.offset-t.offset);let c=[],l=0;for(let t of s){if(t.offset>l){let r=n.slice(l,t.offset).replaceAll(`\xA0`,` `);r&&c.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length).replaceAll(`\xA0`,` `);i&&(t.kind===`escape`?c.push(e.text(i,[r.escapeMark.create()])):r.sourceLiteral?c.push(e.text(i,[r.sourceLiteral.create({sourceRaw:t.raw})])):c.push(e.text(i))),l=t.offset+t.length}}if(l<n.length){let t=n.slice(l).replaceAll(`\xA0`,` `);t&&c.push(e.text(t))}return c.length===1?c[0]:c}),r.code&&(i.inlineCode=t=>e.text(t.value,[r.code.create({sourceFenceChar:t.data?.sourceFenceChar??"`",sourceFenceLength:typeof t.data?.sourceFenceLength==`number`?t.data.sourceFenceLength:1})]));let a=r.strike??r.delete;if(a&&(i.delete=qL(a)),r.highlight&&(i.mark=qL(r.highlight)),r.comment&&(i.comment=qL(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=KL(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=qL(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=qL(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=KL(n.heading,e=>({level:e.depth,headingStyle:e.data?.sourceStyle??`atx`,sourceTrailingHashes:e.data?.sourceTrailingHashes??null,sourceUnderlineLength:e.data?.sourceUnderlineLength??null,sourceContiguousNext:e.data?.sourceContiguousNext??!1}))),n.codeBlock&&(i.code=t=>{let r=t.value?[e.text(t.value)]:[];return n.codeBlock.createAndFill({language:t.lang??null,meta:t.meta??null,fenceDelimiter:t.data?.sourceFenceChar??"`",fenceLength:t.data?.sourceFenceLength??3,sourceStyle:t.data?.sourceStyle??`fenced`},r)}),n.thematicBreak&&(i.thematicBreak=e=>n.thematicBreak.createAndFill({sourceRaw:e.data?.sourceRaw??`---`})),n.hardBreak&&(i.break=e=>n.hardBreak.createAndFill({hardBreakStyle:e.data?.sourceStyle??`spaces`})),n.list&&(i.list=KL(n.list,e=>({ordered:!!e.ordered,start:e.start??1,spread:!!e.spread,bulletMarker:e.data?.bulletMarker??null,listMarkerDelimiter:e.data?.listMarkerDelimiter??null}))),n.listItem&&(i.listItem=KL(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread}))),r.link){let t=r.sourceLiteral;i.link=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[](${n.url??``})`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.url??``,title:n.title??null,linkStyle:n.data?.sourceStyle??`inline`,refLabel:null,sourceUrlForm:n.data?.sourceUrlForm??null,sourceTitleMarker:n.data?.sourceTitleMarker??null});return o.map(e=>e.mark(s.addToSet(e.marks)))},i.linkReference=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[${n.label??``}][${n.identifier??``}]`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:``,title:null,linkStyle:n.referenceType??`shortcut`,refLabel:n.label??n.identifier??null});return o.map(e=>e.mark(s.addToSet(e.marks)))}}n.htmlBlock&&(i.html=e=>n.htmlBlock.createAndFill({content:e.value??``}));let o=n.linkDefinition??n.linkRefDef;if(o){let e=!!o.spec.attrs?.url,t=!!o.spec.attrs?.href,n=!!o.spec.attrs?.identifier,r=!!o.spec.attrs?.sourceLayout,a=!!o.spec.attrs?.sourceTitleMarker;i.definition=i=>{let s={title:i.title??null};return n&&(s.identifier=i.identifier??``),s.label=i.label??i.identifier??``,e?s.url=i.url??``:t&&(s.href=i.url??``),r&&(s.sourceLayout=i.data?.sourceLayout??null),a&&(s.sourceTitleMarker=i.data?.sourceTitleMarker??null),o.createAndFill(s)}}if(n.jsxComponent){let r=e=>{if(e&&typeof e==`object`&&`sourceRaw`in e){let t=e.sourceRaw;if(typeof t==`string`)return t}};i.mdxJsxFlowElement=(e,i,a)=>{let o=e.name??``,s=FZ.getOrWildcard(o),c=IZ(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=EZ(e,t.current.sourcePath);n!==e&&(c.src=n,c.sourceUrl=e)}let l=a.all(e).flat();return n.jsxComponent.createAndFill({componentName:o,kind:`element`,attributes:e.attributes,sourceRaw:r(e.data)??``,sourceDirty:!1,props:c},l.length?l:void 0)};let a=(e,t)=>{let n=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return n&&typeof n.value==`string`?n.value:null};i.mdxJsxTextElement=t=>{if(t.name===`InlineMath`&&n.mathInline){let e=a(t,`formula`)??``,r=a(t,`id`);return n.mathInline.create({formula:e,id:r??null})}if(t.name===`Tag`&&n.tag){let e=a(t,`value`)??``;return n.tag.create({value:e})}if(n.jsxInline){let i=r(t.data)??``;return n.jsxInline.createAndFill({},i?[e.text(i)]:null)}return n.jsxComponent.createAndFill({sourceRaw:r(t.data)??``})},i.mdxFlowExpression=e=>{let t=r(e.data)??`{${e.value??``}}`;return n.jsxComponent.createAndFill({kind:`expression`,sourceRaw:t,sourceDirty:!1})},i.mdxTextExpression=t=>{let n=r(t.data)??`{${t.value??``}}`;return e.text(n)}}return n.wikiLink&&(i.wikiLink=e=>n.wikiLink.createAndFill({target:e.data?.target??``,alias:e.data?.alias??null,anchor:e.data?.anchor??null})),n.tag&&(i.tag=e=>n.tag.createAndFill({value:e.value})),n.wikiLinkEmbed&&(i.wikiLinkEmbed=(i,a)=>{let o=i.data?.target??``,s=i.data?.alias??null,c=i.data?.anchor??null,l=tq(o),{resolveEmbed:u,sourcePath:d}=t.current,f=u&&d?u(o,d)??null:null,p=f?`/${f}`:o,m=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(m&&UZ.has(l)&&n.jsxComponent&&FZ.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,alt:s??o,target:o,anchor:c,alias:s}});if(m&&BG.has(l)&&n.jsxComponent&&FZ.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&HG.has(l)&&n.jsxComponent&&FZ.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&UG.has(l)&&n.jsxComponent&&FZ.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&d?e(o,d)??null:null,i=r===null?null:NZ(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,target:o,anchor:c,alias:s,size:i}})}let h=s||(c?`${o}#${c}`:o);if(JG.has(l)&&r.link){let t=r.link.create({href:p,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s});return e.text(h,[t])}if(r.link){let t=r.link.create({href:o,title:null,linkStyle:`inline`,refLabel:null});return e.text(h,[t])}throw Error("[wikiLinkEmbed handler] schema lacks `link` mark — cannot dispatch without violating the STOP rule against emitting PM wikiLinkEmbed server-side")}),n.mathInline&&(i.inlineMath=e=>n.mathInline.create({formula:e.value??``})),i.math||=t=>{let r=t.value==null?`«unknown:${t.type}»`:t.value;return n.rawMdxFallback?(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled block mdast: ${t.type}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled block mdast: ${t.type}`},r?[e.text(r)]:null)):null},i.inlineMath||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled inline mdast: ${t.type}`})),t.value==null?e.text(`«unknown:${t.type}»`):e.text(t.value)),n.footnoteReference?i.footnoteReference=e=>n.footnoteReference.create({identifier:e.identifier,label:e.label??e.identifier}):i.footnoteReference||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteReference`,reason:`FootnoteReference extension missing — recovering [^id] source`})),e.text(`[^${t.label??t.identifier}]`)),n.footnoteDefinition?i.footnoteDefinition=KL(n.footnoteDefinition,e=>{let t=e;return{identifier:t.identifier,label:t.label??t.identifier}}):i.footnoteDefinition||=t=>{console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteDefinition`,reason:`FootnoteDefinition extension missing — recovering [^id]: marker`}));let r=`[^${t.label??t.identifier}]: `;return n.paragraph?n.paragraph.create(null,e.text(r)):null},i.rawMdxFallbackMdast=t=>{if(!n.rawMdxFallback)return null;let r=t.position?{start:t.position.start?.offset??0,end:t.position.end?.offset??0}:{start:0,end:0};return console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.originalType,reason:`Unhandled mdast: ${t.originalType}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled mdast: ${t.originalType}`,originalSpan:r},t.value?[e.text(t.value)]:null)},i}function GZ(e){let t={},n={},r=e.nodes,i=e.marks;r.paragraph&&(t.paragraph=QL(`paragraph`)),r.blockquote&&(t.blockquote=QL(`blockquote`,e=>{let t=e.attrs.sourceMarkerSpacings,n={};return Array.isArray(t)&&t.length>0&&(n.sourceMarkerSpacings=t),Object.keys(n).length>0?{data:n}:{}})),r.heading&&(t.heading=QL(`heading`,e=>({depth:e.attrs.level,data:{sourceStyle:e.attrs.headingStyle,sourceTrailingHashes:e.attrs.sourceTrailingHashes??void 0,sourceUnderlineLength:e.attrs.sourceUnderlineLength??void 0,sourceContiguousNext:e.attrs.sourceContiguousNext===!0?!0:void 0}}))),r.codeBlock&&(t.codeBlock=e=>{let t=e.attrs.sourceStyle===`indented`?`indented`:`fenced`;return{type:`code`,lang:t===`indented`?null:e.attrs.language??null,meta:t===`indented`?null:e.attrs.meta??null,value:e.textContent??``,data:{sourceFenceChar:e.attrs.fenceDelimiter,sourceFenceLength:e.attrs.fenceLength,sourceStyle:t}}}),r.thematicBreak&&(t.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),r.hardBreak&&(t.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle}})),r.list&&(t.list=QL(`list`,e=>({ordered:e.attrs.ordered??!1,start:e.attrs.ordered?e.attrs.start??1:null,spread:e.attrs.spread??!1,data:{bulletMarker:e.attrs.bulletMarker,listMarkerDelimiter:e.attrs.listMarkerDelimiter}}))),r.listItem&&(t.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&zZ(r[0])?r.slice(1):r;return{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,children:i}}),r.table&&(t.table=(e,t,n)=>{let r=n.all(e),i=[],a=e.firstChild;a&&a.forEach(e=>{let t=e.attrs.align;i.push(t===`left`||t===`right`||t===`center`?t:null)});let o=r.filter(e=>e.type===`tableRow`),s=e.attrs.sourceDashCounts,c=Array.isArray(s)&&s.length>0?{sourceDashCounts:s}:void 0,l={type:`table`,align:i,children:o};return c&&(l.data=c),l}),r.tableRow&&(t.tableRow=QL(`tableRow`));let a=e=>{let t=e.attrs.sourcePadding,n={};return typeof t==`object`&&t&&typeof t.left==`number`&&typeof t.right==`number`&&(n.sourcePadding=t),Object.keys(n).length>0?{data:n}:{}};if(r.tableCell&&(t.tableCell=QL(`tableCell`,a)),r.tableHeader&&(t.tableHeader=QL(`tableCell`,a)),r.image&&(t.image=e=>({type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title})),r.imageReference&&(t.imageReference=e=>{let t=e.attrs.label??``,n=e.attrs.identifier??t;return{type:`imageReference`,alt:e.attrs.alt??``,identifier:n,label:t||n,referenceType:e.attrs.referenceType??`shortcut`}}),r.htmlBlock&&(t.htmlBlock=e=>({type:`html`,value:e.attrs.content})),r.linkDefinition??r.linkRefDef){let e=r.linkDefinition?`linkDefinition`:`linkRefDef`;t[e]=e=>{let t={},n=e.attrs.sourceLayout;(n===`multiline`||n===`inline`)&&(t.sourceLayout=n);let r=e.attrs.sourceTitleMarker;(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r);let i={type:`definition`,identifier:e.attrs.identifier??e.attrs.label??``,label:e.attrs.label??e.attrs.identifier??``,url:e.attrs.url??e.attrs.href??``,title:e.attrs.title};return Object.keys(t).length>0&&(i.data=t),i}}if(r.jsxComponent&&(t.jsxComponent=(e,t,n)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let r=e.attrs.componentName||null,i=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!RZ(e)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:r,attributes:i,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:FZ.getOrWildcard(r??`*`).serialize(e,{all:e=>n.all(e),registry:FZ,serializeChildren:()=>{throw Error(`SerializeContext.serializeChildren is not available in the PM→mdast handler. Compat descriptors that need markdown-byte body rendering must emit a marker mdast node and let the to-markdown handler render the body via state.containerFlow.`)}})}),r.rawMdxFallback&&(t.rawMdxFallback=e=>{let t=e.textContent??``,n=typeof e.attrs.reason==`string`?e.attrs.reason:``,r=e.attrs.originalSpan;return{type:`rawMdxFallback`,value:t,data:{reason:n,originalSpan:r&&typeof r==`object`&&`start`in r&&`end`in r?{start:Number(r.start)||0,end:Number(r.end)||0}:{start:0,end:0}}}}),r.jsxInline&&(t.jsxInline=e=>{let t=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:null,attributes:[],children:[],data:{sourceRaw:String(t)}}}),r.mathInline&&(t.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;return typeof n==`string`&&n.length>0?{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]}:{type:`inlineMath`,value:t}}),r.wikiLink&&(t.wikiLink=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLink`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),r.tag&&(t.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),r.wikiLinkEmbed&&(t.wikiLinkEmbed=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),i.emphasis&&(n.emphasis=$L(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.strong&&(n.strong=$L(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.code&&(n.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return VZ(n,{sourceFenceChar:r,sourceFenceLength:i})}),i.strike??i.delete){let e=i.strike?`strike`:`delete`;n[e]=$L(`delete`)}return i.highlight&&(n.highlight=$L(`mark`)),i.comment&&(n.comment=$L(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),r.commentBlock&&(t.commentBlock=QL(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),r.footnoteReference&&(t.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),r.footnoteDefinition&&(t.footnoteDefinition=QL(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),i.link&&(n.link=(e,t,n)=>{if(e.attrs.sourceForm===`wikiembed`){let t=typeof e.attrs.target==`string`&&e.attrs.target.length>0?e.attrs.target:e.attrs.href??``,n=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,r=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}let r=e.attrs.linkStyle;if(r===`autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`autolink`}};if(r===`gfm-autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`gfm-autolink`}};if(r===`inline`||!r){let t={};e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let r=e.attrs.sourceTitleMarker;return(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),{type:`link`,url:e.attrs.href??``,title:e.attrs.title??null,children:n,...Object.keys(t).length>0?{data:t}:{}}}return{type:`linkReference`,identifier:(e.attrs.refLabel??``).toLowerCase(),label:e.attrs.refLabel,referenceType:r,children:n}}),i.escapeMark&&(n.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data=t.data??{},t.data.escapedChars=t.data.escapedChars??[];for(let e=0;e<t.value.length;e++)t.data.escapedChars.push({offset:e,char:t.value[e]})}return n.length===1?n[0]:n}),i.sourceLiteral&&(n.sourceLiteral=(e,t,n)=>{let r=typeof e.attrs.sourceRaw==`string`?e.attrs.sourceRaw:``;if(n.length===1&&n[0]?.type===`text`){let e=n[0],t=r||e.value;return UK(t,e.value)&&(e.data=e.data??{},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:t,markHandlers:n}}const KZ=/\p{M}+/gu,qZ=/[^\p{L}\p{N}]+/gu,JZ=/^-+|-+$/g;function YZ(e){return e.trim().normalize(`NFKD`).replace(KZ,``).toLowerCase().replace(qZ,`-`).replace(JZ,``)}function XZ(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function ZZ(e,t){let n=YZ(e);return n?XZ(n,t):``}const QZ=HB(),$Z=oB(),eQ=sB();function tQ(){return PJ.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function nQ(){return tQ().filter(e=>rQ(e)!==`fence`)}function rQ(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function iQ(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:rQ(e)}}function aQ(e){if(e.hidden!==!0&&e.type!==`reactnode`){if(`defaultValue`in e&&e.defaultValue!==void 0)return e.defaultValue;if(e.type===`enum`)return e.enumValues[0];if(e.type===`string`)return``;if(e.type===`number`)return 0;if(e.type===`boolean`)return!1}}function oQ(e,t){return!(e.omitOnDefault===!0&&`defaultValue`in e&&Object.is(e.defaultValue,t)||e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&t===``)}function sQ(e){let t=[];for(let n of e.props){let e=aQ(n);e!==void 0&&oQ(n,e)&&t.push(qq(n.name,e))}return t}function cQ(e){return mz(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[QZ],mdastExtensions:[$Z]}).children}function lQ(e){let t=rQ(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
|
|
426
426
|
A --> B`};else{let r=sQ(e),i=t===`jsx-block`?cQ(e):[];n={type:`mdxJsxFlowElement`,name:e.name,attributes:r,children:i}}return cP({type:`root`,children:[n]},{extensions:[eQ]}).trimEnd()}function uQ(e){let t=[];for(let n of e.props){if(n.hidden===!0)continue;let e={name:n.name,type:n.type,required:n.required};n.description!==void 0&&(e.description=n.description),n.advanced===!0&&(e.advanced=!0),n.omitOnDefault===!0&&(e.omitOnDefault=!0),n.type===`enum`&&(e.values=n.enumValues,n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue)),n.type===`string`&&(n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.language!==void 0&&(e.language=n.language),n.accept!==void 0&&(e.accept=n.accept)),n.type===`boolean`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.type===`number`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),t.push(e)}return t}function dQ(e){return{...iQ(e),example:lQ(e),params:uQ(e)}}function fQ(){return[``,"**Custom canonical components.** OK `.md` / `.mdx` supports the JSX components below — use whichever is semantically useful in any part of the doc. For full source syntax + parameter schemas, call `get_components({ ids })` with the ids you want to use. Fenced code blocks render naturally and don't need a fetch — including ` ```mermaid ` for diagrams and ` ```html preview ` for interactive HTML/JS/CSS pages (the fence info-string `preview` token renders the block as a live iframe; works for `html` / `htm` / `xml`; optional `h=` / `w=` tokens set size, e.g. ` ```html preview h=400px `). Use ` ```html preview ` whenever you want anything interactive or JS-powered (charts, demos, calculators, animations) — just author the standalone HTML page in the fence. Call `get_authoring_palette` for the markdown-native component forms (write `> [!NOTE]`, not `<Callout>`), copy-ready themed `html preview` starters, and the theme tokens (`var(--chart-1)`, `var(--foreground)`, …) an embed should reference so it tracks the reader's light/dark theme. Arbitrary `<TagName>` JSX falls through as raw MDX when no canonical fits.",``,...nQ().map(iQ).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
|
|
427
|
-
`)}const pQ=M({docName:dq,summary:mq,content:k().optional(),...pq}).loose(),mQ=M({docName:dq,summary:mq,markdown:k(),position:N([`append`,`prepend`,`replace`]).optional(),...pq}).loose(),hQ=M({docName:dq,summary:mq,find:k().min(1),replace:k(),offset:A().int().nonnegative().optional(),...pq}).loose(),gQ=M({docName:dq,connectionId:k().min(1),scope:N([`last`,`session`,`file`]).optional(),...pq}).loose(),_Q=M({value:k(),truncatedFrom:A().int().nonnegative().optional(),hint:k().optional()}).loose(),vQ=M({type:P(`orphan`),parentCandidates:j(k()),message:k()}).loose(),yQ=M({timestamp:k().min(1),summary:_Q.optional()}).loose(),bQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:j(vQ).optional(),summary:_Q.optional()}).loose(),xQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:_Q.optional()}).loose(),SQ=M({docName:k().min(1),scope:N([`last`,`session`]),undone:Ls()}).loose(),CQ=M({docName:dq,patch:nc(k(),Xs([Mc,zs()])),types:nc(k(),N(jc)).optional(),summary:mq,...pq}).loose(),wQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:j(k()),summary:_Q.optional()}).loose(),TQ=M({entries:j(M({level:N([`info`,`warn`,`error`]),message:k().max(8192),event:k().optional(),fields:nc(k(),Us()).optional(),ts:A().optional(),sourceId:k().optional(),lineNumber:A().optional()}).loose()).max(100)}).loose(),EQ=M({accepted:A().int().min(0)}).loose(),DQ=M({status:k().min(1),reason:k()}).loose(),OQ=M({docName:k().min(1),content:k(),lifecycle:DQ.nullable()}).loose(),kQ=M({documents:j(M({kind:N([`document`,`asset`,`folder`]).default(`document`),docName:k().min(1).optional(),docExt:k().min(1).default(`.md`),size:A().int().nonnegative(),modified:k().min(1),isSymlink:Ls().default(!1),canonicalDocName:k().nullable().default(null),targetPath:k().nullable().default(null),path:k().min(1).optional(),assetExt:k().min(1).optional(),mediaKind:N([`image`,`video`,`audio`,`pdf`,`text`]).nullable().optional(),referencedBy:j(k().min(1)).optional(),hasChildren:Ls().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName)`})),truncated:Ls().optional()}).loose(),AQ=M({source:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),jQ=M({docName:k().min(1),backlinks:j(AQ)}).loose(),MQ=M({counts:nc(k().min(1),A().int().nonnegative())}).loose(),NQ=Qs(`kind`,[M({kind:P(`doc`),docName:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),M({kind:P(`external`),url:k().min(1),title:k(),snippet:k().nullable()}).loose()]),PQ=M({docName:k().min(1),forwardLinks:j(NQ)}).loose(),FQ=Qs(`kind`,[M({id:k().min(1),kind:P(`doc`),docName:k().min(1),anchor:k().nullable(),label:k(),cluster:k().nullable(),category:k().nullable(),tags:j(k()).nullable()}).loose(),M({id:k().min(1),kind:P(`external`),url:k().min(1),label:k()}).loose()]),IQ=M({source:k().min(1),target:k().min(1)}).loose(),LQ=M({nodes:j(FQ),links:j(IQ)}).loose(),RQ=M({ts:A().int().min(0),url:k(),method:k(),ua:k().optional(),origin:k().optional(),referer:k().optional(),host:k().optional(),remote:k().optional(),secChUa:k().optional(),secChUaMobile:k().optional(),secChUaPlatform:k().optional(),secFetchSite:k().optional(),secFetchDest:k().optional(),secFetchMode:k().optional(),secFetchUser:k().optional()}).loose(),zQ=M({app:Xs([P(`cursor`),P(`codex`),P(`claude`),zs()]),signals_fired:j(k())}).loose(),BQ=M({entries:j(RQ),count:A().int().min(0),detection:zQ}).loose(),VQ=M({writers:j(M({id:k().min(1),name:k().optional(),email:k().optional()}).loose()).optional(),...pq}).loose(),HQ=M({checkpointRef:k().min(1)}).loose(),UQ=M({v:A().int().optional(),id:k().min(1),name:k().min(1),colorSeed:k().optional(),docs:j(k()),summaries:j(k()).optional()}).loose(),WQ=M({entries:j(M({sha:k().min(1),timestamp:k().min(1),author:k(),authorEmail:k(),type:N([`checkpoint`,`wip`,`upstream`,`park`]),message:k(),contributors:j(UQ),checkpoint:Us().nullable()}).loose()),total:A().int().nonnegative().optional(),truncated:Ls().optional()}).loose(),GQ=M({sha:k().regex(/^[0-9a-f]{40}$/i),content:k(),timestamp:k(),author:k()}).loose(),KQ=M({lines:j(M({type:N([`added`,`removed`,`unchanged`]),text:k()}).loose()),additions:A().int().nonnegative(),deletions:A().int().nonnegative()}).loose(),qQ=M({contentDir:k().min(1),pathSeparator:N([`/`,`\\`]),symlinkResolved:Ls()}).loose(),JQ=j(Qs(`source`,[M({docName:k().min(1),timestamp:k().min(1),size:A().int().nonnegative(),source:P(`flat`)}).loose(),M({docName:k().min(1),timestamp:k().min(1),source:P(`timeline`),sha:k().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),YQ=M({orphans:j(M({docName:k().min(1),title:k()}).loose())}).loose(),XQ=M({hubs:j(M({docName:k().min(1),title:k(),count:A().int().nonnegative()}).loose())}).loose(),ZQ=M({source:k().min(1),title:k(),snippet:k().nullable()}).loose(),QQ=M({deadLinks:j(M({target:k().min(1),sources:j(ZQ)}).loose())}).loose(),$Q=M({target:M({docName:k().min(1),title:k(),aliases:j(k())}).loose(),mentions:j(M({source:k().min(1),excerpt:k(),offset:A().int().nonnegative()}).loose()),truncated:Ls()}).loose(),e$=M({dir:k().min(1),port:A().int().min(1).max(65535).optional()}).loose(),t$=M({port:A().int().positive()}).loose(),n$=M({projectPath:k().min(1)}).loose(),r$=N([`not-a-git-worktree`,`init-failed`]),i$=Qs(`ok`,[M({ok:P(!0),projectPath:k().min(1)}).loose(),M({ok:P(!1),reason:r$,message:k().min(1)}).loose()]),a$=M({host:k().min(1).optional()}).loose(),o$=M({pat:k().min(1),host:k().min(1).optional()}).loose(),s$=M({name:k().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:k().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),c$=M({identity:M({name:k().min(1),email:k().min(1)}).loose().nullable()}).loose(),l$=M({authenticated:Ls()}).loose(),u$=M({type:P(`complete`).optional(),login:k().min(1).optional()}).loose(),d$=M({}).loose(),f$=M({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),p$=M({docName:k().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:j(f$)}).loose(),m$=M({displayName:k().min(1),color:k().min(1),icon:k().optional(),connectionId:k().min(1)}).loose(),h$=M({sessionAlive:Ls(),agent:m$.nullable(),files:j(p$)}).loose(),g$=M({diff:k(),generatedAt:A().int().min(0)}).loose(),_$=M({}).loose(),v$=M({}).loose(),y$=M({}).loose(),b$=M({}).loose(),x$=M({}).loose(),S$=M({displayName:k().min(1),icon:k(),color:k().min(1),currentDoc:k().nullable(),mode:N([`idle`,`writing`]),ts:A().int().min(0)}).loose(),C$=M({presence:nc(k().min(1),S$)}).loose(),w$=nc(k().min(1),Ls()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});M({path:k().min(1,`path must be non-empty`)}).loose();const T$=M({}).loose(),E$=M({fromDocName:k().min(1),toDocName:k().min(1)}).loose(),D$=M({fromPath:k().min(1),toPath:k().min(1)}).loose(),O$=M({}).loose(),k$=M({path:k().min(1),...pq,summary:mq}).loose(),A$=M({docName:k().min(1)}).loose(),j$=M({path:k().min(1),...pq,summary:mq}).loose(),M$=M({path:k().min(1)}).loose(),N$=M({kind:N([`file`,`folder`]),path:k().min(1),...pq,summary:mq}).loose(),P$=M({kind:N([`file`,`folder`]),path:k().min(1),duplicatedDocNames:j(k().min(1))}).loose(),F$=M({pages:j(M({docName:k().min(1),title:k(),docExt:k().min(1),size:A().int().nonnegative(),modified:k().min(1),icon:k().min(1).max(2048).optional()}).loose())}).loose(),I$=M({level:A().int().min(1).max(6),text:k(),slug:k()}).loose(),L$=M({docName:k().min(1),headings:j(I$)}).loose();M({docName:fq,newDocName:fq,summary:mq,...pq}).loose();const R$=M({docName:k().min(1),rewrites:A().int().nonnegative()}).loose();M({renamed:j(E$),rewrittenDocs:j(R$),summary:_Q.optional()}).loose();const z$=M({kind:N([`file`,`folder`,`asset`]),fromPath:k().min(1),toPath:k().min(1),...pq,summary:mq}).loose(),B$=M({renamed:j(E$),renamedAssets:j(D$),rewrittenDocs:j(R$).optional(),summary:_Q.optional()}).loose(),V$=M({kind:N([`file`,`folder`,`asset`]),path:k().min(1),...pq}).loose(),H$=M({deletedDocNames:j(k().min(1))}).loose(),U$=M({kind:N([`file`,`folder`,`asset`]),path:k().min(1),...pq,summary:mq}).loose(),W$=M({deletedDocNames:j(k().min(1))}).loose(),G$=M({docName:k().min(1),commitSha:k().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:mq,...pq}).loose(),K$=M({restoredFrom:k().min(1),timestamp:k().min(1),summary:_Q.optional()}).loose(),q$=N([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),J$=M({label:k().min(1),webUrl:_s().nullable()}).loose(),Y$=Qs(`checkStatus`,[M({checkStatus:P(`allowed`)}).loose(),M({checkStatus:P(`denied`),deniedReason:N([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),M({checkStatus:P(`unknown`),unknownError:N([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),X$=M({state:q$,lastSyncUtc:k().nullable(),lastFetchUtc:k().nullable(),lastPushedSha:k().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:Ls(),syncEnabled:Ls(),identityUnresolved:Ls(),remote:J$.nullable().optional(),error:k().optional(),errorCode:N([`auth-403`,`auth-401`,`auth-scope-mismatch`,`semantic-protected-branch`]).optional(),pausedReason:k().optional(),pushPermission:Y$.optional()}).loose(),Z$=M({op:N([`sync`,`push`,`pull`]).optional()}).loose(),Q$=M({op:N([`sync`,`push`,`pull`])}).loose(),$$=M({file:k().min(1),detectedAt:k().min(1),oursSha:k().optional(),theirsSha:k().optional(),baseSha:k().optional()}).loose(),e1=M({conflicts:j($$)}).loose(),t1=M({file:k().min(1),strategy:N([`mine`,`theirs`,`content`,`delete`]),content:k().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),n1=M({}).loose(),r1=M({file:k().min(1),base:k(),ours:k(),theirs:k(),kind:N([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:k().nullable()}).loose(),i1=M({}).loose(),a1=M({plan:Ec(e=>e!==void 0,{message:`plan is required`})}).loose(),o1=M({plan:Ec(e=>e!==void 0,{message:`plan is required`})}).loose(),s1=M({result:Ec(e=>e!==void 0,{message:`result is required`})}).loose(),c1=M({path:k().min(1),summary:k().min(1)}).loose(),l1=M({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),u1=M({packs:j(M({id:k().min(1),name:k().min(1),description:k().min(1),defaultSubfolder:k().optional(),folders:j(c1),entryCounts:l1}).loose())}).loose(),d1=M({noOpen:Ls().optional(),out:k().min(1).optional()}).loose(),f1=M({reason:N([`unsupported-platform`,`spawn-error`]),message:k()}).loose(),p1=Qs(`status`,[M({status:P(`installed`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k()}).loose(),M({status:P(`built`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k(),handoffError:f1.optional()}).loose(),M({status:P(`failed`),buildError:k()}).loose(),M({status:P(`skip-current`),skillVersion:k(),recordedAt:k().optional()}).loose()]),m1=M({tags:j(M({name:k().min(1),count:A().int().nonnegative(),isLeaf:Ls()}).loose())}).loose(),h1=M({docName:k().min(1),title:k(),matchingTags:j(k().min(1)),snippet:k().nullable()}).loose(),g1=M({name:k().min(1),docs:j(h1)}).loose(),_1=M({folder:Us(),frontmatter_local:nc(k(),Us()).nullable()}).loose(),v1=M({path:k(),frontmatter:nc(k(),Us()).optional()}).loose(),y1=M({applied:Us()}).loose(),b1=nc(k(),Us()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),x1=M({template:M({name:k().min(1),folder:k(),scope:N([`local`,`inherited`]),path:k().min(1),frontmatter:b1,body:k()}).strict()}).strict(),S1=M({folder:k(),name:k(),body:k().optional(),frontmatter:b1.optional()}).strict(),C1=M({path:k().min(1),created:Ls(),warnings:j(k())}).strict(),w1=M({existed:Ls(),path:k().min(1)}).strict(),T1=M({query:k().optional(),intent:N([`autocomplete`,`full_text`,`omnibar`]).optional(),scopes:j(N([`page`,`folder`,`content`])).optional(),scope:k().optional(),limit:A().int().nonnegative().optional()}).loose(),E1=M({kind:N([`page`,`folder`,`content`]),path:k().min(1),title:k(),score:A(),signals:nc(k(),Us()),snippet:k().optional()}).loose(),D1=M({query:k(),intent:N([`autocomplete`,`full_text`,`omnibar`]),results:j(E1),elapsedMs:A().nonnegative()}).loose(),O1=M({version:k().min(1),recordedAt:k().min(1)}).loose(),k1=M({currentVersion:k().min(1),targets:nc(k(),O1.nullable())}).loose(),A1=`server-info`,j1=`branch-switched`,M1=`disk-ack`,N1=`config-validation-rejected`,P1=`config-ignore-nested-error`,F1=N([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),I1=M({v:P(1),ch:P(A1),seq:A(),serverInstanceId:k().min(1),currentBranch:k().min(1).optional()}).loose(),L1=M({v:P(1),ch:P(j1),seq:A(),branch:k().min(1)}).loose(),R1=M({v:P(1),ch:F1,seq:A()}).loose(),z1=M({v:P(1),ch:P(M1),seq:A(),docName:k().min(1),sv:k().min(1)}).loose(),B1=M({v:P(1),ch:P(N1),seq:A(),docName:k().min(1),error:ll}).loose(),V1=M({v:P(1),ch:P(P1),seq:A(),path:k().min(1),error:k().min(1)}).loose(),H1={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},U1=new WeakMap;function W1(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function G1(e){return e.trim().toLowerCase()}function K1(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function q1(e){return e.split(`/`).filter(Boolean).join(` `)}function J1(e){let t=K1(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0;return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:q1(e.path),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function Y1(e){let t=MU({schema:H1});return e.length>0&&UU(t,e),t}function X1(e){let t={documents:e};return U1.set(t,Y1(e)),t}function Z1(e){let t=U1.get(e);if(t)return t;let n=Y1(e.documents);return U1.set(e,n),n}function Q1(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`]:[`page`,`folder`]}function $1(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function e0(e,t){let n=G1(t);if(!n)return 0;let r=G1(e.title),i=G1(e.name),a=G1(e.path),o=a.split(`/`);return r===n||i===n?700:a===n?650:r.startsWith(n)||i.startsWith(n)?600:o.some(e=>e.startsWith(n))?550:r.includes(n)||i.includes(n)?500:a.includes(n)?450:-1}function t0(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function n0(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function r0(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function i0(e,t){return G1(t).length<4?0:e===`full_text`?1:0}function a0(e,t,n={}){let r=n.intent??`omnibar`,i=W1(n.limit),a=new Set(n.scopes??Q1(r)),o=e.documents.filter(e=>$1(e,a)),s=G1(t);if(!s)return o.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,i).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let c=yW(Z1(e),{term:s,properties:n0(r),boost:r0(r),tolerance:i0(r,s),limit:Math.max(i*4,40)}),l=new Map(c.hits.filter(e=>$1(e.document,a)).map(e=>[e.document.id,e.score])),u=t0(o),d=new Map;for(let e of o)e0(e,s)>=0&&d.set(e.id,e);for(let e of c.hits)$1(e.document,a)&&d.set(e.document.id,e.document);return[...d.values()].map(e=>{let t=Math.max(0,e0(e,s)),n=l.get(e.id)??0,r=u.get(e.id)??0;return{document:e,score:t+n*20+r,signals:{lexical:t,fullText:n,recency:r}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score).slice(0,i)}function o0(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),s0(n)}function s0(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const c0=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),l0=globalThis;l0[c0]===void 0&&(l0[c0]=Fi());const u0=l0[c0],d0=[`.ok`,`skill-state.yml`],f0=[`claude-cowork`,`cli-hosts`],p0=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],m0=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,h0=Js({version:k().regex(m0,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(u0,{description:`Recorded skill version for this target.`}),recordedAt:Vo().register(u0,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:N(p0).register(u0,{description:`Install-source surface that recorded this entry.`}).optional()}),g0=Js({schema:P(1).register(u0,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Js({"claude-cowork":h0.optional(),"cli-hosts":h0.optional()}).register(u0,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function _0(){return{schema:1,targets:{}}}function v0(){let e=!1,t=``,n=0;return r=>{let i=y0(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function y0(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const b0=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],x0={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function S0(e,t=b0){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const C0={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function w0(e){return e?C0[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const T0={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function E0(e){let t=e?.trim();return t?T0[w0(t)]??t:`Agent`}function D0(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const O0=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function k0(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function A0(e){let t=e.trim();return O0.test(t)||t.startsWith(`//`)}function j0(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(A0(n))return{kind:`external`,url:n};let r=D0(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=k0(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function M0(e,t){let n=e.trim();if(!n)return null;if(A0(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=k0(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function N0(e,t){let n=e.trim();if(!n||O0.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function P0(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function F0(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function I0(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function L0(e){return e.split(`/`).filter(e=>e!==``)}function R0(e,t){let n=I0(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function z0(e,t){let n=I0(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:L0(r).length}function B0(e,t){let n=L0(e),r=L0(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function V0(){let e=new Map;function t(t){let n=P0(t);if(n===``)return;let r=F0(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=P0(t),r=F0(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=I0(P0(n)),o=[],s=[];for(let e of i)R0(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=z0(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=z0(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=B0(a,I0(t));for(let r=1;r<e.length;r++){let i=e[r],o=B0(a,I0(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function H0(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function U0(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function W0(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function G0(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function K0(){try{let e=l(c(b(import.meta.url)),`..`,`package.json`),t=JSON.parse(m(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const q0=K0(),J0=1;var Y0=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function X0(e,t){return l(e,`${t}.lock`)}const Z0=new Map;function Q0(e){Z0.set(e,(Z0.get(e)??0)+1)}function $0(e){let t=Z0.get(e);return t===void 0||t<=1?(Z0.delete(e),!0):(Z0.set(e,t-1),!1)}function e2(e,t){try{let n=JSON.parse(m(e,`utf-8`));return n&&typeof n==`object`&&G0(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function t2(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;f(n,{recursive:!0});let a=X0(n,t),o={pid:process.pid,hostname:y(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??q0},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!d(a))try{let e=p(a,`wx`,384);try{_(e,s)}finally{u(e)}return Q0(a),n2({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=e2(a,i);if(e){let r=e.hostname===y();if(r&&e.pid===process.pid)return g(a,s,{encoding:`utf-8`,mode:384}),Q0(a),n2({lockName:t,lockDir:n,lockPath:a});if(r&&W0(e.pid))throw new Y0(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{h(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function n2(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>o2({lockName:t,lockDir:n}),updatePort:e=>r2({lockName:t,lockDir:n,port:e})}}function r2(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=X0(n,t);if(!d(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(m(a,`utf-8`));if(!e||typeof e!=`object`||!G0(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==y())){o.port=r;try{g(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function i2(e){let{lockName:t,lockDir:n}=e,r=X0(n,t);if(!d(r))return null;let i;try{let e=JSON.parse(m(r,`utf-8`));if(!e||typeof e!=`object`||!G0(e.pid))return null;i=e}catch{return null}if(i.hostname!==y())return null;if(!W0(i.pid)){try{h(r)}catch{}return null}return i}function a2(e){let{lockName:t,lockDir:n}=e,r=X0(n,t);if(!d(r))return{status:`absent`};let i;try{i=JSON.parse(m(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!G0(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==y())return{status:`stale`,lock:o};if(!W0(o.pid)){try{h(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function o2(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=X0(n,t);if($0(i)&&d(i))try{let e=JSON.parse(m(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==y())return;h(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var s2=class extends Y0{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function c2(e,t){try{return t2({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof Y0&&e.lockName===`server`?new s2(e.existing,e.lockPath):e}}function l2(e,t){r2({lockName:`server`,lockDir:e,port:t})}function u2(e){return i2({lockName:`server`,lockDir:e})}function d2(e){o2({lockName:`server`,lockDir:e})}export{vG as $,da as $i,S1 as $n,rq as $r,C$ as $t,Rq as A,Ns as Ai,gq as An,sq as Ar,CQ as At,z1 as B,P as Bi,$Q as Bn,Oq as Br,d$ as Bt,xQ as C,Fc as Ci,T1 as Cn,dG as Cr,WG as Ct,bQ as D,$c as Di,u1 as Dn,_0 as Dr,v1 as Dt,mQ as E,nl as Ei,s1 as En,E0 as Er,_1 as Et,eG as F,j as Fi,Dq as Fn,VJ as Fr,KG as Ft,M1 as G,kc as Gi,n1 as Gn,NW as Gr,s$ as Gt,j1 as H,A as Hi,r1 as Hn,ZW as Hr,c$ as Ht,L1 as I,Ls as Ii,k1 as In,$K as Ir,d1 as It,pG as J,Xs as Ji,Q$ as Jn,VW as Jr,n$ as Jt,A1 as K,nc as Ki,X$ as Kn,MG as Kr,l$ as Kt,V1 as L,Ec as Li,g0 as Ln,w0 as Lr,p1 as Lt,jQ as M,N as Mi,Cq as Mn,NZ as Mr,WQ as Mt,Mq as N,zs as Ni,Sq as Nn,nQ as Nr,GQ as Nt,pQ as O,Kc as Oi,a1 as On,o0 as Or,y1 as Ot,YW as P,Vs as Pi,Tq as Pn,ZZ as Pr,XQ as Pt,yG as Q,zo as Qi,x1 as Qn,a0 as Qr,PZ as Qt,B1 as R,Qs as Ri,T$ as Rn,Aq as Rr,w$ as Rt,hQ as S,dl as Si,HQ as Sn,J1 as Sr,wG as St,SQ as T,hl as Ti,o1 as Tn,RW as Tr,O$ as Tt,P1 as U,M as Ui,e1 as Un,lG as Ur,o$ as Ut,I1 as V,Js as Vi,i1 as Vn,oK as Vr,a$ as Vt,N1 as W,cc as Wi,t1 as Wn,IW as Wr,u$ as Wt,bG as X,_s as Xi,m1 as Xn,N0 as Xr,e$ as Xt,xG as Y,Us as Yi,g1 as Yn,fQ as Yr,i$ as Yt,_G as Z,Vo as Zi,w1 as Zn,D0 as Zr,t$ as Zt,x0 as _,Sl as _i,f0 as _n,S0 as _r,KQ as _t,t2 as a,un as aa,cq as ai,NG as an,W$ as ar,j$ as at,h$ as b,tl as bi,hG as bn,FX as br,N$ as bt,G0 as c,on as ca,F as ci,F$ as cn,Hq as cr,A$ as ct,a2 as d,O as da,Uc as di,z$ as dn,DW as dr,PG as dt,Ua as ea,MW as ei,x$ as en,C1 as er,Nq as et,u2 as f,D as fa,Hc as fi,B$ as fn,KW as fr,kG as ft,l2 as g,Cl as gi,d0 as gn,mG as gr,H$ as gt,r2 as h,Mc as hi,K$ as hn,M0 as hr,V$ as ht,s2 as i,cn as ia,PW as ii,jG as in,U$ as ir,$$ as it,MQ as j,sc as ji,vq as jn,qW as jr,wQ as jt,yQ as k,qc as ki,Iq as kn,H0 as kr,PQ as kt,X0 as l,Lt as la,xl as li,Lq as ln,qQ as lr,qG as lt,d2 as m,ft as ma,jc as mi,G$ as mn,j0 as mr,QQ as mt,q0 as n,ai as na,JW as ni,DG as nn,y$ as nr,TQ as nt,c2 as o,fn as oa,Fy as oi,fG as on,TG as or,M$ as ot,o2 as p,pt as pa,Vc as pi,JQ as pn,Bq as pr,SG as pt,gG as q,k as qi,Z$ as qn,dQ as qr,Wq as qt,J0 as r,vr as ra,YZ as ri,YQ as rn,_$ as rr,EQ as rt,W0 as s,mn as sa,Tf as si,L$ as sn,Uq as sr,k$ as st,Y0 as t,Wa as ta,U0 as ti,b$ as tn,v$ as tr,Fq as tt,i2 as u,Tt as ua,Wc as ui,Vq as un,OW as ur,EG as ut,CG as v,_l as vi,m0 as vn,V0 as vr,kQ as vt,gQ as w,ul as wi,D1 as wn,uG as wr,BQ as wt,g$ as x,bl as xi,VQ as xn,X1 as xr,P$ as xt,GG as y,Jc as yi,AG as yn,v0 as yr,OQ as yt,R1 as z,ec as zi,Gq as zn,OG as zr,LQ as zt};
|
|
428
|
-
//# sourceMappingURL=server-lock-BpjJj3OD-
|
|
427
|
+
`)}const pQ=M({docName:dq,summary:mq,content:k().optional(),...pq}).loose(),mQ=M({docName:dq,summary:mq,markdown:k(),position:N([`append`,`prepend`,`replace`]).optional(),extension:N([`.md`,`.mdx`]).optional(),...pq}).loose(),hQ=M({docName:dq,summary:mq,find:k().min(1),replace:k(),offset:A().int().nonnegative().optional(),...pq}).loose(),gQ=M({docName:dq,connectionId:k().min(1),scope:N([`last`,`session`,`file`]).optional(),...pq}).loose(),_Q=M({value:k(),truncatedFrom:A().int().nonnegative().optional(),hint:k().optional()}).loose(),vQ=M({type:P(`orphan`),parentCandidates:j(k()),message:k()}).loose(),yQ=M({timestamp:k().min(1),summary:_Q.optional()}).loose(),bQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:j(vQ).optional(),summary:_Q.optional()}).loose(),xQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:_Q.optional()}).loose(),SQ=M({docName:k().min(1),scope:N([`last`,`session`]),undone:Ls()}).loose(),CQ=M({docName:dq,patch:nc(k(),Xs([Mc,zs()])),types:nc(k(),N(jc)).optional(),summary:mq,...pq}).loose(),wQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:j(k()),summary:_Q.optional()}).loose(),TQ=M({entries:j(M({level:N([`info`,`warn`,`error`]),message:k().max(8192),event:k().optional(),fields:nc(k(),Us()).optional(),ts:A().optional(),sourceId:k().optional(),lineNumber:A().optional()}).loose()).max(100)}).loose(),EQ=M({accepted:A().int().min(0)}).loose(),DQ=M({status:k().min(1),reason:k()}).loose(),OQ=M({docName:k().min(1),content:k(),lifecycle:DQ.nullable()}).loose(),kQ=M({documents:j(M({kind:N([`document`,`asset`,`folder`]).default(`document`),docName:k().min(1).optional(),docExt:k().min(1).default(`.md`),size:A().int().nonnegative(),modified:k().min(1),isSymlink:Ls().default(!1),canonicalDocName:k().nullable().default(null),targetPath:k().nullable().default(null),path:k().min(1).optional(),assetExt:k().min(1).optional(),mediaKind:N([`image`,`video`,`audio`,`pdf`,`text`]).nullable().optional(),referencedBy:j(k().min(1)).optional(),hasChildren:Ls().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName)`})),truncated:Ls().optional()}).loose(),AQ=M({source:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),jQ=M({docName:k().min(1),backlinks:j(AQ)}).loose(),MQ=M({counts:nc(k().min(1),A().int().nonnegative())}).loose(),NQ=Qs(`kind`,[M({kind:P(`doc`),docName:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),M({kind:P(`external`),url:k().min(1),title:k(),snippet:k().nullable()}).loose()]),PQ=M({docName:k().min(1),forwardLinks:j(NQ)}).loose(),FQ=Qs(`kind`,[M({id:k().min(1),kind:P(`doc`),docName:k().min(1),anchor:k().nullable(),label:k(),cluster:k().nullable(),category:k().nullable(),tags:j(k()).nullable()}).loose(),M({id:k().min(1),kind:P(`external`),url:k().min(1),label:k()}).loose()]),IQ=M({source:k().min(1),target:k().min(1)}).loose(),LQ=M({nodes:j(FQ),links:j(IQ)}).loose(),RQ=M({ts:A().int().min(0),url:k(),method:k(),ua:k().optional(),origin:k().optional(),referer:k().optional(),host:k().optional(),remote:k().optional(),secChUa:k().optional(),secChUaMobile:k().optional(),secChUaPlatform:k().optional(),secFetchSite:k().optional(),secFetchDest:k().optional(),secFetchMode:k().optional(),secFetchUser:k().optional()}).loose(),zQ=M({app:Xs([P(`cursor`),P(`codex`),P(`claude`),zs()]),signals_fired:j(k())}).loose(),BQ=M({entries:j(RQ),count:A().int().min(0),detection:zQ}).loose(),VQ=M({writers:j(M({id:k().min(1),name:k().optional(),email:k().optional()}).loose()).optional(),...pq}).loose(),HQ=M({checkpointRef:k().min(1)}).loose(),UQ=M({v:A().int().optional(),id:k().min(1),name:k().min(1),colorSeed:k().optional(),docs:j(k()),summaries:j(k()).optional()}).loose(),WQ=M({entries:j(M({sha:k().min(1),timestamp:k().min(1),author:k(),authorEmail:k(),type:N([`checkpoint`,`wip`,`upstream`,`park`]),message:k(),contributors:j(UQ),checkpoint:Us().nullable()}).loose()),total:A().int().nonnegative().optional(),truncated:Ls().optional()}).loose(),GQ=M({sha:k().regex(/^[0-9a-f]{40}$/i),content:k(),timestamp:k(),author:k()}).loose(),KQ=M({lines:j(M({type:N([`added`,`removed`,`unchanged`]),text:k()}).loose()),additions:A().int().nonnegative(),deletions:A().int().nonnegative()}).loose(),qQ=M({contentDir:k().min(1),pathSeparator:N([`/`,`\\`]),symlinkResolved:Ls()}).loose(),JQ=j(Qs(`source`,[M({docName:k().min(1),timestamp:k().min(1),size:A().int().nonnegative(),source:P(`flat`)}).loose(),M({docName:k().min(1),timestamp:k().min(1),source:P(`timeline`),sha:k().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),YQ=M({orphans:j(M({docName:k().min(1),title:k()}).loose())}).loose(),XQ=M({hubs:j(M({docName:k().min(1),title:k(),count:A().int().nonnegative()}).loose())}).loose(),ZQ=M({source:k().min(1),title:k(),snippet:k().nullable()}).loose(),QQ=M({deadLinks:j(M({target:k().min(1),sources:j(ZQ)}).loose())}).loose(),$Q=M({target:M({docName:k().min(1),title:k(),aliases:j(k())}).loose(),mentions:j(M({source:k().min(1),excerpt:k(),offset:A().int().nonnegative()}).loose()),truncated:Ls()}).loose(),e$=M({dir:k().min(1),port:A().int().min(1).max(65535).optional()}).loose(),t$=M({port:A().int().positive()}).loose(),n$=M({projectPath:k().min(1)}).loose(),r$=N([`not-a-git-worktree`,`init-failed`]),i$=Qs(`ok`,[M({ok:P(!0),projectPath:k().min(1)}).loose(),M({ok:P(!1),reason:r$,message:k().min(1)}).loose()]),a$=M({host:k().min(1).optional()}).loose(),o$=M({pat:k().min(1),host:k().min(1).optional()}).loose(),s$=M({name:k().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:k().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),c$=M({identity:M({name:k().min(1),email:k().min(1)}).loose().nullable()}).loose(),l$=M({authenticated:Ls()}).loose(),u$=M({type:P(`complete`).optional(),login:k().min(1).optional()}).loose(),d$=M({}).loose(),f$=M({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),p$=M({docName:k().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:j(f$)}).loose(),m$=M({displayName:k().min(1),color:k().min(1),icon:k().optional(),connectionId:k().min(1)}).loose(),h$=M({sessionAlive:Ls(),agent:m$.nullable(),files:j(p$)}).loose(),g$=M({diff:k(),generatedAt:A().int().min(0)}).loose(),_$=M({}).loose(),v$=M({}).loose(),y$=M({}).loose(),b$=M({}).loose(),x$=M({}).loose(),S$=M({displayName:k().min(1),icon:k(),color:k().min(1),currentDoc:k().nullable(),mode:N([`idle`,`writing`]),ts:A().int().min(0)}).loose(),C$=M({presence:nc(k().min(1),S$)}).loose(),w$=nc(k().min(1),Ls()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});M({path:k().min(1,`path must be non-empty`)}).loose();const T$=M({}).loose(),E$=M({fromDocName:k().min(1),toDocName:k().min(1)}).loose(),D$=M({fromPath:k().min(1),toPath:k().min(1)}).loose(),O$=M({}).loose(),k$=M({path:k().min(1),...pq,summary:mq}).loose(),A$=M({docName:k().min(1)}).loose(),j$=M({path:k().min(1),...pq,summary:mq}).loose(),M$=M({path:k().min(1)}).loose(),N$=M({kind:N([`file`,`folder`]),path:k().min(1),...pq,summary:mq}).loose(),P$=M({kind:N([`file`,`folder`]),path:k().min(1),duplicatedDocNames:j(k().min(1))}).loose(),F$=M({pages:j(M({docName:k().min(1),title:k(),docExt:k().min(1),size:A().int().nonnegative(),modified:k().min(1),icon:k().min(1).max(2048).optional()}).loose())}).loose(),I$=M({level:A().int().min(1).max(6),text:k(),slug:k()}).loose(),L$=M({docName:k().min(1),headings:j(I$)}).loose();M({docName:fq,newDocName:fq,summary:mq,...pq}).loose();const R$=M({docName:k().min(1),rewrites:A().int().nonnegative()}).loose();M({renamed:j(E$),rewrittenDocs:j(R$),summary:_Q.optional()}).loose();const z$=M({kind:N([`file`,`folder`,`asset`]),fromPath:k().min(1),toPath:k().min(1),...pq,summary:mq}).loose(),B$=M({renamed:j(E$),renamedAssets:j(D$),rewrittenDocs:j(R$).optional(),summary:_Q.optional()}).loose(),V$=M({kind:N([`file`,`folder`,`asset`]),path:k().min(1),...pq}).loose(),H$=M({deletedDocNames:j(k().min(1))}).loose(),U$=M({kind:N([`file`,`folder`,`asset`]),path:k().min(1),...pq,summary:mq}).loose(),W$=M({deletedDocNames:j(k().min(1))}).loose(),G$=M({docName:k().min(1),commitSha:k().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:mq,...pq}).loose(),K$=M({restoredFrom:k().min(1),timestamp:k().min(1),summary:_Q.optional()}).loose(),q$=N([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),J$=M({label:k().min(1),webUrl:_s().nullable()}).loose(),Y$=Qs(`checkStatus`,[M({checkStatus:P(`allowed`)}).loose(),M({checkStatus:P(`denied`),deniedReason:N([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),M({checkStatus:P(`unknown`),unknownError:N([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),X$=M({state:q$,lastSyncUtc:k().nullable(),lastFetchUtc:k().nullable(),lastPushedSha:k().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:Ls(),syncEnabled:Ls(),identityUnresolved:Ls(),remote:J$.nullable().optional(),error:k().optional(),errorCode:N([`auth-403`,`auth-401`,`auth-scope-mismatch`,`semantic-protected-branch`]).optional(),pausedReason:k().optional(),pushPermission:Y$.optional()}).loose(),Z$=M({op:N([`sync`,`push`,`pull`]).optional()}).loose(),Q$=M({op:N([`sync`,`push`,`pull`])}).loose(),$$=M({file:k().min(1),detectedAt:k().min(1),oursSha:k().optional(),theirsSha:k().optional(),baseSha:k().optional()}).loose(),e1=M({conflicts:j($$)}).loose(),t1=M({file:k().min(1),strategy:N([`mine`,`theirs`,`content`,`delete`]),content:k().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),n1=M({}).loose(),r1=M({file:k().min(1),base:k(),ours:k(),theirs:k(),kind:N([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:k().nullable()}).loose(),i1=M({}).loose(),a1=M({plan:Ec(e=>e!==void 0,{message:`plan is required`})}).loose(),o1=M({plan:Ec(e=>e!==void 0,{message:`plan is required`})}).loose(),s1=M({result:Ec(e=>e!==void 0,{message:`result is required`})}).loose(),c1=M({path:k().min(1),summary:k().min(1)}).loose(),l1=M({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),u1=M({packs:j(M({id:k().min(1),name:k().min(1),description:k().min(1),defaultSubfolder:k().optional(),folders:j(c1),entryCounts:l1}).loose())}).loose(),d1=M({noOpen:Ls().optional(),out:k().min(1).optional()}).loose(),f1=M({reason:N([`unsupported-platform`,`spawn-error`]),message:k()}).loose(),p1=Qs(`status`,[M({status:P(`installed`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k()}).loose(),M({status:P(`built`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k(),handoffError:f1.optional()}).loose(),M({status:P(`failed`),buildError:k()}).loose(),M({status:P(`skip-current`),skillVersion:k(),recordedAt:k().optional()}).loose()]),m1=M({tags:j(M({name:k().min(1),count:A().int().nonnegative(),isLeaf:Ls()}).loose())}).loose(),h1=M({docName:k().min(1),title:k(),matchingTags:j(k().min(1)),snippet:k().nullable()}).loose(),g1=M({name:k().min(1),docs:j(h1)}).loose(),_1=M({folder:Us(),frontmatter_local:nc(k(),Us()).nullable()}).loose(),v1=M({path:k(),frontmatter:nc(k(),Us()).optional()}).loose(),y1=M({applied:Us()}).loose(),b1=nc(k(),Us()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),x1=M({template:M({name:k().min(1),folder:k(),scope:N([`local`,`inherited`]),path:k().min(1),frontmatter:b1,body:k()}).strict()}).strict(),S1=M({folder:k(),name:k(),body:k().optional(),frontmatter:b1.optional()}).strict(),C1=M({path:k().min(1),created:Ls(),warnings:j(k())}).strict(),w1=M({existed:Ls(),path:k().min(1)}).strict(),T1=M({query:k().optional(),intent:N([`autocomplete`,`full_text`,`omnibar`]).optional(),scopes:j(N([`page`,`folder`,`content`])).optional(),scope:k().optional(),limit:A().int().nonnegative().optional()}).loose(),E1=M({kind:N([`page`,`folder`,`content`]),path:k().min(1),title:k(),score:A(),signals:nc(k(),Us()),snippet:k().optional()}).loose(),D1=M({query:k(),intent:N([`autocomplete`,`full_text`,`omnibar`]),results:j(E1),elapsedMs:A().nonnegative()}).loose(),O1=M({version:k().min(1),recordedAt:k().min(1)}).loose(),k1=M({currentVersion:k().min(1),targets:nc(k(),O1.nullable())}).loose(),A1=`server-info`,j1=`branch-switched`,M1=`disk-ack`,N1=`config-validation-rejected`,P1=`config-ignore-nested-error`,F1=N([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),I1=M({v:P(1),ch:P(A1),seq:A(),serverInstanceId:k().min(1),currentBranch:k().min(1).optional()}).loose(),L1=M({v:P(1),ch:P(j1),seq:A(),branch:k().min(1)}).loose(),R1=M({v:P(1),ch:F1,seq:A()}).loose(),z1=M({v:P(1),ch:P(M1),seq:A(),docName:k().min(1),sv:k().min(1)}).loose(),B1=M({v:P(1),ch:P(N1),seq:A(),docName:k().min(1),error:ll}).loose(),V1=M({v:P(1),ch:P(P1),seq:A(),path:k().min(1),error:k().min(1)}).loose(),H1={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},U1=new WeakMap;function W1(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function G1(e){return e.trim().toLowerCase()}function K1(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function q1(e){return e.split(`/`).filter(Boolean).join(` `)}function J1(e){let t=K1(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0;return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:q1(e.path),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function Y1(e){let t=MU({schema:H1});return e.length>0&&UU(t,e),t}function X1(e){let t={documents:e};return U1.set(t,Y1(e)),t}function Z1(e){let t=U1.get(e);if(t)return t;let n=Y1(e.documents);return U1.set(e,n),n}function Q1(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`]:[`page`,`folder`]}function $1(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function e0(e,t){let n=G1(t);if(!n)return 0;let r=G1(e.title),i=G1(e.name),a=G1(e.path),o=a.split(`/`);return r===n||i===n?700:a===n?650:r.startsWith(n)||i.startsWith(n)?600:o.some(e=>e.startsWith(n))?550:r.includes(n)||i.includes(n)?500:a.includes(n)?450:-1}function t0(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function n0(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function r0(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function i0(e,t){return G1(t).length<4?0:e===`full_text`?1:0}function a0(e,t,n={}){let r=n.intent??`omnibar`,i=W1(n.limit),a=new Set(n.scopes??Q1(r)),o=e.documents.filter(e=>$1(e,a)),s=G1(t);if(!s)return o.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,i).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let c=yW(Z1(e),{term:s,properties:n0(r),boost:r0(r),tolerance:i0(r,s),limit:Math.max(i*4,40)}),l=new Map(c.hits.filter(e=>$1(e.document,a)).map(e=>[e.document.id,e.score])),u=t0(o),d=new Map;for(let e of o)e0(e,s)>=0&&d.set(e.id,e);for(let e of c.hits)$1(e.document,a)&&d.set(e.document.id,e.document);return[...d.values()].map(e=>{let t=Math.max(0,e0(e,s)),n=l.get(e.id)??0,r=u.get(e.id)??0;return{document:e,score:t+n*20+r,signals:{lexical:t,fullText:n,recency:r}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score).slice(0,i)}function o0(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),s0(n)}function s0(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const c0=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),l0=globalThis;l0[c0]===void 0&&(l0[c0]=Fi());const u0=l0[c0],d0=[`.ok`,`skill-state.yml`],f0=[`claude-cowork`,`cli-hosts`],p0=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],m0=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,h0=Js({version:k().regex(m0,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(u0,{description:`Recorded skill version for this target.`}),recordedAt:Vo().register(u0,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:N(p0).register(u0,{description:`Install-source surface that recorded this entry.`}).optional()}),g0=Js({schema:P(1).register(u0,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Js({"claude-cowork":h0.optional(),"cli-hosts":h0.optional()}).register(u0,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function _0(){return{schema:1,targets:{}}}function v0(){let e=!1,t=``,n=0;return r=>{let i=y0(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function y0(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const b0=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],x0={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function S0(e,t=b0){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const C0={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function w0(e){return e?C0[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const T0={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function E0(e){let t=e?.trim();return t?T0[w0(t)]??t:`Agent`}function D0(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const O0=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function k0(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function A0(e){let t=e.trim();return O0.test(t)||t.startsWith(`//`)}function j0(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(A0(n))return{kind:`external`,url:n};let r=D0(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=k0(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function M0(e,t){let n=e.trim();if(!n)return null;if(A0(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=k0(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function N0(e,t){let n=e.trim();if(!n||O0.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function P0(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function F0(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function I0(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function L0(e){return e.split(`/`).filter(e=>e!==``)}function R0(e,t){let n=I0(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function z0(e,t){let n=I0(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:L0(r).length}function B0(e,t){let n=L0(e),r=L0(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function V0(){let e=new Map;function t(t){let n=P0(t);if(n===``)return;let r=F0(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=P0(t),r=F0(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=I0(P0(n)),o=[],s=[];for(let e of i)R0(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=z0(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=z0(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=B0(a,I0(t));for(let r=1;r<e.length;r++){let i=e[r],o=B0(a,I0(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function H0(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function U0(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function W0(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function G0(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function K0(){try{let e=l(c(b(import.meta.url)),`..`,`package.json`),t=JSON.parse(m(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const q0=K0(),J0=1;var Y0=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function X0(e,t){return l(e,`${t}.lock`)}const Z0=new Map;function Q0(e){Z0.set(e,(Z0.get(e)??0)+1)}function $0(e){let t=Z0.get(e);return t===void 0||t<=1?(Z0.delete(e),!0):(Z0.set(e,t-1),!1)}function e2(e,t){try{let n=JSON.parse(m(e,`utf-8`));return n&&typeof n==`object`&&G0(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function t2(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;f(n,{recursive:!0});let a=X0(n,t),o={pid:process.pid,hostname:y(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??q0},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!d(a))try{let e=p(a,`wx`,384);try{_(e,s)}finally{u(e)}return Q0(a),n2({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=e2(a,i);if(e){let r=e.hostname===y();if(r&&e.pid===process.pid)return g(a,s,{encoding:`utf-8`,mode:384}),Q0(a),n2({lockName:t,lockDir:n,lockPath:a});if(r&&W0(e.pid))throw new Y0(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{h(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function n2(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>o2({lockName:t,lockDir:n}),updatePort:e=>r2({lockName:t,lockDir:n,port:e})}}function r2(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=X0(n,t);if(!d(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(m(a,`utf-8`));if(!e||typeof e!=`object`||!G0(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==y())){o.port=r;try{g(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function i2(e){let{lockName:t,lockDir:n}=e,r=X0(n,t);if(!d(r))return null;let i;try{let e=JSON.parse(m(r,`utf-8`));if(!e||typeof e!=`object`||!G0(e.pid))return null;i=e}catch{return null}if(i.hostname!==y())return null;if(!W0(i.pid)){try{h(r)}catch{}return null}return i}function a2(e){let{lockName:t,lockDir:n}=e,r=X0(n,t);if(!d(r))return{status:`absent`};let i;try{i=JSON.parse(m(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!G0(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==y())return{status:`stale`,lock:o};if(!W0(o.pid)){try{h(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function o2(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=X0(n,t);if($0(i)&&d(i))try{let e=JSON.parse(m(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==y())return;h(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var s2=class extends Y0{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function c2(e,t){try{return t2({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof Y0&&e.lockName===`server`?new s2(e.existing,e.lockPath):e}}function l2(e,t){r2({lockName:`server`,lockDir:e,port:t})}function u2(e){return i2({lockName:`server`,lockDir:e})}function d2(e){o2({lockName:`server`,lockDir:e})}export{vG as $,da as $i,S1 as $n,rq as $r,C$ as $t,Rq as A,Ns as Ai,gq as An,sq as Ar,CQ as At,z1 as B,P as Bi,$Q as Bn,Oq as Br,d$ as Bt,xQ as C,Fc as Ci,T1 as Cn,dG as Cr,WG as Ct,bQ as D,$c as Di,u1 as Dn,_0 as Dr,v1 as Dt,mQ as E,nl as Ei,s1 as En,E0 as Er,_1 as Et,eG as F,j as Fi,Dq as Fn,VJ as Fr,KG as Ft,M1 as G,kc as Gi,n1 as Gn,NW as Gr,s$ as Gt,j1 as H,A as Hi,r1 as Hn,ZW as Hr,c$ as Ht,L1 as I,Ls as Ii,k1 as In,$K as Ir,d1 as It,pG as J,Xs as Ji,Q$ as Jn,VW as Jr,n$ as Jt,A1 as K,nc as Ki,X$ as Kn,MG as Kr,l$ as Kt,V1 as L,Ec as Li,g0 as Ln,w0 as Lr,p1 as Lt,jQ as M,N as Mi,Cq as Mn,NZ as Mr,WQ as Mt,Mq as N,zs as Ni,Sq as Nn,nQ as Nr,GQ as Nt,pQ as O,Kc as Oi,a1 as On,o0 as Or,y1 as Ot,YW as P,Vs as Pi,Tq as Pn,ZZ as Pr,XQ as Pt,yG as Q,zo as Qi,x1 as Qn,a0 as Qr,PZ as Qt,B1 as R,Qs as Ri,T$ as Rn,Aq as Rr,w$ as Rt,hQ as S,dl as Si,HQ as Sn,J1 as Sr,wG as St,SQ as T,hl as Ti,o1 as Tn,RW as Tr,O$ as Tt,P1 as U,M as Ui,e1 as Un,lG as Ur,o$ as Ut,I1 as V,Js as Vi,i1 as Vn,oK as Vr,a$ as Vt,N1 as W,cc as Wi,t1 as Wn,IW as Wr,u$ as Wt,bG as X,_s as Xi,m1 as Xn,N0 as Xr,e$ as Xt,xG as Y,Us as Yi,g1 as Yn,fQ as Yr,i$ as Yt,_G as Z,Vo as Zi,w1 as Zn,D0 as Zr,t$ as Zt,x0 as _,Sl as _i,f0 as _n,S0 as _r,KQ as _t,t2 as a,un as aa,cq as ai,NG as an,W$ as ar,j$ as at,h$ as b,tl as bi,hG as bn,FX as br,N$ as bt,G0 as c,on as ca,F as ci,F$ as cn,Hq as cr,A$ as ct,a2 as d,O as da,Uc as di,z$ as dn,DW as dr,PG as dt,Ua as ea,MW as ei,x$ as en,C1 as er,Nq as et,u2 as f,D as fa,Hc as fi,B$ as fn,KW as fr,kG as ft,l2 as g,Cl as gi,d0 as gn,mG as gr,H$ as gt,r2 as h,Mc as hi,K$ as hn,M0 as hr,V$ as ht,s2 as i,cn as ia,PW as ii,jG as in,U$ as ir,$$ as it,MQ as j,sc as ji,vq as jn,qW as jr,wQ as jt,yQ as k,qc as ki,Iq as kn,H0 as kr,PQ as kt,X0 as l,Lt as la,xl as li,Lq as ln,qQ as lr,qG as lt,d2 as m,ft as ma,jc as mi,G$ as mn,j0 as mr,QQ as mt,q0 as n,ai as na,JW as ni,DG as nn,y$ as nr,TQ as nt,c2 as o,fn as oa,Fy as oi,fG as on,TG as or,M$ as ot,o2 as p,pt as pa,Vc as pi,JQ as pn,Bq as pr,SG as pt,gG as q,k as qi,Z$ as qn,dQ as qr,Wq as qt,J0 as r,vr as ra,YZ as ri,YQ as rn,_$ as rr,EQ as rt,W0 as s,mn as sa,Tf as si,L$ as sn,Uq as sr,k$ as st,Y0 as t,Wa as ta,U0 as ti,b$ as tn,v$ as tr,Fq as tt,i2 as u,Tt as ua,Wc as ui,Vq as un,OW as ur,EG as ut,CG as v,_l as vi,m0 as vn,V0 as vr,kQ as vt,gQ as w,ul as wi,D1 as wn,uG as wr,BQ as wt,g$ as x,bl as xi,VQ as xn,X1 as xr,P$ as xt,GG as y,Jc as yi,AG as yn,v0 as yr,OQ as yt,R1 as z,ec as zi,Gq as zn,OG as zr,LQ as zt};
|
|
428
|
+
//# sourceMappingURL=server-lock-BpjJj3OD-D9FMFKPA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./server-lock-BpjJj3OD-D9FMFKPA.mjs";export{e as updateServerLockPort};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-
|
|
1
|
+
import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-D9FMFKPA.mjs";import"./gh-detect-D3EaYkiE.mjs";import{g as a,h as o,k as s}from"./init-Bo84hmNW.mjs";import{Sr as c}from"./dist-DeQtb-TH.mjs";import"./loader-DcRPCz_p.mjs";import{c as l}from"./colors-BtKMHmBX.mjs";import"./preview-DIgwrffB.mjs";import{n as u}from"./write-project-skill-ZPEnzf-i.mjs";import{spawnSync as d}from"node:child_process";import{basename as f,dirname as ee,isAbsolute as p,join as m,relative as h,resolve as g}from"node:path";import{existsSync as _,lstatSync as te,readFileSync as ne,readdirSync as v,statSync as y}from"node:fs";import{hostname as b}from"node:os";import{readFile as x,realpath as S}from"node:fs/promises";function C(e,t,a={}){let o=r(e,t);if(!_(o))return{status:`missing`,lockPath:o};let s;try{s=JSON.parse(ne(o,`utf-8`))}catch{return{status:`corrupt`,lockPath:o}}if(!s||typeof s!=`object`||!n(s.pid))return{status:`corrupt`,lockPath:o};let c=s;if(!(a.isAlive??i)(c.pid))return{status:`dead-pid`,lockPath:o,lock:c};let l=a.host??b();return c.hostname===l?{status:`alive`,lockPath:o,lock:c}:{status:`foreign-host`,lockPath:o,lock:c}}function w(e){return e.replace(/:\d+$/,``)}function T(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:w(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:w(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:w(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function E(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}const D=2e3,O=2e3,k=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/Open Knowledge(?:\.app| Helper)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/,/(^|\s)--ok-project-path=/];function A(e){return k.some(t=>t.test(e))}function j(e){let t=e.trim().split(/\s+/).find(e=>e.startsWith(`--ok-lock-dir-b64=`));if(t==null)return null;let n=t.slice(18);if(!n)return null;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);return p(e)?e:null}catch{return null}}function M(e){let t=e.indexOf(`--ok-project-path=`);if(t===-1)return null;let n=t+18,r=e.slice(n),i=r.search(/\s--/),a=(i===-1?r:r.slice(0,i)).trim();return a&&p(a)?a:null}function re(e){let t=[];for(let n of e.split(`
|
|
2
2
|
`)){let e=n.trim();if(!e)continue;let r=e.indexOf(` `);if(r===-1)continue;let i=e.slice(0,r),a=e.slice(r+1),o=Number.parseInt(i,10);!Number.isNaN(o)&&A(a)&&t.push({pid:o,command:a})}return t}function ie(e){let t=[],n=e.split(`
|
|
3
3
|
`);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.indexOf(` `);if(i===-1)continue;let a=r.slice(0,i),o=r.slice(i+1).trim(),s=Number.parseInt(a,10);!Number.isNaN(s)&&A(o)&&t.push({pid:s,command:o})}return t}async function ae(){let e=d(`pgrep`,[`-a`,`-f`,`cli\\.mjs|open-knowledge|Open Knowledge(\\.app| Helper)|--ok-lock-dir-b64=|--ok-project-path=|(^|[ /])ok[ ]+(start|mcp|ui)([ ]|$)|packages/(cli|app)|hocuspocus|vite`],{encoding:`utf-8`,timeout:D});if(!(e.error!=null&&e.error.code===`ENOENT`)){let t=e.stdout??``,n=re(t);if(n.length>0||t.trim()===``)return n}let t=d(`ps`,[`-axo`,`pid,command`],{encoding:`utf-8`,timeout:D});return t.error!=null||!t.stdout?[]:ie(t.stdout)}function oe(e){let t=e.trim().split(/\s+/).filter(Boolean);for(let e of t){if(e.startsWith(`@`))continue;let t=f(e);if(t===`open-knowledge`||t===`ok`||e.endsWith(`/packages/cli/src/cli.ts`)||e.endsWith(`/packages/cli/dist/cli.mjs`)||t===`cli.mjs`||t===`cli.ts`)return e}return null}function N(e){let t=d(`ps`,[`-p`,String(e),`-o`,`command=`],{encoding:`utf-8`,timeout:D});return t.error!=null||!t.stdout?null:t.stdout.trim()||null}function P(e){let t=d(`ps`,[`-p`,String(e),`-o`,`%cpu=,%mem=`],{encoding:`utf-8`,timeout:D});if(t.error!=null||!t.stdout)return null;let[n,r]=t.stdout.trim().split(/\s+/),i=Number.parseFloat(n??``),a=Number.parseFloat(r??``);return Number.isNaN(i)||Number.isNaN(a)?null:{cpuPercent:i,memPercent:a}}async function F(e){let t=d(`lsof`,[`-p`,String(e),`-a`,`-d`,`cwd`,`-Fn`],{encoding:`utf-8`,timeout:D});if(t.error!=null)return null;let n=t.stdout??``;for(let e of n.split(`
|
|
4
4
|
`))if(e.startsWith(`n`)&&e.length>1)return e.slice(1);return null}function I(e){let t=[],n=e.split(`
|
|
5
5
|
`);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.split(/\s+/);if(i.length<2)continue;let a=Number.parseInt(i[1]??``,10);Number.isNaN(a)||t.push(a)}return[...new Set(t)]}function L(e){return _(m(e,`server.lock`))||_(m(e,`ui.lock`))}function R(e,t){for(let n of[m(t,`.ok`,`local`),m(t,`.ok`)])_(n)&&L(n)&&e.add(n)}function z(e,t){let n=0,r=(t,i)=>{if(n>=O||(n++,R(e,t),i>=3))return;let a;try{a=v(t)}catch{return}for(let e of a){if(n>=O)return;if(e===`node_modules`||e===`.git`||e===`Library`||e.startsWith(`.`)&&e!==`.ok`)continue;let a=m(t,e),o=!1;try{o=te(a).isDirectory()}catch{continue}o&&r(a,i+1)}};r(t,0)}async function B(){let e=new Set,t=await ae(),n=t.map(e=>F(e.pid)),r=await Promise.all(n);for(let n of t){let t=j(n.command);t!=null&&_(t)&&e.add(t);let r=M(n.command);r!=null&&R(e,r)}for(let t of r)t!=null&&R(e,t);let i=d(`lsof`,[`-iTCP`,`-sTCP:LISTEN`,`-nP`],{encoding:`utf-8`,timeout:D});if(i.error==null&&i.stdout){let n=I(i.stdout),r=new Set(t.map(e=>e.pid)),a=n.filter(e=>!r.has(e)).map(e=>F(e)),o=await Promise.all(a);for(let t of o)t!=null&&R(e,t)}(e.size===0||r.some(e=>e===`/`))&&z(e,process.cwd());let a=new Map;for(let t of e)try{let e=await S(t);a.set(e,e)}catch{a.set(t,t)}return[...a.values()]}var V=e(l(),1);function H(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function U(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function W(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:oe(r),command:r,isDesktop:H(r)}}function G(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function K(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&G(e)?`ui-orphan`:`stale`}const q=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function se(e){switch(e){case`running`:return V.default.green(e);case`desktop`:return V.default.blue(e);case`foreign`:return V.default.cyan(e);case`ui-orphan`:return V.default.magenta(e);case`stale`:return V.default.yellow(e)}}function J(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ce(e){return`${J(e.server.usage)} | ${J(e.ui?.usage??null)}`}function le(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function ue(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=K(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,le(e),ce(e),t,String(n),U(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=se(K(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=V.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
6
6
|
`)}async function Y(e={}){let t=e.discover??B,n=e.inspect??C,r=e.log??(e=>console.log(e)),i=e.resolveCommand??N,a=e.resolveUsage??P,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=W(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:K(e)}));r(JSON.stringify(e,null,2));return}r(ue(e.all?s:s.filter(e=>q.has(K(e)))))}function de(){return new t(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await Y({all:t.all===!0||e===`all`,json:t.json===!0})})}function fe(e,t,n={}){let r=n.isAlive??i,a=[];for(let[n,i]of[[`server`,e],[`ui`,t]])(i.status===`alive`||i.status===`foreign-host`&&r(i.lock.pid))&&a.push({name:n,pid:i.lock.pid,port:i.lock.port});return{targets:a}}function X(e){let t=e.inspect??(t=>C(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=fe(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function Z(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function pe(e,t=i){let n=await B(),r=null;for(let i of n){let n=C(i,`server`),a=C(i,`ui`);if(Z(n,t)&&n.lock.port===e||Z(a,t)&&a.lock.port===e)return i;r===null&&(Z(n,t)&&n.lock.pid===e||Z(a,t)&&a.lock.pid===e)&&(r=i)}return r}function Q(e){let t=X({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function me(e){return new t(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=X({lockDir:c(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await Y({});return}if(n===`all`){let e=await B();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=C(n,`server`),r=C(n,`ui`);!Z(e,i)&&!Z(r,i)||(Q(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await pe(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Q(t);return}Q(c(n))})}async function he(e,t){let n,r;try{n=await S(g(e)),r=await S(g(ee(e)))}catch{return{kind:`not-git`}}if(!$(n,r))return{kind:`symlink-escape`};let i=m(n,`.git`),a;try{a=y(i)}catch{return{kind:`not-git`}}let o;if(a.isDirectory()){let e;try{e=await S(i)}catch{return{kind:`not-git`}}if(!$(e,n))return{kind:`symlink-escape`};o=e}else if(a.isFile()){let e;try{e=await x(i,`utf-8`)}catch{return{kind:`not-git`}}let t=/^gitdir:\s*(.+)$/m.exec(e.trim());if(!t)return{kind:`not-git`};let r=t[1].trim(),a=p(r)?r:g(n,r);try{o=await S(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=m(await ge(o),`config`),c;try{c=await x(s,`utf-8`)}catch{return{kind:`not-git`}}let l=ve(c);if(l===null)return{kind:`no-origin`};let u=T(l);if(u===null||u.hostname!==`github.com`)return{kind:`non-github`};let d=u.owner.toLowerCase()===t.owner.toLowerCase(),f=u.name.toLowerCase()===t.repo.toLowerCase();return!d||!f?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://github.com/${u.owner}/${u.name}.git`}}async function ge(e){let t;try{t=(await x(m(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=p(t)?t:g(e,t);try{return await S(n)}catch{return n}}function $(e,t){if(e===t)return!0;let n=h(t,e);return n.length>0&&!n.startsWith(`..`)&&!p(n)}function _e(e){let t=e.indexOf(`#`),n=e.indexOf(`;`),r=-1;return t>=0&&n>=0?r=Math.min(t,n):t>=0?r=t:n>=0&&(r=n),(r===-1?e:e.slice(0,r)).trim()}function ve(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=_e(n);if(e.length===0)continue;if(e.startsWith(`[`)){t=/^\[\s*remote\s+["']origin["']\s*\]$/.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/.exec(e);if(r)return ye(r[1])}return null}function ye(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const be=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=a(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let n=u(e,t);return{integration:`project-skill`,editorId:e.id,action:n.action,...n.path?{path:n.path}:{},...n.error?{error:n.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function xe(e,t,n={},r=be){let i=[];for(let a of t){let t=s[a];for(let a of r)i.push(a.write(t,e,n))}return i}function Se(e,t,n={}){return{integrations:xe(e,t,n),claudeLaunchJson:t.includes(`claude`)?o(e,n):void 0}}export{de as a,P as c,C as d,me as i,E as l,he as n,B as o,X as r,N as s,Se as t,T as u};
|
|
7
|
-
//# sourceMappingURL=src-
|
|
7
|
+
//# sourceMappingURL=src-ClkLa20g.mjs.map
|