@imenam/mcp-documentor 1.0.72 → 1.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +271 -259
  2. package/dist/shared/schemas/doc.schema.d.ts +1 -4
  3. package/dist/shared/schemas/doc.schema.js +1 -4
  4. package/dist/src/cli/setup-mcp.d.ts +20 -1
  5. package/dist/src/cli/setup-mcp.js +65 -6
  6. package/dist/src/core/conflict-inspector.d.ts +13 -0
  7. package/dist/src/core/conflict-inspector.js +17 -0
  8. package/dist/src/core/git-sync.d.ts +11 -4
  9. package/dist/src/core/git-sync.js +33 -22
  10. package/dist/src/core/storage-engine.d.ts +14 -15
  11. package/dist/src/core/storage-engine.js +15 -51
  12. package/dist/src/gui-worker.js +91 -34
  13. package/dist/src/index.js +100 -110
  14. package/dist/src/tools/check-links.js +1 -1
  15. package/dist/src/tools/conflicts.js +50 -5
  16. package/dist/src/tools/list-projects.js +7 -5
  17. package/dist/src/tools/sync.js +14 -7
  18. package/dist/src/version.d.ts +1 -1
  19. package/dist/src/version.js +1 -1
  20. package/gui/dist/assets/{arc-KWKRz6LO.js → arc-CsM5OJTM.js} +1 -1
  21. package/gui/dist/assets/{architectureDiagram-3BPJPVTR-Cjfl98ZS.js → architectureDiagram-3BPJPVTR-BwIu1llT.js} +1 -1
  22. package/gui/dist/assets/{blockDiagram-GPEHLZMM-CtPUrnse.js → blockDiagram-GPEHLZMM-BVijVnPI.js} +1 -1
  23. package/gui/dist/assets/{c4Diagram-AAUBKEIU-Dh5_7IZy.js → c4Diagram-AAUBKEIU-D-rcZUZu.js} +1 -1
  24. package/gui/dist/assets/channel-DKPwwuQf.js +1 -0
  25. package/gui/dist/assets/{chunk-2J33WTMH-44T5JbXy.js → chunk-2J33WTMH-ByfTGREe.js} +1 -1
  26. package/gui/dist/assets/{chunk-4BX2VUAB-D1fEQ0Ng.js → chunk-4BX2VUAB-B_5oCXyz.js} +1 -1
  27. package/gui/dist/assets/{chunk-55IACEB6-M2lEB2Vn.js → chunk-55IACEB6-Bc2Kq9HD.js} +1 -1
  28. package/gui/dist/assets/{chunk-727SXJPM-B3A_Fp4f.js → chunk-727SXJPM-CVwmKEMQ.js} +1 -1
  29. package/gui/dist/assets/{chunk-AQP2D5EJ-CqkJXv3c.js → chunk-AQP2D5EJ-BkMuEFxD.js} +1 -1
  30. package/gui/dist/assets/{chunk-FMBD7UC4-Iyj_Ky8e.js → chunk-FMBD7UC4-CU7EDl9I.js} +1 -1
  31. package/gui/dist/assets/{chunk-ND2GUHAM-DE5R-C9U.js → chunk-ND2GUHAM-1b34Dtkn.js} +1 -1
  32. package/gui/dist/assets/{chunk-QZHKN3VN-BekBU-YP.js → chunk-QZHKN3VN-DnUfMecI.js} +1 -1
  33. package/gui/dist/assets/classDiagram-4FO5ZUOK-CnCvVGW9.js +1 -0
  34. package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-CnCvVGW9.js +1 -0
  35. package/gui/dist/assets/{cose-bilkent-S5V4N54A-Dw2zOlxr.js → cose-bilkent-S5V4N54A-D9OBrxKr.js} +1 -1
  36. package/gui/dist/assets/{dagre-BM42HDAG-ebVZNyxI.js → dagre-BM42HDAG-zDqwL8xs.js} +1 -1
  37. package/gui/dist/assets/{diagram-2AECGRRQ-Bh5FUKy0.js → diagram-2AECGRRQ-ejbP8WIj.js} +1 -1
  38. package/gui/dist/assets/{diagram-5GNKFQAL-YJJTJy-Q.js → diagram-5GNKFQAL-Cv9WmtFO.js} +1 -1
  39. package/gui/dist/assets/{diagram-KO2AKTUF-D161kBvB.js → diagram-KO2AKTUF-BI0ybJiN.js} +1 -1
  40. package/gui/dist/assets/{diagram-LMA3HP47-Drcmx9J8.js → diagram-LMA3HP47-DlVGttLq.js} +1 -1
  41. package/gui/dist/assets/{diagram-OG6HWLK6-DRrxnW_H.js → diagram-OG6HWLK6-DjoAH-Fq.js} +1 -1
  42. package/gui/dist/assets/{erDiagram-TEJ5UH35-FrH4iEa3.js → erDiagram-TEJ5UH35-BVQHVGK4.js} +1 -1
  43. package/gui/dist/assets/{flowDiagram-I6XJVG4X-BMxSElvH.js → flowDiagram-I6XJVG4X-oZP2Z-6T.js} +1 -1
  44. package/gui/dist/assets/{ganttDiagram-6RSMTGT7-H09FGGUr.js → ganttDiagram-6RSMTGT7-dy4QyEOP.js} +1 -1
  45. package/gui/dist/assets/{gitGraphDiagram-PVQCEYII-DLhPfXNp.js → gitGraphDiagram-PVQCEYII-BxgLy7Ln.js} +1 -1
  46. package/gui/dist/assets/{index-CdGsMXYw.js → index-Dtv0slFQ.js} +97 -97
  47. package/gui/dist/assets/index-QkCDSQ2A.css +1 -0
  48. package/gui/dist/assets/{infoDiagram-5YYISTIA-CV8ctX8t.js → infoDiagram-5YYISTIA-DNOdinpR.js} +1 -1
  49. package/gui/dist/assets/{ishikawaDiagram-YF4QCWOH-BeuHUSPO.js → ishikawaDiagram-YF4QCWOH-C4pQ434G.js} +1 -1
  50. package/gui/dist/assets/{journeyDiagram-JHISSGLW-CfAHwYXQ.js → journeyDiagram-JHISSGLW-CBrVYW94.js} +1 -1
  51. package/gui/dist/assets/{kanban-definition-UN3LZRKU-CFF4KWbn.js → kanban-definition-UN3LZRKU-Df-rgiY8.js} +1 -1
  52. package/gui/dist/assets/{linear-DwZpGeRp.js → linear-B_6fRXVt.js} +1 -1
  53. package/gui/dist/assets/{mindmap-definition-RKZ34NQL-BW0yW4ap.js → mindmap-definition-RKZ34NQL-CRAd_VDM.js} +1 -1
  54. package/gui/dist/assets/{pieDiagram-4H26LBE5-plBCN_c7.js → pieDiagram-4H26LBE5-CJkmLrDI.js} +1 -1
  55. package/gui/dist/assets/{quadrantDiagram-W4KKPZXB-Dmp9sOq_.js → quadrantDiagram-W4KKPZXB-D-rDEcnF.js} +1 -1
  56. package/gui/dist/assets/{requirementDiagram-4Y6WPE33-CthKC15J.js → requirementDiagram-4Y6WPE33-DE8MhSMe.js} +1 -1
  57. package/gui/dist/assets/{sankeyDiagram-5OEKKPKP-BCAzzfPU.js → sankeyDiagram-5OEKKPKP-BwlxtrUs.js} +1 -1
  58. package/gui/dist/assets/{sequenceDiagram-3UESZ5HK-DgwOe82k.js → sequenceDiagram-3UESZ5HK-B4LjBzWg.js} +1 -1
  59. package/gui/dist/assets/{stateDiagram-AJRCARHV-B6k-x1TC.js → stateDiagram-AJRCARHV-Bv72afPK.js} +1 -1
  60. package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-BKJDOkkR.js +1 -0
  61. package/gui/dist/assets/{timeline-definition-PNZ67QCA-CqwqJkZw.js → timeline-definition-PNZ67QCA-CBxgf8iW.js} +1 -1
  62. package/gui/dist/assets/{vennDiagram-CIIHVFJN-REFDrI5t.js → vennDiagram-CIIHVFJN-DPSdK06q.js} +1 -1
  63. package/gui/dist/assets/{wardley-L42UT6IY-53gLZWfR.js → wardley-L42UT6IY-JIAzuoPm.js} +1 -1
  64. package/gui/dist/assets/{wardleyDiagram-YWT4CUSO-OPfKpNx-.js → wardleyDiagram-YWT4CUSO-YDfaF1wT.js} +1 -1
  65. package/gui/dist/assets/{xychartDiagram-2RQKCTM6-HWGySgFg.js → xychartDiagram-2RQKCTM6-DHlPryZX.js} +1 -1
  66. package/gui/dist/index.html +2 -2
  67. package/package.json +65 -65
  68. package/dist/src/tools/set-project.d.ts +0 -14
  69. package/dist/src/tools/set-project.js +0 -18
  70. package/gui/dist/assets/channel-JejxY436.js +0 -1
  71. package/gui/dist/assets/classDiagram-4FO5ZUOK-CdAqI_QA.js +0 -1
  72. package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-CdAqI_QA.js +0 -1
  73. package/gui/dist/assets/index-DAzSbGj_.css +0 -1
  74. package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-bfw3SR0t.js +0 -1
@@ -1,3 +1,4 @@
1
+ import matter from "gray-matter";
1
2
  import { z } from "zod";
2
3
  import { parseConflicts, applyResolutions, preview, hasConflictMarkers } from "../core/conflict-inspector.js";
3
4
  const ok = (text) => ({ content: [{ type: "text", text }] });
@@ -73,7 +74,8 @@ export async function getConflictHunks(syncEngine, args) {
73
74
  return ok(`None of the requested hunks exist in "${v.path}" (it has ${hunks.length}).`);
74
75
  const lines = [`${v.path} — ${wanted.length} of ${hunks.length} hunk(s), during a ${operation}.`, ""];
75
76
  for (const hunk of wanted) {
76
- lines.push(`Hunk ${hunk.index} — section "${hunk.section}" (line ${hunk.line})`);
77
+ const scope = hunk.inFrontmatter ? " [frontmatter — \"both\" is not available, it would duplicate a key]" : "";
78
+ lines.push(`Hunk ${hunk.index} — section "${hunk.section}" (line ${hunk.line})${scope}`);
77
79
  if (hunk.base)
78
80
  lines.push(` [base — what both sides started from]`, preview(hunk.base, v.max_chars_per_side));
79
81
  lines.push(` [local — this machine]`, preview(hunk.local, v.max_chars_per_side));
@@ -112,10 +114,53 @@ export async function resolveConflictHunks(syncEngine, args) {
112
114
  if (!hasConflictMarkers(original)) {
113
115
  return err(`"${v.path}" has no conflict markers — there is nothing to resolve hunk by hunk.`);
114
116
  }
115
- const result = applyResolutions(original, operation, decisions);
116
- // The invariant is checked against the text itself rather than the hunk
117
- // count: staging a file that still holds markers tells git the conflict is
118
- // settled and lets the markers be committed as documentation content.
117
+ // Concatenating both sides of a frontmatter hunk repeats the key it holds,
118
+ // which makes the YAML unparseable for every reader of the document.
119
+ const { hunks } = parseConflicts(original, operation);
120
+ const badBoth = v.decisions.filter((d) => d.take === "both" && hunks.find((h) => h.index === d.hunk)?.inFrontmatter);
121
+ if (badBoth.length > 0) {
122
+ return err(`Hunk(s) ${badBoth.map((d) => d.hunk).join(", ")} concern frontmatter, where "both" would duplicate a key and break the YAML. ` +
123
+ `Use "local", "remote", or "custom" with the single value you want.`);
124
+ }
125
+ // A hoisted frontmatter block lives in the body but describes YAML keys.
126
+ // Applying its chosen side literally would paste "title: X" into the prose
127
+ // and leave the real frontmatter untouched, so those hunks are dropped from
128
+ // the body and their values folded back into the frontmatter instead.
129
+ const frontmatterUpdates = {};
130
+ const effective = decisions.map((decision) => {
131
+ const hunk = hunks.find((h) => h.index === decision.index);
132
+ if (!hunk?.hoisted)
133
+ return decision;
134
+ const chosen = decision.take === "local" ? hunk.local
135
+ : decision.take === "remote" ? hunk.remote
136
+ : decision.take === "custom" ? decision.content.split(/\r?\n/)
137
+ : [];
138
+ if (chosen.length > 0) {
139
+ try {
140
+ const asYaml = ["---", ...chosen, "---", ""].join("\n");
141
+ Object.assign(frontmatterUpdates, matter(asYaml).data);
142
+ }
143
+ catch {
144
+ // Not parseable as YAML - leave the frontmatter alone rather than
145
+ // corrupting it; the caller still sees the block disappear.
146
+ }
147
+ }
148
+ return { index: decision.index, take: "none" };
149
+ });
150
+ const result = applyResolutions(original, operation, effective);
151
+ if (Object.keys(frontmatterUpdates).length > 0) {
152
+ try {
153
+ const parsed = matter(result.text);
154
+ result.text = matter.stringify(parsed.content, { ...parsed.data, ...frontmatterUpdates });
155
+ }
156
+ catch {
157
+ // Frontmatter still holds markers of its own; it will be rewritten
158
+ // once those hunks are resolved too.
159
+ }
160
+ }
161
+ // The invariant is checked against the resulting text rather than the hunk
162
+ // bookkeeping: staging a file that still holds markers tells git the
163
+ // conflict is settled and lets them be committed as documentation content.
119
164
  const settled = !hasConflictMarkers(result.text);
120
165
  await syncEngine.writeResolvedFile(v.path, result.text, settled);
121
166
  const lines = [`Resolved ${result.applied.length} hunk(s) in "${v.path}".`];
@@ -1,12 +1,14 @@
1
1
  export async function listProjects(storageEngine) {
2
2
  try {
3
3
  const config = storageEngine.getConfig();
4
- const lines = config.projects.map((p) => {
5
- const marker = p === config.currentProject ? " (active)" : "";
6
- return `- ${p}${marker}`;
7
- });
4
+ const lines = config.projects.map((p) => `- ${p}`);
8
5
  return {
9
- content: [{ type: "text", text: `Projects:\n\n${lines.join("\n")}\n\nCurrent project: ${config.currentProject}` }],
6
+ content: [
7
+ {
8
+ type: "text",
9
+ text: `Projects:\n\n${lines.join("\n")}\n\nThere is no active project: every tool call names the project it targets explicitly.`,
10
+ },
11
+ ],
10
12
  };
11
13
  }
12
14
  catch (err) {
@@ -34,16 +34,23 @@ export async function syncStatus(syncEngine) {
34
34
  return err(`Error getting sync status: ${e instanceof Error ? e.message : String(e)}`);
35
35
  }
36
36
  }
37
+ /**
38
+ * A pull commits uncommitted local edits before rebasing over them - worth
39
+ * saying, since the caller did not ask for a commit.
40
+ */
41
+ function autoCommitNote(autoCommitted) {
42
+ return autoCommitted
43
+ ? "Your uncommitted local changes were committed first so they could be replayed on top of the remote.\n"
44
+ : "";
45
+ }
37
46
  function describePull(res) {
38
47
  switch (res.status) {
39
48
  case "up-to-date":
40
49
  return "Already up to date — nothing to pull.";
41
50
  case "updated":
42
- return `Pulled ${res.changed.length} changed file(s):\n - ${res.changed.join("\n - ")}`;
43
- case "diverged":
44
- return `You have uncommitted local changes while the remote has ${res.behind} new commit(s). No changes applied — your local data is intact. Run push_docs to commit and publish your changes, then pull again.`;
51
+ return `${autoCommitNote(res.autoCommitted)}Pulled ${res.changed.length} changed file(s):\n - ${res.changed.join("\n - ")}`;
45
52
  case "conflict":
46
- return `Conflict in ${res.conflicted.length} file(s):\n - ${res.conflicted.join("\n - ")}\nResolve with resolve_sync_conflict (side "local" keeps this machine version, "remote" keeps the other machine version), or edit these markdown files directly. Then run push_docs.`;
53
+ return `${autoCommitNote(res.autoCommitted)}Conflict in ${res.conflicted.length} file(s):\n - ${res.conflicted.join("\n - ")}\nResolve with resolve_sync_conflict (side "local" keeps this machine version, "remote" keeps the other machine version), or edit these markdown files directly. Then run push_docs.`;
47
54
  }
48
55
  }
49
56
  /** Reindex embeddings for new docs after a successful merge. Best-effort. */
@@ -92,9 +99,9 @@ export async function syncDocs(syncEngine, storageEngine, embeddingEngine, embed
92
99
  const v = PushDocsArgs.parse(args);
93
100
  const pull = await syncEngine.pull();
94
101
  const reindexNote = await reindexAfterPull(pull, storageEngine, embeddingEngine, embeddingStore);
95
- // Don't push over a divergence/conflict — surface it so the user can resolve first.
96
- if (pull.status === "diverged" || pull.status === "conflict") {
97
- return ok(`Pull step:\n${describePull(pull)}${reindexNote}\n\nPush skipped until the above is resolved.`);
102
+ // Don't push over a conflict — surface it so the caller can resolve first.
103
+ if (pull.status === "conflict") {
104
+ return ok(`Pull step:\n${describePull(pull)}${reindexNote}\n\nPush skipped until the conflict is resolved.`);
98
105
  }
99
106
  const push = await syncEngine.push(v.message);
100
107
  return ok(`Pull step: ${describePull(pull)}${reindexNote}\n\nPush step: ${push.message}`);
@@ -1 +1 @@
1
- export declare const APP_VERSION = "1.0.72";
1
+ export declare const APP_VERSION = "1.0.76";
@@ -1,2 +1,2 @@
1
1
  // Auto-generated version file - do not edit manually
2
- export const APP_VERSION = '1.0.72';
2
+ export const APP_VERSION = '1.0.76';
@@ -1 +1 @@
1
- import{a0 as ln,a1 as an,a2 as y,a3 as tn,a4 as H,a5 as q,a6 as _,a7 as un,a8 as rn,a9 as L,aa as o,ab as B,ac as sn,ad as on,ae as fn}from"./index-CdGsMXYw.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,C,a){var O=I-l,i=D-h,n=C-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function W(l,h,I,D,v,A,C){var a=l-I,O=h-D,i=(C?A:-A)/L(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,F=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*L(fn(0,T*T*R-P*P)),j=(P*g-m*S)/R,z=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=j-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(j=w,z=p),{cx:j,cy:z,x01:-n,y01:-d,x11:j*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=yn,I=B(0),D=null,v=gn,A=dn,C=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,F=un(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(F>tn-y)a.moveTo(s*H(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*H(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=F,S=F,j=C.apply(this,arguments)/2,z=j>y&&(D?+D.apply(this,arguments):L(u*u+s*s)),w=_(un(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(z>y){var G=sn(z/u*q(j)),M=sn(z/s*q(j));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(S-=M*2)>y?(M*=t?1:-1,m+=M,g-=M):(S=0,m=g=(f+c)/2)}var J=s*H(m),K=s*q(m),N=u*H(T),Q=u*q(T);if(w>y){var U=s*H(g),V=s*q(g),X=u*H(R),Y=u*q(R),E;if(F<rn)if(E=pn(J,K,X,Y,U,V,N,Q)){var Z=J-E[0],$=K-E[1],b=U-E[0],k=V-E[1],nn=1/q(on((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,g,!t)):a.moveTo(J,K),!(u>y)||!(P>y)?a.lineTo(N,Q):p>y?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-rn/2;return[H(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:B(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:B(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{a0 as ln,a1 as an,a2 as y,a3 as tn,a4 as H,a5 as q,a6 as _,a7 as un,a8 as rn,a9 as L,aa as o,ab as B,ac as sn,ad as on,ae as fn}from"./index-Dtv0slFQ.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,C,a){var O=I-l,i=D-h,n=C-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function W(l,h,I,D,v,A,C){var a=l-I,O=h-D,i=(C?A:-A)/L(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,F=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*L(fn(0,T*T*R-P*P)),j=(P*g-m*S)/R,z=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=j-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(j=w,z=p),{cx:j,cy:z,x01:-n,y01:-d,x11:j*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=yn,I=B(0),D=null,v=gn,A=dn,C=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,F=un(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(F>tn-y)a.moveTo(s*H(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*H(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=F,S=F,j=C.apply(this,arguments)/2,z=j>y&&(D?+D.apply(this,arguments):L(u*u+s*s)),w=_(un(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(z>y){var G=sn(z/u*q(j)),M=sn(z/s*q(j));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(S-=M*2)>y?(M*=t?1:-1,m+=M,g-=M):(S=0,m=g=(f+c)/2)}var J=s*H(m),K=s*q(m),N=u*H(T),Q=u*q(T);if(w>y){var U=s*H(g),V=s*q(g),X=u*H(R),Y=u*q(R),E;if(F<rn)if(E=pn(J,K,X,Y,U,V,N,Q)){var Z=J-E[0],$=K-E[1],b=U-E[0],k=V-E[1],nn=1/q(on((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,g,!t)):a.moveTo(J,K),!(u>y)||!(P>y)?a.lineTo(N,Q):p>y?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-rn/2;return[H(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:B(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:B(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};