@zh-xx/antu 0.13.0 → 0.13.1
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/assets/viewer.html +6 -6
- package/bin/antu-mcp.mjs +11 -6
- package/bin/antu.mjs +11 -6
- package/embed/antu-embed.js +16 -8
- package/lib/chunks/report-BTsYMUG2.mjs +4 -4
- package/lib/html.mjs +4 -4
- package/lib/validate.mjs +5 -5
- package/package.json +1 -1
- package/server.json +2 -2
package/assets/viewer.html
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
<meta charset="UTF-8">
|
|
9
9
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
10
10
|
<title>Antu · Antu</title>
|
|
11
|
-
<meta name="generator" content="antu 0.13.
|
|
11
|
+
<meta name="generator" content="antu 0.13.1">
|
|
12
12
|
<script type="text/plain" id="antu-license">
|
|
13
|
-
Antu 0.13.
|
|
13
|
+
Antu 0.13.1
|
|
14
14
|
Copyright (C) 2026 Ji Cheng
|
|
15
15
|
|
|
16
16
|
Antu is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public
|
|
@@ -24,9 +24,9 @@ you drew from your material, are not part of Antu and are not covered by this li
|
|
|
24
24
|
publish them, or sell them on any terms you like. This licence covers Antu's code in the page, and the notices in
|
|
25
25
|
the page must stay with it.
|
|
26
26
|
|
|
27
|
-
Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.
|
|
28
|
-
The licence: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
29
|
-
Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
27
|
+
Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.1
|
|
28
|
+
The licence: https://github.com/zh-xx/Antu/blob/v0.13.1/LICENSE
|
|
29
|
+
Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.1/skills/antu/THIRD-PARTY-NOTICES.md
|
|
30
30
|
|
|
31
31
|
=== The licence of Antu ===
|
|
32
32
|
|
|
@@ -1488,7 +1488,7 @@ html, body { margin: 0; height: 100%; font-family: system-ui, "Microsoft YaHei",
|
|
|
1488
1488
|
+`).split(`
|
|
1489
1489
|
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,E.useEffect)(()=>{let n=t?.target??ug,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&Cm(e))return!1;let n=pg(e.code,s);if(a.current.add(e[n]),fg(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=pg(e.code,s);fg(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function fg(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function pg(e,t){return t.includes(e)?`code`:`key`}var _te=()=>{let e=Zh();return(0,E.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=um(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return am(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=om(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function mg(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)vte(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function vte(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function hg(e,t){return mg(e,t)}function gg(e,t){return mg(e,t)}function _g(e,t){return{id:e,type:`select`,selected:t}}function vg(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);(a.selected!==void 0||e)&&a.selected!==e&&(n&&(a.selected=e),r.push(_g(a.id,e)))}return r}function yg({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function bg(e){return{id:e.id,type:`remove`}}var yte=rm(`React Flow`,`https://reactflow.dev/`);function bte(e,t,n={}){return Fm(e,t,{...n,onError:n.onError??yte})}var xg=e=>Tee(e),Sg=e=>Fp(e);function Cg(e){return(0,E.forwardRef)(e)}var wg=typeof window<`u`?E.useLayoutEffect:E.useEffect;function Tg(e){let[t,n]=(0,E.useState)(BigInt(0)),[r]=(0,E.useState)(()=>xte(()=>n(e=>e+BigInt(1))));return wg(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function xte(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Eg=(0,E.createContext)(null);function Ste({children:e}){let t=Zh(),n=Tg((0,E.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=yg({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=Tg((0,E.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(yg({items:s,lookup:o}))},[])),i=(0,E.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,D.jsx)(Eg.Provider,{value:i,children:e})}function Cte(){let e=(0,E.useContext)(Eg);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var wte=e=>!!e.panZoom;function Dg(){let e=_te(),t=Zh(),n=Cte(),r=Xh(wte),i=(0,E.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=xg(e)?e:n.get(e.id),a=i.parentId?hm(i.position,i.measured,i.parentId,n,r):i.position;return Xp({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&xg(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Sg(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await Vp({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(bg);o?.(f),c(e)}if(m){let e=d.map(bg);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=tm(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=Xp(s?r:a),l=em(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=tm(e)?e:a(e);if(!r)return!1;let i=em(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return Eee(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??Aee();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,E.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var Og=e=>e.selected,Tte=typeof window<`u`?window:void 0;function Ete({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=Zh(),{deleteElements:r}=Dg(),i=dg(e,{actInsideInputWithModifier:!1}),a=dg(t,{target:Tte});(0,E.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(Og),edges:e.filter(Og)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,E.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function Dte(e){let t=Zh();(0,E.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=bm(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,wp.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var kg={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},Ote=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function kte({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=kp.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:h,noWheelClassName:g,noPanClassName:_,onViewportChange:v,isControlledViewport:y,paneClickDistance:b,selectionOnDrag:x}){let S=Zh(),C=(0,E.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:ee}=Xh(Ote,Kh),te=dg(p),ne=(0,E.useRef)();Dte(C);let re=(0,E.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[v,y]);return(0,E.useEffect)(()=>{if(C.current){ne.current=Ree({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:e=>S.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=S.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=S.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=S.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=ne.current.getViewport();return S.setState({panZoom:ne.current,transform:[e,t,n],domNode:C.current.closest(`.react-flow`)}),()=>{ne.current?.destroy()}}},[]),(0,E.useEffect)(()=>{ne.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:te,preventScrolling:m,noPanClassName:_,userSelectionActive:w,noWheelClassName:g,lib:T,onTransformChange:re,connectionInProgress:ee,selectionOnDrag:x,paneClickDistance:b})},[e,t,n,r,i,a,o,s,c,te,m,_,w,g,T,re,ee,x,b]),(0,D.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:kg,children:h})}var Ate=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function jte(){let{userSelectionActive:e,userSelectionRect:t}=Xh(Ate,Kh);return e&&t?(0,D.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var Ag=(e,t)=>n=>{n.target===t.current&&e?.(n)},Mte=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Nte({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Ap.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,E.useRef)(0),_=Zh(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=Xh(Mte,Kh),C=y&&(e||v),w=(0,E.useRef)(null),T=(0,E.useRef)(),ee=(0,E.useRef)(new Set),te=(0,E.useRef)(new Set),ne=(0,E.useRef)(!1),re=(0,E.useRef)(!1),ie=(0,E.useRef)({x:0,y:0}),ae=(0,E.useRef)(!1),oe=e=>{if(re.current||ne.current||_.getState().connection.inProgress){re.current=!1,ne.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},se=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},ce=d?e=>d(e):void 0,le=e=>{re.current&&=(e.stopPropagation(),!1)},ue=n=>{if(n.pointerType===`touch`&&r!==!1&&!t)return;let{domNode:i,transform:a}=_.getState();if(T.current=i?.getBoundingClientRect(),!T.current)return;let s=n.target===w.current;if(!s&&n.target.closest(`.nokey`)||!e||!(o&&s||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),re.current=!1;let{x:c,y:l}=wm(n.nativeEvent,T.current),u=am({x:c,y:l},a);_.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:c,y:l}}),s||(n.stopPropagation(),n.preventDefault())};function de(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=om(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=ee.current,g=te.current;ee.current=new Set(zp(a,m,i,n===Ap.Partial,!0).map(e=>e.id)),te.current=new Set;let v=u?.selectable??!0;for(let e of ee.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&te.current.add(e)}}gm(h,ee.current)||c(vg(a,ee.current,!0)),gm(g,te.current)||l(vg(o,te.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function fe(){if(!i||!T.current)return;let[e,t]=Kp(ie.current,T.current,S);x({x:e,y:t}).then(e=>{if(!re.current||!e){g.current=requestAnimationFrame(fe);return}let{x:t,y:n}=ie.current;de(t,n),g.current=requestAnimationFrame(fe)})}let pe=()=>{cancelAnimationFrame(g.current),g.current=0,ae.current=!1};(0,E.useEffect)(()=>()=>pe(),[]);let me=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=wm(e.nativeEvent,T.current);ie.current={x:o,y:c};let l=om({x:n.startX,y:n.startY},r);if(!re.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}re.current=!0,ae.current||=(fe(),!0),de(o,c)},he=e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(ne.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&oe?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),re.current&&(c?.(e),_.setState({nodesSelectionActive:ee.current.size>0})),pe())},ge=e=>{e.target?.releasePointerCapture?.(e.pointerId),pe()},_e=r===!0||Array.isArray(r)&&r.includes(0);return(0,D.jsxs)(`div`,{className:ec([`react-flow__pane`,{draggable:_e,dragging:b,selection:e}]),onClick:C?void 0:Ag(oe,w),onContextMenu:Ag(se,w),onWheel:Ag(ce,w),onPointerEnter:C?void 0:f,onPointerMove:C?me:p,onPointerUp:he,onPointerCancel:C?ge:void 0,onPointerDownCapture:C?ue:void 0,onClickCapture:C?le:void 0,onPointerLeave:m,ref:w,style:kg,children:[h,(0,D.jsx)(jte,{})]})}function jg({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,wp.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function Mg({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=Zh(),[c,l]=(0,E.useState)(!1),u=(0,E.useRef)();return(0,E.useEffect)(()=>{if(!t)return u.current=vh({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{jg({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,E.useEffect)(()=>{!t&&e.current&&u.current&&u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var Pte=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Ng(){let e=Zh();return(0,E.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=Pte(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=im(t,i));let{position:a,positionAbsolute:s}=Bp({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var Pg=(0,E.createContext)(null),Fte=Pg.Provider;Pg.Consumer;var Fg=()=>(0,E.useContext)(Pg),Ig=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Lg=(0,E.createContext)(null);function Rg({children:e}){let t=Xh(Ig,Kh);return(0,D.jsx)(Lg.Provider,{value:t,children:e})}function Ite(){let e=(0,E.useContext)(Lg);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var Lte={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Rte=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return Lte;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===Op.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function zte({type:e=`source`,position:t=Np.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=Zh(),_=Fg(),{connectOnClick:v,noPanClassName:y,rfId:b}=Ite(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:ee,valid:te}=Xh(Rte(_,m,e),Kh);_||g.getState().onError?.(`010`,wp.error010());let ne=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(bte(i,e,{onError:n}))}n?.(i),s?.(i)},re=e=>{if(!_)return;let t=O(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();Oh.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:ne,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,D.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:ec([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:te,connectionindicator:r&&(!T||w)&&(T||ee?a:i)}]),onMouseDown:re,onTouchStart:re,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=xm(t.target),h=n||c,{connection:v,isValid:y}=Oh.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&ne(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var zg=(0,E.memo)(Cg(zte));function Bte({data:e,isConnectable:t,sourcePosition:n=Np.Bottom}){return(0,D.jsxs)(D.Fragment,{children:[e?.label,(0,D.jsx)(zg,{type:`source`,position:n,isConnectable:t})]})}function Vte({data:e,isConnectable:t,targetPosition:n=Np.Top,sourcePosition:r=Np.Bottom}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(zg,{type:`target`,position:n,isConnectable:t}),e?.label,(0,D.jsx)(zg,{type:`source`,position:r,isConnectable:t})]})}function Hte(){return null}function Bg({data:e,isConnectable:t,targetPosition:n=Np.Top}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(zg,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Vg={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ute={input:Bte,default:Vte,output:Bg,group:Hte};function Hg(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Ug=e=>{let{width:t,height:n,x:r,y:i}=Rp(e.nodeLookup,{filter:e=>!!e.selected});return{width:nm(t)?t:null,height:nm(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function Wte({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=Zh(),{width:i,height:a,transformString:o,userSelectionActive:s}=Xh(Ug,Kh),c=Ng(),l=(0,E.useRef)(null);(0,E.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(Mg({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,D.jsx)(`div`,{className:ec([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,D.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(Vg,e.key)&&(e.preventDefault(),c({direction:Vg[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Wg=typeof window<`u`?window:void 0,Gg=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Gte({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:ee,translateExtent:te,minZoom:ne,maxZoom:re,preventScrolling:ie,onSelectionContextMenu:ae,noWheelClassName:oe,noPanClassName:se,disableKeyboardA11y:ce,onViewportChange:le,isControlledViewport:ue}){let{nodesSelectionActive:de,userSelectionActive:fe}=Xh(Gg,Kh),pe=dg(l,{target:Wg}),me=dg(h,{target:Wg}),he=me||w,ge=me||b,_e=u&&he!==!0,ve=pe||fe||_e;return Ete({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,D.jsx)(kte,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:ge,panActivationKeyPressed:me,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!pe&&he,defaultViewport:ee,translateExtent:te,minZoom:ne,maxZoom:re,zoomActivationKeyCode:g,preventScrolling:ie,noWheelClassName:oe,noPanClassName:se,onViewportChange:le,isControlledViewport:ue,paneClickDistance:s,selectionOnDrag:_e,children:(0,D.jsxs)(Nte,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:he,autoPanOnSelection:T,isSelecting:!!ve,selectionMode:d,selectionKeyPressed:pe,paneClickDistance:s,selectionOnDrag:_e,children:[e,de&&(0,D.jsx)(Wte,{onSelectionContextMenu:ae,noPanClassName:se,disableKeyboardA11y:ce})]})})}Gte.displayName=`FlowRenderer`;var Kg=(0,E.memo)(Gte),Kte=e=>t=>e?zp(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function qte(e){return Xh((0,E.useCallback)(Kte(e),[e]),Kh)}var Jte=e=>e.updateNodeInternals;function qg(){let e=Xh(Jte),[t]=(0,E.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,E.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Jg({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=Zh(),a=(0,E.useRef)(null),o=(0,E.useRef)(null),s=(0,E.useRef)(e.sourcePosition),c=(0,E.useRef)(e.targetPosition),l=(0,E.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,E.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,E.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,E.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Yg({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=Xh(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},Kh),S=y.type||`default`,C=g?.[S]||Ute[S];C===void 0&&(v?.(`003`,wp.error003(S)),S=`default`,C=g?.default||Ute.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),ee=!!(y.connectable||l&&y.connectable===void 0),te=!!(y.focusable||u&&y.focusable===void 0),ne=Zh(),re=mm(y),ie=Jg({node:y,nodeType:S,hasDimensions:re,resizeObserver:d}),ae=Mg({nodeRef:ie,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),oe=Ng();if(y.hidden)return null;let se=pm(y),ce=Hg(y),le=T||w||t||n||r||i,ue=n?e=>n(e,{...b.userNode}):void 0,de=r?e=>r(e,{...b.userNode}):void 0,fe=i?e=>i(e,{...b.userNode}):void 0,pe=a?e=>a(e,{...b.userNode}):void 0,me=o?e=>o(e,{...b.userNode}):void 0,he=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=ne.getState();T&&(!r||!w||i>0)&&jg({id:e,store:ne,nodeRef:ie}),t&&t(n,{...b.userNode})},ge=t=>{if(!(Cm(t.nativeEvent)||m)){if(Ep.includes(t.key)&&T){let n=t.key===`Escape`;jg({id:e,store:ne,unselect:n,nodeRef:ie})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Vg,t.key)){t.preventDefault();let{ariaLabelConfig:e}=ne.getState();ne.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),oe({direction:Vg[t.key],factor:t.shiftKey?4:1})}}},_e=()=>{if(m||!ie.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=ne.getState();i&&(zp(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+se.width/2,y.position.y+se.height/2,{zoom:t[2]}))};return(0,D.jsx)(`div`,{className:ec([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:ae}]),ref:ie,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:le?`all`:`none`,visibility:re?`visible`:`hidden`,...y.style,...ce},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:ue,onMouseMove:de,onMouseLeave:fe,onContextMenu:pe,onClick:he,onDoubleClick:me,onKeyDown:te?ge:void 0,tabIndex:te?0:void 0,onFocus:te?_e:void 0,role:y.ariaRole??(te?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${$h}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,D.jsx)(Fte,{value:e,children:(0,D.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:ee,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:ae,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...se})})})}var Xg=(0,E.memo)(Yg),Zg=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Yte(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=Xh(Zg,Kh),a=qte(e.onlyRenderVisibleElements),o=qg();return(0,D.jsx)(`div`,{className:`react-flow__nodes`,style:kg,children:a.map(a=>(0,D.jsx)(Xg,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}Yte.displayName=`NodeRenderer`;var Qg=(0,E.memo)(Yte);function Xte(e){return Xh((0,E.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&Mm({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),Kh)}var Zte=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,D.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},Qte=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,D.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},$te={[Mp.Arrow]:Zte,[Mp.ArrowClosed]:Qte};function ene(e){let t=Zh();return(0,E.useMemo)(()=>Object.prototype.hasOwnProperty.call($te,e)?$te[e]:(t.getState().onError?.(`009`,wp.error009(e)),null),[e])}var tne=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=ene(t);return c?(0,D.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,D.jsx)(c,{color:n,strokeWidth:o})}):null},nne=({defaultColor:e,rfId:t})=>{let n=Xh(e=>e.edges),r=Xh(e=>e.defaultEdgeOptions),i=(0,E.useMemo)(()=>Ym(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,D.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,D.jsx)(`defs`,{children:i.map(e=>(0,D.jsx)(tne,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};nne.displayName=`MarkerDefinitions`;var k=(0,E.memo)(nne);function rne({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,E.useState)({x:1,y:0,width:0,height:0}),p=ec([`react-flow__edge-textwrapper`,l]),m=(0,E.useRef)(null);return(0,E.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,D.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,D.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,D.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}rne.displayName=`EdgeText`;var ine=(0,E.memo)(rne);function $g({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`path`,{...u,d:e,fill:`none`,className:ec([`react-flow__edge-path`,u.className])}),l?(0,D.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&nm(t)&&nm(n)?(0,D.jsx)(ine,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function e_({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Np.Left||e===Np.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function ane({sourceX:e,sourceY:t,sourcePosition:n=Np.Bottom,targetX:r,targetY:i,targetPosition:a=Np.Top}){let[o,s]=e_({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=e_({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=Em({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function t_(e){return(0,E.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=ane({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,D.jsx)($g,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var one=t_({isInternal:!1}),sne=t_({isInternal:!0});one.displayName=`SimpleBezierEdge`,sne.displayName=`SimpleBezierEdgeInternal`;function n_(e){return(0,E.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Np.Bottom,targetPosition:m=Np.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Hm({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,D.jsx)($g,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var r_=n_({isInternal:!1}),cne=n_({isInternal:!0});r_.displayName=`SmoothStepEdge`,cne.displayName=`SmoothStepEdgeInternal`;function lne(e){return(0,E.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,D.jsx)(r_,{...n,id:r,pathOptions:(0,E.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var i_=lne({isInternal:!1}),une=lne({isInternal:!0});i_.displayName=`StepEdge`,une.displayName=`StepEdgeInternal`;function dne(e){return(0,E.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=Im({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,D.jsx)($g,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var a_=dne({isInternal:!1}),fne=dne({isInternal:!0});a_.displayName=`StraightEdge`,fne.displayName=`StraightEdgeInternal`;function pne(e){return(0,E.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Np.Bottom,targetPosition:s=Np.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=km({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,D.jsx)($g,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var mne=pne({isInternal:!1}),o_=pne({isInternal:!0});mne.displayName=`BezierEdge`,o_.displayName=`BezierEdgeInternal`;var s_={default:o_,straight:fne,step:une,smoothstep:cne,simplebezier:sne},hne={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},c_=(e,t,n)=>n===Np.Left?e-t:n===Np.Right?e+t:e,gne=(e,t,n)=>n===Np.Top?e-t:n===Np.Bottom?e+t:e,l_=`react-flow__edgeupdater`;function u_({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,D.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:ec([l_,`${l_}-${s}`]),cx:c_(t,r,e),cy:gne(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function d_({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=Zh(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;Oh.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,D.jsxs)(D.Fragment,{children:[(e===!0||e===`source`)&&(0,D.jsx)(u_,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,D.jsx)(u_,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function f_({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=Xh(t=>t.edgeLookup.get(e)),b=Xh(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||s_[x];S===void 0&&(_?.(`011`,wp.error011(x)),x=`default`,S=h?.default||s_.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),ee=(0,E.useRef)(null),[te,ne]=(0,E.useState)(!1),[re,ie]=(0,E.useState)(!1),ae=Zh(),{zIndex:oe=y.zIndex,sourceX:se,sourceY:ce,targetX:le,targetY:ue,sourcePosition:de,targetPosition:fe}=Xh((0,E.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return hne;let i=Wm({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=jm({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||hne,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex,_]),Kh),pe=(0,E.useMemo)(()=>y.markerStart?`url('#${Jm(y.markerStart,m)}')`:void 0,[y.markerStart,m]),me=(0,E.useMemo)(()=>y.markerEnd?`url('#${Jm(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||se===null||ce===null||le===null||ue===null)return null;let he=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=ae.getState();T&&(ae.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),ee.current?.blur()):n([e])),i&&i(t,y)},ge=a?e=>{a(e,{...y})}:void 0,_e=o?e=>{o(e,{...y})}:void 0,ve=s?e=>{s(e,{...y})}:void 0,ye=c?e=>{c(e,{...y})}:void 0,be=l?e=>{l(e,{...y})}:void 0;return(0,D.jsx)(`svg`,{style:{zIndex:oe},children:(0,D.jsxs)(`g`,{className:ec([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:te,selectable:T}]),onClick:he,onDoubleClick:ge,onContextMenu:_e,onMouseEnter:ve,onMouseMove:ye,onMouseLeave:be,onKeyDown:C?t=>{if(!v&&Ep.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=ae.getState();t.key===`Escape`?(ee.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${eg}-${m}`:void 0,ref:ee,...y.domAttributes,children:[!re&&(0,D.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:se,sourceY:ce,targetX:le,targetY:ue,sourcePosition:de,targetPosition:fe,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:pe,markerEnd:me,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,D.jsx)(d_,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:se,sourceY:ce,targetX:le,targetY:ue,sourcePosition:de,targetPosition:fe,setUpdateHover:ne,setReconnecting:ie})]})})}var p_=(0,E.memo)(f_),_ne=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function m_({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=Xh(_ne,Kh),b=Xte(t);return(0,D.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,D.jsx)(k,{defaultColor:e,rfId:n}),b.map(e=>(0,D.jsx)(p_,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}m_.displayName=`EdgeRenderer`;var vne=(0,E.memo)(m_),h_=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function g_({children:e}){let t=Zh(),n=(0,E.useRef)(null),[r]=(0,E.useState)(()=>t.getState().transform);return wg(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=h_(r)))};return r(),t.subscribe(r)},[t]),(0,D.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:h_(r)},children:e})}function __(e){let t=Dg(),n=(0,E.useRef)(!1);(0,E.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var yne=e=>e.panZoom?.syncViewport;function bne(e){let t=Xh(yne),n=Zh();return(0,E.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function xne(e){return e.connection.inProgress?{...e.connection,to:am(e.connection.to,e.transform)}:{...e.connection}}function Sne(e){return e?t=>e(xne(t)):xne}function v_(e){return Xh(Sne(e),Kh)}var y_=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Cne({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=Xh(y_,Kh);return a&&i&&c?(0,D.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,D.jsx)(`g`,{className:ec([`react-flow__connection`,vm(s)]),children:(0,D.jsx)(b_,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var b_=({style:e,type:t=jp.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=v_();if(!i)return;if(n)return(0,D.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:vm(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case jp.Bezier:[m]=km(h);break;case jp.SimpleBezier:[m]=ane(h);break;case jp.Step:[m]=Hm({...h,borderRadius:0});break;case jp.SmoothStep:[m]=Hm(h);break;default:[m]=Im(h)}return(0,D.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};b_.displayName=`ConnectionLine`;var x_={};function wne(e=x_){(0,E.useRef)(e),Zh(),(0,E.useEffect)(()=>{},[e])}function S_(){Zh(),(0,E.useRef)(!1),(0,E.useEffect)(()=>{},[])}function C_({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:ee,defaultViewport:te,translateExtent:ne,minZoom:re,maxZoom:ie,preventScrolling:ae,defaultMarkerColor:oe,zoomOnScroll:se,zoomOnPinch:ce,panOnScroll:le,panOnScrollSpeed:ue,panOnScrollMode:de,zoomOnDoubleClick:fe,panOnDrag:pe,autoPanOnSelection:me,onPaneClick:he,onPaneMouseEnter:ge,onPaneMouseMove:_e,onPaneMouseLeave:ve,onPaneScroll:ye,onPaneContextMenu:be,paneClickDistance:xe,nodeClickDistance:Se,onEdgeContextMenu:Ce,onEdgeMouseEnter:we,onEdgeMouseMove:Te,onEdgeMouseLeave:Ee,reconnectRadius:De,onReconnect:Oe,onReconnectStart:ke,onReconnectEnd:Ae,noDragClassName:je,noWheelClassName:Me,noPanClassName:Ne,disableKeyboardA11y:Pe,nodeExtent:Fe,rfId:Ie,viewport:Le,onViewportChange:Re,nodesDraggable:ze}){return wne(e),wne(t),S_(),__(n),bne(Le),(0,D.jsx)(Kg,{onPaneClick:he,onPaneMouseEnter:ge,onPaneMouseMove:_e,onPaneMouseLeave:ve,onPaneContextMenu:be,onPaneScroll:ye,paneClickDistance:xe,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:ee,zoomOnScroll:se,zoomOnPinch:ce,zoomOnDoubleClick:fe,panOnScroll:le,panOnScrollSpeed:ue,panOnScrollMode:de,panOnDrag:pe,autoPanOnSelection:me,defaultViewport:te,translateExtent:ne,minZoom:re,maxZoom:ie,onSelectionContextMenu:d,preventScrolling:ae,noDragClassName:je,noWheelClassName:Me,noPanClassName:Ne,disableKeyboardA11y:Pe,onViewportChange:Re,isControlledViewport:!!Le,children:(0,D.jsxs)(g_,{children:[(0,D.jsx)(vne,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:Oe,onReconnectStart:ke,onReconnectEnd:Ae,onlyRenderVisibleElements:T,onEdgeContextMenu:Ce,onEdgeMouseEnter:we,onEdgeMouseMove:Te,onEdgeMouseLeave:Ee,reconnectRadius:De,defaultMarkerColor:oe,noPanClassName:Ne,disableKeyboardA11y:Pe,rfId:Ie}),(0,D.jsx)(Cne,{style:h,type:m,component:g,containerStyle:_}),(0,D.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,D.jsx)(Qg,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:Se,onlyRenderVisibleElements:T,noPanClassName:Ne,noDragClassName:je,disableKeyboardA11y:Pe,nodeExtent:Fe,rfId:Ie,nodesDraggable:ze}),(0,D.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}C_.displayName=`GraphView`;var Tne=(0,E.memo)(C_),w_=rm(`React Flow`,`https://reactflow.dev/`),T_=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??Tp;fh(h,g,_);let{nodesInitialized:x}=ih(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=um(Rp(p,{filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Tp,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Op.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...wee},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:w_,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:Dp,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},E_=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>$ee((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await kee({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...T_({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,fitViewQueued:o,zIndexMode:s,nodesSelectionActive:c}=m(),{nodesInitialized:l,hasSelectedNodes:u}=ih(e,t,n,{nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:s}),d=c&&u;o&&l?(h(),p({nodes:e,nodesInitialized:l,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):p({nodes:e,nodesInitialized:l,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();fh(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=jee(e,n,r,i,a,o,l);d&&(th(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=Km(e,o.fromHandle,Np.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=lh(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(hg(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(gg(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>_g(e,!0)));return}i(vg(r,new Set([...e]),!0)),a(vg(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>_g(e,!0)));return}a(vg(n,new Set([...e]))),i(vg(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(_g(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(_g(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,_g(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,_g(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(ih(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return uh({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...wee}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...T_()})}},Object.is);function D_({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,E.useState)(()=>E_({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,D.jsx)(nte,{value:m,children:(0,D.jsx)(Ste,{children:(0,D.jsx)(Rg,{children:p})})})}function O_({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,E.useContext)(Jh)?(0,D.jsx)(D.Fragment,{children:e}):(0,D.jsx)(D_,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var k_={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function Ene({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:ee,onEdgesDelete:te,onDelete:ne,onSelectionChange:re,onSelectionDragStart:ie,onSelectionDrag:ae,onSelectionDragStop:oe,onSelectionContextMenu:se,onSelectionStart:ce,onSelectionEnd:le,onBeforeDelete:ue,connectionMode:de,connectionLineType:fe=jp.Bezier,connectionLineStyle:pe,connectionLineComponent:me,connectionLineContainerStyle:he,deleteKeyCode:ge=`Backspace`,selectionKeyCode:_e=`Shift`,selectionOnDrag:ve=!1,selectionMode:ye=Ap.Full,panActivationKeyCode:be=`Space`,multiSelectionKeyCode:xe=dm()?`Meta`:`Control`,zoomActivationKeyCode:Se=dm()?`Meta`:`Control`,snapToGrid:Ce,snapGrid:we,onlyRenderVisibleElements:Te=!1,selectNodesOnDrag:Ee,nodesDraggable:De,autoPanOnNodeFocus:Oe,nodesConnectable:ke,nodesFocusable:Ae,nodeOrigin:je=og,edgesFocusable:Me,edgesReconnectable:Ne,elementsSelectable:Pe=!0,defaultViewport:Fe=pte,minZoom:Ie=.5,maxZoom:Le=2,translateExtent:Re=Tp,preventScrolling:ze=!0,nodeExtent:Be,defaultMarkerColor:Ve=`#b1b1b7`,zoomOnScroll:He=!0,zoomOnPinch:Ue=!0,panOnScroll:We=!1,panOnScrollSpeed:Ge=.5,panOnScrollMode:Ke=kp.Free,zoomOnDoubleClick:qe=!0,panOnDrag:Je=!0,onPaneClick:Ye,onPaneMouseEnter:Xe,onPaneMouseMove:Ze,onPaneMouseLeave:Qe,onPaneScroll:$e,onPaneContextMenu:et,paneClickDistance:tt=1,nodeClickDistance:nt=0,children:rt,onReconnect:it,onReconnectStart:at,onReconnectEnd:ot,onEdgeContextMenu:st,onEdgeDoubleClick:ct,onEdgeMouseEnter:lt,onEdgeMouseMove:ut,onEdgeMouseLeave:dt,reconnectRadius:ft=10,onNodesChange:pt,onEdgesChange:mt,noDragClassName:ht=`nodrag`,noWheelClassName:gt=`nowheel`,noPanClassName:_t=`nopan`,fitView:vt,fitViewOptions:yt,connectOnClick:bt,attributionPosition:xt,proOptions:St,defaultEdgeOptions:Ct,elevateNodesOnSelect:wt=!0,elevateEdgesOnSelect:Tt=!1,disableKeyboardA11y:Et=!1,autoPanOnConnect:Dt,autoPanOnNodeDrag:Ot,autoPanOnSelection:kt=!0,autoPanSpeed:At,connectionRadius:jt,isValidConnection:Mt,onError:Nt,style:Pt,id:Ft,nodeDragThreshold:It,connectionDragThreshold:Lt,viewport:Rt,onViewportChange:zt,width:Bt,height:Vt,colorMode:Ht=`light`,debug:Ut,onScroll:Wt,ariaLabelConfig:Gt,zIndexMode:Kt=`basic`,...qt},Jt){let Yt=Ft||`1`,Xt=gte(Ht),Zt=(0,E.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Wt?.(e)},[Wt]);return(0,D.jsx)(`div`,{"data-testid":`rf__wrapper`,...qt,onScroll:Zt,style:{...Pt,...k_},ref:Jt,className:ec([`react-flow`,i,Xt]),id:Ft,role:`application`,children:(0,D.jsxs)(O_,{nodes:e,edges:t,width:Bt,height:Vt,fitView:vt,fitViewOptions:yt,minZoom:Ie,maxZoom:Le,nodeOrigin:je,nodeExtent:Be,zIndexMode:Kt,children:[(0,D.jsx)(hte,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:De,autoPanOnNodeFocus:Oe,nodesConnectable:ke,nodesFocusable:Ae,edgesFocusable:Me,edgesReconnectable:Ne,elementsSelectable:Pe,elevateNodesOnSelect:wt,elevateEdgesOnSelect:Tt,minZoom:Ie,maxZoom:Le,nodeExtent:Be,onNodesChange:pt,onEdgesChange:mt,snapToGrid:Ce,snapGrid:we,connectionMode:de,translateExtent:Re,connectOnClick:bt,defaultEdgeOptions:Ct,fitView:vt,fitViewOptions:yt,onNodesDelete:ee,onEdgesDelete:te,onDelete:ne,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:ae,onSelectionDragStart:ie,onSelectionDragStop:oe,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:_t,nodeOrigin:je,rfId:Yt,autoPanOnConnect:Dt,autoPanOnNodeDrag:Ot,autoPanSpeed:At,onError:Nt,connectionRadius:jt,isValidConnection:Mt,selectNodesOnDrag:Ee,nodeDragThreshold:It,connectionDragThreshold:Lt,onBeforeDelete:ue,debug:Ut,ariaLabelConfig:Gt,zIndexMode:Kt}),(0,D.jsx)(Tne,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:fe,connectionLineStyle:pe,connectionLineComponent:me,connectionLineContainerStyle:he,selectionKeyCode:_e,selectionOnDrag:ve,selectionMode:ye,deleteKeyCode:ge,multiSelectionKeyCode:xe,panActivationKeyCode:be,zoomActivationKeyCode:Se,onlyRenderVisibleElements:Te,defaultViewport:Fe,translateExtent:Re,minZoom:Ie,maxZoom:Le,preventScrolling:ze,zoomOnScroll:He,zoomOnPinch:Ue,zoomOnDoubleClick:qe,panOnScroll:We,panOnScrollSpeed:Ge,panOnScrollMode:Ke,panOnDrag:Je,autoPanOnSelection:kt,onPaneClick:Ye,onPaneMouseEnter:Xe,onPaneMouseMove:Ze,onPaneMouseLeave:Qe,onPaneScroll:$e,onPaneContextMenu:et,paneClickDistance:tt,nodeClickDistance:nt,onSelectionContextMenu:se,onSelectionStart:ce,onSelectionEnd:le,onReconnect:it,onReconnectStart:at,onReconnectEnd:ot,onEdgeContextMenu:st,onEdgeDoubleClick:ct,onEdgeMouseEnter:lt,onEdgeMouseMove:ut,onEdgeMouseLeave:dt,reconnectRadius:ft,defaultMarkerColor:Ve,noDragClassName:ht,noWheelClassName:gt,noPanClassName:_t,rfId:Yt,disableKeyboardA11y:Et,nodeExtent:Be,viewport:Rt,onViewportChange:zt,nodesDraggable:De}),(0,D.jsx)(fte,{onSelectionChange:re}),rt,(0,D.jsx)(lte,{proOptions:St,position:xt}),(0,D.jsx)(cte,{rfId:Yt,disableKeyboardA11y:Et})]})})}var Dne=Cg(Ene);function One(e){let[t,n]=(0,E.useState)(e);return[t,n,(0,E.useCallback)(e=>n(t=>hg(e,t)),[])]}function A_(e){let[t,n]=(0,E.useState)(e);return[t,n,(0,E.useCallback)(e=>n(t=>gg(e,t)),[])]}wp.error014();function kne({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,D.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ec([`react-flow__background-pattern`,n,r])})}function Ane({radius:e,className:t}){return(0,D.jsx)(`circle`,{cx:e,cy:e,r:e,className:ec([`react-flow__background-pattern`,`dots`,t])})}var j_;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(j_||={});var jne={[j_.Dots]:1,[j_.Lines]:1,[j_.Cross]:6},Mne=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function M_({id:e,variant:t=j_.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,E.useRef)(null),{transform:f,patternId:p}=Xh(Mne,Kh),m=r||jne[t],h=t===j_.Dots,g=t===j_.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]+x[0]/2,b[1]*f[2]+x[1]/2],C=`${p}${e||``}`;return(0,D.jsxs)(`svg`,{className:ec([`react-flow__background`,l]),style:{...c,...kg,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,D.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,D.jsx)(Ane,{radius:y/2,className:u}):(0,D.jsx)(kne,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,D.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}M_.displayName=`Background`;var N_=(0,E.memo)(M_);function Nne(){return(0,D.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,D.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function Pne(){return(0,D.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,D.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function Fne(){return(0,D.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,D.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function Ine(){return(0,D.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,D.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function P_(){return(0,D.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,D.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function F_({children:e,className:t,...n}){return(0,D.jsx)(`button`,{type:`button`,className:ec([`react-flow__controls-button`,t]),...n,children:e})}var I_=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function L_({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=Zh(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=Xh(I_,Kh),{zoomIn:y,zoomOut:b,fitView:x}=Dg();return(0,D.jsxs)(tg,{className:ec([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(F_,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,D.jsx)(Nne,{})}),(0,D.jsx)(F_,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,D.jsx)(Pne,{})})]}),n&&(0,D.jsx)(F_,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,D.jsx)(Fne,{})}),r&&(0,D.jsx)(F_,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,D.jsx)(P_,{}):(0,D.jsx)(Ine,{})}),u]})}L_.displayName=`Controls`;var Lne=(0,E.memo)(L_);function R_({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,D.jsx)(`rect`,{className:ec([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var z_=(0,E.memo)(R_),Rne=e=>e.nodes.map(e=>e.id),B_=e=>e instanceof Function?e:()=>e;function zne({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=z_,onClick:o}){let s=Xh(Rne,Kh),c=B_(t),l=B_(e),u=B_(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,D.jsx)(D.Fragment,{children:s.map(e=>(0,D.jsx)(Vne,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Bne({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=Xh(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=pm(r);return{node:r,x:i,y:a,width:o,height:s}},Kh);return!l||l.hidden||!mm(l)?null:(0,D.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var Vne=(0,E.memo)(Bne),Hne=(0,E.memo)(zne),V_=200,H_=150,U_=e=>!e.hidden,Une=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?Qp(Rp(e.nodeLookup,{filter:U_}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},W_=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Wne=(e,t)=>W_(e.viewBB,t.viewBB)&&W_(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,Gne=`react-flow__minimap-desc`;function G_({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=Zh(),S=(0,E.useRef)(null),{boundingRect:C,panZoom:w,viewBB:T,rfId:ee,translateExtent:te,flowWidth:ne,flowHeight:re,ariaLabelConfig:ie}=Xh(Une,Wne),ae=e?.width??V_,oe=e?.height??H_,se=C.width/ae,ce=C.height/oe,le=Math.max(se,ce),ue=le*ae,de=le*oe,fe=b*le,pe=C.x-(ue-C.width)/2-fe,me=C.y-(de-C.height)/2-fe,he=ue+fe*2,ge=de+fe*2,_e=`${Gne}-${ee}`,ve=(0,E.useRef)(0),ye=(0,E.useRef)();ve.current=le,(0,E.useEffect)(()=>{let e=x.getState().panZoom;if(S.current&&e)return ye.current=Mee({domNode:S.current,panZoom:e,getTransform:()=>x.getState().transform,getViewScale:()=>ve.current}),()=>{ye.current?.destroy()}},[w]),(0,E.useEffect)(()=>{ye.current?.update({translateExtent:te,width:ne,height:re,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,te,ne,re]);let be=p?e=>{let[t,n]=ye.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,xe=(0,E.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m?.(e,n)},[m]),Se=m?xe:void 0,Ce=_??ie[`minimap.ariaLabel`];return(0,D.jsx)(tg,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*le:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:ec([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,D.jsxs)(`svg`,{width:ae,height:oe,viewBox:`${pe} ${me} ${he} ${ge}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":_e,ref:S,onClick:be,children:[Ce&&(0,D.jsx)(`title`,{id:_e,children:Ce}),(0,D.jsx)(Hne,{onClick:Se,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,D.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${pe-fe},${me-fe}h${he+fe*2}v${ge+fe*2}h${-he-fe*2}z
|
|
1490
1490
|
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}G_.displayName=`MiniMap`;var K_=(0,E.memo)(G_),Kne=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,qne={[Lh.Line]:`right`,[Lh.Handle]:`bottom-right`};function q_({nodeId:e,position:t,variant:n=Lh.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=Fg(),y=typeof e==`string`?e:v,b=Zh(),x=(0,E.useRef)(null),S=n===Lh.Handle,C=Xh((0,E.useCallback)(Kne(S&&p),[S,p]),Kh),w=(0,E.useRef)(null),T=t??qne[n];(0,E.useEffect)(()=>{if(x.current&&y)return w.current||=Wee({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=lh([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...hm({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let ee=T.split(`-`);return(0,D.jsx)(`div`,{className:ec([`react-flow__resize-control`,`nodrag`,...ee,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,E.memo)(q_);var J_=`antu.prefs`;function Y_(){try{let e=window.localStorage.getItem(J_);return e?JSON.parse(e):{}}catch{return{}}}function X_(e){try{window.localStorage.setItem(J_,JSON.stringify({...Y_(),...e}))}catch{}}var Jne={read:Y_,write:X_},Z_=()=>{};function Yne(){let e=new Map,t=new Map;return{on(n,r){if(e.set(n,r),t.has(n)){let e=t.get(n);t.delete(n),r(...e)}return()=>{e.get(n)===r&&e.delete(n)}},has(t){return e.has(t)},run(n,...r){let i=e.get(n);if(i)return i(...r);t.set(n,r)}}}function Xne(){let e=[],t=new Set;return{get:()=>e,set(n){e=n,t.forEach(e=>e())},subscribe(e){return t.add(e),()=>t.delete(e)}}}function Q_({preset:e}={}){let t=typeof window<`u`?window.__ANTU_PRESET__??null:null;return{embedded:!1,preset:e===void 0?t:e,prefs:Jne,lang:{read:ie,write:oe},emit:Z_,commands:Yne(),highlight:Xne(),initial:{},drawn:Z_,root:typeof document<`u`?document:null}}var $_=(0,E.createContext)(Q_()),ev=(0,E.createContext)(null),tv=()=>(0,E.useContext)($_),nv=()=>(0,E.useContext)($_).prefs,rv=()=>(0,E.useContext)($_).preset,iv=e=>(0,E.useContext)($_).ui?.[e]!==!1;function av(e,t){if(!e)return!1;let n=typeof t.composedPath==`function`?t.composedPath():null;return n&&n.length?n.includes(e):e.contains(t.target)}var ov=(0,E.createContext)(null);function Zne({children:e,lang:t}){let n=tv(),[r,i]=(0,E.useState)(()=>(t?te(t):null)??n.lang.read()??ne());(0,E.useEffect)(()=>{typeof document>`u`||n.embedded||(document.documentElement.lang=r===`zh`?`zh-CN`:`en`,document.documentElement.dataset.antuLang=r)},[r,n.embedded]);let a=(0,E.useCallback)(e=>{let t=te(e);i(t),n.lang.write(t)},[n.lang]),o=(0,E.useMemo)(()=>{let e=(e,t)=>se(r,e,t);return{lang:r,setLang:a,t:e,labelOf:(t,n)=>{let r=t[n];return r?e(r):n},formatNumber:e=>new Intl.NumberFormat(r===`zh`?`zh-CN`:`en-US`).format(e),ariaLabels:Mi(r)}},[r,a]);return(0,D.jsx)(ov.Provider,{value:o,children:e})}function sv(){let e=(0,E.useContext)(ov);if(!e)throw Error(`useLang must be used inside <LangProvider>`);return e}var cv=[`document`,`modern`,`legal`],lv=`document`,uv={equity:{width:Nn.normal},control:{width:Nn.heavy},contract:{width:Nn.normal,dash:Pn.longDash},debt:{width:Nn.strong,dash:Pn.dashDot},guarantee:{width:Nn.normal,dash:Pn.dashed},kinship:{width:3.6,double:!0},employment:{width:Nn.normal,dash:Pn.dotted},agency:{width:Nn.strong,dash:`1 4`,round:!0},other:{width:Nn.hair,dash:`3 3`}},Qne={equity:{width:.85},control:{width:1.9},contract:{width:.85,dash:`5 3`},debt:{width:1.3,dash:`5 2 1.5 2`},guarantee:{width:.85,dash:`4 3`},kinship:{width:3.2,double:!0},employment:{width:.85,dash:Pn.dotted},agency:{width:1.3,dash:`1 4`,round:!0},other:{width:.6,dash:`3 3`}},dv=(e,t)=>Object.fromEntries(Object.entries(e).map(([e,n])=>[e,{...n,stroke:t}])),fv={neutral:{width:Nn.normal},positive:{width:Nn.strong},negative:{width:Nn.normal,dash:Pn.dashed}},pv={main:{width:Nn.strong},plain:{width:Nn.normal},back:{width:Nn.normal,dash:Pn.dashed}},mv={conclusion:{width:Nn.heavy},norm:{width:Nn.normal},element:{width:Nn.normal},fact:{width:Nn.hair},inference:{width:Nn.normal,dash:Pn.dotted},judgement:{width:Nn.strong}},hv={for:{width:Nn.normal},against:{width:Nn.strong,dash:Pn.dashed},basis:{width:Nn.normal,dash:Pn.dotted}},gv=(e,t)=>Object.fromEntries(Object.entries(e).map(([e,n])=>[e,{...n,...t[e]}])),_v={document:{id:`document`,shadowRgb:`17, 17, 17`,chrome:{radius:2,capsule:2,chip:2,bg:`#ffffff`,bgPop:`#ffffff`,border:`1px solid #111111`,shadow:`none`,blur:`none`},labelKey:`theme.document`,font:{body:`"FangSong", "STFangsong", "FangSong_GB2312", "Songti SC", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", serif`,head:`"SimHei", "Heiti SC", "STHeiti", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif`},color:{ink:`#111111`,ink2:`#2b2b2b`,ink3:`#4d4d4d`,ink4:`#767676`,bg:`#ffffff`,canvas:`#ffffff`,frame:`#111111`,line:`#c9c9c9`,chip:`#f0f0f0`,side1:`#111111`,side2:`#555555`,axis:`#767676`},radius:{person:18,company:3,organization:3,government:3,other:3,pill:2,group:0},entity:{person:{stroke:`#111111`,fill:`#ffffff`,width:1.3},company:{stroke:`#111111`,fill:`#ffffff`,width:1.6},organization:{stroke:`#111111`,fill:`#ffffff`,width:1.3,dash:Pn.dashed},government:{stroke:`#111111`,fill:`#ffffff`,width:1.3},other:{stroke:`#555555`,fill:`#ffffff`,width:1.1,dash:Pn.dotted}},relation:dv(Qne,`#767676`),camp:[{fill:`#ffffff`,stroke:`#111111`,text:`#111111`},{fill:`#ececec`,stroke:`#111111`,text:`#111111`},{fill:`#f7f7f7`,stroke:`#8a8a8a`,text:`#4d4d4d`}],group:{fill:`#f5f5f5`,stroke:`#8a8a8a`,title:`#111111`},campBox:{fill:`none`,stroke:`#111111`,width:.75,dash:`2 3`},flow:{outcome:gv(fv,{neutral:{stroke:`#111111`,fill:`#ffffff`},positive:{stroke:`#111111`,fill:`#ffffff`},negative:{stroke:`#111111`,fill:`#ececec`}}),start:{stroke:`#111111`,fill:`#e2e2e2`},note:{stroke:`none`,fill:`#f5f5f5`,fold:`#767676`},stage:{fill:`#f5f5f5`,stroke:`#8a8a8a`,title:`#111111`},stageLit:{fill:`#e2e2e2`,stroke:`#111111`,title:`#111111`},link:gv(pv,{main:{stroke:`#111111`},plain:{stroke:`#2b2b2b`},back:{stroke:`#4d4d4d`}})},justify:{node:gv(mv,{conclusion:{stroke:`#111111`,fill:`#ffffff`},norm:{stroke:`#111111`,fill:`#ececec`},element:{stroke:`#111111`,fill:`#ffffff`},fact:{stroke:`#111111`,fill:`#ffffff`},inference:{stroke:`#111111`,fill:`#ffffff`},judgement:{stroke:`#111111`,fill:`#ececec`}}),stance:gv(hv,{for:{stroke:`#2b2b2b`},against:{stroke:`#111111`},basis:{stroke:`#4d4d4d`}})},pill:{colored:!1,border:`#111111`}},modern:{id:`modern`,shadowRgb:`15, 23, 42`,chrome:{radius:14,capsule:999,chip:999,bg:`rgba(255, 255, 255, 0.78)`,bgPop:`rgba(255, 255, 255, 0.94)`,border:`1px solid rgba(15, 23, 42, 0.07)`,shadow:`0 4px 18px rgba(15, 23, 42, 0.10), 0 1px 2px rgba(15, 23, 42, 0.06)`,blur:`blur(16px) saturate(1.8)`},labelKey:`theme.modern`,font:{body:`system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif`,head:`system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif`},color:{ink:`#0f172a`,ink2:`#475569`,ink3:`#64748b`,ink4:`#94a3b8`,bg:`#fbfcfd`,canvas:`#fbfcfd`,frame:`#e2e8f0`,line:`#e8ebef`,chip:`#f1f4f8`,side1:`#475569`,side2:`#64748b`,axis:`#94a3b8`},radius:{person:14,company:8,organization:8,government:6,other:8,pill:12,group:12},entity:{person:{stroke:`#94a3b8`,fill:`#f1f5f9`,width:1},company:{stroke:`#334155`,fill:`#ffffff`,width:1.25},organization:{stroke:`#94a3b8`,fill:`#ffffff`,width:1,dash:Pn.dashed},government:{stroke:`#64748b`,fill:`#f8fafc`,width:1},other:{stroke:`#94a3b8`,fill:`#f8fafc`,width:.9,dash:Pn.dotted}},relation:dv(uv,`#475569`),camp:[{fill:`#f1f5f9`,stroke:`#94a3b8`,text:`#334155`},{fill:`#ffffff`,stroke:`#94a3b8`,text:`#334155`},{fill:`#f8fafc`,stroke:`#e2e8f0`,text:`#64748b`}],group:{fill:`#f8fafc`,stroke:`#e2e8f0`,title:`#475569`},campBox:{fill:`#f8fafc`,stroke:`#e2e8f0`,width:1},flow:{outcome:gv(fv,{neutral:{stroke:`#64748b`,fill:`#f8fafc`},positive:{stroke:`#334155`,fill:`#f1f5f9`},negative:{stroke:`#64748b`,fill:`#f1f5f9`}}),start:{stroke:`#334155`,fill:`#e2e8f0`},note:{stroke:`none`,fill:`#f1f5f9`,fold:`#94a3b8`},stage:{fill:`#f8fafc`,stroke:`#e2e8f0`,title:`#475569`},stageLit:{fill:`#f1f5f9`,stroke:`#64748b`,title:`#334155`},link:gv(pv,{main:{stroke:`#0f172a`},plain:{stroke:`#475569`},back:{stroke:`#64748b`}})},justify:{node:gv(mv,{conclusion:{stroke:`#0f172a`,fill:`#f1f5f9`},norm:{stroke:`#475569`,fill:`#e2e8f0`},element:{stroke:`#64748b`,fill:`#f8fafc`},fact:{stroke:`#94a3b8`,fill:`#ffffff`},inference:{stroke:`#64748b`,fill:`#f8fafc`},judgement:{stroke:`#334155`,fill:`#e2e8f0`}}),stance:gv(hv,{for:{stroke:`#475569`},against:{stroke:`#334155`},basis:{stroke:`#94a3b8`}})},pill:{colored:!1,border:`#cbd5e1`}},legal:{id:`legal`,shadowRgb:`19, 35, 63`,chrome:{radius:6,capsule:6,chip:4,bg:`#ffffff`,bgPop:`#ffffff`,border:`1px solid #c7d2e4`,shadow:`0 2px 10px rgba(19, 35, 63, 0.10)`,blur:`none`},labelKey:`theme.legal`,font:{body:`system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif`,head:`system-ui, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif`},color:{ink:`#13233f`,ink2:`#2d4366`,ink3:`#5b6f8f`,ink4:`#8aa0c4`,bg:`#ffffff`,canvas:`#ffffff`,frame:`#c7d2e4`,line:`#dbe3f0`,chip:`#eef3fb`,side1:`#1f3f7f`,side2:`#9a1b1b`,axis:`#8aa0c4`},radius:{person:14,company:3,organization:4,government:3,other:4,pill:4,group:6},entity:{person:{stroke:`#2f5aa8`,fill:`#eef3fb`,width:1},company:{stroke:`#1f3f7f`,fill:`#e3ecfa`,width:1.5},organization:{stroke:`#2f5aa8`,fill:`#f4f7fc`,width:1,dash:Pn.dashed},government:{stroke:`#13233f`,fill:`#eef3fb`,width:1.1},other:{stroke:`#8aa0c4`,fill:`#f8fafd`,width:.9,dash:Pn.dotted}},relation:{equity:{...uv.equity,stroke:`#1f3f7f`},control:{...uv.control,stroke:`#13233f`},contract:{...uv.contract,stroke:`#5b6f8f`},debt:{...uv.debt,stroke:`#9a1b1b`},guarantee:{...uv.guarantee,stroke:`#2f5aa8`},kinship:{...uv.kinship,stroke:`#4b3a8c`},employment:{...uv.employment,stroke:`#1d6b6b`},agency:{...uv.agency,stroke:`#1d6b6b`},other:{...uv.other,stroke:`#8aa0c4`}},camp:[{fill:`#eaf0fb`,stroke:`#9fb6e0`,text:`#1f3f7f`},{fill:`#fbecec`,stroke:`#e3b4b4`,text:`#9a1b1b`},{fill:`#f4f7fc`,stroke:`#c7d2e4`,text:`#5b6f8f`}],group:{fill:`#f4f7fc`,stroke:`#c7d2e4`,title:`#2d4366`},campBox:{fill:`#f4f7fc`,stroke:`#c7d2e4`,width:1},flow:{outcome:gv(fv,{neutral:{stroke:`#2f5aa8`,fill:`#eef3fb`},positive:{stroke:`#1f3f7f`,fill:`#e3ecfa`},negative:{stroke:`#9a1b1b`,fill:`#fbecec`}}),start:{stroke:`#13233f`,fill:`#dbe5f5`},note:{stroke:`none`,fill:`#f4f7fc`,fold:`#8aa0c4`},stage:{fill:`#f4f7fc`,stroke:`#c7d2e4`,title:`#2d4366`},stageLit:{fill:`#eaf0fb`,stroke:`#1f3f7f`,title:`#1f3f7f`},link:gv(pv,{main:{stroke:`#13233f`},plain:{stroke:`#2d4366`},back:{stroke:`#5b6f8f`}})},justify:{node:gv(mv,{conclusion:{stroke:`#1f3f7f`,fill:`#e3ecfa`},norm:{stroke:`#4b3a8c`,fill:`#efecf8`},element:{stroke:`#2f5aa8`,fill:`#eef3fb`},fact:{stroke:`#8aa0c4`,fill:`#f8fafd`},inference:{stroke:`#1d6b6b`,fill:`#e8f4f4`},judgement:{stroke:`#13233f`,fill:`#dbe5f5`}}),stance:gv(hv,{for:{stroke:`#2d4366`},against:{stroke:`#9a1b1b`},basis:{stroke:`#4b3a8c`}})},pill:{colored:!0,border:`#c7d2e4`}}},vv=e=>Object.prototype.hasOwnProperty.call(_v,e),yv=e=>vv(e)?_v[e]:_v[lv],bv=(0,E.createContext)({id:lv,theme:yv(lv),setTheme:()=>{},forced:!1});function $ne(e){let t=e.color;return{"--antu-text":t.ink,"--antu-text-2":t.ink2,"--antu-text-3":t.ink3,"--antu-text-4":t.ink4,"--antu-canvas":t.canvas,"--antu-line":t.line,"--antu-line-soft":t.line,"--antu-chip":t.chip,"--antu-side1":t.side1,"--antu-side2":t.side2,"--antu-axis":t.axis,"--antu-bg":t.bg,"--antu-bad":e.flow.outcome.negative.stroke,"--antu-shadow-rgb":e.shadowRgb,"--antu-chrome-radius":`${e.chrome.radius}px`,"--antu-capsule-radius":`${e.chrome.capsule}px`,"--antu-chip-radius":`${e.chrome.chip}px`,"--antu-pill-radius":`${e.radius.pill}px`,"--antu-chrome-bg":e.chrome.bg,"--antu-chrome-bg-pop":e.chrome.bgPop,"--antu-chrome-border":e.chrome.border,"--antu-chrome-shadow":e.chrome.shadow,"--antu-chrome-blur":e.chrome.blur,"--antu-font":e.font.body,"--antu-font-head":e.font.head}}function ere({children:e,theme:t,initialTheme:n}){let r=nv(),i=rv(),[a,o]=(0,E.useState)(()=>{if(vv(n))return n;let e=r.read().theme;return vv(e)?e:null}),s=vv(t)?t:vv(i?.theme)?i.theme:null,c=s??a??`document`,l=(0,E.useCallback)(e=>{vv(e)&&!s&&(o(e),r.write({theme:e}))},[s,r]),u=(0,E.useMemo)(()=>({id:c,theme:yv(c),setTheme:l,forced:!!s}),[c,l,s]);return(0,D.jsx)(bv.Provider,{value:u,children:e})}var xv=()=>(0,E.useContext)(bv);function Sv(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let n=document.implementation.createHTMLDocument(),r=n.createElement(`base`),i=n.createElement(`a`);return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}var tre=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Cv(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}var wv=null;function Tv(e={}){return wv||(e.includeStyleProperties?(wv=e.includeStyleProperties,wv):(wv=Cv(window.getComputedStyle(document.documentElement)),wv))}function Ev(e,t){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace(`px`,``)):0}function nre(e){let t=Ev(e,`border-left-width`),n=Ev(e,`border-right-width`);return e.clientWidth+t+n}function rre(e){let t=Ev(e,`border-top-width`),n=Ev(e,`border-bottom-width`);return e.clientHeight+t+n}function ire(e,t={}){return{width:t.width||nre(e),height:t.height||rre(e)}}function Dv(){let e,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}var Ov=16384;function are(e){(e.width>Ov||e.height>Ov)&&(e.width>Ov&&e.height>Ov?e.width>e.height?(e.height*=Ov/e.width,e.width=Ov):(e.width*=Ov/e.height,e.height=Ov):e.width>Ov?(e.height*=Ov/e.width,e.width=Ov):(e.width*=Ov/e.height,e.height=Ov))}function kv(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin=`anonymous`,r.decoding=`async`,r.src=e})}async function ore(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function sre(e,t,n){let r=`http://www.w3.org/2000/svg`,i=document.createElementNS(r,`svg`),a=document.createElementNS(r,`foreignObject`);return i.setAttribute(`width`,`${t}`),i.setAttribute(`height`,`${n}`),i.setAttribute(`viewBox`,`0 0 ${t} ${n}`),a.setAttribute(`width`,`100%`),a.setAttribute(`height`,`100%`),a.setAttribute(`x`,`0`),a.setAttribute(`y`,`0`),a.setAttribute(`externalResourcesRequired`,`true`),i.appendChild(a),a.appendChild(e),ore(i)}var Av=(e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Av(n,t)};function cre(e){let t=e.getPropertyValue(`content`);return`${e.cssText} content: '${t.replace(/'|"/g,``)}';`}function lre(e,t){return Tv(t).map(t=>`${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t)?` !important`:``};`).join(` `)}function jv(e,t,n,r){let i=`.${e}:${t}`,a=n.cssText?cre(n):lre(n,r);return document.createTextNode(`${i}{${a}}`)}function Mv(e,t,n,r){let i=window.getComputedStyle(e,n),a=i.getPropertyValue(`content`);if(a===``||a===`none`)return;let o=tre();try{t.className=`${t.className} ${o}`}catch{return}let s=document.createElement(`style`);s.appendChild(jv(o,n,i,r)),t.appendChild(s)}function ure(e,t,n){Mv(e,t,`:before`,n),Mv(e,t,`:after`,n)}var Nv=`application/font-woff`,Pv=`image/jpeg`,Fv={woff:Nv,woff2:Nv,ttf:`application/font-truetype`,eot:`application/vnd.ms-fontobject`,png:`image/png`,jpg:Pv,jpeg:Pv,gif:`image/gif`,tiff:`image/tiff`,svg:`image/svg+xml`,webp:`image/webp`};function Iv(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:``}function Lv(e){return Fv[Iv(e).toLowerCase()]||``}function Rv(e){return e.split(/,/)[1]}function zv(e){return e.search(/^(data:)/)!==-1}function Bv(e,t){return`data:${t};base64,${e}`}async function Vv(e,t,n){let r=await fetch(e,t);if(r.status===404)throw Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((e,t)=>{let a=new FileReader;a.onerror=t,a.onloadend=()=>{try{e(n({res:r,result:a.result}))}catch(e){t(e)}},a.readAsDataURL(i)})}var Hv={};function Uv(e,t,n){let r=e.replace(/\?.*/,``);return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,``)),t?`[${t}]${r}`:r}async function A(e,t,n){let r=Uv(e,t,n.includeQueryParams);if(Hv[r]!=null)return Hv[r];n.cacheBust&&(e+=(/\?/.test(e)?`&`:`?`)+new Date().getTime());let i;try{i=Bv(await Vv(e,n.fetchRequestInit,({res:e,result:n})=>(t||=e.headers.get(`Content-Type`)||``,Rv(n))),t)}catch(t){i=n.imagePlaceholder||``;let r=`Failed to fetch resource: ${e}`;t&&(r=typeof t==`string`?t:t.message),r&&console.warn(r)}return Hv[r]=i,i}async function Wv(e){let t=e.toDataURL();return t===`data:,`?e.cloneNode(!1):kv(t)}async function Gv(e,t){if(e.currentSrc){let t=document.createElement(`canvas`),n=t.getContext(`2d`);return t.width=e.clientWidth,t.height=e.clientHeight,n?.drawImage(e,0,0,t.width,t.height),kv(t.toDataURL())}let n=e.poster;return kv(await A(n,Lv(n),t))}async function dre(e,t){try{if(e?.contentDocument?.body)return await $v(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function Kv(e,t){return Av(e,HTMLCanvasElement)?Wv(e):Av(e,HTMLVideoElement)?Gv(e,t):Av(e,HTMLIFrameElement)?dre(e,t):e.cloneNode(fre(e))}var qv=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SLOT`,fre=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SVG`;async function pre(e,t,n){if(fre(t))return t;let r=[];return r=qv(e)&&e.assignedNodes?Cv(e.assignedNodes()):Av(e,HTMLIFrameElement)&&e.contentDocument?.body?Cv(e.contentDocument.body.childNodes):Cv((e.shadowRoot??e).childNodes),r.length===0||Av(e,HTMLVideoElement)||await r.reduce((e,r)=>e.then(()=>$v(r,n)).then(e=>{e&&t.appendChild(e)}),Promise.resolve()),t}function Jv(e,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):Tv(n).forEach(n=>{let a=i.getPropertyValue(n);n===`font-size`&&a.endsWith(`px`)&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),Av(e,HTMLIFrameElement)&&n===`display`&&a===`inline`&&(a=`block`),n===`d`&&t.getAttribute(`d`)&&(a=`path(${t.getAttribute(`d`)})`),r.setProperty(n,a,i.getPropertyPriority(n))})}function Yv(e,t){Av(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Av(e,HTMLInputElement)&&t.setAttribute(`value`,e.value)}function Xv(e,t){if(Av(e,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(t=>e.value===t.getAttribute(`value`));r&&r.setAttribute(`selected`,``)}}function Zv(e,t,n){return Av(t,Element)&&(Jv(e,t,n),ure(e,t,n),Yv(e,t),Xv(e,t)),t}async function Qv(e,t){let n=e.querySelectorAll?e.querySelectorAll(`use`):[];if(n.length===0)return e;let r={};for(let i=0;i<n.length;i++){let a=n[i].getAttribute(`xlink:href`);if(a){let n=e.querySelector(a),i=document.querySelector(a);!n&&i&&!r[a]&&(r[a]=await $v(i,t,!0))}}let i=Object.values(r);if(i.length){let t=`http://www.w3.org/1999/xhtml`,n=document.createElementNS(t,`svg`);n.setAttribute(`xmlns`,t),n.style.position=`absolute`,n.style.width=`0`,n.style.height=`0`,n.style.overflow=`hidden`,n.style.display=`none`;let r=document.createElementNS(t,`defs`);n.appendChild(r);for(let e=0;e<i.length;e++)r.appendChild(i[e]);e.appendChild(n)}return e}async function $v(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(e=>Kv(e,t)).then(n=>pre(e,n,t)).then(n=>Zv(e,n,t)).then(e=>Qv(e,t))}var ey=/url\((['"]?)([^'"]+?)\1\)/g,ty=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,ny=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function ry(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}function iy(e){let t=[];return e.replace(ey,(e,n,r)=>(t.push(r),e)),t.filter(e=>!zv(e))}async function ay(e,t,n,r,i){try{let a=n?Sv(t,n):t,o=Lv(t),s;return s=i?Bv(await i(a),o):await A(a,o,r),e.replace(ry(t),`$1${s}$3`)}catch{}return e}function mre(e,{preferredFontFormat:t}){return t?e.replace(ny,e=>{for(;;){let[n,,r]=ty.exec(e)||[];if(!r)return``;if(r===t)return`src: ${n};`}}):e}function oy(e){return e.search(ey)!==-1}async function sy(e,t,n){if(!oy(e))return e;let r=mre(e,n);return iy(r).reduce((e,r)=>e.then(e=>ay(e,r,t,n)),Promise.resolve(r))}async function cy(e,t,n){let r=t.style?.getPropertyValue(e);if(r){let i=await sy(r,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function hre(e,t){await cy(`background`,e,t)||await cy(`background-image`,e,t),await cy(`mask`,e,t)||await cy(`-webkit-mask`,e,t)||await cy(`mask-image`,e,t)||await cy(`-webkit-mask-image`,e,t)}async function gre(e,t){let n=Av(e,HTMLImageElement);if((!n||zv(e.src))&&(!Av(e,SVGImageElement)||zv(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,i=await A(r,Lv(r),t);await new Promise((r,a)=>{e.onload=r,e.onerror=t.onImageErrorHandler?(...e)=>{try{r(t.onImageErrorHandler(...e))}catch(e){a(e)}}:a;let o=e;o.decode&&=r,o.loading===`lazy`&&(o.loading=`eager`),n?(e.srcset=``,e.src=i):e.href.baseVal=i})}async function _re(e,t){let n=Cv(e.childNodes).map(e=>ly(e,t));await Promise.all(n).then(()=>e)}async function ly(e,t){Av(e,Element)&&(await hre(e,t),await gre(e,t),await _re(e,t))}function uy(e,t){let{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(e=>{n[e]=r[e]}),e}var dy={};async function fy(e){let t=dy[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},dy[e]=t,t)}async function py(e,t){let n=e.cssText,r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let a=i.replace(r,`$1`);return a.startsWith(`https://`)||(a=new URL(a,e.url).href),Vv(a,t.fetchRequestInit,({result:e})=>(n=n.replace(i,`url(${e})`),[i,e]))});return Promise.all(i).then(()=>n)}function my(e){if(e==null)return[];let t=[],n=e.replace(/(\/\*[\s\S]*?\*\/)/gi,``),r=RegExp(`((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})`,`gi`);for(;;){let e=r.exec(n);if(e===null)break;t.push(e[0])}n=n.replace(r,``);let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=RegExp(`((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})`,`gi`);for(;;){let e=i.exec(n);if(e===null){if(e=a.exec(n),e===null)break;i.lastIndex=a.lastIndex}else a.lastIndex=i.lastIndex;t.push(e[0])}return t}async function hy(e,t){let n=[],r=[];return e.forEach(n=>{if(`cssRules`in n)try{Cv(n.cssRules||[]).forEach((e,i)=>{if(e.type===CSSRule.IMPORT_RULE){let a=i+1,o=e.href,s=fy(o).then(e=>py(e,t)).then(e=>my(e).forEach(e=>{try{n.insertRule(e,e.startsWith(`@import`)?a+=1:n.cssRules.length)}catch(t){console.error(`Error inserting rule from remote css`,{rule:e,error:t})}})).catch(e=>{console.error(`Error loading remote css`,e.toString())});r.push(s)}})}catch(i){let a=e.find(e=>e.href==null)||document.styleSheets[0];n.href!=null&&r.push(fy(n.href).then(e=>py(e,t)).then(e=>my(e).forEach(e=>{a.insertRule(e,a.cssRules.length)})).catch(e=>{console.error(`Error loading remote stylesheet`,e)})),console.error(`Error inlining remote css file`,i)}}),Promise.all(r).then(()=>(e.forEach(e=>{if(`cssRules`in e)try{Cv(e.cssRules||[]).forEach(e=>{n.push(e)})}catch(t){console.error(`Error while reading CSS rules from ${e.href}`,t)}}),n))}function gy(e){return e.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>oy(e.style.getPropertyValue(`src`)))}async function _y(e,t){if(e.ownerDocument==null)throw Error(`Provided element is not within a Document`);return gy(await hy(Cv(e.ownerDocument.styleSheets),t))}function vy(e){return e.trim().replace(/["']/g,``)}function yy(e){let t=new Set;function n(e){(e.style.fontFamily||getComputedStyle(e).fontFamily).split(`,`).forEach(e=>{t.add(vy(e))}),Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&n(e)})}return n(e),t}async function by(e,t){let n=await _y(e,t),r=yy(e);return(await Promise.all(n.filter(e=>r.has(vy(e.style.fontFamily))).map(e=>{let n=e.parentStyleSheet?e.parentStyleSheet.href:null;return sy(e.cssText,n,t)}))).join(`
|
|
1491
|
-
`)}async function xy(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await by(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function vre(e,t={}){let{width:n,height:r}=ire(e,t),i=await $v(e,t,!0);return await xy(i,t),await ly(i,t),uy(i,t),await sre(i,n,r)}async function Sy(e,t={}){let{width:n,height:r}=ire(e,t),i=await kv(await vre(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||Dv(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||are(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}var yre=2,Cy=`is-exporting`;function bre(e,t,n=24){return{width:e+n*2,height:t+n*2,offsetX:n,offsetY:n}}function xre(e){return`${String(e||`antu`).replace(/[\\/:*?"<>|\s]+/g,`-`).slice(0,60)||`antu`}.png`}function Sre(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}function Cre(e){return new Promise((t,n)=>{e.toBlob(e=>{e?t(e):n(Error(`the rendered image could not be encoded as PNG`))},`image/png`)})}async function wy({rootEl:e,graph:t,title:n}){let{blob:r,width:i,height:a}=await j({rootEl:e,graph:t});return Sre(r,xre(n)),{width:i,height:a}}async function j({rootEl:e,graph:t,pixelRatio:n=yre}){let r=e?.querySelector(`.react-flow__viewport`);if(!r)throw Error(`canvas content layer not found; cannot export`);let{width:i,height:a}=t.size,o=bre(i,a),s=e.closest(`.antu-app`)||document.body;s.classList.add(Cy);try{let e=await Sy(r,{width:i,height:a,pixelRatio:n,backgroundColor:`#ffffff`,style:{width:`${i}px`,height:`${a}px`,transform:`translate(0px, 0px) scale(1)`}}),t=document.createElement(`canvas`);t.width=Math.round(o.width*n),t.height=Math.round(o.height*n);let s=t.getContext(`2d`);return s.fillStyle=`#ffffff`,s.fillRect(0,0,t.width,t.height),s.drawImage(e,Math.round(o.offsetX*n),Math.round(o.offsetY*n)),{blob:await Cre(t),width:t.width,height:t.height}}finally{s.classList.remove(Cy)}}var wre=3,Tre=[`@`,`~`];function Ty(e,t){if(!e||typeof e!=`object`||t==null)return null;let n=String(t),r=n.startsWith(`rule:`),i=r?n.slice(5):n,a=Ey(e,i,r),o=Math.max(...Tre.map(e=>i.lastIndexOf(e)));return a||o<=0?a:Ey(e,i.slice(0,o),r)}function Ey(e,t,n){let r=[e];for(let e=0;e<wre&&r.length;e++){let e=[];for(let i of r)for(let[r,a]of Object.entries(i))if(Array.isArray(a)&&r!==`sources`){for(let i of a)if(i&&typeof i==`object`&&!Array.isArray(i)){if(i.id===t&&(!n||r===`rules`))return{collection:r,item:i};e.push(i)}}r=e}return null}function Ere(e,t){let n=Array.isArray(t?.sourceIds)?t.sourceIds:[],r=Array.isArray(e?.sources)?e.sources:[];return n.map(e=>r.find(t=>t?.id===e)).filter(Boolean)}function Dre(e,t){if(t==null)return{type:`select`,id:null,collection:null,sourceIds:[],sources:[]};let n=Ty(e,t);if(!n)return{type:`select`,id:String(t),collection:null,sourceIds:[],sources:[]};let{collection:r,item:i}=n;return{type:`select`,id:i.id,collection:r,sourceIds:Array.isArray(i.sourceIds)?[...i.sourceIds]:[],sources:Ere(e,i)}}var Ore=new Set([`pnode`,`card`,`entry`,`scaleCard`,`rnode`,`jnode`]);function Dy(e,t,n){if(n==null)return[];let r=Ty(e,String(n));if(!r||r.item.id!==String(n))return[];let i=(t??[]).filter(t=>Ty(e,t.id)?.item===r.item).map(e=>e.id);return r.collection===`rules`&&i.push(`rule:${r.item.id}`),i}function Oy(e,t,n){let r=Dy(e,t,n),i=r.find(e=>e.startsWith(`rule:`));if(i)return i;let a=new Map((t??[]).map(e=>[e.id,e.type]));return r.find(e=>Ore.has(a.get(e)))??null}function kre({width:e,natural:t,zoomRight:n=null,minimapWidth:r=null}){let i=n==null?15:n+12,a=t=>t?e-15-r-12:e-15,o=n=>Math.min(Math.max(e/2-t/2,i),n-t);if(r!=null&&t<=a(!0)-i)return{left:o(a(!0)),maxWidth:null,hideMinimap:!1};let s=r!=null,c=a(!1);return t<=c-i?{left:o(c),maxWidth:null,hideMinimap:s}:{left:i,maxWidth:Math.max(c-i,0),hideMinimap:s}}var ky=202;function Are(e){let t=(e,t)=>t.reduce((t,n)=>t+(parseFloat(e[n])||0),0),n=getComputedStyle(e),r=[...e.children].filter(e=>getComputedStyle(e).position!==`absolute`),i=parseFloat(n.columnGap)||0,a=r.reduce((e,n)=>e+n.getBoundingClientRect().width+t(getComputedStyle(n),[`marginLeft`,`marginRight`]),0);return Math.ceil(a+i*Math.max(r.length-1,0)+t(n,[`paddingLeft`,`paddingRight`,`borderLeftWidth`,`borderRightWidth`]))}var Ay=3,jre=160,Mre=()=>null,jy=`__minimap__`,Nre=({width:e,height:t})=>({id:jy,type:`miniGhost`,position:{x:0,y:0},width:Math.max(1,e),height:Math.max(1,t),draggable:!1,selectable:!1,connectable:!1,focusable:!1,data:{},style:{pointerEvents:`none`,visibility:`hidden`}}),Pre=e=>e.id===jy?`#eef1f5`:`#cbd5e1`,Fre=e=>e.startsWith(`rule:`)?`[data-pin-id="${CSS.escape(e)}"]`:`.react-flow__node[data-id="${CSS.escape(e)}"]`;function My({ref:e,graph:t,fitKey:n,fitWidth:r=!1,fitSelf:i=!1,fitMinZoom:a=0,fitMaxZoom:o=0,nodeTypes:s,showGrid:c=!1,style:l,children:u,onNodeMouseEnter:d,onNodeMouseLeave:f,onNodeClick:p,onPaneClick:m}){let{ariaLabels:h}=sv(),g=(0,E.useMemo)(()=>({...s,miniGhost:Mre}),[s]),{theme:_}=xv(),[v,y,b]=One([Nre(t.size),...t.nodes]),[x,S,C]=A_(t.edges);(0,E.useEffect)(()=>{y(e=>{let n=new Map(e.map(e=>[e.id,e]));return[Nre(t.size),...t.nodes].map(e=>n.get(e.id)?.selected?{...e,selected:!0}:e)}),S(t.edges)},[t,y,S]);let w=(0,E.useRef)(null),T=(0,E.useRef)(!1),ee=(e=300)=>{let{width:n,height:i}=t.size;if(!w.current)return;T.current=!0;let s=oe.current;if(r&&n&&i&&s?.clientWidth&&s?.clientHeight){let r={width:s.clientWidth,height:s.clientHeight},a=an(t.size,r),o=r.height*nn/4,c=i*a+o*2<=r.height?(r.height-i*a)/2:o;w.current.setViewport({x:(r.width-n*a)/2,y:c,zoom:a},{duration:e});return}if(a&&n&&i&&s?.clientWidth&&s?.clientHeight){let n={width:s.clientWidth,height:s.clientHeight};if(rn(t.size,n)<a){let t=a,r=n.width*nn/4,o=i*t+16<=n.height?(n.height-i*t)/2:n.height*nn/4;w.current.setViewport({x:r,y:o,zoom:t},{duration:e});return}}if(o&&n&&i&&s?.clientWidth&&s?.clientHeight){let t={width:s.clientWidth,height:s.clientHeight};if(Math.min(t.width/(n*1.12),t.height/(i*1.12))>o){let r=o;w.current.setViewport({x:(t.width-n*r)/2,y:(t.height-i*r)/2,zoom:r},{duration:e});return}}n&&i?w.current.fitBounds({x:0,y:0,width:n,height:i},{padding:nn,duration:e}):w.current.fitView({padding:nn,duration:e})},te=(0,E.useRef)(!0),{drawn:ne}=tv(),[re,ie]=(0,E.useState)(!1);(0,E.useEffect)(()=>{let e=requestAnimationFrame(()=>{let e=te.current;ee(e?0:300),te.current=!1,e&&(ne(),ie(!0))});return()=>cancelAnimationFrame(e)},[n??t]);let ae=(0,E.useMemo)(()=>[[-160,-160],[t.size.width+jre,t.size.height+jre]],[t]),oe=(0,E.useRef)(null),[se,ce]=(0,E.useState)({width:0,height:0});(0,E.useEffect)(()=>{let e=oe.current;if(!e)return;let t=new ResizeObserver(([e])=>{let{width:t,height:n}=e.contentRect;ce({width:t,height:n})});return t.observe(e),()=>t.disconnect()},[]);let le=(0,E.useMemo)(()=>{let{width:e,height:n}=se;return!e||!n?.1:Math.max(rn(t.size,{width:e,height:n}),.05)},[se,t]);(0,E.useImperativeHandle)(e,()=>({exportPng:({title:e}={})=>wy({rootEl:oe.current,graph:t,title:e})}),[t]);let{commands:ue}=tv(),de=(0,E.useRef)(ee);de.current=ee,(0,E.useEffect)(()=>{let e=ue.on(`fitView`,()=>de.current(300)),n=ue.on(`exportPng`,({pixelRatio:e}={})=>j({rootEl:oe.current,graph:t,pixelRatio:e}));return()=>{e(),n()}},[ue,t]);let fe=(0,E.useContext)(ev),{highlight:pe}=tv(),me=(0,E.useRef)(null);me.current={spec:fe,graph:t,minZoom:le},(0,E.useEffect)(()=>{if(!re)return;let e=e=>oe.current?.querySelector(Fre(e)),t=e=>y(t=>t.map(t=>!!t.selected==(t.id===e)?t:{...t,selected:t.id===e})),n=ue.on(`select`,n=>{if(!ue.has(`pin`))return!1;if(n===null)return ue.run(`pin`,null),t(null),!0;let{spec:r,graph:i}=me.current,a=Oy(r,i.nodes,n);return!a||!e(a)?!1:(ue.run(`pin`,a),t(a),!0)}),r=ue.on(`focus`,t=>{let{spec:n,graph:r,minZoom:i}=me.current,a=Dy(n,r.nodes,t).map(e).find(Boolean),o=w.current,s=oe.current?.getBoundingClientRect();if(!a||!o||!s?.width)return!1;let c=a.getBoundingClientRect(),l=o.getZoom(),u=o.screenToFlowPosition({x:c.left+c.width/2,y:c.top+c.height/2}),d=Math.min(s.width*.9*l/c.width,s.height*.9*l/c.height);return o.setCenter(u.x,u.y,{zoom:Math.max(Math.min(l,d),i),duration:300}),!0});return()=>{n(),r()}},[re,ue,y]);let he=(0,E.useSyncExternalStore)(pe.subscribe,pe.get),ge=(0,E.useMemo)(()=>{let e=he.flatMap(e=>Dy(fe,t.nodes,e)).map(Fre);return e.length?`.antu-app:not(.${Cy}) :is(${e.join(`, `)}) { outline: 3px solid var(--antu-side1); outline-offset: 4px; }`:``},[he,fe,t]),_e=iv(`zoom`),ve=iv(`minimap`),ye=iv(`capsule`),[be,xe]=(0,E.useState)({left:null,maxWidth:null,hideMinimap:!1}),Se=(0,E.useRef)(ky);(0,E.useLayoutEffect)(()=>{let e=oe.current;if(!e||!ye)return;let t=()=>{let t=e.querySelector(`.antu-dock-capsule .antu-dock-bar`);if(!t||!e.clientWidth)return;let n=e.getBoundingClientRect(),r=_e?e.querySelector(`.react-flow__controls`):null,i=e.querySelector(`.react-flow__minimap`);i?.offsetWidth&&(Se.current=i.offsetWidth);let a=kre({width:e.clientWidth,natural:Are(t),zoomRight:r?r.getBoundingClientRect().right-n.left:null,minimapWidth:ve?Se.current:null});xe(e=>e.left===a.left&&e.maxWidth===a.maxWidth&&e.hideMinimap===a.hideMinimap?e:a)};t();let n=new ResizeObserver(t);n.observe(e);let r=e.querySelector(`.antu-dock-capsule .antu-dock-bar`);return r&&n.observe(r),()=>n.disconnect()},[ye,_e,ve]);let Ce=be.left==null?void 0:{left:be.left,marginLeft:0,transform:`none`,...be.maxWidth==null?{}:{"--antu-dock-max":`${be.maxWidth}px`}};return(0,E.useEffect)(()=>{let e=oe.current?.querySelector(`.react-flow__viewport`);if(e)for(let[t,n]of Object.entries($ne(_)))e.style.setProperty(t,n)},[_,t]),(0,D.jsxs)(`main`,{className:`antu-canvas${c?` show-grid`:``}`,ref:oe,style:l,children:[ge&&(0,D.jsx)(`style`,{children:ge}),(0,D.jsxs)(Dne,{nodes:v,edges:x,onNodesChange:b,onEdgesChange:C,nodeTypes:g,ariaLabelConfig:h,nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,panOnScroll:!0,panOnScrollMode:`free`,panOnScrollSpeed:1,zoomOnScroll:!1,zoomOnPinch:!0,panOnDrag:!0,translateExtent:ae,onInit:e=>{w.current=e,T.current||requestAnimationFrame(()=>ee(0))},onNodeMouseEnter:d,onNodeMouseLeave:f,onNodeClick:p,onPaneClick:m,fitView:!r&&!i,fitViewOptions:{padding:nn,...o?{maxZoom:o}:{}},minZoom:le,maxZoom:Ay,children:[(0,D.jsx)(N_,{gap:20,color:`#e8ebef`}),_e&&(0,D.jsx)(Lne,{showInteractive:!1,onFitView:()=>ee(300)}),ye&&(0,D.jsx)(tg,{position:`bottom-center`,className:`antu-dock-capsule${be.maxWidth==null?``:` is-wrapped`}`,style:Ce,children:u}),ve&&!be.hideMinimap&&(0,D.jsx)(K_,{pannable:!0,zoomable:!0,nodeColor:Pre})]})]})}function Ny(e){let{t}=sv(),n=(0,E.useRef)(null),r=(0,E.useRef)(!1),[i,a]=(0,E.useState)(!1);return{canvasRef:n,exporting:i,onExport:async()=>{if(!r.current){r.current=!0,a(!0);try{await n.current?.exportPng({title:e})}catch(e){console.error(`[antu] export failed:`,e),window.alert(t(`export.failed`,{message:e.message}))}finally{r.current=!1,a(!1)}}}}}var Py=(0,E.createContext)({hoveredId:null,pinnedId:null,pin:()=>{},unpin:()=>{},focusOn:null});function Fy({event:e,actorNames:t,sources:n,isPinned:r,showPreview:i,placement:a,onClose:o}){let{t:s,lang:c}=sv(),l=e.date&&e.dateEnd?tt(e.date,e.dateEnd,s):``;return(0,D.jsxs)(`div`,{className:[`antu-preview`,`nowheel`,`nopan`,a,r?`pinned`:``].filter(Boolean).join(` `),children:[r&&(0,D.jsx)(`button`,{className:`antu-preview-close`,title:s(`common.close`),onClick:e=>{e.stopPropagation(),o()},children:`×`}),r&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`antu-preview-time`,children:et(e,c)}),l&&(0,D.jsx)(`div`,{className:`antu-preview-duration`,children:s(`card.duration`,{duration:l})}),(0,D.jsx)(`div`,{className:`antu-preview-title`,children:e.label}),t.length>0&&(0,D.jsx)(`div`,{className:`antu-preview-actors`,children:t.map(e=>(0,D.jsx)(`span`,{className:`antu-actor-tag`,children:e},e))})]}),e.detail&&(0,D.jsx)(`div`,{className:`antu-preview-text`,children:e.detail}),r&&e.dateNote&&(0,D.jsx)(`div`,{className:`antu-preview-note`,children:s(`card.dateNote`,{note:e.dateNote})}),r&&n.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`antu-preview-sub`,children:s(`card.sources`,{n:n.length})}),n.map(e=>(0,D.jsxs)(`div`,{className:`antu-source`,children:[(0,D.jsxs)(`div`,{className:`antu-source-name`,children:[e.name,(0,D.jsx)(`span`,{className:`antu-source-type`,children:ji(ki,e.type,c)})]}),e.quote&&(0,D.jsx)(`div`,{className:`antu-source-quote`,children:e.quote})]},e.id))]}),!r&&(0,D.jsx)(`div`,{className:`antu-preview-src${n.length?``:` is-none`}`,children:n.length?s(`card.sourcesList`,{n:n.length,names:n.map(e=>e.name).join(` · `)}):s(`card.sourcesUnlisted`)}),i&&(0,D.jsx)(`div`,{className:`antu-preview-hint`,children:s(`card.previewHint`)})]})}var Ire=(0,E.memo)(function({data:e}){let{event:t,actorNames:n,sources:r,groupIndex:i,row:a,cardW:o,cardH:s,labelLines:c,fields:l={},isH:u}=e,{hoveredId:d,pinnedId:f,pin:p,unpin:m}=(0,E.useContext)(Py),{t:h,lang:g}=sv(),_=f===t.id,v=!f&&d===t.id,y=_||v;return(0,D.jsxs)(`div`,{className:`antu-card g${i}`,style:{width:o,height:s},role:`button`,tabIndex:0,"aria-label":h(`card.ariaLabel`,{label:t.label,date:t.date||``}),"aria-expanded":y,onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),_?m():p(t.id)):e.key===`Escape`&&m()},children:[(0,D.jsx)(`div`,{className:`antu-card-label`,style:{WebkitLineClamp:c,lineClamp:c},children:t.label}),l.summary&&t.summary&&(0,D.jsx)(`div`,{className:`antu-card-snippet`,children:t.summary}),l.actors&&n.length>0&&(0,D.jsx)(`div`,{className:`antu-card-actors`,children:n.map(e=>(0,D.jsx)(`span`,{className:`antu-actor-tag`,children:e},e))}),(0,D.jsxs)(`div`,{className:`antu-card-foot`,children:[(0,D.jsx)(`span`,{className:`antu-card-time${t.date?``:` is-unknown`}`,title:t.dateNote||``,children:et(t,g)}),l.sources&&(0,D.jsxs)(`span`,{className:`antu-card-src${r.length?``:` is-none`}`,children:[(0,D.jsx)(`i`,{className:`antu-src-dot`}),r.length?h(`card.sources`,{n:r.length}):h(`card.sourcesUnlisted`)]})]}),y&&(0,D.jsx)(Fy,{event:t,actorNames:n,sources:r,isPinned:_,showPreview:v,placement:u?a===0?`right`:`left`:a===0?`below`:`above`,onClose:m})]})}),Lre=[[`en`,`dock.langEn`],[`zh`,`dock.langZh`]];function Iy({options:e,value:t,onChange:n,title:r}){let{t:i}=sv();return(0,D.jsx)(`div`,{className:`antu-dock-seg`,title:r,children:e.map(([e,r])=>(0,D.jsx)(`button`,{className:`antu-dock-seg-item${t===e?` is-on`:``}`,onClick:()=>n(e),children:i(r)},e))})}function Ly(){let{t:e,lang:t,setLang:n}=sv();return(0,D.jsx)(Iy,{options:Lre,value:t,onChange:n,title:e(`dock.lang`)})}function Ry({exporting:e=!1,onExport:t}){let{t:n}=sv();return(0,D.jsxs)(`button`,{className:`antu-dock-action`,onClick:t,disabled:e,title:n(`dock.exportTitle`),children:[(0,D.jsx)(`svg`,{className:`antu-dock-action-icon`,viewBox:`0 0 16 16`,width:`13`,height:`13`,fill:`none`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`M8 1.8v7.4M4.8 6.2 8 9.4l3.2-3.2M2.4 12.6h11.2`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})}),n(e?`dock.exporting`:`dock.exportImage`)]})}var zy=[`sources`,`actors`,`summary`],By={sources:`dock.sources`,actors:`dock.actors`,summary:`dock.summary`},Vy=[[`vertical`,`dock.vertical`],[`horizontal`,`dock.horizontal`]];function Hy({fields:e={},onToggleField:t,orientation:n=`vertical`,onToggleOrientation:r,showGrid:i=!1,onToggleGrid:a,stagger:o=!1,onToggleStagger:s,exporting:c=!1,onExport:l}){let{t:u}=sv();return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[zy.map(n=>(0,D.jsx)(`button`,{className:`antu-dock-chip${e[n]?` is-on`:``}`,onClick:()=>t(n,!e[n]),children:u(By[n])},n)),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Iy,{options:Vy,value:n,onChange:r}),s&&n===`vertical`&&(0,D.jsx)(`button`,{className:`antu-dock-chip${o?` is-on`:``}`,"data-chip":`stagger`,"aria-pressed":o,title:u(`dock.staggerHint`),onClick:()=>s(!o),children:u(`dock.stagger`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),!(o&&n===`vertical`)&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{className:`antu-dock-chip${i?` is-on`:``}`,"data-chip":`grid`,onClick:()=>a(!i),children:u(`dock.grid`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`})]}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:c,onExport:l})]})})}var Uy=(0,E.memo)(function({data:e}){let{width:t,height:n,isH:r,groupIndex:i,sideTitle:a,colTitle:o,actors:s,laneWs:c=[]}=e;return(0,D.jsxs)(`div`,{className:`antu-colhead g${i}${r?` is-h`:``}${s?` is-span`:``}`,style:{width:t,height:n||void 0},children:[a&&(0,D.jsx)(`div`,{className:`antu-colhead-side`,children:a}),s&&(0,D.jsx)(`div`,{className:`antu-colhead-actors`,children:s.map((e,t)=>(0,D.jsx)(`div`,{className:`antu-colhead-actor`,style:{width:c[t]},children:e},t))}),o&&(0,D.jsx)(`div`,{className:`antu-colhead-actor`,children:o})]})}),Wy=(0,E.memo)(function({data:e}){let{isH:t,length:n,dotOffsets:r,dotSize:i}=e;return(0,D.jsxs)(`div`,{className:`antu-axis-wrap${t?` is-h`:``}`,style:t?{width:n}:{height:n},children:[(0,D.jsx)(`div`,{className:`antu-axis-line`,style:t?{width:n}:{height:n},children:t?(0,D.jsx)(`svg`,{className:`antu-axis-arrow`,width:`6`,height:`10`,viewBox:`0 0 6 10`,"aria-hidden":`true`,children:(0,D.jsx)(`polygon`,{points:`0,0 6,5 0,10`,fill:`currentColor`})}):(0,D.jsx)(`svg`,{className:`antu-axis-arrow`,width:`10`,height:`6`,viewBox:`0 0 10 6`,"aria-hidden":`true`,children:(0,D.jsx)(`polygon`,{points:`0,0 10,0 5,6`,fill:`currentColor`})})}),r.map((e,n)=>(0,D.jsx)(`span`,{className:`antu-axis-dot`,style:t?{left:e,top:-4,width:i,height:i}:{top:e,left:-4,width:i,height:i}},n))]})}),Gy=(0,E.memo)(function({data:e}){let{segments:t,isH:n}=e;return(0,D.jsx)(`div`,{className:`antu-link-layer`,children:t.map((e,t)=>(0,D.jsx)(`span`,{className:`antu-link${n?` is-h`:``}`,style:{left:e.left,top:e.top,width:e.width,height:e.height}},t))})}),Ky=1,qy=(0,E.memo)(function({data:e}){let{rows:t,cellW:n,cellH:r,originX:i,originY:a,isH:o,lanes:s=[]}=e,c=1/(Xh(e=>e.transform[2])||1),l=.8*c,u=o?r:n,d=Ky*u,f=[...Array.from({length:Ky},(e,t)=>({start:t*u,size:u})),...s.map(e=>({start:d+e.start,size:e.size}))],p=d+(s.length?s[s.length-1].start+s[s.length-1].size:0);for(let e=0;e<Ky;e+=1)f.push({start:p+e*u,size:u});let m=p+Ky*u,h=o?i+t*n:m,g=o?m:a+t*r,_=[];for(let e=0;e<t;e+=1)f.forEach((t,s)=>{let u=(o?i+e*n:t.start)+l/2,d=(o?t.start:a+e*r)+l/2;_.push((0,D.jsx)(`rect`,{className:`antu-cell`,x:u,y:d,width:(o?n:t.size)-l,height:(o?t.size:r)-l,strokeWidth:l,strokeDasharray:`${11*c} ${7*c}`},`${e}-${s}`))});return(0,D.jsx)(`svg`,{className:`antu-cells`,style:{left:o?0:-d,top:o?-d:0,width:h,height:g},children:_})});function Jy(e,t,n){let{embedded:r,emit:i,commands:a}=tv(),o=(0,E.useRef)(null);(0,E.useEffect)(()=>{r&&o.current!==t&&(o.current=t,i(Dre(e,t)))},[r,i,e,t]),(0,E.useEffect)(()=>{if(n)return a.on(`pin`,e=>n(e))},[a,n])}var Rre={card:Ire,colHeader:Uy,axis:Wy,links:Gy,cells:qy},Yy={sources:!1,actors:!1,summary:!0};function Xy({spec:e}){let t=rv(),n=nv(),r=e?.title||``,[i,a]=(0,E.useState)(()=>({...Yy,...n.read().fields,...t?.fields||{}})),o=(e,t)=>{a(n=>({...n,[e]:t})),n.write({fields:{...n.read().fields,[e]:t}})},[s,c]=(0,E.useState)(()=>n.read().showGrid===!0),l=e=>{c(e),n.write({showGrid:e})},[u,d]=(0,E.useState)(()=>n.read().staggers||{}),f=t?.stagger??u[r]??!0,p=e=>{let t={...u,[r]:e};d(t),n.write({staggers:t})},[m,h]=(0,E.useState)(()=>n.read().orientations||{}),g=Array.isArray(e?.slots)?e.slots.length:0,_=t?.orientation||m[r]||(g>=5?`vertical`:`horizontal`),v=e=>{let t={...m,[r]:e};h(t),n.write({orientations:t})},y=(0,E.useMemo)(()=>Ze(e,i,void 0,_,{stagger:f}),[e,i,_,f]),[b,x]=(0,E.useState)(null),[S,C]=(0,E.useState)(null);Jy(e,S,C);let{canvasRef:w,exporting:T,onExport:ee}=Ny(e?.title),te=(0,E.useMemo)(()=>({hoveredId:b,pinnedId:S,pin:e=>C(e),unpin:()=>C(null)}),[b,S]);return(0,D.jsx)(`div`,{className:`antu-fact`,children:(0,D.jsx)(Py.Provider,{value:te,children:(0,D.jsx)(My,{ref:w,graph:y,nodeTypes:Rre,showGrid:s&&!y.staggered,style:{"--antu-card-pad-x":`13px`,"--antu-card-pad-y":`11px`,"--antu-label-font":`13px`,"--antu-snippet-font":`${ye}px`},onNodeMouseEnter:(e,t)=>{t.type===`card`&&x(t.id)},onNodeMouseLeave:(e,t)=>{x(e=>e===t.id?null:e)},onNodeClick:(e,t)=>{t.type===`card`&&C(t.id)},onPaneClick:()=>C(null),children:(0,D.jsx)(Hy,{fields:i,onToggleField:o,orientation:_,onToggleOrientation:v,showGrid:s,onToggleGrid:l,stagger:f,onToggleStagger:p,exporting:T,onExport:ee})})})})}v(`fact`,`timeline`,Xy,`graphKind.timeline`);var Zy=(0,E.memo)(function({data:e}){let{event:t,groupIndex:n,actorNames:r,sources:i,fields:a,cardH:o,sameDay:s,dim:c=!1}=e,{hoveredId:l,pinnedId:u,pin:d,unpin:f}=(0,E.useContext)(Py),{t:p,lang:m}=sv(),h=u===t.id,g=!u&&l===t.id,_=h||g;return(0,D.jsxs)(`div`,{className:`antu-chr-entry${c?` is-dim`:``}`,style:{height:o},"data-group":n,children:[(0,D.jsx)(`div`,{className:`antu-chr-when${t.date?``:` is-unknown`}`,style:{width:150},title:t.dateNote||``,children:nt(t,m,s).map((e,t)=>(0,D.jsx)(`div`,{className:e.strong?`is-date`:``,children:e.text},t))}),(0,D.jsxs)(`div`,{className:`antu-chr-card`,style:{left:198,width:560,height:o},role:`button`,tabIndex:0,"aria-label":p(`card.ariaLabel`,{label:t.label,date:t.date||``}),"aria-expanded":_,onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),h?f():d(t.id)):e.key===`Escape`&&f()},children:[(0,D.jsx)(`div`,{className:`antu-chr-title`,children:t.label}),a.summary&&t.summary&&(0,D.jsx)(`div`,{className:`antu-chr-summary`,children:t.summary}),(a.actors&&r.length>0||a.sources)&&(0,D.jsxs)(`div`,{className:`antu-chr-tags`,children:[a.actors&&r.map(e=>(0,D.jsx)(`span`,{className:`antu-actor-tag`,children:e},e)),a.sources&&(0,D.jsxs)(`span`,{className:`antu-card-src${i.length?``:` is-none`}`,children:[(0,D.jsx)(`i`,{className:`antu-src-dot`}),i.length?p(`card.sources`,{n:i.length}):p(`card.sourcesUnlisted`)]})]}),_&&(0,D.jsx)(Fy,{event:t,actorNames:r,sources:i,isPinned:h,showPreview:g,placement:`right`,onClose:f})]})]})}),Qy=(0,E.memo)(function({data:e}){let{x:t,top:n,bottom:r,dots:i,pills:a,breaks:o,dotSize:s}=e,{t:c}=sv(),l=[],u=n;for(let e of o)l.push({y0:u,y1:e.y0,dashed:!1}),l.push({y0:e.y0,y1:e.y1,dashed:!0}),u=e.y1;return l.push({y0:u,y1:r,dashed:!1}),(0,D.jsxs)(`div`,{className:`antu-chr-spine`,children:[l.filter(e=>e.y1>e.y0).map((e,n)=>(0,D.jsx)(`span`,{className:`antu-chr-line${e.dashed?` is-break`:``}`,style:{left:t-1.5,top:e.y0,height:e.y1-e.y0}},`s${n}`)),i.map((e,n)=>(0,D.jsx)(`span`,{className:`antu-chr-dot g${e.groupIndex} s-${e.shape}${e.hollow?` is-hollow`:``}${e.dim?` is-dim`:``}`,style:{left:t-s/2,top:e.y-s/2,width:s,height:s}},`d${n}`)),a.map((e,n)=>(0,D.jsx)(`span`,{className:`antu-chr-gap${e.gap.long?` is-long`:``}`,style:{left:t+12,top:e.y},children:(e.gap.approx?c(`card.approxPrefix`):``)+c(e.gap.key,e.gap.vars)},`p${n}`))]})}),zre=(0,E.memo)(function({data:e}){let{groups:t,active:n=null,onToggle:r}=e;return(0,D.jsx)(`div`,{className:`antu-chr-legend nodrag nopan`,children:t.map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`antu-chr-legend-item g${e.groupIndex}${n===e.groupIndex?` is-on`:``}${n!==null&&n!==e.groupIndex?` is-off`:``}`,"aria-pressed":n===e.groupIndex,onClick:()=>r?.(e.groupIndex),children:[(0,D.jsx)(`i`,{className:`antu-chr-mark s-${e.shape}`}),e.label]},e.groupIndex))})}),Bre=[`sources`,`actors`,`summary`],$y={sources:`dock.sources`,actors:`dock.actors`,summary:`dock.summary`};function Vre({fields:e={},onToggleField:t,exporting:n=!1,onExport:r}){let{t:i}=sv();return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[Bre.map(n=>(0,D.jsx)(`button`,{className:`antu-dock-chip${e[n]?` is-on`:``}`,onClick:()=>t(n,!e[n]),children:i($y[n])},n)),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:n,onExport:r})]})})}var Hre={entry:Zy,spine:Qy,legend:zre};function Ure(e){if(typeof document>`u`)return null;let t=document.createElement(`canvas`).getContext?.(`2d`);if(!t)return null;let n=getComputedStyle(e?.querySelector?.(`.antu-app`)||document.body).fontFamily,r={title:`600 14px ${n}`,summary:`${rt}px ${n}`},i=new Map;return(e,n)=>{let a=n+`\0`+e,o=i.get(a);return o===void 0&&(t.font=r[n],o=t.measureText(e).width,i.set(a,o)),o}}var eb={sources:!1,actors:!1,summary:!0};function tb({spec:e}){let t=rv(),n=nv(),[r,i]=(0,E.useState)(()=>({...eb,...n.read().fields,...t?.fields||{}})),a=(e,t)=>{i(n=>({...n,[e]:t})),n.write({fields:{...n.read().fields,[e]:t}})},{root:o}=tv(),s=(0,E.useMemo)(()=>Ure(o),[o]),c=(0,E.useMemo)(()=>kt(e,r,{measure:s}),[e,r,s]),[l,u]=(0,E.useState)(null),d=e=>u(t=>t===e?null:e),f=(0,E.useMemo)(()=>{if(l===null)return{...c,nodes:c.nodes.map(e=>e.type===`legend`?{...e,data:{...e.data,active:null,onToggle:d}}:e)};let e=c.nodes.map(e=>e.type===`entry`?{...e,data:{...e.data,dim:e.data.groupIndex!==l||e.data.shape===`none`}}:e.type===`spine`?{...e,data:{...e.data,dots:e.data.dots.map(e=>({...e,dim:e.groupIndex!==l||e.shape===`none`}))}}:e.type===`legend`?{...e,data:{...e.data,active:l,onToggle:d}}:e);return{...c,nodes:e}},[c,l]),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)(null);Jy(e,h,g);let{canvasRef:_,exporting:v,onExport:y}=Ny(e?.title),b=(0,E.useMemo)(()=>({hoveredId:p,pinnedId:h,pin:e=>g(e),unpin:()=>g(null)}),[p,h]);return(0,D.jsx)(`div`,{className:`antu-fact antu-chr`,children:(0,D.jsx)(Py.Provider,{value:b,children:(0,D.jsx)(My,{ref:_,graph:f,fitWidth:!0,nodeTypes:Hre,style:{"--antu-chr-pad-x":`14px`,"--antu-chr-pad-y":`10px`,"--antu-chr-title-font":`14px`,"--antu-chr-title-lh":`20px`,"--antu-chr-summary-font":`${rt}px`,"--antu-chr-summary-lh":`18px`,"--antu-chr-tag-font":`${it}px`,"--antu-chr-tag-lh":`20px`,"--antu-chr-when-lh":`18px`},onNodeMouseEnter:(e,t)=>{t.type===`entry`&&m(t.id)},onNodeMouseLeave:(e,t)=>{m(e=>e===t.id?null:e)},onNodeClick:(e,t)=>{t.type===`entry`&&g(t.id)},onPaneClick:()=>g(null),children:(0,D.jsx)(Vre,{fields:r,onToggleField:a,exporting:v,onExport:y})})})})}v(`fact`,`chronicle`,tb,`graphKind.chronicle`);var nb=e=>e<=20?String.fromCodePoint(9312+e-1):`(${e})`,Wre=(0,E.memo)(function({data:e}){let{t}=sv(),{theme:n}=xv(),r=n.color,i=[r.side1,r.side2,r.axis],a=r.line,o=r.ink3,{width:s,labelW:c,lanesH:l,axisY:u,lanes:d,segments:f,ticks:p,marks:m,leaders:h,brackets:g}=e,_=u+44,v=e=>i[e]??i[2],y=[];return d.forEach((e,t)=>y.push(t===0?0:y[t-1]+(e.groupIndex===d[t-1].groupIndex?0:1))),(0,D.jsxs)(`div`,{className:`antu-sc-layer`,style:{width:s,height:_},children:[(0,D.jsxs)(`svg`,{width:s,height:_,className:`antu-sc-svg`,"aria-hidden":`true`,children:[d.map((e,t)=>(0,D.jsxs)(`g`,{children:[y[t]%2==1&&(0,D.jsx)(`rect`,{x:0,y:e.top,width:s,height:e.lineY-e.top+14,fill:r.chip,fillOpacity:.6}),(0,D.jsx)(`line`,{x1:c,x2:s,y1:e.lineY,y2:e.lineY,stroke:a,strokeWidth:2})]},e.key)),f.filter(e=>e.breakBefore).map(e=>{let t=e.breakBefore;return(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`rect`,{x:t.x+6,y:0,width:t.w-12,height:u,fill:r.chip}),(0,D.jsx)(`line`,{x1:t.x+6,x2:t.x+6,y1:0,y2:u,stroke:r.line,strokeDasharray:`3 4`}),(0,D.jsx)(`line`,{x1:t.x+t.w-6,x2:t.x+t.w-6,y1:0,y2:u,stroke:r.line,strokeDasharray:`3 4`}),(0,D.jsx)(`text`,{x:t.x+32,y:u+5,textAnchor:`middle`,fontSize:14,fontWeight:700,fill:o,children:`//`})]},`b${e.index}`)}),h.map((e,t)=>(0,D.jsx)(`line`,{x1:e.x,x2:e.x,y1:e.y0,y2:e.y1,stroke:r.ink4,strokeWidth:1,strokeDasharray:e.run?`3 3`:void 0},`l${t}`)),m.map(e=>{let n=v(e.groupIndex);if(e.kind===`band`)return(0,D.jsx)(`rect`,{x:e.x0,y:e.y-7,width:e.x1-e.x0,height:14,rx:3,fill:n,fillOpacity:.16,stroke:n,strokeOpacity:.5,strokeDasharray:`3 2`},e.id);if(e.kind===`bar`)return(0,D.jsx)(`rect`,{x:e.x0,y:e.y-4,width:Math.max(6,e.x1-e.x0),height:8,rx:4,fill:n},e.id);if(e.undated)return(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:5,fill:r.bg,stroke:i[2],strokeWidth:1.5,strokeDasharray:`2 2`},e.id);if(e.coarse){let i=t(`scale.coarse.${e.prec}`),a=e.x+130>s;return(0,D.jsxs)(`g`,{children:[e.groupIndex===1?(0,D.jsx)(`rect`,{x:e.x-5,y:e.y-5,width:10,height:10,rx:2,fill:r.bg,stroke:n,strokeWidth:1.8}):(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:5,fill:r.bg,stroke:n,strokeWidth:1.8}),(0,D.jsx)(`text`,{x:a?e.x-10:e.x+10,y:e.y+4,textAnchor:a?`end`:`start`,fontSize:11,fill:n,children:i})]},e.id)}return e.groupIndex===1?(0,D.jsx)(`rect`,{x:e.x-5,y:e.y-5,width:10,height:10,rx:2,fill:n,stroke:r.bg,strokeWidth:2},e.id):(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:5.5,fill:n,stroke:r.bg,strokeWidth:2},e.id)}),g.map(e=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`path`,{d:`M${e.x0} ${e.y-4} V${e.y} H${e.x1} V${e.y-4}`,fill:`none`,stroke:o,strokeWidth:1.2}),(0,D.jsx)(`text`,{x:(e.x0+e.x1)/2,y:e.y+13,textAnchor:`middle`,fontSize:11,fill:o,children:nb(e.run)})]},`r${e.run}`)),(0,D.jsx)(`line`,{x1:c,x2:s,y1:u,y2:u,stroke:r.axis,strokeWidth:1.5}),p.map((e,t)=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`line`,{x1:e.x,x2:e.x,y1:u,y2:u+5,stroke:r.axis}),(0,D.jsx)(`text`,{x:e.x,y:u+17,textAnchor:`middle`,fontSize:10.5,fill:o,children:e.label})]},`t${t}`))]}),d.map(e=>(0,D.jsxs)(`div`,{className:`antu-sc-lane g${e.groupIndex}`,style:{bottom:`calc(100% - ${e.lineY+8}px)`,width:c-20},children:[(0,D.jsx)(`i`,{}),(0,D.jsxs)(`span`,{children:[e.side?(0,D.jsx)(`em`,{className:`antu-sc-lane-side`,children:e.side}):null,e.other?d.length>1?t(`scale.other`):t(`scale.events`):e.label]})]},e.key)),f.map(e=>(0,D.jsx)(`div`,{className:`antu-sc-seg`,style:{left:e.x0,width:e.x1-e.x0,top:u+24},children:t(`scale.segment`,{n:e.index+1,unit:t(`scale.unit.${e.unit}`),count:e.count})},`c${e.index}`)),f.filter(e=>e.breakBefore?.gap).map(e=>(0,D.jsx)(`div`,{className:`antu-sc-break`,style:{left:e.breakBefore.x,width:e.breakBefore.w,top:l/2-10},children:t(e.breakBefore.gap.key,e.breakBefore.gap.vars)},`g${e.index}`))]})}),Gre=(0,E.memo)(function({data:e}){let{event:t,undated:n,titleLines:r,timeLines:i=1,cardH:a,actorNames:o=[],sources:s=[]}=e,{hoveredId:c,pinnedId:l,pin:u,unpin:d}=(0,E.useContext)(Py),{t:f,lang:p}=sv(),m=l===t.id,h=!l&&c===t.id,g=m||h;return(0,D.jsxs)(`div`,{className:`antu-sc-card${n?` is-undated`:``}`,style:{height:a},role:`button`,tabIndex:0,"aria-label":f(`card.ariaLabel`,{label:t.label,date:t.date||``}),"aria-expanded":g,onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),m?d():u(t.id)):e.key===`Escape`&&d()},children:[(0,D.jsx)(`div`,{className:`antu-sc-title`,style:{WebkitLineClamp:r,lineClamp:r},children:t.label}),i===2&&!n?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`antu-sc-time`,children:[Qe(t.date,t.approx,p),` -`]}),(0,D.jsx)(`div`,{className:`antu-sc-time`,children:$e(t.date,t.dateEnd,p)})]}):(0,D.jsx)(`div`,{className:`antu-sc-time${i===2?` is-wrap`:``}`,children:n?f(`scale.undated`):et(t,p)}),g&&(0,D.jsx)(Fy,{event:t,actorNames:o,sources:s,isPinned:m,showPreview:h,placement:`below`,onClose:d})]})});function Kre(e,t){let n=e.filter(e=>typeof e.date==`string`&&e.date).map(e=>e.date).sort();if(!n.length)return``;let r=Qe(n[0],!1,t),i=Qe(n[n.length-1],!1,t);return r===i?r:n[0].slice(0,10)===n[n.length-1].slice(0,10)&&r.includes(` `)&&i.includes(` `)?`${r}–${i.split(` `).pop()}`:`${r}–${i}`}var rb=(0,E.memo)(function({id:e,data:t}){let{run:n,events:r,cardH:i}=t,{pinnedId:a,unpin:o}=(0,E.useContext)(Py),{t:s,lang:c}=sv(),l=a===e;return(0,D.jsxs)(`div`,{className:`antu-sc-card antu-sc-run`,style:{height:i},role:`button`,tabIndex:0,"aria-expanded":l,children:[(0,D.jsxs)(`div`,{className:`antu-sc-title`,style:{WebkitLineClamp:1,lineClamp:1},children:[nb(n),` `,s(`scale.run`,{n:r.length})]}),(0,D.jsx)(`div`,{className:`antu-sc-time`,children:Kre(r,c)}),l&&(0,D.jsxs)(`div`,{className:`antu-preview pinned below nowheel nopan`,children:[(0,D.jsx)(`button`,{className:`antu-preview-close`,title:s(`common.close`),onClick:e=>{e.stopPropagation(),o()},children:`×`}),(0,D.jsxs)(`div`,{className:`antu-preview-title`,children:[nb(n),` `,s(`scale.run`,{n:r.length})]}),r.map(e=>(0,D.jsxs)(`div`,{className:`antu-sc-run-row`,children:[(0,D.jsx)(`span`,{className:`antu-sc-run-time`,children:et(e,c)}),(0,D.jsx)(`span`,{children:e.label})]},e.id))]})]})}),qre=(0,E.memo)(function({data:e}){let{t,lang:n}=sv();return(0,D.jsx)(`div`,{className:`antu-sc-list`,style:{width:e.width,"--antu-sc-list-lh":`${e.lh}px`},children:e.runs.map(e=>(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`antu-sc-list-head`,children:[nb(e.run),` `,t(`scale.runListed`,{n:e.events.length})]}),e.events.map(e=>(0,D.jsxs)(`div`,{className:`antu-sc-list-row`,children:[(0,D.jsx)(`span`,{className:`antu-sc-run-time`,children:et(e,n)}),(0,D.jsx)(`span`,{children:e.label})]},e.id))]},e.run))})});function Jre({byParty:e=!1,onToggleByParty:t,exporting:n=!1,onExport:r}){let{t:i}=sv();return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[t&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{"data-chip":`byParty`,className:`antu-dock-chip${e?` is-on`:``}`,onClick:()=>t(!e),children:i(`dock.byParty`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`})]}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:n,onExport:r})]})})}var ib={scaleLayer:Wre,scaleCard:Gre,scaleRun:rb,scaleRunList:qre};function Yre(e){if(typeof document>`u`)return null;let t=document.createElement(`canvas`).getContext?.(`2d`);if(!t)return null;let n=`600 ${Mt}px ${getComputedStyle(e?.querySelector?.(`.antu-app`)||document.body).fontFamily}`,r=new Map;return e=>{let i=r.get(e);return i===void 0&&(t.font=n,i=t.measureText(e).width,r.set(e,i)),i}}function Xre({spec:e}){let{root:t}=tv(),n=(0,E.useMemo)(()=>Yre(t),[t]),r=rv(),i=nv(),a=e?.title||``,o=(0,E.useMemo)(()=>{let t=Array.isArray(e?.actors)?e.actors:[];if(t.length<2)return!1;let n=new Map;for(let e of t)e?.groupId&&n.set(e.groupId,(n.get(e.groupId)??0)+1);return[...n.values()].some(e=>e>=2)},[e]),[s,c]=(0,E.useState)(()=>i.read().scaleByParty||{}),l=o&&(r?.byParty??s[a]??!1),u=e=>{let t={...s,[a]:e};c(t),i.write({scaleByParty:t})},d=(0,E.useMemo)(()=>tn(e,{},{measure:n,byParty:l}),[e,n,l]),[f,p]=(0,E.useState)(null),[m,h]=(0,E.useState)(null);Jy(e,m,h);let{canvasRef:g,exporting:_,onExport:v}=Ny(e?.title),y=(0,E.useMemo)(()=>({hoveredId:f,pinnedId:m,pin:e=>h(e),unpin:()=>h(null)}),[f,m]),b=e=>e.type===`scaleCard`||e.type===`scaleRun`;return(0,D.jsx)(`div`,{className:`antu-fact antu-sc`,children:(0,D.jsx)(Py.Provider,{value:y,children:(0,D.jsx)(My,{ref:g,graph:d,nodeTypes:ib,style:{"--antu-sc-pad-x":`10px`,"--antu-sc-pad-y":`8px`,"--antu-sc-title-font":`${Mt}px`,"--antu-sc-title-lh":`17px`,"--antu-sc-time-font":`11px`,"--antu-sc-time-lh":`15px`},onNodeMouseEnter:(e,t)=>{t.type===`scaleCard`&&p(t.id)},onNodeMouseLeave:(e,t)=>p(e=>e===t.id?null:e),onNodeClick:(e,t)=>{b(t)&&h(t.id)},onPaneClick:()=>h(null),children:(0,D.jsx)(Jre,{byParty:l,onToggleByParty:o?u:null,exporting:_,onExport:v})})})})}v(`fact`,`scale`,Xre,`graphKind.scale`);function ab(e,t,n){let r=n.flow;return e===`note`?{...r.note,width:1}:e===`start`&&(t??`neutral`)===`neutral`?{...r.outcome.neutral,...r.start}:r.outcome[t]??r.outcome.neutral}var Zre=(e,t)=>t?e.flow.stageLit:e.flow.stage;function Qre(e,t,n){let r=n.flow.link,i=e===`back`?r.back:e===`main`&&t?r.main:r.plain;return{stroke:i.stroke,width:i.width,dash:i.dash}}var ob=1;function $re({kind:e,outcome:t,w:n,h:r,theme:i}){let a=ab(e,t,i),o={fill:a.fill,stroke:a.stroke,strokeWidth:a.width??1.1,...a.dash?{strokeDasharray:a.dash}:{}},s={fill:`none`,stroke:a.stroke,strokeWidth:1},c=ob,l=ob,u=n-2,d=r-2;switch(e){case`start`:return(0,D.jsx)(`rect`,{className:`antu-pn-shape`,...o,x:c,y:l,width:u,height:d,rx:d/2});case`end`:return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`rect`,{className:`antu-pn-shape`,...o,x:c,y:l,width:u,height:d,rx:d/2}),(0,D.jsx)(`rect`,{className:`antu-pn-ring`,...s,x:5,y:5,width:u-8,height:d-8,rx:(d-8)/2})]});case`decision`:return(0,D.jsx)(`polygon`,{className:`antu-pn-shape`,...o,points:`${n/2},${l} ${n-ob},${r/2} ${n/2},${r-ob} ${c},${r/2}`});case`document`:{let e=l+d-7;return(0,D.jsx)(`path`,{className:`antu-pn-shape`,...o,d:`M ${c} 7 Q ${c} ${l} 7 ${l} L ${c+u-6} ${l} Q ${c+u} ${l} ${c+u} 7 L ${c+u} ${e} C ${c+u*.75} ${e-7*1.6} ${c+u*.5} ${e-7*.2} ${c+u*.5} ${e+7*.4} S ${c+u*.2} ${e+12.6} ${c} ${e} Z`})}case`note`:return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`path`,{className:`antu-pn-shape`,...o,d:`M ${c} ${l} L ${c+u-14} ${l} L ${c+u} 15 L ${c+u} ${l+d} L ${c} ${l+d} Z`}),(0,D.jsx)(`path`,{className:`antu-pn-fold`,fill:`none`,stroke:a.fold,strokeWidth:1,d:`M ${c+u-14} ${l} L ${c+u-14} 15 L ${c+u} 15`})]});default:return(0,D.jsx)(`rect`,{className:`antu-pn-shape`,...o,x:c,y:l,width:u,height:d,rx:6})}}var eie=(0,E.memo)(function({id:e,data:t}){let{node:n,w:r,h:i,textW:a,ruleCount:o=0,lit:s=!1,isSpine:c,stageLabel:l,actorNames:u,sources:d,showDetail:f,vertical:p,layer:m}=t,{hoveredId:h,pinnedId:g,pin:_,unpin:v}=(0,E.useContext)(Py),{t:y,lang:b}=sv(),{theme:x}=xv(),S=g===e,C=!g&&h===e,w=S||C,T=n.kind,ee=n.outcome||`neutral`,te=f&&n.detail?String(n.detail).split(`
|
|
1491
|
+
`)}async function xy(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await by(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function vre(e,t={}){let{width:n,height:r}=ire(e,t),i=await $v(e,t,!0);return await xy(i,t),await ly(i,t),uy(i,t),await sre(i,n,r)}async function Sy(e,t={}){let{width:n,height:r}=ire(e,t),i=await kv(await vre(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||Dv(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||are(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}var yre=2,Cy=`is-exporting`;function bre(e,t,n=24){return{width:e+n*2,height:t+n*2,offsetX:n,offsetY:n}}function xre(e){return`${String(e||`antu`).replace(/[\\/:*?"<>|\s]+/g,`-`).slice(0,60)||`antu`}.png`}function Sre(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}function Cre(e){return new Promise((t,n)=>{e.toBlob(e=>{e?t(e):n(Error(`the rendered image could not be encoded as PNG`))},`image/png`)})}async function wy({rootEl:e,graph:t,title:n}){let{blob:r,width:i,height:a}=await j({rootEl:e,graph:t});return Sre(r,xre(n)),{width:i,height:a}}async function j({rootEl:e,graph:t,pixelRatio:n=yre}){let r=e?.querySelector(`.react-flow__viewport`);if(!r)throw Error(`canvas content layer not found; cannot export`);let{width:i,height:a}=t.size,o=bre(i,a),s=e.closest(`.antu-app`)||document.body;s.classList.add(Cy);try{let e=await Sy(r,{width:i,height:a,pixelRatio:n,backgroundColor:`#ffffff`,style:{width:`${i}px`,height:`${a}px`,transform:`translate(0px, 0px) scale(1)`}}),t=document.createElement(`canvas`);t.width=Math.round(o.width*n),t.height=Math.round(o.height*n);let s=t.getContext(`2d`);return s.fillStyle=`#ffffff`,s.fillRect(0,0,t.width,t.height),s.drawImage(e,Math.round(o.offsetX*n),Math.round(o.offsetY*n)),{blob:await Cre(t),width:t.width,height:t.height}}finally{s.classList.remove(Cy)}}var wre=3,Tre=[`@`,`~`];function Ty(e,t){if(!e||typeof e!=`object`||t==null)return null;let n=String(t),r=n.startsWith(`rule:`),i=r?n.slice(5):n,a=Ey(e,i,r),o=Math.max(...Tre.map(e=>i.lastIndexOf(e)));return a||o<=0?a:Ey(e,i.slice(0,o),r)}function Ey(e,t,n){let r=[e];for(let e=0;e<wre&&r.length;e++){let e=[];for(let i of r)for(let[r,a]of Object.entries(i))if(Array.isArray(a)&&r!==`sources`){for(let i of a)if(i&&typeof i==`object`&&!Array.isArray(i)){if(i.id===t&&(!n||r===`rules`))return{collection:r,item:i};e.push(i)}}r=e}return null}function Ere(e,t){let n=Array.isArray(t?.sourceIds)?t.sourceIds:[],r=Array.isArray(e?.sources)?e.sources:[];return n.map(e=>r.find(t=>t?.id===e)).filter(Boolean)}function Dre(e,t){if(t==null)return{type:`select`,id:null,collection:null,sourceIds:[],sources:[]};let n=Ty(e,t);if(!n)return{type:`select`,id:String(t),collection:null,sourceIds:[],sources:[]};let{collection:r,item:i}=n;return{type:`select`,id:i.id,collection:r,sourceIds:Array.isArray(i.sourceIds)?[...i.sourceIds]:[],sources:Ere(e,i)}}var Ore=new Set([`pnode`,`card`,`entry`,`scaleCard`,`rnode`,`jnode`]);function Dy(e,t,n){if(n==null)return[];let r=Ty(e,String(n));if(!r||r.item.id!==String(n))return[];let i=(t??[]).filter(t=>Ty(e,t.id)?.item===r.item).map(e=>e.id);return r.collection===`rules`&&i.push(`rule:${r.item.id}`),i}function Oy(e,t,n){let r=Dy(e,t,n),i=r.find(e=>e.startsWith(`rule:`));if(i)return i;let a=new Map((t??[]).map(e=>[e.id,e.type]));return r.find(e=>Ore.has(a.get(e)))??null}function kre({width:e,natural:t,zoomRight:n=null,minimapWidth:r=null}){let i=n==null?15:n+12,a=t=>t?e-15-r-12:e-15,o=n=>Math.min(Math.max(e/2-t/2,i),n-t);if(r!=null&&t<=a(!0)-i)return{left:o(a(!0)),maxWidth:null,hideMinimap:!1};let s=r!=null,c=a(!1);return t<=c-i?{left:o(c),maxWidth:null,hideMinimap:s}:{left:i,maxWidth:Math.max(c-i,0),hideMinimap:s}}var ky=202;function Are(e){let t=(e,t)=>t.reduce((t,n)=>t+(parseFloat(e[n])||0),0),n=getComputedStyle(e),r=[...e.children].filter(e=>getComputedStyle(e).position!==`absolute`),i=parseFloat(n.columnGap)||0,a=r.reduce((e,n)=>e+n.getBoundingClientRect().width+t(getComputedStyle(n),[`marginLeft`,`marginRight`]),0);return Math.ceil(a+i*Math.max(r.length-1,0)+t(n,[`paddingLeft`,`paddingRight`,`borderLeftWidth`,`borderRightWidth`]))}var Ay=3,jre=160,Mre=()=>null,jy=`__minimap__`,Nre=({width:e,height:t})=>({id:jy,type:`miniGhost`,position:{x:0,y:0},width:Math.max(1,e),height:Math.max(1,t),draggable:!1,selectable:!1,connectable:!1,focusable:!1,data:{},style:{pointerEvents:`none`,visibility:`hidden`}}),Pre=e=>e.id===jy?`#eef1f5`:`#cbd5e1`,Fre=e=>e.startsWith(`rule:`)?`[data-pin-id="${CSS.escape(e)}"]`:`.react-flow__node[data-id="${CSS.escape(e)}"]`;function My({ref:e,graph:t,fitKey:n,fitWidth:r=!1,fitSelf:i=!1,fitMinZoom:a=0,fitMaxZoom:o=0,nodeTypes:s,showGrid:c=!1,style:l,children:u,onNodeMouseEnter:d,onNodeMouseLeave:f,onNodeClick:p,onPaneClick:m}){let{ariaLabels:h}=sv(),g=(0,E.useMemo)(()=>({...s,miniGhost:Mre}),[s]),{theme:_}=xv(),[v,y,b]=One([Nre(t.size),...t.nodes]),[x,S,C]=A_(t.edges);(0,E.useEffect)(()=>{y(e=>{let n=new Map(e.map(e=>[e.id,e]));return[Nre(t.size),...t.nodes].map(e=>{let t=n.get(e.id);if(!t)return e;let r=e;return t.measured&&t.type===e.type&&(r={...r,measured:t.measured}),t.selected?{...r,selected:!0}:r})}),S(t.edges)},[t,y,S]);let w=(0,E.useRef)(null),T=(0,E.useRef)(!1),ee=(e=300)=>{let{width:n,height:i}=t.size;if(!w.current)return;T.current=!0;let s=oe.current;if(r&&n&&i&&s?.clientWidth&&s?.clientHeight){let r={width:s.clientWidth,height:s.clientHeight},a=an(t.size,r),o=r.height*nn/4,c=i*a+o*2<=r.height?(r.height-i*a)/2:o;w.current.setViewport({x:(r.width-n*a)/2,y:c,zoom:a},{duration:e});return}if(a&&n&&i&&s?.clientWidth&&s?.clientHeight){let n={width:s.clientWidth,height:s.clientHeight};if(rn(t.size,n)<a){let t=a,r=n.width*nn/4,o=i*t+16<=n.height?(n.height-i*t)/2:n.height*nn/4;w.current.setViewport({x:r,y:o,zoom:t},{duration:e});return}}if(o&&n&&i&&s?.clientWidth&&s?.clientHeight){let t={width:s.clientWidth,height:s.clientHeight};if(Math.min(t.width/(n*1.12),t.height/(i*1.12))>o){let r=o;w.current.setViewport({x:(t.width-n*r)/2,y:(t.height-i*r)/2,zoom:r},{duration:e});return}}n&&i?w.current.fitBounds({x:0,y:0,width:n,height:i},{padding:nn,duration:e}):w.current.fitView({padding:nn,duration:e})},te=(0,E.useRef)(!0),{drawn:ne}=tv(),[re,ie]=(0,E.useState)(!1);(0,E.useEffect)(()=>{let e=requestAnimationFrame(()=>{let e=te.current;ee(e?0:300),te.current=!1,e&&(ne(),ie(!0))});return()=>cancelAnimationFrame(e)},[n??t]);let ae=(0,E.useMemo)(()=>[[-160,-160],[t.size.width+jre,t.size.height+jre]],[t]),oe=(0,E.useRef)(null),[se,ce]=(0,E.useState)({width:0,height:0});(0,E.useEffect)(()=>{let e=oe.current;if(!e)return;let t=new ResizeObserver(([e])=>{let{width:t,height:n}=e.contentRect;ce({width:t,height:n})});return t.observe(e),()=>t.disconnect()},[]);let le=(0,E.useMemo)(()=>{let{width:e,height:n}=se;return!e||!n?.1:Math.max(rn(t.size,{width:e,height:n}),.05)},[se,t]);(0,E.useImperativeHandle)(e,()=>({exportPng:({title:e}={})=>wy({rootEl:oe.current,graph:t,title:e})}),[t]);let{commands:ue}=tv(),de=(0,E.useRef)(ee);de.current=ee,(0,E.useEffect)(()=>{let e=ue.on(`fitView`,()=>de.current(300)),n=ue.on(`exportPng`,({pixelRatio:e}={})=>j({rootEl:oe.current,graph:t,pixelRatio:e}));return()=>{e(),n()}},[ue,t]);let fe=(0,E.useContext)(ev),{highlight:pe}=tv(),me=(0,E.useRef)(null);me.current={spec:fe,graph:t,minZoom:le},(0,E.useEffect)(()=>{if(!re)return;let e=e=>oe.current?.querySelector(Fre(e)),t=e=>y(t=>t.map(t=>!!t.selected==(t.id===e)?t:{...t,selected:t.id===e})),n=ue.on(`select`,n=>{if(!ue.has(`pin`))return!1;if(n===null)return ue.run(`pin`,null),t(null),!0;let{spec:r,graph:i}=me.current,a=Oy(r,i.nodes,n);return!a||!e(a)?!1:(ue.run(`pin`,a),t(a),!0)}),r=ue.on(`focus`,t=>{let{spec:n,graph:r,minZoom:i}=me.current,a=Dy(n,r.nodes,t).map(e).find(Boolean),o=w.current,s=oe.current?.getBoundingClientRect();if(!a||!o||!s?.width)return!1;let c=a.getBoundingClientRect(),l=o.getZoom(),u=o.screenToFlowPosition({x:c.left+c.width/2,y:c.top+c.height/2}),d=Math.min(s.width*.9*l/c.width,s.height*.9*l/c.height);return o.setCenter(u.x,u.y,{zoom:Math.max(Math.min(l,d),i),duration:300}),!0});return()=>{n(),r()}},[re,ue,y]);let he=(0,E.useSyncExternalStore)(pe.subscribe,pe.get),ge=(0,E.useMemo)(()=>{let e=he.flatMap(e=>Dy(fe,t.nodes,e)).map(Fre);return e.length?`.antu-app:not(.${Cy}) :is(${e.join(`, `)}) { outline: 3px solid var(--antu-side1); outline-offset: 4px; }`:``},[he,fe,t]),_e=iv(`zoom`),ve=iv(`minimap`),ye=iv(`capsule`),[be,xe]=(0,E.useState)({left:null,maxWidth:null,hideMinimap:!1}),Se=(0,E.useRef)(ky);(0,E.useLayoutEffect)(()=>{let e=oe.current;if(!e||!ye)return;let t=()=>{let t=e.querySelector(`.antu-dock-capsule .antu-dock-bar`);if(!t||!e.clientWidth)return;let n=e.getBoundingClientRect(),r=_e?e.querySelector(`.react-flow__controls`):null,i=e.querySelector(`.react-flow__minimap`);i?.offsetWidth&&(Se.current=i.offsetWidth);let a=kre({width:e.clientWidth,natural:Are(t),zoomRight:r?r.getBoundingClientRect().right-n.left:null,minimapWidth:ve?Se.current:null});xe(e=>e.left===a.left&&e.maxWidth===a.maxWidth&&e.hideMinimap===a.hideMinimap?e:a)};t();let n=new ResizeObserver(t);n.observe(e);let r=e.querySelector(`.antu-dock-capsule .antu-dock-bar`);return r&&n.observe(r),()=>n.disconnect()},[ye,_e,ve]);let Ce=be.left==null?void 0:{left:be.left,marginLeft:0,transform:`none`,...be.maxWidth==null?{}:{"--antu-dock-max":`${be.maxWidth}px`}};return(0,E.useEffect)(()=>{let e=oe.current?.querySelector(`.react-flow__viewport`);if(e)for(let[t,n]of Object.entries($ne(_)))e.style.setProperty(t,n)},[_,t]),(0,D.jsxs)(`main`,{className:`antu-canvas${c?` show-grid`:``}`,ref:oe,style:l,children:[ge&&(0,D.jsx)(`style`,{children:ge}),(0,D.jsxs)(Dne,{nodes:v,edges:x,onNodesChange:b,onEdgesChange:C,nodeTypes:g,ariaLabelConfig:h,nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,panOnScroll:!0,panOnScrollMode:`free`,panOnScrollSpeed:1,zoomOnScroll:!1,zoomOnPinch:!0,panOnDrag:!0,translateExtent:ae,onInit:e=>{w.current=e,T.current||requestAnimationFrame(()=>ee(0))},onNodeMouseEnter:d,onNodeMouseLeave:f,onNodeClick:p,onPaneClick:m,fitView:!r&&!i,fitViewOptions:{padding:nn,...o?{maxZoom:o}:{}},minZoom:le,maxZoom:Ay,children:[(0,D.jsx)(N_,{gap:20,color:`#e8ebef`}),_e&&(0,D.jsx)(Lne,{showInteractive:!1,onFitView:()=>ee(300)}),ye&&(0,D.jsx)(tg,{position:`bottom-center`,className:`antu-dock-capsule${be.maxWidth==null?``:` is-wrapped`}`,style:Ce,children:u}),ve&&!be.hideMinimap&&(0,D.jsx)(K_,{pannable:!0,zoomable:!0,nodeColor:Pre})]})]})}function Ny(e){let{t}=sv(),n=(0,E.useRef)(null),r=(0,E.useRef)(!1),[i,a]=(0,E.useState)(!1);return{canvasRef:n,exporting:i,onExport:async()=>{if(!r.current){r.current=!0,a(!0);try{await n.current?.exportPng({title:e})}catch(e){console.error(`[antu] export failed:`,e),window.alert(t(`export.failed`,{message:e.message}))}finally{r.current=!1,a(!1)}}}}}var Py=(0,E.createContext)({hoveredId:null,pinnedId:null,pin:()=>{},unpin:()=>{},focusOn:null});function Fy({event:e,actorNames:t,sources:n,isPinned:r,showPreview:i,placement:a,onClose:o}){let{t:s,lang:c}=sv(),l=e.date&&e.dateEnd?tt(e.date,e.dateEnd,s):``;return(0,D.jsxs)(`div`,{className:[`antu-preview`,`nowheel`,`nopan`,a,r?`pinned`:``].filter(Boolean).join(` `),children:[r&&(0,D.jsx)(`button`,{className:`antu-preview-close`,title:s(`common.close`),onClick:e=>{e.stopPropagation(),o()},children:`×`}),r&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`antu-preview-time`,children:et(e,c)}),l&&(0,D.jsx)(`div`,{className:`antu-preview-duration`,children:s(`card.duration`,{duration:l})}),(0,D.jsx)(`div`,{className:`antu-preview-title`,children:e.label}),t.length>0&&(0,D.jsx)(`div`,{className:`antu-preview-actors`,children:t.map(e=>(0,D.jsx)(`span`,{className:`antu-actor-tag`,children:e},e))})]}),e.detail&&(0,D.jsx)(`div`,{className:`antu-preview-text`,children:e.detail}),r&&e.dateNote&&(0,D.jsx)(`div`,{className:`antu-preview-note`,children:s(`card.dateNote`,{note:e.dateNote})}),r&&n.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`antu-preview-sub`,children:s(`card.sources`,{n:n.length})}),n.map(e=>(0,D.jsxs)(`div`,{className:`antu-source`,children:[(0,D.jsxs)(`div`,{className:`antu-source-name`,children:[e.name,(0,D.jsx)(`span`,{className:`antu-source-type`,children:ji(ki,e.type,c)})]}),e.quote&&(0,D.jsx)(`div`,{className:`antu-source-quote`,children:e.quote})]},e.id))]}),!r&&(0,D.jsx)(`div`,{className:`antu-preview-src${n.length?``:` is-none`}`,children:n.length?s(`card.sourcesList`,{n:n.length,names:n.map(e=>e.name).join(` · `)}):s(`card.sourcesUnlisted`)}),i&&(0,D.jsx)(`div`,{className:`antu-preview-hint`,children:s(`card.previewHint`)})]})}var Ire=(0,E.memo)(function({data:e}){let{event:t,actorNames:n,sources:r,groupIndex:i,row:a,cardW:o,cardH:s,labelLines:c,fields:l={},isH:u}=e,{hoveredId:d,pinnedId:f,pin:p,unpin:m}=(0,E.useContext)(Py),{t:h,lang:g}=sv(),_=f===t.id,v=!f&&d===t.id,y=_||v;return(0,D.jsxs)(`div`,{className:`antu-card g${i}`,style:{width:o,height:s},role:`button`,tabIndex:0,"aria-label":h(`card.ariaLabel`,{label:t.label,date:t.date||``}),"aria-expanded":y,onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),_?m():p(t.id)):e.key===`Escape`&&m()},children:[(0,D.jsx)(`div`,{className:`antu-card-label`,style:{WebkitLineClamp:c,lineClamp:c},children:t.label}),l.summary&&t.summary&&(0,D.jsx)(`div`,{className:`antu-card-snippet`,children:t.summary}),l.actors&&n.length>0&&(0,D.jsx)(`div`,{className:`antu-card-actors`,children:n.map(e=>(0,D.jsx)(`span`,{className:`antu-actor-tag`,children:e},e))}),(0,D.jsxs)(`div`,{className:`antu-card-foot`,children:[(0,D.jsx)(`span`,{className:`antu-card-time${t.date?``:` is-unknown`}`,title:t.dateNote||``,children:et(t,g)}),l.sources&&(0,D.jsxs)(`span`,{className:`antu-card-src${r.length?``:` is-none`}`,children:[(0,D.jsx)(`i`,{className:`antu-src-dot`}),r.length?h(`card.sources`,{n:r.length}):h(`card.sourcesUnlisted`)]})]}),y&&(0,D.jsx)(Fy,{event:t,actorNames:n,sources:r,isPinned:_,showPreview:v,placement:u?a===0?`right`:`left`:a===0?`below`:`above`,onClose:m})]})}),Lre=[[`en`,`dock.langEn`],[`zh`,`dock.langZh`]];function Iy({options:e,value:t,onChange:n,title:r}){let{t:i}=sv();return(0,D.jsx)(`div`,{className:`antu-dock-seg`,title:r,children:e.map(([e,r])=>(0,D.jsx)(`button`,{className:`antu-dock-seg-item${t===e?` is-on`:``}`,onClick:()=>n(e),children:i(r)},e))})}function Ly(){let{t:e,lang:t,setLang:n}=sv();return(0,D.jsx)(Iy,{options:Lre,value:t,onChange:n,title:e(`dock.lang`)})}function Ry({exporting:e=!1,onExport:t}){let{t:n}=sv();return(0,D.jsxs)(`button`,{className:`antu-dock-action`,onClick:t,disabled:e,title:n(`dock.exportTitle`),children:[(0,D.jsx)(`svg`,{className:`antu-dock-action-icon`,viewBox:`0 0 16 16`,width:`13`,height:`13`,fill:`none`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`M8 1.8v7.4M4.8 6.2 8 9.4l3.2-3.2M2.4 12.6h11.2`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})}),n(e?`dock.exporting`:`dock.exportImage`)]})}var zy=[`sources`,`actors`,`summary`],By={sources:`dock.sources`,actors:`dock.actors`,summary:`dock.summary`},Vy=[[`vertical`,`dock.vertical`],[`horizontal`,`dock.horizontal`]];function Hy({fields:e={},onToggleField:t,orientation:n=`vertical`,onToggleOrientation:r,showGrid:i=!1,onToggleGrid:a,stagger:o=!1,onToggleStagger:s,exporting:c=!1,onExport:l}){let{t:u}=sv();return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[zy.map(n=>(0,D.jsx)(`button`,{className:`antu-dock-chip${e[n]?` is-on`:``}`,onClick:()=>t(n,!e[n]),children:u(By[n])},n)),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Iy,{options:Vy,value:n,onChange:r}),s&&n===`vertical`&&(0,D.jsx)(`button`,{className:`antu-dock-chip${o?` is-on`:``}`,"data-chip":`stagger`,"aria-pressed":o,title:u(`dock.staggerHint`),onClick:()=>s(!o),children:u(`dock.stagger`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),!(o&&n===`vertical`)&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{className:`antu-dock-chip${i?` is-on`:``}`,"data-chip":`grid`,onClick:()=>a(!i),children:u(`dock.grid`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`})]}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:c,onExport:l})]})})}var Uy=(0,E.memo)(function({data:e}){let{width:t,height:n,isH:r,groupIndex:i,sideTitle:a,colTitle:o,actors:s,laneWs:c=[]}=e;return(0,D.jsxs)(`div`,{className:`antu-colhead g${i}${r?` is-h`:``}${s?` is-span`:``}`,style:{width:t,height:n||void 0},children:[a&&(0,D.jsx)(`div`,{className:`antu-colhead-side`,children:a}),s&&(0,D.jsx)(`div`,{className:`antu-colhead-actors`,children:s.map((e,t)=>(0,D.jsx)(`div`,{className:`antu-colhead-actor`,style:{width:c[t]},children:e},t))}),o&&(0,D.jsx)(`div`,{className:`antu-colhead-actor`,children:o})]})}),Wy=(0,E.memo)(function({data:e}){let{isH:t,length:n,dotOffsets:r,dotSize:i}=e;return(0,D.jsxs)(`div`,{className:`antu-axis-wrap${t?` is-h`:``}`,style:t?{width:n}:{height:n},children:[(0,D.jsx)(`div`,{className:`antu-axis-line`,style:t?{width:n}:{height:n},children:t?(0,D.jsx)(`svg`,{className:`antu-axis-arrow`,width:`6`,height:`10`,viewBox:`0 0 6 10`,"aria-hidden":`true`,children:(0,D.jsx)(`polygon`,{points:`0,0 6,5 0,10`,fill:`currentColor`})}):(0,D.jsx)(`svg`,{className:`antu-axis-arrow`,width:`10`,height:`6`,viewBox:`0 0 10 6`,"aria-hidden":`true`,children:(0,D.jsx)(`polygon`,{points:`0,0 10,0 5,6`,fill:`currentColor`})})}),r.map((e,n)=>(0,D.jsx)(`span`,{className:`antu-axis-dot`,style:t?{left:e,top:-4,width:i,height:i}:{top:e,left:-4,width:i,height:i}},n))]})}),Gy=(0,E.memo)(function({data:e}){let{segments:t,isH:n}=e;return(0,D.jsx)(`div`,{className:`antu-link-layer`,children:t.map((e,t)=>(0,D.jsx)(`span`,{className:`antu-link${n?` is-h`:``}`,style:{left:e.left,top:e.top,width:e.width,height:e.height}},t))})}),Ky=1,qy=(0,E.memo)(function({data:e}){let{rows:t,cellW:n,cellH:r,originX:i,originY:a,isH:o,lanes:s=[]}=e,c=1/(Xh(e=>e.transform[2])||1),l=.8*c,u=o?r:n,d=Ky*u,f=[...Array.from({length:Ky},(e,t)=>({start:t*u,size:u})),...s.map(e=>({start:d+e.start,size:e.size}))],p=d+(s.length?s[s.length-1].start+s[s.length-1].size:0);for(let e=0;e<Ky;e+=1)f.push({start:p+e*u,size:u});let m=p+Ky*u,h=o?i+t*n:m,g=o?m:a+t*r,_=[];for(let e=0;e<t;e+=1)f.forEach((t,s)=>{let u=(o?i+e*n:t.start)+l/2,d=(o?t.start:a+e*r)+l/2;_.push((0,D.jsx)(`rect`,{className:`antu-cell`,x:u,y:d,width:(o?n:t.size)-l,height:(o?t.size:r)-l,strokeWidth:l,strokeDasharray:`${11*c} ${7*c}`},`${e}-${s}`))});return(0,D.jsx)(`svg`,{className:`antu-cells`,style:{left:o?0:-d,top:o?-d:0,width:h,height:g},children:_})});function Jy(e,t,n){let{embedded:r,emit:i,commands:a}=tv(),o=(0,E.useRef)(null);(0,E.useEffect)(()=>{r&&o.current!==t&&(o.current=t,i(Dre(e,t)))},[r,i,e,t]),(0,E.useEffect)(()=>{if(n)return a.on(`pin`,e=>n(e))},[a,n])}var Rre={card:Ire,colHeader:Uy,axis:Wy,links:Gy,cells:qy},Yy={sources:!1,actors:!1,summary:!0};function Xy({spec:e}){let t=rv(),n=nv(),r=e?.title||``,[i,a]=(0,E.useState)(()=>({...Yy,...n.read().fields,...t?.fields||{}})),o=(e,t)=>{a(n=>({...n,[e]:t})),n.write({fields:{...n.read().fields,[e]:t}})},[s,c]=(0,E.useState)(()=>n.read().showGrid===!0),l=e=>{c(e),n.write({showGrid:e})},[u,d]=(0,E.useState)(()=>n.read().staggers||{}),f=t?.stagger??u[r]??!0,p=e=>{let t={...u,[r]:e};d(t),n.write({staggers:t})},[m,h]=(0,E.useState)(()=>n.read().orientations||{}),g=Array.isArray(e?.slots)?e.slots.length:0,_=t?.orientation||m[r]||(g>=5?`vertical`:`horizontal`),v=e=>{let t={...m,[r]:e};h(t),n.write({orientations:t})},y=(0,E.useMemo)(()=>Ze(e,i,void 0,_,{stagger:f}),[e,i,_,f]),[b,x]=(0,E.useState)(null),[S,C]=(0,E.useState)(null);Jy(e,S,C);let{canvasRef:w,exporting:T,onExport:ee}=Ny(e?.title),te=(0,E.useMemo)(()=>({hoveredId:b,pinnedId:S,pin:e=>C(e),unpin:()=>C(null)}),[b,S]);return(0,D.jsx)(`div`,{className:`antu-fact`,children:(0,D.jsx)(Py.Provider,{value:te,children:(0,D.jsx)(My,{ref:w,graph:y,nodeTypes:Rre,showGrid:s&&!y.staggered,style:{"--antu-card-pad-x":`13px`,"--antu-card-pad-y":`11px`,"--antu-label-font":`13px`,"--antu-snippet-font":`${ye}px`},onNodeMouseEnter:(e,t)=>{t.type===`card`&&x(t.id)},onNodeMouseLeave:(e,t)=>{x(e=>e===t.id?null:e)},onNodeClick:(e,t)=>{t.type===`card`&&C(t.id)},onPaneClick:()=>C(null),children:(0,D.jsx)(Hy,{fields:i,onToggleField:o,orientation:_,onToggleOrientation:v,showGrid:s,onToggleGrid:l,stagger:f,onToggleStagger:p,exporting:T,onExport:ee})})})})}v(`fact`,`timeline`,Xy,`graphKind.timeline`);var Zy=(0,E.memo)(function({data:e}){let{event:t,groupIndex:n,actorNames:r,sources:i,fields:a,cardH:o,sameDay:s,dim:c=!1}=e,{hoveredId:l,pinnedId:u,pin:d,unpin:f}=(0,E.useContext)(Py),{t:p,lang:m}=sv(),h=u===t.id,g=!u&&l===t.id,_=h||g;return(0,D.jsxs)(`div`,{className:`antu-chr-entry${c?` is-dim`:``}`,style:{height:o},"data-group":n,children:[(0,D.jsx)(`div`,{className:`antu-chr-when${t.date?``:` is-unknown`}`,style:{width:150},title:t.dateNote||``,children:nt(t,m,s).map((e,t)=>(0,D.jsx)(`div`,{className:e.strong?`is-date`:``,children:e.text},t))}),(0,D.jsxs)(`div`,{className:`antu-chr-card`,style:{left:198,width:560,height:o},role:`button`,tabIndex:0,"aria-label":p(`card.ariaLabel`,{label:t.label,date:t.date||``}),"aria-expanded":_,onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),h?f():d(t.id)):e.key===`Escape`&&f()},children:[(0,D.jsx)(`div`,{className:`antu-chr-title`,children:t.label}),a.summary&&t.summary&&(0,D.jsx)(`div`,{className:`antu-chr-summary`,children:t.summary}),(a.actors&&r.length>0||a.sources)&&(0,D.jsxs)(`div`,{className:`antu-chr-tags`,children:[a.actors&&r.map(e=>(0,D.jsx)(`span`,{className:`antu-actor-tag`,children:e},e)),a.sources&&(0,D.jsxs)(`span`,{className:`antu-card-src${i.length?``:` is-none`}`,children:[(0,D.jsx)(`i`,{className:`antu-src-dot`}),i.length?p(`card.sources`,{n:i.length}):p(`card.sourcesUnlisted`)]})]}),_&&(0,D.jsx)(Fy,{event:t,actorNames:r,sources:i,isPinned:h,showPreview:g,placement:`right`,onClose:f})]})]})}),Qy=(0,E.memo)(function({data:e}){let{x:t,top:n,bottom:r,dots:i,pills:a,breaks:o,dotSize:s}=e,{t:c}=sv(),l=[],u=n;for(let e of o)l.push({y0:u,y1:e.y0,dashed:!1}),l.push({y0:e.y0,y1:e.y1,dashed:!0}),u=e.y1;return l.push({y0:u,y1:r,dashed:!1}),(0,D.jsxs)(`div`,{className:`antu-chr-spine`,children:[l.filter(e=>e.y1>e.y0).map((e,n)=>(0,D.jsx)(`span`,{className:`antu-chr-line${e.dashed?` is-break`:``}`,style:{left:t-1.5,top:e.y0,height:e.y1-e.y0}},`s${n}`)),i.map((e,n)=>(0,D.jsx)(`span`,{className:`antu-chr-dot g${e.groupIndex} s-${e.shape}${e.hollow?` is-hollow`:``}${e.dim?` is-dim`:``}`,style:{left:t-s/2,top:e.y-s/2,width:s,height:s}},`d${n}`)),a.map((e,n)=>(0,D.jsx)(`span`,{className:`antu-chr-gap${e.gap.long?` is-long`:``}`,style:{left:t+12,top:e.y},children:(e.gap.approx?c(`card.approxPrefix`):``)+c(e.gap.key,e.gap.vars)},`p${n}`))]})}),zre=(0,E.memo)(function({data:e}){let{groups:t,active:n=null,onToggle:r}=e;return(0,D.jsx)(`div`,{className:`antu-chr-legend nodrag nopan`,children:t.map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`antu-chr-legend-item g${e.groupIndex}${n===e.groupIndex?` is-on`:``}${n!==null&&n!==e.groupIndex?` is-off`:``}`,"aria-pressed":n===e.groupIndex,onClick:()=>r?.(e.groupIndex),children:[(0,D.jsx)(`i`,{className:`antu-chr-mark s-${e.shape}`}),e.label]},e.groupIndex))})}),Bre=[`sources`,`actors`,`summary`],$y={sources:`dock.sources`,actors:`dock.actors`,summary:`dock.summary`};function Vre({fields:e={},onToggleField:t,exporting:n=!1,onExport:r}){let{t:i}=sv();return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[Bre.map(n=>(0,D.jsx)(`button`,{className:`antu-dock-chip${e[n]?` is-on`:``}`,onClick:()=>t(n,!e[n]),children:i($y[n])},n)),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:n,onExport:r})]})})}var Hre={entry:Zy,spine:Qy,legend:zre};function Ure(e){if(typeof document>`u`)return null;let t=document.createElement(`canvas`).getContext?.(`2d`);if(!t)return null;let n=getComputedStyle(e?.querySelector?.(`.antu-app`)||document.body).fontFamily,r={title:`600 14px ${n}`,summary:`${rt}px ${n}`},i=new Map;return(e,n)=>{let a=n+`\0`+e,o=i.get(a);return o===void 0&&(t.font=r[n],o=t.measureText(e).width,i.set(a,o)),o}}var eb={sources:!1,actors:!1,summary:!0};function tb({spec:e}){let t=rv(),n=nv(),[r,i]=(0,E.useState)(()=>({...eb,...n.read().fields,...t?.fields||{}})),a=(e,t)=>{i(n=>({...n,[e]:t})),n.write({fields:{...n.read().fields,[e]:t}})},{root:o}=tv(),s=(0,E.useMemo)(()=>Ure(o),[o]),c=(0,E.useMemo)(()=>kt(e,r,{measure:s}),[e,r,s]),[l,u]=(0,E.useState)(null),d=e=>u(t=>t===e?null:e),f=(0,E.useMemo)(()=>{if(l===null)return{...c,nodes:c.nodes.map(e=>e.type===`legend`?{...e,data:{...e.data,active:null,onToggle:d}}:e)};let e=c.nodes.map(e=>e.type===`entry`?{...e,data:{...e.data,dim:e.data.groupIndex!==l||e.data.shape===`none`}}:e.type===`spine`?{...e,data:{...e.data,dots:e.data.dots.map(e=>({...e,dim:e.groupIndex!==l||e.shape===`none`}))}}:e.type===`legend`?{...e,data:{...e.data,active:l,onToggle:d}}:e);return{...c,nodes:e}},[c,l]),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)(null);Jy(e,h,g);let{canvasRef:_,exporting:v,onExport:y}=Ny(e?.title),b=(0,E.useMemo)(()=>({hoveredId:p,pinnedId:h,pin:e=>g(e),unpin:()=>g(null)}),[p,h]);return(0,D.jsx)(`div`,{className:`antu-fact antu-chr`,children:(0,D.jsx)(Py.Provider,{value:b,children:(0,D.jsx)(My,{ref:_,graph:f,fitWidth:!0,nodeTypes:Hre,style:{"--antu-chr-pad-x":`14px`,"--antu-chr-pad-y":`10px`,"--antu-chr-title-font":`14px`,"--antu-chr-title-lh":`20px`,"--antu-chr-summary-font":`${rt}px`,"--antu-chr-summary-lh":`18px`,"--antu-chr-tag-font":`${it}px`,"--antu-chr-tag-lh":`20px`,"--antu-chr-when-lh":`18px`},onNodeMouseEnter:(e,t)=>{t.type===`entry`&&m(t.id)},onNodeMouseLeave:(e,t)=>{m(e=>e===t.id?null:e)},onNodeClick:(e,t)=>{t.type===`entry`&&g(t.id)},onPaneClick:()=>g(null),children:(0,D.jsx)(Vre,{fields:r,onToggleField:a,exporting:v,onExport:y})})})})}v(`fact`,`chronicle`,tb,`graphKind.chronicle`);var nb=e=>e<=20?String.fromCodePoint(9312+e-1):`(${e})`,Wre=(0,E.memo)(function({data:e}){let{t}=sv(),{theme:n}=xv(),r=n.color,i=[r.side1,r.side2,r.axis],a=r.line,o=r.ink3,{width:s,labelW:c,lanesH:l,axisY:u,lanes:d,segments:f,ticks:p,marks:m,leaders:h,brackets:g}=e,_=u+44,v=e=>i[e]??i[2],y=[];return d.forEach((e,t)=>y.push(t===0?0:y[t-1]+(e.groupIndex===d[t-1].groupIndex?0:1))),(0,D.jsxs)(`div`,{className:`antu-sc-layer`,style:{width:s,height:_},children:[(0,D.jsxs)(`svg`,{width:s,height:_,className:`antu-sc-svg`,"aria-hidden":`true`,children:[d.map((e,t)=>(0,D.jsxs)(`g`,{children:[y[t]%2==1&&(0,D.jsx)(`rect`,{x:0,y:e.top,width:s,height:e.lineY-e.top+14,fill:r.chip,fillOpacity:.6}),(0,D.jsx)(`line`,{x1:c,x2:s,y1:e.lineY,y2:e.lineY,stroke:a,strokeWidth:2})]},e.key)),f.filter(e=>e.breakBefore).map(e=>{let t=e.breakBefore;return(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`rect`,{x:t.x+6,y:0,width:t.w-12,height:u,fill:r.chip}),(0,D.jsx)(`line`,{x1:t.x+6,x2:t.x+6,y1:0,y2:u,stroke:r.line,strokeDasharray:`3 4`}),(0,D.jsx)(`line`,{x1:t.x+t.w-6,x2:t.x+t.w-6,y1:0,y2:u,stroke:r.line,strokeDasharray:`3 4`}),(0,D.jsx)(`text`,{x:t.x+32,y:u+5,textAnchor:`middle`,fontSize:14,fontWeight:700,fill:o,children:`//`})]},`b${e.index}`)}),h.map((e,t)=>(0,D.jsx)(`line`,{x1:e.x,x2:e.x,y1:e.y0,y2:e.y1,stroke:r.ink4,strokeWidth:1,strokeDasharray:e.run?`3 3`:void 0},`l${t}`)),m.map(e=>{let n=v(e.groupIndex);if(e.kind===`band`)return(0,D.jsx)(`rect`,{x:e.x0,y:e.y-7,width:e.x1-e.x0,height:14,rx:3,fill:n,fillOpacity:.16,stroke:n,strokeOpacity:.5,strokeDasharray:`3 2`},e.id);if(e.kind===`bar`)return(0,D.jsx)(`rect`,{x:e.x0,y:e.y-4,width:Math.max(6,e.x1-e.x0),height:8,rx:4,fill:n},e.id);if(e.undated)return(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:5,fill:r.bg,stroke:i[2],strokeWidth:1.5,strokeDasharray:`2 2`},e.id);if(e.coarse){let i=t(`scale.coarse.${e.prec}`),a=e.x+130>s;return(0,D.jsxs)(`g`,{children:[e.groupIndex===1?(0,D.jsx)(`rect`,{x:e.x-5,y:e.y-5,width:10,height:10,rx:2,fill:r.bg,stroke:n,strokeWidth:1.8}):(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:5,fill:r.bg,stroke:n,strokeWidth:1.8}),(0,D.jsx)(`text`,{x:a?e.x-10:e.x+10,y:e.y+4,textAnchor:a?`end`:`start`,fontSize:11,fill:n,children:i})]},e.id)}return e.groupIndex===1?(0,D.jsx)(`rect`,{x:e.x-5,y:e.y-5,width:10,height:10,rx:2,fill:n,stroke:r.bg,strokeWidth:2},e.id):(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:5.5,fill:n,stroke:r.bg,strokeWidth:2},e.id)}),g.map(e=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`path`,{d:`M${e.x0} ${e.y-4} V${e.y} H${e.x1} V${e.y-4}`,fill:`none`,stroke:o,strokeWidth:1.2}),(0,D.jsx)(`text`,{x:(e.x0+e.x1)/2,y:e.y+13,textAnchor:`middle`,fontSize:11,fill:o,children:nb(e.run)})]},`r${e.run}`)),(0,D.jsx)(`line`,{x1:c,x2:s,y1:u,y2:u,stroke:r.axis,strokeWidth:1.5}),p.map((e,t)=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`line`,{x1:e.x,x2:e.x,y1:u,y2:u+5,stroke:r.axis}),(0,D.jsx)(`text`,{x:e.x,y:u+17,textAnchor:`middle`,fontSize:10.5,fill:o,children:e.label})]},`t${t}`))]}),d.map(e=>(0,D.jsxs)(`div`,{className:`antu-sc-lane g${e.groupIndex}`,style:{bottom:`calc(100% - ${e.lineY+8}px)`,width:c-20},children:[(0,D.jsx)(`i`,{}),(0,D.jsxs)(`span`,{children:[e.side?(0,D.jsx)(`em`,{className:`antu-sc-lane-side`,children:e.side}):null,e.other?d.length>1?t(`scale.other`):t(`scale.events`):e.label]})]},e.key)),f.map(e=>(0,D.jsx)(`div`,{className:`antu-sc-seg`,style:{left:e.x0,width:e.x1-e.x0,top:u+24},children:t(`scale.segment`,{n:e.index+1,unit:t(`scale.unit.${e.unit}`),count:e.count})},`c${e.index}`)),f.filter(e=>e.breakBefore?.gap).map(e=>(0,D.jsx)(`div`,{className:`antu-sc-break`,style:{left:e.breakBefore.x,width:e.breakBefore.w,top:l/2-10},children:t(e.breakBefore.gap.key,e.breakBefore.gap.vars)},`g${e.index}`))]})}),Gre=(0,E.memo)(function({data:e}){let{event:t,undated:n,titleLines:r,timeLines:i=1,cardH:a,actorNames:o=[],sources:s=[]}=e,{hoveredId:c,pinnedId:l,pin:u,unpin:d}=(0,E.useContext)(Py),{t:f,lang:p}=sv(),m=l===t.id,h=!l&&c===t.id,g=m||h;return(0,D.jsxs)(`div`,{className:`antu-sc-card${n?` is-undated`:``}`,style:{height:a},role:`button`,tabIndex:0,"aria-label":f(`card.ariaLabel`,{label:t.label,date:t.date||``}),"aria-expanded":g,onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),m?d():u(t.id)):e.key===`Escape`&&d()},children:[(0,D.jsx)(`div`,{className:`antu-sc-title`,style:{WebkitLineClamp:r,lineClamp:r},children:t.label}),i===2&&!n?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`antu-sc-time`,children:[Qe(t.date,t.approx,p),` -`]}),(0,D.jsx)(`div`,{className:`antu-sc-time`,children:$e(t.date,t.dateEnd,p)})]}):(0,D.jsx)(`div`,{className:`antu-sc-time${i===2?` is-wrap`:``}`,children:n?f(`scale.undated`):et(t,p)}),g&&(0,D.jsx)(Fy,{event:t,actorNames:o,sources:s,isPinned:m,showPreview:h,placement:`below`,onClose:d})]})});function Kre(e,t){let n=e.filter(e=>typeof e.date==`string`&&e.date).map(e=>e.date).sort();if(!n.length)return``;let r=Qe(n[0],!1,t),i=Qe(n[n.length-1],!1,t);return r===i?r:n[0].slice(0,10)===n[n.length-1].slice(0,10)&&r.includes(` `)&&i.includes(` `)?`${r}–${i.split(` `).pop()}`:`${r}–${i}`}var rb=(0,E.memo)(function({id:e,data:t}){let{run:n,events:r,cardH:i}=t,{pinnedId:a,unpin:o}=(0,E.useContext)(Py),{t:s,lang:c}=sv(),l=a===e;return(0,D.jsxs)(`div`,{className:`antu-sc-card antu-sc-run`,style:{height:i},role:`button`,tabIndex:0,"aria-expanded":l,children:[(0,D.jsxs)(`div`,{className:`antu-sc-title`,style:{WebkitLineClamp:1,lineClamp:1},children:[nb(n),` `,s(`scale.run`,{n:r.length})]}),(0,D.jsx)(`div`,{className:`antu-sc-time`,children:Kre(r,c)}),l&&(0,D.jsxs)(`div`,{className:`antu-preview pinned below nowheel nopan`,children:[(0,D.jsx)(`button`,{className:`antu-preview-close`,title:s(`common.close`),onClick:e=>{e.stopPropagation(),o()},children:`×`}),(0,D.jsxs)(`div`,{className:`antu-preview-title`,children:[nb(n),` `,s(`scale.run`,{n:r.length})]}),r.map(e=>(0,D.jsxs)(`div`,{className:`antu-sc-run-row`,children:[(0,D.jsx)(`span`,{className:`antu-sc-run-time`,children:et(e,c)}),(0,D.jsx)(`span`,{children:e.label})]},e.id))]})]})}),qre=(0,E.memo)(function({data:e}){let{t,lang:n}=sv();return(0,D.jsx)(`div`,{className:`antu-sc-list`,style:{width:e.width,"--antu-sc-list-lh":`${e.lh}px`},children:e.runs.map(e=>(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`antu-sc-list-head`,children:[nb(e.run),` `,t(`scale.runListed`,{n:e.events.length})]}),e.events.map(e=>(0,D.jsxs)(`div`,{className:`antu-sc-list-row`,children:[(0,D.jsx)(`span`,{className:`antu-sc-run-time`,children:et(e,n)}),(0,D.jsx)(`span`,{children:e.label})]},e.id))]},e.run))})});function Jre({byParty:e=!1,onToggleByParty:t,exporting:n=!1,onExport:r}){let{t:i}=sv();return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[t&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{"data-chip":`byParty`,className:`antu-dock-chip${e?` is-on`:``}`,onClick:()=>t(!e),children:i(`dock.byParty`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`})]}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:n,onExport:r})]})})}var ib={scaleLayer:Wre,scaleCard:Gre,scaleRun:rb,scaleRunList:qre};function Yre(e){if(typeof document>`u`)return null;let t=document.createElement(`canvas`).getContext?.(`2d`);if(!t)return null;let n=`600 ${Mt}px ${getComputedStyle(e?.querySelector?.(`.antu-app`)||document.body).fontFamily}`,r=new Map;return e=>{let i=r.get(e);return i===void 0&&(t.font=n,i=t.measureText(e).width,r.set(e,i)),i}}function Xre({spec:e}){let{root:t}=tv(),n=(0,E.useMemo)(()=>Yre(t),[t]),r=rv(),i=nv(),a=e?.title||``,o=(0,E.useMemo)(()=>{let t=Array.isArray(e?.actors)?e.actors:[];if(t.length<2)return!1;let n=new Map;for(let e of t)e?.groupId&&n.set(e.groupId,(n.get(e.groupId)??0)+1);return[...n.values()].some(e=>e>=2)},[e]),[s,c]=(0,E.useState)(()=>i.read().scaleByParty||{}),l=o&&(r?.byParty??s[a]??!1),u=e=>{let t={...s,[a]:e};c(t),i.write({scaleByParty:t})},d=(0,E.useMemo)(()=>tn(e,{},{measure:n,byParty:l}),[e,n,l]),[f,p]=(0,E.useState)(null),[m,h]=(0,E.useState)(null);Jy(e,m,h);let{canvasRef:g,exporting:_,onExport:v}=Ny(e?.title),y=(0,E.useMemo)(()=>({hoveredId:f,pinnedId:m,pin:e=>h(e),unpin:()=>h(null)}),[f,m]),b=e=>e.type===`scaleCard`||e.type===`scaleRun`;return(0,D.jsx)(`div`,{className:`antu-fact antu-sc`,children:(0,D.jsx)(Py.Provider,{value:y,children:(0,D.jsx)(My,{ref:g,graph:d,nodeTypes:ib,style:{"--antu-sc-pad-x":`10px`,"--antu-sc-pad-y":`8px`,"--antu-sc-title-font":`${Mt}px`,"--antu-sc-title-lh":`17px`,"--antu-sc-time-font":`11px`,"--antu-sc-time-lh":`15px`},onNodeMouseEnter:(e,t)=>{t.type===`scaleCard`&&p(t.id)},onNodeMouseLeave:(e,t)=>p(e=>e===t.id?null:e),onNodeClick:(e,t)=>{b(t)&&h(t.id)},onPaneClick:()=>h(null),children:(0,D.jsx)(Jre,{byParty:l,onToggleByParty:o?u:null,exporting:_,onExport:v})})})})}v(`fact`,`scale`,Xre,`graphKind.scale`);function ab(e,t,n){let r=n.flow;return e===`note`?{...r.note,width:1}:e===`start`&&(t??`neutral`)===`neutral`?{...r.outcome.neutral,...r.start}:r.outcome[t]??r.outcome.neutral}var Zre=(e,t)=>t?e.flow.stageLit:e.flow.stage;function Qre(e,t,n){let r=n.flow.link,i=e===`back`?r.back:e===`main`&&t?r.main:r.plain;return{stroke:i.stroke,width:i.width,dash:i.dash}}var ob=1;function $re({kind:e,outcome:t,w:n,h:r,theme:i}){let a=ab(e,t,i),o={fill:a.fill,stroke:a.stroke,strokeWidth:a.width??1.1,...a.dash?{strokeDasharray:a.dash}:{}},s={fill:`none`,stroke:a.stroke,strokeWidth:1},c=ob,l=ob,u=n-2,d=r-2;switch(e){case`start`:return(0,D.jsx)(`rect`,{className:`antu-pn-shape`,...o,x:c,y:l,width:u,height:d,rx:d/2});case`end`:return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`rect`,{className:`antu-pn-shape`,...o,x:c,y:l,width:u,height:d,rx:d/2}),(0,D.jsx)(`rect`,{className:`antu-pn-ring`,...s,x:5,y:5,width:u-8,height:d-8,rx:(d-8)/2})]});case`decision`:return(0,D.jsx)(`polygon`,{className:`antu-pn-shape`,...o,points:`${n/2},${l} ${n-ob},${r/2} ${n/2},${r-ob} ${c},${r/2}`});case`document`:{let e=l+d-7;return(0,D.jsx)(`path`,{className:`antu-pn-shape`,...o,d:`M ${c} 7 Q ${c} ${l} 7 ${l} L ${c+u-6} ${l} Q ${c+u} ${l} ${c+u} 7 L ${c+u} ${e} C ${c+u*.75} ${e-7*1.6} ${c+u*.5} ${e-7*.2} ${c+u*.5} ${e+7*.4} S ${c+u*.2} ${e+12.6} ${c} ${e} Z`})}case`note`:return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`path`,{className:`antu-pn-shape`,...o,d:`M ${c} ${l} L ${c+u-14} ${l} L ${c+u} 15 L ${c+u} ${l+d} L ${c} ${l+d} Z`}),(0,D.jsx)(`path`,{className:`antu-pn-fold`,fill:`none`,stroke:a.fold,strokeWidth:1,d:`M ${c+u-14} ${l} L ${c+u-14} 15 L ${c+u} 15`})]});default:return(0,D.jsx)(`rect`,{className:`antu-pn-shape`,...o,x:c,y:l,width:u,height:d,rx:6})}}var eie=(0,E.memo)(function({id:e,data:t}){let{node:n,w:r,h:i,textW:a,ruleCount:o=0,lit:s=!1,isSpine:c,stageLabel:l,actorNames:u,sources:d,showDetail:f,vertical:p,layer:m}=t,{hoveredId:h,pinnedId:g,pin:_,unpin:v}=(0,E.useContext)(Py),{t:y,lang:b}=sv(),{theme:x}=xv(),S=g===e,C=!g&&h===e,w=S||C,T=n.kind,ee=n.outcome||`neutral`,te=f&&n.detail?String(n.detail).split(`
|
|
1492
1492
|
`)[0]:``,ne=p?m===0?`below`:`above`:m===0?`right`:`left`;return(0,D.jsxs)(`div`,{className:`antu-pn k-${T} o-${ee}${c?` is-spine`:``}${s?` is-lit`:``}`,style:{width:r,height:i},role:`button`,tabIndex:0,"aria-label":n.label,"aria-expanded":w,onKeyDown:t=>{t.key===`Enter`||t.key===` `?(t.preventDefault(),S?v():_(e)):t.key===`Escape`&&v()},children:[(0,D.jsx)(`svg`,{className:`antu-pn-svg`,width:r,height:i,"aria-hidden":`true`,children:(0,D.jsx)($re,{kind:T,outcome:ee,w:r,h:i,theme:x})}),(0,D.jsxs)(`div`,{className:`antu-pn-body`,style:{width:a},children:[(0,D.jsx)(`div`,{className:`antu-pn-label`,children:n.label}),te&&(0,D.jsx)(`div`,{className:`antu-pn-detail`,children:te})]}),o>0&&(0,D.jsx)(`span`,{className:`antu-pn-rules`,children:y(`flow.ruleBadge`,{n:o})}),w&&(0,D.jsxs)(`div`,{className:[`antu-preview`,`nowheel`,`nopan`,ne,S?`pinned`:``].filter(Boolean).join(` `),children:[S&&(0,D.jsx)(`button`,{className:`antu-preview-close`,title:y(`common.close`),onClick:e=>{e.stopPropagation(),v()},children:`×`}),S&&(0,D.jsxs)(D.Fragment,{children:[l&&(0,D.jsx)(`div`,{className:`antu-preview-time`,children:l}),(0,D.jsx)(`div`,{className:`antu-preview-title`,children:n.label}),u.length>0&&(0,D.jsx)(`div`,{className:`antu-preview-actors`,children:u.map(e=>(0,D.jsx)(`span`,{className:`antu-actor-tag`,children:e},e))})]}),n.detail&&(0,D.jsx)(`div`,{className:`antu-preview-text`,children:n.detail}),S&&d.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`antu-preview-sub`,children:y(`card.sources`,{n:d.length})}),d.map(e=>(0,D.jsxs)(`div`,{className:`antu-source`,children:[(0,D.jsxs)(`div`,{className:`antu-source-name`,children:[e.name,(0,D.jsx)(`span`,{className:`antu-source-type`,children:ji(ki,e.type,b)})]}),e.quote&&(0,D.jsx)(`div`,{className:`antu-source-quote`,children:e.quote})]},e.id))]}),!S&&(0,D.jsx)(`div`,{className:`antu-preview-src${d.length?``:` is-none`}`,children:d.length?y(`card.sourcesList`,{n:d.length,names:d.map(e=>e.name).join(` · `)}):y(`card.sourcesUnlisted`)}),C&&(0,D.jsx)(`div`,{className:`antu-preview-hint`,children:y(`flow.previewHint`)})]})]})}),sb=(e,t)=>t.kind===`all`?e(`rule.tScopeAll`):t.kind===`one`?t.stage:e(`rule.tScopeRange`,{from:t.from,to:t.to}),cb=(0,E.memo)(function({data:e}){let{table:t,sourceById:n}=e,{hoveredId:r,pinnedId:i,pin:a,unpin:o,hover:s}=(0,E.useContext)(Py),{t:c,lang:l}=sv(),u=t.cols.map(e=>`${e}px`).join(` `);return(0,D.jsxs)(`div`,{className:`antu-rtable nopan`,style:{width:t.w,height:t.h},children:[(0,D.jsxs)(`div`,{className:`antu-rtable-title`,children:[(0,D.jsx)(`b`,{children:c(`rule.tableTitle`)}),(0,D.jsx)(`span`,{children:c(`rule.tableNote`)})]}),(0,D.jsxs)(`div`,{className:`antu-rtable-head`,style:{gridTemplateColumns:u},children:[(0,D.jsx)(`span`,{children:c(`rule.colWhen`)}),(0,D.jsx)(`span`,{children:c(`rule.colThen`)}),(0,D.jsx)(`span`,{children:c(`rule.colScope`)})]}),t.groups.map(e=>(0,D.jsxs)(`div`,{className:`antu-rtable-group`,children:[e.headed&&(0,D.jsxs)(`div`,{className:`antu-rtable-ghead${e.endId?` is-end`:``}`,children:[e.endId?c(`rule.groupEnd`,{end:e.endLabel}):c(`rule.groupRest`),(0,D.jsx)(`span`,{children:c(`rule.count`,{n:e.rows.length})})]}),e.rows.map(e=>{let t=`rule:${e.rule.id}`,d=gi(e.rule),f=i===t,p=f||!i&&r===t,m=(e.rule.sourceIds??[]).map(e=>n.get(e)).filter(Boolean);return(0,D.jsxs)(`div`,{"data-pin-id":t,className:`antu-rtable-row${p?` is-lit`:``}`,style:{gridTemplateColumns:u,height:e.h},role:`button`,tabIndex:0,"aria-expanded":f,onMouseEnter:()=>s(t),onMouseLeave:()=>s(null),onClick:e=>{e.stopPropagation(),f?o():a(t)},onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),f?o():a(t)):e.key===`Escape`&&o()},children:[(0,D.jsx)(`div`,{className:`antu-rtable-when`,children:d.length===1?d[0]:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`antu-rtable-any`,children:c(`rule.anyOf`)}),(0,D.jsx)(`ul`,{children:d.map(e=>(0,D.jsx)(`li`,{children:e},e))})]})}),(0,D.jsx)(`div`,{className:`antu-rtable-then`,children:e.rule.then}),(0,D.jsx)(`div`,{className:`antu-rtable-scope`,children:sb(c,e.scope)}),f&&(0,D.jsxs)(`div`,{className:`antu-preview pinned below nowheel nopan antu-rtable-pop`,onClick:e=>e.stopPropagation(),children:[(0,D.jsx)(`button`,{className:`antu-preview-close`,title:c(`common.close`),onClick:e=>{e.stopPropagation(),o()},children:`×`}),(0,D.jsx)(`div`,{className:`antu-preview-time`,children:sb(c,e.scope)}),(0,D.jsx)(`div`,{className:`antu-preview-title`,children:e.rule.then}),(0,D.jsxs)(`div`,{className:`antu-preview-text`,children:[c(`rule.if`),` `,d.join(c(`rule.or`))]}),m.length>0?m.map(e=>(0,D.jsxs)(`div`,{className:`antu-source`,children:[(0,D.jsxs)(`div`,{className:`antu-source-name`,children:[e.name,(0,D.jsx)(`span`,{className:`antu-source-type`,children:ji(ki,e.type,l)})]}),e.quote&&(0,D.jsx)(`div`,{className:`antu-source-quote`,children:e.quote})]},e.id)):(0,D.jsx)(`div`,{className:`antu-preview-src is-none`,children:c(`card.sourcesUnlisted`)})]})]},t)})]},e.endId??`rest`))]})}),lb=[`main`,`branch`,`back`],ub=(0,E.memo)(function({data:e}){let{theme:t}=xv(),{connections:n,width:r,height:i,showConditions:a,highlightMain:o,curved:s}=e;return(0,D.jsxs)(`div`,{className:`antu-plinks${o?` is-main-hl`:``}`,children:[(0,D.jsxs)(`svg`,{className:`antu-plinks-svg`,width:r,height:i,"aria-hidden":`true`,children:[(0,D.jsx)(`defs`,{children:lb.map(e=>(0,D.jsx)(`marker`,{id:`antu-arrow-${e}`,className:`antu-arrow k-${e}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,markerUnits:`userSpaceOnUse`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M 0 1 L 9 5 L 0 9 Z`,fill:Qre(e,o,t).stroke})},e))}),n.map(e=>{let n=Qre(e.kind,o,t);return(0,D.jsx)(`path`,{className:`antu-plink k-${e.kind}`,d:s?e.dCurve:e.d,fill:`none`,stroke:n.stroke,strokeWidth:n.width,strokeDasharray:n.dash,markerEnd:`url(#antu-arrow-${e.kind})`},e.id)})]}),a&&n.filter(e=>e.label).map(e=>(0,D.jsx)(`span`,{className:`antu-plabel k-${e.kind}`,style:{left:e.labelAt.x,top:e.labelAt.y,width:e.labelSize.width,height:e.labelSize.height},children:e.label},e.id))]})}),db=(0,E.memo)(function({data:e}){let{theme:t}=xv(),{boxes:n,width:r,height:i,lit:a=[]}=e,o=e=>Zre(t,a.includes(e.stageId));return(0,D.jsxs)(`div`,{className:`antu-pstages`,children:[(0,D.jsx)(`svg`,{className:`antu-pstages-svg`,width:r,height:i,"aria-hidden":`true`,children:n.map(e=>(0,D.jsx)(`rect`,{className:`antu-pstage-box`,x:e.x+.5,y:e.y+.5,width:Math.max(0,e.w-1),height:Math.max(0,e.h-1),rx:t.radius.group,fill:o(e).fill,stroke:o(e).stroke,strokeWidth:a.includes(e.stageId)?1.5:1},e.stageId))}),n.map(e=>(0,D.jsx)(`span`,{className:`antu-pstage-name`,title:e.label,style:{left:e.x+14-2,top:e.y+7,maxWidth:Math.max(0,e.w-28),fontSize:13,color:o(e).title},children:e.label},e.stageId))]})}),tie=[[`conditions`,`flow.conditions`],[`detail`,`flow.detail`],[`mainLine`,`flow.mainLine`],[`stages`,`flow.stages`],[`rules`,`flow.rules`]],nie=[[`vertical`,`dock.vertical`],[`horizontal`,`dock.horizontal`]],rie=[[`curved`,`flow.linkCurved`],[`straight`,`flow.linkStraight`]];function iie({fields:e={},onToggleField:t,hasStages:n=!1,hasRules:r=!1,orientation:i=`vertical`,onToggleOrientation:a,linkStyle:o=`curved`,onToggleLinkStyle:s,exporting:c=!1,onExport:l}){let{t:u}=sv();return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[tie.filter(([e])=>(e!==`stages`||n)&&(e!==`rules`||r)).map(([n,r])=>(0,D.jsx)(`button`,{className:`antu-dock-chip${e[n]?` is-on`:``}`,onClick:()=>t(n,!e[n]),children:u(r)},n)),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Iy,{options:nie,value:i,onChange:a}),(0,D.jsx)(Iy,{options:rie,value:o,onChange:s,title:u(`flow.linkStyle`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:c,onExport:l})]})})}var aie={pnode:eie,prtable:cb,plinks:ub,pstages:db},oie={conditions:!0,detail:!0,mainLine:!0,stages:!0,rules:!0},sie={width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,style:{pointerEvents:`none`}};function fb({spec:e}){let t=rv(),n=nv(),r=e?.title||``,i=Array.isArray(e?.stages)&&e.stages.length>0,a=Array.isArray(e?.rules)&&e.rules.length>0,[o,s]=(0,E.useState)(()=>n.read().flowFieldsByDiagram||{}),c={...oie,...o[r],...t?.fields||{}},l=(e,t)=>{let i={...o,[r]:{...o[r],[e]:t}};s(i),n.write({flowFieldsByDiagram:i})},[u,d]=(0,E.useState)(()=>n.read().orientations||{}),f=t?.orientation||u[r]||`vertical`,p=e=>{let t={...u,[r]:e};d(t),n.write({orientations:t})},[m,h]=(0,E.useState)(()=>t?.linkStyle||n.read().linkStyle||`curved`),g=e=>{h(e),n.write({linkStyle:e})},_=(0,E.useMemo)(()=>Ci(e,{detail:c.detail,stages:c.stages,rules:c.rules},void 0,f),[e,c.detail,c.stages,c.rules,f]),[v,y]=(0,E.useState)(null),[b,x]=(0,E.useState)(null);Jy(e,b,x);let S=(0,E.useMemo)(()=>({hoveredId:v,pinnedId:b,pin:e=>x(e),unpin:()=>x(null),hover:e=>y(e)}),[v,b]),C=(0,E.useMemo)(()=>{let t=b?.startsWith(`rule:`)?b:!b&&v?.startsWith(`rule:`)?v:null;return t?(e.rules??[]).find(e=>`rule:${e.id}`===t)??null:null},[v,b,e]),w=(0,E.useMemo)(()=>{let{width:t,height:n}=_.size,r=[],i=C?C.stageIds?.length?C.stageIds:_.stageBoxes.map(e=>e.stageId):[];_.stageBoxes.length&&r.push({...sie,id:`__stages__`,type:`pstages`,position:{x:0,y:0},data:{boxes:_.stageBoxes,width:t,height:n,lit:i}}),r.push({...sie,id:`__plinks__`,type:`plinks`,position:{x:0,y:0},data:{connections:_.connections,width:t,height:n,showConditions:c.conditions,highlightMain:c.mainLine,curved:m===`curved`}});let a=C?.endId?_.nodes.map(e=>e.id===C.endId?{...e,data:{...e.data,lit:!0}}:e):_.nodes,o=_.ruleTable?[{id:`__rules__`,type:`prtable`,position:{x:_.ruleTable.x,y:_.ruleTable.y},width:_.ruleTable.w,height:_.ruleTable.h,draggable:!1,selectable:!1,connectable:!1,focusable:!1,data:{table:_.ruleTable,sourceById:new Map((e.sources??[]).map(e=>[e.id,e]))}}]:[];return{nodes:[...r,...a,...o],edges:[],size:_.size}},[_,e,c.conditions,c.mainLine,m,C]),{canvasRef:T,exporting:ee,onExport:te}=Ny(e?.title);return(0,D.jsx)(`div`,{className:`antu-procedure`,children:(0,D.jsx)(Py.Provider,{value:S,children:(0,D.jsx)(My,{ref:T,graph:w,fitKey:_,nodeTypes:aie,onNodeMouseEnter:(e,t)=>{t.type===`pnode`&&y(t.id)},onNodeMouseLeave:(e,t)=>{y(e=>e===t.id?null:e)},onNodeClick:(e,t)=>{t.type===`pnode`&&x(t.id)},onPaneClick:()=>x(null),children:(0,D.jsx)(iie,{fields:c,onToggleField:l,hasStages:i,hasRules:a,orientation:f,onToggleOrientation:p,linkStyle:m,onToggleLinkStyle:g,exporting:ee,onExport:te})})})})}v(`procedure`,`flow`,fb,`graphKind.flow`);var pb=(e,t=yv())=>t.entity[e]??t.entity.other,mb=(e,t=yv())=>t.radius[e]??t.radius.other,hb=(e,t=yv())=>t.relation[e]??t.relation.other,cie=(e=yv())=>e.group,lie=(e=yv())=>e.campBox,uie=.18,gb=(0,E.memo)(function({data:e}){let{theme:t}=xv(),{width:n,height:r,links:i,pills:a,empties:o,frames:s,texts:c,table:l=null,showLabels:u=!0}=e,d=[...new Set(i.filter(e=>e.arrow!==`none`).map(e=>e.ink?`ink`:e.kind??`equity`))];return(0,D.jsxs)(`div`,{className:`antu-ln-layer`,style:{width:n,height:r},children:[(0,D.jsxs)(`svg`,{width:n,height:r,className:`antu-ln-svg`,"aria-hidden":`true`,children:[(0,D.jsx)(`defs`,{children:d.map(e=>(0,D.jsx)(`marker`,{id:`antu-ln-arrow-${e}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,markerUnits:`userSpaceOnUse`,orient:`auto-start-reverse`,children:(0,D.jsx)(`path`,{d:`M 0 1 L 9 5 L 0 9 Z`,fill:e===`ink`?t.color.ink2:hb(e,t).stroke})},e))}),l&&(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`rect`,{x:l.x,y:l.y,width:l.w,height:l.headH,fill:t.color.chip}),l.rows.filter(e=>e.sep!==!1).map(e=>(0,D.jsx)(`line`,{x1:l.x,x2:l.x+l.w,y1:e.y+e.h,y2:e.y+e.h,stroke:t.color.line},`rl${e.id}`)),l.xs.map((e,n)=>(0,D.jsx)(`line`,{x1:e,x2:e,y1:l.y,y2:l.bottom,stroke:t.color.line},`cl${n}`)),(0,D.jsx)(`line`,{x1:l.x,x2:l.x+l.w,y1:l.y,y2:l.y,stroke:t.color.ink4}),(0,D.jsx)(`line`,{x1:l.x,x2:l.x+l.w,y1:l.y+l.headH,y2:l.y+l.headH,stroke:t.color.ink4})]}),s.map((e,n)=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:t.radius.group,fill:t.color.bg,stroke:t.color.line}),(0,D.jsx)(`text`,{x:e.titleAt[0],y:e.titleAt[1],fontSize:14,fontWeight:700,fill:t.color.ink3,children:e.title})]},`f${n}`)),o.map((e,n)=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:t.radius.group,fill:t.color.chip,stroke:t.color.ink4,strokeDasharray:`4 4`}),(0,D.jsx)(`text`,{x:e.x+e.w/2,y:e.y+e.h/2-2,textAnchor:`middle`,fontSize:16,fontWeight:650,fill:t.color.ink3,children:e.text}),(0,D.jsx)(`text`,{x:e.x+e.w/2,y:e.y+e.h/2+22,textAnchor:`middle`,fontSize:12.5,fill:t.color.ink4,children:e.sub})]},`e${n}`)),i.map((e,n)=>{let r=e.ink?`ink`:e.kind??`equity`,i=e.ink?{stroke:t.color.ink2,width:1.6}:hb(r,t);return(0,D.jsxs)(`g`,{opacity:e.opacity??1,children:[(0,D.jsx)(`path`,{d:e.d,fill:`none`,stroke:i.stroke,strokeWidth:e.width??i.width,strokeDasharray:e.back?`5 4`:i.dash,markerEnd:e.arrow===`none`||e.arrow===`start`?void 0:`url(#antu-ln-arrow-${r})`,markerStart:e.arrow===`start`?`url(#antu-ln-arrow-${r})`:void 0}),i.double&&(0,D.jsx)(`path`,{d:e.d,fill:`none`,stroke:t.color.bg,strokeWidth:(e.width??i.width)-2.4})]},`l${n}`)})]}),l&&l.header.map(e=>(0,D.jsx)(`div`,{className:`antu-ln-cell is-head`,style:{left:e.x,top:l.y,width:e.w,height:l.headH},children:e.text},`th${e.x}`)),l&&l.rows.flatMap(e=>e.cells.map((t,n)=>(0,D.jsx)(`div`,{className:`antu-ln-cell${t.bold?` is-first`:``}`,"data-row":e.id,style:{left:t.x,top:t.y??e.y,width:t.w,height:t.h??e.h},children:t.lines.map((e,r)=>(0,D.jsx)(`div`,{className:(n===0||t.sub)&&r>0?`antu-ln-cell-sub`:void 0,children:e},r))},`${e.id}:${n}`))),u&&a.map((e,n)=>(0,D.jsx)(`span`,{className:`antu-ln-pill${e.unknown?` is-unknown`:``}${e.back?` is-back`:``}${e.ink?` is-ink`:``}`,"data-rel":e.relId,style:{left:e.x,top:e.y,opacity:e.opacity??1,...e.kind&&!e.ink?{borderColor:hb(e.kind,t).stroke,color:hb(e.kind,t).stroke}:{}},children:e.text},`pt${n}`)),c.map((e,t)=>(0,D.jsxs)(`div`,{className:`antu-ln-text${e.tone===`note`?` is-note`:e.tone===`row`?` is-row`:e.tone===`title`?` is-title`:``}`,style:{left:e.x,top:e.y,width:e.w},children:[(0,D.jsx)(`div`,{children:e.main}),e.sub&&(0,D.jsx)(`div`,{className:`antu-ln-text-sub`,children:e.sub})]},`t${t}`))]})}),_b=e=>`antu-rt-arrow-${e.replace(/[^0-9a-z]/gi,``)}`,die={routeLayer:(0,E.memo)(function({data:e}){let{theme:t}=xv(),n=t.flow,r=n.link.main.stroke,i=n.outcome.negative.stroke,a=n.link.plain.stroke,o=e=>n.outcome[e]??n.outcome.neutral,{width:s,height:c,top:l,bandBottom:u,bands:d,lineY:f,lineFrom:p,lineTo:m,stations:h,hangs:g,arcs:_,showLabels:v=!0}=e,y=[...new Set([i,a,r])];return(0,D.jsxs)(`div`,{className:`antu-rt-layer`,style:{width:s,height:c},children:[(0,D.jsx)(gb,{data:{...e,links:[],pills:[],blocks:[],showLabels:v}}),(0,D.jsxs)(`svg`,{width:s,height:c,className:`antu-rt-svg`,"aria-hidden":`true`,children:[(0,D.jsx)(`defs`,{children:y.map(e=>(0,D.jsx)(`marker`,{id:_b(e),viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,markerUnits:`userSpaceOnUse`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M 0 1 L 9 5 L 0 9 Z`,fill:e})},e))}),d.map((e,r)=>(0,D.jsx)(`rect`,{x:e.x,y:l,width:e.w,height:u-l,rx:t.radius.group,fill:n.stage.fill,stroke:n.stage.stroke},`b${r}`)),(0,D.jsx)(`line`,{x1:p,x2:m,y1:f,y2:f,stroke:r,strokeWidth:5,strokeLinecap:`round`}),g.map((e,r)=>{let s=e.boxes[0],c=e.fromX,l=f+16,u=[];if(s&&u.push((0,D.jsx)(`path`,{d:`M ${c} ${l} C ${c} ${l+22} ${e.cx} ${s.y-30} ${e.cx} ${s.y-2}`,fill:`none`,stroke:i,strokeWidth:2,markerEnd:`url(#${_b(i)})`},`in`)),e.boxes.forEach((n,r)=>{let i=o(n.outcome).stroke;if(r>0){let t=e.boxes[r-1];u.push((0,D.jsx)(`path`,{d:`M ${e.cx} ${t.y+t.h} L ${e.cx} ${n.y-2}`,fill:`none`,stroke:a,strokeWidth:1.6,markerEnd:`url(#${_b(a)})`},`a${r}`))}u.push((0,D.jsx)(`rect`,{x:n.x,y:n.y,width:n.w,height:n.h,rx:n.kind===`end`?Math.min(n.h/2,22):8,fill:n.kind===`end`?o(n.outcome).fill:t.color.bg,stroke:n.kind===`end`?i:n.outcome===`neutral`?t.color.ink4:i,strokeWidth:1.6,strokeDasharray:n.kind===`end`?o(n.outcome).dash:void 0},`r${r}`))}),e.more){let r=e.boxes.at(-1);u.push((0,D.jsx)(`path`,{d:`M ${e.cx} ${r.y+r.h} L ${e.cx} ${e.more.y-2}`,fill:`none`,stroke:a,strokeWidth:1.6,strokeDasharray:`3 3`},`m`)),u.push((0,D.jsx)(`rect`,{x:e.more.x,y:e.more.y,width:e.more.w,height:e.more.h,rx:t.radius.group,fill:n.stage.fill,stroke:t.color.ink4,strokeDasharray:`4 3`},`mr`))}if(e.tail.type===`return`&&e.boxes.length&&!e.tail.asArc){let t=e.boxes.at(-1),n=h.find(t=>t.id===e.tail.to),r=t.x+t.w,a=t.y+t.h/2,o=Math.max(r+22,n.x+34);u.push((0,D.jsx)(`path`,{d:`M ${r} ${a} L ${o} ${a} L ${o} ${f+40} L ${n.x+9} ${f+15}`,fill:`none`,stroke:i,strokeWidth:2,strokeDasharray:`5 4`,strokeLinejoin:`round`,markerEnd:`url(#${_b(i)})`},`ret`))}return(0,D.jsx)(`g`,{children:u},`h${r}`)}),_.map((e,t)=>{let n=e.kind===`jump`?a:i,r=e.toX>e.fromX?1:-1,o=`${e.start===`box`?`M ${e.fromX} ${e.fromY} L ${e.out} ${e.fromY} L ${e.out} ${e.depth-18}`:`M ${e.fromX} ${f+16} C ${e.fromX} ${f+40} ${e.out} ${f+50} ${e.out} ${f+80} L ${e.out} ${e.depth-18}`} Q ${e.out} ${e.depth} ${e.out+r*18} ${e.depth} L ${e.into-r*18} ${e.depth} Q ${e.into} ${e.depth} ${e.into} ${e.depth-18} L ${e.into} ${f+80} C ${e.into} ${f+50} ${e.toX} ${f+40} ${e.toX} ${f+14}`;return(0,D.jsx)(`path`,{d:o,fill:`none`,stroke:n,strokeWidth:2,strokeDasharray:e.kind===`jump`?void 0:`6 4`,strokeLinejoin:`round`,markerEnd:`url(#${_b(n)})`},`c${t}`)}),h.map(e=>{let i=o(e.outcome).stroke;return e.kind===`decision`?(0,D.jsx)(`path`,{d:`M ${e.x} ${e.y-17} L ${e.x+17} ${e.y} L ${e.x} ${e.y+17} L ${e.x-17} ${e.y} Z`,fill:n.outcome.neutral.fill,stroke:r,strokeWidth:2.6},e.id):e.kind===`start`?(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:11,fill:r,stroke:t.color.bg,strokeWidth:3},e.id):e.kind===`end`?(0,D.jsx)(`rect`,{x:e.x-11,y:e.y-11,width:22,height:22,rx:4,fill:e.outcome===`neutral`?t.color.ink:i,stroke:t.color.bg,strokeWidth:3},e.id):e.kind===`document`?(0,D.jsx)(`rect`,{x:e.x-8,y:e.y-10,width:16,height:20,rx:3,fill:t.color.bg,stroke:i,strokeWidth:3},e.id):(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:9,fill:t.color.bg,stroke:i,strokeWidth:3,strokeDasharray:e.kind===`note`?`3 3`:void 0},e.id)})]}),h.map(e=>(0,D.jsxs)(`div`,{className:`antu-rt-label${e.kind===`decision`?` is-decision`:``}`,"data-id":e.id,title:e.detail||void 0,style:{left:e.labelBox.x,top:e.labelBox.y,width:e.labelBox.w,height:e.labelBox.h},children:[e.actor&&(0,D.jsx)(`div`,{className:`antu-rt-actor`,children:e.actor}),(0,D.jsx)(`div`,{children:e.label})]},`l${e.id}`)),d.map((e,t)=>(0,D.jsx)(`div`,{className:`antu-rt-band`,style:{left:e.x,top:l+6,width:e.w},children:e.label},`bt${t}`)),g.flatMap((e,t)=>[...e.boxes.map(e=>(0,D.jsx)(`div`,{className:`antu-rt-box${e.kind===`end`?` is-end`:``}`,"data-id":e.id,title:e.detail||void 0,style:{left:e.x,top:e.y,width:e.w,height:e.h,color:e.kind===`end`?o(e.outcome).stroke:void 0},children:(0,D.jsx)(`span`,{children:e.label})},`hb${t}${e.id}`)),...e.more?[(0,D.jsx)(`div`,{className:`antu-rt-more`,style:{left:e.more.x,top:e.more.y,width:e.more.w,height:e.more.h},children:e.more.text},`hm${t}`)]:[],...v&&e.cond?[(0,D.jsx)(`span`,{className:`antu-rt-cond is-hang`,style:{left:e.cx,top:e.topY-22},children:e.cond},`hc${t}`)]:[]]),v&&_.filter(e=>e.cond).map((e,t)=>(0,D.jsx)(`span`,{className:`antu-rt-cond${e.kind===`loop`?` is-loop`:``}`,style:{left:(e.out+e.into)/2,top:e.depth},children:e.cond},`ac${t}`))]})})},vb=.8;function fie({spec:e}){let t=nv(),n=`proc:${e?.title||``}`,{t:r,lang:i}=sv(),[a,o]=(0,E.useState)(()=>t.read().procedureRouteFieldsByDiagram||{}),s=a[n]?.labels??!0,c=e=>{let r={...a,[n]:{...a[n],labels:e}};o(r),t.write({procedureRouteFieldsByDiagram:r})},l=(0,E.useMemo)(()=>ur(e,{t:r}),[e,i]),u=(0,E.useMemo)(()=>({nodes:l.nodes.map(e=>({...e,data:{...e.data,showLabels:s}})),edges:[],size:l.size}),[l,s]),{canvasRef:d,exporting:f,onExport:p}=Ny(e?.title);return(0,D.jsx)(`div`,{className:`antu-procedure antu-rt`,children:(0,D.jsx)(My,{ref:d,graph:u,fitKey:l,fitSelf:!0,fitMinZoom:vb,nodeTypes:die,children:(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[(0,D.jsx)(`button`,{className:`antu-dock-chip${s?` is-on`:``}`,onClick:()=>c(!s),children:r(`proc.route.labels`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:f,onExport:p})]})})})})}v(`procedure`,`route`,fie,`graphKind.route`);var pie=1;function mie({kind:e,w:t,h:n,theme:r,end:i=!1}){let a=pb(e,r),o=mb(e,r),s={fill:i?r.color.ink:a.fill,stroke:i?r.color.ink:a.stroke,strokeWidth:a.width},c=a.dash,l=pie,u=pie,d=t-2,f=n-2,p=Math.min(o,f/2);switch(e){case`government`:return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`rect`,{className:`antu-rn-shape`,...s,strokeDasharray:c,x:l,y:u,width:d,height:f,rx:p}),(0,D.jsx)(`rect`,{className:`antu-rn-ring`,fill:`none`,stroke:i?r.color.bg:a.stroke,strokeWidth:.75,x:5,y:5,width:d-8,height:f-8,rx:Math.max(0,p-2)})]});default:return(0,D.jsx)(`rect`,{className:`antu-rn-shape`,...s,strokeDasharray:c,x:l,y:u,width:d,height:f,rx:p})}}var yb=(0,E.memo)(function({id:e,data:t}){let{entity:n,w:r,h:i,textW:a,lit:o=!1,dim:s=!1,groupLabel:c,sources:l,relations:u,vertical:d,layer:f,centre:p=!1,end:m=!1,camp:h=null,hintKey:g=`rel.previewHint`}=t,{hoveredId:_,pinnedId:v,pin:y,unpin:b,focusOn:x}=(0,E.useContext)(Py),{t:S,lang:C}=sv(),{theme:w}=xv(),T=v===e,ee=!v&&_===e,te=T||ee,ne=d?f===0?`below`:`above`:f===0?`right`:`left`;return(0,D.jsxs)(`div`,{className:`antu-rn k-${n.kind}${o?` is-lit`:``}${s?` is-dim`:``}${p?` is-centre`:``}${m?` is-end`:``}`,style:{width:r,height:i},role:`button`,tabIndex:0,"aria-label":n.label,"aria-expanded":te,onKeyDown:t=>{t.key===`Enter`||t.key===` `?(t.preventDefault(),T?b():y(e)):t.key===`Escape`&&b()},children:[h&&(0,D.jsxs)(`span`,{className:`antu-rn-camp t${h.tone}`,children:[(0,D.jsx)(`i`,{}),h.label]}),(0,D.jsx)(`svg`,{className:`antu-rn-svg`,width:r,height:i,"aria-hidden":`true`,children:(0,D.jsx)(mie,{kind:n.kind,w:r,h:i,theme:w,end:m})}),(0,D.jsxs)(`div`,{className:`antu-rn-body`,style:{width:a},children:[(0,D.jsx)(`div`,{className:`antu-rn-label`,children:n.label}),n.role&&(0,D.jsx)(`div`,{className:`antu-rn-role`,children:n.role})]}),te&&(0,D.jsxs)(`div`,{className:[`antu-preview`,`nowheel`,`nopan`,ne,T?`pinned`:``].filter(Boolean).join(` `),children:[T&&(0,D.jsx)(`button`,{className:`antu-preview-close`,title:S(`common.close`),onClick:e=>{e.stopPropagation(),b()},children:`×`}),T&&(0,D.jsxs)(D.Fragment,{children:[c&&(0,D.jsx)(`div`,{className:`antu-preview-time`,children:c}),(0,D.jsx)(`div`,{className:`antu-preview-title`,children:n.label}),n.role&&(0,D.jsx)(`div`,{className:`antu-preview-sub`,children:n.role})]}),T&&x&&(0,D.jsx)(`button`,{className:`antu-dock-chip antu-rn-focus`,onClick:t=>{t.stopPropagation(),x(e)},children:S(`rel.focus.open`)}),n.detail&&(0,D.jsx)(`div`,{className:`antu-preview-text`,children:n.detail}),u.length>0&&(0,D.jsx)(`div`,{className:`antu-rn-relations`,children:u.map(e=>(0,D.jsxs)(`div`,{className:`antu-rn-relation`,children:[(0,D.jsx)(`span`,{className:`antu-rn-relation-arrow`,children:e.directed?e.out?`→`:`←`:`—`}),(0,D.jsx)(`span`,{className:`antu-rn-relation-other`,children:e.other}),(0,D.jsx)(`span`,{className:`antu-rn-relation-text`,children:e.text})]},e.id))}),T&&l.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`antu-preview-sub`,children:S(`card.sources`,{n:l.length})}),l.map(e=>(0,D.jsxs)(`div`,{className:`antu-source`,children:[(0,D.jsxs)(`div`,{className:`antu-source-name`,children:[e.name,(0,D.jsx)(`span`,{className:`antu-source-type`,children:ji(ki,e.type,C)})]}),e.quote&&(0,D.jsx)(`div`,{className:`antu-source-quote`,children:e.quote})]},e.id))]}),!T&&(0,D.jsx)(`div`,{className:`antu-preview-src${l.length?``:` is-none`}`,children:l.length?S(`card.sourcesList`,{n:l.length,names:l.map(e=>e.name).join(` · `)}):S(`card.sourcesUnlisted`)}),ee&&(0,D.jsx)(`div`,{className:`antu-preview-hint`,children:S(g)})]})]})}),hie=e=>e.slice(1).map((t,n)=>[e[n],t]);function gie(e){let t=hie(e),n=t.reduce((e,[t,n])=>e+Math.hypot(n[0]-t[0],n[1]-t[1]),0)/2;for(let[e,r]of t){let t=Math.hypot(r[0]-e[0],r[1]-e[1]);if(n<=t&&t>0){let i=n/t;return[e[0]+(r[0]-e[0])*i,e[1]+(r[1]-e[1])*i]}n-=t}return e[0]}function _ie(e,t){let n=null;for(let[r,i]of hie(e)){let e=i[0]-r[0],a=i[1]-r[1],o=e*e+a*a,s=o===0?0:Math.max(0,Math.min(1,((t[0]-r[0])*e+(t[1]-r[1])*a)/o)),c=[r[0]+e*s,r[1]+a*s],l=Math.hypot(c[0]-t[0],c[1]-t[1]);(!n||l<n.d)&&(n={at:c,d:l})}return n}function vie(e,t=140){let n=new Map(e.map(e=>[e.relationId,e])),r=[];for(let i of e){if(!i.secures||i.points.length<2)continue;let e=n.get(i.secures);if(!e||e.points.length<2)continue;let a=gie(i.points),o=_ie(e.points,a);o&&o.d<=t&&r.push({id:i.id,claimId:e.id,from:a,to:o.at})}return r}function bb(e,t){let n=new Set(e.filter(e=>e.from===t||e.to===t).map(e=>e.relationId));for(let t of e)n.has(t.relationId)&&t.secures&&n.add(t.secures);let r=new Set([t]);for(let t of e)n.has(t.relationId)&&[t.from,t.to].forEach(e=>r.add(e));return{lines:n,entities:r}}var yie=(0,E.memo)(function({data:e}){let{connections:t,width:n,height:r,hiddenKinds:i=[],showLabels:a,curved:o,litEntity:s=null}=e,{theme:c}=xv(),l=(0,E.useMemo)(()=>t.filter(e=>!i.includes(e.kind)),[t,i]),u=(0,E.useMemo)(()=>[...new Set(l.filter(e=>e.directed).map(e=>e.kind))],[l]),d=(0,E.useMemo)(()=>{if(s===null)return[];let e=new Set(l.map(e=>e.id)),n=new Set(t.filter(e=>e.from===s||e.to===s).map(e=>e.id));return vie(t,1/0).filter(t=>n.has(t.id)&&e.has(t.id)&&e.has(t.claimId))},[t,l,s]),f=(0,E.useMemo)(()=>s===null?null:bb(t,s).lines,[t,s]),p=e=>(f===null||f.has(e.relationId)?1:uie)*(e.faint?.6:1);return(0,D.jsxs)(`div`,{className:`antu-rlinks`,children:[(0,D.jsxs)(`svg`,{className:`antu-rlinks-svg`,width:n,height:r,"aria-hidden":`true`,children:[(0,D.jsx)(`defs`,{children:u.map(e=>(0,D.jsx)(`marker`,{id:`antu-rarrow-${e}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,markerUnits:`userSpaceOnUse`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M 0 1 L 9 5 L 0 9 Z`,fill:hb(e,c).stroke})},e))}),l.map(e=>{let t=hb(e.kind,c),n=o&&e.dCurve?e.dCurve:e.d,r=e.directed?`url(#antu-rarrow-${e.kind})`:void 0;return(0,D.jsxs)(`g`,{className:`antu-rlink k-${e.kind}`,opacity:p(e),children:[(0,D.jsx)(`path`,{d:n,fill:`none`,stroke:t.stroke,strokeWidth:e.faint?Math.max(1,t.width*.75):t.width,strokeDasharray:t.dash,markerEnd:r}),t.double&&(0,D.jsx)(`path`,{d:n,fill:`none`,stroke:c.color.bg,strokeWidth:t.width-2.4})]},e.id)}),d.map(e=>(0,D.jsxs)(`g`,{className:`antu-rtie`,children:[(0,D.jsx)(`line`,{x1:e.from[0],y1:e.from[1],x2:e.to[0],y2:e.to[1],stroke:hb(`guarantee`,c).stroke,strokeWidth:1.2,strokeDasharray:`2 3`}),(0,D.jsx)(`circle`,{cx:e.to[0],cy:e.to[1],r:3.2,fill:hb(`guarantee`,c).stroke})]},`tie:${e.id}`))]}),a&&l.map(e=>(0,D.jsx)(`span`,{className:`antu-rlabel k-${e.kind}`,style:{left:e.labelAt.x,top:e.labelAt.y,width:e.labelSize.width,height:e.labelSize.height,opacity:p(e)},children:e.label},e.id))]})}),xb=(0,E.memo)(function({data:e}){let{boxes:t,width:n,height:r}=e,{theme:i}=xv(),a=cie(i),o=lie(i);return(0,D.jsxs)(`div`,{className:`antu-rgroups`,children:[(0,D.jsx)(`svg`,{className:`antu-rgroups-svg`,width:n,height:r,"aria-hidden":`true`,children:t.map(e=>(0,D.jsx)(`rect`,{className:`antu-rgroup-box`,x:e.x+.5,y:e.y+.5,width:Math.max(0,e.w-1),height:Math.max(0,e.h-1),rx:i.radius.group,fill:o.fill,stroke:o.stroke,strokeWidth:o.width,strokeDasharray:o.dash},e.groupId))}),t.map(e=>(0,D.jsx)(`span`,{className:`antu-rgroup-name`,title:e.label,style:{left:e.x+18-2,top:e.y+7,maxWidth:Math.max(0,e.w-36),fontSize:13,color:a.title},children:e.label},e.groupId))]})}),bie=[[`vertical`,`dock.vertical`],[`horizontal`,`dock.horizontal`]],xie=[[`curved`,`flow.linkCurved`],[`straight`,`flow.linkStraight`]];function Sie({kinds:e={},hiddenKinds:t=[],onToggleKind:n,showLabels:r=!0,onToggleLabels:i,hasGroups:a=!1,showGroups:o=!0,onToggleGroups:s,orientation:c=`vertical`,onToggleOrientation:l,linkStyle:u=`curved`,onToggleLinkStyle:d,exporting:f=!1,onExport:p}){let{t:m}=sv(),h=Pi.filter(t=>e[t]>0);return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[h.length>1&&h.map(r=>(0,D.jsx)(`button`,{className:`antu-dock-chip antu-rkind k-${r}${t.includes(r)?``:` is-on`}`,onClick:()=>n(r),title:m(`rel.kindChipTitle`,{n:e[r]}),children:m(`rel.kind.${r}`)},r)),h.length>1&&(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(`button`,{className:`antu-dock-chip${r?` is-on`:``}`,onClick:()=>i(!r),children:m(`rel.labels`)}),a&&(0,D.jsx)(`button`,{className:`antu-dock-chip${o?` is-on`:``}`,onClick:()=>s(!o),children:m(`rel.groups`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Iy,{options:bie,value:c,onChange:l,title:m(a&&o?`dock.orientationCamps`:`dock.orientation`)}),(0,D.jsx)(Iy,{options:xie,value:u,onChange:d,title:m(`flow.linkStyle`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:f,onExport:p})]})})}function Sb(e,t,n=e=>e){let r=nv(),[i,a]=(0,E.useState)(()=>n(r.read()[e]?.[t]));return[i,n=>{a(n);let i={...r.read()[e]||{}};n==null?delete i[t]:i[t]=n,r.write({[e]:i})}]}var Cie={rnode:yb,rlinks:yie,rgroups:xb},wie={labels:!0,groups:!0,hiddenKinds:[]},Tie={width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,style:{pointerEvents:`none`}};function Eie({spec:e}){let t=rv(),n=nv(),r=`rel:${e?.title||``}`,i=Array.isArray(e?.groups)&&e.groups.length>0,{t:a,lang:o}=sv(),[s,c]=Sb(`relationshipFieldsByDiagram`,r,e=>t?.fields?{...e,...t.fields}:e),l={...wie,...s},u=e=>c({...s,...e}),d=e=>{let t=l.hiddenKinds.includes(e)?l.hiddenKinds.filter(t=>t!==e):[...l.hiddenKinds,e];u({hiddenKinds:t})},[f,p]=Sb(`orientations`,r,e=>t?.orientation||e),m=f||`vertical`,[h,g]=(0,E.useState)(()=>t?.linkStyle||n.read().linkStyle||`curved`),_=e=>{g(e),n.write({linkStyle:e})},v=(0,E.useMemo)(()=>pa(e,{groups:l.groups,t:a},void 0,m),[e,l.groups,m,o]),[y,b]=(0,E.useState)(null),[x,S]=(0,E.useState)(null);Jy(e,x,S);let{commands:C}=tv(),w=(0,E.useMemo)(()=>({hoveredId:y,pinnedId:x,pin:e=>S(e),unpin:()=>S(null),focusOn:e=>{n.write({relationshipCentres:{...n.read().relationshipCentres||{},[r]:e}}),S(null),C.run(`setKind`,`focus`)}}),[y,x,r,n,C]),T=x??y,ee=(0,E.useMemo)(()=>{let{width:e,height:t}=v.size,n=[];v.groupBoxes.length&&n.push({...Tie,id:`__groups__`,type:`rgroups`,position:{x:0,y:0},data:{boxes:v.groupBoxes,width:e,height:t}}),n.push({...Tie,id:`__rlinks__`,type:`rlinks`,position:{x:0,y:0},data:{connections:v.connections,width:e,height:t,hiddenKinds:l.hiddenKinds,showLabels:l.labels,curved:h===`curved`,litEntity:T}});let r=T?bb(v.connections,T).entities:null,i=r?v.nodes.map(e=>({...e,data:{...e.data,lit:e.id===T,dim:!r.has(e.id)}})):v.nodes;return{nodes:[...n,...i],edges:[],size:v.size}},[v,l.hiddenKinds,l.labels,h,T]),{canvasRef:te,exporting:ne,onExport:re}=Ny(e?.title);return(0,D.jsx)(`div`,{className:`antu-relationship`,children:(0,D.jsx)(Py.Provider,{value:w,children:(0,D.jsx)(My,{ref:te,graph:ee,fitKey:v,fitMaxZoom:Wn,nodeTypes:Cie,onNodeMouseEnter:(e,t)=>{t.type===`rnode`&&b(t.id)},onNodeMouseLeave:(e,t)=>{b(e=>e===t.id?null:e)},onNodeClick:(e,t)=>{t.type===`rnode`&&S(t.id)},onPaneClick:()=>S(null),children:(0,D.jsx)(Sie,{kinds:v.stats.kinds,hiddenKinds:l.hiddenKinds,onToggleKind:d,showLabels:l.labels,onToggleLabels:e=>u({labels:e}),hasGroups:i,showGroups:l.groups,onToggleGroups:e=>u({groups:e}),orientation:m,onToggleOrientation:p,linkStyle:h,onToggleLinkStyle:_,exporting:ne,onExport:re})})})})}v(`relationship`,`graph`,Eie,`graphKind.graph`);function Cb({kinds:e={},hiddenKinds:t=[],onToggleKind:n,showLabels:r=!0,onToggleLabels:i,parties:a=[],centre:o=null,onPickCentre:s,isDefaultCentre:c=!0,onResetCentre:l,exporting:u=!1,onExport:d,extra:f=null}){let{t:p}=sv(),m=Pi.filter(t=>e[t]>0);return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[m.length>1&&m.map(r=>(0,D.jsx)(`button`,{className:`antu-dock-chip antu-rkind k-${r}${t.includes(r)?``:` is-on`}`,onClick:()=>n(r),title:p(`rel.kindChipTitle`,{n:e[r]}),children:p(`rel.kind.${r}`)},r)),m.length>1&&(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(`button`,{className:`antu-dock-chip${r?` is-on`:``}`,onClick:()=>i(!r),children:p(`rel.labels`)}),f,a.length>1&&s&&(0,D.jsx)(`select`,{className:`antu-dock-chip antu-pt-end`,value:o??``,onChange:e=>s(e.target.value),title:p(`rel.focus.centre`),"aria-label":p(`rel.focus.centre`),children:a.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.label},e.id))}),!c&&(0,D.jsx)(`button`,{className:`antu-dock-chip antu-rf-reset`,onClick:l,title:p(`rel.focus.resetTitle`),children:p(`rel.focus.reset`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:u,onExport:d})]})})}var Die={rnode:yb,rlinks:yie,rfocusNote:(0,E.memo)(function(){let{t:e}=sv();return(0,D.jsx)(`div`,{className:`antu-rf-note`,children:e(`rel.focus.apart`)})})},Oie={labels:!0,hiddenKinds:[]},kie={width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,style:{pointerEvents:`none`}};function wb({spec:e}){let t=rv(),n=`rel:${e?.title||``}`,{t:r,lang:i}=sv(),[a,o]=Sb(`relationshipFieldsByDiagram`,n,e=>t?.fields?{...e,...t.fields}:e),s={...Oie,...a},c=e=>o({...a,...e}),l=e=>{let t=s.hiddenKinds.includes(e)?s.hiddenKinds.filter(t=>t!==e):[...s.hiddenKinds,e];c({hiddenKinds:t})},[u,d]=Sb(`relationshipCentres`,n,e=>t?.centre??e),f=(0,E.useMemo)(()=>Ua(e,{centre:u,t:r}),[e,u,i]),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)(null);Jy(e,h,g);let _=(0,E.useMemo)(()=>({hoveredId:p,pinnedId:h,pin:e=>g(e),unpin:()=>g(null)}),[p,h]),v=h??p,y=(0,E.useMemo)(()=>{let{width:e,height:t}=f.size,n=[{...kie,id:`__rlinks__`,type:`rlinks`,position:{x:0,y:0},data:{connections:f.connections,width:e,height:t,hiddenKinds:s.hiddenKinds,showLabels:s.labels,curved:!1,litEntity:v}}];f.note&&n.push({...kie,id:`__note__`,type:`rfocusNote`,position:f.note,data:{}});let r=v?bb(f.connections,v).entities:null,i=f.nodes.map(e=>({...e,data:{...e.data,hintKey:e.data.centre?`rel.previewHint`:`rel.focus.hint`,...r?{lit:e.id===v,dim:!r.has(e.id)}:{}}}));return{nodes:[...n,...i],edges:[],size:f.size}},[f,s.hiddenKinds,s.labels,v]),{canvasRef:b,exporting:x,onExport:S}=Ny(e?.title);return(0,D.jsx)(`div`,{className:`antu-relationship antu-rf`,children:(0,D.jsx)(Py.Provider,{value:_,children:(0,D.jsx)(My,{ref:b,graph:y,fitKey:f,fitMaxZoom:Wn,nodeTypes:Die,onNodeMouseEnter:(e,t)=>{t.type===`rnode`&&m(t.id)},onNodeMouseLeave:(e,t)=>m(e=>e===t.id?null:e),onNodeClick:(e,t)=>{t.type===`rnode`&&(t.id===f.centre?g(t.id):(g(null),m(null),d(t.id)))},onPaneClick:()=>g(null),children:(0,D.jsx)(Cb,{kinds:f.stats.kinds,hiddenKinds:s.hiddenKinds,onToggleKind:l,showLabels:s.labels,onToggleLabels:e=>c({labels:e}),parties:e.entities,centre:f.centre,onPickCentre:e=>{g(null),d(e===f.defaultCentre?null:e)},isDefaultCentre:f.centre===f.defaultCentre,onResetCentre:()=>d(null),exporting:x,onExport:S})})})})}v(`relationship`,`focus`,wb,`graphKind.focus`);var Tb={matrixLayer:(0,E.memo)(function({data:e}){let{theme:t}=xv(),{width:n,height:r,corner:i,bands:a,heads:o,rowHeads:s,cells:c,diagonal:l,showLabels:u=!0}=e,d=l.length-1,f=l[d].x+l[d].w,p=l[d].y+l[d].h,m=l[0].x,h=o[0].y;return(0,D.jsxs)(`div`,{className:`antu-mx-layer`,style:{width:n,height:r},children:[(0,D.jsxs)(`svg`,{width:n,height:r,className:`antu-mx-svg`,"aria-hidden":`true`,children:[a.map((e,n)=>{let r=t.camp[e.tone]??t.camp[0];return(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`rect`,{x:e.top.x,y:e.top.y,width:e.top.w,height:e.top.h,fill:r.fill,stroke:r.stroke}),(0,D.jsx)(`rect`,{x:e.left.x,y:e.left.y,width:e.left.w,height:e.left.h,fill:r.fill,stroke:r.stroke})]},`b${n}`)}),(0,D.jsx)(`rect`,{x:i.x,y:i.y,width:i.w,height:i.h,fill:t.color.chip,stroke:t.color.ink4}),(0,D.jsx)(`rect`,{x:m,y:h,width:f-m,height:o[0].h,fill:t.color.chip}),(0,D.jsx)(`rect`,{x:s[0].x,y:s[0].y,width:s[0].w,height:p-s[0].y,fill:t.color.chip}),l.map((e,n)=>(0,D.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,fill:t.color.chip},`d${n}`)),s.map((e,n)=>(0,D.jsx)(`line`,{x1:s[0].x,x2:f,y1:e.y,y2:e.y,stroke:t.color.ink4},`rl${n}`)),(0,D.jsx)(`line`,{x1:s[0].x,x2:f,y1:p,y2:p,stroke:t.color.ink4}),o.map((e,n)=>(0,D.jsx)(`line`,{x1:e.x,x2:e.x,y1:h,y2:p,stroke:t.color.ink4},`cl${n}`)),(0,D.jsx)(`line`,{x1:f,x2:f,y1:h,y2:p,stroke:t.color.ink4}),(0,D.jsx)(`line`,{x1:m,x2:f,y1:h+o[0].h,y2:h+o[0].h,stroke:t.color.ink,strokeWidth:1.5}),(0,D.jsx)(`line`,{x1:m,x2:m,y1:h,y2:p,stroke:t.color.ink,strokeWidth:1.5}),!u&&c.flatMap(e=>e.chips.map((n,r)=>{let i=hb(n.kind,t),a=n.x+n.w/2,o=n.y+n.h/2;return(0,D.jsx)(`circle`,{cx:a,cy:o,r:6,fill:i.stroke,fillOpacity:.85},`${e.row}|${e.col}|${r}`)}))]}),a.map((e,n)=>(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`antu-mx-band`,style:{left:e.top.x,top:e.top.y,width:e.top.w,height:e.top.h,color:(t.camp[e.tone]??t.camp[0]).text},children:e.label}),(0,D.jsx)(`div`,{className:`antu-mx-band is-side${/[\u2e80-\u9fff]/.test(e.label)?` is-cjk`:``}`,style:{left:e.left.x,top:e.left.y,width:e.left.w,height:e.left.h,color:(t.camp[e.tone]??t.camp[0]).text},children:(0,D.jsx)(`span`,{children:e.label})})]},`bt${n}`)),o.map(e=>(0,D.jsx)(`div`,{className:`antu-mx-head`,"data-id":e.id,style:{left:e.x,top:e.y,width:e.w,height:e.h},children:(0,D.jsx)(`span`,{children:e.text})},`h${e.id}`)),s.map(e=>(0,D.jsx)(`div`,{className:`antu-mx-rowhead`,"data-id":e.id,style:{left:e.x,top:e.y,width:e.w,height:e.h},children:(0,D.jsx)(`span`,{children:e.text})},`r${e.id}`)),u&&c.flatMap(e=>e.chips.map((t,n)=>(0,D.jsx)(`span`,{className:`antu-mx-chip k-${t.kind}`,"data-rel":t.id,style:{left:t.x,top:t.y,width:t.w,height:t.h},children:(0,D.jsx)(`span`,{children:t.text})},`t${e.row}|${e.col}|${n}`)))]})})};function Aie({spec:e}){let t=`rel:${e?.title||``}`,{t:n,lang:r}=sv(),[i,a]=Sb(`relationshipFieldsByDiagram`,t),o=i?.labels??!0,s=e=>a({...i,labels:e}),c=(0,E.useMemo)(()=>to(e,{t:n}),[e,r]),l=(0,E.useMemo)(()=>({nodes:c.nodes.map(e=>({...e,data:{...e.data,showLabels:o}})),edges:[],size:c.size}),[c,o]),{canvasRef:u,exporting:d,onExport:f}=Ny(e?.title);return(0,D.jsx)(`div`,{className:`antu-relationship antu-mx`,children:(0,D.jsx)(My,{ref:u,graph:l,fitKey:c,fitWidth:!0,nodeTypes:Tb,children:(0,D.jsx)(Cb,{kinds:{},showLabels:o,onToggleLabels:s,exporting:d,onExport:f})})})}v(`relationship`,`matrix`,Aie,`graphKind.matrix`);var Eb={rnode:yb,lineLayer:gb};function Db({spec:e,build:t,className:n,options:r={},onParty:i=null,dockExtra:a=null,fitWidth:o=!0,decorate:s=null,fitMaxZoom:c=0}){let l=`rel:${e?.title||``}`,{t:u,lang:d}=sv(),[f,p]=Sb(`relationshipFieldsByDiagram`,l),m=f?.labels??!0,h=e=>p({...f,labels:e}),g=JSON.stringify(r),_=(0,E.useMemo)(()=>t(e,{...r,t:u}),[e,d,g]),[v,y]=(0,E.useState)(null),[b,x]=(0,E.useState)(null);Jy(e,b,x);let S=(0,E.useMemo)(()=>({hoveredId:v,pinnedId:b,pin:e=>x(e),unpin:()=>x(null)}),[v,b]),C=(0,E.useMemo)(()=>({nodes:_.nodes.map(e=>e.type===`lineLayer`?{...e,data:{...e.data,showLabels:m}}:s?{...e,data:s(e)}:e),edges:[],size:_.size}),[_,m,s]),{canvasRef:w,exporting:T,onExport:ee}=Ny(e?.title);return(0,D.jsx)(`div`,{className:`antu-relationship ${n}`,children:(0,D.jsx)(Py.Provider,{value:S,children:(0,D.jsx)(My,{ref:w,graph:C,fitKey:_,fitWidth:o,fitSelf:!o,fitMaxZoom:c,nodeTypes:Eb,onNodeMouseEnter:(e,t)=>{t.type===`rnode`&&y(t.id)},onNodeMouseLeave:(e,t)=>y(e=>e===t.id?null:e),onNodeClick:(e,t)=>{t.type===`rnode`&&(i?i(t.id,{pin:()=>x(t.id),unpin:()=>x(null)}):x(t.id))},onPaneClick:()=>x(null),children:(0,D.jsx)(Cb,{kinds:{},showLabels:m,onToggleLabels:h,exporting:T,onExport:ee,extra:a?a(_):null})})})})}function jie({spec:e,build:t,className:n,kind:r}){let i=rv(),{t:a}=sv(),[o,s]=Sb(`relationshipCompanies`,`rel:${e?.title||``}:${r}`,e=>i?.company??e);return(0,D.jsx)(Db,{spec:e,build:t,className:n,options:{company:o},dockExtra:e=>e.several&&(0,D.jsxs)(`select`,{className:`antu-dock-chip antu-co-pick`,value:e.company??`*`,onChange:e=>s(e.target.value),title:a(`rel.company.label`),"aria-label":a(`rel.company.label`),children:[(0,D.jsx)(`option`,{value:`*`,children:a(`rel.company.all`)}),e.companies.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.label},e.id))]})})}function Mie({spec:e}){return(0,D.jsx)(jie,{spec:e,build:To,className:`antu-eq`,kind:`equity`})}v(`relationship`,`equity`,Mie,`graphKind.equity`);function Nie({spec:e}){return(0,D.jsx)(jie,{spec:e,build:jo,className:`antu-au`,kind:`authority`})}v(`relationship`,`authority`,Nie,`graphKind.authority`);function Pie({spec:e}){let t=rv(),n=`rel:${e?.title||``}`,{t:r}=sv(),[i,a]=Sb(`relationshipCentres`,n,e=>t?.centre??e),o=e=>a(e===``?null:e);return(0,D.jsx)(Db,{spec:e,build:Ho,className:`antu-rl`,options:{centre:i},dockExtra:t=>(0,D.jsx)(D.Fragment,{children:(0,D.jsx)(`select`,{className:`antu-dock-chip antu-rl-centre`,value:t.centre,onChange:e=>o(e.target.value===t.defaultCentre?``:e.target.value),title:r(`rel.related.centre`),"aria-label":r(`rel.related.centre`),children:e.entities.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.label},e.id))})})})}v(`relationship`,`related`,Pie,`graphKind.related`);var Fie=1;function Iie({spec:e}){let t=rv(),n=`rel:${e?.title||``}`,{t:r}=sv(),[i,a]=Sb(`relationshipPaths`,n,e=>t?.from||t?.to?{...e,...t.from?{from:t.from}:{},...t.to?{to:t.to}:{}}:e),o=i||{},s={from:o.from,to:o.to},c=e=>a({...o,...e}),l=(t,n)=>(0,D.jsx)(`select`,{className:`antu-dock-chip antu-pt-end`,value:t,onChange:e=>c({[n]:e.target.value}),title:r(`rel.path.${n}`),"aria-label":r(`rel.path.${n}`),children:e.entities.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.label},e.id))});return(0,D.jsx)(Db,{spec:e,build:ts,className:`antu-pt`,options:s,fitWidth:!1,fitMaxZoom:Fie,dockExtra:e=>(0,D.jsxs)(D.Fragment,{children:[l(e.from,`from`),(0,D.jsx)(`button`,{className:`antu-dock-chip`,onClick:()=>c({from:e.to,to:e.from}),title:r(`rel.path.swap`),"aria-label":r(`rel.path.swap`),children:`⇄`}),l(e.to,`to`)]})})}v(`relationship`,`path`,Iie,`graphKind.path`);var Lie=(e,t)=>t.justify.node[e]??t.justify.node.fact,Rie=(e,t)=>t.justify.stance[e]??t.justify.stance.for,Ob=e=>e.flow.stage,zie=.18,kb=.62,Ab=(0,E.memo)(function({data:e}){let{boxes:t,width:n,height:r,onToggle:i,foldable:a=!0}=e,{t:o}=sv(),{theme:s}=xv(),c=Ob(s);return(0,D.jsxs)(`div`,{className:`antu-rgroups`,children:[(0,D.jsx)(`svg`,{className:`antu-rgroups-svg`,width:n,height:r,"aria-hidden":`true`,children:t.map(e=>(0,D.jsx)(`rect`,{className:`antu-rgroup-box${e.collapsed?` is-folded`:``}`,x:e.x+.5,y:e.y+.5,width:Math.max(0,e.w-1),height:Math.max(0,e.h-1),rx:10,fill:c.fill,stroke:c.stroke,strokeWidth:1,strokeDasharray:e.collapsed?`5 4`:void 0},e.groupId))}),t.map(e=>{let t={left:e.x+18-2,top:e.y+7,maxWidth:Math.max(0,e.w-36),fontSize:13,color:c.title},n=e.collapsed?`${e.label} · ${o(`jus.folded`,{n:e.hidden})}`:e.label;return a&&(e.collapsed||e.total>1)?(0,D.jsxs)(`button`,{type:`button`,className:`antu-rgroup-name antu-jissue-toggle nodrag nopan${e.collapsed?` is-folded`:``}`,title:o(e.collapsed?`jus.unfold`:`jus.fold`),"aria-expanded":!e.collapsed,style:t,onClick:t=>{t.stopPropagation(),i(e.groupId)},children:[(0,D.jsx)(`span`,{className:`antu-jissue-arrow`,"aria-hidden":`true`,children:e.collapsed?`▸`:`▾`}),n]},e.groupId):(0,D.jsx)(`span`,{className:`antu-rgroup-name`,title:e.label,style:t,children:n},e.groupId)})]})}),Bie=1;function Vie({kind:e,w:t,h:n,rejected:r,theme:i}){let a=Lie(e,i),o={fill:a.fill,stroke:a.stroke,strokeWidth:a.width,...r?{strokeDasharray:`5 3`}:a.dash?{strokeDasharray:a.dash}:{}},s=Bie,c=Bie,l=t-2,u=n-2;switch(e){case`conclusion`:return(0,D.jsx)(`rect`,{className:`antu-jn-shape`,...o,x:s,y:c,width:l,height:u,rx:9});case`norm`:return(0,D.jsx)(`rect`,{className:`antu-jn-shape`,...o,x:s,y:c,width:l,height:u,rx:3});case`element`:return(0,D.jsx)(`rect`,{className:`antu-jn-shape`,...o,x:s,y:c,width:l,height:u,rx:Math.min(16,u/2)});case`inference`:return(0,D.jsx)(`rect`,{className:`antu-jn-shape`,...o,x:s,y:c,width:l,height:u,rx:8});case`judgement`:return(0,D.jsx)(`rect`,{className:`antu-jn-shape`,...o,x:s,y:c,width:l,height:u,rx:8});default:return(0,D.jsx)(`rect`,{className:`antu-jn-shape`,...o,x:s,y:c,width:l,height:u,rx:3})}}var Hie=e=>e.replace(`T`,` `),Uie=(0,E.memo)(function({id:e,data:t}){let{node:n,w:r,h:i,textW:a,lit:o=!1,dim:s=!1,copyOf:c,copies:l,groupLabel:u,sources:d,grounds:f,supports:p,vertical:m,layer:h}=t,{hoveredId:g,pinnedId:_,pin:v,unpin:y}=(0,E.useContext)(Py),{t:b,lang:x}=sv(),{theme:S}=xv(),C=_===e,w=!_&&g===e,T=C||w,ee=n.holds===`no`,te=m?h===0?`below`:`above`:h===0?`right`:`left`;return(0,D.jsxs)(`div`,{className:`antu-jn k-${n.kind}${o?` is-lit`:``}${s?` is-dim`:``}${ee?` is-rejected`:``}${c?` is-copy`:``}`,style:{width:r,height:i,opacity:ee&&!s?kb:void 0},role:`button`,tabIndex:0,"aria-label":n.label,"aria-expanded":T,onKeyDown:t=>{t.key===`Enter`||t.key===` `?(t.preventDefault(),C?y():v(e)):t.key===`Escape`&&y()},children:[(0,D.jsx)(`svg`,{className:`antu-jn-svg`,width:r,height:i,"aria-hidden":`true`,children:(0,D.jsx)(Vie,{kind:n.kind,w:r,h:i,rejected:ee,theme:S})}),(0,D.jsxs)(`div`,{className:`antu-jn-body`,style:{width:a},children:[(0,D.jsxs)(`div`,{className:`antu-jn-tag`,children:[(0,D.jsx)(`span`,{className:`antu-jn-kind`,children:b(`jus.kind.${n.kind}`)}),n.date&&(0,D.jsx)(`span`,{className:`antu-jn-date`,children:Hie(n.date)}),n.holds&&(0,D.jsx)(`span`,{className:`antu-jn-holds is-${n.holds}`,children:b(`jus.holds.${n.holds}`)}),n.combine&&(0,D.jsx)(`span`,{className:`antu-jn-combine is-${n.combine}`,title:b(`jus.combine.${n.combine}Long`),children:b(`jus.combine.${n.combine}`)}),c&&(0,D.jsx)(`span`,{className:`antu-jn-copy`,children:b(`jus.copy`)})]}),(0,D.jsx)(`div`,{className:`antu-jn-label`,children:n.label})]}),T&&(0,D.jsxs)(`div`,{className:[`antu-preview`,`nowheel`,`nopan`,te,C?`pinned`:``].filter(Boolean).join(` `),children:[C&&(0,D.jsx)(`button`,{className:`antu-preview-close`,title:b(`common.close`),onClick:e=>{e.stopPropagation(),y()},children:`×`}),C&&(0,D.jsxs)(D.Fragment,{children:[u&&(0,D.jsx)(`div`,{className:`antu-preview-time`,children:u}),(0,D.jsxs)(`div`,{className:`antu-preview-sub`,children:[b(`jus.kind.${n.kind}`),n.holds?` · ${b(`jus.holds.${n.holds}`)}`:``,n.date?` · ${Hie(n.date)}`:``]}),(0,D.jsx)(`div`,{className:`antu-preview-title`,children:n.label})]}),n.detail&&(0,D.jsx)(`div`,{className:`antu-preview-text`,children:n.detail}),l>1&&(0,D.jsx)(`div`,{className:`antu-preview-sub`,children:b(`jus.copies`,{n:l})}),f.length>0&&(0,D.jsxs)(`div`,{className:`antu-jn-rows`,children:[(0,D.jsxs)(`div`,{className:`antu-jn-rows-title`,children:[b(`jus.grounds`),n.combine?` · ${b(`jus.combine.${n.combine}Long`)}`:``]}),f.map(e=>(0,D.jsxs)(`div`,{className:`antu-jn-row is-${e.stance}`,children:[(0,D.jsx)(`span`,{className:`antu-jn-row-stance`,children:b(`jus.stance.${e.stance}`)}),(0,D.jsx)(`span`,{className:`antu-jn-row-text`,children:e.text})]},`${e.id}:${e.stance}`))]}),p.length>0&&(0,D.jsxs)(`div`,{className:`antu-jn-rows`,children:[(0,D.jsx)(`div`,{className:`antu-jn-rows-title`,children:b(`jus.supports`)}),p.map(e=>(0,D.jsxs)(`div`,{className:`antu-jn-row is-${e.stance}`,children:[(0,D.jsx)(`span`,{className:`antu-jn-row-stance`,children:b(`jus.stance.${e.stance}`)}),(0,D.jsx)(`span`,{className:`antu-jn-row-text`,children:e.text})]},`${e.id}:${e.stance}`))]}),C&&d.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`antu-preview-sub`,children:b(`card.sources`,{n:d.length})}),d.map(e=>(0,D.jsxs)(`div`,{className:`antu-source`,children:[(0,D.jsxs)(`div`,{className:`antu-source-name`,children:[e.name,(0,D.jsx)(`span`,{className:`antu-source-type`,children:ji(ki,e.type,x)})]}),e.quote&&(0,D.jsx)(`div`,{className:`antu-source-quote`,children:e.quote})]},e.id))]}),!C&&(0,D.jsx)(`div`,{className:`antu-preview-src${d.length?``:` is-none`}`,children:d.length?b(`card.sourcesList`,{n:d.length,names:d.map(e=>e.name).join(` · `)}):b(`card.sourcesUnlisted`)}),w&&(0,D.jsx)(`div`,{className:`antu-preview-hint`,children:b(`jus.previewHint`)})]})]})}),jb=(0,E.memo)(function({data:e}){let{theme:t}=xv(),{connections:n,width:r,height:i,showLabels:a,curved:o,litLines:s=null}=e,c=(0,E.useMemo)(()=>[...new Set(n.map(e=>e.stance))],[n]),l=e=>s===null||s.has(e.id)?1:zie;return(0,D.jsxs)(`div`,{className:`antu-jlinks`,children:[(0,D.jsxs)(`svg`,{className:`antu-jlinks-svg`,width:r,height:i,"aria-hidden":`true`,children:[(0,D.jsx)(`defs`,{children:c.map(e=>(0,D.jsx)(`marker`,{id:`antu-jarrow-${e}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,markerUnits:`userSpaceOnUse`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M 0 1 L 9 5 L 0 9 Z`,fill:Rie(e,t).stroke})},e))}),n.map(e=>{let n=Rie(e.stance,t);return(0,D.jsx)(`g`,{className:`antu-jlink s-${e.stance}`,opacity:l(e),children:(0,D.jsx)(`path`,{d:o?e.dCurve:e.d,fill:`none`,stroke:n.stroke,strokeWidth:n.width,strokeDasharray:n.dash,markerEnd:`url(#antu-jarrow-${e.stance})`})},e.id)})]}),a&&n.filter(e=>e.label&&e.labelAt).map(e=>(0,D.jsx)(`span`,{className:`antu-rlabel antu-jlabel s-${e.stance}`,style:{left:e.labelAt.x,top:e.labelAt.y,width:e.labelSize.width,height:e.labelSize.height,opacity:l(e)},children:e.label},e.id))]})}),Mb=[[`horizontal`,`dock.horizontal`],[`vertical`,`dock.vertical`]],Nb=[[`curved`,`flow.linkCurved`],[`straight`,`flow.linkStraight`]];function Wie({hasIssues:e=!1,hasShared:t=!1,merged:n=!1,onToggleMerged:r,allFolded:i=!1,onToggleAll:a,hasLabels:o=!1,showLabels:s=!0,onToggleLabels:c,orientation:l=`horizontal`,onToggleOrientation:u,linkStyle:d=`curved`,onToggleLinkStyle:f,exporting:p=!1,onExport:m}){let{t:h}=sv();return(0,D.jsx)(`div`,{className:`antu-dock`,children:(0,D.jsxs)(`div`,{className:`antu-dock-bar`,children:[e&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{className:`antu-dock-chip${i?` is-on`:``}`,onClick:a,title:h(`jus.foldAllTitle`),children:h(`jus.foldAll`)}),!o&&(0,D.jsx)(`span`,{className:`antu-dock-sep`})]}),t&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{className:`antu-dock-chip${n?` is-on`:``}`,onClick:()=>r(!n),title:h(`jus.mergeTitle`),children:h(`jus.merge`)}),!o&&(0,D.jsx)(`span`,{className:`antu-dock-sep`})]}),o&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{className:`antu-dock-chip${s?` is-on`:``}`,onClick:()=>c(!s),children:h(`rel.labels`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`})]}),(0,D.jsx)(Iy,{options:Mb,value:l,onChange:u}),(0,D.jsx)(Iy,{options:Nb,value:d,onChange:f,title:h(`flow.linkStyle`)}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ly,{}),(0,D.jsx)(`span`,{className:`antu-dock-sep`}),(0,D.jsx)(Ry,{exporting:p,onExport:m})]})})}function Gie(e,t,n){let r=new Map;for(let e of t)r.set(e.data.node.id,[...r.get(e.data.node.id)??[],e.id]);let i=new Map(t.map(e=>[e.id,e.data.node.id])),a=e=>r.get(i.get(e))??[e],o=new Set(a(n)),s=new Set,c=!0;for(;c;){c=!1;for(let t of e)if(o.has(t.to)&&!s.has(t.id)){s.add(t.id);for(let e of a(t.from))o.has(e)||o.add(e);c=!0}}let l=new Set(a(n));for(c=!0;c;){c=!1;for(let t of e)if(l.has(t.from)&&!s.has(t.id)){s.add(t.id);for(let e of a(t.to))l.add(e),o.add(e);c=!0}}return{lines:s,nodes:o}}var Kie={jnode:Uie,jlinks:jb,jgroups:Ab},qie={width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,style:{pointerEvents:`none`}};function Jie({spec:e}){let t=rv(),n=nv(),r=`jus:${e?.title||``}`,i=Array.isArray(e?.links)&&e.links.some(e=>e?.label),[a,o]=(0,E.useState)(()=>n.read().justificationLabels||{}),s=t?.fields?.labels??a[r]??!0,c=e=>{let t={...a,[r]:e};o(t),n.write({justificationLabels:t})},[l,u]=(0,E.useState)(()=>n.read().orientations||{}),d=t?.orientation||l[r]||`horizontal`,f=e=>{let t={...l,[r]:e};u(t),n.write({orientations:t})},[p,m]=(0,E.useState)(()=>t?.linkStyle||n.read().linkStyle||`curved`),h=e=>{m(e),n.write({linkStyle:e})},g=(0,E.useMemo)(()=>Array.isArray(e?.groups)?e.groups.map(e=>e?.id).filter(Boolean):[],[e]),[_,v]=(0,E.useState)(()=>n.read().justificationFolded||{}),y=(0,E.useMemo)(()=>Ks(e,Hs).issues,[e]),b=(0,E.useMemo)(()=>(t?.fields?.collapsed??_[r]??y).filter(e=>g.includes(e)),[_,r,g,y]),x=(0,E.useRef)(b),S=(0,E.useRef)(_),C=e=>{x.current=e,S.current={...S.current,[r]:e},v(S.current),n.write({justificationFolded:S.current})},w=e=>{let t=x.current.filter(e=>g.includes(e));C(t.includes(e)?t.filter(t=>t!==e):[...t,e])},T=g.length>0&&g.every(e=>b.includes(e)),ee=()=>C(x.current.length===g.length?[]:g),te=(0,E.useMemo)(()=>{let t=new Map,n=new Map((Array.isArray(e?.nodes)?e.nodes:[]).map(e=>[e?.id,e?.kind]));for(let r of Array.isArray(e?.links)?e.links:[])n.get(r?.from)===`fact`&&t.set(r.from,(t.get(r.from)??0)+1);return[...t.values()].some(e=>e>1)},[e]),[ne,re]=(0,E.useState)(()=>n.read().justificationMerged||{}),ie=t?.fields?.merged??ne[r]??!1,ae=e=>{let t={...ne,[r]:e};re(t),n.write({justificationMerged:t})},oe=(0,E.useMemo)(()=>Hs(e,{collapsed:b,merged:ie},void 0,d),[e,d,b,ie]),[se,ce]=(0,E.useState)(null),[le,ue]=(0,E.useState)(null);Jy(e,le,ue);let de=(0,E.useMemo)(()=>({hoveredId:se,pinnedId:le,pin:e=>ue(e),unpin:()=>ue(null)}),[se,le]),fe=le??se,pe=(0,E.useMemo)(()=>{let{width:e,height:t}=oe.size,n=[];oe.groupBoxes.length&&n.push({...qie,id:`__groups__`,type:`jgroups`,position:{x:0,y:0},data:{boxes:oe.groupBoxes,width:e,height:t,onToggle:w}});let r=fe?Gie(oe.connections,oe.nodes,fe):null;n.push({...qie,id:`__jlinks__`,type:`jlinks`,position:{x:0,y:0},data:{connections:oe.connections,width:e,height:t,showLabels:s,curved:p===`curved`,litLines:r?r.lines:null}});let i=r?oe.nodes.map(e=>({...e,data:{...e.data,lit:e.id===fe,dim:!r.nodes.has(e.id)}})):oe.nodes;return{nodes:[...n,...i],edges:[],size:oe.size}},[oe,s,p,fe]),{canvasRef:me,exporting:he,onExport:ge}=Ny(e?.title);return(0,D.jsx)(`div`,{className:`antu-justification`,children:(0,D.jsx)(Py.Provider,{value:de,children:(0,D.jsx)(My,{ref:me,graph:pe,fitKey:oe,nodeTypes:Kie,onNodeMouseEnter:(e,t)=>{t.type===`jnode`&&ce(t.id)},onNodeMouseLeave:(e,t)=>{ce(e=>e===t.id?null:e)},onNodeClick:(e,t)=>{t.type===`jnode`&&ue(t.id)},onPaneClick:()=>ue(null),children:(0,D.jsx)(Wie,{hasShared:te,merged:ie,onToggleMerged:ae,hasIssues:g.length>1,allFolded:T,onToggleAll:ee,hasLabels:i,showLabels:s,onToggleLabels:c,orientation:d,onToggleOrientation:f,linkStyle:p,onToggleLinkStyle:h,exporting:he,onExport:ge})})})})}v(`justification`,`tree`,Jie,`graphKind.tree`);var Yie=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,ne());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function ee(){return g?!0:!(e.unstable_now()-T<w)}function te(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ee());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ne():S=!1}}}var ne;if(typeof y==`function`)ne=function(){y(te)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=te,ne=function(){ie.postMessage(null)}}else ne=function(){_(te,0)};function ae(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ne()))),r},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Xie=o(((e,t)=>{t.exports=Yie()})),Zie=o((e=>{var t=Xie(),n=Zs(),r=qh();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),ee=Symbol.for(`react.transitional.element`),te=Symbol.for(`react.portal`),ne=Symbol.for(`react.fragment`),re=Symbol.for(`react.strict_mode`),ie=Symbol.for(`react.profiler`),ae=Symbol.for(`react.consumer`),oe=Symbol.for(`react.context`),se=Symbol.for(`react.forward_ref`),ce=Symbol.for(`react.suspense`),le=Symbol.for(`react.suspense_list`),ue=Symbol.for(`react.memo`),de=Symbol.for(`react.lazy`),fe=Symbol.for(`react.activity`),pe=Symbol.for(`react.legacy_hidden`),me=Symbol.for(`react.memo_cache_sentinel`),he=Symbol.for(`react.view_transition`),ge=Symbol.for(`react.recoverable`),_e=Symbol.iterator;function ve(e){return typeof e!=`object`||!e?null:(e=_e&&e[_e]||e[`@@iterator`],typeof e==`function`?e:null)}var ye=Symbol.for(`react.client.reference`);function be(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ye?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case ne:return`Fragment`;case ie:return`Profiler`;case re:return`StrictMode`;case ce:return`Suspense`;case le:return`SuspenseList`;case fe:return`Activity`;case he:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case te:return`Portal`;case oe:return e.displayName||`Context`;case ae:return(e._context.displayName||`Context`)+`.Consumer`;case se:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ue:return t=e.displayName||null,t===null?be(e.type)||`Memo`:t;case de:t=e._payload,e=e._init;try{return be(e(t))}catch{}}return null}var xe=Array.isArray,Se=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ce=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,we={pending:!1,data:null,method:null,action:null},Te=[],Ee=-1;function De(e){return{current:e}}function Oe(e){0>Ee||(e.current=Te[Ee],Te[Ee]=null,Ee--)}function ke(e,t){Ee++,Te[Ee]=e.current,e.current=t}var Ae=De(null),je=De(null),Me=De(null),Ne=De(null);function Pe(e,t){switch(ke(Me,t),ke(je,e),ke(Ae,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Oe(Ae),ke(Ae,e)}function Fe(){Oe(Ae),Oe(je),Oe(Me)}function Ie(e){var t=e.memoizedState;t!==null&&($m._currentValue=t.memoizedState,ke(Ne,e)),t=Ae.current;var n=dp(t,e.type);t!==n&&(ke(je,e),ke(Ae,n))}function Le(e){je.current===e&&(Oe(Ae),Oe(je)),Ne.current===e&&(Oe(Ne),$m._currentValue=we)}var Re,ze;function Be(e){if(Re===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Re=t&&t[1]||``,ze=-1<e.stack.indexOf(`
|
|
1493
1493
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
1494
1494
|
`+Re+e+ze}var Ve=!1;function He(e,t){if(!e||Ve)return``;Ve=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
package/bin/antu-mcp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Antu 0.13.
|
|
2
|
+
// Antu 0.13.1
|
|
3
3
|
// Copyright (C) 2026 Ji Cheng
|
|
4
4
|
//
|
|
5
5
|
// Antu is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
// publish them, or sell them on any terms you like. This licence covers Antu's code in the page, and the notices in
|
|
14
14
|
// the page must stay with it.
|
|
15
15
|
//
|
|
16
|
-
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.
|
|
17
|
-
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
18
|
-
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
16
|
+
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.1
|
|
17
|
+
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.1/LICENSE
|
|
18
|
+
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.1/skills/antu/THIRD-PARTY-NOTICES.md
|
|
19
19
|
//
|
|
20
20
|
// === The licence of Antu ===
|
|
21
21
|
//
|
|
@@ -1489,7 +1489,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
1489
1489
|
depsCount: ${n},
|
|
1490
1490
|
deps: ${r}}`};var i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),Ose=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ec(),n=Dc();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),kse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Pc(),n=Ec(),r=Oc(),i=Dc();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),Ase=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Bc(),n=Pc(),r=Dc(),i=kse();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),jse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Pc(),n=Ec(),r=Dc(),i=Dc();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),Mse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Dc();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),Nse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:Pc().validateUnion,error:{message:`must match a schema in anyOf`}}})),Pse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ec(),n=Dc();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),Fse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Dc();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),Ise=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ec(),n=Dc(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),Lse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Dc();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),Rse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Sse(),n=wse(),r=Cse(),i=Tse(),a=Ese(),o=Dse(),s=Ose(),c=kse(),l=Ase(),u=jse(),d=Mse(),f=Nse(),p=Pse(),m=Fse(),h=Ise(),g=Lse();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),zse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ec();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),Bse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[zse().default]})),Vse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),Hse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=use(),n=xse(),r=Rse(),i=Bse(),a=Vse();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),Use=w((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),Wse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ec(),n=Use(),r=Uc(),i=Hc(),a=Dc();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),Gse=T({$id:()=>Qc,$schema:()=>Zc,default:()=>rl,definitions:()=>el,properties:()=>nl,title:()=>$c,type:()=>tl}),Zc,Qc,$c,el,tl,nl,rl,Kse=C((()=>{Zc=`http://json-schema.org/draft-07/schema#`,Qc=`http://json-schema.org/draft-07/schema#`,$c=`Core schema meta-schema`,el={schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},tl=[`object`,`boolean`],nl={$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},rl={$schema:Zc,$id:Qc,title:$c,definitions:el,type:tl,properties:nl,default:!0}})),il=w(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;var n=sse(),r=Hse(),i=Wse(),a=(Kse(),ne(Gse).default),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`,c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=Bc();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=Ec();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=Vc();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return d.default}});var f=Hc();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return f.default}})})),qse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:ee,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:y,int32:{type:`number`,validate:S},int64:{type:`number`,validate:C},float:{type:`number`,validate:w},double:{type:`number`,validate:w},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-+(d<0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}var d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}var h=/\/|:/,g=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _(e){return h.test(e)&&g.test(e)}var v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}var b=-(2**31),x=2**31-1;function S(e){return Number.isInteger(e)&&e<=x&&e>=b}function C(e){return Number.isInteger(e)}function w(){return!0}var T=/[^\\]\\Z/;function ee(e){if(T.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),Jse=w((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;var t=il(),n=Ec(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),Yse=w(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=qse(),r=Jse(),i=Ec(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s})),Xse=te(il(),1),Zse=te(Yse(),1);function Qse(){let e=new Xse.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Zse.default)(e),e}var $se=class{constructor(e){this._ajv=e??Qse()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}},ece=class{constructor(e){this._server=e}requestStream(e,t,n){return this._server.requestStream(e,t,n)}createMessageStream(e,t){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return this.requestStream({method:`sampling/createMessage`,params:e},Es,t)}elicitInputStream(e,t){let n=this._server.getClientCapabilities(),r=e.mode??`form`;switch(r){case`url`:if(!n?.elicitation?.url)throw Error(`Client does not support url elicitation.`);break;case`form`:if(!n?.elicitation?.form)throw Error(`Client does not support form elicitation.`)}let i=r===`form`&&e.mode===void 0?{...e,mode:`form`}:e;return this.requestStream({method:`elicitation/create`,params:i},Ns,t)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._server.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}};function tce(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);if(t===`tools/call`&&!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`)}function nce(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`)}}var rce=class extends Qoe{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ys.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new $se,this.setRequestHandler(ko,e=>this._oninitialize(e)),this.setNotificationHandler(Ao,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(xs,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=ys.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||={tasks:new ece(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=Cc(this._capabilities,e)}setRequestHandler(e,t){let n=pa(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r=ga(n);if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);return r===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let r=da(vs,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new Rs(So.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=da(Io,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new Rs(So.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=da(_s,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new Rs(So.InvalidParams,`Invalid tools/call result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){nce(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&tce(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Tae.includes(t)?t:ro,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:`ping`},wo)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return e.tools?this.request({method:`sampling/createMessage`,params:e},Ds,t):this.request({method:`sampling/createMessage`,params:e},Es,t)}async elicitInput(e,t){switch(e.mode??`form`){case`url`:{if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support url elicitation.`);let n=e;return this.request({method:`elicitation/create`,params:n},Ns,t)}case`form`:{if(!this._clientCapabilities?.elicitation?.form)throw Error(`Client does not support form elicitation.`);let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},Ns,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new Rs(So.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof Rs?e:new Rs(So.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:`roots/list`,params:e},Ls,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}},al=Symbol.for(`mcp.completable`);function ol(e){return!!e&&typeof e==`object`&&al in e}function ice(e){return e[al]?.complete}var ace;(function(e){e.Completable=`McpCompletable`})(ace||={});var oce=/^[A-Za-z0-9._-]{1,128}$/;function sce(e){let t=[];if(e.length===0)return{isValid:!1,warnings:[`Tool name cannot be empty`]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(` `)&&t.push(`Tool name contains spaces, which may cause parsing issues`),e.includes(`,`)&&t.push(`Tool name contains commas, which may cause parsing issues`),(e.startsWith(`-`)||e.endsWith(`-`))&&t.push(`Tool name starts or ends with a dash, which may cause parsing issues in some contexts`),(e.startsWith(`.`)||e.endsWith(`.`))&&t.push(`Tool name starts or ends with a dot, which may cause parsing issues in some contexts`),!oce.test(e)){let n=e.split(``).filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,n)=>n.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${n.map(e=>`"${e}"`).join(`, `)}`,`Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)`),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function cce(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let e of t)console.warn(` - ${e}`);console.warn(`Tool registration will proceed, but this may cause compatibility issues.`),console.warn(`Consider updating the tool name to conform to the MCP tool naming standard.`),console.warn(`See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.`)}}function sl(e){let t=sce(e);return cce(e,t.warnings),t.isValid}var cl=class{constructor(e){this._mcpServer=e}registerToolTask(e,t,n){let r={taskSupport:`required`,...t.execution};if(r.taskSupport===`forbidden`)throw Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,t.title,t.description,t.inputSchema,t.outputSchema,t.annotations,r,t._meta,n)}},lce=class{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new rce(e,t)}get experimental(){return this._experimental||={tasks:new cl(this)},this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||=(this.server.assertCanSetRequestHandler(pl(gs)),this.server.assertCanSetRequestHandler(pl(vs)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(gs,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:(()=>{let e=ma(t.inputSchema);return e?yc(e,{strictUnions:!0,pipeStrategy:`input`}):uce})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){let e=ma(t.outputSchema);e&&(n.outputSchema=yc(e,{strictUnions:!0,pipeStrategy:`output`}))}return n})})),this.server.setRequestHandler(vs,async(e,t)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new Rs(So.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new Rs(So.InvalidParams,`Tool ${e.params.name} disabled`);let r=!!e.params.task,i=n.execution?.taskSupport,a=`createTask`in n.handler;if((i===`required`||i===`optional`)&&!a)throw new Rs(So.InternalError,`Tool ${e.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i===`required`&&!r)throw new Rs(So.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(i===`optional`&&!r&&a)return await this.handleAutomaticTaskPolling(n,e,t);let o=await this.validateToolInput(n,e.params.arguments,e.params.name),s=await this.executeToolHandler(n,o,t);return r||await this.validateToolOutput(n,s,e.params.name),s}catch(e){if(e instanceof Rs&&e.code===So.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),!0)}createToolError(e){return{content:[{type:`text`,text:e}],isError:!0}}async validateToolInput(e,t,n){if(!e.inputSchema)return;let r=await fa(ma(e.inputSchema)??e.inputSchema,t);if(!r.success){let e=ha(`error`in r?r.error:`Unknown error`);throw new Rs(So.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${e}`)}return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema||!(`content`in t)||t.isError)return;if(!t.structuredContent)throw new Rs(So.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let r=await fa(ma(e.outputSchema),t.structuredContent);if(!r.success){let e=ha(`error`in r?r.error:`Unknown error`);throw new Rs(So.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${e}`)}}async executeToolHandler(e,t,n){let r=e.handler;if(`createTask`in r){if(!n.taskStore)throw Error(`No task store provided.`);let i={...n,taskStore:n.taskStore};if(e.inputSchema){let e=r;return await Promise.resolve(e.createTask(t,i))}{let e=r;return await Promise.resolve(e.createTask(i))}}if(e.inputSchema){let e=r;return await Promise.resolve(e(t,n))}{let e=r;return await Promise.resolve(e(n))}}async handleAutomaticTaskPolling(e,t,n){if(!n.taskStore)throw Error(`No task store provided for task-capable tool.`);let r=await this.validateToolInput(e,t.params.arguments,t.params.name),i=e.handler,a={...n,taskStore:n.taskStore},o=r?await Promise.resolve(i.createTask(r,a)):await Promise.resolve(i.createTask(a)),s=o.task.taskId,c=o.task,l=c.pollInterval??5e3;for(;c.status!==`completed`&&c.status!==`failed`&&c.status!==`cancelled`;){await new Promise(e=>setTimeout(e,l));let e=await n.taskStore.getTask(s);if(!e)throw new Rs(So.InternalError,`Task ${s} not found during polling`);c=e}return await n.taskStore.getTaskResult(s)}setCompletionRequestHandler(){this._completionHandlerInitialized||=(this.server.assertCanSetRequestHandler(pl(Ps)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Ps,async e=>{switch(e.params.ref.type){case`ref/prompt`:return woe(e),this.handlePromptCompletion(e,e.params.ref);case`ref/resource`:return Toe(e),this.handleResourceCompletion(e,e.params.ref);default:throw new Rs(So.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new Rs(So.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new Rs(So.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return hl;let r=pa(n.argsSchema)?.[e.params.argument.name];if(!ol(r))return hl;let i=ice(r);return i?ml(await i(e.params.argument.value,e.params.context)):hl}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return hl;throw new Rs(So.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let r=n.resourceTemplate.completeCallback(e.params.argument.name);return r?ml(await r(e.params.argument.value,e.params.context)):hl}setResourceRequestHandlers(){this._resourceHandlersInitialized||=(this.server.assertCanSetRequestHandler(pl($o)),this.server.assertCanSetRequestHandler(pl(ts)),this.server.assertCanSetRequestHandler(pl(is)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler($o,async(e,t)=>{let n=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),r=[];for(let e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;let n=await e.resourceTemplate.listCallback(t);for(let t of n.resources)r.push({...e.metadata,...t})}return{resources:[...n,...r]}}),this.server.setRequestHandler(ts,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(is,async(e,t)=>{let n=new URL(e.params.uri),r=this._registeredResources[n.toString()];if(r){if(!r.enabled)throw new Rs(So.InvalidParams,`Resource ${n} disabled`);return r.readCallback(n,t)}for(let e of Object.values(this._registeredResourceTemplates)){let r=e.resourceTemplate.uriTemplate.match(n.toString());if(r)return e.readCallback(n,r,t)}throw new Rs(So.InvalidParams,`Resource ${n} not found`)}),!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||=(this.server.assertCanSetRequestHandler(pl(ss)),this.server.assertCanSetRequestHandler(pl(ls)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(ss,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?dce(t.argsSchema):void 0}))})),this.server.setRequestHandler(ls,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new Rs(So.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new Rs(So.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let r=await fa(ma(n.argsSchema),e.params.arguments);if(!r.success){let t=ha(`error`in r?r.error:`Unknown error`);throw new Rs(So.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}let i=r.data,a=n.callback;return await Promise.resolve(a(i,t))}{let e=n.callback;return await Promise.resolve(e(t))}}),!0)}resource(e,t,...n){let r;typeof n[0]==`object`&&(r=n.shift());let i=n[0];if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let n=this._createRegisteredResource(e,void 0,t,r,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let n=this._createRegisteredResourceTemplate(e,void 0,t,r,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}}registerResource(e,t,n,r){if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let i=this._createRegisteredResource(e,n.title,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,n.title,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(e,t,n,r,i){let a={name:e,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{e.uri!==void 0&&e.uri!==n&&(delete this._registeredResources[n],e.uri&&(this._registeredResources[e.uri]=a)),e.name!==void 0&&(a.name=e.name),e.title!==void 0&&(a.title=e.title),e.metadata!==void 0&&(a.metadata=e.metadata),e.callback!==void 0&&(a.readCallback=e.callback),e.enabled!==void 0&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=a,a}_createRegisteredResourceTemplate(e,t,n,r,i){let a={resourceTemplate:n,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.template!==void 0&&(a.resourceTemplate=t.template),t.metadata!==void 0&&(a.metadata=t.metadata),t.callback!==void 0&&(a.readCallback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!n.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,n,r,i){let a={title:t,description:n,argsSchema:r===void 0?void 0:ua(r),callback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.description!==void 0&&(a.description=t.description),t.argsSchema!==void 0&&(a.argsSchema=ua(t.argsSchema)),t.callback!==void 0&&(a.callback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=a,r&&Object.values(r).some(e=>ol(e instanceof Ja?e._def?.innerType:e))&&this.setCompletionRequestHandler(),a}_createRegisteredTool(e,t,n,r,i,a,o,s,c){sl(e);let l={title:t,description:n,inputSchema:fl(r),outputSchema:fl(i),annotations:a,execution:o,_meta:s,handler:c,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(typeof t.name==`string`&&sl(t.name),delete this._registeredTools[e],t.name&&(this._registeredTools[t.name]=l)),t.title!==void 0&&(l.title=t.title),t.description!==void 0&&(l.description=t.description),t.paramsSchema!==void 0&&(l.inputSchema=ua(t.paramsSchema)),t.outputSchema!==void 0&&(l.outputSchema=ua(t.outputSchema)),t.callback!==void 0&&(l.handler=t.callback),t.annotations!==void 0&&(l.annotations=t.annotations),t._meta!==void 0&&(l._meta=t._meta),t.enabled!==void 0&&(l.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...t){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let n,r,i,a;if(typeof t[0]==`string`&&(n=t.shift()),t.length>1){let n=t[0];if(dl(n))r=t.shift(),t.length>1&&typeof t[0]==`object`&&t[0]!==null&&!dl(t[0])&&(a=t.shift());else if(typeof n==`object`&&n){if(Object.values(n).some(e=>typeof e==`object`&&!!e))throw Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);a=t.shift()}}let o=t[0];return this._createRegisteredTool(e,void 0,n,r,i,a,{taskSupport:`forbidden`},void 0,o)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:r,description:i,inputSchema:a,outputSchema:o,annotations:s,_meta:c}=t;return this._createRegisteredTool(e,r,i,a,o,s,{taskSupport:`forbidden`},c,n)}prompt(e,...t){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let n;typeof t[0]==`string`&&(n=t.shift());let r;t.length>1&&(r=t.shift());let i=t[0],a=this._createRegisteredPrompt(e,void 0,n,r,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(e,t,n){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:r,description:i,argsSchema:a}=t,o=this._createRegisteredPrompt(e,r,i,a,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},uce={type:`object`,properties:{}};function ll(e){return typeof e==`object`&&!!e&&`parse`in e&&typeof e.parse==`function`&&`safeParse`in e&&typeof e.safeParse==`function`}function ul(e){return`_def`in e||`_zod`in e||ll(e)}function dl(e){return typeof e!=`object`||!e||ul(e)?!1:Object.keys(e).length===0||Object.values(e).some(ll)}function fl(e){if(e){if(dl(e))return ua(e);if(!ul(e))throw Error(`inputSchema must be a Zod schema or raw shape, received an unrecognized object`);return e}}function dce(e){let t=pa(e);return t?Object.entries(t).map(([e,t])=>({name:e,description:gie(t),required:!_ie(t)})):[]}function pl(e){let t=pa(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=ga(t);if(typeof n==`string`)return n;throw Error(`Schema method literal must be a string`)}function ml(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var hl={completion:{values:[],hasMore:!1}},fce=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??10485760}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
1491
1491
|
`);if(e===-1)return null;let t=this._buffer.toString(`utf8`,0,e).replace(/\r$/,``);return this._buffer=this._buffer.subarray(e+1),pce(t)}clear(){this._buffer=void 0}};function pce(e){return jae.parse(JSON.parse(e))}function mce(e){return JSON.stringify(e)+`
|
|
1492
|
-
`}var hce=class{constructor(t=e.stdin,n=e.stdout,r){this._stdin=t,this._stdout=n,this._started=!1,this._ondata=e=>{try{this._readBuffer.append(e),this.processReadBuffer()}catch(e){this.onerror?.(e),this.close().catch(()=>{})}},this._onerror=e=>{this.onerror?.(e)},this._readBuffer=new fce({maxBufferSize:r?.maxBufferSize})}async start(){if(this._started)throw Error(`StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this._started=!0,this._stdin.on(`data`,this._ondata),this._stdin.on(`error`,this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off(`data`,this._ondata),this._stdin.off(`error`,this._onerror),this._stdin.listenerCount(`data`)===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(t=>{let n=mce(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}},gl=`/*ANTU_SPEC*/null`;function _l(e){return String(e).replace(/</g,`\\u003c`)}function gce(e,t,{preset:n}={}){if(e.split(`/*ANTU_SPEC*/null`).length!==2)throw Error(`the viewer template does not hold exactly one ${gl}`);let r=_l(JSON.stringify(t)),i=n?`;window.__ANTU_PRESET__ = ${_l(JSON.stringify(n))}`:``;return e.replace(gl,()=>r+i)}f(u(h(import.meta.url)),`../..`);var vl=f(u(h(import.meta.url)),`..`);d(vl,`dist-engine/engine.js`),d(vl,`dist-engine/engine.css`);function _ce(e){return String(e).replace(/[&<>"]/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e])}function yl(){return`0.13.0`}function vce(e){return String(e||`antu`).replace(/[\\/:*?"<>|\s]+/g,`-`).slice(0,60)}function yce(e,{preset:t,force:n=!1,quiet:r=!1}={}){{let n=_ce(e?.title||`Antu`);return gce(i(d(vl,`assets/viewer.html`),`utf8`),e,{preset:t}).replace(/<title>[^<]*<\/title>/,()=>`<title>${n} · Antu</title>`)}}function bce(e,{outPath:t,preset:r,force:i=!1,quiet:a=!1}={}){let o=yce(e,{preset:r,force:i,quiet:a}),s=f(t||`${vce(e?.title)}.html`);return n(u(s),{recursive:!0}),c(s,o),{path:s,bytes:Buffer.byteLength(o)}}var bl=new Map,xl=[`experimental`,`stable`,`deprecated`];function Sl(e,t){if(!e)throw Error(`registerKnowledge: type must not be empty`);if(!t?.validate)throw Error(`registerKnowledge: validate is required`);if(!t?.describe)throw Error(`registerKnowledge: describe is required (the agent-facing field table)`);if(!Number.isInteger(t.specVersion)||t.specVersion<1)throw Error(`registerKnowledge: specVersion is required, a whole number (the generation of this type's JSON format, core/specVersion.js)`);Cl(e,t),bl.set(e,t)}function Cl(e,t){let n=Object.keys(t.layouts??{}),r=Object.keys(t.diagrams??{});for(let t of n)if(!r.includes(t))throw Error(`registerKnowledge: ${e}/${t} has a layout but no entry in diagrams (version, status, since)`);for(let t of r)if(!n.includes(t))throw Error(`registerKnowledge: ${e}/${t} is in diagrams but has no layout`);for(let[n,r]of Object.entries(t.diagrams??{})){if(!Number.isInteger(r.version)||r.version<1)throw Error(`registerKnowledge: ${e}/${n}: version must be a whole number >= 1`);if(!xl.includes(r.status))throw Error(`registerKnowledge: ${e}/${n}: status must be one of ${xl.join(`, `)}`);if(!/^\d+\.\d+\.\d+$/.test(r.since??``))throw Error(`registerKnowledge: ${e}/${n}: since must be a release number such as 0.7.0`)}}function xce(e){let t=bl.get(e);return Object.entries(t?.diagrams??{}).map(([t,n])=>({type:e,kind:t,...n}))}function wl(e){return bl.get(e)}function Tl(){return[...bl.entries()].map(([e,t])=>({type:e,labelKey:t.label??`graphType.${e}`}))}function Sce(e){return bl.get(e)?.validate}function Cce(e,t){let n=bl.get(e)?.layouts;if(n)return t&&n[t]?n[t]:Object.values(n)[0]}function El(e){return Object.keys(bl.get(e)?.layouts??{})}var Dl=e=>({name:`specVersion`,req:`no`,ty:`integer`,note:`which generation of this format the file follows (now ${e}); omit = the current one. Write it: it is how an older file is recognised after a breaking change`});function wce(e,t){return e.specVersion===void 0?null:!Number.isInteger(e.specVersion)||e.specVersion<1?{key:`err.specVersionForm`,params:{value:JSON.stringify(e.specVersion)}}:Number.isInteger(t)&&e.specVersion>t?{key:`err.specVersionNewer`,params:{value:e.specVersion,known:t,type:e.type}}:null}var Tce=/^(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}))?)?)?)?$/;function Ol(e){let t=Tce.exec(typeof e==`string`?e.trim():``);if(!t)return null;let[n,r,i,a,o,s]=t.slice(1).map(e=>e===void 0?void 0:Number(e)),c=(e,t,n,r,i,a)=>Date.UTC(e,t,n,r,i,a),l,u;return r===void 0?(l=c(n,0,1,0,0,0),u=c(n+1,0,1,0,0,0)):i===void 0?(l=c(n,r-1,1,0,0,0),u=c(n,r,1,0,0,0)):a===void 0?(l=c(n,r-1,i,0,0,0),u=c(n,r-1,i+1,0,0,0)):s===void 0?(l=c(n,r-1,i,a,o,0),u=l+6e4):(l=c(n,r-1,i,a,o,s),u=l+1e3),Number.isNaN(l)?null:{from:l,to:u}}function Ece(e){let t=Ol(e?.date);if(!t)return null;let{from:n,to:r}=t,i=e.dateEnd===void 0?null:Ol(e.dateEnd);if(i&&i.to>n&&(r=Math.max(r,i.to)),e.approx===!0){let e=t.to-t.from;n-=e,r+=e}return{from:n,to:r}}function Dce(e){let t=[],n=null;return(Array.isArray(e?.slots)?e.slots:[]).forEach((e,r)=>{let i=(Array.isArray(e?.events)?e.events:[]).map((e,t)=>({event:e,ei:t,span:Ece(e)})).filter(e=>e.span);if(i.length===0)return;let a={from:Math.min(...i.map(e=>e.span.from)),to:Math.max(...i.map(e=>e.span.to))};if(n&&a.to<=n.span.from){let e=i.find(e=>e.span.to<=n.span.from)??i[0];t.push(se(`note.dateOrder`,{at:`slots[${r}].events[${e.ei}]`,id:e.event.id,date:e.event.date,beforeAt:`slots[${n.si}].events[${n.ei}]`,beforeId:n.event.id,beforeDate:n.event.date}))}let o=i.reduce((e,t)=>t.span.to>e.span.to?t:e);n={span:a,si:r,ei:o.ei,event:o.event}}),t}function Oce(e){let t=Array.isArray(e?.actors)?e.actors:[],n=new Set;for(let t of Array.isArray(e?.slots)?e.slots:[])for(let e of Array.isArray(t?.events)?t.events:[])for(let t of Array.isArray(e?.actorIds)?e.actorIds:[])n.add(t);return t.map((e,t)=>({a:e,i:t})).filter(({a:e})=>e&&typeof e.id==`string`&&!n.has(e.id)).map(({a:e,i:t})=>se(`note.partyNoEvent`,{at:`actors[${t}]`,id:e.id,name:e.name??e.id}))}var kce=19,Ace=2,jce=18,kl=6,Mce=16,Nce=11.5,Al=1,Pce=.55;function jl(e){let t=e.codePointAt(0);return t>=4352&&t<=4447||t>=11904&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510?Al:Pce}function Ml(e){let t=0;for(let n of String(e??``))t+=jl(n);return t}var Nl=(e,t)=>Ml(e)*t,Fce=262/13;262/Nce;function Ice(e={},t=Ace,n=0){let r=22+kce*t+kl+Mce;return e.summary&&(r+=24),e.actors&&n>0&&(r+=jce*n+kl),r}function Pl(e,t,n={}){let r=n.latin??1,i=n.cjk??1;return Fl(e,t,e=>{let t=0;for(let n of e)t+=jl(n)*(jl(n)===Al?i:r);return t})}function Fl(e,t,n){let r=t,i=n,a=String(e??``);if(!a)return 0;let o=a.match(/[^\sᄀ-ᅟ⺀-가-힣豈-︰--⦆¢-₩]+|\s|./gu)||[],s=1,c=0;for(let e of o){let t=i(e);if(/^\s$/.test(e)){c>0&&(c+=t);continue}if(c+t<=r)c+=t;else if(t<=r)s+=+(c>0),c=t;else{c>0&&(s+=1);let e=Math.ceil(t/r);s+=e-1,c=t-(e-1)*r}}return s}var Il={SIDE1:`side1`,AXIS:`axis`,SIDE2:`side2`},Ll=3;function Rl(e){let t=(Array.isArray(e?.actors)?e.actors:[]).filter(e=>Bl(e)&&e.id);if(new Set(t.map(e=>e.id)).size<2)return e=>e?.groupId??null;let n=new Map(t.map(e=>[e.id,e.groupId])),r=(Array.isArray(e?.groups)?e.groups[2]?.id:null)??null;return e=>{let t=Array.isArray(e?.actorIds)?e.actorIds:[];return t.length===1&&n.get(t[0])||r}}var zl=/^\d{4}(-\d{2}(-\d{2}(T\d{2}(:\d{2}(:\d{2})?)?)?)?)?$/;function Lce(e,t){if(typeof e!=`string`||typeof t!=`string`)return!1;let n=Math.min(e.length,t.length);return e.slice(0,n)<t.slice(0,n)}var Rce=[Il.SIDE1,Il.SIDE2,Il.AXIS];function Bl(e){return e&&typeof e==`object`&&!Array.isArray(e)}function Vl(e){let t=[],n=Array.isArray(e?.actors)?e.actors:[],r=Array.isArray(e?.groups)?e.groups:[],i=Array.isArray(e?.sources)?e.sources:[],a=e?.slots,o={errors:t,byActor:!1,sideLabels:{[Il.SIDE1]:``,[Il.SIDE2]:``,[Il.AXIS]:``},columns:[],rows:[],placements:new Map,axisColumnIndex:0,actorById:new Map,groupById:new Map,groupIndexById:new Map,sourceById:new Map,eventCount:0},s=new Map;n.forEach((e,n)=>{if(!Bl(e)){t.push(se(`err.notObject`,{at:`actors[${n}]`}));return}if(!e.id){t.push(se(`err.required`,{at:`actors[${n}]`,field:`id`}));return}s.has(e.id)&&t.push(se(`err.duplicateId`,{at:`actors[${n}]`,id:e.id})),s.set(e.id,e),e.name||t.push(se(`err.required`,{at:`actors[${n}] (${e.id})`,field:`name`}))}),e?.views!==void 0&&t.push(se(`err.viewsRemoved`));let c=new Map,l=new Map;r.length>Ll&&t.push(se(`err.tooManyGroups`,{at:`groups`,max:Ll,actual:r.length})),r.forEach((e,n)=>{if(!Bl(e)){t.push(se(`err.notObject`,{at:`groups[${n}]`}));return}if(!e.id){t.push(se(`err.required`,{at:`groups[${n}]`,field:`id`}));return}l.has(e.id)&&t.push(se(`err.duplicateId`,{at:`groups[${n}]`,id:e.id})),c.set(e.id,e),l.set(e.id,n),e.label||t.push(se(`err.required`,{at:`groups[${n}] (${e.id})`,field:`label`}))});let u=s.size>=2,d=new Map;n.forEach((e,n)=>{if(!Bl(e)||!e.id)return;let r=`actors[${n}] (${e.id})`,i=e.groupId!==void 0&&e.groupId!==null&&e.groupId!==``;if(!u){i&&t.push(se(`err.actorGroupOneParty`,{at:r}));return}if(!i){t.push(se(`err.actorNeedsGroup`,{at:r,n:s.size}));return}if(!l.has(e.groupId)){t.push(se(`err.missingRef`,{at:r,field:`groupId`,kind:`group`,id:e.groupId}));return}let a=l.get(e.groupId);if(a>1){t.push(se(`err.actorGroupNotSide`,{at:r,groupId:e.groupId}));return}d.set(e.id,a===0?Il.SIDE1:Il.SIDE2)});let f=new Map;if(i.forEach((e,n)=>{if(!Bl(e)){t.push(se(`err.notObject`,{at:`sources[${n}]`}));return}if(!e.id){t.push(se(`err.required`,{at:`sources[${n}]`,field:`id`}));return}f.has(e.id)&&t.push(se(`err.duplicateId`,{at:`sources[${n}]`,id:e.id})),f.set(e.id,e),e.type||t.push(se(`err.required`,{at:`sources[${n}] (${e.id})`,field:`type`})),e.name||t.push(se(`err.required`,{at:`sources[${n}] (${e.id})`,field:`name`}))}),!Array.isArray(a))return t.push(se(`err.slotNotArray`)),{...o,actorById:s,groupById:c,groupIndexById:l,sourceById:f};a.length===0&&t.push(se(`err.slotsEmpty`));let p=new Set,m={[Il.SIDE1]:new Set,[Il.SIDE2]:new Set},h=[];a.forEach((e,n)=>{let r=`slots[${n}]`;if(!Bl(e)){t.push(se(`err.slotShape`,{at:r}));return}if(!Array.isArray(e.events)){t.push(se(`err.eventsNotArray`,{at:r}));return}e.events.length===0&&t.push(se(`err.slotEventsEmpty`,{at:r})),e.events.forEach((e,i)=>{let a=`${r}.events[${i}]${e?.id?` (${e.id})`:``}`;if(!Bl(e)){t.push(se(`err.notObject`,{at:a}));return}e.id?p.has(e.id)?t.push(se(`err.duplicateId`,{at:a,id:e.id})):p.add(e.id):t.push(se(`err.required`,{at:a,field:`id`})),e.date&&!zl.test(e.date)&&t.push(se(`err.badDate`,{at:a,field:`date`,value:e.date})),e.label||t.push(se(`err.required`,{at:a,field:`label`})),e.dateEnd!==void 0&&e.dateEnd!==null&&(typeof e.dateEnd!=`string`||!zl.test(e.dateEnd)?t.push(se(`err.badDate`,{at:a,field:`dateEnd`,value:e.dateEnd})):e.date?Lce(e.dateEnd,e.date)&&t.push(se(`err.dateEndBeforeDate`,{at:a,end:e.dateEnd,start:e.date})):t.push(se(`err.dateEndNeedsDate`,{at:a}))),e.summary!==void 0&&e.summary!==null&&(typeof e.summary==`string`?Ml(e.summary)>22.782608695652176&&t.push(se(`err.summaryTooLong`,{at:a,max:22,actual:Math.ceil(Ml(e.summary))})):t.push(se(`err.mustBeString`,{at:a,field:`summary`})));let o=Array.isArray(e.actorIds)?e.actorIds:[];o.forEach(e=>{s.has(e)||t.push(se(`err.missingRef`,{at:a,field:`actorIds`,kind:`actor`,id:e}))});let c=e.groupId!==void 0&&e.groupId!==null&&e.groupId!==``;u&&c?t.push(se(`err.eventGroupWithParties`,{at:a})):c&&!l.has(e.groupId)&&t.push(se(`err.missingRef`,{at:a,field:`groupId`,kind:`group`,id:e.groupId})),(Array.isArray(e.sourceIds)?e.sourceIds:[]).forEach(e=>{f.has(e)||t.push(se(`err.missingRef`,{at:a,field:`sourceIds`,kind:`source`,id:e}))});let g=c?l.get(e.groupId):void 0,_,v=null;if(u)o.length===1&&d.has(o[0])?(_=d.get(o[0]),v=o[0]):_=Il.AXIS;else if(o.length>=2)_=Il.AXIS,(g===0||g===1)&&t.push(se(`err.multiActorNeedsAxis`,{at:a,n:o.length,groupId:e.groupId}));else if(!c)_=Il.AXIS;else if(g===void 0)return;else _=Rce[g]??Il.AXIS;if(!u&&_!==Il.AXIS&&o.length!==1){t.push(se(`err.groupNeedsOneActor`,{at:a,groupId:e.groupId,n:o.length}));return}!u&&_!==Il.AXIS&&o.length===1&&(v=o[0]),v&&s.has(v)&&m[_].add(v),h.push({slotIndex:n,event:e,side:_,actorId:v})})});let g=n.map(e=>Bl(e)?e.id:null).filter(Boolean),_=e=>g.filter(t=>m[e].has(t)),v=e=>{let t=_(e),n=u&&g.filter(t=>d.get(t)===e).length>1;return t.length||!u?t.map(t=>({key:`${e}:${t}`,side:e,actorId:t,actorName:s.get(t)?.name,named:n})):[{key:e,side:e,actorId:null}]},y=[];y.push(...v(Il.SIDE1).reverse());let b=y.length;y.push({key:Il.AXIS,side:Il.AXIS}),y.push(...v(Il.SIDE2));let x=new Map(y.map((e,t)=>[e.key,t])),S=a.map((e,t)=>({index:t,cells:new Map})),C=new Map,w=0;return h.forEach(({slotIndex:e,event:n,side:r,actorId:i})=>{let a=r===Il.AXIS?Il.AXIS:`${r}:${i}`,o=x.get(a);if(o===void 0)return;w+=1;let s=S[e];if(s.cells.has(a)){let r=s.cells.get(a);t.push(se(`err.oneEventPerCell`,{at:`slots[${e}]`,a:r.id,b:n.id}))}else s.cells.set(a,n);C.set(n.id,{row:e,col:o,key:a})}),{errors:t,byActor:u,sideLabels:{[Il.SIDE1]:r[0]?.label??``,[Il.SIDE2]:r[1]?.label??``,[Il.AXIS]:r[2]?.label??``},columns:y,rows:S,placements:C,axisColumnIndex:b,actorById:s,groupById:c,groupIndexById:l,sourceById:f,eventCount:w}}function Hl(e){return e===Il.SIDE1?0:e===Il.SIDE2?1:2}function zce(e){let t=1;for(let n of e.rows)n.cells.forEach(e=>{let n=Ml(e.label||``);t=Math.max(t,Math.min(2,Math.ceil(n/Fce)))});return t}function Bce(e,t){if(!t.actors)return 0;let n=0;for(let t of e.rows)t.cells.forEach(t=>{let r=(Array.isArray(t.actorIds)?t.actorIds:[]).map(t=>e.actorById.get(t)?.name||t);if(r.length===0)return;let i=r.reduce((e,t)=>e+Nl(t,10)+14,0)+4*(r.length-1);n=Math.max(n,Math.ceil(i/262))});return n}function Ul(e,t){let n=new Set;return e.cells.forEach((e,r)=>{let i=t.columns.findIndex(e=>e.key===r);i>=0&&n.add(i)}),n}var Vce=.5;function Hce(e,t){if(!t)return e.rows.map((e,t)=>t);let n=e.rows.map(t=>Ul(t,e)),r=[];return n.forEach((e,t)=>{let i=t===0?0:r[t-1]+Vce;for(let a=0;a<t;a++)[...e].some(e=>n[a].has(e))&&(i=Math.max(i,r[a]+1));r.push(i)}),r}function Wl(e,t,n,r=!1){let i=e.columns.length,a=e.rows.length,o=zce(e),s=Bce(e,t),c=Ice(t,o,s),l=c+28,u=n?316:l,d=n?l:316,f=new Set;e.rows.forEach(e=>e.cells.forEach((e,t)=>f.add(t)));let p=[],m=0;e.columns.forEach(e=>{let t=f.has(e.key)?d:n?52:104;p.push({start:m,size:t}),m+=t});let h=n?150:0,g=n?0:96,_=n?u:d,v=n?d:u,y=r&&!n,b=Hce(e,y),x=a===0?0:(b[a-1]+1)*u,S=(e,t)=>n?{x:h+b[e]*u,y:p[t].start}:{x:p[t].start,y:g+b[e]*u},C=p[e.axisColumnIndex]??{start:0,size:d};return{isH:n,colCount:i,rowCount:a,labelLines:o,actorLines:s,cardH:c,cellH:l,slotExtent:u,laneExtent:d,lanes:p,originX:h,originY:g,cellBoxW:_,cellBoxH:v,cellAt:S,rowTops:b,timeSpan:x,staggered:y,axisCenter:C.start+C.size/2,contentW:n?h+x+6:m,contentH:n?m:g+x+6}}var Gl={draggable:!1,selectable:!1,connectable:!1,focusable:!1};function Uce(e,t,n){let r=(Array.isArray(e.actorIds)?e.actorIds:[]).map(e=>t.actorById.get(e)?.name||e),i=(Array.isArray(e.sourceIds)?e.sourceIds:[]).map(e=>t.sourceById.get(e)).filter(Boolean);return{event:e,actorNames:r,sources:i,sourceCount:i.length,row:n}}function Kl(e){return{id:`__cells__`,type:`cells`,position:{x:0,y:0},width:1,height:1,style:{pointerEvents:`none`},data:{cols:e.colCount,rows:e.rowCount,cellW:e.cellBoxW,cellH:e.cellBoxH,lanes:e.lanes,originX:e.originX,originY:e.originY,isH:e.isH},...Gl}}function ql(e,t){let n=t=>e.columns.filter(e=>e.side===t).length,r=t=>e.columns.findIndex(e=>e.side===t),i=[];return e.columns.forEach((a,o)=>{let s=n(a.side),c=a.side!==Il.AXIS&&(s>1||a.named),l=o===r(a.side),u={type:`colHeader`,...Gl},d={isH:t.isH,side:a.side,groupIndex:Hl(a.side)};if(!c){i.push({...u,id:`__head__${a.key}`,position:t.isH?{x:0,y:t.lanes[o].start}:{x:t.lanes[o].start,y:0},data:{...d,width:t.isH?150:t.lanes[o].size,height:t.isH?t.lanes[o].size:null,sideTitle:e.sideLabels[a.side],colTitle:null}});return}if(t.isH){i.push({...u,id:`__head__${a.key}`,position:{x:0,y:t.lanes[o].start},data:{...d,width:150,height:t.lanes[o].size,sideTitle:l?e.sideLabels[a.side]:null,colTitle:a.actorName}});return}if(!l)return;let f=e.columns.slice(o,o+s);i.push({...u,id:`__head__${a.key}`,position:{x:t.lanes[o].start,y:0},data:{...d,width:t.lanes.slice(o,o+s).reduce((e,t)=>e+t.size,0),height:null,sideTitle:e.sideLabels[a.side],colTitle:null,actors:f.map(e=>e.actorName),laneWs:t.lanes.slice(o,o+s).map(e=>e.size)}})}),i}function Wce(e,t){let n=e.rows.map(e=>t.rowTops[e.index]*t.slotExtent+t.slotExtent/2-5);return{id:`__axis__`,type:`axis`,position:t.isH?{x:t.originX,y:t.axisCenter-1}:{x:t.axisCenter-1,y:t.originY},data:{isH:t.isH,length:t.timeSpan,dotSize:10,dotOffsets:n},...Gl}}function Jl(e,t){return{id:`__links__`,type:`links`,position:{x:0,y:0},width:1,height:1,style:{pointerEvents:`none`},data:{segments:e,isH:t},...Gl}}function Gce(e,t,n,r,i,a){let o=i.cellAt(n,t),s=o.x+(i.cellBoxW-288)/2,c=o.y+(i.cellBoxH-i.cardH)/2,l=null;if(i.isH){let e=s+144;if(t<r.axisColumnIndex){let t=c+i.cardH;l={left:e,top:t,height:i.axisCenter-t}}else t>r.axisColumnIndex&&(l={left:e,top:i.axisCenter,height:c-i.axisCenter})}else{let e=c+i.cardH/2;if(t<r.axisColumnIndex){let t=s+288;l={left:t,top:e,width:i.axisCenter-t}}else t>r.axisColumnIndex&&(l={left:i.axisCenter,top:e,width:s-i.axisCenter})}return{node:{id:e.id,type:`card`,position:{x:s,y:c},data:{...Uce(e,r,n),groupIndex:Hl(r.columns[t].side),cardW:288,cardH:i.cardH,labelLines:i.labelLines,fields:a,isH:i.isH}},link:l}}function Yl(e,t={},n,r=`vertical`,{stagger:i=!1}={}){let a=r===`horizontal`,o=Vl(e),s=Wl(o,t,a,i),c=[Kl(s),...ql(o,s)],l=[],u=[];return o.rows.forEach(e=>{e.cells.forEach((n,r)=>{let i=o.columns.findIndex(e=>e.key===r);if(i<0)return;let{node:a,link:c}=Gce(n,i,e.index,o,s,t);l.push(a),c&&u.push(c)})}),u.length&&c.push(Jl(u,a)),c.push(Wce(o,s)),c.push(...l),{errors:o.errors,sideLabels:o.sideLabels,nodes:c,edges:[],grid:o,layout:`grid`,staggered:s.staggered,size:{width:s.contentW,height:s.contentH}}}function Xl(e,t,n){let[r,i]=String(e).split(`T`),a=t?oe(n,`card.approxPrefix`):``;if(!i)return a+r;let o=i.split(`:`);return`${a}${r} ${o.slice(0,2).join(`:`)}${o[2]?`:`+o[2]:``}`}function Zl(e,t,n){let r=Xl(t,!1,n);return String(e).split(`T`)[0]===String(t).split(`T`)[0]&&String(t).includes(`T`)?r.split(` `).pop():r}function Ql(e,t){if(!e.date)return oe(t,`card.dateUnknown`);let n=Xl(e.date,e.approx,t);return e.dateEnd?`${n} - ${Zl(e.date,e.dateEnd,t)}`:n}function $l(e,t,n=!1){if(!e.date)return[{text:oe(t,`chronicle.dateUnknown`),strong:!1}];let[r,i]=String(e.date).split(`T`),a=[{text:(e.approx?oe(t,`card.approxPrefix`):``)+r,strong:!0}],o=i?Xl(e.date,!1,t).split(` `).pop():``;n&&o&&a.shift();let s=!a.length;if(!e.dateEnd)return o&&a.push({text:o,strong:s}),a;let c=Zl(e.date,e.dateEnd,t);return o&&!c.includes(`-`)?a.push({text:`${o} – ${c}`,strong:s}):(o&&a.push({text:o,strong:s}),a.push({text:`– ${c}`,strong:!1})),a}var eu=12.5,tu=4,Kce=6,nu=10,qce=90,Jce={latin:1.2,cjk:1.06},Yce={latin:1.12,cjk:1.06},Xce={sameSlot:10,none:22,short:38,long:70},ru=864e5,Zce=/^(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2})(?::(\d{2})(?::(\d{2}))?)?)?)?)?$/;function iu(e){let t=typeof e==`string`?Zce.exec(e):null;if(!t)return null;let[,n,r,i,a,o,s]=t,c=a==null?i==null?r==null?`year`:`month`:`day`:`time`;return{y:+n,mo:r?+r:1,d:i?+i:1,h:a?+a:0,mi:o?+o:0,s:s?+s:0,prec:c}}var D={year:0,month:1,day:2,time:3},Qce=e=>Date.UTC(e.y,e.mo-1,e.d,e.h,e.mi,e.s);function $ce(e,t,n=!1){let r=iu(e),i=iu(t);if(!r||!i)return null;let a=D[r.prec]<=D[i.prec]?r.prec:i.prec,o=(e,t,r)=>({key:e,vars:t,long:r,approx:!!n});if(a===`year`||a===`month`){let e=a===`year`?(i.y-r.y)*12:(i.y-r.y)*12+(i.mo-r.mo);return e<=0?null:ou(e,o)}if(a===`time`){let e=Qce(i)-Qce(r);if(e<=0)return null;if(e<ru){let t=Math.round(e/1e3);if(t<60)return o(`chronicle.gapSeconds`,{n:t},!1);if(t<3600)return o(`chronicle.gapMinutes`,{n:Math.round(t/60)},!1);let n=Math.floor(t/3600),r=Math.round((t-n*3600)/60);return r===60&&(n+=1,r=0),r?o(`chronicle.gapHoursMinutes`,{h:n,m:r},!1):o(`chronicle.gapHours`,{n},!1)}return au(Math.floor(e/ru),o)}let s=Math.round((Date.UTC(i.y,i.mo-1,i.d)-Date.UTC(r.y,r.mo-1,r.d))/ru);return s<=0?null:au(s,o)}function ele(e){let t=(e,t,n)=>({key:e,vars:t,long:n,approx:!1});if(!(e>0))return null;if(e<ru){let n=Math.round(e/1e3);return n<60?t(`chronicle.gapSeconds`,{n},!1):n<3600?t(`chronicle.gapMinutes`,{n:Math.round(n/60)},!1):t(`chronicle.gapHours`,{n:Math.round(n/3600)},!1)}return au(Math.round(e/ru),t)}function au(e,t){return e<30?t(`chronicle.gapDays`,{n:e},!1):ou(Math.max(1,Math.round(e/30.44)),t)}function ou(e,t){let n=Math.floor(e/12),r=e%12;return n?r?t(`chronicle.gapYearsMonths`,{y:n,m:r},!0):t(`chronicle.gapYears`,{n},!0):t(`chronicle.gapMonths`,{n:r},!0)}var su=(e,t)=>e==null?t:t==null||e>t?e:t;function tle(e){let t=Array.isArray(e?.slots)?e.slots:[],n=[],r=null,i=!1,a=!1;return t.forEach((e,t)=>{let o=(Array.isArray(e?.events)?e.events:[]).filter(e=>e&&typeof e==`object`);if(!o.length)return;let s=o.every(e=>typeof e.date==`string`&&e.date),c=s?[...o].sort((e,t)=>e.date<t.date?-1:+(e.date>t.date)):o,l=c.find(e=>e.date)?.date??null,u=c.some(e=>e.date&&e.approx);c.forEach((e,o)=>{let c=o===0,d=null,f=`sameSlot`;c&&(n.length?(d=a&&s?$ce(r,l,i||u):null,f=d?d.long?`long`:`short`:`none`):f=`top`);let p=typeof e.date==`string`&&e.date.length>=10?e.date.slice(0,10):null,m=n.at(-1)?.event,h=!!(p&&m&&typeof m.date==`string`&&m.date.slice(0,10)===p&&!e.approx);n.push({event:e,slotIndex:t,first:c,gap:d,spacing:f,sameDay:h})}),a=s,r=null;for(let e of c)r=su(r,su(e.date,e.dateEnd));i=c.some(e=>e.approx)}),n}var cu=[`circle`,`square`,`diamond`];function lu(e,t){let n=(Array.isArray(e?.groups)?e.groups:[]).findIndex(n=>n?.id===Rl(e)(t));return n<0?`none`:cu[Math.min(n,2)]}function uu(e,t){let n=(Array.isArray(e?.groups)?e.groups:[]).findIndex(n=>n?.id===Rl(e)(t));return n>=0&&n<3?n:2}function nle(e,t,n,r){let i=[];if(n.actors)for(let t of Array.isArray(e.actorIds)?e.actorIds:[])i.push(Nl(r.get(t)?.name||t,10)+14);if(n.sources&&i.push(qce),!i.length)return 0;let a=1,o=0;for(let e of i){let t=o?nu+e:e;o&&o+t>532?(a+=1,o=e):o+=t}return a}function rle({titleLines:e,summaryLines:t,tagLines:n,whenLineCount:r=3}){let i=20+20*Math.max(1,e);return t&&(i+=tu+18*t),n&&(i+=Kce+20*n),Math.max(i,10+18*r)}function du(e,t,n){let r=(e,t,r,i)=>n?Fl(e,531,e=>n(e,t)):Pl(e,532/r,i);return{title:Math.max(1,r(e.label||``,`title`,14,Jce)),summary:t.summary&&e.summary?r(e.summary,`summary`,eu,Yce):0}}function ile(e,t={},{measure:n}={}){let r=new Map((e?.actors||[]).filter(Boolean).map(e=>[e.id,e])),i=new Map((e?.sources||[]).filter(Boolean).map(e=>[e.id,e])),a=(Array.isArray(e?.groups)?e.groups.slice(0,3):[]).map((e,t)=>({label:e?.label,groupIndex:t,shape:cu[t]})).filter(e=>e.label),o=tle(e),s=[],c=[],l=[],u=[],d=a.length?34:0,f=null;o.forEach((a,o)=>{let{event:p}=a;if(f!=null){let e=Xce[a.spacing]??Xce.none;a.gap&&(l.push({y:f+e/2,gap:a.gap}),a.gap.long&&u.push({y0:f,y1:f+e})),d=f+e}let{title:m,summary:h}=du(p,t,typeof n==`function`?n:null),g=nle(p,e,t,r),_=rle({titleLines:m,summaryLines:h,tagLines:g,whenLineCount:$l(p,`en`,a.sameDay).length}),v=uu(e,p),y=(Array.isArray(p.actorIds)?p.actorIds:[]).map(e=>r.get(e)?.name||e),b=(Array.isArray(p.sourceIds)?p.sourceIds:[]).map(e=>i.get(e)).filter(Boolean);s.push({id:p.id,type:`entry`,position:{x:0,y:d},width:758,height:_,draggable:!1,connectable:!1,data:{event:p,index:o,groupIndex:v,shape:lu(e,p),actorNames:y,sources:b,fields:t,lines:{title:m,summary:h,tags:g},sameDay:a.sameDay,cardH:_}}),c.push({y:d+20,groupIndex:v,shape:lu(e,p),hollow:!p.date}),f=d+_});let p=f??0,m=[];return o.length&&m.push({id:`__spine__`,type:`spine`,position:{x:0,y:0},width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,style:{pointerEvents:`none`},data:{x:174,top:c[0].y,bottom:c[c.length-1].y,dots:c,pills:l,breaks:u,dotSize:13}}),a.length&&m.push({id:`__legend__`,type:`legend`,position:{x:198,y:0},width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,data:{groups:a}}),m.push(...s),{errors:[],nodes:m,edges:[],items:o,eventCount:o.length,layout:`chronicle`,size:{width:758,height:p}}}var ale=12,fu=40,pu=12.5,ole={latin:1.2,cjk:1.06},mu=(e,t=1)=>16+17*e+2+15*t,hu=e=>e?.dateEnd&&Nl(Ql(e,`en`),11)*1.05>176?2:1,gu=mu(2,2)+10,sle=10,_u=22,cle=12,vu=e=>cle+Math.max(1,e)*gu+_u,yu=14,bu=864e5,xu=36e5;function Su(e){let t=iu(e?.date);if(!t)return null;let n=e=>Date.UTC(e.y,e.mo-1,e.d,e.h,e.mi,e.s),r=e=>e.prec===`year`?Date.UTC(e.y+1,0,1):e.prec===`month`?Date.UTC(e.y,e.mo,1):e.prec===`day`?Date.UTC(e.y,e.mo-1,e.d+1):n(e),i=n(t),a=iu(e?.dateEnd);return a&&r(a)>i?{from:i,to:r(a),kind:`bar`,exact:!0}:t.prec===`time`?{from:i,to:i,kind:`dot`,exact:!0}:{from:i,to:r(t),kind:`band`,exact:!1,prec:t.prec}}var lle=e=>{let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2};function Cu(e){let t=e.slice(1).map((t,n)=>t-e[n]),n=[],r=(e,n)=>{let r=[];for(let i=e+n;i>=0&&i<t.length&&r.length<3&&!(t[i]>=t[e]);i+=n)r.push(t[i]);return r};return t.forEach((e,t)=>{if(e<1728e5)return;let i=r(t,1);i.length||(i=r(t,-1)),i.length&&e/Math.max(lle(i),6e4)>=20&&n.push({i:t,g:e})}),n.sort((e,t)=>t.g-e.g).slice(0,2).map(e=>e.i).sort((e,t)=>e-t)}function ule(e){return e>730*bu?`year`:e>60*bu?`month`:e>2*bu?`day`:e>3*xu?`hour`:`minute`}function wu(e,t,n,r){let i=new Date(e),a=[],o={year:[1,2,5,10],month:[1,2,3,6],day:[1,2,7,14],hour:[1,2,3,6,12],minute:[1,2,5,10,15,30]}[n];for(let s of o){a.length=0;let o;o=n===`year`?Date.UTC(i.getUTCFullYear(),0,1):n===`month`?Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1):n===`day`?Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()):n===`hour`?Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),i.getUTCHours()):Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),i.getUTCHours(),i.getUTCMinutes());let c=0;for(;o<=t&&c++<2e3;){o>=e&&a.push(o);let t=new Date(o);n===`year`?o=Date.UTC(t.getUTCFullYear()+s,0,1):n===`month`?o=Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+s,1):o+=n===`day`?s*bu:n===`hour`?s*xu:s*6e4}if(a.length<=r)break}return[...a]}function Tu(e,t,n){let r=new Date(e),i=e=>String(e).padStart(2,`0`),a=`${i(r.getUTCMonth()+1)}-${i(r.getUTCDate())}`;if(t===`year`)return String(r.getUTCFullYear());if(t===`month`)return`${r.getUTCFullYear()}-${i(r.getUTCMonth()+1)}`;if(t===`day`)return a;let o=`${i(r.getUTCHours())}:${i(r.getUTCMinutes())}`;return n==null||new Date(n).getUTCDate()!==r.getUTCDate()?`${a} ${o}`:o}function Eu(e,t){let n=new Map,r=(Array.isArray(e?.actors)?e.actors:[]).filter(e=>e?.id);if(!t||r.length<2)return n;for(let t of Array.isArray(e?.groups)?e.groups.slice(0,2):[]){let e=r.filter(e=>t?.id&&e.groupId===t.id);e.length>=2&&n.set(t.id,e)}return n}function dle(e,{byParty:t=!1}={}){let n=Rl(e),r=Eu(e,t);return e=>{let t=n(e),i=Array.isArray(e?.actorIds)?e.actorIds:[];return i.length===1&&r.get(t)?.some(e=>e.id===i[0])?`actor:${i[0]}`:t}}function fle(e,t,{byParty:n=!1}={}){let r=dle(e,{byParty:n}),i=Eu(e,n),a=(Array.isArray(e?.groups)?e.groups.slice(0,3):[]).filter(e=>e&&e.id),o=new Set(t.map(r)),s=a.flatMap((e,t)=>{let n=i.get(e.id)?.filter(e=>o.has(`actor:${e.id}`));return n?.length?n.map(n=>({key:`actor:${n.id}`,label:n.name??``,side:e.label??``,groupIndex:t})):[{key:e.id,label:e.label??``,groupIndex:t}]}),c=new Set(s.map(e=>e.key));return t.some(e=>!c.has(r(e)))&&s.push({key:`__other__`,label:null,groupIndex:2,other:!0}),s}function ple(e,{levels:t=3,width:n=196,gap:r=sle}={}){let i=e.map(e=>({ids:[e.id],x:e.x,from:e.x,to:e.x}));for(;;){let e=mle(i,t,n,r);if(e)return e;let a=-1,o=1/0;for(let e=0;e+1<i.length;e++){let t=i[e+1].x-i[e].x;t<o&&(o=t,a=e)}if(a<0)return mle(i,t,n,r)??[];let s=i[a],c=i[a+1],l=[...s.ids,...c.ids],u=Math.min(s.from,c.from),d=Math.max(s.to,c.to);i.splice(a,2,{ids:l,x:(u+d)/2,from:u,to:d}),i=i.sort((e,t)=>e.x-t.x)}}function mle(e,t,n,r){let i=Array(t).fill(-1/0),a=[];for(let t of e){let e=t.x-n/2,o=i.findIndex(t=>t+r<=e);if(o<0)return null;i[o]=t.x+n/2,a.push({...t,level:o})}return a}function Du(e,t={},{measure:n,byParty:r=!1}={}){let i=new Map((e?.actors||[]).filter(Boolean).map(e=>[e.id,e])),a=new Map((e?.sources||[]).filter(Boolean).map(e=>[e.id,e])),o=[];(Array.isArray(e?.slots)?e.slots:[]).forEach((e,t)=>{for(let n of Array.isArray(e?.events)?e.events:[])n&&typeof n==`object`&&o.push({event:n,slotIndex:t})}),o.forEach(e=>e.time=Su(e.event)),o.forEach(e=>{e.time?.exact&&(e.time.t=e.time.from)});let s=e=>({before:o.slice(0,e).reverse().find(e=>e.time?.exact),after:o.slice(e+1).find(e=>e.time?.exact)}),c=o.filter(e=>e.time?.exact).map(e=>e.time.t),l=c.length>1?Math.max(6e4,(Math.max(...c)-Math.min(...c))/20):xu,u=(e,t,n)=>{let{before:r,after:i}=s(e),a;return a=r&&i?(r.time.t+i.time.t)/2:r?r.time.t+l:i?i.time.t-l:t==null?e*xu:(t+n)/2,t==null?a:Math.min(Math.max(a,t),n-1)};o.forEach((e,t)=>{e.time&&!e.time.exact&&(e.time.t=u(t,e.time.from,e.time.to))}),o.forEach((e,t)=>{if(e.time)return;let n=o.slice(0,t).reverse().find(e=>e.time),r=o.slice(t+1).find(e=>e.time),i=n&&r?(n.time.t+r.time.t)/2:n?n.time.t+l:r?r.time.t-l:t*xu;e.time={t:i,from:i,to:i,kind:`dot`,undated:!0}});let d=[...new Set(o.map(e=>e.time.t))].sort((e,t)=>e-t),f=[...new Set(o.filter(e=>!e.time.undated).map(e=>e.time.t))].sort((e,t)=>e-t),p=f.length?f:d,m=Cu(p),h=[],g=0;for(let e of m)h.push([p[g],p[e]]),g=e+1;h.push([p[g],p[p.length-1]]),h[0][0]=Math.min(h[0][0],d[0]),h[h.length-1][1]=Math.max(h[h.length-1][1],d[d.length-1]);let _=e=>{let t=h.findIndex(([,t])=>e<=t);return t<0?h.length-1:t},v=h.map(([e,t],n)=>({index:n,from:e,to:t,count:o.filter(e=>_(e.time.t)===n).length,unit:t>e?ule(t-e):`day`})),y=e=>Nl(e,ale)*1.06,b=fle(e,o.map(e=>e.event),{byParty:r}).flatMap(e=>[e.label||``,e.side||``]),x=Math.round(Math.min(196,Math.max(132,...b.map(e=>y(e)+fu)))),S=x;v.forEach((e,t)=>{if(t>0){let n=e.from-v[t-1].to;e.breakBefore={x:S,w:64,gap:ele(n)},S+=64}e.x0=S,e.w=Math.max(170,e.count*116),e.x1=S+e.w,S=e.x1});let C=S,w=e=>{let t=v[_(e)],n=t.w-196;return t.to===t.from?t.x0+t.w/2:t.x0+98+(Math.min(Math.max(e,t.from),t.to)-t.from)/(t.to-t.from)*n},T=(e,t)=>Math.min(Math.max(e,v[t].from),v[t].to),ee=fle(e,o.map(e=>e.event),{byParty:r}),te=dle(e,{byParty:r}),ne=e=>{let t=ee.findIndex(t=>t.key===te(e));return t>=0?t:ee.length-1},re=[],ie=[],ae=e=>re[e],se=e=>re[e]+ie[e],ce=o.map((e,t)=>{let n=_(e.time.t),r=e.time.kind,i=w(r===`dot`?e.time.t:T(e.time.from,n)),a=r===`dot`?i:w(T(e.time.to,n)),o=r===`bar`?i:w(e.time.t),s=v[n],c=r===`band`&&s.to>s.from&&e.time.to-e.time.from>s.to-s.from,l=r===`band`&&(c||a-i<8)?`dot`:r;return l===`dot`?i=a=o:a-i<6&&(a=i+6),{id:e.event.id,order:t,lane:ne(e.event),kind:l,x:o,x0:i,x1:a,undated:!!e.time.undated,coarse:c,prec:e.time.prec,event:e.event}}),le=new Map;for(let e of ce){let t=`${e.lane}:${Math.round(e.x)}`;e.stack=le.get(t)??0,le.set(t,e.stack+1)}let ue=e=>Math.min(2,Math.max(1,n?Fl(e,173,e=>n(e,`title`)):Pl(e,176/pu,ole))),de=[],fe=[],pe=ee.map((e,t)=>{let n=ce.filter(e=>e.lane===t).sort((e,t)=>e.x-t.x||e.order-t.order),r=e=>Math.min(Math.max(e,x+4+98),C-98);return ple(n.map(e=>({id:e.id,x:r(e.x)})))}),me=0;pe.forEach((e,t)=>{re[t]=me,ie[t]=e.length?vu(Math.max(0,...e.map(e=>e.level))+1):34,me+=ie[t]}),pe.forEach((e,t)=>{let n=e=>{let t=e.ids.map(e=>ce.find(t=>t.id===e).x);return(Math.min(...t)+Math.max(...t))/2};for(let r of e){let e=r.x-98,i=r.ids.map(e=>ce.find(t=>t.id===e)).sort((e,t)=>e.order-t.order),a=i.length>1,o=a?1:ue(i[0].event.label||``),s=a?1:i[0].undated?Nl(oe(`en`,`scale.undated`),11)*1.05>176?2:1:hu(i[0].event),c=mu(o,s),l=se(t)-_u-r.level*gu,u={id:a?`__run__${fe.length+1}`:i[0].id,lane:t,level:r.level,x:e,y:l-c,w:196,h:c,titleLines:o,timeLines:s,anchor:n(r),members:i};a&&(u.run=fe.length+1,u.span=[Math.min(...i.map(e=>e.x0)),Math.max(...i.map(e=>e.x1))],fe.push(u)),de.push(u)}});let he=re.length?re[re.length-1]+ie[ie.length-1]:0,ge=he+14,_e=v.flatMap(e=>{let t=Math.max(2,Math.floor(e.w/84)),n=e.to>e.from?wu(e.from,e.to,e.unit,t):[],r=e.unit;return n.length||(n=e.to>e.from?[e.from,e.to]:[e.from],r=e.to>e.from?`minute`:`day`),n.map((e,t)=>({x:w(e),label:Tu(e,r,t?n[t-1]:null)}))}),ve=fe.reduce((e,t)=>e+1+t.members.length,0),ye=fe.length?yu+ve*18:0,be=he+56+ye,xe=e=>ee[ne(e)].groupIndex,Se=[{id:`__scale__`,type:`scaleLayer`,position:{x:0,y:0},width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,style:{pointerEvents:`none`},data:{width:C,labelW:x,lanesH:he,axisY:ge,lanes:ee.map((e,t)=>({...e,top:ae(t),lineY:se(t)})),segments:v,ticks:_e,marks:ce.map(e=>({id:e.id,kind:e.kind,x:e.x,x0:e.x0,x1:e.x1,y:se(e.lane)-e.stack*12,undated:e.undated,coarse:e.coarse,prec:e.prec,approx:!!e.event.approx,groupIndex:ee[e.lane].groupIndex})),leaders:de.map(e=>({x:Math.min(Math.max(e.anchor,e.x+8),e.x+e.w-8),y0:e.y+e.h,y1:se(e.lane)-6,run:!!e.run})),brackets:fe.map(e=>({x0:e.span[0],x1:e.span[1],y:se(e.lane)+9,run:e.run}))}}];for(let e of de)Se.push({id:e.id,type:e.run?`scaleRun`:`scaleCard`,position:{x:e.x,y:e.y},width:e.w,height:e.h,draggable:!1,connectable:!1,data:e.run?{run:e.run,events:e.members.map(e=>e.event),groupIndex:ee[e.lane].groupIndex,cardH:e.h}:{event:e.members[0].event,undated:e.members[0].undated,groupIndex:xe(e.members[0].event),titleLines:e.titleLines,timeLines:e.timeLines,cardH:e.h,actorNames:(Array.isArray(e.members[0].event.actorIds)?e.members[0].event.actorIds:[]).map(e=>i.get(e)?.name||e),sources:(Array.isArray(e.members[0].event.sourceIds)?e.members[0].event.sourceIds:[]).map(e=>a.get(e)).filter(Boolean)}});return fe.length&&Se.push({id:`__runs__`,type:`scaleRunList`,position:{x,y:he+56+yu},width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,data:{runs:fe.map(e=>({run:e.run,events:e.members.map(e=>e.event)})),width:C-x,lh:18}}),{errors:[],nodes:Se,edges:[],layout:`scale`,eventCount:o.length,segments:v,gathered:fe.map(e=>({run:e.run,ids:e.members.map(e=>e.id)})),cards:de.map(e=>({id:e.id,lane:e.lane,level:e.level,x:e.x,y:e.y,w:e.w,h:e.h,ids:e.members.map(e=>e.id)})),undated:ce.filter(e=>e.undated).length,labelW:x,size:{width:C,height:be}}}function Ou(e,t){if(!e||!t||!e.width||!e.height)return 1;let n=t.width/(e.width*1.12),r=t.height/(e.height*1.12);return Math.min(n,r,1)}function hle(e,t){return!e||!t||!e.width?1:Math.min(t.width/(e.width*1.12),1)}var ku={width:1600,height:900},Au=(e,t)=>Math.round(e*Math.min(t,1)*10)/10;function ju(e,t){let n=`Text on one screen (${e.canvas.width}×${e.canvas.height})`,r=Au(e.font,e.open.fit),i=Au(e.font,e.other.fit),a=e=>e.toFixed(1),o=[];e.open.fit>=1&&e.other.fit>=1?o.push(`${n}: full size (${e.font} px) either way.`):o.push(`${n}: ${a(r)} px as it opens (${e.open.name}), ${a(i)} px ${e.other.name}. Full size is ${e.font} px.`);let s=Math.max(r,i);if(s<9?o.push(`Note: the text is too small to read without zooming in (under 9 px). Consider ${t}; do not drop facts to make it fit.`):s<11&&o.push(`Note: the text is small (under 11 px); the reader can zoom in. ${t[0].toUpperCase()}${t.slice(1)} would make it easier to read.`),e.folded!==void 0&&s<11){let t=e.folded>=1?`full size (${e.font} px)`:`${a(Au(e.font,e.folded))} px`;o.push(`With every issue folded the text is ${t}: the reader can fold issues ("Fold issues" in the bar) instead of your splitting it.`)}return o}var Mu={envelope:[{name:`type`,req:`yes`,ty:`string`,note:`always "fact"`},Dl(2),{name:`title`,req:`yes`,ty:`string`,note:`diagram title, shown at the top left`}],actors:[{name:`id`,req:`yes`,ty:`string`,note:`unique within the diagram; events reference it via actorIds`},{name:`name`,req:`yes`,ty:`string`,note:`display name, e.g. "Huayuan Trading"`},{name:`role`,req:`no`,ty:`string`,note:`procedural standing, e.g. "plaintiff"`},{name:`groupId`,req:`*`,ty:`string`,note:`the side this party is on: the 1st or the 2nd group. Required with 2 or more parties; not written with one`}],groups:[{name:`id`,req:`yes`,ty:`string`,note:`parties (2 or more) or events (one party) reference it via groupId`},{name:`label`,req:`yes`,ty:`string`,note:`column heading, e.g. "Sun Hao's side" (parties) or "performance as agreed" (one party's acts)`},{name:``,req:``,ty:``,note:`at most 3: the 1st on the left (top) side, the 2nd on the right (bottom) side, the 3rd on the axis`},{name:``,req:``,ty:``,note:`2 or more parties: the groups split the parties. 0 or 1 party: they split the events by kind of act`}],sources:[{name:`id`,req:`yes`,ty:`string`,note:`events reference it via sourceIds`},{name:`type`,req:`yes`,ty:`string`,note:`contract / evidence / judgment / transcript, etc.`},{name:`name`,req:`yes`,ty:`string`,note:`material name, e.g. "corridor surveillance video"`},{name:`loc`,req:`no`,ty:`object`,note:`location, e.g. { file, page } or { file, timestamp }`},{name:`quote`,req:`no`,ty:`string`,note:`verbatim excerpt (several passages joined with ……), shown when the card is opened; a shortened or reworded version goes in detail`}],slots:[{name:`events`,req:`yes`,ty:`array`,note:`events at this time point; must not be empty`},{name:``,req:``,ty:``,note:`array order is chronological order; date is display-only and never reorders`}],events:[{name:`id`,req:`yes`,ty:`string`,note:`unique within the diagram`},{name:`date`,req:`no`,ty:`string`,note:`ISO 8601. Go to seconds when known, otherwise stop at the day. **Leave it out when the material gives no date: never make one up.** The card then says the date is unknown; the order is the order of slots, so nothing moves`},{name:`label`,req:`yes`,ty:`string`,note:`card title; about 20 characters per line, at most two lines`},{name:`dateEnd`,req:`no`,ty:`string`,note:`for a span, the end instant; needs date, and must not be earlier than it`},{name:`approx`,req:`no`,ty:`boolean`,note:`time is not exact (estimated or inferred); the diagram shows "approx."`},{name:`dateNote`,req:`no`,ty:`string`,note:`why the time is not exact, and how it was derived`},{name:`summary`,req:`no`,ty:`string`,note:`the line under the card title; about 22 characters`},{name:`detail`,req:`no`,ty:`string`,note:`full text revealed when the card is opened`},{name:`actorIds`,req:`no`,ty:`string[]`,note:`parties involved. One: that party's side and column. Two or more, or none: the centre axis`},{name:`groupId`,req:`*`,ty:`string`,note:`only when the diagram has 0 or 1 party: which side this event falls on. With 2 or more parties, leave it out`},{name:`sourceIds`,req:`no`,ty:`string[]`,note:`which materials it rests on`}]};function Nu(){let e=[`Fields of a fact spec. "yes" means required.`,``];for(let[t,n]of Object.entries(Mu)){e.push(`[${t}]`);for(let t of n){if(!t.name){e.push(` · ${t.note}`);continue}e.push(` ${t.name.padEnd(12)} ${t.req.padEnd(3)} ${t.ty.padEnd(15)} ${t.note}`)}e.push(``)}return e.push(`"*": required or not depending on the number of parties, as the note says.`),e.push(`Cross-field rules (dangling references, a span running backwards, a party without a`),e.push(`side, two events in the same lane of one time slot) are not listed`),e.push(`above: call antu_validate after writing. It reports each problem with its field path.`),e.join(`
|
|
1492
|
+
`}var hce=class{constructor(t=e.stdin,n=e.stdout,r){this._stdin=t,this._stdout=n,this._started=!1,this._ondata=e=>{try{this._readBuffer.append(e),this.processReadBuffer()}catch(e){this.onerror?.(e),this.close().catch(()=>{})}},this._onerror=e=>{this.onerror?.(e)},this._readBuffer=new fce({maxBufferSize:r?.maxBufferSize})}async start(){if(this._started)throw Error(`StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this._started=!0,this._stdin.on(`data`,this._ondata),this._stdin.on(`error`,this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off(`data`,this._ondata),this._stdin.off(`error`,this._onerror),this._stdin.listenerCount(`data`)===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(t=>{let n=mce(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}},gl=`/*ANTU_SPEC*/null`;function _l(e){return String(e).replace(/</g,`\\u003c`)}function gce(e,t,{preset:n}={}){if(e.split(`/*ANTU_SPEC*/null`).length!==2)throw Error(`the viewer template does not hold exactly one ${gl}`);let r=_l(JSON.stringify(t)),i=n?`;window.__ANTU_PRESET__ = ${_l(JSON.stringify(n))}`:``;return e.replace(gl,()=>r+i)}f(u(h(import.meta.url)),`../..`);var vl=f(u(h(import.meta.url)),`..`);d(vl,`dist-engine/engine.js`),d(vl,`dist-engine/engine.css`);function _ce(e){return String(e).replace(/[&<>"]/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e])}function yl(){return`0.13.1`}function vce(e){return String(e||`antu`).replace(/[\\/:*?"<>|\s]+/g,`-`).slice(0,60)}function yce(e,{preset:t,force:n=!1,quiet:r=!1}={}){{let n=_ce(e?.title||`Antu`);return gce(i(d(vl,`assets/viewer.html`),`utf8`),e,{preset:t}).replace(/<title>[^<]*<\/title>/,()=>`<title>${n} · Antu</title>`)}}function bce(e,{outPath:t,preset:r,force:i=!1,quiet:a=!1}={}){let o=yce(e,{preset:r,force:i,quiet:a}),s=f(t||`${vce(e?.title)}.html`);return n(u(s),{recursive:!0}),c(s,o),{path:s,bytes:Buffer.byteLength(o)}}var bl=new Map,xl=[`experimental`,`stable`,`deprecated`];function Sl(e,t){if(!e)throw Error(`registerKnowledge: type must not be empty`);if(!t?.validate)throw Error(`registerKnowledge: validate is required`);if(!t?.describe)throw Error(`registerKnowledge: describe is required (the agent-facing field table)`);if(!Number.isInteger(t.specVersion)||t.specVersion<1)throw Error(`registerKnowledge: specVersion is required, a whole number (the generation of this type's JSON format, core/specVersion.js)`);Cl(e,t),bl.set(e,t)}function Cl(e,t){let n=Object.keys(t.layouts??{}),r=Object.keys(t.diagrams??{});for(let t of n)if(!r.includes(t))throw Error(`registerKnowledge: ${e}/${t} has a layout but no entry in diagrams (version, status, since)`);for(let t of r)if(!n.includes(t))throw Error(`registerKnowledge: ${e}/${t} is in diagrams but has no layout`);for(let[n,r]of Object.entries(t.diagrams??{})){if(!Number.isInteger(r.version)||r.version<1)throw Error(`registerKnowledge: ${e}/${n}: version must be a whole number >= 1`);if(!xl.includes(r.status))throw Error(`registerKnowledge: ${e}/${n}: status must be one of ${xl.join(`, `)}`);if(!/^\d+\.\d+\.\d+$/.test(r.since??``))throw Error(`registerKnowledge: ${e}/${n}: since must be a release number such as 0.7.0`)}}function xce(e){let t=bl.get(e);return Object.entries(t?.diagrams??{}).map(([t,n])=>({type:e,kind:t,...n}))}function wl(e){return bl.get(e)}function Tl(){return[...bl.entries()].map(([e,t])=>({type:e,labelKey:t.label??`graphType.${e}`}))}function Sce(e){return bl.get(e)?.validate}function Cce(e,t){let n=bl.get(e)?.layouts;if(n)return t&&n[t]?n[t]:Object.values(n)[0]}function El(e){return Object.keys(bl.get(e)?.layouts??{})}var Dl=e=>({name:`specVersion`,req:`no`,ty:`integer`,note:`which generation of this format the file follows (now ${e}); omit = the current one. Write it: it is how an older file is recognised after a breaking change`});function wce(e,t){return e.specVersion===void 0?null:!Number.isInteger(e.specVersion)||e.specVersion<1?{key:`err.specVersionForm`,params:{value:JSON.stringify(e.specVersion)}}:Number.isInteger(t)&&e.specVersion>t?{key:`err.specVersionNewer`,params:{value:e.specVersion,known:t,type:e.type}}:null}var Tce=/^(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}))?)?)?)?$/;function Ol(e){let t=Tce.exec(typeof e==`string`?e.trim():``);if(!t)return null;let[n,r,i,a,o,s]=t.slice(1).map(e=>e===void 0?void 0:Number(e)),c=(e,t,n,r,i,a)=>Date.UTC(e,t,n,r,i,a),l,u;return r===void 0?(l=c(n,0,1,0,0,0),u=c(n+1,0,1,0,0,0)):i===void 0?(l=c(n,r-1,1,0,0,0),u=c(n,r,1,0,0,0)):a===void 0?(l=c(n,r-1,i,0,0,0),u=c(n,r-1,i+1,0,0,0)):s===void 0?(l=c(n,r-1,i,a,o,0),u=l+6e4):(l=c(n,r-1,i,a,o,s),u=l+1e3),Number.isNaN(l)?null:{from:l,to:u}}function Ece(e){let t=Ol(e?.date);if(!t)return null;let{from:n,to:r}=t,i=e.dateEnd===void 0?null:Ol(e.dateEnd);if(i&&i.to>n&&(r=Math.max(r,i.to)),e.approx===!0){let e=t.to-t.from;n-=e,r+=e}return{from:n,to:r}}function Dce(e){let t=[],n=null;return(Array.isArray(e?.slots)?e.slots:[]).forEach((e,r)=>{let i=(Array.isArray(e?.events)?e.events:[]).map((e,t)=>({event:e,ei:t,span:Ece(e)})).filter(e=>e.span);if(i.length===0)return;let a={from:Math.min(...i.map(e=>e.span.from)),to:Math.max(...i.map(e=>e.span.to))};if(n&&a.to<=n.span.from){let e=i.find(e=>e.span.to<=n.span.from)??i[0];t.push(se(`note.dateOrder`,{at:`slots[${r}].events[${e.ei}]`,id:e.event.id,date:e.event.date,beforeAt:`slots[${n.si}].events[${n.ei}]`,beforeId:n.event.id,beforeDate:n.event.date}))}let o=i.reduce((e,t)=>t.span.to>e.span.to?t:e);n={span:a,si:r,ei:o.ei,event:o.event}}),t}function Oce(e){let t=Array.isArray(e?.actors)?e.actors:[],n=new Set;for(let t of Array.isArray(e?.slots)?e.slots:[])for(let e of Array.isArray(t?.events)?t.events:[])for(let t of Array.isArray(e?.actorIds)?e.actorIds:[])n.add(t);return t.map((e,t)=>({a:e,i:t})).filter(({a:e})=>e&&typeof e.id==`string`&&!n.has(e.id)).map(({a:e,i:t})=>se(`note.partyNoEvent`,{at:`actors[${t}]`,id:e.id,name:e.name??e.id}))}var kce=19,Ace=2,jce=18,kl=6,Mce=16,Nce=11.5,Al=1,Pce=.55;function jl(e){let t=e.codePointAt(0);return t>=4352&&t<=4447||t>=11904&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510?Al:Pce}function Ml(e){let t=0;for(let n of String(e??``))t+=jl(n);return t}var Nl=(e,t)=>Ml(e)*t,Fce=262/13;262/Nce;function Ice(e={},t=Ace,n=0){let r=22+kce*t+kl+Mce;return e.summary&&(r+=24),e.actors&&n>0&&(r+=jce*n+kl),r}function Pl(e,t,n={}){let r=n.latin??1,i=n.cjk??1;return Fl(e,t,e=>{let t=0;for(let n of e)t+=jl(n)*(jl(n)===Al?i:r);return t})}function Fl(e,t,n){let r=t,i=n,a=String(e??``);if(!a)return 0;let o=a.match(/[^\sᄀ-ᅟ⺀-가-힣豈-︰--⦆¢-₩]+|\s|./gu)||[],s=1,c=0;for(let e of o){let t=i(e);if(/^\s$/.test(e)){c>0&&(c+=t);continue}if(c+t<=r)c+=t;else if(t<=r)s+=+(c>0),c=t;else{c>0&&(s+=1);let e=Math.ceil(t/r);s+=e-1,c=t-(e-1)*r}}return s}var Il={SIDE1:`side1`,AXIS:`axis`,SIDE2:`side2`},Ll=3;function Rl(e){let t=(Array.isArray(e?.actors)?e.actors:[]).filter(e=>Bl(e)&&e.id);if(new Set(t.map(e=>e.id)).size<2)return e=>e?.groupId??null;let n=new Map(t.map(e=>[e.id,e.groupId])),r=(Array.isArray(e?.groups)?e.groups[2]?.id:null)??null;return e=>{let t=Array.isArray(e?.actorIds)?e.actorIds:[];return t.length===1&&n.get(t[0])||r}}var zl=/^\d{4}(-\d{2}(-\d{2}(T\d{2}(:\d{2}(:\d{2})?)?)?)?)?$/;function Lce(e,t){if(typeof e!=`string`||typeof t!=`string`)return!1;let n=Math.min(e.length,t.length);return e.slice(0,n)<t.slice(0,n)}var Rce=[Il.SIDE1,Il.SIDE2,Il.AXIS];function Bl(e){return e&&typeof e==`object`&&!Array.isArray(e)}function Vl(e){let t=[],n=Array.isArray(e?.actors)?e.actors:[],r=Array.isArray(e?.groups)?e.groups:[],i=Array.isArray(e?.sources)?e.sources:[],a=e?.slots,o={errors:t,byActor:!1,sideLabels:{[Il.SIDE1]:``,[Il.SIDE2]:``,[Il.AXIS]:``},columns:[],rows:[],placements:new Map,axisColumnIndex:0,actorById:new Map,groupById:new Map,groupIndexById:new Map,sourceById:new Map,eventCount:0},s=new Map;n.forEach((e,n)=>{if(!Bl(e)){t.push(se(`err.notObject`,{at:`actors[${n}]`}));return}if(!e.id){t.push(se(`err.required`,{at:`actors[${n}]`,field:`id`}));return}s.has(e.id)&&t.push(se(`err.duplicateId`,{at:`actors[${n}]`,id:e.id})),s.set(e.id,e),e.name||t.push(se(`err.required`,{at:`actors[${n}] (${e.id})`,field:`name`}))}),e?.views!==void 0&&t.push(se(`err.viewsRemoved`));let c=new Map,l=new Map;r.length>Ll&&t.push(se(`err.tooManyGroups`,{at:`groups`,max:Ll,actual:r.length})),r.forEach((e,n)=>{if(!Bl(e)){t.push(se(`err.notObject`,{at:`groups[${n}]`}));return}if(!e.id){t.push(se(`err.required`,{at:`groups[${n}]`,field:`id`}));return}l.has(e.id)&&t.push(se(`err.duplicateId`,{at:`groups[${n}]`,id:e.id})),c.set(e.id,e),l.set(e.id,n),e.label||t.push(se(`err.required`,{at:`groups[${n}] (${e.id})`,field:`label`}))});let u=s.size>=2,d=new Map;n.forEach((e,n)=>{if(!Bl(e)||!e.id)return;let r=`actors[${n}] (${e.id})`,i=e.groupId!==void 0&&e.groupId!==null&&e.groupId!==``;if(!u){i&&t.push(se(`err.actorGroupOneParty`,{at:r}));return}if(!i){t.push(se(`err.actorNeedsGroup`,{at:r,n:s.size}));return}if(!l.has(e.groupId)){t.push(se(`err.missingRef`,{at:r,field:`groupId`,kind:`group`,id:e.groupId}));return}let a=l.get(e.groupId);if(a>1){t.push(se(`err.actorGroupNotSide`,{at:r,groupId:e.groupId}));return}d.set(e.id,a===0?Il.SIDE1:Il.SIDE2)});let f=new Map;if(i.forEach((e,n)=>{if(!Bl(e)){t.push(se(`err.notObject`,{at:`sources[${n}]`}));return}if(!e.id){t.push(se(`err.required`,{at:`sources[${n}]`,field:`id`}));return}f.has(e.id)&&t.push(se(`err.duplicateId`,{at:`sources[${n}]`,id:e.id})),f.set(e.id,e),e.type||t.push(se(`err.required`,{at:`sources[${n}] (${e.id})`,field:`type`})),e.name||t.push(se(`err.required`,{at:`sources[${n}] (${e.id})`,field:`name`}))}),!Array.isArray(a))return t.push(se(`err.slotNotArray`)),{...o,actorById:s,groupById:c,groupIndexById:l,sourceById:f};a.length===0&&t.push(se(`err.slotsEmpty`));let p=new Set,m={[Il.SIDE1]:new Set,[Il.SIDE2]:new Set},h=[];a.forEach((e,n)=>{let r=`slots[${n}]`;if(!Bl(e)){t.push(se(`err.slotShape`,{at:r}));return}if(!Array.isArray(e.events)){t.push(se(`err.eventsNotArray`,{at:r}));return}e.events.length===0&&t.push(se(`err.slotEventsEmpty`,{at:r})),e.events.forEach((e,i)=>{let a=`${r}.events[${i}]${e?.id?` (${e.id})`:``}`;if(!Bl(e)){t.push(se(`err.notObject`,{at:a}));return}e.id?p.has(e.id)?t.push(se(`err.duplicateId`,{at:a,id:e.id})):p.add(e.id):t.push(se(`err.required`,{at:a,field:`id`})),e.date&&!zl.test(e.date)&&t.push(se(`err.badDate`,{at:a,field:`date`,value:e.date})),e.label||t.push(se(`err.required`,{at:a,field:`label`})),e.dateEnd!==void 0&&e.dateEnd!==null&&(typeof e.dateEnd!=`string`||!zl.test(e.dateEnd)?t.push(se(`err.badDate`,{at:a,field:`dateEnd`,value:e.dateEnd})):e.date?Lce(e.dateEnd,e.date)&&t.push(se(`err.dateEndBeforeDate`,{at:a,end:e.dateEnd,start:e.date})):t.push(se(`err.dateEndNeedsDate`,{at:a}))),e.summary!==void 0&&e.summary!==null&&(typeof e.summary==`string`?Ml(e.summary)>22.782608695652176&&t.push(se(`err.summaryTooLong`,{at:a,max:22,actual:Math.ceil(Ml(e.summary))})):t.push(se(`err.mustBeString`,{at:a,field:`summary`})));let o=Array.isArray(e.actorIds)?e.actorIds:[];o.forEach(e=>{s.has(e)||t.push(se(`err.missingRef`,{at:a,field:`actorIds`,kind:`actor`,id:e}))});let c=e.groupId!==void 0&&e.groupId!==null&&e.groupId!==``;u&&c?t.push(se(`err.eventGroupWithParties`,{at:a})):c&&!l.has(e.groupId)&&t.push(se(`err.missingRef`,{at:a,field:`groupId`,kind:`group`,id:e.groupId})),(Array.isArray(e.sourceIds)?e.sourceIds:[]).forEach(e=>{f.has(e)||t.push(se(`err.missingRef`,{at:a,field:`sourceIds`,kind:`source`,id:e}))});let g=c?l.get(e.groupId):void 0,_,v=null;if(u)o.length===1&&d.has(o[0])?(_=d.get(o[0]),v=o[0]):_=Il.AXIS;else if(o.length>=2)_=Il.AXIS,(g===0||g===1)&&t.push(se(`err.multiActorNeedsAxis`,{at:a,n:o.length,groupId:e.groupId}));else if(!c)_=Il.AXIS;else if(g===void 0)return;else _=Rce[g]??Il.AXIS;if(!u&&_!==Il.AXIS&&o.length!==1){t.push(se(`err.groupNeedsOneActor`,{at:a,groupId:e.groupId,n:o.length}));return}!u&&_!==Il.AXIS&&o.length===1&&(v=o[0]),v&&s.has(v)&&m[_].add(v),h.push({slotIndex:n,event:e,side:_,actorId:v})})});let g=n.map(e=>Bl(e)?e.id:null).filter(Boolean),_=e=>g.filter(t=>m[e].has(t)),v=e=>{let t=_(e),n=u&&g.filter(t=>d.get(t)===e).length>1;return t.length||!u?t.map(t=>({key:`${e}:${t}`,side:e,actorId:t,actorName:s.get(t)?.name,named:n})):[{key:e,side:e,actorId:null}]},y=[];y.push(...v(Il.SIDE1).reverse());let b=y.length;y.push({key:Il.AXIS,side:Il.AXIS}),y.push(...v(Il.SIDE2));let x=new Map(y.map((e,t)=>[e.key,t])),S=a.map((e,t)=>({index:t,cells:new Map})),C=new Map,w=0;return h.forEach(({slotIndex:e,event:n,side:r,actorId:i})=>{let a=r===Il.AXIS?Il.AXIS:`${r}:${i}`,o=x.get(a);if(o===void 0)return;w+=1;let s=S[e];if(s.cells.has(a)){let r=s.cells.get(a);t.push(se(`err.oneEventPerCell`,{at:`slots[${e}]`,a:r.id,b:n.id}))}else s.cells.set(a,n);C.set(n.id,{row:e,col:o,key:a})}),{errors:t,byActor:u,sideLabels:{[Il.SIDE1]:r[0]?.label??``,[Il.SIDE2]:r[1]?.label??``,[Il.AXIS]:r[2]?.label??``},columns:y,rows:S,placements:C,axisColumnIndex:b,actorById:s,groupById:c,groupIndexById:l,sourceById:f,eventCount:w}}function Hl(e){return e===Il.SIDE1?0:e===Il.SIDE2?1:2}function zce(e){let t=1;for(let n of e.rows)n.cells.forEach(e=>{let n=Ml(e.label||``);t=Math.max(t,Math.min(2,Math.ceil(n/Fce)))});return t}function Bce(e,t){if(!t.actors)return 0;let n=0;for(let t of e.rows)t.cells.forEach(t=>{let r=(Array.isArray(t.actorIds)?t.actorIds:[]).map(t=>e.actorById.get(t)?.name||t);if(r.length===0)return;let i=r.reduce((e,t)=>e+Nl(t,10)+14,0)+4*(r.length-1);n=Math.max(n,Math.ceil(i/262))});return n}function Ul(e,t){let n=new Set;return e.cells.forEach((e,r)=>{let i=t.columns.findIndex(e=>e.key===r);i>=0&&n.add(i)}),n}var Vce=.5;function Hce(e,t){if(!t)return e.rows.map((e,t)=>t);let n=e.rows.map(t=>Ul(t,e)),r=[];return n.forEach((e,t)=>{let i=t===0?0:r[t-1]+Vce;for(let a=0;a<t;a++)[...e].some(e=>n[a].has(e))&&(i=Math.max(i,r[a]+1));r.push(i)}),r}function Wl(e,t,n,r=!1){let i=e.columns.length,a=e.rows.length,o=zce(e),s=Bce(e,t),c=Ice(t,o,s),l=c+28,u=n?316:l,d=n?l:316,f=new Set;e.rows.forEach(e=>e.cells.forEach((e,t)=>f.add(t)));let p=[],m=0;e.columns.forEach(e=>{let t=f.has(e.key)?d:n?52:104;p.push({start:m,size:t}),m+=t});let h=n?150:0,g=n?0:96,_=n?u:d,v=n?d:u,y=r&&!n,b=Hce(e,y),x=a===0?0:(b[a-1]+1)*u,S=(e,t)=>n?{x:h+b[e]*u,y:p[t].start}:{x:p[t].start,y:g+b[e]*u},C=p[e.axisColumnIndex]??{start:0,size:d};return{isH:n,colCount:i,rowCount:a,labelLines:o,actorLines:s,cardH:c,cellH:l,slotExtent:u,laneExtent:d,lanes:p,originX:h,originY:g,cellBoxW:_,cellBoxH:v,cellAt:S,rowTops:b,timeSpan:x,staggered:y,axisCenter:C.start+C.size/2,contentW:n?h+x+6:m,contentH:n?m:g+x+6}}var Gl={draggable:!1,selectable:!1,connectable:!1,focusable:!1};function Uce(e,t,n){let r=(Array.isArray(e.actorIds)?e.actorIds:[]).map(e=>t.actorById.get(e)?.name||e),i=(Array.isArray(e.sourceIds)?e.sourceIds:[]).map(e=>t.sourceById.get(e)).filter(Boolean);return{event:e,actorNames:r,sources:i,sourceCount:i.length,row:n}}function Kl(e){return{id:`__cells__`,type:`cells`,position:{x:0,y:0},width:1,height:1,style:{pointerEvents:`none`},data:{cols:e.colCount,rows:e.rowCount,cellW:e.cellBoxW,cellH:e.cellBoxH,lanes:e.lanes,originX:e.originX,originY:e.originY,isH:e.isH},...Gl}}function ql(e,t){let n=t=>e.columns.filter(e=>e.side===t).length,r=t=>e.columns.findIndex(e=>e.side===t),i=[];return e.columns.forEach((a,o)=>{let s=n(a.side),c=a.side!==Il.AXIS&&(s>1||a.named),l=o===r(a.side),u={type:`colHeader`,...Gl},d={isH:t.isH,side:a.side,groupIndex:Hl(a.side)};if(!c){i.push({...u,id:`__head__${a.key}`,position:t.isH?{x:0,y:t.lanes[o].start}:{x:t.lanes[o].start,y:0},data:{...d,width:t.isH?150:t.lanes[o].size,height:t.isH?t.lanes[o].size:null,sideTitle:e.sideLabels[a.side],colTitle:null}});return}if(t.isH){i.push({...u,id:`__head__${a.key}`,position:{x:0,y:t.lanes[o].start},data:{...d,width:150,height:t.lanes[o].size,sideTitle:l?e.sideLabels[a.side]:null,colTitle:a.actorName}});return}if(!l)return;let f=e.columns.slice(o,o+s);i.push({...u,id:`__head__${a.key}`,position:{x:t.lanes[o].start,y:0},data:{...d,width:t.lanes.slice(o,o+s).reduce((e,t)=>e+t.size,0),height:null,sideTitle:e.sideLabels[a.side],colTitle:null,actors:f.map(e=>e.actorName),laneWs:t.lanes.slice(o,o+s).map(e=>e.size)}})}),i}function Wce(e,t){let n=e.rows.map(e=>t.rowTops[e.index]*t.slotExtent+t.slotExtent/2-5);return{id:`__axis__`,type:`axis`,position:t.isH?{x:t.originX,y:t.axisCenter-1}:{x:t.axisCenter-1,y:t.originY},data:{isH:t.isH,length:t.timeSpan,dotSize:10,dotOffsets:n},...Gl}}function Jl(e,t){return{id:`__links__`,type:`links`,position:{x:0,y:0},width:1,height:1,style:{pointerEvents:`none`},data:{segments:e,isH:t},...Gl}}function Gce(e,t,n,r,i,a){let o=i.cellAt(n,t),s=o.x+(i.cellBoxW-288)/2,c=o.y+(i.cellBoxH-i.cardH)/2,l=null;if(i.isH){let e=s+144;if(t<r.axisColumnIndex){let t=c+i.cardH;l={left:e,top:t,height:i.axisCenter-t}}else t>r.axisColumnIndex&&(l={left:e,top:i.axisCenter,height:c-i.axisCenter})}else{let e=c+i.cardH/2;if(t<r.axisColumnIndex){let t=s+288;l={left:t,top:e,width:i.axisCenter-t}}else t>r.axisColumnIndex&&(l={left:i.axisCenter,top:e,width:s-i.axisCenter})}return{node:{id:e.id,type:`card`,position:{x:s,y:c},data:{...Uce(e,r,n),groupIndex:Hl(r.columns[t].side),cardW:288,cardH:i.cardH,labelLines:i.labelLines,fields:a,isH:i.isH}},link:l}}function Yl(e,t={},n,r=`vertical`,{stagger:i=!1}={}){let a=r===`horizontal`,o=Vl(e),s=Wl(o,t,a,i),c=[Kl(s),...ql(o,s)],l=[],u=[];return o.rows.forEach(e=>{e.cells.forEach((n,r)=>{let i=o.columns.findIndex(e=>e.key===r);if(i<0)return;let{node:a,link:c}=Gce(n,i,e.index,o,s,t);l.push(a),c&&u.push(c)})}),u.length&&c.push(Jl(u,a)),c.push(Wce(o,s)),c.push(...l),{errors:o.errors,sideLabels:o.sideLabels,nodes:c,edges:[],grid:o,layout:`grid`,staggered:s.staggered,size:{width:s.contentW,height:s.contentH}}}function Xl(e,t,n){let[r,i]=String(e).split(`T`),a=t?oe(n,`card.approxPrefix`):``;if(!i)return a+r;let o=i.split(`:`);return`${a}${r} ${o.slice(0,2).join(`:`)}${o[2]?`:`+o[2]:``}`}function Zl(e,t,n){let r=Xl(t,!1,n);return String(e).split(`T`)[0]===String(t).split(`T`)[0]&&String(t).includes(`T`)?r.split(` `).pop():r}function Ql(e,t){if(!e.date)return oe(t,`card.dateUnknown`);let n=Xl(e.date,e.approx,t);return e.dateEnd?`${n} - ${Zl(e.date,e.dateEnd,t)}`:n}function $l(e,t,n=!1){if(!e.date)return[{text:oe(t,`chronicle.dateUnknown`),strong:!1}];let[r,i]=String(e.date).split(`T`),a=[{text:(e.approx?oe(t,`card.approxPrefix`):``)+r,strong:!0}],o=i?Xl(e.date,!1,t).split(` `).pop():``;n&&o&&a.shift();let s=!a.length;if(!e.dateEnd)return o&&a.push({text:o,strong:s}),a;let c=Zl(e.date,e.dateEnd,t);return o&&!c.includes(`-`)?a.push({text:`${o} – ${c}`,strong:s}):(o&&a.push({text:o,strong:s}),a.push({text:`– ${c}`,strong:!1})),a}var eu=12.5,tu=4,Kce=6,nu=10,qce=90,Jce={latin:1.2,cjk:1.06},Yce={latin:1.12,cjk:1.06},Xce={sameSlot:10,none:22,short:38,long:70},ru=864e5,Zce=/^(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2})(?::(\d{2})(?::(\d{2}))?)?)?)?)?$/;function iu(e){let t=typeof e==`string`?Zce.exec(e):null;if(!t)return null;let[,n,r,i,a,o,s]=t,c=a==null?i==null?r==null?`year`:`month`:`day`:`time`;return{y:+n,mo:r?+r:1,d:i?+i:1,h:a?+a:0,mi:o?+o:0,s:s?+s:0,prec:c}}var D={year:0,month:1,day:2,time:3},Qce=e=>Date.UTC(e.y,e.mo-1,e.d,e.h,e.mi,e.s);function $ce(e,t,n=!1){let r=iu(e),i=iu(t);if(!r||!i)return null;let a=D[r.prec]<=D[i.prec]?r.prec:i.prec,o=(e,t,r)=>({key:e,vars:t,long:r,approx:!!n});if(a===`year`||a===`month`){let e=a===`year`?(i.y-r.y)*12:(i.y-r.y)*12+(i.mo-r.mo);return e<=0?null:ou(e,o)}if(a===`time`){let e=Qce(i)-Qce(r);if(e<=0)return null;if(e<ru){let t=Math.round(e/1e3);if(t<60)return o(`chronicle.gapSeconds`,{n:t},!1);if(t<3600)return o(`chronicle.gapMinutes`,{n:Math.round(t/60)},!1);let n=Math.floor(t/3600),r=Math.round((t-n*3600)/60);return r===60&&(n+=1,r=0),r?o(`chronicle.gapHoursMinutes`,{h:n,m:r},!1):o(`chronicle.gapHours`,{n},!1)}return au(Math.floor(e/ru),o)}let s=Math.round((Date.UTC(i.y,i.mo-1,i.d)-Date.UTC(r.y,r.mo-1,r.d))/ru);return s<=0?null:au(s,o)}function ele(e){let t=(e,t,n)=>({key:e,vars:t,long:n,approx:!1});if(!(e>0))return null;if(e<ru){let n=Math.round(e/1e3);return n<60?t(`chronicle.gapSeconds`,{n},!1):n<3600?t(`chronicle.gapMinutes`,{n:Math.round(n/60)},!1):t(`chronicle.gapHours`,{n:Math.round(n/3600)},!1)}return au(Math.round(e/ru),t)}function au(e,t){return e<30?t(`chronicle.gapDays`,{n:e},!1):ou(Math.max(1,Math.round(e/30.44)),t)}function ou(e,t){let n=Math.floor(e/12),r=e%12;return n?r?t(`chronicle.gapYearsMonths`,{y:n,m:r},!0):t(`chronicle.gapYears`,{n},!0):t(`chronicle.gapMonths`,{n:r},!0)}var su=(e,t)=>e==null?t:t==null||e>t?e:t;function tle(e){let t=Array.isArray(e?.slots)?e.slots:[],n=[],r=null,i=!1,a=!1;return t.forEach((e,t)=>{let o=(Array.isArray(e?.events)?e.events:[]).filter(e=>e&&typeof e==`object`);if(!o.length)return;let s=o.every(e=>typeof e.date==`string`&&e.date),c=s?[...o].sort((e,t)=>e.date<t.date?-1:+(e.date>t.date)):o,l=c.find(e=>e.date)?.date??null,u=c.some(e=>e.date&&e.approx);c.forEach((e,o)=>{let c=o===0,d=null,f=`sameSlot`;c&&(n.length?(d=a&&s?$ce(r,l,i||u):null,f=d?d.long?`long`:`short`:`none`):f=`top`);let p=typeof e.date==`string`&&e.date.length>=10?e.date.slice(0,10):null,m=n.at(-1)?.event,h=!!(p&&m&&typeof m.date==`string`&&m.date.slice(0,10)===p&&!e.approx);n.push({event:e,slotIndex:t,first:c,gap:d,spacing:f,sameDay:h})}),a=s,r=null;for(let e of c)r=su(r,su(e.date,e.dateEnd));i=c.some(e=>e.approx)}),n}var cu=[`circle`,`square`,`diamond`];function lu(e,t){let n=(Array.isArray(e?.groups)?e.groups:[]).findIndex(n=>n?.id===Rl(e)(t));return n<0?`none`:cu[Math.min(n,2)]}function uu(e,t){let n=(Array.isArray(e?.groups)?e.groups:[]).findIndex(n=>n?.id===Rl(e)(t));return n>=0&&n<3?n:2}function nle(e,t,n,r){let i=[];if(n.actors)for(let t of Array.isArray(e.actorIds)?e.actorIds:[])i.push(Nl(r.get(t)?.name||t,10)+14);if(n.sources&&i.push(qce),!i.length)return 0;let a=1,o=0;for(let e of i){let t=o?nu+e:e;o&&o+t>532?(a+=1,o=e):o+=t}return a}function rle({titleLines:e,summaryLines:t,tagLines:n,whenLineCount:r=3}){let i=20+20*Math.max(1,e);return t&&(i+=tu+18*t),n&&(i+=Kce+20*n),Math.max(i,10+18*r)}function du(e,t,n){let r=(e,t,r,i)=>n?Fl(e,531,e=>n(e,t)):Pl(e,532/r,i);return{title:Math.max(1,r(e.label||``,`title`,14,Jce)),summary:t.summary&&e.summary?r(e.summary,`summary`,eu,Yce):0}}function ile(e,t={},{measure:n}={}){let r=new Map((e?.actors||[]).filter(Boolean).map(e=>[e.id,e])),i=new Map((e?.sources||[]).filter(Boolean).map(e=>[e.id,e])),a=(Array.isArray(e?.groups)?e.groups.slice(0,3):[]).map((e,t)=>({label:e?.label,groupIndex:t,shape:cu[t]})).filter(e=>e.label),o=tle(e),s=[],c=[],l=[],u=[],d=a.length?34:0,f=null;o.forEach((a,o)=>{let{event:p}=a;if(f!=null){let e=Xce[a.spacing]??Xce.none;a.gap&&(l.push({y:f+e/2,gap:a.gap}),a.gap.long&&u.push({y0:f,y1:f+e})),d=f+e}let{title:m,summary:h}=du(p,t,typeof n==`function`?n:null),g=nle(p,e,t,r),_=rle({titleLines:m,summaryLines:h,tagLines:g,whenLineCount:$l(p,`en`,a.sameDay).length}),v=uu(e,p),y=(Array.isArray(p.actorIds)?p.actorIds:[]).map(e=>r.get(e)?.name||e),b=(Array.isArray(p.sourceIds)?p.sourceIds:[]).map(e=>i.get(e)).filter(Boolean);s.push({id:p.id,type:`entry`,position:{x:0,y:d},width:758,height:_,draggable:!1,connectable:!1,data:{event:p,index:o,groupIndex:v,shape:lu(e,p),actorNames:y,sources:b,fields:t,lines:{title:m,summary:h,tags:g},sameDay:a.sameDay,cardH:_}}),c.push({y:d+20,groupIndex:v,shape:lu(e,p),hollow:!p.date}),f=d+_});let p=f??0,m=[];return o.length&&m.push({id:`__spine__`,type:`spine`,position:{x:0,y:0},width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,style:{pointerEvents:`none`},data:{x:174,top:c[0].y,bottom:c[c.length-1].y,dots:c,pills:l,breaks:u,dotSize:13}}),a.length&&m.push({id:`__legend__`,type:`legend`,position:{x:198,y:0},width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,data:{groups:a}}),m.push(...s),{errors:[],nodes:m,edges:[],items:o,eventCount:o.length,layout:`chronicle`,size:{width:758,height:p}}}var ale=12,fu=40,pu=12.5,ole={latin:1.2,cjk:1.06},mu=(e,t=1)=>16+17*e+2+15*t,hu=e=>e?.dateEnd&&Nl(Ql(e,`en`),11)*1.05>176?2:1,gu=mu(2,2)+10,sle=10,_u=22,cle=12,vu=e=>cle+Math.max(1,e)*gu+_u,yu=14,bu=864e5,xu=36e5;function Su(e){let t=iu(e?.date);if(!t)return null;let n=e=>Date.UTC(e.y,e.mo-1,e.d,e.h,e.mi,e.s),r=e=>e.prec===`year`?Date.UTC(e.y+1,0,1):e.prec===`month`?Date.UTC(e.y,e.mo,1):e.prec===`day`?Date.UTC(e.y,e.mo-1,e.d+1):n(e),i=n(t),a=iu(e?.dateEnd);return a&&r(a)>i?{from:i,to:r(a),kind:`bar`,exact:!0}:t.prec===`time`?{from:i,to:i,kind:`dot`,exact:!0}:{from:i,to:r(t),kind:`band`,exact:!1,prec:t.prec}}var lle=e=>{let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2};function Cu(e){let t=e.slice(1).map((t,n)=>t-e[n]),n=[],r=(e,n)=>{let r=[];for(let i=e+n;i>=0&&i<t.length&&r.length<3&&!(t[i]>=t[e]);i+=n)r.push(t[i]);return r};return t.forEach((e,t)=>{if(e<1728e5)return;let i=r(t,1);i.length||(i=r(t,-1)),i.length&&e/Math.max(lle(i),6e4)>=20&&n.push({i:t,g:e})}),n.sort((e,t)=>t.g-e.g).slice(0,2).map(e=>e.i).sort((e,t)=>e-t)}function ule(e){return e>730*bu?`year`:e>60*bu?`month`:e>2*bu?`day`:e>3*xu?`hour`:`minute`}function wu(e,t,n,r){let i=new Date(e),a=[],o={year:[1,2,5,10],month:[1,2,3,6],day:[1,2,7,14],hour:[1,2,3,6,12],minute:[1,2,5,10,15,30]}[n];for(let s of o){a.length=0;let o;o=n===`year`?Date.UTC(i.getUTCFullYear(),0,1):n===`month`?Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1):n===`day`?Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()):n===`hour`?Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),i.getUTCHours()):Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),i.getUTCHours(),i.getUTCMinutes());let c=0;for(;o<=t&&c++<2e3;){o>=e&&a.push(o);let t=new Date(o);n===`year`?o=Date.UTC(t.getUTCFullYear()+s,0,1):n===`month`?o=Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+s,1):o+=n===`day`?s*bu:n===`hour`?s*xu:s*6e4}if(a.length<=r)break}return[...a]}function Tu(e,t,n){let r=new Date(e),i=e=>String(e).padStart(2,`0`),a=`${i(r.getUTCMonth()+1)}-${i(r.getUTCDate())}`;if(t===`year`)return String(r.getUTCFullYear());if(t===`month`)return`${r.getUTCFullYear()}-${i(r.getUTCMonth()+1)}`;if(t===`day`)return a;let o=`${i(r.getUTCHours())}:${i(r.getUTCMinutes())}`;return n==null||new Date(n).getUTCDate()!==r.getUTCDate()?`${a} ${o}`:o}function Eu(e,t){let n=new Map,r=(Array.isArray(e?.actors)?e.actors:[]).filter(e=>e?.id);if(!t||r.length<2)return n;for(let t of Array.isArray(e?.groups)?e.groups.slice(0,2):[]){let e=r.filter(e=>t?.id&&e.groupId===t.id);e.length>=2&&n.set(t.id,e)}return n}function dle(e,{byParty:t=!1}={}){let n=Rl(e),r=Eu(e,t);return e=>{let t=n(e),i=Array.isArray(e?.actorIds)?e.actorIds:[];return i.length===1&&r.get(t)?.some(e=>e.id===i[0])?`actor:${i[0]}`:t}}function fle(e,t,{byParty:n=!1}={}){let r=dle(e,{byParty:n}),i=Eu(e,n),a=(Array.isArray(e?.groups)?e.groups.slice(0,3):[]).filter(e=>e&&e.id),o=new Set(t.map(r)),s=a.flatMap((e,t)=>{let n=i.get(e.id)?.filter(e=>o.has(`actor:${e.id}`));return n?.length?n.map(n=>({key:`actor:${n.id}`,label:n.name??``,side:e.label??``,groupIndex:t})):[{key:e.id,label:e.label??``,groupIndex:t}]}),c=new Set(s.map(e=>e.key));return t.some(e=>!c.has(r(e)))&&s.push({key:`__other__`,label:null,groupIndex:2,other:!0}),s}function ple(e,{levels:t=3,width:n=196,gap:r=sle}={}){let i=e.map(e=>({ids:[e.id],x:e.x,from:e.x,to:e.x}));for(;;){let e=mle(i,t,n,r);if(e)return e;let a=-1,o=1/0;for(let e=0;e+1<i.length;e++){let t=i[e+1].x-i[e].x;t<o&&(o=t,a=e)}if(a<0)return mle(i,t,n,r)??[];let s=i[a],c=i[a+1],l=[...s.ids,...c.ids],u=Math.min(s.from,c.from),d=Math.max(s.to,c.to);i.splice(a,2,{ids:l,x:(u+d)/2,from:u,to:d}),i=i.sort((e,t)=>e.x-t.x)}}function mle(e,t,n,r){let i=Array(t).fill(-1/0),a=[];for(let t of e){let e=t.x-n/2,o=i.findIndex(t=>t+r<=e);if(o<0)return null;i[o]=t.x+n/2,a.push({...t,level:o})}return a}function Du(e,t={},{measure:n,byParty:r=!1}={}){let i=new Map((e?.actors||[]).filter(Boolean).map(e=>[e.id,e])),a=new Map((e?.sources||[]).filter(Boolean).map(e=>[e.id,e])),o=[];(Array.isArray(e?.slots)?e.slots:[]).forEach((e,t)=>{for(let n of Array.isArray(e?.events)?e.events:[])n&&typeof n==`object`&&o.push({event:n,slotIndex:t})}),o.forEach(e=>e.time=Su(e.event)),o.forEach(e=>{e.time?.exact&&(e.time.t=e.time.from)});let s=e=>({before:o.slice(0,e).reverse().find(e=>e.time?.exact),after:o.slice(e+1).find(e=>e.time?.exact)}),c=o.filter(e=>e.time?.exact).map(e=>e.time.t),l=c.length>1?Math.max(6e4,(Math.max(...c)-Math.min(...c))/20):xu,u=(e,t,n)=>{let{before:r,after:i}=s(e),a;return a=r&&i?(r.time.t+i.time.t)/2:r?r.time.t+l:i?i.time.t-l:t==null?e*xu:(t+n)/2,t==null?a:Math.min(Math.max(a,t),n-1)};o.forEach((e,t)=>{e.time&&!e.time.exact&&(e.time.t=u(t,e.time.from,e.time.to))}),o.forEach((e,t)=>{if(e.time)return;let n=o.slice(0,t).reverse().find(e=>e.time),r=o.slice(t+1).find(e=>e.time),i=n&&r?(n.time.t+r.time.t)/2:n?n.time.t+l:r?r.time.t-l:t*xu;e.time={t:i,from:i,to:i,kind:`dot`,undated:!0}});let d=[...new Set(o.map(e=>e.time.t))].sort((e,t)=>e-t),f=[...new Set(o.filter(e=>!e.time.undated).map(e=>e.time.t))].sort((e,t)=>e-t),p=f.length?f:d,m=Cu(p),h=[],g=0;for(let e of m)h.push([p[g],p[e]]),g=e+1;h.push([p[g],p[p.length-1]]),h[0][0]=Math.min(h[0][0],d[0]),h[h.length-1][1]=Math.max(h[h.length-1][1],d[d.length-1]);let _=e=>{let t=h.findIndex(([,t])=>e<=t);return t<0?h.length-1:t},v=h.map(([e,t],n)=>({index:n,from:e,to:t,count:o.filter(e=>_(e.time.t)===n).length,unit:t>e?ule(t-e):`day`})),y=e=>Nl(e,ale)*1.06,b=fle(e,o.map(e=>e.event),{byParty:r}).flatMap(e=>[e.label||``,e.side||``]),x=Math.round(Math.min(196,Math.max(132,...b.map(e=>y(e)+fu)))),S=x;v.forEach((e,t)=>{if(t>0){let n=e.from-v[t-1].to;e.breakBefore={x:S,w:64,gap:ele(n)},S+=64}e.x0=S,e.w=Math.max(170,e.count*116),e.x1=S+e.w,S=e.x1});let C=S,w=e=>{let t=v[_(e)],n=t.w-196;return t.to===t.from?t.x0+t.w/2:t.x0+98+(Math.min(Math.max(e,t.from),t.to)-t.from)/(t.to-t.from)*n},T=(e,t)=>Math.min(Math.max(e,v[t].from),v[t].to),ee=fle(e,o.map(e=>e.event),{byParty:r}),te=dle(e,{byParty:r}),ne=e=>{let t=ee.findIndex(t=>t.key===te(e));return t>=0?t:ee.length-1},re=[],ie=[],ae=e=>re[e],se=e=>re[e]+ie[e],ce=o.map((e,t)=>{let n=_(e.time.t),r=e.time.kind,i=w(r===`dot`?e.time.t:T(e.time.from,n)),a=r===`dot`?i:w(T(e.time.to,n)),o=r===`bar`?i:w(e.time.t),s=v[n],c=r===`band`&&s.to>s.from&&e.time.to-e.time.from>s.to-s.from,l=r===`band`&&(c||a-i<8)?`dot`:r;return l===`dot`?i=a=o:a-i<6&&(a=i+6),{id:e.event.id,order:t,lane:ne(e.event),kind:l,x:o,x0:i,x1:a,undated:!!e.time.undated,coarse:c,prec:e.time.prec,event:e.event}}),le=new Map;for(let e of ce){let t=`${e.lane}:${Math.round(e.x)}`;e.stack=le.get(t)??0,le.set(t,e.stack+1)}let ue=e=>Math.min(2,Math.max(1,n?Fl(e,173,e=>n(e,`title`)):Pl(e,176/pu,ole))),de=[],fe=[],pe=ee.map((e,t)=>{let n=ce.filter(e=>e.lane===t).sort((e,t)=>e.x-t.x||e.order-t.order),r=e=>Math.min(Math.max(e,x+4+98),C-98);return ple(n.map(e=>({id:e.id,x:r(e.x)})))}),me=0;pe.forEach((e,t)=>{re[t]=me,ie[t]=e.length?vu(Math.max(0,...e.map(e=>e.level))+1):34,me+=ie[t]}),pe.forEach((e,t)=>{let n=e=>{let t=e.ids.map(e=>ce.find(t=>t.id===e).x);return(Math.min(...t)+Math.max(...t))/2};for(let r of e){let e=r.x-98,i=r.ids.map(e=>ce.find(t=>t.id===e)).sort((e,t)=>e.order-t.order),a=i.length>1,o=a?1:ue(i[0].event.label||``),s=a?1:i[0].undated?Nl(oe(`en`,`scale.undated`),11)*1.05>176?2:1:hu(i[0].event),c=mu(o,s),l=se(t)-_u-r.level*gu,u={id:a?`__run__${fe.length+1}`:i[0].id,lane:t,level:r.level,x:e,y:l-c,w:196,h:c,titleLines:o,timeLines:s,anchor:n(r),members:i};a&&(u.run=fe.length+1,u.span=[Math.min(...i.map(e=>e.x0)),Math.max(...i.map(e=>e.x1))],fe.push(u)),de.push(u)}});let he=re.length?re[re.length-1]+ie[ie.length-1]:0,ge=he+14,_e=v.flatMap(e=>{let t=Math.max(2,Math.floor(e.w/84)),n=e.to>e.from?wu(e.from,e.to,e.unit,t):[],r=e.unit;return n.length||(n=e.to>e.from?[e.from,e.to]:[e.from],r=e.to>e.from?`minute`:`day`),n.map((e,t)=>({x:w(e),label:Tu(e,r,t?n[t-1]:null)}))}),ve=fe.reduce((e,t)=>e+1+t.members.length,0),ye=fe.length?yu+ve*18:0,be=he+56+ye,xe=e=>ee[ne(e)].groupIndex,Se=[{id:`__scale__`,type:`scaleLayer`,position:{x:0,y:0},width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,style:{pointerEvents:`none`},data:{width:C,labelW:x,lanesH:he,axisY:ge,lanes:ee.map((e,t)=>({...e,top:ae(t),lineY:se(t)})),segments:v,ticks:_e,marks:ce.map(e=>({id:e.id,kind:e.kind,x:e.x,x0:e.x0,x1:e.x1,y:se(e.lane)-e.stack*12,undated:e.undated,coarse:e.coarse,prec:e.prec,approx:!!e.event.approx,groupIndex:ee[e.lane].groupIndex})),leaders:de.map(e=>({x:Math.min(Math.max(e.anchor,e.x+8),e.x+e.w-8),y0:e.y+e.h,y1:se(e.lane)-6,run:!!e.run})),brackets:fe.map(e=>({x0:e.span[0],x1:e.span[1],y:se(e.lane)+9,run:e.run}))}}];for(let e of de)Se.push({id:e.id,type:e.run?`scaleRun`:`scaleCard`,position:{x:e.x,y:e.y},width:e.w,height:e.h,draggable:!1,connectable:!1,data:e.run?{run:e.run,events:e.members.map(e=>e.event),groupIndex:ee[e.lane].groupIndex,cardH:e.h}:{event:e.members[0].event,undated:e.members[0].undated,groupIndex:xe(e.members[0].event),titleLines:e.titleLines,timeLines:e.timeLines,cardH:e.h,actorNames:(Array.isArray(e.members[0].event.actorIds)?e.members[0].event.actorIds:[]).map(e=>i.get(e)?.name||e),sources:(Array.isArray(e.members[0].event.sourceIds)?e.members[0].event.sourceIds:[]).map(e=>a.get(e)).filter(Boolean)}});return fe.length&&Se.push({id:`__runs__`,type:`scaleRunList`,position:{x,y:he+56+yu},width:1,height:1,draggable:!1,selectable:!1,connectable:!1,focusable:!1,data:{runs:fe.map(e=>({run:e.run,events:e.members.map(e=>e.event)})),width:C-x,lh:18}}),{errors:[],nodes:Se,edges:[],layout:`scale`,eventCount:o.length,segments:v,gathered:fe.map(e=>({run:e.run,ids:e.members.map(e=>e.id)})),cards:de.map(e=>({id:e.id,lane:e.lane,level:e.level,x:e.x,y:e.y,w:e.w,h:e.h,ids:e.members.map(e=>e.id)})),undated:ce.filter(e=>e.undated).length,labelW:x,size:{width:C,height:be}}}function Ou(e,t){if(!e||!t||!e.width||!e.height)return 1;let n=t.width/(e.width*1.12),r=t.height/(e.height*1.12);return Math.min(n,r,1)}function hle(e,t){return!e||!t||!e.width?1:Math.min(t.width/(e.width*1.12),1)}var ku={width:1600,height:900},Au=(e,t)=>Math.round(e*Math.min(t,1)*10)/10;function ju(e,t){let n=`Text on one screen (${e.canvas.width}×${e.canvas.height})`,r=Au(e.font,e.open.fit),i=Au(e.font,e.other.fit),a=e=>e.toFixed(1),o=[];e.open.fit>=1&&e.other.fit>=1?o.push(`${n}: full size (${e.font} px) either way.`):o.push(`${n}: ${a(r)} px as it opens (${e.open.name}), ${a(i)} px ${e.other.name}. Full size is ${e.font} px.`);let s=Math.max(r,i);if(s<9?o.push(`Note: the text is too small to read without zooming in (under 9 px). Consider ${t}; do not drop facts to make it fit.`):s<11&&o.push(`Note: the text is small (under 11 px); the reader can zoom in. ${t[0].toUpperCase()}${t.slice(1)} would make it easier to read.`),e.folded!==void 0&&s<11){let t=e.folded>=1?`full size (${e.font} px)`:`${a(Au(e.font,e.folded))} px`;o.push(`With every issue folded the text is ${t}: the reader can fold issues ("Fold issues" in the bar) instead of your splitting it.`)}return o}var Mu={envelope:[{name:`type`,req:`yes`,ty:`string`,note:`always "fact"`},Dl(2),{name:`title`,req:`yes`,ty:`string`,note:`diagram title, shown at the top left`}],actors:[{name:`id`,req:`yes`,ty:`string`,note:`unique within the diagram; events reference it via actorIds`},{name:`name`,req:`yes`,ty:`string`,note:`display name, e.g. "Huayuan Trading"`},{name:`role`,req:`no`,ty:`string`,note:`procedural standing, e.g. "plaintiff"`},{name:`groupId`,req:`*`,ty:`string`,note:`the side this party is on: the 1st or the 2nd group. Required with 2 or more parties; not written with one`}],groups:[{name:`id`,req:`yes`,ty:`string`,note:`parties (2 or more) or events (one party) reference it via groupId`},{name:`label`,req:`yes`,ty:`string`,note:`column heading, e.g. "Sun Hao's side" (parties) or "performance as agreed" (one party's acts)`},{name:``,req:``,ty:``,note:`at most 3: the 1st on the left (top) side, the 2nd on the right (bottom) side, the 3rd on the axis`},{name:``,req:``,ty:``,note:`2 or more parties: the groups split the parties. 0 or 1 party: they split the events by kind of act`}],sources:[{name:`id`,req:`yes`,ty:`string`,note:`events reference it via sourceIds`},{name:`type`,req:`yes`,ty:`string`,note:`contract / evidence / judgment / transcript, etc.`},{name:`name`,req:`yes`,ty:`string`,note:`material name, e.g. "corridor surveillance video"`},{name:`loc`,req:`no`,ty:`object`,note:`location, e.g. { file, page } or { file, timestamp }`},{name:`quote`,req:`no`,ty:`string`,note:`verbatim excerpt (several passages joined with ……), shown when the card is opened; a shortened or reworded version goes in detail`}],slots:[{name:`events`,req:`yes`,ty:`array`,note:`events at this time point; must not be empty`},{name:``,req:``,ty:``,note:`array order is chronological order; date is display-only and never reorders`}],events:[{name:`id`,req:`yes`,ty:`string`,note:`unique within the diagram`},{name:`date`,req:`no`,ty:`string`,note:`ISO 8601. Go to seconds when known, otherwise stop at the day. **Leave it out when the material gives no date: never make one up.** The card then says the date is unknown; the order is the order of slots, so nothing moves`},{name:`label`,req:`yes`,ty:`string`,note:`card title; about 20 characters per line, at most two lines`},{name:`dateEnd`,req:`no`,ty:`string`,note:`for a span, the end instant; needs date, and must not be earlier than it`},{name:`approx`,req:`no`,ty:`boolean`,note:`time is not exact (estimated or inferred); the diagram shows "approx."`},{name:`dateNote`,req:`no`,ty:`string`,note:`why the time is not exact, and how it was derived`},{name:`summary`,req:`no`,ty:`string`,note:`the line under the card title; about 22 characters`},{name:`detail`,req:`no`,ty:`string`,note:`full text revealed when the card is opened`},{name:`actorIds`,req:`no`,ty:`string[]`,note:`parties involved. One: that party's side and column. Two or more, or none: the centre axis`},{name:`groupId`,req:`*`,ty:`string`,note:`only when the diagram has 0 or 1 party: which side this event falls on. With 2 or more parties, leave it out`},{name:`sourceIds`,req:`no`,ty:`string[]`,note:`which materials it rests on`}]};function Nu(){let e=[`Fields of a fact spec. "yes" means required.`,``];for(let[t,n]of Object.entries(Mu)){e.push(`[${t}]`);for(let t of n){if(!t.name){e.push(` · ${t.note}`);continue}e.push(` ${t.name.padEnd(12)} ${t.req.padEnd(3)} ${t.ty.padEnd(15)} ${t.note}`)}e.push(``)}return e.push(`"*": required or not depending on the number of parties, as the note says.`),e.push(`Cross-field rules (dangling references, a span running backwards, a party without a`),e.push(`side, two events in the same lane of one time slot) are not listed`),e.push(`above: call antu_validate after writing. It reports each problem with its field path.`),e.join(`
|
|
1493
1493
|
`)}function Pu(e,t,{fields:n,canvas:r}){let i=t(e,n),a=Number(hle(i.size,r).toFixed(3)),o=Number(Ou(i.size,r).toFixed(3)),s=Math.max(1,Math.round(i.size.height*a/r.height*10)/10),c=i.items.filter(e=>e.gap);return{text:{font:14,canvas:r,open:{name:`fitted to width`,fit:a},other:{name:`whole column`,fit:o}},counts:{slots:Array.isArray(e.slots)?e.slots.length:0,events:i.items.length,actors:e.actors?.length??0,sources:e.sources?.length??0},size:i.size,screens:s,gaps:{short:c.filter(e=>!e.gap.long).length,long:c.filter(e=>e.gap.long).length},undated:i.items.filter(e=>!e.event.date).length}}function Fu(e){let t=[];return t.push(`Kind: chronicle (every event in one column, in slot order; orientation does not apply)`),t.push(`Data: ${e.counts.events} events / ${e.counts.slots} time slots / ${e.counts.actors} parties / ${e.counts.sources} sources`),t.push(`Content ${e.size.width}×${e.size.height}; it opens fitted to its width, about ${e.screens} screen(s) tall`),t.push(`Gaps written between time points: ${e.gaps.short} short, ${e.gaps.long} of 30 days or more (marked)`),e.undated&&t.push(`${e.undated} event(s) without a date: shown in slot order with a hollow dot, and no gap on either side`),t.push(...ju(e.text,`splitting the case into periods, one diagram each`)),t.join(`
|
|
1494
1494
|
`)}function Iu(e,t,{canvas:n}){let r=t(e,{}),i=Number(Ou(r.size,n).toFixed(3));return{text:{font:pu,canvas:n,open:{name:`fitted whole`,fit:i},other:{name:`fitted whole`,fit:i}},counts:{events:r.eventCount,actors:e.actors?.length??0,sources:e.sources?.length??0},size:r.size,segments:r.segments.map(e=>({unit:e.unit,count:e.count})),gathered:r.gathered.map(e=>e.ids.length),undated:r.undated}}function Lu(e){let t=[];return t.push(`Kind: scale (distance on the axis is real time; orientation does not apply)`),t.push(`Data: ${e.counts.events} events / ${e.counts.actors} parties / ${e.counts.sources} sources`),t.push(`Content ${e.size.width}×${e.size.height}`),t.push(e.segments.length>1?`The axis breaks into ${e.segments.length} segments: ${e.segments.map((e,t)=>`${t+1}. by ${e.unit}, ${e.count} event(s)`).join(`; `)}`:`One segment, by ${e.segments[0]?.unit??`day`}`),e.gathered.length&&t.push(`${e.gathered.length} run(s) of events too close to show one by one are gathered (${e.gathered.join(`, `)} events); they are listed in full under the diagram`),e.undated&&t.push(`${e.undated} event(s) without a date: placed between their neighbours in data order, with a hollow dot`),t.push(...ju(e.text,`splitting the case into periods, one diagram each`)),t.join(`
|
|
1495
1495
|
`)}var Ru={specVersion:2,label:`graphType.fact`,fields:Mu,describe:Nu,validate:e=>Vl(e).errors,notes:e=>[...Dce(e),...Oce(e)],info:(e,t,n)=>{let r=Array.isArray(e.slots)?e.slots:[],i=r.flatMap(e=>(e?.events||[]).map(e=>e?.date)).filter(e=>typeof e==`string`&&e).sort(),a=t(`info.slots`,{n:n(r.length)});if(i.length>0){let e=i[0].slice(0,10),n=i[i.length-1].slice(0,10);a+=e===n?` · ${e}`:` · ${t(`info.span`,{from:e,to:n})}`}return[a,t(`info.actors`,{n:n(e.actors?.length||0)}),t(`info.sources`,{n:n(e.sources?.length||0)})]},report:(e,t,{orientation:n,fields:r={summary:!0},kind:i,canvas:a})=>{if(i===`chronicle`)return Pu(e,t,{fields:r,canvas:a});if(i===`scale`)return Iu(e,t,{canvas:a});let o=t(e,r,void 0,n??`vertical`),s=Vl(e),c={side1:0,axis:0,side2:0};s.columns.forEach(e=>{c[e.side]+=1});let l={events:o.eventCount??s.eventCount??0,columns:c,blocked:o.errors.length>0?o.errors[0]:null},u={};for(let n of[`vertical`,`horizontal`]){let i=t(e,r,void 0,n,{stagger:!0});u[n]={size:i.size,fit:Number(Ou(i.size,a).toFixed(3))}}let d=t(e,r,void 0,`vertical`,{stagger:!1}),f={size:d.size,fit:Number(Ou(d.size,a).toFixed(3))},p=Array.isArray(e.slots)?e.slots.length:0,m=n??(p>=5?`vertical`:`horizontal`),h=m===`vertical`?`horizontal`:`vertical`;return{text:{font:13,canvas:a,open:{name:m,fit:u[m].fit},other:{name:h,fit:u[h].fit}},unstaggered:f,counts:{slots:p,events:(e.slots??[]).reduce((e,t)=>e+(t?.events?.length||0),0),actors:e.actors?.length??0,sources:e.sources?.length??0},byOrientation:u,suggestedOrientation:p>=5?`vertical`:`horizontal`,placement:l}},formatReport:e=>{if(e.kind===`chronicle`)return Fu(e);if(e.kind===`scale`)return Lu(e);let t=[];t.push(`Data: ${e.counts.events} events / ${e.counts.slots} time slots / ${e.counts.actors} parties / ${e.counts.sources} sources`);let n=e.byOrientation.vertical,r=e.byOrientation.horizontal,i=e.unstaggered,a=i&&(i.size.height!==n.size.height||i.size.width!==n.size.width)?` (rows staggered, the page's default; with "Stagger" off ${i.size.width}×${i.size.height}, fit zoom ${i.fit})`:``;t.push(`Vertical: content ${n.size.width}×${n.size.height}, fit zoom ${n.fit}${a}`),t.push(`Horizontal: content ${r.size.width}×${r.size.height}, fit zoom ${r.fit}`),t.push(e.suggestedOrientation===`vertical`?`Suggested orientation: vertical (by the slot-count rule, ${e.counts.slots} slots >= 5)`:`Suggested orientation: horizontal (by the slot-count rule, ${e.counts.slots} slots < 5)`),t.push(...ju(e.text,`splitting the timeline into periods, one diagram each`));let o=e.placement;return t.push(`Columns: side1 ${o.columns.side1} / axis ${o.columns.axis} / side2 ${o.columns.side2}, ${o.events} events`),o.blocked&&(t.push(`Does not fit: ${o.blocked}`),t.push(`Common cause: two or more events of one time slot fall in the same lane (the grid is one event per cell).`),t.push(`How to fix: split that time slot into two finer time points, or check the parties of the events so they land in different lanes.`)),t.join(`
|
|
@@ -1536,7 +1536,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
1536
1536
|
if (!el) return null
|
|
1537
1537
|
const r = el.getBoundingClientRect()
|
|
1538
1538
|
return JSON.stringify({ x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2) })
|
|
1539
|
-
})()`);if(!t)throw Error(`Cannot click element: ${e}`);let{x:n,y:r}=JSON.parse(t);for(let e of[`mousePressed`,`mouseReleased`])await _.send(`Input.dispatchMouseEvent`,{type:e,x:n,y:r,button:`left`,clickCount:1})},
|
|
1539
|
+
})()`);if(!t)throw Error(`Cannot click element: ${e}`);let{x:n,y:r}=JSON.parse(t);for(let e of[`mousePressed`,`mouseReleased`])await _.send(`Input.dispatchMouseEvent`,{type:e,x:n,y:r,button:`left`,clickCount:1})},async hoverAt(e,{dx:t=0,dy:n=0}={}){let r=await b.eval(`(() => {
|
|
1540
|
+
const el = (${e})
|
|
1541
|
+
if (!el) return null
|
|
1542
|
+
const r = el.getBoundingClientRect()
|
|
1543
|
+
return JSON.stringify({ x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2) })
|
|
1544
|
+
})()`);if(!r)throw Error(`Cannot hover element: ${e}`);let{x:i,y:a}=JSON.parse(r);await _.send(`Input.dispatchMouseEvent`,{type:`mouseMoved`,x:i+t,y:a+n})},get requests(){return v.slice()},get errors(){return y.slice()},async close(){_.close(),await ph(f),await hh(h)}};return b}async function _h(e,{width:t=1600,height:n=900,settleMs:r=800}={}){let i=Date.now(),a=await gh({width:t,height:n});try{await a.open(g(e).href,{settleMs:r});let o=await a.eval(`document.querySelectorAll(${JSON.stringify(ah)}).length`);return{data:await a.screenshotData(),mimeType:`image/png`,width:t,height:n,cards:o,ms:Date.now()-i}}finally{await a.close()}}var vh=new lce({name:`antu`,version:yl()}),yh=La({}).describe(`the Antu JSON (envelope + content layer; see the spec resources)`),bh=Ga(dde).optional().describe(`the look of the page: document (black and white, for print; the default), modern (rounded, light) or legal (navy). Omit it and the reader chooses in the page; give it and the page is fixed to it`),xh=Ta().optional().describe(`which way of drawing (fact: timeline, chronicle or scale; relationship: graph, focus, matrix, equity, authority, related or path; procedure: flow or route); omit it for the default, the first`),Sh=e=>({content:[{type:`text`,text:e}]}),Ch=e=>({content:[{type:`text`,text:e}],isError:!0});vh.registerTool(`antu_examples`,{title:`See the examples`,description:`List the examples, or fetch one in full. **With no arguments you get the small ones**(as small as possible, one idea each). A good first pass is: antu_schema for the fields, antu_guide for the mechanism, then fetch 1-minimal.en.json here to see how one is written.
|
|
1540
1545
|
Three batches: agent (the default, 1 KB small examples, the ones to write data from), real (real cases, 4-8 KB, for reference), raw (raw judgments, **not examples**: the source material these examples came from, never use it as a template).`,inputSchema:{file:Ta().optional().describe(`the one to fetch, e.g. examples/agent/fact/1-minimal.en.json. Omit to list them`),group:Ga([`agent`,`real`,`raw`]).optional().describe(`which batch to list: agent (default, small examples) / real (real cases) / raw (source material, not examples)`),type:Ta().optional().describe(`which diagram type, fact by default (fact diagram)`)}},async({file:e,group:t=`agent`,type:n=`fact`})=>{if(!Tl().some(e=>e.type===n))return Ch(`no examples for type "${n}" yet. Available: ${Tl().map(e=>`${e.type} (${se(e.labelKey)})`).join(`, `)||`(none)`}.`);if(e){let t=Gm(e);return t?Sh(`# ${e}\n\n\`\`\`json\n${t.text}\n\`\`\``):Ch(`example not found: ${e}. Call antu_examples with no arguments to see the list.`)}let r=Wm({type:n,group:t}),i=r.map(e=>`- ${e.file} (${(e.bytes/1024).toFixed(1)} KB)\n ${e.title}\n ${e.line}`);if(r.length===0&&t===`agent`)return Sh(`no small examples for type "${n}" yet. Try group="real".`);let a=t===`real`?`Real cases: ${r.length} (4-8 KB each, for reference, write your data from the default small examples first):`:t===`raw`?`Raw judgments: ${r.length} (**not examples**, never use them as a template; the source material these examples came from):`:`Small examples: ${r.length} (about 1 KB each, start with 1-minimal):`,o=t===`agent`?`
|
|
1541
1546
|
|
|
1542
1547
|
There are also real cases (group="real") and source material (group="raw").`:`
|
package/bin/antu.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Antu 0.13.
|
|
2
|
+
// Antu 0.13.1
|
|
3
3
|
// Copyright (C) 2026 Ji Cheng
|
|
4
4
|
//
|
|
5
5
|
// Antu is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
// publish them, or sell them on any terms you like. This licence covers Antu's code in the page, and the notices in
|
|
14
14
|
// the page must stay with it.
|
|
15
15
|
//
|
|
16
|
-
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.
|
|
17
|
-
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
18
|
-
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
16
|
+
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.1
|
|
17
|
+
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.1/LICENSE
|
|
18
|
+
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.1/skills/antu/THIRD-PARTY-NOTICES.md
|
|
19
19
|
//
|
|
20
20
|
// === The licence of Antu ===
|
|
21
21
|
//
|
|
@@ -1469,10 +1469,15 @@ import{execFileSync as e,spawn as t,spawnSync as n}from"node:child_process";impo
|
|
|
1469
1469
|
if (!el) return null
|
|
1470
1470
|
const r = el.getBoundingClientRect()
|
|
1471
1471
|
return JSON.stringify({ x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2) })
|
|
1472
|
-
})()`);if(!t)throw Error(`Cannot click element: ${e}`);let{x:n,y:r}=JSON.parse(t);for(let e of[`mousePressed`,`mouseReleased`])await _.send(`Input.dispatchMouseEvent`,{type:e,x:n,y:r,button:`left`,clickCount:1})},
|
|
1472
|
+
})()`);if(!t)throw Error(`Cannot click element: ${e}`);let{x:n,y:r}=JSON.parse(t);for(let e of[`mousePressed`,`mouseReleased`])await _.send(`Input.dispatchMouseEvent`,{type:e,x:n,y:r,button:`left`,clickCount:1})},async hoverAt(e,{dx:t=0,dy:n=0}={}){let r=await b.eval(`(() => {
|
|
1473
|
+
const el = (${e})
|
|
1474
|
+
if (!el) return null
|
|
1475
|
+
const r = el.getBoundingClientRect()
|
|
1476
|
+
return JSON.stringify({ x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2) })
|
|
1477
|
+
})()`);if(!r)throw Error(`Cannot hover element: ${e}`);let{x:i,y:a}=JSON.parse(r);await _.send(`Input.dispatchMouseEvent`,{type:`mouseMoved`,x:i+t,y:a+n})},get requests(){return v.slice()},get errors(){return y.slice()},async close(){_.close(),await Qa(p),await eo(h)}};return b}async function to(e,{width:t=1600,height:n=900,settleMs:r=800}={}){let i=Date.now(),a=await Xne({width:t,height:n});try{await a.open(h(e).href,{settleMs:r});let o=await a.eval(`document.querySelectorAll(${JSON.stringify(qa)}).length`);return{data:await a.screenshotData(),mimeType:`image/png`,width:t,height:n,cards:o,ms:Date.now()-i}}finally{await a.close()}}var no=`@zh-xx/antu`,Zne=`https://registry.npmjs.org/${no.replace(/\//g,`%2f`)}/latest`,Qne=1500;function ro(e,t){let n=e=>/^(\d+)\.(\d+)\.(\d+)$/.exec(String(e))?.slice(1).map(Number),r=n(e),i=n(t);if(!r||!i)return null;for(let e=0;e<3;e+=1)if(r[e]!==i[e])return r[e]<i[e]?-1:1;return 0}function $ne(e=m(import.meta.url)){let t=d(e);return u(t)===`scripts`&&r(f(t,`..`,`SKILL.md`))?`skill`:e.split(/[\\/]/).includes(`node_modules`)?`npm`:`source`}function ere({current:e,latest:t,where:n}){return ro(e,t)===-1?n===`skill`?[`Notice: Antu ${t} is out; this skill is ${e}.`,`When the request is done, tell the user in a sentence or two that the skill can be updated with:`,` npx skills update antu -g`,`Do not run it unless the user agrees.`].join(`
|
|
1473
1478
|
`):n===`npm`?[`Notice: Antu ${t} is out; this is ${e}.`,`When the request is done, tell the user in a sentence or two that it can be updated with:`,` npm update -g ${no} (or run it with: npx -y ${no}@latest)`,`Do not run it unless the user agrees.`].join(`
|
|
1474
1479
|
`):``:``}async function tre({url:e,cacheFile:t,now:n}){try{let e=JSON.parse(a(t,`utf8`));if(typeof e.latest==`string`&&n-e.checkedAt<864e5)return e.latest}catch{}let r=new AbortController,i=setTimeout(()=>r.abort(),Qne);try{let i=await fetch(e,{signal:r.signal,headers:{accept:`application/json`}});if(!i.ok)return null;let a=(await i.json())?.version;if(typeof a!=`string`)return null;try{c(t,JSON.stringify({checkedAt:n,latest:a}))}catch{}return a}catch{return null}finally{clearTimeout(i)}}async function nre({current:e,where:t=$ne(),env:n=process.env,now:r=Date.now()}={}){try{if(n.ANTU_NO_UPDATE_NOTIFIER||t===`source`||ro(e,e)===null)return``;let i=n.ANTU_REGISTRY_URL||Zne,a=await tre({url:i,cacheFile:f(l(),`antu-update-check-${g(`sha1`).update(i).digest(`hex`).slice(0,16)}.json`),now:r});return a?ere({current:e,latest:a,where:t}):``}catch{return``}}function io(e,t){return{release:e,types:we().map(e=>e.type).filter(e=>!t||e===t).map(e=>({type:e,specVersion:Ce(e).specVersion,diagrams:Se(e).map(({kind:e,version:t,status:n,since:r})=>({kind:e,version:t,status:n,since:r}))}))}}function ao(e){let t=[`Antu ${e.release}`,``];for(let n of e.types){t.push(`${n.type}: format generation ${n.specVersion}`);let e=Math.max(...n.diagrams.map(e=>e.kind.length));n.diagrams.forEach((n,r)=>t.push(` ${n.kind.padEnd(e)} v${n.version} ${n.status} since ${n.since}${r===0?` (default)`:``}`))}return t.join(`
|
|
1475
|
-
`)}var oo=`0.13.
|
|
1480
|
+
`)}var oo=`0.13.1`,so=`Antu ${oo}: check and draw an Antu diagram (JSON)
|
|
1476
1481
|
|
|
1477
1482
|
node antu.mjs validate <spec.json> is the JSON valid? (each problem, with its field path)
|
|
1478
1483
|
node antu.mjs layout <spec.json> [--orientation vertical|horizontal] [--kind K]
|
package/embed/antu-embed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Antu 0.13.
|
|
1
|
+
// Antu 0.13.1
|
|
2
2
|
// Copyright (C) 2026 Ji Cheng
|
|
3
3
|
//
|
|
4
4
|
// Antu is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
// publish them, or sell them on any terms you like. This licence covers Antu's code in the page, and the notices in
|
|
13
13
|
// the page must stay with it.
|
|
14
14
|
//
|
|
15
|
-
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.
|
|
16
|
-
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
17
|
-
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
15
|
+
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.1
|
|
16
|
+
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.1/LICENSE
|
|
17
|
+
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.1/skills/antu/THIRD-PARTY-NOTICES.md
|
|
18
18
|
//
|
|
19
19
|
// === The licence of Antu ===
|
|
20
20
|
//
|
|
@@ -66871,10 +66871,18 @@ function Vy({ ref: e, graph: t, fitKey: n, fitWidth: r = !1, fitSelf: i = !1, fi
|
|
|
66871
66871
|
(0, E.useEffect)(() => {
|
|
66872
66872
|
y((e) => {
|
|
66873
66873
|
let n = new Map(e.map((e) => [e.id, e]));
|
|
66874
|
-
return [Ere(t.size), ...t.nodes].map((e) =>
|
|
66875
|
-
|
|
66876
|
-
|
|
66877
|
-
|
|
66874
|
+
return [Ere(t.size), ...t.nodes].map((e) => {
|
|
66875
|
+
let t = n.get(e.id);
|
|
66876
|
+
if (!t) return e;
|
|
66877
|
+
let r = e;
|
|
66878
|
+
return t.measured && t.type === e.type && (r = {
|
|
66879
|
+
...r,
|
|
66880
|
+
measured: t.measured
|
|
66881
|
+
}), t.selected ? {
|
|
66882
|
+
...r,
|
|
66883
|
+
selected: !0
|
|
66884
|
+
} : r;
|
|
66885
|
+
});
|
|
66878
66886
|
}), S(t.edges);
|
|
66879
66887
|
}, [
|
|
66880
66888
|
t,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Antu 0.13.
|
|
1
|
+
// Antu 0.13.1
|
|
2
2
|
// Copyright (C) 2026 Ji Cheng
|
|
3
3
|
//
|
|
4
4
|
// Antu is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
// publish them, or sell them on any terms you like. This licence covers Antu's code in the page, and the notices in
|
|
13
13
|
// the page must stay with it.
|
|
14
14
|
//
|
|
15
|
-
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.
|
|
16
|
-
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
17
|
-
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
15
|
+
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.1
|
|
16
|
+
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.1/LICENSE
|
|
17
|
+
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.1/skills/antu/THIRD-PARTY-NOTICES.md
|
|
18
18
|
//
|
|
19
19
|
// === The licence of Antu ===
|
|
20
20
|
//
|
package/lib/html.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Antu 0.13.
|
|
1
|
+
// Antu 0.13.1
|
|
2
2
|
// Copyright (C) 2026 Ji Cheng
|
|
3
3
|
//
|
|
4
4
|
// Antu is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
// publish them, or sell them on any terms you like. This licence covers Antu's code in the page, and the notices in
|
|
13
13
|
// the page must stay with it.
|
|
14
14
|
//
|
|
15
|
-
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.
|
|
16
|
-
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
17
|
-
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
15
|
+
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.1
|
|
16
|
+
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.1/LICENSE
|
|
17
|
+
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.1/skills/antu/THIRD-PARTY-NOTICES.md
|
|
18
18
|
//
|
|
19
19
|
// === The licence of Antu ===
|
|
20
20
|
//
|
package/lib/validate.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Antu 0.13.
|
|
1
|
+
// Antu 0.13.1
|
|
2
2
|
// Copyright (C) 2026 Ji Cheng
|
|
3
3
|
//
|
|
4
4
|
// Antu is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
// publish them, or sell them on any terms you like. This licence covers Antu's code in the page, and the notices in
|
|
13
13
|
// the page must stay with it.
|
|
14
14
|
//
|
|
15
|
-
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.
|
|
16
|
-
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
17
|
-
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.
|
|
15
|
+
// Corresponding Source of this version: https://github.com/zh-xx/Antu/tree/v0.13.1
|
|
16
|
+
// The licence: https://github.com/zh-xx/Antu/blob/v0.13.1/LICENSE
|
|
17
|
+
// Third-party notices: https://github.com/zh-xx/Antu/blob/v0.13.1/skills/antu/THIRD-PARTY-NOTICES.md
|
|
18
18
|
//
|
|
19
19
|
// === The licence of Antu ===
|
|
20
20
|
//
|
|
@@ -1422,4 +1422,4 @@
|
|
|
1422
1422
|
// SOFTWARE.
|
|
1423
1423
|
// ````
|
|
1424
1424
|
//
|
|
1425
|
-
import{a as e,c as t,d as n,i as r,l as i,n as a,r as o,t as s,u as c}from"./chunks/report-BTsYMUG2.mjs";function l(e,r){return{release:e,types:n().map(e=>e.type).filter(e=>!r||e===r).map(e=>({type:e,specVersion:i(e).specVersion,diagrams:t(e).map(({kind:e,version:t,status:n,since:r})=>({kind:e,version:t,status:n,since:r}))}))}}function u(e){if(typeof e!=`object`||!e||Array.isArray(e))return{spec:e,changes:[]};let t=structuredClone(e),n=typeof t.type==`string`?i(t.type)?.normalize:void 0;return{spec:t,changes:n?[...n(t)]:[]}}var d=`0.13.
|
|
1425
|
+
import{a as e,c as t,d as n,i as r,l as i,n as a,r as o,t as s,u as c}from"./chunks/report-BTsYMUG2.mjs";function l(e,r){return{release:e,types:n().map(e=>e.type).filter(e=>!r||e===r).map(e=>({type:e,specVersion:i(e).specVersion,diagrams:t(e).map(({kind:e,version:t,status:n,since:r})=>({kind:e,version:t,status:n,since:r}))}))}}function u(e){if(typeof e!=`object`||!e||Array.isArray(e))return{spec:e,changes:[]};let t=structuredClone(e),n=typeof t.type==`string`?i(t.type)?.normalize:void 0;return{spec:t,changes:n?[...n(t)]:[]}}var d=`0.13.1`;function f(t){let n=e(t);return{ok:n.length===0,errors:[...n],notes:n.length?[]:[...r(t)]}}function p(t,{kind:n,orientation:r}={}){let i=e(t);if(i.length)return{ok:!1,reason:`the spec is not valid`,errors:[...i]};let c=a(t,n);if(c)return{ok:!1,reason:c};let l=o(t,{kind:n,orientation:r});return l.ok?{...l,text:s(l)}:l}function m(e){return u(e)}function h(){return Object.fromEntries(n().map(({type:e})=>[e,c(e)]))}function g(){return l(d)}export{h as kinds,p as layout,m as normalize,f as validate,g as versions};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zh-xx/antu",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "Antu: legal diagrams (fact, procedure, relationship, justification) from JSON, as one offline HTML page. The command line, the MCP server, and the entries to embed a diagram in an application.",
|
|
5
5
|
"license": "AGPL-3.0-or-later",
|
|
6
6
|
"author": "Ji Cheng",
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/zh-xx/Antu",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.13.
|
|
9
|
+
"version": "0.13.1",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@zh-xx/antu",
|
|
14
|
-
"version": "0.13.
|
|
14
|
+
"version": "0.13.1",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
}
|