@justyork/repo-mind 0.3.0

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 (177) hide show
  1. package/README.md +110 -0
  2. package/dist/ab-demo/arm-baseline.d.ts +8 -0
  3. package/dist/ab-demo/arm-baseline.js +40 -0
  4. package/dist/ab-demo/arm-repomind.d.ts +7 -0
  5. package/dist/ab-demo/arm-repomind.js +35 -0
  6. package/dist/ab-demo/estimate-tokens.d.ts +3 -0
  7. package/dist/ab-demo/estimate-tokens.js +10 -0
  8. package/dist/ab-demo/load-questions.d.ts +2 -0
  9. package/dist/ab-demo/load-questions.js +65 -0
  10. package/dist/ab-demo/paths.d.ts +5 -0
  11. package/dist/ab-demo/paths.js +31 -0
  12. package/dist/ab-demo/run-ab.d.ts +7 -0
  13. package/dist/ab-demo/run-ab.js +128 -0
  14. package/dist/ab-demo/run-arms.d.ts +3 -0
  15. package/dist/ab-demo/run-arms.js +67 -0
  16. package/dist/ab-demo/session-overhead.d.ts +3 -0
  17. package/dist/ab-demo/session-overhead.js +68 -0
  18. package/dist/ab-demo/types.d.ts +65 -0
  19. package/dist/ab-demo/types.js +1 -0
  20. package/dist/ab-demo/validate-corpus.d.ts +3 -0
  21. package/dist/ab-demo/validate-corpus.js +38 -0
  22. package/dist/check/collect-violations.d.ts +11 -0
  23. package/dist/check/collect-violations.js +127 -0
  24. package/dist/cli.d.ts +2 -0
  25. package/dist/cli.js +147 -0
  26. package/dist/commands/check.d.ts +6 -0
  27. package/dist/commands/check.js +19 -0
  28. package/dist/commands/export.d.ts +8 -0
  29. package/dist/commands/export.js +80 -0
  30. package/dist/commands/init.d.ts +4 -0
  31. package/dist/commands/init.js +86 -0
  32. package/dist/commands/prepare.d.ts +7 -0
  33. package/dist/commands/prepare.js +61 -0
  34. package/dist/commands/setup.d.ts +11 -0
  35. package/dist/commands/setup.js +84 -0
  36. package/dist/commands/sync-links.d.ts +7 -0
  37. package/dist/commands/sync-links.js +41 -0
  38. package/dist/commands/ui.d.ts +5 -0
  39. package/dist/commands/ui.js +83 -0
  40. package/dist/index/asset-file.d.ts +4 -0
  41. package/dist/index/asset-file.js +26 -0
  42. package/dist/index/doc-index.d.ts +21 -0
  43. package/dist/index/doc-index.js +231 -0
  44. package/dist/index/knowledge-file.d.ts +4 -0
  45. package/dist/index/knowledge-file.js +17 -0
  46. package/dist/index/link-index.d.ts +41 -0
  47. package/dist/index/link-index.js +150 -0
  48. package/dist/index/path-inference.d.ts +9 -0
  49. package/dist/index/path-inference.js +33 -0
  50. package/dist/index/resolve-asset-href.d.ts +2 -0
  51. package/dist/index/resolve-asset-href.js +65 -0
  52. package/dist/index/resolve-md-href.d.ts +7 -0
  53. package/dist/index/resolve-md-href.js +116 -0
  54. package/dist/index/slug.d.ts +5 -0
  55. package/dist/index/slug.js +43 -0
  56. package/dist/index/types.d.ts +44 -0
  57. package/dist/index/types.js +71 -0
  58. package/dist/mcp/server.d.ts +1 -0
  59. package/dist/mcp/server.js +155 -0
  60. package/dist/package-version.d.ts +2 -0
  61. package/dist/package-version.js +15 -0
  62. package/dist/prepare/auto-links.d.ts +22 -0
  63. package/dist/prepare/auto-links.js +124 -0
  64. package/dist/prepare/prepare-docs.d.ts +36 -0
  65. package/dist/prepare/prepare-docs.js +106 -0
  66. package/dist/tools/explore-graph.d.ts +25 -0
  67. package/dist/tools/explore-graph.js +84 -0
  68. package/dist/tools/get-doc.d.ts +11 -0
  69. package/dist/tools/get-doc.js +21 -0
  70. package/dist/tools/get-glossary-term.d.ts +9 -0
  71. package/dist/tools/get-glossary-term.js +41 -0
  72. package/dist/tools/list-docs.d.ts +19 -0
  73. package/dist/tools/list-docs.js +35 -0
  74. package/dist/tools/search-docs.d.ts +14 -0
  75. package/dist/tools/search-docs.js +80 -0
  76. package/dist/ui/api-handlers.d.ts +12 -0
  77. package/dist/ui/api-handlers.js +223 -0
  78. package/dist/ui/catalog-meta.d.ts +4 -0
  79. package/dist/ui/catalog-meta.js +47 -0
  80. package/dist/ui/db/drafts-db.d.ts +49 -0
  81. package/dist/ui/db/drafts-db.js +179 -0
  82. package/dist/ui/diff.d.ts +8 -0
  83. package/dist/ui/diff.js +58 -0
  84. package/dist/ui/docs-watcher.d.ts +13 -0
  85. package/dist/ui/docs-watcher.js +59 -0
  86. package/dist/ui/draft-api.d.ts +7 -0
  87. package/dist/ui/draft-api.js +413 -0
  88. package/dist/ui/fs-operations.d.ts +52 -0
  89. package/dist/ui/fs-operations.js +304 -0
  90. package/dist/ui/fs-tree.d.ts +28 -0
  91. package/dist/ui/fs-tree.js +148 -0
  92. package/dist/ui/graph-all.d.ts +5 -0
  93. package/dist/ui/graph-all.js +50 -0
  94. package/dist/ui/link-cascade.d.ts +9 -0
  95. package/dist/ui/link-cascade.js +113 -0
  96. package/dist/ui/parse-multipart.d.ts +12 -0
  97. package/dist/ui/parse-multipart.js +64 -0
  98. package/dist/ui/publish.d.ts +14 -0
  99. package/dist/ui/publish.js +83 -0
  100. package/dist/ui/safe-path.d.ts +6 -0
  101. package/dist/ui/safe-path.js +42 -0
  102. package/dist/ui/serve-asset.d.ts +4 -0
  103. package/dist/ui/serve-asset.js +49 -0
  104. package/dist/ui/server.d.ts +17 -0
  105. package/dist/ui/server.js +237 -0
  106. package/dist/ui/stats.d.ts +9 -0
  107. package/dist/ui/stats.js +23 -0
  108. package/dist/ui/templates.d.ts +12 -0
  109. package/dist/ui/templates.js +39 -0
  110. package/dist/ui/upload-asset.d.ts +11 -0
  111. package/dist/ui/upload-asset.js +61 -0
  112. package/package.json +55 -0
  113. package/templates/adr-example.md +27 -0
  114. package/templates/agent-instruction-example.md +20 -0
  115. package/templates/combat-system-example.md +27 -0
  116. package/templates/feature-spec-example.md +27 -0
  117. package/templates/glossary-term-example.md +15 -0
  118. package/templates/open-question-example.md +26 -0
  119. package/ui/dist/assets/arc-DhC0JPue.js +1 -0
  120. package/ui/dist/assets/architectureDiagram-3BPJPVTR-Cun_Ijrv.js +36 -0
  121. package/ui/dist/assets/blockDiagram-GPEHLZMM-CgiNAArN.js +132 -0
  122. package/ui/dist/assets/c4Diagram-AAUBKEIU-BIwHcwcH.js +10 -0
  123. package/ui/dist/assets/channel-CNwAp9ic.js +1 -0
  124. package/ui/dist/assets/chunk-2J33WTMH-DXRgHPpp.js +1 -0
  125. package/ui/dist/assets/chunk-4BX2VUAB-BTb70kIb.js +1 -0
  126. package/ui/dist/assets/chunk-55IACEB6-BrAelyhX.js +1 -0
  127. package/ui/dist/assets/chunk-727SXJPM-BlYnlPdj.js +206 -0
  128. package/ui/dist/assets/chunk-AQP2D5EJ-DSPgdKZ8.js +231 -0
  129. package/ui/dist/assets/chunk-FMBD7UC4-BhH8ir2K.js +15 -0
  130. package/ui/dist/assets/chunk-ND2GUHAM-DCAuTSxB.js +1 -0
  131. package/ui/dist/assets/chunk-QZHKN3VN-DtYEkbYr.js +1 -0
  132. package/ui/dist/assets/classDiagram-4FO5ZUOK-DnHeGLmR.js +1 -0
  133. package/ui/dist/assets/classDiagram-v2-Q7XG4LA2-DnHeGLmR.js +1 -0
  134. package/ui/dist/assets/cose-bilkent-S5V4N54A-CAM4jLYo.js +1 -0
  135. package/ui/dist/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
  136. package/ui/dist/assets/dagre-BM42HDAG-CISbgani.js +4 -0
  137. package/ui/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  138. package/ui/dist/assets/diagram-2AECGRRQ-BmXargwF.js +43 -0
  139. package/ui/dist/assets/diagram-5GNKFQAL-COlrLu0O.js +10 -0
  140. package/ui/dist/assets/diagram-KO2AKTUF-B-kUxuHX.js +3 -0
  141. package/ui/dist/assets/diagram-LMA3HP47-C3AVVxcm.js +24 -0
  142. package/ui/dist/assets/diagram-OG6HWLK6-JHeftSsO.js +24 -0
  143. package/ui/dist/assets/erDiagram-TEJ5UH35-BSWwMysi.js +85 -0
  144. package/ui/dist/assets/flowDiagram-I6XJVG4X-D-q1cK69.js +162 -0
  145. package/ui/dist/assets/ganttDiagram-6RSMTGT7-DrYn1H_t.js +292 -0
  146. package/ui/dist/assets/gitGraphDiagram-PVQCEYII-vJByl99X.js +106 -0
  147. package/ui/dist/assets/graph-CAnANduQ.js +1 -0
  148. package/ui/dist/assets/graph-DwoitsWW.js +2 -0
  149. package/ui/dist/assets/infoDiagram-5YYISTIA-D6zhGTMj.js +2 -0
  150. package/ui/dist/assets/init-Gi6I4Gst.js +1 -0
  151. package/ui/dist/assets/ishikawaDiagram-YF4QCWOH-CY-U_l7l.js +70 -0
  152. package/ui/dist/assets/journeyDiagram-JHISSGLW-jKj4lBEJ.js +139 -0
  153. package/ui/dist/assets/kanban-definition-UN3LZRKU-PZ-5AYw2.js +89 -0
  154. package/ui/dist/assets/katex-C5jXJg4s.js +257 -0
  155. package/ui/dist/assets/layout-DGIYPm2g.js +1 -0
  156. package/ui/dist/assets/linear-COY9pyF4.js +1 -0
  157. package/ui/dist/assets/main-BBzCq-49.js +308 -0
  158. package/ui/dist/assets/mermaid.core-Bddhr0ku.js +309 -0
  159. package/ui/dist/assets/mindmap-definition-RKZ34NQL-CPY2Fdu_.js +96 -0
  160. package/ui/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  161. package/ui/dist/assets/pieDiagram-4H26LBE5-C7GJ49et.js +30 -0
  162. package/ui/dist/assets/quadrantDiagram-W4KKPZXB-DQyQN5K7.js +7 -0
  163. package/ui/dist/assets/requirementDiagram-4Y6WPE33-CDrkwz1t.js +84 -0
  164. package/ui/dist/assets/sankeyDiagram-5OEKKPKP-BrYb9Eql.js +40 -0
  165. package/ui/dist/assets/sequenceDiagram-3UESZ5HK-B8If_JZp.js +162 -0
  166. package/ui/dist/assets/stateDiagram-AJRCARHV-BbpTp9VX.js +1 -0
  167. package/ui/dist/assets/stateDiagram-v2-BHNVJYJU-BT4PvMFS.js +1 -0
  168. package/ui/dist/assets/theme-DV7vqTnV.js +1 -0
  169. package/ui/dist/assets/theme-SpsWsRN5.css +1 -0
  170. package/ui/dist/assets/timeline-definition-PNZ67QCA-DhUg6aIV.js +120 -0
  171. package/ui/dist/assets/transform-BwXaE9hv.js +1 -0
  172. package/ui/dist/assets/vennDiagram-CIIHVFJN-DpQVNNzF.js +34 -0
  173. package/ui/dist/assets/wardley-L42UT6IY-CyaxzHGP.js +173 -0
  174. package/ui/dist/assets/wardleyDiagram-YWT4CUSO-Bm0mA7wm.js +78 -0
  175. package/ui/dist/assets/xychartDiagram-2RQKCTM6-OJbmgDx6.js +7 -0
  176. package/ui/dist/graph.html +27 -0
  177. package/ui/dist/index.html +37 -0
@@ -0,0 +1,61 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { assetApiPath, isImageFileName } from '../index/asset-file.js';
4
+ import { parseMultipartFormData } from './parse-multipart.js';
5
+ import { isValidFsName, joinRelativePath, normalizeRelativePath, resolveUnderKnowledgeRoot } from './safe-path.js';
6
+ export const MAX_ASSET_UPLOAD_BYTES = 5 * 1024 * 1024;
7
+ const DEFAULT_ASSET_DIR = 'assets';
8
+ function isUnderAssetsDir(relativeDir) {
9
+ const normalized = normalizeRelativePath(relativeDir);
10
+ if (!normalized) {
11
+ return false;
12
+ }
13
+ return normalized === 'assets' || normalized.startsWith('assets/');
14
+ }
15
+ function validateImageFileName(fileName) {
16
+ const base = path.basename(fileName);
17
+ if (!isImageFileName(base)) {
18
+ return false;
19
+ }
20
+ const stem = base.slice(0, base.length - path.extname(base).length);
21
+ return isValidFsName(stem);
22
+ }
23
+ export function handleAssetUpload(knowledgeRoot, body, contentType) {
24
+ let parsed;
25
+ try {
26
+ parsed = parseMultipartFormData(body, contentType);
27
+ }
28
+ catch (error) {
29
+ const message = error instanceof Error ? error.message : 'invalid multipart body';
30
+ return { status: 400, body: { error: message } };
31
+ }
32
+ const file = parsed.files.get('file');
33
+ if (!file) {
34
+ return { status: 400, body: { error: 'file field required' } };
35
+ }
36
+ if (file.data.length > MAX_ASSET_UPLOAD_BYTES) {
37
+ return { status: 400, body: { error: 'file too large (max 5MB)' } };
38
+ }
39
+ const relativeDir = normalizeRelativePath(parsed.fields.get('relativeDir')?.trim() || DEFAULT_ASSET_DIR);
40
+ if (!isUnderAssetsDir(relativeDir)) {
41
+ return { status: 400, body: { error: 'relativeDir must be under assets/' } };
42
+ }
43
+ const fileName = path.basename(file.fileName);
44
+ if (!validateImageFileName(fileName)) {
45
+ return { status: 400, body: { error: 'invalid image file name' } };
46
+ }
47
+ const relativePath = joinRelativePath(relativeDir, fileName);
48
+ const absolutePath = resolveUnderKnowledgeRoot(knowledgeRoot, relativePath);
49
+ if (!absolutePath) {
50
+ return { status: 400, body: { error: 'invalid upload path' } };
51
+ }
52
+ fs.mkdirSync(path.dirname(absolutePath), { recursive: true });
53
+ fs.writeFileSync(absolutePath, file.data);
54
+ return {
55
+ status: 200,
56
+ body: {
57
+ relativePath,
58
+ url: assetApiPath(relativePath),
59
+ },
60
+ };
61
+ }
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@justyork/repo-mind",
3
+ "version": "0.3.0",
4
+ "description": "Unified docs/ workspace for humans (UI) and AI agents (MCP) — Confluence in your repo",
5
+ "type": "module",
6
+ "bin": {
7
+ "repo-mind": "dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "ui/dist",
12
+ "templates"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc && npm run build:ui",
16
+ "build:ui": "vite build --config ui/vite.config.ts",
17
+ "test": "vitest run",
18
+ "test:watch": "vitest",
19
+ "ab-demo": "npm run build --silent && node dist/ab-demo/run-ab.js --dry-run",
20
+ "ab-demo:run": "npm run build --silent && node dist/ab-demo/run-ab.js",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "engines": {
24
+ "node": ">=18"
25
+ },
26
+ "keywords": [
27
+ "mcp",
28
+ "ai",
29
+ "documentation",
30
+ "knowledge-base"
31
+ ],
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/justyork/repomind.git"
36
+ },
37
+ "dependencies": {
38
+ "@modelcontextprotocol/sdk": "^1.12.1",
39
+ "better-sqlite3": "^12.11.1",
40
+ "chokidar": "^4.0.3",
41
+ "fast-glob": "^3.3.3",
42
+ "gray-matter": "^4.0.3",
43
+ "mermaid": "^11.15.0",
44
+ "minimatch": "^10.0.1"
45
+ },
46
+ "devDependencies": {
47
+ "@types/better-sqlite3": "^7.6.13",
48
+ "@types/node": "^22.15.21",
49
+ "d3": "^7.9.0",
50
+ "marked": "^15.0.12",
51
+ "typescript": "^5.8.3",
52
+ "vite": "^6.3.5",
53
+ "vitest": "^3.2.1"
54
+ }
55
+ }
@@ -0,0 +1,27 @@
1
+ ---
2
+ type: adr
3
+ domain: technical
4
+ slug: use-plain-markdown
5
+ status: accepted
6
+ title: Use plain Markdown for project knowledge
7
+ tags:
8
+ - storage
9
+ - markdown
10
+ related:
11
+ - mcp
12
+ updated: 2026-06-21
13
+ ---
14
+
15
+ ## Context
16
+
17
+ We need a format that humans and agents can read without special tooling.
18
+
19
+ ## Decision
20
+
21
+ Store all project knowledge as Markdown files with YAML frontmatter under `docs/`.
22
+
23
+ ## Consequences
24
+
25
+ - Easy to diff in git
26
+ - No database required for v1
27
+ - Agents can query via MCP instead of reading whole files
@@ -0,0 +1,20 @@
1
+ ---
2
+ type: agent-instruction
3
+ domain: shared
4
+ slug: query-first
5
+ status: accepted
6
+ title: Query project knowledge before reading files
7
+ tags:
8
+ - agents
9
+ - workflow
10
+ related:
11
+ - mcp
12
+ updated: 2026-06-21
13
+ ---
14
+
15
+ When answering project questions:
16
+
17
+ 1. Call `search_docs` or `get_glossary_term` first
18
+ 2. Use `get_doc` for the specific slug you need
19
+ 3. Use `explore_graph` to understand related decisions
20
+ 4. Only read raw markdown files if MCP tools return no results
@@ -0,0 +1,27 @@
1
+ ---
2
+ type: feature-spec
3
+ domain: game-design
4
+ slug: combat-system
5
+ status: proposed
6
+ title: Combat System
7
+ tags:
8
+ - game-design
9
+ - combat
10
+ related:
11
+ - mcp
12
+ updated: 2026-06-21
13
+ ---
14
+
15
+ ## Summary
16
+
17
+ Turn-based combat with action points, elemental weaknesses, and status effects.
18
+
19
+ ## Core loop
20
+
21
+ 1. Player selects up to 3 actions per turn (costs action points)
22
+ 2. Enemy AI chooses actions based on threat table
23
+ 3. Apply damage, shields, and status effects in initiative order
24
+
25
+ ## Design notes
26
+
27
+ This example doc shows how game-design knowledge fits the same `feature-spec` type as product specs — no schema expansion required.
@@ -0,0 +1,27 @@
1
+ ---
2
+ type: feature-spec
3
+ domain: technical
4
+ slug: user-authentication
5
+ status: proposed
6
+ title: User Authentication
7
+ tags:
8
+ - auth
9
+ - security
10
+ related:
11
+ - mcp
12
+ updated: 2026-06-21
13
+ ---
14
+
15
+ ## Summary
16
+
17
+ Users sign in with email and password. Sessions expire after 24 hours.
18
+
19
+ ## Requirements
20
+
21
+ - Password hashing with bcrypt
22
+ - Rate limiting on login attempts
23
+ - Session tokens stored as httpOnly cookies
24
+
25
+ ## Open Questions
26
+
27
+ See `open-questions/search-ranking.md` for unresolved ranking behavior.
@@ -0,0 +1,15 @@
1
+ ---
2
+ type: glossary-term
3
+ domain: shared
4
+ slug: mcp
5
+ status: accepted
6
+ title: Model Context Protocol (MCP)
7
+ tags:
8
+ - agents
9
+ - integration
10
+ related:
11
+ - use-plain-markdown
12
+ updated: 2026-06-21
13
+ ---
14
+
15
+ Model Context Protocol (MCP) is a standard for connecting AI agents to tools and data sources. RepoMind exposes project knowledge through MCP read tools so agents query by intent instead of ingesting entire files.
@@ -0,0 +1,26 @@
1
+ ---
2
+ type: open-question
3
+ domain: product
4
+ slug: search-ranking
5
+ status: draft
6
+ title: Is grep ranking good enough?
7
+ tags:
8
+ - search
9
+ - performance
10
+ related:
11
+ - mcp
12
+ updated: 2026-06-21
13
+ ---
14
+
15
+ ## Question
16
+
17
+ Should v1 ship with simple grep-based ranking, or invest in SQLite FTS early?
18
+
19
+ ## Options
20
+
21
+ 1. Grep + scoring formula (current v1 plan)
22
+ 2. SQLite FTS index (Approach B)
23
+
24
+ ## Decision criteria
25
+
26
+ Run the A/B kill-switch demo. Upgrade only if ranking quality blocks adoption.
@@ -0,0 +1 @@
1
+ import{$ as ln,a0 as an,a1 as G,a2 as q,a3 as z,a4 as un,a5 as y,a6 as tn,a7 as K,a8 as _,a9 as rn,aa as o,ab as on,ac as sn,ad as fn}from"./mermaid.core-Bddhr0ku.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,B,a){var O=I-l,i=D-h,n=B-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 V(l,h,I,D,v,A,B){var a=l-I,O=h-D,i=(B?A:-A)/K(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,C=(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)*K(on(0,T*T*R-P*P)),$=(P*g-m*S)/R,j=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=$-C,e=j-t,r=w-C,F=p-t;return x*x+e*e>r*r+F*F&&($=w,j=p),{cx:$,cy:j,x01:-n,y01:-d,x11:$*(v/T-1),y11:j*(v/T-1)}}function hn(){var l=cn,h=yn,I=z(0),D=null,v=gn,A=dn,B=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)-un,c=A.apply(this,arguments)-un,C=rn(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(C>tn-y)a.moveTo(s*G(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*G(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=C,S=C,$=B.apply(this,arguments)/2,j=$>y&&(D?+D.apply(this,arguments):K(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(j>y){var F=sn(j/u*q($)),L=sn(j/s*q($));(P-=F*2)>y?(F*=t?1:-1,R+=F,T-=F):(P=0,R=T=(f+c)/2),(S-=L*2)>y?(L*=t?1:-1,m+=L,g-=L):(S=0,m=g=(f+c)/2)}var H=s*G(m),J=s*q(m),M=u*G(T),N=u*q(T);if(w>y){var Q=s*G(g),U=s*q(g),W=u*G(R),X=u*q(R),E;if(C<an)if(E=pn(H,J,W,X,Q,U,M,N)){var Y=H-E[0],Z=J-E[1],b=Q-E[0],k=U-E[1],nn=1/q(fn((Y*b+Z*k)/(K(Y*Y+Z*Z)*K(b*b+k*k)))/2),en=K(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=V(W,X,H,J,s,x,t),r=V(Q,U,M,N,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(H,J),a.arc(0,0,s,m,g,!t)):a.moveTo(H,J),!(u>y)||!(P>y)?a.lineTo(M,N):p>y?(e=V(M,N,Q,U,u,-p,t),r=V(H,J,W,X,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-an/2;return[G(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:z(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:z(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:z(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:z(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:z(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:z(+n),i):A},i.padAngle=function(n){return arguments.length?(B=typeof n=="function"?n:z(+n),i):B},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};