@imenam/mcp-documentor 1.0.55 → 1.0.57

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 (64) hide show
  1. package/README.md +70 -0
  2. package/dist/shared/read-only.d.ts +4 -0
  3. package/dist/shared/read-only.js +14 -0
  4. package/dist/src/core/git-sync.d.ts +56 -0
  5. package/dist/src/core/git-sync.js +215 -0
  6. package/dist/src/core/storage-engine.d.ts +22 -0
  7. package/dist/src/core/storage-engine.js +62 -3
  8. package/dist/src/gui-worker.js +18 -0
  9. package/dist/src/index.js +450 -332
  10. package/dist/src/tools/sync.d.ts +17 -0
  11. package/dist/src/tools/sync.js +113 -0
  12. package/dist/src/version.d.ts +1 -1
  13. package/dist/src/version.js +1 -1
  14. package/gui/dist/assets/{arc-CCHCB-wD.js → arc-hl-9jVa3.js} +1 -1
  15. package/gui/dist/assets/{architectureDiagram-3BPJPVTR-CY9HTuIq.js → architectureDiagram-3BPJPVTR-Cv0e-QlI.js} +1 -1
  16. package/gui/dist/assets/{blockDiagram-GPEHLZMM-BOVxufIP.js → blockDiagram-GPEHLZMM-DmqN7ioQ.js} +1 -1
  17. package/gui/dist/assets/{c4Diagram-AAUBKEIU-D4gw0Vvh.js → c4Diagram-AAUBKEIU-CCmx3y3D.js} +1 -1
  18. package/gui/dist/assets/channel-Be8bJJxH.js +1 -0
  19. package/gui/dist/assets/{chunk-2J33WTMH-D9MZap0G.js → chunk-2J33WTMH-DkiBzADG.js} +1 -1
  20. package/gui/dist/assets/{chunk-4BX2VUAB-DZp7afnZ.js → chunk-4BX2VUAB-DNbC5-R6.js} +1 -1
  21. package/gui/dist/assets/{chunk-55IACEB6--z45PUIk.js → chunk-55IACEB6-BDo8xvgP.js} +1 -1
  22. package/gui/dist/assets/{chunk-727SXJPM-BpzsGHwS.js → chunk-727SXJPM-BXbVbdMj.js} +1 -1
  23. package/gui/dist/assets/{chunk-AQP2D5EJ-BHrif5nf.js → chunk-AQP2D5EJ-BYle6aB3.js} +1 -1
  24. package/gui/dist/assets/{chunk-FMBD7UC4-BJnvL7mL.js → chunk-FMBD7UC4-BdIrLn1p.js} +1 -1
  25. package/gui/dist/assets/{chunk-ND2GUHAM-B30rNlK9.js → chunk-ND2GUHAM-BkjdsZf2.js} +1 -1
  26. package/gui/dist/assets/{chunk-QZHKN3VN-C30k0U0w.js → chunk-QZHKN3VN-pwVXVLDb.js} +1 -1
  27. package/gui/dist/assets/classDiagram-4FO5ZUOK-DxtDCVWj.js +1 -0
  28. package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-DxtDCVWj.js +1 -0
  29. package/gui/dist/assets/{cose-bilkent-S5V4N54A-D_ZPLp5P.js → cose-bilkent-S5V4N54A-COfRIcXU.js} +1 -1
  30. package/gui/dist/assets/{dagre-BM42HDAG-2XyC0YBj.js → dagre-BM42HDAG-BnD4nd21.js} +1 -1
  31. package/gui/dist/assets/{diagram-2AECGRRQ-fNv6yQF_.js → diagram-2AECGRRQ-E9oTEn4C.js} +1 -1
  32. package/gui/dist/assets/{diagram-5GNKFQAL-BUlxr0NW.js → diagram-5GNKFQAL-oSJwag8_.js} +1 -1
  33. package/gui/dist/assets/{diagram-KO2AKTUF-CtusNGfh.js → diagram-KO2AKTUF-B5ycmD2n.js} +1 -1
  34. package/gui/dist/assets/{diagram-LMA3HP47-Dkq3FOEe.js → diagram-LMA3HP47-DUo9wv_e.js} +1 -1
  35. package/gui/dist/assets/{diagram-OG6HWLK6-rjhcMJNr.js → diagram-OG6HWLK6-C-0r9-AW.js} +1 -1
  36. package/gui/dist/assets/{erDiagram-TEJ5UH35-Bqmogkqv.js → erDiagram-TEJ5UH35-C8w0nNRI.js} +1 -1
  37. package/gui/dist/assets/{flowDiagram-I6XJVG4X-BcYYq0Bh.js → flowDiagram-I6XJVG4X-CPZzt4CO.js} +1 -1
  38. package/gui/dist/assets/{ganttDiagram-6RSMTGT7-BGmJltMK.js → ganttDiagram-6RSMTGT7-B0TRw-bC.js} +1 -1
  39. package/gui/dist/assets/{gitGraphDiagram-PVQCEYII-JIYjcd0T.js → gitGraphDiagram-PVQCEYII-CxuhZqVM.js} +1 -1
  40. package/gui/dist/assets/{index-BwW5YDD1.js → index-84YuA9I8.js} +75 -75
  41. package/gui/dist/assets/{infoDiagram-5YYISTIA-CJKrfqe4.js → infoDiagram-5YYISTIA-qLgkATyo.js} +1 -1
  42. package/gui/dist/assets/{ishikawaDiagram-YF4QCWOH-Bu4wBvlL.js → ishikawaDiagram-YF4QCWOH-Bv8EcedY.js} +1 -1
  43. package/gui/dist/assets/{journeyDiagram-JHISSGLW-B2CtojGV.js → journeyDiagram-JHISSGLW-CO1wpi9j.js} +1 -1
  44. package/gui/dist/assets/{kanban-definition-UN3LZRKU-CKbuCL_h.js → kanban-definition-UN3LZRKU-INpnb6ij.js} +1 -1
  45. package/gui/dist/assets/{linear-BdHWi7h7.js → linear-yh3g20kh.js} +1 -1
  46. package/gui/dist/assets/{mindmap-definition-RKZ34NQL-Dbf71zzi.js → mindmap-definition-RKZ34NQL-BzSJP5cs.js} +1 -1
  47. package/gui/dist/assets/{pieDiagram-4H26LBE5-P8RSqdBA.js → pieDiagram-4H26LBE5-DH9i355H.js} +1 -1
  48. package/gui/dist/assets/{quadrantDiagram-W4KKPZXB-mVsJmQan.js → quadrantDiagram-W4KKPZXB-CNmW8Mck.js} +1 -1
  49. package/gui/dist/assets/{requirementDiagram-4Y6WPE33-BfHNLWFb.js → requirementDiagram-4Y6WPE33-DIxitFst.js} +1 -1
  50. package/gui/dist/assets/{sankeyDiagram-5OEKKPKP-CF28kVcG.js → sankeyDiagram-5OEKKPKP-BI4KHeTZ.js} +1 -1
  51. package/gui/dist/assets/{sequenceDiagram-3UESZ5HK-Bvs2r29Y.js → sequenceDiagram-3UESZ5HK-CbMtHFNi.js} +1 -1
  52. package/gui/dist/assets/{stateDiagram-AJRCARHV-Cbg-3kIx.js → stateDiagram-AJRCARHV-DWXkOhjJ.js} +1 -1
  53. package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-Dv9pwdh3.js +1 -0
  54. package/gui/dist/assets/{timeline-definition-PNZ67QCA-ChYm8r8v.js → timeline-definition-PNZ67QCA-DGsBQPbg.js} +1 -1
  55. package/gui/dist/assets/{vennDiagram-CIIHVFJN-CPcYOWG6.js → vennDiagram-CIIHVFJN-Dw5U_iYl.js} +1 -1
  56. package/gui/dist/assets/{wardley-L42UT6IY-KWdiWaFE.js → wardley-L42UT6IY-DGOHyaD_.js} +1 -1
  57. package/gui/dist/assets/{wardleyDiagram-YWT4CUSO-DAgBnDcZ.js → wardleyDiagram-YWT4CUSO-DpOyo37L.js} +1 -1
  58. package/gui/dist/assets/{xychartDiagram-2RQKCTM6-DwOk_srp.js → xychartDiagram-2RQKCTM6-BM5vPGiE.js} +1 -1
  59. package/gui/dist/index.html +1 -1
  60. package/package.json +2 -1
  61. package/gui/dist/assets/channel-V0oafPxe.js +0 -1
  62. package/gui/dist/assets/classDiagram-4FO5ZUOK-BZlXnsXv.js +0 -1
  63. package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-BZlXnsXv.js +0 -1
  64. package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-Cg1sS-MT.js +0 -1
@@ -0,0 +1,17 @@
1
+ import type { SyncEngine } from "../core/git-sync.js";
2
+ import type { StorageEngine } from "../core/storage-engine.js";
3
+ import type { EmbeddingEngine } from "../core/embedding-engine.js";
4
+ import type { EmbeddingStore } from "../core/embedding-store.js";
5
+ type ToolResult = {
6
+ content: {
7
+ type: "text";
8
+ text: string;
9
+ }[];
10
+ isError?: boolean;
11
+ };
12
+ export declare function syncStatus(syncEngine: SyncEngine): Promise<ToolResult>;
13
+ export declare function pullDocs(syncEngine: SyncEngine, storageEngine: StorageEngine, embeddingEngine: EmbeddingEngine, embeddingStore: EmbeddingStore): Promise<ToolResult>;
14
+ export declare function pushDocs(syncEngine: SyncEngine, args: unknown): Promise<ToolResult>;
15
+ export declare function syncDocs(syncEngine: SyncEngine, storageEngine: StorageEngine, embeddingEngine: EmbeddingEngine, embeddingStore: EmbeddingStore, args: unknown): Promise<ToolResult>;
16
+ export declare function resolveSyncConflict(syncEngine: SyncEngine, args: unknown): Promise<ToolResult>;
17
+ export {};
@@ -0,0 +1,113 @@
1
+ import { z } from "zod";
2
+ import { reindexEmbeddings } from "./reindex-embeddings.js";
3
+ function ok(text) {
4
+ return { content: [{ type: "text", text }] };
5
+ }
6
+ function err(text) {
7
+ return { content: [{ type: "text", text }], isError: true };
8
+ }
9
+ const NOT_CONFIGURED = "Sync is not configured. Set MCP_DOCUMENTOR_SYNC_REMOTE (and MCP_DOCUMENTOR_SYNC_TOKEN) in the server environment.";
10
+ export async function syncStatus(syncEngine) {
11
+ try {
12
+ if (!syncEngine.isConfigured())
13
+ return ok(NOT_CONFIGURED);
14
+ const s = await syncEngine.status();
15
+ const lines = [
16
+ `Branch: ${s.branch}`,
17
+ `Ahead: ${s.ahead} commit(s) · Behind: ${s.behind} commit(s)`,
18
+ s.conflicted.length > 0 ? `Conflicted files (${s.conflicted.length}):\n - ${s.conflicted.join("\n - ")}` : "No conflicts.",
19
+ s.dirty.length > 0 ? `Uncommitted changes (${s.dirty.length}):\n - ${s.dirty.join("\n - ")}` : "Working tree clean.",
20
+ ];
21
+ return ok(lines.join("\n"));
22
+ }
23
+ catch (e) {
24
+ return err(`Error getting sync status: ${e instanceof Error ? e.message : String(e)}`);
25
+ }
26
+ }
27
+ function describePull(res) {
28
+ switch (res.status) {
29
+ case "up-to-date":
30
+ return "Already up to date — nothing to pull.";
31
+ case "updated":
32
+ return `Pulled ${res.changed.length} changed file(s):\n - ${res.changed.join("\n - ")}`;
33
+ case "diverged":
34
+ 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 to merge.`;
35
+ case "conflict":
36
+ return `Merge conflict in ${res.conflicted.length} file(s):\n - ${res.conflicted.join("\n - ")}\nEdit these markdown files to resolve, or use resolve_sync_conflict, then push_docs.`;
37
+ }
38
+ }
39
+ /** Reindex embeddings for new docs after a successful merge. Best-effort. */
40
+ async function reindexAfterPull(res, storageEngine, embeddingEngine, embeddingStore) {
41
+ if (res.status !== "updated" || res.changed.length === 0)
42
+ return "";
43
+ if (!embeddingEngine.isConfigured())
44
+ return "\n(Embeddings not reindexed: OpenAI key not configured.)";
45
+ try {
46
+ await reindexEmbeddings(storageEngine, embeddingEngine, embeddingStore, {});
47
+ return "\nEmbeddings reindexed for new documents.";
48
+ }
49
+ catch (e) {
50
+ return `\n(Embedding reindex failed: ${e instanceof Error ? e.message : String(e)})`;
51
+ }
52
+ }
53
+ export async function pullDocs(syncEngine, storageEngine, embeddingEngine, embeddingStore) {
54
+ try {
55
+ if (!syncEngine.isConfigured())
56
+ return err(NOT_CONFIGURED);
57
+ const res = await syncEngine.pull();
58
+ const reindexNote = await reindexAfterPull(res, storageEngine, embeddingEngine, embeddingStore);
59
+ return ok(describePull(res) + reindexNote);
60
+ }
61
+ catch (e) {
62
+ return err(`Error pulling docs: ${e instanceof Error ? e.message : String(e)}`);
63
+ }
64
+ }
65
+ const PushDocsArgs = z.object({ message: z.string().optional() });
66
+ export async function pushDocs(syncEngine, args) {
67
+ try {
68
+ if (!syncEngine.isConfigured())
69
+ return err(NOT_CONFIGURED);
70
+ const v = PushDocsArgs.parse(args);
71
+ const res = await syncEngine.push(v.message);
72
+ return ok(res.message);
73
+ }
74
+ catch (e) {
75
+ return err(`Error pushing docs: ${e instanceof Error ? e.message : String(e)}`);
76
+ }
77
+ }
78
+ export async function syncDocs(syncEngine, storageEngine, embeddingEngine, embeddingStore, args) {
79
+ try {
80
+ if (!syncEngine.isConfigured())
81
+ return err(NOT_CONFIGURED);
82
+ const v = PushDocsArgs.parse(args);
83
+ const pull = await syncEngine.pull();
84
+ const reindexNote = await reindexAfterPull(pull, storageEngine, embeddingEngine, embeddingStore);
85
+ // Don't push over a divergence/conflict — surface it so the user can resolve first.
86
+ if (pull.status === "diverged" || pull.status === "conflict") {
87
+ return ok(`Pull step:\n${describePull(pull)}${reindexNote}\n\nPush skipped until the above is resolved.`);
88
+ }
89
+ const push = await syncEngine.push(v.message);
90
+ return ok(`Pull step: ${describePull(pull)}${reindexNote}\n\nPush step: ${push.message}`);
91
+ }
92
+ catch (e) {
93
+ return err(`Error syncing docs: ${e instanceof Error ? e.message : String(e)}`);
94
+ }
95
+ }
96
+ const ResolveConflictArgs = z.object({
97
+ strategy: z.enum(["mine", "theirs"]),
98
+ paths: z.array(z.string()).optional(),
99
+ });
100
+ export async function resolveSyncConflict(syncEngine, args) {
101
+ try {
102
+ if (!syncEngine.isConfigured())
103
+ return err(NOT_CONFIGURED);
104
+ const v = ResolveConflictArgs.parse(args);
105
+ const resolved = await syncEngine.resolveConflict(v.strategy, v.paths);
106
+ if (resolved.length === 0)
107
+ return ok("No conflicted files to resolve.");
108
+ return ok(`Resolved ${resolved.length} file(s) keeping "${v.strategy}":\n - ${resolved.join("\n - ")}\nReview and run push_docs to finalize.`);
109
+ }
110
+ catch (e) {
111
+ return err(`Error resolving conflict: ${e instanceof Error ? e.message : String(e)}`);
112
+ }
113
+ }
@@ -1 +1 @@
1
- export declare const APP_VERSION = "1.0.55";
1
+ export declare const APP_VERSION = "1.0.57";
@@ -1,2 +1,2 @@
1
1
  // Auto-generated version file - do not edit manually
2
- export const APP_VERSION = '1.0.55';
2
+ export const APP_VERSION = '1.0.57';
@@ -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-BwW5YDD1.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-84YuA9I8.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};