local-diff-reviewer 2.0.1 → 2.0.2
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/cli/start.js +43 -20
- package/dist/web/assets/{arc-BTM4ghNf.js → arc-B7-mERto.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-DyOV0Jtr.js → architectureDiagram-3BPJPVTR-CGBZ-TOM.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-CxJbhmIT.js → blockDiagram-GPEHLZMM-CPUsWxwO.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-BJQFA8CQ.js → c4Diagram-AAUBKEIU-BrGC76e2.js} +1 -1
- package/dist/web/assets/channel-D4t7EEft.js +1 -0
- package/dist/web/assets/{chunk-2J33WTMH-C5OtbA_r.js → chunk-2J33WTMH-DO5M3_on.js} +1 -1
- package/dist/web/assets/{chunk-3OPIFGDE-B9KuazSf.js → chunk-3OPIFGDE-CSPnSUqT.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-B8LRminS.js → chunk-4BX2VUAB-Yk4LD9Fh.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-SkDhErOo.js → chunk-55IACEB6-CdJ5okh-.js} +1 -1
- package/dist/web/assets/{chunk-5ZQYHXKU-Bb82bV79.js → chunk-5ZQYHXKU-Brh435ls.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-Dl1e3M-k.js → chunk-727SXJPM-DXT9bcQv.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-ds7_Qz_Y.js → chunk-AQP2D5EJ-BzWxbCxi.js} +1 -1
- package/dist/web/assets/{chunk-BSJP7CBP-Ddngm4Zu.js → chunk-BSJP7CBP-Dpp9nqlQ.js} +1 -1
- package/dist/web/assets/{chunk-CSCIHK7Q-zBbkk0kR.js → chunk-CSCIHK7Q-BZklNqpa.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-C9gGg2hs.js → chunk-FMBD7UC4-DlQlzxGl.js} +1 -1
- package/dist/web/assets/{chunk-KSCS5N6A-CYRCkspU.js → chunk-KSCS5N6A-BT7uTjI5.js} +1 -1
- package/dist/web/assets/{chunk-L5ZTLDWV-at0vaITZ.js → chunk-L5ZTLDWV-CMJh1etA.js} +1 -1
- package/dist/web/assets/{chunk-LZXEDZCA-CB2tlbwU.js → chunk-LZXEDZCA-VR0Aupd7.js} +2 -2
- package/dist/web/assets/{chunk-ND2GUHAM-SF9ziKuY.js → chunk-ND2GUHAM-DcTDOdXO.js} +1 -1
- package/dist/web/assets/{chunk-NZK2D7GU-cDloGQoC.js → chunk-NZK2D7GU-BQxWA0Zt.js} +1 -1
- package/dist/web/assets/{chunk-O5CBEL6O-BKhNShTj.js → chunk-O5CBEL6O-CqMHxOEH.js} +1 -1
- package/dist/web/assets/chunk-QZHKN3VN-BUDsgeQ5.js +1 -0
- package/dist/web/assets/chunk-WU5MYG2G-Mkpj--9T.js +1 -0
- package/dist/web/assets/{chunk-XPW4576I-C5N-bWNh.js → chunk-XPW4576I-Bbgz_SG2.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-t_9OOsD1.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-C5q22guA.js +1 -0
- package/dist/web/assets/{cose-bilkent-S5V4N54A-CVt4gjy_.js → cose-bilkent-S5V4N54A-D-s9jx4F.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-DsFFRdXb.js → dagre-BM42HDAG-ZuX2xzZr.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-DU-SS203.js → diagram-2AECGRRQ-CnqxNDL3.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-Caxxw6ez.js → diagram-5GNKFQAL-DZBOyqBD.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-C86fE-G2.js → diagram-KO2AKTUF-CkqvrGpH.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-CbblsEig.js → diagram-LMA3HP47-CE-O7tWQ.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-VVwPWCNJ.js → diagram-OG6HWLK6-B9xpAXis.js} +1 -1
- package/dist/web/assets/{dist-DP09l7dv.js → dist-DvROHOnO.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-DybhgsWs.js → erDiagram-TEJ5UH35-uglocG5h.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-L175L0f8.js → flowDiagram-I6XJVG4X-PW6_BcrK.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-Bnn1hKvs.js → ganttDiagram-6RSMTGT7-DzTnDNdb.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-C0ZBrF0f.js → gitGraphDiagram-PVQCEYII-YJ-R5KKR.js} +1 -1
- package/dist/web/assets/{index-B4AzQzzw.js → index-CjVhgpf_.js} +19 -19
- package/dist/web/assets/{infoDiagram-5YYISTIA-BjE1edtT.js → infoDiagram-5YYISTIA-DDRGN3lR.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-CA7-Z3nV.js → ishikawaDiagram-YF4QCWOH-CBWcrRdn.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-7yRPAxui.js → journeyDiagram-JHISSGLW-VqzplVbl.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-CxJbCLrw.js → kanban-definition-UN3LZRKU-CQ4heueH.js} +1 -1
- package/dist/web/assets/{line-BZChgTw_.js → line-DZouZnjB.js} +1 -1
- package/dist/web/assets/{linear-Ch3uwdzh.js → linear-4BymPEG9.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-BwmBog8o.js → mermaid-parser.core-CO0Monou.js} +1 -1
- package/dist/web/assets/{mermaid.core-DbfGaZdz.js → mermaid.core-PVghItMD.js} +3 -3
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-DY-t2KPo.js → mindmap-definition-RKZ34NQL-7wYrRHjH.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-BkM6-CcI.js → pieDiagram-4H26LBE5-C3b1EYQk.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-Bo2ow9Oq.js → quadrantDiagram-W4KKPZXB-BXPy0AWD.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-BpPkW4oY.js → requirementDiagram-4Y6WPE33-ChDmv03F.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-Clh6BTES.js → sankeyDiagram-5OEKKPKP-CMk0qj7x.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-Cj1hGXAx.js → sequenceDiagram-3UESZ5HK-CnCvjiTW.js} +1 -1
- package/dist/web/assets/{src-Bm_zkrgy.js → src-MP5tblZ9.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-D34qh_xR.js → stateDiagram-AJRCARHV-9wNs4PR_.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BGBYsvK8.js +1 -0
- package/dist/web/assets/{timeline-definition-PNZ67QCA-C14XIn0F.js → timeline-definition-PNZ67QCA-VDppi8O1.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-CmRloXuF.js → vennDiagram-CIIHVFJN-B7NhrHjY.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-BJfba87H.js → wardleyDiagram-YWT4CUSO-BHwySjYy.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-DnEMDZBA.js → xychartDiagram-2RQKCTM6-Cj_7_DKi.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/channel-zJdz6BA1.js +0 -1
- package/dist/web/assets/chunk-QZHKN3VN-DOXAr87O.js +0 -1
- package/dist/web/assets/chunk-WU5MYG2G-HE1Sw8W0.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-DhMmSdQh.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-C-ONPelI.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-zAS4zz8v.js +0 -1
package/dist/cli/start.js
CHANGED
|
@@ -29,6 +29,9 @@ function anchorKey(anchor) {
|
|
|
29
29
|
if (anchor.type === "diff-line") return `diff:${anchor.filePath}:${anchor.side}:${anchor.lineNumber}`;
|
|
30
30
|
return `markdown:${anchor.filePath}:${anchor.lineNumber}`;
|
|
31
31
|
}
|
|
32
|
+
function isThreadOnFileSnapshot(thread, file) {
|
|
33
|
+
return thread.filePath === file.path && thread.fileSnapshotHash === file.snapshotHash;
|
|
34
|
+
}
|
|
32
35
|
function getThreadStatus(thread) {
|
|
33
36
|
if (thread.status === "resolved") return "resolved";
|
|
34
37
|
return getOpenThreadStatus(thread);
|
|
@@ -42,12 +45,10 @@ function getMergedThreadStatus(threads) {
|
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
// src/server/storage.ts
|
|
45
|
-
async function readComments(repoRoot
|
|
46
|
-
|
|
47
|
-
if (!diffHash2) return store;
|
|
48
|
-
return { threads: store.threads.filter((thread) => thread.diffHash === diffHash2) };
|
|
48
|
+
async function readComments(repoRoot) {
|
|
49
|
+
return readCommentStore(repoRoot);
|
|
49
50
|
}
|
|
50
|
-
async function attachLegacyComments(repoRoot, diffHash2) {
|
|
51
|
+
async function attachLegacyComments(repoRoot, diffHash2, diffFiles) {
|
|
51
52
|
const store = await readCommentStore(repoRoot);
|
|
52
53
|
let changed = false;
|
|
53
54
|
for (const thread of store.threads) {
|
|
@@ -55,6 +56,11 @@ async function attachLegacyComments(repoRoot, diffHash2) {
|
|
|
55
56
|
thread.diffHash = diffHash2;
|
|
56
57
|
changed = true;
|
|
57
58
|
}
|
|
59
|
+
const file = diffFiles.find((item) => item.path === thread.filePath);
|
|
60
|
+
if (!thread.fileSnapshotHash && file && (thread.diffHash === diffHash2 || getThreadStatus(thread) === "submit")) {
|
|
61
|
+
thread.fileSnapshotHash = file.snapshotHash;
|
|
62
|
+
changed = true;
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
if (changed) await writeComments(repoRoot, store);
|
|
60
66
|
}
|
|
@@ -93,7 +99,8 @@ async function readLegacyComments(repoRoot) {
|
|
|
93
99
|
function normalizeStore(store) {
|
|
94
100
|
const groups = /* @__PURE__ */ new Map();
|
|
95
101
|
for (const thread of store.threads) {
|
|
96
|
-
const
|
|
102
|
+
const snapshotKey = thread.fileSnapshotHash ?? (thread.diffHash ? `diff:${thread.diffHash}` : "legacy");
|
|
103
|
+
const key = `${snapshotKey}:${anchorKey(thread.anchor)}`;
|
|
97
104
|
groups.set(key, [...groups.get(key) ?? [], thread]);
|
|
98
105
|
}
|
|
99
106
|
return {
|
|
@@ -137,7 +144,7 @@ async function importAgentComments(repoRoot, diffHash2, diffFiles, rawComments)
|
|
|
137
144
|
}
|
|
138
145
|
const thread = buildAgentThread(parsed, diffHash2, diffFiles, result, label);
|
|
139
146
|
if (!thread) continue;
|
|
140
|
-
const existingThread = store.threads.find((item) => item.
|
|
147
|
+
const existingThread = store.threads.find((item) => item.fileSnapshotHash === thread.fileSnapshotHash && sameAnchor(item.anchor, thread.anchor));
|
|
141
148
|
if (hasDuplicateAgentComment(store.threads, thread)) {
|
|
142
149
|
result.skipped.push(`${label}: duplicate agent comment skipped`);
|
|
143
150
|
continue;
|
|
@@ -227,6 +234,7 @@ function buildAgentThread(comment, diffHash2, diffFiles, result, label) {
|
|
|
227
234
|
filePath: anchor.filePath,
|
|
228
235
|
anchor,
|
|
229
236
|
diffHash: diffHash2,
|
|
237
|
+
fileSnapshotHash: file.snapshotHash,
|
|
230
238
|
status: "replied",
|
|
231
239
|
comments: [
|
|
232
240
|
{
|
|
@@ -273,7 +281,7 @@ function buildAnchor(file, comment, result, label) {
|
|
|
273
281
|
function hasDuplicateAgentComment(threads, nextThread) {
|
|
274
282
|
const nextComment = nextThread.comments[0]?.body.trim();
|
|
275
283
|
return threads.some((thread) => {
|
|
276
|
-
return thread.comments.some((comment) => comment.author === "agent" && comment.body.trim() === nextComment) && thread.
|
|
284
|
+
return thread.comments.some((comment) => comment.author === "agent" && comment.body.trim() === nextComment) && thread.fileSnapshotHash === nextThread.fileSnapshotHash && thread.filePath === nextThread.filePath && sameAnchor(thread.anchor, nextThread.anchor);
|
|
277
285
|
});
|
|
278
286
|
}
|
|
279
287
|
function diffLineExists(file, side, lineNumber) {
|
|
@@ -312,6 +320,7 @@ function isRecord(value) {
|
|
|
312
320
|
}
|
|
313
321
|
|
|
314
322
|
// src/core/diff-parser.ts
|
|
323
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
315
324
|
var hunkHeaderPattern = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
|
|
316
325
|
function parseUnifiedDiff(input) {
|
|
317
326
|
const lines = input.replace(/\r\n/g, "\n").split("\n");
|
|
@@ -328,6 +337,7 @@ function parseUnifiedDiff(input) {
|
|
|
328
337
|
oldPath: paths?.[1] ?? "",
|
|
329
338
|
newPath: paths?.[2] ?? "",
|
|
330
339
|
path: paths?.[2] ?? "",
|
|
340
|
+
snapshotHash: "",
|
|
331
341
|
status: "modified",
|
|
332
342
|
additions: 0,
|
|
333
343
|
deletions: 0,
|
|
@@ -413,7 +423,11 @@ function parseUnifiedDiff(input) {
|
|
|
413
423
|
const synthetic = { type: "context", content: line, oldLineNumber: oldLine, newLineNumber: newLine };
|
|
414
424
|
currentHunk.lines.push(synthetic);
|
|
415
425
|
}
|
|
416
|
-
return files.filter((file) => file.path);
|
|
426
|
+
return files.filter((file) => file.path).map((file) => ({ ...file, snapshotHash: fileSnapshotHash(file) }));
|
|
427
|
+
}
|
|
428
|
+
function fileSnapshotHash(file) {
|
|
429
|
+
const snapshot = { ...file, snapshotHash: void 0 };
|
|
430
|
+
return createHash2("sha256").update(JSON.stringify(snapshot)).digest("hex").slice(0, 16);
|
|
417
431
|
}
|
|
418
432
|
function normalizeDiffPath(path) {
|
|
419
433
|
if (path === "/dev/null") return path;
|
|
@@ -424,7 +438,7 @@ function isMarkdownPath(path) {
|
|
|
424
438
|
}
|
|
425
439
|
|
|
426
440
|
// src/core/git.ts
|
|
427
|
-
import { createHash as
|
|
441
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
428
442
|
import { execFile } from "node:child_process";
|
|
429
443
|
import { promisify } from "node:util";
|
|
430
444
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -473,7 +487,7 @@ function parseReviewMode(args) {
|
|
|
473
487
|
throw new Error("Usage: local-diff-reviewer [working|staged|<base> <target>]");
|
|
474
488
|
}
|
|
475
489
|
function diffHash(diff) {
|
|
476
|
-
return
|
|
490
|
+
return createHash3("sha256").update(diff).digest("hex").slice(0, 16);
|
|
477
491
|
}
|
|
478
492
|
function isSafeRepoPath(repoRoot, path) {
|
|
479
493
|
const normalized = normalize(join2(repoRoot, path));
|
|
@@ -528,7 +542,7 @@ function binaryAddedDiff(path) {
|
|
|
528
542
|
}
|
|
529
543
|
|
|
530
544
|
// src/cli/runtime-registry.ts
|
|
531
|
-
import { createHash as
|
|
545
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
532
546
|
import { access, mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
533
547
|
import { homedir as homedir2, platform as platform2 } from "node:os";
|
|
534
548
|
import { basename as basename2, dirname as dirname2, join as join3 } from "node:path";
|
|
@@ -569,7 +583,7 @@ async function stopRecordedRuntimes(repoRoot) {
|
|
|
569
583
|
}
|
|
570
584
|
function runtimePath(repoRoot) {
|
|
571
585
|
const repoName = basename2(repoRoot) || "repo";
|
|
572
|
-
const repoHash =
|
|
586
|
+
const repoHash = createHash4("sha256").update(repoRoot).digest("hex").slice(0, 12);
|
|
573
587
|
return join3(runtimeDir(), `${repoName}-${repoHash}.runtime.json`);
|
|
574
588
|
}
|
|
575
589
|
function runtimeDir() {
|
|
@@ -623,7 +637,7 @@ import { createServer } from "node:http";
|
|
|
623
637
|
import { join as join4, normalize as normalize2, resolve, sep } from "node:path";
|
|
624
638
|
|
|
625
639
|
// src/shared/types.ts
|
|
626
|
-
var REVIEW_REFRESH_PROTOCOL =
|
|
640
|
+
var REVIEW_REFRESH_PROTOCOL = 3;
|
|
627
641
|
|
|
628
642
|
// src/core/markdown-source-map.ts
|
|
629
643
|
import GithubSlugger from "github-slugger";
|
|
@@ -816,8 +830,13 @@ async function startServer(state, port = 4966) {
|
|
|
816
830
|
res.status(400).json({ error: "Comment body is required" });
|
|
817
831
|
return;
|
|
818
832
|
}
|
|
833
|
+
const file = state.diffFiles.find((item) => item.path === body.filePath);
|
|
834
|
+
if (!file) {
|
|
835
|
+
res.status(400).json({ error: "Comment file is not present in the current diff" });
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
819
838
|
const store = await readComments(state.session.repoRoot);
|
|
820
|
-
const existingThread = store.threads.find((thread2) => thread2.
|
|
839
|
+
const existingThread = store.threads.find((thread2) => thread2.fileSnapshotHash === file.snapshotHash && sameAnchor(thread2.anchor, body.anchor));
|
|
821
840
|
const comment = {
|
|
822
841
|
id: crypto.randomUUID(),
|
|
823
842
|
body: commentBody,
|
|
@@ -838,6 +857,7 @@ async function startServer(state, port = 4966) {
|
|
|
838
857
|
filePath: body.filePath,
|
|
839
858
|
anchor: body.anchor,
|
|
840
859
|
diffHash: state.session.diffHash,
|
|
860
|
+
fileSnapshotHash: file.snapshotHash,
|
|
841
861
|
status: "submit",
|
|
842
862
|
comments: [comment],
|
|
843
863
|
createdAt: now,
|
|
@@ -982,7 +1002,7 @@ async function startServer(state, port = 4966) {
|
|
|
982
1002
|
try {
|
|
983
1003
|
const scope = req.body;
|
|
984
1004
|
const store = await readComments(state.session.repoRoot);
|
|
985
|
-
const threads = selectPromptThreads(store.threads, scope);
|
|
1005
|
+
const threads = selectPromptThreads(store.threads, scope, state.diffFiles);
|
|
986
1006
|
res.json({ prompt: formatPrompt(threads) });
|
|
987
1007
|
} catch (error) {
|
|
988
1008
|
next(error);
|
|
@@ -1032,12 +1052,15 @@ function listen(app, port) {
|
|
|
1032
1052
|
});
|
|
1033
1053
|
});
|
|
1034
1054
|
}
|
|
1035
|
-
function selectPromptThreads(threads, scope) {
|
|
1055
|
+
function selectPromptThreads(threads, scope, currentFiles) {
|
|
1056
|
+
const isCurrentSnapshotThread = (thread) => currentFiles.some((file) => isThreadOnFileSnapshot(thread, file));
|
|
1036
1057
|
if (scope.type === "thread") return threads.filter((thread) => thread.id === scope.threadId);
|
|
1037
1058
|
if (scope.type === "file-unresolved") {
|
|
1038
|
-
return threads.filter(
|
|
1059
|
+
return threads.filter(
|
|
1060
|
+
(thread) => thread.filePath === scope.filePath && thread.status !== "resolved" && isCurrentSnapshotThread(thread)
|
|
1061
|
+
);
|
|
1039
1062
|
}
|
|
1040
|
-
return threads.filter((thread) => thread.status !== "resolved");
|
|
1063
|
+
return threads.filter((thread) => thread.status !== "resolved" && isCurrentSnapshotThread(thread));
|
|
1041
1064
|
}
|
|
1042
1065
|
|
|
1043
1066
|
// src/cli/start.ts
|
|
@@ -1061,7 +1084,7 @@ async function main() {
|
|
|
1061
1084
|
diffHash: diffHash(diff),
|
|
1062
1085
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1063
1086
|
};
|
|
1064
|
-
await attachLegacyComments(repoRoot, session.diffHash);
|
|
1087
|
+
await attachLegacyComments(repoRoot, session.diffHash, diffFiles);
|
|
1065
1088
|
const importResult = await importAgentComments(repoRoot, session.diffHash, diffFiles, comments);
|
|
1066
1089
|
if (!newSession && !dev) {
|
|
1067
1090
|
const reusedUrl = await refreshRunningReview(session, diffFiles);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./path-BJQEcSo7.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-
|
|
1
|
+
import{n as e,t}from"./path-BJQEcSo7.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-DvROHOnO.js";function m(e){return e.innerRadius}function h(e){return e.outerRadius}function g(e){return e.startAngle}function _(e){return e.endAngle}function v(e){return e&&e.padAngle}function y(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function b(e,t,n,r,i,a,o){var c=e-n,l=t-r,u=(o?a:-a)/d(c*c+l*l),f=u*l,p=-u*c,m=e+f,h=t+p,g=n+f,_=r+p,v=(m+g)/2,y=(h+_)/2,b=g-m,x=_-h,S=b*b+x*x,C=i-a,w=m*_-g*h,T=(x<0?-1:1)*d(s(0,C*C*S-w*w)),E=(w*x-b*T)/S,D=(-w*b-x*T)/S,O=(w*x+b*T)/S,k=(-w*b+x*T)/S,A=E-v,j=D-y,M=O-v,N=k-y;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-f,y01:-p,x11:E*(i/C-1),y11:D*(i/C-1)}}function x(){var s=m,x=h,S=e(0),C=null,w=g,T=_,E=v,D=null,O=t(k);function k(){var e,t,m=+s.apply(this,arguments),h=+x.apply(this,arguments),g=w.apply(this,arguments)-r,_=T.apply(this,arguments)-r,v=l(_-g),k=_>g;if(D||=e=O(),h<m&&(t=h,h=m,m=t),!(h>1e-12))D.moveTo(0,0);else if(v>c-1e-12)D.moveTo(h*u(g),h*a(g)),D.arc(0,0,h,g,_,!k),m>1e-12&&(D.moveTo(m*u(_),m*a(_)),D.arc(0,0,m,_,g,k));else{var A=g,j=_,M=g,N=_,P=v,F=v,I=E.apply(this,arguments)/2,L=I>1e-12&&(C?+C.apply(this,arguments):d(m*m+h*h)),R=p(l(h-m)/2,+S.apply(this,arguments)),z=R,B=R,V,H;if(L>1e-12){var U=o(L/m*a(I)),W=o(L/h*a(I));(P-=U*2)>1e-12?(U*=k?1:-1,M+=U,N-=U):(P=0,M=N=(g+_)/2),(F-=W*2)>1e-12?(W*=k?1:-1,A+=W,j-=W):(F=0,A=j=(g+_)/2)}var G=h*u(A),K=h*a(A),q=m*u(N),J=m*a(N);if(R>1e-12){var Y=h*u(j),X=h*a(j),Z=m*u(M),Q=m*a(M),$;if(v<i)if($=y(G,K,Z,Q,Y,X,q,J)){var ee=G-$[0],te=K-$[1],ne=Y-$[0],re=X-$[1],ie=1/a(f((ee*ne+te*re)/(d(ee*ee+te*te)*d(ne*ne+re*re)))/2),ae=d($[0]*$[0]+$[1]*$[1]);z=p(R,(m-ae)/(ie-1)),B=p(R,(h-ae)/(ie+1))}else z=B=0}F>1e-12?B>1e-12?(V=b(Z,Q,G,K,h,B,k),H=b(Y,X,q,J,h,B,k),D.moveTo(V.cx+V.x01,V.cy+V.y01),B<R?D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,h,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),!k),D.arc(H.cx,H.cy,B,n(H.y11,H.x11),n(H.y01,H.x01),!k))):(D.moveTo(G,K),D.arc(0,0,h,A,j,!k)):D.moveTo(G,K),!(m>1e-12)||!(P>1e-12)?D.lineTo(q,J):z>1e-12?(V=b(q,J,Y,X,m,-z,k),H=b(G,K,Z,Q,m,-z,k),D.lineTo(V.cx+V.x01,V.cy+V.y01),z<R?D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,m,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),k),D.arc(H.cx,H.cy,z,n(H.y11,H.x11),n(H.y01,H.x01),!k))):D.arc(0,0,m,N,M,k)}if(D.closePath(),e)return D=null,e+``||null}return k.centroid=function(){var e=(+s.apply(this,arguments)+ +x.apply(this,arguments))/2,t=(+w.apply(this,arguments)+ +T.apply(this,arguments))/2-i/2;return[u(t)*e,a(t)*e]},k.innerRadius=function(t){return arguments.length?(s=typeof t==`function`?t:e(+t),k):s},k.outerRadius=function(t){return arguments.length?(x=typeof t==`function`?t:e(+t),k):x},k.cornerRadius=function(t){return arguments.length?(S=typeof t==`function`?t:e(+t),k):S},k.padRadius=function(t){return arguments.length?(C=t==null?null:typeof t==`function`?t:e(+t),k):C},k.startAngle=function(t){return arguments.length?(w=typeof t==`function`?t:e(+t),k):w},k.endAngle=function(t){return arguments.length?(T=typeof t==`function`?t:e(+t),k):T},k.padAngle=function(t){return arguments.length?(E=typeof t==`function`?t:e(+t),k):E},k.context=function(e){return arguments.length?(D=e??null,k):D},k}export{x as t};
|