@lincyaw/aegis-ui 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"DetailBeside.js","sources":["../../../src/components/ui/DetailBeside.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport {\n type ViewBounds,\n scrollerOf,\n viewBoundsOf,\n} from '../../lib/scrollView';\nimport './DetailBeside.css';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\nexport interface DetailBesideProps {\n /**\n * `grid-template-columns` of the list and the detail above 768 px, e.g.\n * `'3fr 2fr'`.\n */\n columns: string;\n /**\n * The selected item's detail: one element, such as a `Panel` titled with\n * the item's name. It is never taller than the view, so a long Panel\n * scrolls its body.\n */\n detail: ReactNode;\n /**\n * The list: a `TraceTree`, `FileTree`, `DataTable` or `ServiceMap`, in a\n * Panel say. The detail follows the row it draws selected.\n */\n children: ReactNode;\n /** The element that scrolls the page; omitted or null means the viewport. */\n scrollContainer?: HTMLElement | null;\n className?: string;\n}\n\nconst NARROW_QUERY = '(max-width: 768px)';\n\n/**\n * The detail as the inline slot draws it. It is kept out of the context the\n * lists read, so a new detail re-renders the slot and not the list.\n */\nconst DetailContext = createContext<ReactNode>(null);\n\n/**\n * How far to scroll so the row is in the view, clear of the `inset` at the\n * view's top, and the detail, whose top can rise no higher than `ceiling`,\n * fits above the view's bottom.\n */\nfunction revealDistance(\n row: DOMRect,\n ceiling: number,\n height: number,\n inset: number,\n view: ViewBounds,\n): number {\n const top = view.top + inset;\n const toRow =\n row.top < top ? row.top - top : Math.max(row.bottom - view.bottom, 0);\n return Math.max(toRow, ceiling + height - view.bottom);\n}\n\n/** The detail right after the selected row, at 768 px and below. */\nfunction InlineDetail({ boxRef }: { boxRef: RefObject<HTMLDivElement> }) {\n const detail = useContext(DetailContext);\n return (\n <div ref={boxRef} className=\"aegis-detail-beside__inline\" role=\"group\">\n {detail}\n </div>\n );\n}\n\n/**\n * A tree, table or map with the selected item's detail beside it. Above\n * 768 px the detail stands in a column on the right, level with the\n * selected row: when the row is too low for it, its bottom meets the\n * view's bottom, and while the page scrolls it stays in the view below\n * the header. At 768 px and below the list draws the detail right after\n * the selected row, the rows that follow under it; a map draws it over\n * the map, under the node. When the page opens with a selection, the\n * selection changes or the selected row is clicked, the page scrolls at\n * once, as little as it takes to show the row and the detail whole, and\n * again whenever the list or the detail changes size, until the viewer\n * scrolls. The wrapper is `aria-busy` while the selected row is still on\n * its way.\n */\nexport function DetailBeside({\n columns,\n detail,\n children,\n scrollContainer = null,\n className,\n}: DetailBesideProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const [busy, setBusy] = useState(false);\n const listRef = useRef<HTMLDivElement>(null);\n const spacerRef = useRef<HTMLDivElement>(null);\n const detailRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLElement | null>(null);\n /** Whether the page is still where the last reveal left it. */\n const followRef = useRef(false);\n const revealedAtRef = useRef(0);\n\n /**\n * Sets the detail level with the row: above 768 px through the spacer's\n * height, at and below by telling the inline detail how tall the row is.\n */\n const place = useCallback(() => {\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n if (spacer === null) {\n box.style.setProperty(\n '--aegis-detail-beside-row-height',\n `${String(rowBox.height)}px`,\n );\n } else {\n const top = spacer.getBoundingClientRect().top;\n spacer.style.height = `${String(Math.max(rowBox.top - top, 0))}px`;\n }\n }, []);\n\n /** Places the row and scrolls as little as it takes to show it and its detail whole. */\n const reveal = useCallback(() => {\n place();\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n const distance = revealDistance(\n rowBox,\n spacer === null ? rowBox.bottom : spacer.getBoundingClientRect().top,\n box.getBoundingClientRect().height,\n parseFloat(getComputedStyle(box).scrollMarginTop),\n viewBoundsOf(scrollContainer),\n );\n const scroller = scrollerOf(scrollContainer);\n if (Math.abs(distance) >= 1) {\n scroller.scrollBy({ top: distance, behavior: 'instant' });\n }\n revealedAtRef.current = scroller.scrollTop;\n }, [place, scrollContainer]);\n\n // A list places its row while React attaches refs, before the detail's\n // own ref is in and before the re-renders its layout effects ask for,\n // so the reveal waits for the commit to finish.\n const revealSoon = useCallback(() => {\n followRef.current = true;\n setBusy(true);\n queueMicrotask(() => {\n reveal();\n setBusy(false);\n });\n }, [reveal]);\n\n const placeRow = useCallback(\n (row: HTMLElement | null) => {\n const moved = row !== null && row === rowRef.current;\n rowRef.current = row;\n if (moved) {\n place();\n } else if (row === null) {\n followRef.current = false;\n setBusy(false);\n } else {\n revealSoon();\n }\n },\n [place, revealSoon],\n );\n\n const awaitRow = useCallback(() => {\n setBusy(true);\n }, []);\n\n useIsomorphicLayoutEffect(place);\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (list === null) {\n return undefined;\n }\n const observer = new ResizeObserver(() => {\n if (followRef.current) {\n reveal();\n } else {\n place();\n }\n });\n // At 768 px and below the detail lies inside the list.\n for (const box of narrow ? [list] : [list, detailRef.current]) {\n if (box !== null) {\n observer.observe(box);\n }\n }\n const activate = (event: MouseEvent): void => {\n if (\n event.target instanceof Node &&\n rowRef.current?.contains(event.target)\n ) {\n revealSoon();\n }\n };\n list.addEventListener('click', activate);\n return () => {\n observer.disconnect();\n list.removeEventListener('click', activate);\n };\n }, [narrow, place, reveal, revealSoon]);\n\n useEffect(() => {\n const scroller = scrollerOf(scrollContainer);\n const target = scrollContainer ?? window;\n const scrolled = (): void => {\n if (Math.abs(scroller.scrollTop - revealedAtRef.current) >= 1) {\n followRef.current = false;\n }\n };\n target.addEventListener('scroll', scrolled, { passive: true });\n return () => {\n target.removeEventListener('scroll', scrolled);\n };\n }, [scrollContainer]);\n\n const inline = useMemo(\n () => (narrow ? <InlineDetail boxRef={detailRef} /> : null),\n [narrow],\n );\n const slot = useMemo(\n (): SelectedRowDetail => ({ placeRow, awaitRow, inline }),\n [placeRow, awaitRow, inline],\n );\n const isolated = (\n <SelectedRowDetailContext.Provider value={null}>\n {detail}\n </SelectedRowDetailContext.Provider>\n );\n\n const cls = ['aegis-detail-beside', className ?? '']\n .filter(Boolean)\n .join(' ');\n\n return (\n <SelectedRowDetailContext.Provider value={slot}>\n <DetailContext.Provider value={isolated}>\n <div\n className={cls}\n style={{ '--aegis-detail-beside-columns': columns } as CSSProperties}\n aria-busy={busy || undefined}\n >\n <div ref={listRef} className=\"aegis-detail-beside__list\">\n {children}\n </div>\n {!narrow && (\n <div className=\"aegis-detail-beside__side\">\n <div ref={spacerRef} />\n <div ref={detailRef} className=\"aegis-detail-beside__detail\">\n {isolated}\n </div>\n </div>\n )}\n </div>\n </DetailContext.Provider>\n </SelectedRowDetailContext.Provider>\n );\n}\n"],"names":["NARROW_QUERY","DetailContext","createContext","revealDistance","row","ceiling","height","inset","view","top","toRow","InlineDetail","boxRef","detail","useContext","jsx","DetailBeside","columns","children","scrollContainer","className","narrow","useMediaQuery","busy","setBusy","useState","listRef","useRef","spacerRef","detailRef","rowRef","followRef","revealedAtRef","place","useCallback","box","rowBox","spacer","reveal","distance","viewBoundsOf","scroller","scrollerOf","revealSoon","placeRow","moved","awaitRow","useIsomorphicLayoutEffect","list","observer","activate","event","useEffect","target","scrolled","inline","useMemo","slot","isolated","SelectedRowDetailContext","cls","jsxs"],"mappings":";;;;;;;AAgDA,MAAMA,IAAe,sBAMfC,IAAgBC,EAAyB,IAAI;AAOnD,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACQ;AACR,QAAMC,IAAMD,EAAK,MAAMD,GAC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ACE,gBAAAL,EAAC4C,EAAyB,UAAzB,EAAkC,OAAOF,GACxC,UAAA,gBAAA1C,EAACd,EAAc,UAAd,EAAuB,OAAOyD,GAC7B,UAAA,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWD;AAAA,MACX,OAAO,EAAE,iCAAiC3C,EAAA;AAAA,MAC1C,aAAWM,KAAQ;AAAA,MAEnB,UAAA;AAAA,QAAA,gBAAAR,EAAC,OAAA,EAAI,KAAKW,GAAS,WAAU,6BAC1B,UAAAR,GACH;AAAA,QACC,CAACG,KACA,gBAAAwC,EAAC,OAAA,EAAI,WAAU,6BACb,UAAA;AAAA,UAAA,gBAAA9C,EAAC,OAAA,EAAI,KAAKa,EAAA,CAAW;AAAA,4BACpB,OAAA,EAAI,KAAKC,GAAW,WAAU,+BAC5B,UAAA6B,EAAA,CACH;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAGN,EAAA,CACF;AAEJ;"}
1
+ {"version":3,"file":"DetailBeside.js","sources":["../../../src/components/ui/DetailBeside.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport {\n type ViewBounds,\n scrollerOf,\n viewBoundsOf,\n} from '../../lib/scrollView';\nimport './DetailBeside.css';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\nexport interface DetailBesideProps {\n /**\n * `grid-template-columns` of the list and the detail above 768 px, e.g.\n * `'3fr 2fr'`.\n */\n columns: string;\n /**\n * The selected item's detail: one element, such as a `Panel` titled with\n * the item's name. It is never taller than the view, so a long Panel\n * scrolls its body. Render it anew from the host's data whenever that\n * data changes: that render tells DetailBeside the change was new data,\n * so the page stays where it is. A detail that fetches its own data and\n * redraws without this host rendering leaves the page following the row,\n * and its next change of size scrolls the page.\n */\n detail: ReactNode;\n /**\n * The list: a `TraceTree`, `FileTree`, `DataTable` or `ServiceMap`, in a\n * Panel say. The detail follows the row it draws selected. Like\n * `detail`, render it anew from the host's data whenever that data\n * changes, so the page stays where it is on new data; a list that fetches\n * its own data and redraws without this host rendering leaves the page\n * following the row, and its next change of size scrolls the page.\n */\n children: ReactNode;\n /**\n * The selection as the page's address names it, or null where the\n * address names none and the list shows a default. It changes only by\n * the viewer's doing: a click, a key, a link, back or forward. The page\n * scrolls to the selected row when this changes, and on the first\n * placement after mount; a row that comes into place for new data, such\n * as a default the data moved, is only levelled with.\n */\n revealKey: string | null;\n /** The element that scrolls the page; omitted or null means the viewport. */\n scrollContainer?: HTMLElement | null;\n className?: string;\n}\n\nconst NARROW_QUERY = '(max-width: 768px)';\n\n/**\n * The detail as the inline slot draws it. It is kept out of the context the\n * lists read, so a new detail re-renders the slot and not the list.\n */\nconst DetailContext = createContext<ReactNode>(null);\n\n/**\n * How far to scroll so the row is in the view, clear of the `inset` at the\n * view's top, and the detail, whose top can rise no higher than `ceiling`,\n * fits above the view's bottom.\n */\nfunction revealDistance(\n row: DOMRect,\n ceiling: number,\n height: number,\n inset: number,\n view: ViewBounds,\n): number {\n const top = view.top + inset;\n const toRow =\n row.top < top ? row.top - top : Math.max(row.bottom - view.bottom, 0);\n return Math.max(toRow, ceiling + height - view.bottom);\n}\n\n/** The detail right after the selected row, at 768 px and below. */\nfunction InlineDetail({ boxRef }: { boxRef: RefObject<HTMLDivElement> }) {\n const detail = useContext(DetailContext);\n return (\n <div ref={boxRef} className=\"aegis-detail-beside__inline\" role=\"group\">\n {detail}\n </div>\n );\n}\n\n/**\n * A tree, table or map with the selected item's detail beside it. Above\n * 768 px the detail stands in a column on the right, level with the\n * selected row: when the row is too low for it, its bottom meets the\n * view's bottom, and while the page scrolls it stays in the view below\n * the header. At 768 px and below the list draws the detail right after\n * the selected row, the rows that follow under it; a map draws it over\n * the map, under the node. When the page opens with a selection,\n * `revealKey` changes or the viewer clicks the selected row, the page\n * scrolls at once, as little as it takes to show the row and the detail\n * whole, and again whenever the list or the detail changes size, until the\n * viewer scrolls or the host renders a new list or detail. Any other\n * placement, such as new data moving the selection or the rows, levels\n * the detail with its row by the same rule and leaves the page where it\n * is; the browser's scroll anchoring can still move it when rows arrive\n * above the view, unless the host sets `overflow-anchor: none` on its\n * scroller. The wrapper is `aria-busy` while a selected row it reveals is\n * still on its way.\n */\nexport function DetailBeside({\n columns,\n detail,\n children,\n revealKey,\n scrollContainer = null,\n className,\n}: DetailBesideProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const [busy, setBusy] = useState(false);\n const listRef = useRef<HTMLDivElement>(null);\n const spacerRef = useRef<HTMLDivElement>(null);\n const detailRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLElement | null>(null);\n /** Whether the page is still where the last reveal left it. */\n const followRef = useRef(false);\n const revealedAtRef = useRef(0);\n /** The latest render's revealKey, and the last reveal's: undefined before the first. */\n const revealKeyRef = useRef(revealKey);\n const revealedKeyRef = useRef<string | null | undefined>(undefined);\n /** The latest render's list and detail, which change when the host renders them anew. */\n const shownRef = useRef({ children, detail });\n\n /**\n * Sets the detail level with the row: above 768 px through the spacer's\n * height, at and below by telling the inline detail how tall the row is.\n */\n const place = useCallback(() => {\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n if (spacer === null) {\n box.style.setProperty(\n '--aegis-detail-beside-row-height',\n `${String(rowBox.height)}px`,\n );\n } else {\n const top = spacer.getBoundingClientRect().top;\n spacer.style.height = `${String(Math.max(rowBox.top - top, 0))}px`;\n }\n }, []);\n\n /** Places the row and scrolls as little as it takes to show it and its detail whole. */\n const reveal = useCallback(() => {\n place();\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n const distance = revealDistance(\n rowBox,\n spacer === null ? rowBox.bottom : spacer.getBoundingClientRect().top,\n box.getBoundingClientRect().height,\n parseFloat(getComputedStyle(box).scrollMarginTop),\n viewBoundsOf(scrollContainer),\n );\n const scroller = scrollerOf(scrollContainer);\n if (Math.abs(distance) >= 1) {\n scroller.scrollBy({ top: distance, behavior: 'instant' });\n }\n revealedAtRef.current = scroller.scrollTop;\n }, [place, scrollContainer]);\n\n // A list places its row while React attaches refs, before the detail's\n // own ref is in and before the re-renders its layout effects ask for,\n // so the reveal waits for the commit to finish.\n const revealSoon = useCallback(() => {\n revealedKeyRef.current = revealKeyRef.current;\n followRef.current = true;\n setBusy(true);\n queueMicrotask(() => {\n reveal();\n setBusy(false);\n });\n }, [reveal]);\n\n // A row placed while a reveal is due is revealed; any other is levelled\n // with, and a new one ends following.\n const placeRow = useCallback(\n (row: HTMLElement | null) => {\n const fresh = row !== rowRef.current;\n rowRef.current = row;\n if (row === null) {\n followRef.current = false;\n setBusy(false);\n } else if (revealedKeyRef.current !== revealKeyRef.current) {\n revealSoon();\n } else {\n if (fresh) {\n followRef.current = false;\n }\n place();\n }\n },\n [place, revealSoon],\n );\n\n const awaitRow = useCallback(() => {\n setBusy(true);\n }, []);\n\n // Runs after the lists have placed their rows in this commit, so a new\n // revealKey reveals the row it selects. A render by the host without one\n // ends following.\n useIsomorphicLayoutEffect(() => {\n const rendered =\n shownRef.current.children !== children ||\n shownRef.current.detail !== detail;\n shownRef.current = { children, detail };\n revealKeyRef.current = revealKey;\n if (revealedKeyRef.current !== revealKey && rowRef.current !== null) {\n revealSoon();\n } else {\n if (rendered) {\n followRef.current = false;\n }\n place();\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (list === null) {\n return undefined;\n }\n const observer = new ResizeObserver(() => {\n if (followRef.current) {\n reveal();\n } else {\n place();\n }\n });\n // At 768 px and below the detail lies inside the list.\n for (const box of narrow ? [list] : [list, detailRef.current]) {\n if (box !== null) {\n observer.observe(box);\n }\n }\n const activate = (event: MouseEvent): void => {\n if (\n event.target instanceof Node &&\n rowRef.current?.contains(event.target)\n ) {\n revealSoon();\n }\n };\n list.addEventListener('click', activate);\n return () => {\n observer.disconnect();\n list.removeEventListener('click', activate);\n };\n }, [narrow, place, reveal, revealSoon]);\n\n useEffect(() => {\n const scroller = scrollerOf(scrollContainer);\n const target = scrollContainer ?? window;\n const scrolled = (): void => {\n if (Math.abs(scroller.scrollTop - revealedAtRef.current) >= 1) {\n followRef.current = false;\n }\n };\n target.addEventListener('scroll', scrolled, { passive: true });\n return () => {\n target.removeEventListener('scroll', scrolled);\n };\n }, [scrollContainer]);\n\n const inline = useMemo(\n () => (narrow ? <InlineDetail boxRef={detailRef} /> : null),\n [narrow],\n );\n const slot = useMemo(\n (): SelectedRowDetail => ({ placeRow, awaitRow, inline }),\n [placeRow, awaitRow, inline],\n );\n const isolated = (\n <SelectedRowDetailContext.Provider value={null}>\n {detail}\n </SelectedRowDetailContext.Provider>\n );\n\n const cls = ['aegis-detail-beside', className ?? '']\n .filter(Boolean)\n .join(' ');\n\n return (\n <SelectedRowDetailContext.Provider value={slot}>\n <DetailContext.Provider value={isolated}>\n <div\n className={cls}\n style={{ '--aegis-detail-beside-columns': columns } as CSSProperties}\n aria-busy={busy || undefined}\n >\n <div ref={listRef} className=\"aegis-detail-beside__list\">\n {children}\n </div>\n {!narrow && (\n <div className=\"aegis-detail-beside__side\">\n <div ref={spacerRef} />\n <div ref={detailRef} className=\"aegis-detail-beside__detail\">\n {isolated}\n </div>\n </div>\n )}\n </div>\n </DetailContext.Provider>\n </SelectedRowDetailContext.Provider>\n );\n}\n"],"names":["NARROW_QUERY","DetailContext","createContext","revealDistance","row","ceiling","height","inset","view","top","toRow","InlineDetail","boxRef","detail","useContext","jsx","DetailBeside","columns","children","revealKey","scrollContainer","className","narrow","useMediaQuery","busy","setBusy","useState","listRef","useRef","spacerRef","detailRef","rowRef","followRef","revealedAtRef","revealKeyRef","revealedKeyRef","shownRef","place","useCallback","box","rowBox","spacer","reveal","distance","viewBoundsOf","scroller","scrollerOf","revealSoon","placeRow","fresh","awaitRow","useIsomorphicLayoutEffect","rendered","list","observer","activate","event","useEffect","target","scrolled","inline","useMemo","slot","isolated","SelectedRowDetailContext","cls","jsxs"],"mappings":";;;;;;;AAiEA,MAAMA,IAAe,sBAMfC,IAAgBC,EAAyB,IAAI;AAOnD,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACQ;AACR,QAAMC,IAAMD,EAAK,MAAMD,GACjBG,IACJN,EAAI,MAAMK,IAAML,EAAI,MAAMK,IAAM,KAAK,IAAIL,EAAI,SAASI,EAAK,QAAQ,CAAC;AACtE,SAAO,KAAK,IAAIE,GAAOL,IAAUC,IAASE,EAAK,MAAM;AACvD;AAGA,SAASG,EAAa,EAAE,QAAAC,KAAiD;AACvE,QAAMC,IAASC,EAAWb,CAAa;AACvC,SACE,gBAAAc,EAAC,SAAI,KAAKH,GAAQ,WAAU,+BAA8B,MAAK,SAC5D,UAAAC,EAAA,CACH;AAEJ;AAqBO,SAASG,GAAa;AAAA,EAC3B,SAAAC;AAAA,EACA,QAAAJ;AAAA,EACA,UAAAK;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,WAAAC;AACF,GAAsB;AACpB,QAAMC,IAASC,EAAcvB,CAAY,GACnC,CAACwB,GAAMC,CAAO,IAAIC,EAAS,EAAK,GAChCC,IAAUC,EAAuB,IAAI,GACrCC,IAAYD,EAAuB,IAAI,GACvCE,IAAYF,EAAuB,IAAI,GACvCG,IAASH,EAA2B,IAAI,GAExCI,IAAYJ,EAAO,EAAK,GACxBK,IAAgBL,EAAO,CAAC,GAExBM,IAAeN,EAAOT,CAAS,GAC/BgB,IAAiBP,EAAkC,MAAS,GAE5DQ,IAAWR,EAAO,EAAE,UAAAV,GAAU,QAAAL,GAAQ,GAMtCwB,IAAQC,EAAY,MAAM;AA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,UAAA,gBAAAnD,EAAC,OAAA,EAAI,KAAKc,EAAA,CAAW;AAAA,4BACpB,OAAA,EAAI,KAAKC,GAAW,WAAU,+BAC5B,UAAAiC,EAAA,CACH;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAGN,EAAA,CACF;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),h=require("react"),Y=require("@dagrejs/dagre"),g=require("@xyflow/react"),Z=require("../../hooks/useIsomorphicLayoutEffect.cjs"),ne=require("../../hooks/useMediaQuery.cjs");;/* empty css */const ae=require("./StatusDot.cjs"),re=require("./selectedRowDetail.cjs"),ce=require("../../locale/useStrings.cjs"),U=180,W=64,le=320,Q=28,de=64,ue={"--aegis-service-map-node-w":`${String(U)}px`,"--aegis-service-map-node-h":`${String(W)}px`,"--aegis-service-map-node-max-w":`${String(le)}px`,"--aegis-service-map-group-label-h":`${String(Q)}px`},ge={width:U,height:W};function pe(t,o,r,n){const a=t.map(s=>s.id),p=new Set(a);return{direction:n,ids:a,links:o.filter(s=>p.has(s.source)&&p.has(s.target)).map(s=>[s.source,s.target]),groups:r}}function me(t,o){const r=new Set(t),n=new Set,a=o.map(s=>{const l=[...new Set(s.nodeIds)].filter(i=>r.has(i)&&!n.has(i));return l.forEach(i=>n.add(i)),{group:s,ids:l}}),p=t.filter(s=>!n.has(s));return[...a,{ids:p}].filter(s=>s.ids.length>0)}function fe(t,o,r,n){const a=new Y.graphlib.Graph;a.setDefaultEdgeLabel(()=>({})),a.setGraph({rankdir:r,nodesep:40,ranksep:80,marginx:16,marginy:16});for(const i of t)a.setNode(i,{...n(i)});for(const[i,e]of o)a.hasNode(i)&&a.hasNode(e)&&a.setEdge(i,e);Y.layout(a);const p=new Map(t.map(i=>{const{x:e=0,y:m=0}=a.node(i),f=n(i);return[i,{x:e-f.width/2,y:m-f.height/2}]})),{width:s=0,height:l=0}=a.graph();return{positions:p,width:s,height:l}}function he(t,o,r){const n=e=>`${r}-group-${String(t.groups.indexOf(e))}`,a=t.direction==="LR",p=me(t.ids,t.groups).map(e=>{const m=fe(e.ids,t.links,t.direction,v=>o.get(v)??ge),f=e.group===void 0?0:Q;return{...e,...m,labelHeight:f,boxHeight:m.height+f}}),s=Math.max(0,...p.map(e=>a?e.boxHeight:e.width));let l=0;const i=p.map(e=>{const m=a?{x:l,y:(s-e.boxHeight)/2}:{x:(s-e.width)/2,y:l};return l+=(a?e.width:e.boxHeight)+de,{...e,origin:m}});return{groups:i.flatMap(e=>e.group===void 0?[]:[{id:`group:${e.group.id}`,type:"serviceGroup",position:e.origin,width:e.width,height:e.boxHeight,data:{label:e.group.label,labelId:n(e.group)},domAttributes:{"aria-roledescription":void 0,"aria-describedby":void 0},zIndex:-1,style:{pointerEvents:"none"},draggable:!1,connectable:!1,selectable:!1,focusable:!1}]),positions:new Map(i.flatMap(e=>[...e.positions].map(([m,f])=>[m,{x:e.origin.x+f.x,y:e.origin.y+e.labelHeight+f.y}]))),groupLabels:new Map(i.flatMap(e=>{const{group:m}=e;return m===void 0?[]:e.ids.map(f=>[f,n(m)])}))}}function ve({data:t}){return d.jsx("div",{className:"aegis-service-map__group",children:d.jsx("span",{id:t.labelId,className:"aegis-service-map__group-label",children:t.label})})}const be={ok:"ink",active:"ink",warn:"caution",error:"warning",muted:"muted"};function _e({data:t}){const{node:o,selected:r}=t,n=o.status??"ok",a=be[n];return d.jsxs("div",{className:["aegis-service-map__node",`aegis-service-map__node--${n}`,r?"aegis-service-map__node--selected":""].filter(Boolean).join(" "),children:[d.jsx(g.Handle,{type:"target",position:g.Position.Left,className:"aegis-service-map__handle"}),d.jsxs("div",{className:"aegis-service-map__node-body",children:[d.jsxs("div",{className:"aegis-service-map__node-label",children:[d.jsx(ae.StatusDot,{pulse:n==="active",tone:r&&a==="ink"?"inverted":a}),d.jsx("span",{className:"aegis-service-map__node-label-text",children:o.label})]}),o.sublabel!==void 0&&d.jsx("div",{className:"aegis-service-map__node-sublabel",children:o.sublabel})]}),o.badge!==void 0&&o.badge!==""&&d.jsx("span",{className:`aegis-service-map__node-badge aegis-service-map__node-badge--${n}`,children:o.badge}),d.jsx(g.Handle,{type:"source",position:g.Position.Right,className:"aegis-service-map__handle"})]})}function xe(t){const{sourceX:o,sourceY:r,targetX:n,targetY:a,label:p,markerEnd:s,style:l}=t,i=h.useId(),e=(o+n)/2,m=`M${o},${r} C${e},${r} ${e},${a} ${n},${a}`;return d.jsxs(d.Fragment,{children:[d.jsx("path",{d:m,className:"aegis-service-map__edge-focus",fill:"none"}),d.jsx("path",{id:i,d:m,className:"aegis-service-map__edge-path",markerEnd:s,style:l,fill:"none"}),p!==void 0&&p!==""&&d.jsx("text",{className:"aegis-service-map__edge-label",children:d.jsx("textPath",{href:`#${i}`,startOffset:"50%",textAnchor:"middle",children:p})})]})}const we={service:_e,serviceGroup:ve},ye={service:xe},Se="(max-width: 768px)",j=24,V=.1,B=1,X=11/13,q=15,J=28,K=200,C=t=>`${t}px`;function Me(t,o){return[...new Set([t,...o.filter(([r])=>r===t).map(([,r])=>r),...o.filter(([,r])=>r===t).map(([r])=>r)])]}function Ne(t){return t.type==="serviceGroup"?"aegis-service-map__minimap-group":""}function Ee(t,o,r,n,a,p){const{fitView:s,getNodes:l,getNodesBounds:i,setViewport:e}=g.useReactFlow(),m=g.useStoreApi(),f=g.useStore(x=>x.width>0&&x.height>0),v=h.useMemo(()=>n!==void 0&&t.ids.includes(n)?{id:n,near:Me(n,t.links)}:void 0,[n,t]),[M,P]=h.useState();return h.useEffect(()=>{if(f&&r){const x=()=>{P(v?.id??null)},w={top:C(j),bottom:C(j),left:C(q+J+j),right:C(a?q+K+j:j)},{width:N,height:S}=m.getState();if(v===void 0){const O=l(),E=i(O),L=g.getViewportForBounds(E,N,S,V,1,w);if(p&&L.zoom<X){const _=X,T=t.direction==="LR",H=y=>T?y.position.x:y.position.y,A=O.filter(y=>y.type==="service").reduce((y,I)=>H(I)<H(y)?I:y),{width:F=U,height:z=W}=A.measured??{};e(T?{x:q+J+j-E.x*_,y:S/2-(A.position.y+z/2)*_,zoom:_}:{x:N/2-(A.position.x+F/2)*_,y:j-E.y*_,zoom:_}).then(x)}else s({maxZoom:1,padding:w}).then(x)}else{const O=g.getViewportForBounds(i(v.near),N,S,V,B,w).zoom>=B;s({nodes:(O?v.near:[v.id]).map(E=>({id:E})),minZoom:B,maxZoom:B,padding:w}).then(x)}}},[f,r,o,v,a,p,t.direction,m,s,l,i,e]),M===(v?.id??null)}function Re({nodeId:t,selection:o}){const r=g.useStore(e=>e.transform),n=g.useStore(e=>e.domNode),a=g.useInternalNode(t);Z.useIsomorphicLayoutEffect(()=>()=>{o.placeRow(null)},[o]),Z.useIsomorphicLayoutEffect(()=>{const e=n?.querySelector(`.react-flow__node[data-id="${CSS.escape(t)}"]`);e instanceof HTMLElement&&o.placeRow(e)},[o,n,t,r]);const p=a?.measured.height;if(o.inline===null||a===void 0||p===void 0)return null;const[,s,l]=r,i=(a.internals.positionAbsolute.y+p)*l+s;return d.jsx("div",{className:"aegis-service-map__detail",style:{marginTop:Math.max(i,0)},children:o.inline})}function je(){const{getViewport:t,setViewport:o}=g.useReactFlow();return h.useCallback(r=>{const n=r.target;if(!(n instanceof Element)||!n.matches(".react-flow__node:focus-visible, .react-flow__edge:focus-visible"))return;const{scrollLeft:a,scrollTop:p}=r.currentTarget,s=r.currentTarget.getBoundingClientRect(),l=n.getBoundingClientRect(),i=l.left-s.left+a,e=l.top-s.top+p;if(i>=0&&e>=0&&i+l.width<=s.width&&e+l.height<=s.height)return;const{x:m,y:f,zoom:v}=t();o({x:m+s.width/2-(i+l.width/2),y:f+s.height/2-(e+l.height/2),zoom:v})},[t,o])}function Oe({nodes:t,edges:o,groups:r=[],direction:n="LR",height:a,fillViewport:p=!1,onNodeClick:s,onEdgeClick:l,selectedNodeId:i,focusNodeId:e,minimap:m=e===void 0,ariaLabel:f,className:v}){const M=ce.useStrings(),P=h.useId(),x=`aegis-service-map${P.replace(/:/g,"-")}`,w=s!==void 0,N=l!==void 0,[S,O]=h.useState(()=>new Map),E=h.useMemo(()=>JSON.stringify(pe(t,o,r,n)),[t,o,r,n]),L=h.useMemo(()=>JSON.parse(E),[E]),_=h.useMemo(()=>he(L,S,P),[L,S,P]),T=n==="LR",H=h.useMemo(()=>[..._.groups,...t.map(u=>{const c=[_.groupLabels.get(u.id),w?`react-flow__node-desc-${x}`:void 0].filter(Boolean).join(" ");return{id:u.id,type:"service",position:_.positions.get(u.id)??{x:0,y:0},measured:S.get(u.id),ariaLabel:u.label,ariaRole:"group",domAttributes:{"aria-roledescription":M.serviceMapNodeRole,"aria-current":i===u.id?!0:void 0,"aria-describedby":c===""?void 0:c},data:{node:u,selected:i===u.id},sourcePosition:T?g.Position.Right:g.Position.Bottom,targetPosition:T?g.Position.Left:g.Position.Top,draggable:!1,connectable:!1,selectable:w,focusable:w}})],[_,t,S,i,T,w,x,M]),A=h.useMemo(()=>{const u=new Map(t.map(c=>[c.id,c.label]));return o.map(c=>({id:c.id,source:c.source,target:c.target,ariaLabel:M.serviceMapEdgeName(u.get(c.source)??c.source,u.get(c.target)??c.target),ariaRole:"group",domAttributes:{"aria-roledescription":M.serviceMapEdgeRole},type:"service",data:{edge:c},label:c.label,selectable:N,focusable:N,className:`aegis-service-map__edge aegis-service-map__edge--${c.status??"ok"}`}))},[t,o,N,M]),{getNode:F}=g.useReactFlow(),z=h.useCallback(u=>{const c=u.flatMap(b=>b.type==="dimensions"&&b.dimensions!==void 0&&F(b.id)?.type==="service"?[[b.id,b.dimensions]]:[]);O(b=>c.every(([R,D])=>b.get(R)?.width===D.width&&b.get(R)?.height===D.height)?b:new Map([...b,...c]))},[F]),y=ne.useMediaQuery(Se),I=m&&!y,$=h.useContext(re.SelectedRowDetailContext),G=Ee(L,_,t.every(u=>S.has(u.id)),e,I,y),k=i!==void 0&&L.ids.includes(i)?i:void 0;Z.useIsomorphicLayoutEffect(()=>{if(!($===null||k===void 0||G))return $.awaitRow(),()=>{$.placeRow(null)}},[$,k,G]);const ee=je(),te=h.useCallback((u,c)=>{c.type==="service"&&s?.(c.data.node)},[s]),se=h.useCallback((u,c)=>{c.data&&l?.(c.data.edge)},[l]),oe=h.useCallback(u=>{if(u.key!=="Enter"&&u.key!==" "||u.repeat)return;const c=u.target;if(!(c instanceof Element))return;const b=c.getAttribute("data-id");if(c.classList.contains("react-flow__node")){const R=t.find(D=>D.id===b);R&&s&&(u.preventDefault(),s(R))}else if(c.classList.contains("react-flow__edge")){const R=o.find(D=>D.id===b);R&&l&&(u.preventDefault(),l(R))}},[t,o,s,l]),ie={...ue,height:a===void 0?void 0:`${String(a)}px`};return d.jsxs("div",{className:["aegis-service-map",p?"aegis-service-map--fill-viewport":"",v].filter(Boolean).join(" "),style:ie,children:[d.jsx("div",{className:"aegis-service-map__pane",children:d.jsxs(g.ReactFlow,{id:x,"aria-label":f,nodes:H,edges:A,nodeTypes:we,edgeTypes:ye,minZoom:V,nodesDraggable:!1,nodesConnectable:!1,autoPanOnNodeFocus:!1,panOnDrag:!0,zoomOnScroll:!0,proOptions:{hideAttribution:!0},ariaLabelConfig:M.serviceMapAriaLabels,onNodesChange:z,onNodeClick:w?te:void 0,onEdgeClick:N?se:void 0,onKeyDown:oe,onFocus:ee,children:[d.jsx(g.Background,{variant:g.BackgroundVariant.Dots,gap:16,size:1}),d.jsx(g.Controls,{showInteractive:!1,position:"top-left"}),I&&d.jsx(g.MiniMap,{pannable:!0,zoomable:!0,position:"bottom-right",style:{width:K},nodeClassName:Ne})]})}),$!==null&&G&&k!==void 0&&d.jsx(Re,{nodeId:k,selection:$})]})}function Le(t){return d.jsx(g.ReactFlowProvider,{children:d.jsx(Oe,{...t})})}exports.ServiceMap=Le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),f=require("react"),X=require("@dagrejs/dagre"),m=require("@xyflow/react"),V=require("../../hooks/useIsomorphicLayoutEffect.cjs"),re=require("../../hooks/useMediaQuery.cjs");;/* empty css */const ce=require("./StatusDot.cjs"),le=require("./selectedRowDetail.cjs"),de=require("../../locale/useStrings.cjs"),W=180,Y=64,ue=320,K=28,ge=64,pe={"--aegis-service-map-node-w":`${String(W)}px`,"--aegis-service-map-node-h":`${String(Y)}px`,"--aegis-service-map-node-max-w":`${String(ue)}px`,"--aegis-service-map-group-label-h":`${String(K)}px`},me={width:W,height:Y};function fe(e,n,o,a){const r=e.map(s=>s.id),g=new Set(r);return{direction:a,ids:r,links:n.filter(s=>g.has(s.source)&&g.has(s.target)).map(s=>[s.source,s.target]),groups:o}}function he(e,n){const o=new Set(e),a=new Set,r=n.map(s=>{const l=[...new Set(s.nodeIds)].filter(i=>o.has(i)&&!a.has(i));return l.forEach(i=>a.add(i)),{group:s,ids:l}}),g=e.filter(s=>!a.has(s));return[...r,{ids:g}].filter(s=>s.ids.length>0)}function ve(e,n,o,a){const r=new X.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:o,nodesep:40,ranksep:80,marginx:16,marginy:16});for(const i of e)r.setNode(i,{...a(i)});for(const[i,t]of n)r.hasNode(i)&&r.hasNode(t)&&r.setEdge(i,t);X.layout(r);const g=new Map(e.map(i=>{const{x:t=0,y:d=0}=r.node(i),h=a(i);return[i,{x:t-h.width/2,y:d-h.height/2}]})),{width:s=0,height:l=0}=r.graph();return{positions:g,width:s,height:l}}function be(e,n,o){const a=t=>`${o}-group-${String(e.groups.indexOf(t))}`,r=e.direction==="LR",g=he(e.ids,e.groups).map(t=>{const d=ve(t.ids,e.links,e.direction,v=>n.get(v)??me),h=t.group===void 0?0:K;return{...t,...d,labelHeight:h,boxHeight:d.height+h}}),s=Math.max(0,...g.map(t=>r?t.boxHeight:t.width));let l=0;const i=g.map(t=>{const d=r?{x:l,y:(s-t.boxHeight)/2}:{x:(s-t.width)/2,y:l};return l+=(r?t.width:t.boxHeight)+ge,{...t,origin:d}});return{groups:i.flatMap(t=>t.group===void 0?[]:[{id:`group:${t.group.id}`,type:"serviceGroup",position:t.origin,width:t.width,height:t.boxHeight,data:{label:t.group.label,labelId:a(t.group)},domAttributes:{"aria-roledescription":void 0,"aria-describedby":void 0},zIndex:-1,style:{pointerEvents:"none"},draggable:!1,connectable:!1,selectable:!1,focusable:!1}]),positions:new Map(i.flatMap(t=>[...t.positions].map(([d,h])=>[d,{x:t.origin.x+h.x,y:t.origin.y+t.labelHeight+h.y}]))),groupLabels:new Map(i.flatMap(t=>{const{group:d}=t;return d===void 0?[]:t.ids.map(h=>[h,a(d)])}))}}function _e({data:e}){return u.jsx("div",{className:"aegis-service-map__group",children:u.jsx("span",{id:e.labelId,className:"aegis-service-map__group-label",children:e.label})})}const xe={ok:"ink",active:"ink",warn:"caution",error:"warning",muted:"muted"};function we({data:e}){const{node:n,selected:o}=e,a=n.status??"ok",r=xe[a];return u.jsxs("div",{className:["aegis-service-map__node",`aegis-service-map__node--${a}`,o?"aegis-service-map__node--selected":""].filter(Boolean).join(" "),children:[u.jsx(m.Handle,{type:"target",position:m.Position.Left,className:"aegis-service-map__handle"}),u.jsxs("div",{className:"aegis-service-map__node-body",children:[u.jsxs("div",{className:"aegis-service-map__node-label",children:[u.jsx(ce.StatusDot,{pulse:a==="active",tone:o&&r==="ink"?"inverted":r}),u.jsx("span",{className:"aegis-service-map__node-label-text",children:n.label})]}),n.sublabel!==void 0&&u.jsx("div",{className:"aegis-service-map__node-sublabel",children:n.sublabel})]}),n.badge!==void 0&&n.badge!==""&&u.jsx("span",{className:`aegis-service-map__node-badge aegis-service-map__node-badge--${a}`,children:n.badge}),u.jsx(m.Handle,{type:"source",position:m.Position.Right,className:"aegis-service-map__handle"})]})}function ye(e){const{sourceX:n,sourceY:o,targetX:a,targetY:r,label:g,markerEnd:s,style:l}=e,i=f.useId(),t=(n+a)/2,d=`M${n},${o} C${t},${o} ${t},${r} ${a},${r}`;return u.jsxs(u.Fragment,{children:[u.jsx("path",{d,className:"aegis-service-map__edge-focus",fill:"none"}),u.jsx("path",{id:i,d,className:"aegis-service-map__edge-path",markerEnd:s,style:l,fill:"none"}),g!==void 0&&g!==""&&u.jsx("text",{className:"aegis-service-map__edge-label",children:u.jsx("textPath",{href:`#${i}`,startOffset:"50%",textAnchor:"middle",children:g})})]})}const Se={service:we,serviceGroup:_e},Me={service:ye},Ne="(max-width: 768px)",j=24,U=.1,C=1,J=11/13,Z=15,Q=28,ee=200,z=e=>`${e}px`;function Ee(e,n){return[...new Set([e,...n.filter(([o])=>o===e).map(([,o])=>o),...n.filter(([,o])=>o===e).map(([o])=>o)])]}function Re(e){return e.type==="serviceGroup"?"aegis-service-map__minimap-group":""}function je(e,n,o,a,r,g){const{fitView:s,getNodes:l,getNodesBounds:i,setViewport:t}=m.useReactFlow(),d=m.useStoreApi(),h=m.useStore(x=>x.width>0&&x.height>0),v=f.useMemo(()=>a!==void 0&&e.ids.includes(a)?{id:a,near:Ee(a,e.links)}:void 0,[a,e]),[M,I]=f.useState();return f.useEffect(()=>{if(h&&o){const x=()=>{I(v?.id??null)},w={top:z(j),bottom:z(j),left:z(Z+Q+j),right:z(r?Z+ee+j:j)},{width:N,height:S}=d.getState();if(v===void 0){const O=l(),E=i(O),L=m.getViewportForBounds(E,N,S,U,1,w);if(g&&L.zoom<J){const _=J,T=e.direction==="LR",H=y=>T?y.position.x:y.position.y,P=O.filter(y=>y.type==="service").reduce((y,A)=>H(A)<H(y)?A:y),{width:F=W,height:G=Y}=P.measured??{};t(T?{x:Z+Q+j-E.x*_,y:S/2-(P.position.y+G/2)*_,zoom:_}:{x:N/2-(P.position.x+F/2)*_,y:j-E.y*_,zoom:_}).then(x)}else s({maxZoom:1,padding:w}).then(x)}else{const O=m.getViewportForBounds(i(v.near),N,S,U,C,w).zoom>=C;s({nodes:(O?v.near:[v.id]).map(E=>({id:E})),minZoom:C,maxZoom:C,padding:w}).then(x)}}},[h,o,n,v,r,g,e.direction,d,s,l,i,t]),M===(v?.id??null)}function Oe({nodeId:e,fitted:n,selection:o}){const a=m.useStore(d=>d.transform),r=m.useStore(d=>d.domNode),g=m.useInternalNode(e);V.useIsomorphicLayoutEffect(()=>()=>{o.placeRow(null)},[o]),V.useIsomorphicLayoutEffect(()=>{const d=r?.querySelector(`.react-flow__node[data-id="${CSS.escape(e)}"]`);n&&d instanceof HTMLElement&&o.placeRow(d)},[o,r,e,a,n]);const s=g?.measured.height;if(o.inline===null||g===void 0||s===void 0)return null;const[,l,i]=a,t=(g.internals.positionAbsolute.y+s)*i+l;return u.jsx("div",{className:"aegis-service-map__detail",style:{marginTop:Math.max(t,0)},children:o.inline})}function Le(){const{getViewport:e,setViewport:n}=m.useReactFlow();return f.useCallback(o=>{const a=o.target;if(!(a instanceof Element)||!a.matches(".react-flow__node:focus-visible, .react-flow__edge:focus-visible"))return;const{scrollLeft:r,scrollTop:g}=o.currentTarget,s=o.currentTarget.getBoundingClientRect(),l=a.getBoundingClientRect(),i=l.left-s.left+r,t=l.top-s.top+g;if(i>=0&&t>=0&&i+l.width<=s.width&&t+l.height<=s.height)return;const{x:d,y:h,zoom:v}=e();n({x:d+s.width/2-(i+l.width/2),y:h+s.height/2-(t+l.height/2),zoom:v})},[e,n])}function Te({nodes:e,edges:n,groups:o=[],direction:a="LR",height:r,fillViewport:g=!1,onNodeClick:s,onEdgeClick:l,selectedNodeId:i,focusNodeId:t,minimap:d=t===void 0,ariaLabel:h,className:v}){const M=de.useStrings(),I=f.useId(),x=`aegis-service-map${I.replace(/:/g,"-")}`,w=s!==void 0,N=l!==void 0,[S,O]=f.useState(()=>new Map),E=f.useMemo(()=>JSON.stringify(fe(e,n,o,a)),[e,n,o,a]),L=f.useMemo(()=>JSON.parse(E),[E]),_=f.useMemo(()=>be(L,S,I),[L,S,I]),T=a==="LR",H=f.useMemo(()=>[..._.groups,...e.map(p=>{const c=[_.groupLabels.get(p.id),w?`react-flow__node-desc-${x}`:void 0].filter(Boolean).join(" ");return{id:p.id,type:"service",position:_.positions.get(p.id)??{x:0,y:0},measured:S.get(p.id),ariaLabel:p.label,ariaRole:"group",domAttributes:{"aria-roledescription":M.serviceMapNodeRole,"aria-current":i===p.id?!0:void 0,"aria-describedby":c===""?void 0:c},data:{node:p,selected:i===p.id},sourcePosition:T?m.Position.Right:m.Position.Bottom,targetPosition:T?m.Position.Left:m.Position.Top,draggable:!1,connectable:!1,selectable:w,focusable:w}})],[_,e,S,i,T,w,x,M]),P=f.useMemo(()=>{const p=new Map(e.map(c=>[c.id,c.label]));return n.map(c=>({id:c.id,source:c.source,target:c.target,ariaLabel:M.serviceMapEdgeName(p.get(c.source)??c.source,p.get(c.target)??c.target),ariaRole:"group",domAttributes:{"aria-roledescription":M.serviceMapEdgeRole},type:"service",data:{edge:c},label:c.label,selectable:N,focusable:N,className:`aegis-service-map__edge aegis-service-map__edge--${c.status??"ok"}`}))},[e,n,N,M]),{getNode:F}=m.useReactFlow(),G=f.useCallback(p=>{const c=p.flatMap(b=>b.type==="dimensions"&&b.dimensions!==void 0&&F(b.id)?.type==="service"?[[b.id,b.dimensions]]:[]);O(b=>c.every(([R,$])=>b.get(R)?.width===$.width&&b.get(R)?.height===$.height)?b:new Map([...b,...c]))},[F]),y=re.useMediaQuery(Ne),A=d&&!y,D=f.useContext(le.SelectedRowDetailContext),k=je(L,_,e.every(p=>S.has(p.id)),t,A,y),B=i!==void 0&&L.ids.includes(i)?i:void 0,[q,te]=f.useState();k&&q!==B&&te(B),V.useIsomorphicLayoutEffect(()=>{if(!(D===null||B===void 0||k))return D.awaitRow(),()=>{D.placeRow(null)}},[D,B,k]);const se=Le(),oe=f.useCallback((p,c)=>{c.type==="service"&&s?.(c.data.node)},[s]),ie=f.useCallback((p,c)=>{c.data&&l?.(c.data.edge)},[l]),ne=f.useCallback(p=>{if(p.key!=="Enter"&&p.key!==" "||p.repeat)return;const c=p.target;if(!(c instanceof Element))return;const b=c.getAttribute("data-id");if(c.classList.contains("react-flow__node")){const R=e.find($=>$.id===b);R&&s&&(p.preventDefault(),s(R))}else if(c.classList.contains("react-flow__edge")){const R=n.find($=>$.id===b);R&&l&&(p.preventDefault(),l(R))}},[e,n,s,l]),ae={...pe,height:r===void 0?void 0:`${String(r)}px`};return u.jsxs("div",{className:["aegis-service-map",g?"aegis-service-map--fill-viewport":"",v].filter(Boolean).join(" "),style:ae,children:[u.jsx("div",{className:"aegis-service-map__pane",children:u.jsxs(m.ReactFlow,{id:x,"aria-label":h,nodes:H,edges:P,nodeTypes:Se,edgeTypes:Me,minZoom:U,nodesDraggable:!1,nodesConnectable:!1,autoPanOnNodeFocus:!1,panOnDrag:!0,zoomOnScroll:!0,proOptions:{hideAttribution:!0},ariaLabelConfig:M.serviceMapAriaLabels,onNodesChange:G,onNodeClick:w?oe:void 0,onEdgeClick:N?ie:void 0,onKeyDown:ne,onFocus:se,children:[u.jsx(m.Background,{variant:m.BackgroundVariant.Dots,gap:16,size:1}),u.jsx(m.Controls,{showInteractive:!1,position:"top-left"}),A&&u.jsx(m.MiniMap,{pannable:!0,zoomable:!0,position:"bottom-right",style:{width:ee},nodeClassName:Re})]})}),D!==null&&q!==void 0&&u.jsx(Oe,{nodeId:q,fitted:k,selection:D})]})}function De(e){return u.jsx(m.ReactFlowProvider,{children:u.jsx(Te,{...e})})}exports.ServiceMap=De;
2
2
  //# sourceMappingURL=ServiceMap.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceMap.cjs","sources":["../../../src/components/ui/ServiceMap.tsx"],"sourcesContent":["// Service-map composition adapted from HyperDX (MIT, DeploySentinel Inc. 2023):\n// https://github.com/hyperdxio/hyperdx/blob/main/packages/app/src/components/ServiceMap/ServiceMap.tsx\nimport {\n type CSSProperties,\n type ComponentProps,\n type FocusEvent,\n type KeyboardEvent,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react';\n\nimport {\n type EdgeLabel,\n type GraphLabel,\n type NodeLabel,\n layout as dagreLayout,\n graphlib,\n} from '@dagrejs/dagre';\nimport {\n Background,\n BackgroundVariant,\n Controls,\n type Edge,\n type EdgeProps,\n Handle,\n MiniMap,\n type Node,\n type NodeChange,\n type NodeProps,\n Position,\n ReactFlow,\n ReactFlowProvider,\n type XYPosition,\n getViewportForBounds,\n useInternalNode,\n useReactFlow,\n useStore,\n useStoreApi,\n} from '@xyflow/react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { useStrings } from '../../locale';\nimport './ServiceMap.css';\nimport { StatusDot } from './StatusDot';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\n/**\n * Drawn as a dot before the node's label. `active` is work in progress, e.g.\n * a running task: the ink dot pulses.\n */\nexport type ServiceMapStatus = 'ok' | 'active' | 'warn' | 'error' | 'muted';\nexport type ServiceMapDirection = 'LR' | 'TB';\n\nexport interface ServiceMapNode {\n id: string;\n label: string;\n sublabel?: string;\n status?: ServiceMapStatus;\n badge?: number | string;\n data?: Record<string, unknown>;\n}\n\n/**\n * A labelled box around some nodes, e.g. the tasks of one phase. Its id may\n * also be a node's id.\n */\nexport interface ServiceMapGroup {\n id: string;\n label: string;\n nodeIds: string[];\n}\n\n/** For assistive technology, named by its nodes' labels, e.g. \"checkout to payments\". */\nexport interface ServiceMapEdge {\n id: string;\n source: string;\n target: string;\n label?: string;\n /** `active` is a node's state only. */\n status?: Exclude<ServiceMapStatus, 'active'>;\n}\n\nexport interface ServiceMapProps {\n nodes: ServiceMapNode[];\n edges: ServiceMapEdge[];\n /**\n * Boxes drawn around groups of nodes, e.g. the phases of a pipeline. The\n * groups follow one another along `direction` in the order given, each\n * laid out on its own; nodes in no group come after the last group. A\n * node belongs to the first group that lists it.\n */\n groups?: ServiceMapGroup[];\n direction?: ServiceMapDirection;\n /** Height in px. Default: the container's height, at least `--service-map-min-height`. */\n height?: number;\n /**\n * Fill the viewport's height below the shell header\n * (`--service-map-viewport-height`), for a page whose main view is the\n * map. At 768 px and below the map keeps its default height, so a touch\n * can still scroll the page past it. `height` overrides it.\n */\n fillViewport?: boolean;\n /**\n * Called when a node is clicked, or gets Enter or Space while focused.\n * Without it nodes can be neither focused nor selected.\n */\n onNodeClick?: (node: ServiceMapNode) => void;\n /** The same for edges. */\n onEdgeClick?: (edge: ServiceMapEdge) => void;\n /** Drawn inverted, and `aria-current` for assistive technology. */\n selectedNodeId?: string;\n /**\n * Opens at actual size on this node instead of fitting the whole map, and\n * again whenever it changes: fitted to the node and the nodes it has a\n * direct edge to or from when they fit at actual size, otherwise centred\n * on the node alone. Large maps stay readable when they open. An id that\n * is not on the map is ignored.\n *\n * Without it the map opens fitted whole. At 768 px and below a map that\n * fits only below a readable size opens at the smallest readable zoom on\n * its start instead, the left edge for `LR` and the top for `TB`, to be\n * panned from there.\n */\n focusNodeId?: string;\n /**\n * Show the minimap in the bottom-right corner. A fit keeps its strip on\n * the right clear, so a map fitted whole opens with no node under it.\n * Default: shown unless `focusNodeId` is given, since a focused view runs\n * past every edge of the map and the minimap would cover nodes there. It\n * is not shown at 768 px and below.\n */\n minimap?: boolean;\n /**\n * The map's accessible name. Each node is a `group` named by its label\n * and, in a group, described by the group's label; a group's box is not\n * a `group`.\n */\n ariaLabel?: string;\n className?: string;\n}\n\ninterface ServiceNodeData extends Record<string, unknown> {\n node: ServiceMapNode;\n selected: boolean;\n}\n\ninterface ServiceGroupData extends Record<string, unknown> {\n label: string;\n /** The label's element id, which the group's nodes are described by. */\n labelId: string;\n}\n\ntype ServiceFlowNode =\n | Node<ServiceNodeData, 'service'>\n | Node<ServiceGroupData, 'serviceGroup'>;\n\ninterface ServiceEdgeData extends Record<string, unknown> {\n edge: ServiceMapEdge;\n}\n\n/** A node is at least this size; it widens with its label up to NODE_MAX_WIDTH, then wraps it. */\nconst NODE_WIDTH = 180;\nconst NODE_HEIGHT = 64;\nconst NODE_MAX_WIDTH = 320;\n/** Room above a group's nodes for its label. */\nconst GROUP_LABEL_HEIGHT = 28;\n/** Space between consecutive groups along the direction. */\nconst GROUP_GAP = 64;\n\n// The layout reads these sizes, so the CSS node and group boxes read them too.\nconst SIZE_VARS = {\n '--aegis-service-map-node-w': `${String(NODE_WIDTH)}px`,\n '--aegis-service-map-node-h': `${String(NODE_HEIGHT)}px`,\n '--aegis-service-map-node-max-w': `${String(NODE_MAX_WIDTH)}px`,\n '--aegis-service-map-group-label-h': `${String(GROUP_LABEL_HEIGHT)}px`,\n};\n\ninterface Size {\n width: number;\n height: number;\n}\n\nconst DEFAULT_SIZE: Size = { width: NODE_WIDTH, height: NODE_HEIGHT };\n\n/** A stretch of the map laid out on its own: a group's nodes, or the nodes in no group. */\ninterface Part {\n group?: ServiceMapGroup;\n ids: string[];\n}\n\n/** What the layout and the fit read: the map without its nodes' and edges' content. */\ninterface MapShape {\n direction: ServiceMapDirection;\n ids: string[];\n /** The endpoints of each edge between two nodes on the map. */\n links: Array<[string, string]>;\n groups: ServiceMapGroup[];\n}\n\nfunction shapeOf(\n nodes: ServiceMapNode[],\n edges: ServiceMapEdge[],\n groups: ServiceMapGroup[],\n direction: ServiceMapDirection,\n): MapShape {\n const ids = nodes.map((n) => n.id);\n const present = new Set(ids);\n return {\n direction,\n ids,\n links: edges\n .filter((e) => present.has(e.source) && present.has(e.target))\n .map((e) => [e.source, e.target]),\n groups,\n };\n}\n\n/** Each group with the nodes it claims, in the order given, then the nodes in no group. */\nfunction partsOf(ids: string[], groups: ServiceMapGroup[]): Part[] {\n const present = new Set(ids);\n const claimed = new Set<string>();\n const grouped = groups.map((group) => {\n const ids = [...new Set(group.nodeIds)].filter(\n (id) => present.has(id) && !claimed.has(id),\n );\n ids.forEach((id) => claimed.add(id));\n return { group, ids };\n });\n const rest = ids.filter((id) => !claimed.has(id));\n return [...grouped, { ids: rest }].filter((part) => part.ids.length > 0);\n}\n\n/** Lays out one part with dagre: its nodes and the edges between them. Positions are top-left corners. */\nfunction layoutPart(\n ids: string[],\n links: MapShape['links'],\n direction: ServiceMapDirection,\n sizeOf: (id: string) => Size,\n): { positions: Map<string, XYPosition>; width: number; height: number } {\n const g = new graphlib.Graph<GraphLabel, NodeLabel, EdgeLabel>();\n g.setDefaultEdgeLabel(() => ({}));\n g.setGraph({\n rankdir: direction,\n nodesep: 40,\n ranksep: 80,\n marginx: 16,\n marginy: 16,\n });\n for (const id of ids) {\n g.setNode(id, { ...sizeOf(id) });\n }\n for (const [source, target] of links) {\n if (g.hasNode(source) && g.hasNode(target)) {\n g.setEdge(source, target);\n }\n }\n dagreLayout(g);\n const positions = new Map(\n ids.map((id) => {\n const { x = 0, y = 0 } = g.node(id) as { x?: number; y?: number };\n const size = sizeOf(id);\n return [id, { x: x - size.width / 2, y: y - size.height / 2 }];\n }),\n );\n const { width = 0, height = 0 } = g.graph();\n return { positions, width, height };\n}\n\ninterface MapLayout {\n /** The group boxes. */\n groups: ServiceFlowNode[];\n /** Each node's top-left corner. */\n positions: Map<string, XYPosition>;\n /** The label id of the group each grouped node is in. */\n groupLabels: Map<string, string>;\n}\n\n/**\n * Lays the parts out one after another along the direction, each centred\n * across it, with dagre inside each part.\n */\nfunction computeLayout(\n shape: MapShape,\n sizes: ReadonlyMap<string, Size>,\n idPrefix: string,\n): MapLayout {\n const labelIdOf = (group: ServiceMapGroup): string =>\n `${idPrefix}-group-${String(shape.groups.indexOf(group))}`;\n const horizontal = shape.direction === 'LR';\n const parts = partsOf(shape.ids, shape.groups).map((part) => {\n const laid = layoutPart(part.ids, shape.links, shape.direction, (id) => {\n return sizes.get(id) ?? DEFAULT_SIZE;\n });\n const labelHeight = part.group === undefined ? 0 : GROUP_LABEL_HEIGHT;\n return {\n ...part,\n ...laid,\n labelHeight,\n boxHeight: laid.height + labelHeight,\n };\n });\n const across = Math.max(\n 0,\n ...parts.map((part) => (horizontal ? part.boxHeight : part.width)),\n );\n let along = 0;\n const placed = parts.map((part) => {\n const origin = horizontal\n ? { x: along, y: (across - part.boxHeight) / 2 }\n : { x: (across - part.width) / 2, y: along };\n along += (horizontal ? part.width : part.boxHeight) + GROUP_GAP;\n return { ...part, origin };\n });\n return {\n groups: placed.flatMap((part): ServiceFlowNode[] =>\n part.group === undefined\n ? []\n : [\n {\n // Prefixed, so a group may share an id with a node.\n id: `group:${part.group.id}`,\n type: 'serviceGroup',\n position: part.origin,\n width: part.width,\n height: part.boxHeight,\n data: {\n label: part.group.label,\n labelId: labelIdOf(part.group),\n },\n // Not a group for assistive technology: the box contains no\n // nodes in the DOM, so its label is plain text, which its\n // nodes are described by. It cannot be focused, so it has no\n // keyboard help either.\n domAttributes: {\n 'aria-roledescription': undefined,\n 'aria-describedby': undefined,\n },\n // Under the edges, and letting clicks through to them: React\n // Flow gives every node's wrapper pointer events once the map\n // has onNodeClick.\n zIndex: -1,\n style: { pointerEvents: 'none' },\n draggable: false,\n connectable: false,\n selectable: false,\n focusable: false,\n },\n ],\n ),\n positions: new Map(\n placed.flatMap((part) =>\n [...part.positions].map(([id, p]) => [\n id,\n {\n x: part.origin.x + p.x,\n y: part.origin.y + part.labelHeight + p.y,\n },\n ]),\n ),\n ),\n groupLabels: new Map(\n placed.flatMap((part) => {\n const { group } = part;\n return group === undefined\n ? []\n : part.ids.map((id) => [id, labelIdOf(group)] as const);\n }),\n ),\n };\n}\n\nfunction ServiceGroup({\n data,\n}: NodeProps<Node<ServiceGroupData, 'serviceGroup'>>): JSX.Element {\n return (\n <div className=\"aegis-service-map__group\">\n <span id={data.labelId} className=\"aegis-service-map__group-label\">\n {data.label}\n </span>\n </div>\n );\n}\n\nconst DOT_TONE: Record<\n ServiceMapStatus,\n NonNullable<ComponentProps<typeof StatusDot>['tone']>\n> = {\n ok: 'ink',\n active: 'ink',\n warn: 'caution',\n error: 'warning',\n muted: 'muted',\n};\n\nfunction ServiceNode({\n data,\n}: NodeProps<Node<ServiceNodeData, 'service'>>): JSX.Element {\n const { node, selected } = data;\n const status = node.status ?? 'ok';\n const tone = DOT_TONE[status];\n return (\n <div\n className={[\n 'aegis-service-map__node',\n `aegis-service-map__node--${status}`,\n selected ? 'aegis-service-map__node--selected' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <Handle\n type=\"target\"\n position={Position.Left}\n className=\"aegis-service-map__handle\"\n />\n <div className=\"aegis-service-map__node-body\">\n <div className=\"aegis-service-map__node-label\">\n <StatusDot\n pulse={status === 'active'}\n tone={selected && tone === 'ink' ? 'inverted' : tone}\n />\n <span className=\"aegis-service-map__node-label-text\">\n {node.label}\n </span>\n </div>\n {node.sublabel !== undefined && (\n <div className=\"aegis-service-map__node-sublabel\">\n {node.sublabel}\n </div>\n )}\n </div>\n {node.badge !== undefined && node.badge !== '' && (\n <span\n className={`aegis-service-map__node-badge aegis-service-map__node-badge--${status}`}\n >\n {node.badge}\n </span>\n )}\n <Handle\n type=\"source\"\n position={Position.Right}\n className=\"aegis-service-map__handle\"\n />\n </div>\n );\n}\n\nfunction ServiceEdge(props: EdgeProps<Edge<ServiceEdgeData>>): JSX.Element {\n const { sourceX, sourceY, targetX, targetY, label, markerEnd, style } = props;\n // The label follows the path by its id, which must be unique on the page,\n // also when two maps share edge ids.\n const pathId = useId();\n const midX = (sourceX + targetX) / 2;\n const path = `M${sourceX},${sourceY} C${midX},${sourceY} ${midX},${targetY} ${targetX},${targetY}`;\n return (\n <>\n {/* The focus ring, drawn along the path under it. */}\n <path d={path} className=\"aegis-service-map__edge-focus\" fill=\"none\" />\n <path\n id={pathId}\n d={path}\n className=\"aegis-service-map__edge-path\"\n markerEnd={markerEnd}\n style={style}\n fill=\"none\"\n />\n {label !== undefined && label !== '' && (\n <text className=\"aegis-service-map__edge-label\">\n <textPath href={`#${pathId}`} startOffset=\"50%\" textAnchor=\"middle\">\n {label}\n </textPath>\n </text>\n )}\n </>\n );\n}\n\nconst NODE_TYPES = { service: ServiceNode, serviceGroup: ServiceGroup };\nconst EDGE_TYPES = { service: ServiceEdge };\n\nconst NARROW_QUERY = '(max-width: 768px)';\n/** Space kept clear around fitted nodes, in px. */\nconst FIT_MARGIN = 24;\n/** Low enough that fitting the whole map fits it, so the minimap's strip stays clear. */\nconst MIN_ZOOM = 0.1;\n/** A focused map opens at this zoom, so its labels are readable. */\nconst FOCUS_ZOOM = 1;\n/** The smallest zoom a narrow map opens at: a node's 13 px label reads at 11 px. */\nconst READABLE_ZOOM = 11 / 13;\n// React Flow draws the controls and the minimap in panels inset by 15 px. A\n// control button is 26 px, 28 inside the controls' hairline border.\nconst PANEL_INSET = 15;\nconst CONTROLS_WIDTH = 28;\nconst MINIMAP_WIDTH = 200;\n\n/** A fit padding in px; React Flow reads a bare number as a fraction of the view. */\nconst px = (value: number): `${number}px` => `${value}px`;\n\n/** A node with the nodes it has a direct edge to or from. */\nfunction neighbourhood(id: string, links: MapShape['links']): string[] {\n return [\n ...new Set([\n id,\n ...links.filter(([source]) => source === id).map(([, target]) => target),\n ...links.filter(([, target]) => target === id).map(([source]) => source),\n ]),\n ];\n}\n\n/** The minimap draws groups as outlines, so the nodes inside them stay visible. */\nfunction minimapNodeClass(node: Node): string {\n return node.type === 'serviceGroup' ? 'aegis-service-map__minimap-group' : '';\n}\n\n/**\n * Fits the view once the layout uses every node's measured size, and again\n * when the layout or the focus changes. Nothing else moves the view, so a\n * new status or selection keeps the user's pan and zoom. Returns whether\n * the view has been fitted to the current focus.\n */\nfunction useFit(\n shape: MapShape,\n layout: MapLayout,\n laidOut: boolean,\n focusNodeId: string | undefined,\n showMinimap: boolean,\n narrow: boolean,\n): boolean {\n const { fitView, getNodes, getNodesBounds, setViewport } = useReactFlow();\n const store = useStoreApi();\n const paneSized = useStore((state) => state.width > 0 && state.height > 0);\n const focus = useMemo(\n () =>\n focusNodeId !== undefined && shape.ids.includes(focusNodeId)\n ? { id: focusNodeId, near: neighbourhood(focusNodeId, shape.links) }\n : undefined,\n [focusNodeId, shape],\n );\n const [fittedTo, setFittedTo] = useState<string | null>();\n useEffect(() => {\n if (paneSized && laidOut) {\n const settle = (): void => {\n setFittedTo(focus?.id ?? null);\n };\n const padding = {\n top: px(FIT_MARGIN),\n bottom: px(FIT_MARGIN),\n left: px(PANEL_INSET + CONTROLS_WIDTH + FIT_MARGIN),\n right: px(\n showMinimap ? PANEL_INSET + MINIMAP_WIDTH + FIT_MARGIN : FIT_MARGIN,\n ),\n };\n const { width, height } = store.getState();\n if (focus === undefined) {\n const all = getNodes();\n const bounds = getNodesBounds(all);\n const fitted = getViewportForBounds(\n bounds,\n width,\n height,\n MIN_ZOOM,\n 1,\n padding,\n );\n if (narrow && fitted.zoom < READABLE_ZOOM) {\n // A phone has no minimap and too little room for the whole map,\n // so it opens where the map starts, on its first node.\n const zoom = READABLE_ZOOM;\n const horizontal = shape.direction === 'LR';\n const along = (n: Node): number =>\n horizontal ? n.position.x : n.position.y;\n const first = all\n .filter((n) => n.type === 'service')\n .reduce((a, b) => (along(b) < along(a) ? b : a));\n const { width: w = NODE_WIDTH, height: h = NODE_HEIGHT } =\n first.measured ?? {};\n void setViewport(\n horizontal\n ? {\n x:\n PANEL_INSET + CONTROLS_WIDTH + FIT_MARGIN - bounds.x * zoom,\n y: height / 2 - (first.position.y + h / 2) * zoom,\n zoom,\n }\n : {\n x: width / 2 - (first.position.x + w / 2) * zoom,\n y: FIT_MARGIN - bounds.y * zoom,\n zoom,\n },\n ).then(settle);\n } else {\n void fitView({ maxZoom: 1, padding }).then(settle);\n }\n } else {\n const nearFits =\n getViewportForBounds(\n getNodesBounds(focus.near),\n width,\n height,\n MIN_ZOOM,\n FOCUS_ZOOM,\n padding,\n ).zoom >= FOCUS_ZOOM;\n void fitView({\n nodes: (nearFits ? focus.near : [focus.id]).map((id) => ({ id })),\n minZoom: FOCUS_ZOOM,\n maxZoom: FOCUS_ZOOM,\n padding,\n }).then(settle);\n }\n }\n }, [\n paneSized,\n laidOut,\n layout,\n focus,\n showMinimap,\n narrow,\n shape.direction,\n store,\n fitView,\n getNodes,\n getNodesBounds,\n setViewport,\n ]);\n return fittedTo === (focus?.id ?? null);\n}\n\n/**\n * The selected node of a map in a `DetailBeside`, once the view is fitted:\n * it places the node's box, again whenever the map pans or zooms, and at\n * 768 px and below draws the detail right under the node, over the map,\n * which grows to hold it.\n */\nfunction ServiceMapSelection({\n nodeId,\n selection,\n}: {\n nodeId: string;\n selection: SelectedRowDetail;\n}): JSX.Element | null {\n const transform = useStore((state) => state.transform);\n const domNode = useStore((state) => state.domNode);\n const node = useInternalNode(nodeId);\n // The node goes only with this component, so a pan places the same node\n // again rather than a new one.\n useIsomorphicLayoutEffect(\n () => () => {\n selection.placeRow(null);\n },\n [selection],\n );\n useIsomorphicLayoutEffect(() => {\n const group = domNode?.querySelector(\n `.react-flow__node[data-id=\"${CSS.escape(nodeId)}\"]`,\n );\n if (group instanceof HTMLElement) {\n selection.placeRow(group);\n }\n }, [selection, domNode, nodeId, transform]);\n const height = node?.measured.height;\n if (selection.inline === null || node === undefined || height === undefined) {\n return null;\n }\n const [, y, zoom] = transform;\n const bottom = (node.internals.positionAbsolute.y + height) * zoom + y;\n return (\n <div\n className=\"aegis-service-map__detail\"\n style={{ marginTop: Math.max(bottom, 0) }}\n >\n {selection.inline}\n </div>\n );\n}\n\n/**\n * Pans a node or edge that gets keyboard focus fully into view, centred.\n * React Flow pans only to a node entirely outside the view, and never to\n * an edge.\n */\nfunction usePanToFocused(): (event: FocusEvent<HTMLDivElement>) => void {\n const { getViewport, setViewport } = useReactFlow();\n return useCallback(\n (event: FocusEvent<HTMLDivElement>) => {\n const target = event.target;\n if (\n !(target instanceof Element) ||\n !target.matches(\n '.react-flow__node:focus-visible, .react-flow__edge:focus-visible',\n )\n ) {\n return;\n }\n // The browser has already scrolled the pane to the element, and React\n // Flow scrolls it back, so the offset is added back to place it.\n const { scrollLeft, scrollTop } = event.currentTarget;\n const pane = event.currentTarget.getBoundingClientRect();\n const box = target.getBoundingClientRect();\n const left = box.left - pane.left + scrollLeft;\n const top = box.top - pane.top + scrollTop;\n if (\n left >= 0 &&\n top >= 0 &&\n left + box.width <= pane.width &&\n top + box.height <= pane.height\n ) {\n return;\n }\n const { x, y, zoom } = getViewport();\n void setViewport({\n x: x + pane.width / 2 - (left + box.width / 2),\n y: y + pane.height / 2 - (top + box.height / 2),\n zoom,\n });\n },\n [getViewport, setViewport],\n );\n}\n\nfunction ServiceMapInner({\n nodes,\n edges,\n groups = [],\n direction = 'LR',\n height,\n fillViewport = false,\n onNodeClick,\n onEdgeClick,\n selectedNodeId,\n focusNodeId,\n minimap = focusNodeId === undefined,\n ariaLabel,\n className,\n}: ServiceMapProps): JSX.Element {\n const strings = useStrings();\n const idPrefix = useId();\n // React Flow names its elements after this id ('1' when none is given),\n // so each map passes its own and a page can hold several.\n const flowId = `aegis-service-map${idPrefix.replace(/:/g, '-')}`;\n const nodesSelectable = onNodeClick !== undefined;\n const edgesSelectable = onEdgeClick !== undefined;\n // Node sizes as React Flow measured them; the layout reads them, so a\n // node can be as wide as its label.\n const [measured, setMeasured] = useState<ReadonlyMap<string, Size>>(\n () => new Map(),\n );\n const shapeJson = useMemo(\n () => JSON.stringify(shapeOf(nodes, edges, groups, direction)),\n [nodes, edges, groups, direction],\n );\n // Parsed back from its JSON, so the shape is a new object only when it\n // changes, not when the parent passes equal arrays again.\n const shape = useMemo(() => JSON.parse(shapeJson) as MapShape, [shapeJson]);\n const layout = useMemo(\n () => computeLayout(shape, measured, idPrefix),\n [shape, measured, idPrefix],\n );\n const isHorizontal = direction === 'LR';\n const flowNodes = useMemo(\n (): ServiceFlowNode[] => [\n ...layout.groups,\n ...nodes.map((n): ServiceFlowNode => {\n // A node in a group is described by the group's label. React Flow\n // describes a node by its keyboard help, the element it names\n // `react-flow__node-desc-<rfId>`; a node that cannot be selected\n // has none.\n const describedBy = [\n layout.groupLabels.get(n.id),\n nodesSelectable ? `react-flow__node-desc-${flowId}` : undefined,\n ]\n .filter(Boolean)\n .join(' ');\n return {\n id: n.id,\n type: 'service',\n position: layout.positions.get(n.id) ?? { x: 0, y: 0 },\n // Handed back as applyNodeChanges would, so React Flow keeps the\n // size it measured instead of measuring the node again.\n measured: measured.get(n.id),\n ariaLabel: n.label,\n // React Flow gives only a focusable node a role, and the role\n // description below needs one.\n ariaRole: 'group',\n domAttributes: {\n 'aria-roledescription': strings.serviceMapNodeRole,\n // A group takes no aria-selected.\n 'aria-current': selectedNodeId === n.id ? true : undefined,\n 'aria-describedby': describedBy === '' ? undefined : describedBy,\n },\n data: { node: n, selected: selectedNodeId === n.id },\n sourcePosition: isHorizontal ? Position.Right : Position.Bottom,\n targetPosition: isHorizontal ? Position.Left : Position.Top,\n draggable: false,\n connectable: false,\n selectable: nodesSelectable,\n focusable: nodesSelectable,\n };\n }),\n ],\n [\n layout,\n nodes,\n measured,\n selectedNodeId,\n isHorizontal,\n nodesSelectable,\n flowId,\n strings,\n ],\n );\n const flowEdges = useMemo((): Array<Edge<ServiceEdgeData>> => {\n const labelOf = new Map(nodes.map((n) => [n.id, n.label]));\n return edges.map((e) => ({\n id: e.id,\n source: e.source,\n target: e.target,\n ariaLabel: strings.serviceMapEdgeName(\n labelOf.get(e.source) ?? e.source,\n labelOf.get(e.target) ?? e.target,\n ),\n // React Flow makes an unfocusable edge an img; aria-roledescription needs a group.\n ariaRole: 'group',\n domAttributes: { 'aria-roledescription': strings.serviceMapEdgeRole },\n type: 'service',\n data: { edge: e },\n label: e.label,\n selectable: edgesSelectable,\n focusable: edgesSelectable,\n className: `aegis-service-map__edge aegis-service-map__edge--${e.status ?? 'ok'}`,\n }));\n }, [nodes, edges, edgesSelectable, strings]);\n\n const { getNode } = useReactFlow();\n const handleNodesChange = useCallback(\n (changes: Array<NodeChange<ServiceFlowNode>>) => {\n const resized = changes.flatMap((change) =>\n change.type === 'dimensions' &&\n change.dimensions !== undefined &&\n getNode(change.id)?.type === 'service'\n ? [[change.id, change.dimensions] as const]\n : [],\n );\n setMeasured((previous) =>\n resized.every(\n ([id, size]) =>\n previous.get(id)?.width === size.width &&\n previous.get(id)?.height === size.height,\n )\n ? previous\n : new Map([...previous, ...resized]),\n );\n },\n [getNode],\n );\n\n const narrow = useMediaQuery(NARROW_QUERY);\n const showMinimap = minimap && !narrow;\n const selection = useContext(SelectedRowDetailContext);\n const fitted = useFit(\n shape,\n layout,\n nodes.every((n) => measured.has(n.id)),\n focusNodeId,\n showMinimap,\n narrow,\n );\n const shownId =\n selectedNodeId !== undefined && shape.ids.includes(selectedNodeId)\n ? selectedNodeId\n : undefined;\n // A DetailBeside waits while the view is fitted to a newly selected node.\n useIsomorphicLayoutEffect(() => {\n if (selection === null || shownId === undefined || fitted) {\n return undefined;\n }\n selection.awaitRow();\n return () => {\n selection.placeRow(null);\n };\n }, [selection, shownId, fitted]);\n const handleFocus = usePanToFocused();\n\n const handleNodeClick = useCallback(\n (_: unknown, n: ServiceFlowNode) => {\n if (n.type === 'service') {\n onNodeClick?.(n.data.node);\n }\n },\n [onNodeClick],\n );\n const handleEdgeClick = useCallback(\n (_: unknown, e: Edge<ServiceEdgeData>) => {\n if (e.data) {\n onEdgeClick?.(e.data.edge);\n }\n },\n [onEdgeClick],\n );\n // React Flow's own Enter and Space only change its internal selection,\n // which never reaches the host, so a focused node or edge answers the\n // keys here, as a click would.\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if ((event.key !== 'Enter' && event.key !== ' ') || event.repeat) {\n return;\n }\n const target = event.target;\n if (!(target instanceof Element)) {\n return;\n }\n const id = target.getAttribute('data-id');\n if (target.classList.contains('react-flow__node')) {\n const node = nodes.find((n) => n.id === id);\n if (node && onNodeClick) {\n event.preventDefault();\n onNodeClick(node);\n }\n } else if (target.classList.contains('react-flow__edge')) {\n const edge = edges.find((e) => e.id === id);\n if (edge && onEdgeClick) {\n event.preventDefault();\n onEdgeClick(edge);\n }\n }\n },\n [nodes, edges, onNodeClick, onEdgeClick],\n );\n\n const style = {\n ...SIZE_VARS,\n height: height === undefined ? undefined : `${String(height)}px`,\n } as CSSProperties;\n\n return (\n <div\n className={[\n 'aegis-service-map',\n fillViewport ? 'aegis-service-map--fill-viewport' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n {/* Positioned over the whole box, so React Flow has a definite height\n even when the box only has its min-height. */}\n <div className=\"aegis-service-map__pane\">\n <ReactFlow\n id={flowId}\n aria-label={ariaLabel}\n nodes={flowNodes}\n edges={flowEdges}\n nodeTypes={NODE_TYPES}\n edgeTypes={EDGE_TYPES}\n minZoom={MIN_ZOOM}\n nodesDraggable={false}\n nodesConnectable={false}\n autoPanOnNodeFocus={false}\n panOnDrag\n zoomOnScroll\n proOptions={{ hideAttribution: true }}\n ariaLabelConfig={strings.serviceMapAriaLabels}\n onNodesChange={handleNodesChange}\n onNodeClick={nodesSelectable ? handleNodeClick : undefined}\n onEdgeClick={edgesSelectable ? handleEdgeClick : undefined}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n >\n <Background variant={BackgroundVariant.Dots} gap={16} size={1} />\n <Controls showInteractive={false} position=\"top-left\" />\n {showMinimap && (\n <MiniMap\n pannable\n zoomable\n position=\"bottom-right\"\n style={{ width: MINIMAP_WIDTH }}\n nodeClassName={minimapNodeClass}\n />\n )}\n </ReactFlow>\n </div>\n {selection !== null && fitted && shownId !== undefined && (\n <ServiceMapSelection nodeId={shownId} selection={selection} />\n )}\n </div>\n );\n}\n\nexport function ServiceMap(props: ServiceMapProps): JSX.Element {\n return (\n <ReactFlowProvider>\n <ServiceMapInner {...props} />\n </ReactFlowProvider>\n );\n}\n"],"names":["NODE_WIDTH","NODE_HEIGHT","NODE_MAX_WIDTH","GROUP_LABEL_HEIGHT","GROUP_GAP","SIZE_VARS","DEFAULT_SIZE","shapeOf","nodes","edges","groups","direction","ids","n","present","e","partsOf","claimed","grouped","group","id","rest","part","layoutPart","links","sizeOf","g","graphlib","source","target","dagreLayout","positions","x","y","size","width","height","computeLayout","shape","sizes","idPrefix","labelIdOf","horizontal","parts","laid","labelHeight","across","along","placed","origin","p","ServiceGroup","data","jsx","DOT_TONE","ServiceNode","node","selected","status","tone","jsxs","Handle","Position","StatusDot","ServiceEdge","props","sourceX","sourceY","targetX","targetY","label","markerEnd","style","pathId","useId","midX","path","Fragment","NODE_TYPES","EDGE_TYPES","NARROW_QUERY","FIT_MARGIN","MIN_ZOOM","FOCUS_ZOOM","READABLE_ZOOM","PANEL_INSET","CONTROLS_WIDTH","MINIMAP_WIDTH","px","value","neighbourhood","minimapNodeClass","useFit","layout","laidOut","focusNodeId","showMinimap","narrow","fitView","getNodes","getNodesBounds","setViewport","useReactFlow","store","useStoreApi","paneSized","useStore","state","focus","useMemo","fittedTo","setFittedTo","useState","useEffect","settle","padding","all","bounds","fitted","getViewportForBounds","zoom","first","a","b","w","h","nearFits","ServiceMapSelection","nodeId","selection","transform","domNode","useInternalNode","useIsomorphicLayoutEffect","bottom","usePanToFocused","getViewport","useCallback","event","scrollLeft","scrollTop","pane","box","left","top","ServiceMapInner","fillViewport","onNodeClick","onEdgeClick","selectedNodeId","minimap","ariaLabel","className","strings","useStrings","flowId","nodesSelectable","edgesSelectable","measured","setMeasured","shapeJson","isHorizontal","flowNodes","describedBy","flowEdges","labelOf","getNode","handleNodesChange","changes","resized","change","previous","useMediaQuery","useContext","SelectedRowDetailContext","shownId","handleFocus","handleNodeClick","_","handleEdgeClick","handleKeyDown","edge","ReactFlow","Background","BackgroundVariant","Controls","MiniMap","ServiceMap","ReactFlowProvider"],"mappings":"sbAyKMA,EAAa,IACbC,EAAc,GACdC,GAAiB,IAEjBC,EAAqB,GAErBC,GAAY,GAGZC,GAAY,CAChB,6BAA8B,GAAG,OAAOL,CAAU,CAAC,KACnD,6BAA8B,GAAG,OAAOC,CAAW,CAAC,KACpD,iCAAkC,GAAG,OAAOC,EAAc,CAAC,KAC3D,oCAAqC,GAAG,OAAOC,CAAkB,CAAC,IACpE,EAOMG,GAAqB,CAAE,MAAON,EAAY,OAAQC,CAAA,EAiBxD,SAASM,GACPC,EACAC,EACAC,EACAC,EACU,CACV,MAAMC,EAAMJ,EAAM,IAAKK,GAAMA,EAAE,EAAE,EAC3BC,EAAU,IAAI,IAAIF,CAAG,EAC3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AAS,WAAW,EACrDzF,GACC3C,EAAAA,IAACqI,EAAAA,QAAA,CACC,SAAQ,GACR,SAAQ,GACR,SAAS,eACT,MAAO,CAAE,MAAOnG,CAAA,EAChB,cAAeI,EAAA,CAAA,CACjB,CAAA,CAAA,EAGN,EACCsC,IAAc,MAAQX,GAAUyD,IAAY,QAC3C1H,MAAC0E,GAAA,CAAoB,OAAQgD,EAAS,UAAA9C,CAAA,CAAsB,CAAA,CAAA,CAAA,CAIpE,CAEO,SAAS0D,GAAW1H,EAAqC,CAC9D,aACG2H,oBAAA,CACC,SAAAvI,EAAAA,IAAC4F,GAAA,CAAiB,GAAGhF,EAAO,EAC9B,CAEJ"}
1
+ {"version":3,"file":"ServiceMap.cjs","sources":["../../../src/components/ui/ServiceMap.tsx"],"sourcesContent":["// Service-map composition adapted from HyperDX (MIT, DeploySentinel Inc. 2023):\n// https://github.com/hyperdxio/hyperdx/blob/main/packages/app/src/components/ServiceMap/ServiceMap.tsx\nimport {\n type CSSProperties,\n type ComponentProps,\n type FocusEvent,\n type KeyboardEvent,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react';\n\nimport {\n type EdgeLabel,\n type GraphLabel,\n type NodeLabel,\n layout as dagreLayout,\n graphlib,\n} from '@dagrejs/dagre';\nimport {\n Background,\n BackgroundVariant,\n Controls,\n type Edge,\n type EdgeProps,\n Handle,\n MiniMap,\n type Node,\n type NodeChange,\n type NodeProps,\n Position,\n ReactFlow,\n ReactFlowProvider,\n type XYPosition,\n getViewportForBounds,\n useInternalNode,\n useReactFlow,\n useStore,\n useStoreApi,\n} from '@xyflow/react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { useStrings } from '../../locale';\nimport './ServiceMap.css';\nimport { StatusDot } from './StatusDot';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\n/**\n * Drawn as a dot before the node's label. `active` is work in progress, e.g.\n * a running task: the ink dot pulses.\n */\nexport type ServiceMapStatus = 'ok' | 'active' | 'warn' | 'error' | 'muted';\nexport type ServiceMapDirection = 'LR' | 'TB';\n\nexport interface ServiceMapNode {\n id: string;\n label: string;\n sublabel?: string;\n status?: ServiceMapStatus;\n badge?: number | string;\n data?: Record<string, unknown>;\n}\n\n/**\n * A labelled box around some nodes, e.g. the tasks of one phase. Its id may\n * also be a node's id.\n */\nexport interface ServiceMapGroup {\n id: string;\n label: string;\n nodeIds: string[];\n}\n\n/** For assistive technology, named by its nodes' labels, e.g. \"checkout to payments\". */\nexport interface ServiceMapEdge {\n id: string;\n source: string;\n target: string;\n label?: string;\n /** `active` is a node's state only. */\n status?: Exclude<ServiceMapStatus, 'active'>;\n}\n\nexport interface ServiceMapProps {\n nodes: ServiceMapNode[];\n edges: ServiceMapEdge[];\n /**\n * Boxes drawn around groups of nodes, e.g. the phases of a pipeline. The\n * groups follow one another along `direction` in the order given, each\n * laid out on its own; nodes in no group come after the last group. A\n * node belongs to the first group that lists it.\n */\n groups?: ServiceMapGroup[];\n direction?: ServiceMapDirection;\n /** Height in px. Default: the container's height, at least `--service-map-min-height`. */\n height?: number;\n /**\n * Fill the viewport's height below the shell header\n * (`--service-map-viewport-height`), for a page whose main view is the\n * map. At 768 px and below the map keeps its default height, so a touch\n * can still scroll the page past it. `height` overrides it.\n */\n fillViewport?: boolean;\n /**\n * Called when a node is clicked, or gets Enter or Space while focused.\n * Without it nodes can be neither focused nor selected.\n */\n onNodeClick?: (node: ServiceMapNode) => void;\n /** The same for edges. */\n onEdgeClick?: (edge: ServiceMapEdge) => void;\n /** Drawn inverted, and `aria-current` for assistive technology. */\n selectedNodeId?: string;\n /**\n * Opens at actual size on this node instead of fitting the whole map, and\n * again whenever it changes: fitted to the node and the nodes it has a\n * direct edge to or from when they fit at actual size, otherwise centred\n * on the node alone. Large maps stay readable when they open. An id that\n * is not on the map is ignored.\n *\n * Without it the map opens fitted whole. At 768 px and below a map that\n * fits only below a readable size opens at the smallest readable zoom on\n * its start instead, the left edge for `LR` and the top for `TB`, to be\n * panned from there.\n */\n focusNodeId?: string;\n /**\n * Show the minimap in the bottom-right corner. A fit keeps its strip on\n * the right clear, so a map fitted whole opens with no node under it.\n * Default: shown unless `focusNodeId` is given, since a focused view runs\n * past every edge of the map and the minimap would cover nodes there. It\n * is not shown at 768 px and below.\n */\n minimap?: boolean;\n /**\n * The map's accessible name. Each node is a `group` named by its label\n * and, in a group, described by the group's label; a group's box is not\n * a `group`.\n */\n ariaLabel?: string;\n className?: string;\n}\n\ninterface ServiceNodeData extends Record<string, unknown> {\n node: ServiceMapNode;\n selected: boolean;\n}\n\ninterface ServiceGroupData extends Record<string, unknown> {\n label: string;\n /** The label's element id, which the group's nodes are described by. */\n labelId: string;\n}\n\ntype ServiceFlowNode =\n | Node<ServiceNodeData, 'service'>\n | Node<ServiceGroupData, 'serviceGroup'>;\n\ninterface ServiceEdgeData extends Record<string, unknown> {\n edge: ServiceMapEdge;\n}\n\n/** A node is at least this size; it widens with its label up to NODE_MAX_WIDTH, then wraps it. */\nconst NODE_WIDTH = 180;\nconst NODE_HEIGHT = 64;\nconst NODE_MAX_WIDTH = 320;\n/** Room above a group's nodes for its label. */\nconst GROUP_LABEL_HEIGHT = 28;\n/** Space between consecutive groups along the direction. */\nconst GROUP_GAP = 64;\n\n// The layout reads these sizes, so the CSS node and group boxes read them too.\nconst SIZE_VARS = {\n '--aegis-service-map-node-w': `${String(NODE_WIDTH)}px`,\n '--aegis-service-map-node-h': `${String(NODE_HEIGHT)}px`,\n '--aegis-service-map-node-max-w': `${String(NODE_MAX_WIDTH)}px`,\n '--aegis-service-map-group-label-h': `${String(GROUP_LABEL_HEIGHT)}px`,\n};\n\ninterface Size {\n width: number;\n height: number;\n}\n\nconst DEFAULT_SIZE: Size = { width: NODE_WIDTH, height: NODE_HEIGHT };\n\n/** A stretch of the map laid out on its own: a group's nodes, or the nodes in no group. */\ninterface Part {\n group?: ServiceMapGroup;\n ids: string[];\n}\n\n/** What the layout and the fit read: the map without its nodes' and edges' content. */\ninterface MapShape {\n direction: ServiceMapDirection;\n ids: string[];\n /** The endpoints of each edge between two nodes on the map. */\n links: Array<[string, string]>;\n groups: ServiceMapGroup[];\n}\n\nfunction shapeOf(\n nodes: ServiceMapNode[],\n edges: ServiceMapEdge[],\n groups: ServiceMapGroup[],\n direction: ServiceMapDirection,\n): MapShape {\n const ids = nodes.map((n) => n.id);\n const present = new Set(ids);\n return {\n direction,\n ids,\n links: edges\n .filter((e) => present.has(e.source) && present.has(e.target))\n .map((e) => [e.source, e.target]),\n groups,\n };\n}\n\n/** Each group with the nodes it claims, in the order given, then the nodes in no group. */\nfunction partsOf(ids: string[], groups: ServiceMapGroup[]): Part[] {\n const present = new Set(ids);\n const claimed = new Set<string>();\n const grouped = groups.map((group) => {\n const ids = [...new Set(group.nodeIds)].filter(\n (id) => present.has(id) && !claimed.has(id),\n );\n ids.forEach((id) => claimed.add(id));\n return { group, ids };\n });\n const rest = ids.filter((id) => !claimed.has(id));\n return [...grouped, { ids: rest }].filter((part) => part.ids.length > 0);\n}\n\n/** Lays out one part with dagre: its nodes and the edges between them. Positions are top-left corners. */\nfunction layoutPart(\n ids: string[],\n links: MapShape['links'],\n direction: ServiceMapDirection,\n sizeOf: (id: string) => Size,\n): { positions: Map<string, XYPosition>; width: number; height: number } {\n const g = new graphlib.Graph<GraphLabel, NodeLabel, EdgeLabel>();\n g.setDefaultEdgeLabel(() => ({}));\n g.setGraph({\n rankdir: direction,\n nodesep: 40,\n ranksep: 80,\n marginx: 16,\n marginy: 16,\n });\n for (const id of ids) {\n g.setNode(id, { ...sizeOf(id) });\n }\n for (const [source, target] of links) {\n if (g.hasNode(source) && g.hasNode(target)) {\n g.setEdge(source, target);\n }\n }\n dagreLayout(g);\n const positions = new Map(\n ids.map((id) => {\n const { x = 0, y = 0 } = g.node(id) as { x?: number; y?: number };\n const size = sizeOf(id);\n return [id, { x: x - size.width / 2, y: y - size.height / 2 }];\n }),\n );\n const { width = 0, height = 0 } = g.graph();\n return { positions, width, height };\n}\n\ninterface MapLayout {\n /** The group boxes. */\n groups: ServiceFlowNode[];\n /** Each node's top-left corner. */\n positions: Map<string, XYPosition>;\n /** The label id of the group each grouped node is in. */\n groupLabels: Map<string, string>;\n}\n\n/**\n * Lays the parts out one after another along the direction, each centred\n * across it, with dagre inside each part.\n */\nfunction computeLayout(\n shape: MapShape,\n sizes: ReadonlyMap<string, Size>,\n idPrefix: string,\n): MapLayout {\n const labelIdOf = (group: ServiceMapGroup): string =>\n `${idPrefix}-group-${String(shape.groups.indexOf(group))}`;\n const horizontal = shape.direction === 'LR';\n const parts = partsOf(shape.ids, shape.groups).map((part) => {\n const laid = layoutPart(part.ids, shape.links, shape.direction, (id) => {\n return sizes.get(id) ?? DEFAULT_SIZE;\n });\n const labelHeight = part.group === undefined ? 0 : GROUP_LABEL_HEIGHT;\n return {\n ...part,\n ...laid,\n labelHeight,\n boxHeight: laid.height + labelHeight,\n };\n });\n const across = Math.max(\n 0,\n ...parts.map((part) => (horizontal ? part.boxHeight : part.width)),\n );\n let along = 0;\n const placed = parts.map((part) => {\n const origin = horizontal\n ? { x: along, y: (across - part.boxHeight) / 2 }\n : { x: (across - part.width) / 2, y: along };\n along += (horizontal ? part.width : part.boxHeight) + GROUP_GAP;\n return { ...part, origin };\n });\n return {\n groups: placed.flatMap((part): ServiceFlowNode[] =>\n part.group === undefined\n ? []\n : [\n {\n // Prefixed, so a group may share an id with a node.\n id: `group:${part.group.id}`,\n type: 'serviceGroup',\n position: part.origin,\n width: part.width,\n height: part.boxHeight,\n data: {\n label: part.group.label,\n labelId: labelIdOf(part.group),\n },\n // Not a group for assistive technology: the box contains no\n // nodes in the DOM, so its label is plain text, which its\n // nodes are described by. It cannot be focused, so it has no\n // keyboard help either.\n domAttributes: {\n 'aria-roledescription': undefined,\n 'aria-describedby': undefined,\n },\n // Under the edges, and letting clicks through to them: React\n // Flow gives every node's wrapper pointer events once the map\n // has onNodeClick.\n zIndex: -1,\n style: { pointerEvents: 'none' },\n draggable: false,\n connectable: false,\n selectable: false,\n focusable: false,\n },\n ],\n ),\n positions: new Map(\n placed.flatMap((part) =>\n [...part.positions].map(([id, p]) => [\n id,\n {\n x: part.origin.x + p.x,\n y: part.origin.y + part.labelHeight + p.y,\n },\n ]),\n ),\n ),\n groupLabels: new Map(\n placed.flatMap((part) => {\n const { group } = part;\n return group === undefined\n ? []\n : part.ids.map((id) => [id, labelIdOf(group)] as const);\n }),\n ),\n };\n}\n\nfunction ServiceGroup({\n data,\n}: NodeProps<Node<ServiceGroupData, 'serviceGroup'>>): JSX.Element {\n return (\n <div className=\"aegis-service-map__group\">\n <span id={data.labelId} className=\"aegis-service-map__group-label\">\n {data.label}\n </span>\n </div>\n );\n}\n\nconst DOT_TONE: Record<\n ServiceMapStatus,\n NonNullable<ComponentProps<typeof StatusDot>['tone']>\n> = {\n ok: 'ink',\n active: 'ink',\n warn: 'caution',\n error: 'warning',\n muted: 'muted',\n};\n\nfunction ServiceNode({\n data,\n}: NodeProps<Node<ServiceNodeData, 'service'>>): JSX.Element {\n const { node, selected } = data;\n const status = node.status ?? 'ok';\n const tone = DOT_TONE[status];\n return (\n <div\n className={[\n 'aegis-service-map__node',\n `aegis-service-map__node--${status}`,\n selected ? 'aegis-service-map__node--selected' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <Handle\n type=\"target\"\n position={Position.Left}\n className=\"aegis-service-map__handle\"\n />\n <div className=\"aegis-service-map__node-body\">\n <div className=\"aegis-service-map__node-label\">\n <StatusDot\n pulse={status === 'active'}\n tone={selected && tone === 'ink' ? 'inverted' : tone}\n />\n <span className=\"aegis-service-map__node-label-text\">\n {node.label}\n </span>\n </div>\n {node.sublabel !== undefined && (\n <div className=\"aegis-service-map__node-sublabel\">\n {node.sublabel}\n </div>\n )}\n </div>\n {node.badge !== undefined && node.badge !== '' && (\n <span\n className={`aegis-service-map__node-badge aegis-service-map__node-badge--${status}`}\n >\n {node.badge}\n </span>\n )}\n <Handle\n type=\"source\"\n position={Position.Right}\n className=\"aegis-service-map__handle\"\n />\n </div>\n );\n}\n\nfunction ServiceEdge(props: EdgeProps<Edge<ServiceEdgeData>>): JSX.Element {\n const { sourceX, sourceY, targetX, targetY, label, markerEnd, style } = props;\n // The label follows the path by its id, which must be unique on the page,\n // also when two maps share edge ids.\n const pathId = useId();\n const midX = (sourceX + targetX) / 2;\n const path = `M${sourceX},${sourceY} C${midX},${sourceY} ${midX},${targetY} ${targetX},${targetY}`;\n return (\n <>\n {/* The focus ring, drawn along the path under it. */}\n <path d={path} className=\"aegis-service-map__edge-focus\" fill=\"none\" />\n <path\n id={pathId}\n d={path}\n className=\"aegis-service-map__edge-path\"\n markerEnd={markerEnd}\n style={style}\n fill=\"none\"\n />\n {label !== undefined && label !== '' && (\n <text className=\"aegis-service-map__edge-label\">\n <textPath href={`#${pathId}`} startOffset=\"50%\" textAnchor=\"middle\">\n {label}\n </textPath>\n </text>\n )}\n </>\n );\n}\n\nconst NODE_TYPES = { service: ServiceNode, serviceGroup: ServiceGroup };\nconst EDGE_TYPES = { service: ServiceEdge };\n\nconst NARROW_QUERY = '(max-width: 768px)';\n/** Space kept clear around fitted nodes, in px. */\nconst FIT_MARGIN = 24;\n/** Low enough that fitting the whole map fits it, so the minimap's strip stays clear. */\nconst MIN_ZOOM = 0.1;\n/** A focused map opens at this zoom, so its labels are readable. */\nconst FOCUS_ZOOM = 1;\n/** The smallest zoom a narrow map opens at: a node's 13 px label reads at 11 px. */\nconst READABLE_ZOOM = 11 / 13;\n// React Flow draws the controls and the minimap in panels inset by 15 px. A\n// control button is 26 px, 28 inside the controls' hairline border.\nconst PANEL_INSET = 15;\nconst CONTROLS_WIDTH = 28;\nconst MINIMAP_WIDTH = 200;\n\n/** A fit padding in px; React Flow reads a bare number as a fraction of the view. */\nconst px = (value: number): `${number}px` => `${value}px`;\n\n/** A node with the nodes it has a direct edge to or from. */\nfunction neighbourhood(id: string, links: MapShape['links']): string[] {\n return [\n ...new Set([\n id,\n ...links.filter(([source]) => source === id).map(([, target]) => target),\n ...links.filter(([, target]) => target === id).map(([source]) => source),\n ]),\n ];\n}\n\n/** The minimap draws groups as outlines, so the nodes inside them stay visible. */\nfunction minimapNodeClass(node: Node): string {\n return node.type === 'serviceGroup' ? 'aegis-service-map__minimap-group' : '';\n}\n\n/**\n * Fits the view once the layout uses every node's measured size, and again\n * when the layout or the focus changes. Nothing else moves the view, so a\n * new status or selection keeps the user's pan and zoom. Returns whether\n * the view has been fitted to the current focus.\n */\nfunction useFit(\n shape: MapShape,\n layout: MapLayout,\n laidOut: boolean,\n focusNodeId: string | undefined,\n showMinimap: boolean,\n narrow: boolean,\n): boolean {\n const { fitView, getNodes, getNodesBounds, setViewport } = useReactFlow();\n const store = useStoreApi();\n const paneSized = useStore((state) => state.width > 0 && state.height > 0);\n const focus = useMemo(\n () =>\n focusNodeId !== undefined && shape.ids.includes(focusNodeId)\n ? { id: focusNodeId, near: neighbourhood(focusNodeId, shape.links) }\n : undefined,\n [focusNodeId, shape],\n );\n const [fittedTo, setFittedTo] = useState<string | null>();\n useEffect(() => {\n if (paneSized && laidOut) {\n const settle = (): void => {\n setFittedTo(focus?.id ?? null);\n };\n const padding = {\n top: px(FIT_MARGIN),\n bottom: px(FIT_MARGIN),\n left: px(PANEL_INSET + CONTROLS_WIDTH + FIT_MARGIN),\n right: px(\n showMinimap ? PANEL_INSET + MINIMAP_WIDTH + FIT_MARGIN : FIT_MARGIN,\n ),\n };\n const { width, height } = store.getState();\n if (focus === undefined) {\n const all = getNodes();\n const bounds = getNodesBounds(all);\n const fitted = getViewportForBounds(\n bounds,\n width,\n height,\n MIN_ZOOM,\n 1,\n padding,\n );\n if (narrow && fitted.zoom < READABLE_ZOOM) {\n // A phone has no minimap and too little room for the whole map,\n // so it opens where the map starts, on its first node.\n const zoom = READABLE_ZOOM;\n const horizontal = shape.direction === 'LR';\n const along = (n: Node): number =>\n horizontal ? n.position.x : n.position.y;\n const first = all\n .filter((n) => n.type === 'service')\n .reduce((a, b) => (along(b) < along(a) ? b : a));\n const { width: w = NODE_WIDTH, height: h = NODE_HEIGHT } =\n first.measured ?? {};\n void setViewport(\n horizontal\n ? {\n x:\n PANEL_INSET + CONTROLS_WIDTH + FIT_MARGIN - bounds.x * zoom,\n y: height / 2 - (first.position.y + h / 2) * zoom,\n zoom,\n }\n : {\n x: width / 2 - (first.position.x + w / 2) * zoom,\n y: FIT_MARGIN - bounds.y * zoom,\n zoom,\n },\n ).then(settle);\n } else {\n void fitView({ maxZoom: 1, padding }).then(settle);\n }\n } else {\n const nearFits =\n getViewportForBounds(\n getNodesBounds(focus.near),\n width,\n height,\n MIN_ZOOM,\n FOCUS_ZOOM,\n padding,\n ).zoom >= FOCUS_ZOOM;\n void fitView({\n nodes: (nearFits ? focus.near : [focus.id]).map((id) => ({ id })),\n minZoom: FOCUS_ZOOM,\n maxZoom: FOCUS_ZOOM,\n padding,\n }).then(settle);\n }\n }\n }, [\n paneSized,\n laidOut,\n layout,\n focus,\n showMinimap,\n narrow,\n shape.direction,\n store,\n fitView,\n getNodes,\n getNodesBounds,\n setViewport,\n ]);\n return fittedTo === (focus?.id ?? null);\n}\n\n/**\n * The selected node of a map in a `DetailBeside`: once the view is fitted\n * it places the node's box, again whenever the map pans or zooms, and at\n * 768 px and below draws the detail right under the node, over the map,\n * which grows to hold it.\n */\nfunction ServiceMapSelection({\n nodeId,\n fitted,\n selection,\n}: {\n nodeId: string;\n fitted: boolean;\n selection: SelectedRowDetail;\n}): JSX.Element | null {\n const transform = useStore((state) => state.transform);\n const domNode = useStore((state) => state.domNode);\n const node = useInternalNode(nodeId);\n // The node goes only with this component, so a pan places the same node\n // again rather than a new one.\n useIsomorphicLayoutEffect(\n () => () => {\n selection.placeRow(null);\n },\n [selection],\n );\n useIsomorphicLayoutEffect(() => {\n const group = domNode?.querySelector(\n `.react-flow__node[data-id=\"${CSS.escape(nodeId)}\"]`,\n );\n if (fitted && group instanceof HTMLElement) {\n selection.placeRow(group);\n }\n }, [selection, domNode, nodeId, transform, fitted]);\n const height = node?.measured.height;\n if (selection.inline === null || node === undefined || height === undefined) {\n return null;\n }\n const [, y, zoom] = transform;\n const bottom = (node.internals.positionAbsolute.y + height) * zoom + y;\n return (\n <div\n className=\"aegis-service-map__detail\"\n style={{ marginTop: Math.max(bottom, 0) }}\n >\n {selection.inline}\n </div>\n );\n}\n\n/**\n * Pans a node or edge that gets keyboard focus fully into view, centred.\n * React Flow pans only to a node entirely outside the view, and never to\n * an edge.\n */\nfunction usePanToFocused(): (event: FocusEvent<HTMLDivElement>) => void {\n const { getViewport, setViewport } = useReactFlow();\n return useCallback(\n (event: FocusEvent<HTMLDivElement>) => {\n const target = event.target;\n if (\n !(target instanceof Element) ||\n !target.matches(\n '.react-flow__node:focus-visible, .react-flow__edge:focus-visible',\n )\n ) {\n return;\n }\n // The browser has already scrolled the pane to the element, and React\n // Flow scrolls it back, so the offset is added back to place it.\n const { scrollLeft, scrollTop } = event.currentTarget;\n const pane = event.currentTarget.getBoundingClientRect();\n const box = target.getBoundingClientRect();\n const left = box.left - pane.left + scrollLeft;\n const top = box.top - pane.top + scrollTop;\n if (\n left >= 0 &&\n top >= 0 &&\n left + box.width <= pane.width &&\n top + box.height <= pane.height\n ) {\n return;\n }\n const { x, y, zoom } = getViewport();\n void setViewport({\n x: x + pane.width / 2 - (left + box.width / 2),\n y: y + pane.height / 2 - (top + box.height / 2),\n zoom,\n });\n },\n [getViewport, setViewport],\n );\n}\n\nfunction ServiceMapInner({\n nodes,\n edges,\n groups = [],\n direction = 'LR',\n height,\n fillViewport = false,\n onNodeClick,\n onEdgeClick,\n selectedNodeId,\n focusNodeId,\n minimap = focusNodeId === undefined,\n ariaLabel,\n className,\n}: ServiceMapProps): JSX.Element {\n const strings = useStrings();\n const idPrefix = useId();\n // React Flow names its elements after this id ('1' when none is given),\n // so each map passes its own and a page can hold several.\n const flowId = `aegis-service-map${idPrefix.replace(/:/g, '-')}`;\n const nodesSelectable = onNodeClick !== undefined;\n const edgesSelectable = onEdgeClick !== undefined;\n // Node sizes as React Flow measured them; the layout reads them, so a\n // node can be as wide as its label.\n const [measured, setMeasured] = useState<ReadonlyMap<string, Size>>(\n () => new Map(),\n );\n const shapeJson = useMemo(\n () => JSON.stringify(shapeOf(nodes, edges, groups, direction)),\n [nodes, edges, groups, direction],\n );\n // Parsed back from its JSON, so the shape is a new object only when it\n // changes, not when the parent passes equal arrays again.\n const shape = useMemo(() => JSON.parse(shapeJson) as MapShape, [shapeJson]);\n const layout = useMemo(\n () => computeLayout(shape, measured, idPrefix),\n [shape, measured, idPrefix],\n );\n const isHorizontal = direction === 'LR';\n const flowNodes = useMemo(\n (): ServiceFlowNode[] => [\n ...layout.groups,\n ...nodes.map((n): ServiceFlowNode => {\n // A node in a group is described by the group's label. React Flow\n // describes a node by its keyboard help, the element it names\n // `react-flow__node-desc-<rfId>`; a node that cannot be selected\n // has none.\n const describedBy = [\n layout.groupLabels.get(n.id),\n nodesSelectable ? `react-flow__node-desc-${flowId}` : undefined,\n ]\n .filter(Boolean)\n .join(' ');\n return {\n id: n.id,\n type: 'service',\n position: layout.positions.get(n.id) ?? { x: 0, y: 0 },\n // Handed back as applyNodeChanges would, so React Flow keeps the\n // size it measured instead of measuring the node again.\n measured: measured.get(n.id),\n ariaLabel: n.label,\n // React Flow gives only a focusable node a role, and the role\n // description below needs one.\n ariaRole: 'group',\n domAttributes: {\n 'aria-roledescription': strings.serviceMapNodeRole,\n // A group takes no aria-selected.\n 'aria-current': selectedNodeId === n.id ? true : undefined,\n 'aria-describedby': describedBy === '' ? undefined : describedBy,\n },\n data: { node: n, selected: selectedNodeId === n.id },\n sourcePosition: isHorizontal ? Position.Right : Position.Bottom,\n targetPosition: isHorizontal ? Position.Left : Position.Top,\n draggable: false,\n connectable: false,\n selectable: nodesSelectable,\n focusable: nodesSelectable,\n };\n }),\n ],\n [\n layout,\n nodes,\n measured,\n selectedNodeId,\n isHorizontal,\n nodesSelectable,\n flowId,\n strings,\n ],\n );\n const flowEdges = useMemo((): Array<Edge<ServiceEdgeData>> => {\n const labelOf = new Map(nodes.map((n) => [n.id, n.label]));\n return edges.map((e) => ({\n id: e.id,\n source: e.source,\n target: e.target,\n ariaLabel: strings.serviceMapEdgeName(\n labelOf.get(e.source) ?? e.source,\n labelOf.get(e.target) ?? e.target,\n ),\n // React Flow makes an unfocusable edge an img; aria-roledescription needs a group.\n ariaRole: 'group',\n domAttributes: { 'aria-roledescription': strings.serviceMapEdgeRole },\n type: 'service',\n data: { edge: e },\n label: e.label,\n selectable: edgesSelectable,\n focusable: edgesSelectable,\n className: `aegis-service-map__edge aegis-service-map__edge--${e.status ?? 'ok'}`,\n }));\n }, [nodes, edges, edgesSelectable, strings]);\n\n const { getNode } = useReactFlow();\n const handleNodesChange = useCallback(\n (changes: Array<NodeChange<ServiceFlowNode>>) => {\n const resized = changes.flatMap((change) =>\n change.type === 'dimensions' &&\n change.dimensions !== undefined &&\n getNode(change.id)?.type === 'service'\n ? [[change.id, change.dimensions] as const]\n : [],\n );\n setMeasured((previous) =>\n resized.every(\n ([id, size]) =>\n previous.get(id)?.width === size.width &&\n previous.get(id)?.height === size.height,\n )\n ? previous\n : new Map([...previous, ...resized]),\n );\n },\n [getNode],\n );\n\n const narrow = useMediaQuery(NARROW_QUERY);\n const showMinimap = minimap && !narrow;\n const selection = useContext(SelectedRowDetailContext);\n const fitted = useFit(\n shape,\n layout,\n nodes.every((n) => measured.has(n.id)),\n focusNodeId,\n showMinimap,\n narrow,\n );\n const shownId =\n selectedNodeId !== undefined && shape.ids.includes(selectedNodeId)\n ? selectedNodeId\n : undefined;\n // While the view moves to a new focus, the detail stays under the node it\n // was drawn under, so the map keeps its height and the page its scroll.\n const [drawnId, setDrawnId] = useState<string>();\n if (fitted && drawnId !== shownId) {\n setDrawnId(shownId);\n }\n // A DetailBeside waits while the view is fitted to a newly selected node.\n useIsomorphicLayoutEffect(() => {\n if (selection === null || shownId === undefined || fitted) {\n return undefined;\n }\n selection.awaitRow();\n return () => {\n selection.placeRow(null);\n };\n }, [selection, shownId, fitted]);\n const handleFocus = usePanToFocused();\n\n const handleNodeClick = useCallback(\n (_: unknown, n: ServiceFlowNode) => {\n if (n.type === 'service') {\n onNodeClick?.(n.data.node);\n }\n },\n [onNodeClick],\n );\n const handleEdgeClick = useCallback(\n (_: unknown, e: Edge<ServiceEdgeData>) => {\n if (e.data) {\n onEdgeClick?.(e.data.edge);\n }\n },\n [onEdgeClick],\n );\n // React Flow's own Enter and Space only change its internal selection,\n // which never reaches the host, so a focused node or edge answers the\n // keys here, as a click would.\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if ((event.key !== 'Enter' && event.key !== ' ') || event.repeat) {\n return;\n }\n const target = event.target;\n if (!(target instanceof Element)) {\n return;\n }\n const id = target.getAttribute('data-id');\n if (target.classList.contains('react-flow__node')) {\n const node = nodes.find((n) => n.id === id);\n if (node && onNodeClick) {\n event.preventDefault();\n onNodeClick(node);\n }\n } else if (target.classList.contains('react-flow__edge')) {\n const edge = edges.find((e) => e.id === id);\n if (edge && onEdgeClick) {\n event.preventDefault();\n onEdgeClick(edge);\n }\n }\n },\n [nodes, edges, onNodeClick, onEdgeClick],\n );\n\n const style = {\n ...SIZE_VARS,\n height: height === undefined ? undefined : `${String(height)}px`,\n } as CSSProperties;\n\n return (\n <div\n className={[\n 'aegis-service-map',\n fillViewport ? 'aegis-service-map--fill-viewport' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n {/* Positioned over the whole box, so React Flow has a definite height\n even when the box only has its min-height. */}\n <div className=\"aegis-service-map__pane\">\n <ReactFlow\n id={flowId}\n aria-label={ariaLabel}\n nodes={flowNodes}\n edges={flowEdges}\n nodeTypes={NODE_TYPES}\n edgeTypes={EDGE_TYPES}\n minZoom={MIN_ZOOM}\n nodesDraggable={false}\n nodesConnectable={false}\n autoPanOnNodeFocus={false}\n panOnDrag\n zoomOnScroll\n proOptions={{ hideAttribution: true }}\n ariaLabelConfig={strings.serviceMapAriaLabels}\n onNodesChange={handleNodesChange}\n onNodeClick={nodesSelectable ? handleNodeClick : undefined}\n onEdgeClick={edgesSelectable ? handleEdgeClick : undefined}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n >\n <Background variant={BackgroundVariant.Dots} gap={16} size={1} />\n <Controls showInteractive={false} position=\"top-left\" />\n {showMinimap && (\n <MiniMap\n pannable\n zoomable\n position=\"bottom-right\"\n style={{ width: MINIMAP_WIDTH }}\n nodeClassName={minimapNodeClass}\n />\n )}\n </ReactFlow>\n </div>\n {selection !== null && drawnId !== undefined && (\n <ServiceMapSelection\n nodeId={drawnId}\n fitted={fitted}\n selection={selection}\n />\n )}\n </div>\n );\n}\n\nexport function ServiceMap(props: ServiceMapProps): JSX.Element {\n return (\n <ReactFlowProvider>\n <ServiceMapInner {...props} />\n </ReactFlowProvider>\n );\n}\n"],"names":["NODE_WIDTH","NODE_HEIGHT","NODE_MAX_WIDTH","GROUP_LABEL_HEIGHT","GROUP_GAP","SIZE_VARS","DEFAULT_SIZE","shapeOf","nodes","edges","groups","direction","ids","n","present","e","partsOf","claimed","grouped","group","id","rest","part","layoutPart","links","sizeOf","g","graphlib","source","target","dagreLayout","positions","x","y","size","width","height","computeLayout","shape","sizes","idPrefix","labelIdOf","horizontal","parts","laid","labelHeight","across","along","placed","origin","p","ServiceGroup","data","jsx","DOT_TONE","ServiceNode","node","selected","status","tone","jsxs","Handle","Position","StatusDot","ServiceEdge","props","sourceX","sourceY","targetX","targetY","label","markerEnd","style","pathId","useId","midX","path","Fragment","NODE_TYPES","EDGE_TYPES","NARROW_QUERY","FIT_MARGIN","MIN_ZOOM","FOCUS_ZOOM","READABLE_ZOOM","PANEL_INSET","CONTROLS_WIDTH","MINIMAP_WIDTH","px","value","neighbourhood","minimapNodeClass","useFit","layout","laidOut","focusNodeId","showMinimap","narrow","fitView","getNodes","getNodesBounds","setViewport","useReactFlow","store","useStoreApi","paneSized","useStore","state","focus","useMemo","fittedTo","setFittedTo","useState","useEffect","settle","padding","all","bounds","fitted","getViewportForBounds","zoom","first","a","b","w","h","nearFits","ServiceMapSelection","nodeId","selection","transform","domNode","useInternalNode","useIsomorphicLayoutEffect","bottom","usePanToFocused","getViewport","useCallback","event","scrollLeft","scrollTop","pane","box","left","top","ServiceMapInner","fillViewport","onNodeClick","onEdgeClick","selectedNodeId","minimap","ariaLabel","className","strings","useStrings","flowId","nodesSelectable","edgesSelectable","measured","setMeasured","shapeJson","isHorizontal","flowNodes","describedBy","flowEdges","labelOf","getNode","handleNodesChange","changes","resized","change","previous","useMediaQuery","useContext","SelectedRowDetailContext","shownId","drawnId","setDrawnId","handleFocus","handleNodeClick","_","handleEdgeClick","handleKeyDown","edge","ReactFlow","Background","BackgroundVariant","Controls","MiniMap","ServiceMap","ReactFlowProvider"],"mappings":"sbAyKMA,EAAa,IACbC,EAAc,GACdC,GAAiB,IAEjBC,EAAqB,GAErBC,GAAY,GAGZC,GAAY,CAChB,6BAA8B,GAAG,OAAOL,CAAU,CAAC,KACnD,6BAA8B,GAAG,OAAOC,CAAW,CAAC,KACpD,iCAAkC,GAAG,OAAOC,EAAc,CAAC,KAC3D,oCAAqC,GAAG,OAAOC,CAAkB,CAAC,IACpE,EAOMG,GAAqB,CAAE,MAAON,EAAY,OAAQC,CAAA,EAiBxD,SAASM,GACPC,EACAC,EACAC,EACAC,EACU,CACV,MAAMC,EAAMJ,EAAM,IAAKK,GAAMA,EAAE,EAAE,EAC3BC,EAAU,IAAI,IAAIF,CAAG,EAC3B,MAAO,CACL,UAAAD,EACA,IAAAC,EACA,MAAOH,EACJ,OAAQM,GAAMD,EAAQ,IAAIC,EAAE,MAAM,GAAKD,EAAQ,IAAIC,EAAE,MAAM,CAAC,EAC5D,IAAKA,GAAM,CAACA,EAAE,OAAQA,EAAE,MAAM,CAAC,EAClC,OAAAL,CAAA,CAEJ,CAGA,SAASM,GA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