@fullstackhouse/cerber 1.6.2-pr.91.45d4d8c → 1.6.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/core/artifact.js +0 -2
- package/dist/core/state.js +7 -18
- package/dist/server/index.js +33 -58
- package/package.json +1 -1
- package/web/dist/assets/{abnfDiagram-WEYOIA3C-DDWiBgJ_.js → abnfDiagram-WEYOIA3C-D5wm8458.js} +1 -1
- package/web/dist/assets/{arc-CXTmovRq.js → arc-CvrQr7ke.js} +1 -1
- package/web/dist/assets/{architectureDiagram-ZHVYKT53-DPwB58EC.js → architectureDiagram-ZHVYKT53-gshkv72h.js} +1 -1
- package/web/dist/assets/{blockDiagram-RJAE7QA3-BbdcPjtf.js → blockDiagram-RJAE7QA3-CPLPXHoV.js} +1 -1
- package/web/dist/assets/{c4Diagram-XDPPPE54-DHzjA55M.js → c4Diagram-XDPPPE54-B1A-GePa.js} +1 -1
- package/web/dist/assets/channel-4aSA0AsI.js +1 -0
- package/web/dist/assets/{chunk-2E7WHVMD-X1BSLNbz.js → chunk-2E7WHVMD-DZv4SQeE.js} +1 -1
- package/web/dist/assets/{chunk-2Q5K7J3B-4uva6Krv.js → chunk-2Q5K7J3B-BN5MFEGk.js} +1 -1
- package/web/dist/assets/{chunk-4EMNKR2T-DFnlUBTZ.js → chunk-4EMNKR2T-CQ9OTS_Y.js} +1 -1
- package/web/dist/assets/{chunk-55XCU76K-Cu8cVLZy.js → chunk-55XCU76K-DqGA3I0P.js} +1 -1
- package/web/dist/assets/{chunk-5VM5RSS4-B9WXEPBE.js → chunk-5VM5RSS4-B0DDtSF3.js} +1 -1
- package/web/dist/assets/{chunk-JWPE2WC7-CCsYBl0M.js → chunk-JWPE2WC7-DyJGNKay.js} +1 -1
- package/web/dist/assets/{chunk-VQ5W62QI-DBHQMI3P.js → chunk-VQ5W62QI-BVaZfdlJ.js} +1 -1
- package/web/dist/assets/{chunk-XXDRQBXY-DFB2lFGh.js → chunk-XXDRQBXY-BijU5AbR.js} +1 -1
- package/web/dist/assets/{chunk-ZCHMQSOR-dvczqjG8.js → chunk-ZCHMQSOR-CJNtblBl.js} +2 -2
- package/web/dist/assets/{classDiagram-v2-4MYWR3UA-Ck2KUiuM.js → classDiagram-v2-4MYWR3UA-31c0fLuG.js} +1 -1
- package/web/dist/assets/{cose-bilkent-JH36ORCC-DcMTug3a.js → cose-bilkent-JH36ORCC-BeI79iat.js} +1 -1
- package/web/dist/assets/{cynefin-EF2NZ3EQ-BG2opkNs.js → cynefin-EF2NZ3EQ-Dj_GKCLo.js} +1 -1
- package/web/dist/assets/{cynefinDiagram-WF24UDRP-BTIMNySy.js → cynefinDiagram-WF24UDRP-DJVl-Cha.js} +1 -1
- package/web/dist/assets/{dagre-NK4GIZVX-1qi-5iCE.js → dagre-NK4GIZVX-YIVvO6e5.js} +1 -1
- package/web/dist/assets/{diagram-CBK3MWTC-CSH989hb.js → diagram-CBK3MWTC-CXGhjXyi.js} +1 -1
- package/web/dist/assets/{diagram-I5XIIV2D-Z_1T8l7R.js → diagram-I5XIIV2D-3iO5MZue.js} +1 -1
- package/web/dist/assets/{diagram-ODIL2UCW-B8jB07f-.js → diagram-ODIL2UCW-C7F71C5O.js} +1 -1
- package/web/dist/assets/{diagram-PFBEJUXE-B9qraPmL.js → diagram-PFBEJUXE-p8y7_tW-.js} +1 -1
- package/web/dist/assets/{diagram-RJA3I4VV-CFhy381H.js → diagram-RJA3I4VV-DJTwvrGz.js} +1 -1
- package/web/dist/assets/{diagram-TYUNFSNR-DYEBj8MB.js → diagram-TYUNFSNR-Byl5ie3W.js} +1 -1
- package/web/dist/assets/{ebnfDiagram-V4P3TTPT-DGtaeIoV.js → ebnfDiagram-V4P3TTPT-kA-zQKdf.js} +1 -1
- package/web/dist/assets/{elk-QONTBCTQ-Cpcx9jQq.js → elk-QONTBCTQ-C7AEE2dT.js} +1 -1
- package/web/dist/assets/{erDiagram-KYQIGQAA-BFMhv1lb.js → erDiagram-KYQIGQAA-CUL9JFt9.js} +1 -1
- package/web/dist/assets/{flowDiagram-IUGLLWBU-ZvrIwHpb.js → flowDiagram-IUGLLWBU-CEOMISZC.js} +1 -1
- package/web/dist/assets/{ganttDiagram-R7GPNTJY-CMElMuNb.js → ganttDiagram-R7GPNTJY-CUs9OnoQ.js} +1 -1
- package/web/dist/assets/{gitGraphDiagram-PDYL7XHY-C2YKWJEE.js → gitGraphDiagram-PDYL7XHY-DbXbR_7n.js} +1 -1
- package/web/dist/assets/{index-CcSO4iOX.js → index-DIVX8aC0.js} +2 -2
- package/web/dist/assets/{infoDiagram-MVDRKAX5-Cekh0IW0.js → infoDiagram-MVDRKAX5-D5gtX5ay.js} +1 -1
- package/web/dist/assets/{ishikawaDiagram-HPEHV2GE-BoxRJEa6.js → ishikawaDiagram-HPEHV2GE-B0vcKoPQ.js} +1 -1
- package/web/dist/assets/{journeyDiagram-BOSHW7O7-kDJSSn-6.js → journeyDiagram-BOSHW7O7-BfKDxBMF.js} +1 -1
- package/web/dist/assets/{kanban-definition-FNSA4HC5-CBQ3lPM5.js → kanban-definition-FNSA4HC5-CmO-kBIa.js} +1 -1
- package/web/dist/assets/{linear-DSIqP0TT.js → linear-DgRqIxsJ.js} +1 -1
- package/web/dist/assets/{mermaid.core-wbwCbWuQ.js → mermaid.core-C6m6PWvg.js} +4 -4
- package/web/dist/assets/{mindmap-definition-6OY57UG3-C2PqDFz9.js → mindmap-definition-6OY57UG3-UFy1BwHP.js} +1 -1
- package/web/dist/assets/{pegDiagram-ECIUJNBX-S9r7bybM.js → pegDiagram-ECIUJNBX-CRD8kT1M.js} +1 -1
- package/web/dist/assets/{pieDiagram-GNMPY74T-C1DFot1v.js → pieDiagram-GNMPY74T-D9KIqFbC.js} +1 -1
- package/web/dist/assets/{quadrantDiagram-D57K4MC3-QaUZgGzi.js → quadrantDiagram-D57K4MC3-0JrGawCn.js} +1 -1
- package/web/dist/assets/{railroadDiagram-Y72NRBL7-BTsaNbut.js → railroadDiagram-Y72NRBL7-ThzD7FI4.js} +1 -1
- package/web/dist/assets/{requirementDiagram-EQYSW5RA-Bul4YAfK.js → requirementDiagram-EQYSW5RA-DcvLUCnu.js} +1 -1
- package/web/dist/assets/{sankeyDiagram-SY24JHO5-J8X2PWDq.js → sankeyDiagram-SY24JHO5-CRT8v_qw.js} +1 -1
- package/web/dist/assets/{sequenceDiagram-BLEHNHQU-CTX4Y6no.js → sequenceDiagram-BLEHNHQU-CySzt9Lb.js} +1 -1
- package/web/dist/assets/{sizeCapture-INFHLROL-CXfB7h8n.js → sizeCapture-INFHLROL-iXzfbVam.js} +1 -1
- package/web/dist/assets/{stateDiagram-v2-A6IESKWZ-Kr5pKDbm.js → stateDiagram-v2-A6IESKWZ-Cb6vX2Os.js} +1 -1
- package/web/dist/assets/{swimlanes-B3ENRKFQ-DDWGDYUC.js → swimlanes-B3ENRKFQ-DFA5myHp.js} +1 -1
- package/web/dist/assets/swimlanesDiagram-AYQRV4AK-BR6137mV.js +8 -0
- package/web/dist/assets/{timeline-definition-JXYKGLGB-BAKElQ5f.js → timeline-definition-JXYKGLGB-D5gGfOD0.js} +1 -1
- package/web/dist/assets/{usecaseDiagram-WPOLBNNX-Dlw_OwnV.js → usecaseDiagram-WPOLBNNX-CnLV1r1M.js} +1 -1
- package/web/dist/assets/{vennDiagram-Q3Y3IDCW-bTukfT0U.js → vennDiagram-Q3Y3IDCW-BYaMLGyP.js} +1 -1
- package/web/dist/assets/{wardleyDiagram-IVAIDKWA-DeM6AGmO.js → wardleyDiagram-IVAIDKWA-DYfnIgdf.js} +1 -1
- package/web/dist/assets/{xychartDiagram-4URNHDU4-CVYyvgbH.js → xychartDiagram-4URNHDU4-C1i9x7_b.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/assets/channel-Bc1egjP3.js +0 -1
- package/web/dist/assets/swimlanesDiagram-AYQRV4AK-BkmYK-f1.js +0 -8
package/dist/core/artifact.js
CHANGED
|
@@ -381,8 +381,6 @@ export const PendingChatSchema = z.object({
|
|
|
381
381
|
progress: z.array(z.string()).default([]),
|
|
382
382
|
/** What the user added while it worked — each one went into the live run. */
|
|
383
383
|
steers: z.array(z.string()).default([]),
|
|
384
|
-
/** What it could no longer take: sent as the next turn once this one lands. */
|
|
385
|
-
queued: z.array(z.string()).optional(),
|
|
386
384
|
/** Why the turn failed. Null while it is still running. */
|
|
387
385
|
error: z.string().nullable().default(null),
|
|
388
386
|
});
|
package/dist/core/state.js
CHANGED
|
@@ -161,25 +161,14 @@ export async function deleteArtifact(id) {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
/** Load by key, apply a mutation, bump updatedAt, save. Returns the new artifact. */
|
|
164
|
-
export function updateArtifactByKey(key, mutate) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const updated = { ...mutate(artifact), updatedAt: new Date().toISOString() };
|
|
172
|
-
await saveArtifact(updated);
|
|
173
|
-
return updated;
|
|
174
|
-
});
|
|
175
|
-
const settled = run.catch(() => { }).finally(() => {
|
|
176
|
-
if (updates.get(key) === settled)
|
|
177
|
-
updates.delete(key);
|
|
178
|
-
});
|
|
179
|
-
updates.set(key, settled);
|
|
180
|
-
return run;
|
|
164
|
+
export async function updateArtifactByKey(key, mutate) {
|
|
165
|
+
const artifact = await loadArtifactByKey(key);
|
|
166
|
+
if (!artifact)
|
|
167
|
+
return null;
|
|
168
|
+
const updated = { ...mutate(artifact), updatedAt: new Date().toISOString() };
|
|
169
|
+
await saveArtifact(updated);
|
|
170
|
+
return updated;
|
|
181
171
|
}
|
|
182
|
-
const updates = new Map();
|
|
183
172
|
/**
|
|
184
173
|
* Clear AI work left in flight by a process that died mid-run — a review marked
|
|
185
174
|
* "running", a chat turn still waiting for its answer, or a check for findings
|
package/dist/server/index.js
CHANGED
|
@@ -776,16 +776,33 @@ export async function buildApp(opts) {
|
|
|
776
776
|
allowUserComments: z.boolean().optional(),
|
|
777
777
|
});
|
|
778
778
|
const turnInFlight = (a) => a.pendingChat != null && a.pendingChat.error == null;
|
|
779
|
-
|
|
780
|
-
|
|
779
|
+
app.post("/api/reviews/:key/chat", async (c) => {
|
|
780
|
+
const key = c.req.param("key");
|
|
781
|
+
const artifact = await loadArtifactByKey(key);
|
|
782
|
+
if (!artifact)
|
|
783
|
+
return c.json({ error: "not found" }, 404);
|
|
784
|
+
// A sent review is a record of what was posted — arguing with it now would
|
|
785
|
+
// rewrite history that GitHub already has.
|
|
786
|
+
if (artifact.sent)
|
|
787
|
+
return c.json({ error: `already sent at ${artifact.sent.at}` }, 409);
|
|
788
|
+
if (isReviewRunning(artifact.id) || turnInFlight(artifact)) {
|
|
789
|
+
return c.json({ error: busy(artifact, "a run for this PR is already in flight") }, 409);
|
|
790
|
+
}
|
|
791
|
+
let request;
|
|
792
|
+
try {
|
|
793
|
+
request = ChatRequestSchema.parse(await c.req.json());
|
|
794
|
+
}
|
|
795
|
+
catch (err) {
|
|
796
|
+
return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
797
|
+
}
|
|
781
798
|
// Record the question before responding, so the cockpit's next poll — and a
|
|
782
799
|
// reload mid-turn — finds a turn being answered rather than a message that
|
|
783
800
|
// went nowhere.
|
|
784
801
|
const pending = await updateArtifactByKey(key, (a) => ({
|
|
785
802
|
...a,
|
|
786
803
|
pendingChat: {
|
|
787
|
-
message,
|
|
788
|
-
refs: refs ?? [],
|
|
804
|
+
message: request.message,
|
|
805
|
+
refs: request.refs ?? [],
|
|
789
806
|
startedAt: new Date().toISOString(),
|
|
790
807
|
progress: [],
|
|
791
808
|
steers: [],
|
|
@@ -799,9 +816,9 @@ export async function buildApp(opts) {
|
|
|
799
816
|
// Holding the request open is fine on localhost and fails behind a reverse
|
|
800
817
|
// proxy's read timeout, which tells the user it broke while the turn
|
|
801
818
|
// quietly succeeds — a worse failure than an honest error.
|
|
802
|
-
void runChatTurn(artifact, message, {
|
|
803
|
-
refs,
|
|
804
|
-
allowUserComments,
|
|
819
|
+
void runChatTurn(artifact, request.message, {
|
|
820
|
+
refs: request.refs,
|
|
821
|
+
allowUserComments: request.allowUserComments,
|
|
805
822
|
onProgress: (m) => {
|
|
806
823
|
console.log(`[chat ${artifact.id}] ${m}`);
|
|
807
824
|
progress.push(m);
|
|
@@ -818,20 +835,12 @@ export async function buildApp(opts) {
|
|
|
818
835
|
// the review's own were. Marked in the same write that clears the
|
|
819
836
|
// turn, so the cockpit's poll has no gap in which nothing is pending.
|
|
820
837
|
const added = result.artifact.comments.some((cm) => !artifact.comments.some((before) => before.id === cm.id));
|
|
821
|
-
let queued = [];
|
|
822
838
|
const landed = await updateArtifactByKey(key, (current) => {
|
|
823
|
-
queued = current.pendingChat?.queued ?? [];
|
|
824
839
|
const merged = { ...mergeConcurrentEdits(artifact, result.artifact, current), pendingChat: null };
|
|
825
840
|
return added ? startRaisedCheck(merged, new Date().toISOString()) : merged;
|
|
826
841
|
});
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
return;
|
|
830
|
-
// The check holds the review's slot, so the next turn waits its go.
|
|
831
|
-
await check;
|
|
832
|
-
const next = await loadArtifactByKey(key);
|
|
833
|
-
if (next && !next.sent)
|
|
834
|
-
await startTurn(key, next, queued.join("\n\n"));
|
|
842
|
+
if (added && landed)
|
|
843
|
+
void checkInBackground(landed);
|
|
835
844
|
})
|
|
836
845
|
.catch(async (err) => {
|
|
837
846
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -845,42 +854,18 @@ export async function buildApp(opts) {
|
|
|
845
854
|
pendingChat: a.pendingChat ? { ...a.pendingChat, error: message } : null,
|
|
846
855
|
})).catch(() => { });
|
|
847
856
|
});
|
|
848
|
-
return pending;
|
|
849
|
-
};
|
|
850
|
-
app.post("/api/reviews/:key/chat", async (c) => {
|
|
851
|
-
const key = c.req.param("key");
|
|
852
|
-
const artifact = await loadArtifactByKey(key);
|
|
853
|
-
if (!artifact)
|
|
854
|
-
return c.json({ error: "not found" }, 404);
|
|
855
|
-
// A sent review is a record of what was posted — arguing with it now would
|
|
856
|
-
// rewrite history that GitHub already has.
|
|
857
|
-
if (artifact.sent)
|
|
858
|
-
return c.json({ error: `already sent at ${artifact.sent.at}` }, 409);
|
|
859
|
-
if (isReviewRunning(artifact.id) || turnInFlight(artifact)) {
|
|
860
|
-
return c.json({ error: busy(artifact, "a run for this PR is already in flight") }, 409);
|
|
861
|
-
}
|
|
862
|
-
let request;
|
|
863
|
-
try {
|
|
864
|
-
request = ChatRequestSchema.parse(await c.req.json());
|
|
865
|
-
}
|
|
866
|
-
catch (err) {
|
|
867
|
-
return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
868
|
-
}
|
|
869
|
-
const pending = await startTurn(key, artifact, request.message, request.refs, request.allowUserComments);
|
|
870
857
|
return c.json(pending, 202);
|
|
871
858
|
});
|
|
872
859
|
// Add to the turn being answered rather than waiting minutes to say "not that,
|
|
873
|
-
// this".
|
|
874
|
-
//
|
|
875
|
-
//
|
|
860
|
+
// this". The message goes into the live run; when the turn has already
|
|
861
|
+
// answered (or is only retrying its JSON) there is nothing to add it to, and
|
|
862
|
+
// the cockpit is told so instead of being shown a message that went nowhere.
|
|
876
863
|
const SteerRequestSchema = z.object({ message: z.string().min(1) });
|
|
877
864
|
app.post("/api/reviews/:key/chat/steer", async (c) => {
|
|
878
865
|
const key = c.req.param("key");
|
|
879
866
|
const artifact = await loadArtifactByKey(key);
|
|
880
867
|
if (!artifact)
|
|
881
868
|
return c.json({ error: "not found" }, 404);
|
|
882
|
-
if (artifact.sent)
|
|
883
|
-
return c.json({ error: `already sent at ${artifact.sent.at}` }, 409);
|
|
884
869
|
let request;
|
|
885
870
|
try {
|
|
886
871
|
request = SteerRequestSchema.parse(await c.req.json());
|
|
@@ -888,21 +873,11 @@ export async function buildApp(opts) {
|
|
|
888
873
|
catch (err) {
|
|
889
874
|
return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
890
875
|
}
|
|
891
|
-
if (turnInFlight(artifact)
|
|
892
|
-
|
|
893
|
-
return c.json(updated);
|
|
876
|
+
if (!turnInFlight(artifact) || !steerChatTurn(artifact.id, request.message)) {
|
|
877
|
+
return c.json({ error: "that turn is no longer taking messages — send this as the next one" }, 409);
|
|
894
878
|
}
|
|
895
|
-
const updated = await updateArtifactByKey(key, (a) => a.pendingChat
|
|
896
|
-
|
|
897
|
-
: a);
|
|
898
|
-
if (updated?.pendingChat)
|
|
899
|
-
return c.json(updated);
|
|
900
|
-
if (!updated)
|
|
901
|
-
return c.json({ error: "not found" }, 404);
|
|
902
|
-
if (isReviewRunning(updated.id)) {
|
|
903
|
-
return c.json({ error: busy(updated, "a run for this PR is already in flight") }, 409);
|
|
904
|
-
}
|
|
905
|
-
return c.json(await startTurn(key, updated, request.message));
|
|
879
|
+
const updated = await updateArtifactByKey(key, (a) => a.pendingChat ? { ...a, pendingChat: { ...a.pendingChat, steers: [...a.pendingChat.steers, request.message] } } : a);
|
|
880
|
+
return c.json(updated);
|
|
906
881
|
});
|
|
907
882
|
// Clear a turn that failed. Only that: a turn still being answered would come
|
|
908
883
|
// back on the next write and the cockpit would have lied about dropping it.
|
package/package.json
CHANGED
package/web/dist/assets/{abnfDiagram-WEYOIA3C-DDWiBgJ_.js → abnfDiagram-WEYOIA3C-D5wm8458.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-2E7WHVMD-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-2E7WHVMD-DZv4SQeE.js";import{p as f}from"./chunk-JWPE2WC7-DyJGNKay.js";import{_ as n,l as o}from"./mermaid.core-C6m6PWvg.js";import{M as c,b as d}from"./cynefin-EF2NZ3EQ-Dj_GKCLo.js";import"./index-DIVX8aC0.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a5 as ln,a6 as an,a7 as H,a8 as j,a9 as B,aa as un,ab as g,ac as tn,ad as L,ae as _,af as rn,ag as o,ah as on,ai as sn,aj as fn}from"./mermaid.core-
|
|
1
|
+
import{a5 as ln,a6 as an,a7 as H,a8 as j,a9 as B,aa as un,ab as g,ac as tn,ad as L,ae as _,af as rn,ag as o,ah as on,ai as sn,aj as fn}from"./mermaid.core-C6m6PWvg.js";function cn(l){return l.innerRadius}function gn(l){return l.outerRadius}function yn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,E,q,v,A,C,a){var I=E-l,i=q-h,n=C-v,d=a-A,u=d*I-n*i;if(!(u*u<g))return u=(n*(h-A)-d*(l-v))/u,[l+u*I,h+u*i]}function W(l,h,E,q,v,A,C){var a=l-E,I=h-q,i=(C?A:-A)/L(a*a+I*I),n=i*I,d=-i*a,u=l+n,s=h+d,f=E+n,c=q+d,F=(u+f)/2,t=(s+c)/2,m=f-u,y=c-s,R=m*m+y*y,T=v-A,P=u*c-f*s,O=(y<0?-1:1)*L(on(0,T*T*R-P*P)),S=(P*y-m*O)/R,z=(-P*m-y*O)/R,w=(P*y+m*O)/R,p=(-P*m+y*O)/R,x=S-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(S=w,z=p),{cx:S,cy:z,x01:-n,y01:-d,x11:S*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=gn,E=B(0),q=null,v=yn,A=dn,C=mn,a=null,I=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,F=rn(c-f),t=c>f;if(a||(a=n=I()),s<u&&(d=s,s=u,u=d),!(s>g))a.moveTo(0,0);else if(F>tn-g)a.moveTo(s*H(f),s*j(f)),a.arc(0,0,s,f,c,!t),u>g&&(a.moveTo(u*H(c),u*j(c)),a.arc(0,0,u,c,f,t));else{var m=f,y=c,R=f,T=c,P=F,O=F,S=C.apply(this,arguments)/2,z=S>g&&(q?+q.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+E.apply(this,arguments)),p=w,x=w,e,r;if(z>g){var G=sn(z/u*j(S)),M=sn(z/s*j(S));(P-=G*2)>g?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(O-=M*2)>g?(M*=t?1:-1,m+=M,y-=M):(O=0,m=y=(f+c)/2)}var J=s*H(m),K=s*j(m),N=u*H(T),Q=u*j(T);if(w>g){var U=s*H(y),V=s*j(y),X=u*H(R),Y=u*j(R),D;if(F<an)if(D=pn(J,K,X,Y,U,V,N,Q)){var Z=J-D[0],$=K-D[1],b=U-D[0],k=V-D[1],nn=1/j(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(D[0]*D[0]+D[1]*D[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}O>g?x>g?(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,y,!t)):a.moveTo(J,K),!(u>g)||!(P>g)?a.lineTo(N,Q):p>g?(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-an/2;return[H(d)*n,j(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?(E=typeof n=="function"?n:B(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:B(+n),i):q},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};
|