Render ```mermaid fences in assistant replies: Unicode box-drawing diagrams in the terminal (lovely-mermaid), light/dark vector SVG on desktop, VS Code and…

Claude 응답의 ``` `mermaid `` 코드 블록을 다이어그램으로 바꿔 그리는 function-hook 플러그인. 터미널에서는 유니코드 박스 텍스트로, desktop·VS Code·모바일에서는 같은 다이어그램을 SVG 이미지로 그린다. /show-me` 같은 스킬이 내는 mermaid 코드가 대상이다.
/plugin marketplace add WhiteKr/whitekr-claude-plugins
/plugin install mermaid@whitekr-claude-plugins
개발 중에는 claude --plugin-dir <이 폴더> 로 로드한다.
ui.render 의 AssistantMessage 를 훅해 닫힌 ``` `mermaid ``` 펜스를 다이어그램으로 바꾼다. 저장된 메시지(ctrl+o)는 바뀌지 않고 화면만 바뀐다.e.surface 로 그리는 방식을 고른다(엔진의 $.ui.resolve() 는 터미널에도 Svg 키를 주므로 요소 표로는 고를 수 없다).Markdown 과 Svg 로 나눠 그린다. SVG는 beautiful-mermaid 의 파서·렌더러로 그리고, 레이아웃 엔진 elkjs만 dagre 로 바꿔 끼운다. 도형·화살촉·라벨이 실제 벡터 다이어그램이 되고, 번들이 1MiB 상한 안에 든다. sequence와 xychart는 beautiful-mermaid 자체 레이아웃을 그대로 쓴다. SVG는 자기 배경을 가지며, 배경과 글자색(선·채움은 이 둘을 섞은 색)을 prefers-color-scheme 하나로 함께 바꾼다. 이미지 속 SVG는 화면이 아니라 OS 테마를 따르므로, 화면 테마가 OS와 달라도 글자가 배경에 묻히지 않게 하려는 것이다. 웹 글꼴은 불러오지 않고 시스템 글꼴을 쓴다./config 의 plugin 항목 또는 settings pluginConfigs.mermaid.options:
useAscii (boolean, 기본 false): 터미널에서 박스 문자 대신 순수 ASCII(+-|>)로 그린다. 터미널·폰트가 ─│▶ 같은 ambiguous-width 글자를 2칸으로 그려 줄이 어긋날 때 켠다. lovely-mermaid에는 ASCII 모드가 없어 그린 결과의 글자를 하나씩 바꾼다(선 -|, 점선 .:, 모서리 +, 화살촉 ><^v).재시도 가 재시 로 보임).direction 은 무시된다. dagre는 그래프 하나에 방향 하나만 받는다.hooks/hooks.js 는 src/hooks.js + lovely-mermaid + beautiful-mermaid 소스 + dagre를 build.mjs(esbuild)로 묶은 산출물이며 커밋 대상이다(마켓플레이스 설치는 빌드 없이 그대로 쓴다). 번들은 약 225KB다(이름까지 minify).
beautiful-mermaid의 공개 SVG 렌더러는 레이아웃 엔진 elkjs 때문에 번들이 1.8MB가 되고, Claude Code는 1MiB(1048576 bytes)를 넘는 hooks 모듈을 읽지 않는다(is over 1048576 bytes and was not read). 그래서 build.mjs 가 beautiful-mermaid의 elk-instance.ts 를 src/elk-dagre.js 로 바꿔 끼운다. 이 파일은 ELK JSON 그래프를 받아 dagre로 배치한 뒤 ELK와 같은 모양으로 위치를 돌려주므로, beautiful-mermaid의 노드 크기 계산·층 정렬·간선 묶기·도형 클리핑을 그대로 쓴다. hooks 로더는 동적 import() 도 거부하므로 모두 정적으로 묶는다.
npm i
npm test # build + test/hooks.test.mjs
npm run test:engine # claude plugin test: 실제 엔진에서 desktop·terminal 트리 확인hooks/hooks.js 121 lines1var In=[[0,172,1],[173,173,0],[174,767,1],[768,879,0],[880,1154,1],[1155,1161,0],[1162,1424,1],[1425,1469,0],[1470,1470,1],[1471,1471,0],[1472,1472,1],[1473,1474,0],[1475,1475,1],[1476,1477,0],[1478,1478,1],[1479,1479,0],[1480,1540,1],[1541,1541,0],[1542,1551,1],[1552,1562,0],[1563,1563,1],[1564,1564,0],[1565,1610,1],[1611,1631,0],[1632,1647,1],[1648,1648,0],[1649,1749,1],[1750,1756,0],[1757,1758,1],[1759,1764,0],[1765,1766,1],[1767,1768,0],[1769,1769,1],[1770,1773,0],[1774,1806,1],[1807,1807,0],[1808,1808,1],[1809,1809,0],[1810,1839,1],[1840,1866,0],[1867,1957,1],[1958,1968,0],[1969,2026,1],[2027,2035,0],[2036,2044,1],[2045,2045,0],[2046,2069,1],[2070,2073,0],[2074,2074,1],[2075,2083,0],[2084,2084,1],[2085,2087,0],[2088,2088,1],[2089,2093,0],[2094,2136,1],[2137,2139,0],[2140,2191,1],[2192,2193,0],[2194,2199,1],[2200,2207,0],[2208,2249,1],[2250,2306,0],[2307,2361,1],[2362,2362,0],[2363,2363,1],[2364,2364,0],[2365,2368,1],[2369,2376,0],[2377,2380,1],[2381,2381,0],[2382,2384,1],[2385,2391,0],[2392,2401,1],[2402,2403,0],[2404,2432,1],[2433,2433,0],[2434,2491,1],[2492,2492,0],[2493,2493,1],[2494,2494,0],[2495,2496,1],[2497,2500,0],[2501,2508,1],[2509,2509,0],[2510,2518,1],[2519,2519,0],[2520,2529,1],[2530,2531,0],[2532,2557,1],[2558,2558,0],[2559,2560,1],[2561,2562,0],[2563,2619,1],[2620,2620,0],[2621,2624,1],[2625,2626,0],[2627,2630,1],[2631,2632,0],[2633,2634,1],[2635,2637,0],[2638,2640,1],[2641,2641,0],[2642,2671,1],[2672,2673,0],[2674,2676,1],[2677,2677,0],[2678,2688,1],[2689,2690,0],[2691,2747,1],[2748,2748,0],[2749,2752,1],[2753,2757,0],[2758,2758,1],[2759,2760,0],[2761,2764,1],[2765,2765,0],[2766,2785,1],[2786,2787,0],[2788,2809,1],[2810,2815,0],[2816,2816,1],[2817,2817,0],[2818,2875,1],[2876,2876,0],[2877,2877,1],[2878,2879,0],[2880,2880,1],[2881,2884,0],[2885,2892,1],[2893,2893,0],[2894,2900,1],[2901,2903,0],[2904,2913,1],[2914,2915,0],[2916,2945,1],[2946,2946,0],[2947,3005,1],[3006,3006,0],[3007,3007,1],[3008,3008,0],[3009,3020,1],[3021,3021,0],[3022,3030,1],[3031,3031,0],[3032,3071,1],[3072,3072,0],[3073,3075,1],[3076,3076,0],[3077,3131,1],[3132,3132,0],[3133,3133,1],[3134,3136,0],[3137,3141,1],[3142,3144,0],[3145,3145,1],[3146,3149,0],[3150,3156,1],[3157,3158,0],[3159,3169,1],[3170,3171,0],[3172,3200,1],[3201,3201,0],[3202,3259,1],[3260,3260,0],[3261,3262,1],[3263,3264,0],[3265,3265,1],[3266,3266,0],[3267,3269,1],[3270,3272,0],[3273,3273,1],[3274,3277,0],[3278,3284,1],[3285,3286,0],[3287,3297,1],[3298,3299,0],[3300,3327,1],[3328,3329,0],[3330,3386,1],[3387,3388,0],[3389,3389,1],[3390,3390,0],[3391,3392,1],[3393,3396,0],[3397,3404,1],[3405,3406,0],[3407,3414,1],[3415,3415,0],[3416,3425,1],[3426,3427,0],[3428,3456,1],[3457,3457,0],[3458,3529,1],[3530,3530,0],[3531,3534,1],[3535,3535,0],[3536,3537,1],[3538,3540,0],[3541,3541,1],[3542,3542,0],[3543,3550,1],[3551,3551,0],[3552,3632,1],[3633,3633,0],[3634,3635,1],[3636,3642,0],[3643,3654,1],[3655,3662,0],[3663,3760,1],[3761,3761,0],[3762,3763,1],[3764,3772,0],[3773,3783,1],[3784,3790,0],[3791,3863,1],[3864,3865,0],[3866,3892,1],[3893,3893,0],[3894,3894,1],[3895,3895,0],[3896,3896,1],[3897,3897,0],[3898,3952,1],[3953,3966,0],[3967,3967,1],[3968,3972,0],[3973,3973,1],[3974,3975,0],[3976,3980,1],[3981,3991,0],[3992,3992,1],[3993,4028,0],[4029,4037,1],[4038,4038,0],[4039,4140,1],[4141,4144,0],[4145,4145,1],[4146,4151,0],[4152,4152,1],[4153,4154,0],[4155,4156,1],[4157,4158,0],[4159,4183,1],[4184,4185,0],[4186,4189,1],[4190,4192,0],[4193,4208,1],[4209,4212,0],[4213,4225,1],[4226,4226,0],[4227,4228,1],[4229,4230,0],[4231,4236,1],[4237,4237,0],[4238,4252,1],[4253,4253,0],[4254,4351,1],[4352,4447,2],[4448,4607,0],[4608,4956,1],[4957,4959,0],[4960,5905,1],[5906,5908,0],[5909,5937,1],[5938,5939,0],[5940,5969,1],[5970,5971,0],[5972,6001,1],[6002,6003,0],[6004,6051,1],[6052,6052,2],[6053,6067,1],[6068,6069,0],[6070,6070,1],[6071,6077,0],[6078,6085,1],[6086,6086,0],[6087,6088,1],[6089,6099,0],[6100,6103,1],[6104,6104,3],[6105,6108,1],[6109,6109,0],[6110,6154,1],[6155,6159,0],[6160,6276,1],[6277,6278,0],[6279,6312,1],[6313,6313,0],[6314,6431,1],[6432,6434,0],[6435,6438,1],[6439,6440,0],[6441,6449,1],[6450,6450,0],[6451,6456,1],[6457,6459,0],[6460,6678,1],[6679,6680,0],[6681,6682,1],[6683,6683,0],[6684,6741,1],[6742,6742,0],[6743,6743,1],[6744,6750,0],[6751,6751,1],[6752,6752,0],[6753,6753,1],[6754,6754,0],[6755,6756,1],[6757,6764,0],[6765,6770,1],[6771,6780,0],[6781,6782,1],[6783,6783,0],[6784,6831,1],[6832,6862,0],[6863,6911,1],[6912,6915,0],[6916,6963,1],[6964,6973,0],[6974,6977,1],[6978,6979,0],[6980,7018,1],[7019,7027,0],[7028,7039,1],[7040,7041,0],[7042,7073,1],[7074,7077,0],[7078,7079,1],[7080,7081,0],[7082,7082,1],[7083,7085,0],[7086,7141,1],[7142,7142,0],[7143,7143,1],[7144,7145,0],[7146,7148,1],[7149,7149,0],[7150,7150,1],[7151,7153,0],[7154,7211,1],[7212,7219,0],[7220,7221,1],[7222,7223,0],[7224,7375,1],[7376,7378,0],[7379,7379,1],[7380,7392,0],[7393,7393,1],[7394,7400,0],[7401,7404,1],[7405,7405,0],[7406,7411,1],[7412,7412,0],[7413,7415,1],[7416,7417,0],[7418,7615,1],[7616,7679,0],[7680,8202,1],[8203,8207,0],[8208,8233,1],[8234,8238,0],[8239,8287,1],[8288,8303,0],[8304,8399,1],[8400,8432,0],[8433,8985,1],[8986,8987,2],[8988,9e3,1],[9001,9002,2],[9003,9192,1],[9193,9196,2],[9197,9199,1],[9200,9200,2],[9201,9202,1],[9203,9203,2],[9204,9724,1],[9725,9726,2],[9727,9747,1],[9748,9749,2],[9750,9799,1],[9800,9811,2],[9812,9854,1],[9855,9855,2],[9856,9874,1],[9875,9875,2],[9876,9888,1],[9889,9889,2],[9890,9897,1],[9898,9899,2],[9900,9916,1],[9917,9918,2],[9919,9923,1],[9924,9925,2],[9926,9933,1],[9934,9934,2],[9935,9939,1],[9940,9940,2],[9941,9961,1],[9962,9962,2],[9963,9969,1],[9970,9971,2],[9972,9972,1],[9973,9973,2],[9974,9977,1],[9978,9978,2],[9979,9980,1],[9981,9981,2],[9982,9988,1],[9989,9989,2],[9990,9993,1],[9994,9995,2],[9996,10023,1],[10024,10024,2],[10025,10059,1],[10060,10060,2],[10061,10061,1],[10062,10062,2],[10063,10066,1],[10067,10069,2],[10070,10070,1],[10071,10071,2],[10072,10132,1],[10133,10135,2],[10136,10159,1],[10160,10160,2],[10161,10174,1],[10175,10175,2],[10176,11034,1],[11035,11036,2],[11037,11087,1],[11088,11088,2],[11089,11092,1],[11093,11093,2],[11094,11502,1],[11503,11505,0],[11506,11743,1],[11744,11775,0],[11776,11903,1],[11904,11929,2],[11930,11930,1],[11931,12019,2],[12020,12031,1],[12032,12245,2],[12246,12271,1],[12272,12329,2],[12330,12335,0],[12336,12350,2],[12351,12352,1],[12353,12438,2],[12439,12440,1],[12441,12442,0],[12443,12543,2],[12544,12548,1],[12549,12591,2],[12592,12592,1],[12593,12643,2],[12644,12644,0],[12645,12686,2],[12687,12687,1],[12688,12771,2],[12772,12782,1],[12783,12830,2],[12831,12831,1],[12832,12871,2],[12872,12879,1],[12880,19903,2],[19904,19967,1],[19968,42124,2],[42125,42127,1],[42128,42182,2],[42183,42606,1],[42607,42610,0],[42611,42611,1],[42612,42621,0],[42622,42653,1],[42654,42655,0],[42656,42735,1],[42736,42737,0],[42738,43009,1],[43010,43010,0],[43011,43013,1],[43014,43014,0],[43015,43018,1],[43019,43019,0],[43020,43044,1],[43045,43046,0],[43047,43051,1],[43052,43052,0],[43053,43203,1],[43204,43205,0],[43206,43231,1],[43232,43249,0],[43250,43257,1],[43258,43258,0],[43259,43262,1],[43263,43263,0],[43264,43301,1],[43302,43309,0],[43310,43334,1],[43335,43345,0],[43346,43359,1],[43360,43388,2],[43389,43391,1],[43392,43394,0],[43395,43442,1],[43443,43443,0],[43444,43445,1],[43446,43449,0],[43450,43451,1],[43452,43453,0],[43454,43492,1],[43493,43493,0],[43494,43560,1],[43561,43566,0],[43567,43568,1],[43569,43570,0],[43571,43572,1],[43573,43574,0],[43575,43586,1],[43587,43587,0],[43588,43595,1],[43596,43596,0],[43597,43643,1],[43644,43644,0],[43645,43695,1],[43696,43696,0],[43697,43697,1],[43698,43700,0],[43701,43702,1],[43703,43704,0],[43705,43709,1],[43710,43711,0],[43712,43712,1],[43713,43713,0],[43714,43755,1],[43756,43757,0],[43758,43765,1],[43766,43766,0],[43767,44004,1],[44005,44005,0],[44006,44007,1],[44008,44008,0],[44009,44012,1],[44013,44013,0],[44014,44031,1],[44032,55203,2],[55204,55215,1],[55216,55238,0],[55239,55242,1],[55243,55291,0],[55292,63743,1],[63744,64255,2],[64256,64285,1],[64286,64286,0],[64287,65023,1],[65024,65039,0],[65040,65049,2],[65050,65055,1],[65056,65071,0],[65072,65106,2],[65107,65107,1],[65108,65126,2],[65127,65127,1],[65128,65131,2],[65132,65278,1],[65279,65279,0],[65280,65280,1],[65281,65376,2],[65377,65437,1],[65438,65440,0],[65441,65503,1],[65504,65510,2],[65511,65519,1],[65520,65528,0],[65529,66044,1],[66045,66045,0],[66046,66271,1],[66272,66272,0],[66273,66421,1],[66422,66426,0],[66427,68096,1],[68097,68099,0],[68100,68100,1],[68101,68102,0],[68103,68107,1],[68108,68111,0],[68112,68151,1],[68152,68154,0],[68155,68158,1],[68159,68159,0],[68160,68324,1],[68325,68326,0],[68327,68899,1],[68900,68903,0],[68904,69290,1],[69291,69292,0],[69293,69372,1],[69373,69375,0],[69376,69445,1],[69446,69456,0],[69457,69505,1],[69506,69509,0],[69510,69632,1],[69633,69633,0],[69634,69687,1],[69688,69702,0],[69703,69743,1],[69744,69744,0],[69745,69746,1],[69747,69748,0],[69749,69758,1],[69759,69761,0],[69762,69810,1],[69811,69814,0],[69815,69816,1],[69817,69818,0],[69819,69825,1],[69826,69826,0],[69827,69887,1],[69888,69890,0],[69891,69926,1],[69927,69931,0],[69932,69932,1],[69933,69940,0],[69941,70002,1],[70003,70003,0],[70004,70015,1],[70016,70017,0],[70018,70069,1],[70070,70078,0],[70079,70081,1],[70082,70083,0],[70084,70088,1],[70089,70092,0],[70093,70094,1],[70095,70095,0],[70096,70190,1],[70191,70193,0],[70194,70195,1],[70196,70196,0],[70197,70197,1],[70198,70199,0],[70200,70205,1],[70206,70206,0],[70207,70208,1],[70209,70209,0],[70210,70366,1],[70367,70367,0],[70368,70370,1],[70371,70378,0],[70379,70399,1],[70400,70401,0],[70402,70458,1],[70459,70460,0],[70461,70461,1],[70462,70462,0],[70463,70463,1],[70464,70464,0],[70465,70486,1],[70487,70487,0],[70488,70501,1],[70502,70508,0],[70509,70511,1],[70512,70516,0],[70517,70711,1],[70712,70719,0],[70720,70721,1],[70722,70724,0],[70725,70725,1],[70726,70726,0],[70727,70749,1],[70750,70750,0],[70751,70831,1],[70832,70832,0],[70833,70834,1],[70835,70840,0],[70841,70841,1],[70842,70842,0],[70843,70844,1],[70845,70845,0],[70846,70846,1],[70847,70848,0],[70849,70849,1],[70850,70851,0],[70852,71086,1],[71087,71087,0],[71088,71089,1],[71090,71093,0],[71094,71099,1],[71100,71101,0],[71102,71102,1],[71103,71104,0],[71105,71131,1],[71132,71133,0],[71134,71218,1],[71219,71226,0],[71227,71228,1],[71229,71229,0],[71230,71230,1],[71231,71232,0],[71233,71338,1],[71339,71339,0],[71340,71340,1],[71341,71341,0],[71342,71343,1],[71344,71349,0],[71350,71350,1],[71351,71351,0],[71352,71452,1],[71453,71455,0],[71456,71457,1],[71458,71461,0],[71462,71462,1],[71463,71467,0],[71468,71726,1],[71727,71735,0],[71736,71736,1],[71737,71738,0],[71739,71983,1],[71984,71984,0],[71985,71994,1],[71995,71996,0],[71997,71997,1],[71998,71999,0],[72e3,72e3,1],[72001,72001,0],[72002,72002,1],[72003,72003,0],[72004,72147,1],[72148,72151,0],[72152,72153,1],[72154,72155,0],[72156,72159,1],[72160,72160,0],[72161,72192,1],[72193,72202,0],[72203,72242,1],[72243,72248,0],[72249,72249,1],[72250,72254,0],[72255,72262,1],[72263,72263,0],[72264,72272,1],[72273,72278,0],[72279,72280,1],[72281,72283,0],[72284,72323,1],[72324,72342,0],[72343,72343,1],[72344,72345,0],[72346,72751,1],[72752,72758,0],[72759,72759,1],[72760,72765,0],[72766,72766,1],[72767,72767,0],[72768,72849,1],[72850,72871,0],[72872,72873,1],[72874,72880,0],[72881,72881,1],[72882,72883,0],[72884,72884,1],[72885,72886,0],[72887,73008,1],[73009,73014,0],[73015,73017,1],[73018,73018,0],[73019,73019,1],[73020,73021,0],[73022,73022,1],[73023,73031,0],[73032,73103,1],[73104,73105,0],[73106,73108,1],[73109,73109,0],[73110,73110,1],[73111,73111,0],[73112,73458,1],[73459,73460,0],[73461,73471,1],[73472,73474,0],[73475,73525,1],[73526,73530,0],[73531,73535,1],[73536,73536,0],[73537,73537,1],[73538,73538,0],[73539,78911,1],[78912,78912,0],[78913,78918,1],[78919,78933,0],[78934,92911,1],[92912,92916,0],[92917,92975,1],[92976,92982,0],[92983,94030,1],[94031,94031,0],[94032,94094,1],[94095,94098,0],[94099,94175,1],[94176,94179,2],[94180,94180,0],[94181,94191,1],[94192,94193,2],[94194,94207,1],[94208,100343,2],[100344,100351,1],[100352,101589,2],[101590,101631,1],[101632,101640,2],[101641,110575,1],[110576,110579,2],[110580,110580,1],[110581,110587,2],[110588,110588,1],[110589,110590,2],[110591,110591,1],[110592,110882,2],[110883,110897,1],[110898,110898,2],[110899,110927,1],[110928,110930,2],[110931,110932,1],[110933,110933,2],[110934,110947,1],[110948,110951,2],[110952,110959,1],[110960,111355,2],[111356,113820,1],[113821,113822,0],[113823,113823,1],[113824,113827,0],[113828,118527,1],[118528,118573,0],[118574,118575,1],[118576,118598,0],[118599,119140,1],[119141,119141,0],[119142,119142,1],[119143,119145,0],[119146,119149,1],[119150,119170,0],[119171,119172,1],[119173,119179,0],[119180,119209,1],[119210,119213,0],[119214,119361,1],[119362,119364,0],[119365,121343,1],[121344,121398,0],[121399,121402,1],[121403,121452,0],[121453,121460,1],[121461,121461,0],[121462,121475,1],[121476,121476,0],[121477,121498,1],[121499,121503,0],[121504,121504,1],[121505,121519,0],[121520,122879,1],[122880,122886,0],[122887,122887,1],[122888,122904,0],[122905,122906,1],[122907,122913,0],[122914,122914,1],[122915,122916,0],[122917,122917,1],[122918,122922,0],[122923,123022,1],[123023,123023,0],[123024,123183,1],[123184,123190,0],[123191,123565,1],[123566,123566,0],[123567,123627,1],[123628,123631,0],[123632,124139,1],[124140,124143,0],[124144,125135,1],[125136,125142,0],[125143,125251,1],[125252,125258,0],[125259,126979,1],[126980,126980,2],[126981,127182,1],[127183,127183,2],[127184,127373,1],[127374,127374,2],[127375,127376,1],[127377,127386,2],[127387,127487,1],[127488,127490,2],[127491,127503,1],[127504,127547,2],[127548,127551,1],[127552,127560,2],[127561,127567,1],[127568,127569,2],[127570,127583,1],[127584,127589,2],[127590,127743,1],[127744,127776,2],[127777,127788,1],[127789,127797,2],[127798,127798,1],[127799,127868,2],[127869,127869,1],[127870,127891,2],[127892,127903,1],[127904,127946,2],[127947,127950,1],[127951,127955,2],[127956,127967,1],[127968,127984,2],[127985,127987,1],[127988,127988,2],[127989,127991,1],[127992,128062,2],[128063,128063,1],[128064,128064,2],[128065,128065,1],[128066,128252,2],[128253,128254,1],[128255,128317,2],[128318,128330,1],[128331,128334,2],[128335,128335,1],[128336,128359,2],[128360,128377,1],[128378,128378,2],[128379,128404,1],[128405,128406,2],[128407,128419,1],[128420,128420,2],[128421,128506,1],[128507,128591,2],[128592,128639,1],[128640,128709,2],[128710,128715,1],[128716,128716,2],[128717,128719,1],[128720,128722,2],[128723,128724,1],[128725,128727,2],[128728,128731,1],[128732,128735,2],[128736,128746,1],[128747,128748,2],[128749,128755,1],[128756,128764,2],[128765,128991,1],[128992,129003,2],[129004,129007,1],[129008,129008,2],[129009,129291,1],[129292,129338,2],[129339,129339,1],[129340,129349,2],[129350,129350,1],[129351,129535,2],[129536,129647,1],[129648,129660,2],[129661,129663,1],[129664,129672,2],[129673,129679,1],[129680,129725,2],[129726,129726,1],[129727,129733,2],[129734,129741,1],[129742,129755,2],[129756,129759,1],[129760,129768,2],[129769,129775,1],[129776,129784,2],[129785,131071,1],[131072,196605,2],[196606,196607,1],[196608,262141,2],[262142,917503,1],[917504,921599,0],[921600,1114111,1]];var Rr,As=65039,gs=e=>e>=127462&&e<=127487;function xs(e){let t=0,n=In.length-1;for(;t<=n;){let r=t+n>>1,o=In[r];if(e<o[0])n=r-1;else if(e>o[1])t=r+1;else return o[2]}return 1}function Gr(e){let t=0,n=!1,r=0;for(let o of e){let i=o.codePointAt(0);i===As&&(n=!0),gs(i)&&r++;let s=xs(i);s>t&&(t=s)}return n||r>=2?2:t}function*ze(e){for(let{segment:t}of(Rr??=new Intl.Segmenter("en",{granularity:"grapheme"})).segment(e))yield[t,Gr(t)]}function H(e){let t=0;for(let{segment:n}of(Rr??=new Intl.Segmenter("en",{granularity:"grapheme"})).segment(e))t+=Gr(n);return t}var st=24,Wr=4,Ie=28,ms=["_","-",".","/"],Be=e=>e.replace(/[A-Z]/g,t=>t.toLowerCase()),Nr=e=>e.replace(/[a-z]/g,t=>t.toUpperCase()),ps=/[\0-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g,Fr=e=>e.replace(ps,"");function ut(e){let t=e.split(`
2`).map(n=>n.endsWith("\r")?n.slice(0,-1):n);return t.length>0&&t[t.length-1]===""&&t.pop(),t}var bs=/[\p{Alphabetic}\p{N}]/u,Mn=e=>bs.test(e),at=e=>Mn(e)||e==="_",ys=10,ws={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};function Cs(e){let t=ws[e];if(t!==void 0)return t;if(!e.startsWith("#"))return null;let n=e.slice(1),r=/^[xX]/.test(n),o=r?n.slice(1):n;if(!(r?/^[0-9a-fA-F]+$/:/^[0-9]+$/).test(o))return null;let i=Number.parseInt(o,r?16:10);return i>1114111||i>=55296&&i<=57343||i<32||i>=127&&i<=159?null:String.fromCodePoint(i)}function fe(e){if(!e.includes("&"))return e;let t=[...e],n="",r=0;for(;r<t.length;){if(t[r]!=="&"){n+=t[r],r++;continue}let o=Math.min(r+1+ys,t.length),i=-1;for(let a=r+1;a<o;a++)if(t[a]===";"){i=a;break}let s=i===-1?null:Cs(t.slice(r+1,i).join(""));s===null?(n+="&",r++):(n+=s,r=i+1)}return n}function Is(e){let r=[...[...e].filter(i=>i!=="`").join("").replaceAll("**","").replaceAll("__","")],o="";for(let i=0;i<r.length;i++){let s=r[i],a=i>0&&Mn(r[i-1])&&r[i+1]!==void 0&&Mn(r[i+1]);(s==="*"||s==="_")&&!a||(o+=s)}return o.trim()}var Es=new Set(["b","strong","i","em","u","s","strike","del","ins","mark","small","big","sub","sup","code","kbd","samp","var","tt","span","font","q","abbr","cite","pre"]);function Ms(e,t){let n=t+1;e[n]==="/"&&n++;let r=n;for(;n<e.length&&/^[0-9A-Za-z]$/.test(e[n]);)n++;if(n===r)return null;let o=e.slice(r,n).join("");for(;n<e.length&&e[n]!==">";){if(e[n]==="<")return null;n++}return e[n]===">"?{name:o,end:n+1}:null}function ks(e){let t=[...e],n="",r=0;for(;r<t.length;){if(t[r]==="<"){let o=Ms(t,r);if(o){let i=o.name.toLowerCase();if(i==="br"){n+=" ",r=o.end;continue}if(Es.has(i)){r=o.end;continue}}}n+=t[r],r++}return n}function En(e,t,n){return e.length>=t.length+n.length&&e.startsWith(t)&&e.endsWith(n)?e.slice(t.length,e.length-n.length):null}function oe(e){let t=ks(e.trim()).trim(),n=(En(t,'"','"')??En(t,"'","'")??t).trim(),r=En(n,"`","`");return fe(r===null?n:Is(r.trim()))}function ht(e){let t="",n=!1;for(let r of e)r==="~"?(t+=n?">":"<",n=!n):t+=r;return t}function vs(e){let t=-1;for(let n of ms)t=Math.max(t,e.lastIndexOf(n));return t}function Yr(e,t,n){t=Math.max(1,t);let r=[],o="",i=0;for(let s of e.split(/\s+/).filter(a=>a!=="")){let a=H(s);if(a>t){o!==""&&(r.push(o),o="");let c="",l=0;for(let[d,f]of ze(s)){if(l+f>t&&c!==""){let u=vs(c),h=u===-1?"":c.slice(u+1);r.push(u===-1?c:c.slice(0,u+1)),c=h,l=H(h)}c+=d,l+=f}o=c,i=l}else o===""?(o=s,i=a):i+1+a<=t?(o+=` ${s}`,i+=1+a):(r.push(o),o=s,i=a)}if(o!==""&&r.push(o),r.length===0&&r.push(""),r.length>n){r.length=n;let s=Math.max(1,t-1),a="",c=0;for(let[l,d]of ze(r[r.length-1])){if(c+d>s)break;a+=l,c+=d}r[r.length-1]=`${a}\u2026`}return r}function ue(e,t){if(H(e)<=t)return e;let n="",r=0;for(let[o,i]of ze(e)){if(r+i+1>t)break;n+=o,r+=i}return`${n}\u2026`}var Ye=128,He=512,At=24,gt=6,xt=8;function mt(e){switch(Nr(e)){case"LR":return"right";case"RL":return"left";case"BT":return"up";default:return"down"}}var We=class{nodes=[];edges=[];index=new Map;groups=[];nodeGroup=[];curGroup=null;truncated=null;warnings=[];classDefs={};dir="down";constructor(t="down"){this.dir=t}nodeIndex(t,n,r){let o=this.index.get(t);return o!==void 0?(n!==null&&(this.nodes[o].label=n,this.nodes[o].shape=r),o):this.nodes.length>=Ye?(this.truncated??=`node cap (${Ye}) reached`,null):(this.index.set(t,this.nodes.length),this.nodes.push({label:n??t,shape:r}),this.nodeGroup.push(this.curGroup),this.nodes.length-1)}nodeLabel(t,n){let r=this.index.get(t);return r!==void 0?(this.nodes[r].label=n,r):this.nodeIndex(t,n,"round")}addClass(t,n){let r=this.nodes[t];r.classes??=[],r.classes.includes(n)||r.classes.push(n)}applyClasses(t){for(let[n,r]of t)for(let o of n){let i=this.index.get(o.trim());if(i!==void 0)for(let s of r)s.trim()!==""&&this.addClass(i,s.trim())}}applyHrefs(t){for(let[n,r]of t){let o=this.index.get(n.trim());o!==void 0&&(this.nodes[o].href=r)}}drop(t){this.truncated===null&&this.warnings.push(`dropped, unreadable statement: "${t}"`)}pushEdge(t){return this.edges.length>=He?(this.truncated??=`edge cap (${He}) reached`,!1):(this.edges.push(t),!0)}};var Gt="\0",z=1,_=2,Ee=4,ie=8,kn=1,vn=2,Sn=4,Me=class{w;h;ch;role;tag;href;mask;style;occupied;curStyle=Sn;curTag;curHref;constructor(t,n){let r=t*n;this.w=t,this.h=n,this.ch=new Array(r).fill(" "),this.role=new Array(r).fill("none"),this.tag=new Array(r).fill(void 0),this.href=new Array(r).fill(void 0),this.mask=new Uint8Array(r),this.style=new Uint8Array(r),this.occupied=new Uint8Array(r)}idx(t,n){return n*this.w+t}set(t,n,r,o){if(t>=this.w||n>=this.h)return;let i=this.idx(t,n);this.ch[i]=r===" "?" ":r,this.role[i]=o,this.curTag!==void 0&&(this.tag[i]=this.curTag),this.curHref!==void 0&&(this.href[i]=this.curHref)}addBits(t,n,r,o="edge"){if(t>=this.w||n>=this.h)return;let i=this.idx(t,n);this.occupied[i]||(this.mask[i]|=r,this.style[i]|=this.curStyle,this.role[i]!=="border"&&(this.role[i]=o),this.curTag!==void 0&&(this.tag[i]=this.curTag),this.curHref!==void 0&&(this.href[i]=this.curHref))}blit(t,n,r){for(let o=0;o<t.h;o++)for(let i=0;i<t.w;i++){let s=n+i,a=r+o;if(s>=this.w||a>=this.h)continue;let c=t.idx(i,o),l=this.idx(s,a);this.ch[l]=t.ch[c],this.role[l]=t.role[c],this.tag[l]=t.tag[c],this.href[l]=t.href[c],this.style[l]=t.style[c],this.occupied[l]=1}}junction(t,n,r){if(t>=this.w||n>=this.h)return;let o=this.idx(t,n);this.mask[o]|=r,this.role[o]!=="border"&&(this.role[o]="edge")}segV(t,n,r){let o=Math.min(n,r),i=Math.max(n,r);for(let s=o;s<=i;s++){let a=0;s>o&&(a|=z),s<i&&(a|=_),this.addBits(t,s,a)}}segH(t,n,r){let o=Math.min(n,r),i=Math.max(n,r);for(let s=o;s<=i;s++){let a=0;s>o&&(a|=Ee),s<i&&(a|=ie),this.addBits(s,t,a)}}finalizeMask(){for(let t=0;t<this.ch.length;t++)if(this.mask[t]!==0)if(this.ch[t]===" "){let n=Bs(this.mask[t]);this.ch[t]=this.style[t]===kn?Ws(n):this.style[t]===vn?Ns(n):n}else(this.ch[t]==="\u2550"||this.ch[t]==="\u2551")&&(this.ch[t]=Ds(this.ch[t],this.mask[t]))}flipVertical(){for(let t=0;t<Math.floor(this.h/2);t++){let n=this.h-1-t;for(let r=0;r<this.w;r++){let o=this.idx(r,t),i=this.idx(r,n);[this.ch[o],this.ch[i]]=[this.ch[i],this.ch[o]],[this.role[o],this.role[i]]=[this.role[i],this.role[o]],[this.tag[o],this.tag[i]]=[this.tag[i],this.tag[o]],[this.href[o],this.href[i]]=[this.href[i],this.href[o]]}}for(let t=0;t<this.ch.length;t++)Hr(this.role[t])||(this.ch[t]=Fs(this.ch[t]))}flipHorizontal(){for(let t=0;t<this.h;t++)for(let n=0;n<Math.floor(this.w/2);n++){let r=this.w-1-n,o=this.idx(n,t),i=this.idx(r,t);[this.ch[o],this.ch[i]]=[this.ch[i],this.ch[o]],[this.role[o],this.role[i]]=[this.role[i],this.role[o]],[this.tag[o],this.tag[i]]=[this.tag[i],this.tag[o]],[this.href[o],this.href[i]]=[this.href[i],this.href[o]]}for(let t=0;t<this.ch.length;t++)Hr(this.role[t])||(this.ch[t]=Ys(this.ch[t]));for(let t=0;t<this.h;t++){let n=0;for(;n<this.w;){let r=this.role[this.idx(n,t)];if(r==="text"||r==="edgeLabel"){let o=this.idx(n,t);for(;n<this.w&&this.role[this.idx(n,t)]===r;)n++;let i=this.idx(n,t);Ss(this.ch,o,i)}else n++}}}toLines(){let t=[],n=[],r=0;for(let s=0;s<this.h;s++){let a=0;for(let x=this.w-1;x>=0;x--)if(this.ch[this.idx(x,s)]!==" "){a=x+1;break}r=Math.max(r,a);let c=[],l=(x,w,g,y)=>{if(x==="")return;let b={text:x,role:w};g!==void 0&&(b.classes=g.split(" ")),y!==void 0&&(b.href=y),c.push(b)},d="",f="",u="none",h,A;for(let x=0;x<a;x++){let w=this.idx(x,s),g=this.ch[w];g!==Gt&&(d+=g,(this.role[w]!==u||this.tag[w]!==h||this.href[w]!==A)&&f!==""&&(l(f,u,h,A),f=""),u=this.role[w],h=this.tag[w],A=this.href[w],f+=g)}l(f,u,h,A),n.push(c),t.push(d.replace(/ +$/,""))}let o=0;for(;o<t.length&&t[o]==="";)o++;let i=t.length;for(;i>o&&t[i-1]==="";)i--;return{plain:t.slice(o,i),styled:n.slice(o,i),width:r}}};function Ss(e,t,n){for(let r=t,o=n-1;r<o;r++,o--)[e[r],e[o]]=[e[o],e[r]]}function ae(e,t,n,r,o){let i=n;for(let[s,a]of ze(t))if(a!==0){e.set(i,r,s,o);for(let c=1;c<a;c++)e.set(i+c,r,Gt,o);i+=a}}function nt(e,t,n,r,o){let i=n;for(let[s,a]of ze(t))if(a!==0){for(let c=0;c<a;c++)i+c<e.w&&r<e.h&&(e.mask[e.idx(i+c,r)]=0),e.set(i+c,r,c===0?s:Gt,o);i+=a}}function Bs(e){switch(e){case 0:return" ";case z:case _:case z|_:return"\u2502";case Ee:case ie:case Ee|ie:return"\u2500";case _|ie:return"\u250C";case _|Ee:return"\u2510";case z|ie:return"\u2514";case z|Ee:return"\u2518";case z|_|ie:return"\u251C";case z|_|Ee:return"\u2524";case _|Ee|ie:return"\u252C";case z|Ee|ie:return"\u2534";default:return"\u253C"}}function Ds(e,t){if(e==="\u2550"){if(t&z&&t&_)return"\u256A";if(t&_)return"\u2564";if(t&z)return"\u2567"}else{if(t&Ee&&t&ie)return"\u256B";if(t&ie)return"\u255F";if(t&Ee)return"\u2562"}return e}var $s={"\u2500":"\u254C","\u2502":"\u254E"},Ls={"\u2500":"\u2501","\u2502":"\u2503","\u250C":"\u250F","\u2510":"\u2513","\u2514":"\u2517","\u2518":"\u251B","\u251C":"\u2523","\u2524":"\u252B","\u252C":"\u2533","\u2534":"\u253B","\u253C":"\u254B"},Rs={"\u2554":"\u255A","\u255A":"\u2554","\u2557":"\u255D","\u255D":"\u2557","\u2564":"\u2567","\u2567":"\u2564","\u250C":"\u2514","\u2514":"\u250C","\u2510":"\u2518","\u2518":"\u2510","\u250F":"\u2517","\u2517":"\u250F","\u2513":"\u251B","\u251B":"\u2513","\u256D":"\u2570","\u2570":"\u256D","\u256E":"\u256F","\u256F":"\u256E","\u252C":"\u2534","\u2534":"\u252C","\u2533":"\u253B","\u253B":"\u2533","\u25BC":"\u25B2","\u25B2":"\u25BC","\u25BD":"\u25B3","\u25B3":"\u25BD"},Gs={"\u2554":"\u2557","\u2557":"\u2554","\u255A":"\u255D","\u255D":"\u255A","\u255F":"\u2562","\u2562":"\u255F","\u250C":"\u2510","\u2510":"\u250C","\u2514":"\u2518","\u2518":"\u2514","\u250F":"\u2513","\u2513":"\u250F","\u2517":"\u251B","\u251B":"\u2517","\u256D":"\u256E","\u256E":"\u256D","\u2570":"\u256F","\u256F":"\u2570","\u251C":"\u2524","\u2524":"\u251C","\u2523":"\u252B","\u252B":"\u2523","\u25B6":"\u25C4","\u25C4":"\u25B6","\u25B7":"\u25C1","\u25C1":"\u25B7"},Ws=e=>$s[e]??e,Ns=e=>Ls[e]??e,Fs=e=>Rs[e]??e,Ys=e=>Gs[e]??e,Hr=e=>e==="text"||e==="edgeLabel"||e==="title";var Ne=1,Kr=3,Tr=2,Bn=1<<21,V=(e,t)=>Math.max(0,e-t),se=e=>Math.floor(e/2);function Xe(e){let t=[e.cardFrom??"",e.label??"",e.cardTo??""].filter(n=>n!=="").join(" ");return t===""?null:t}function Hs(e){let t=e.nodes.length,n=Array.from({length:t},()=>[]),r=new Array(t).fill(0);for(let l of e.edges)l.from!==l.to&&(n[l.from].push(l.to),r[l.to]++);let o=new Uint8Array(t),i=Array.from({length:t},()=>[]),s=[],a=[...Array(t).keys()].filter(l=>r[l]===0);for(let l of[...a,...Array(t).keys()])o[l]===0&&Ts(l,n,o,i,s);let c=new Array(t).fill(0);for(let l=s.length-1;l>=0;l--){let d=s[l];for(let f of i[d])c[f]=Math.max(c[f],c[d]+1)}return c}function Ts(e,t,n,r,o){let i=[{u:e,i:0}];for(n[e]=1;i.length>0;){let s=i[i.length-1],a=s.u;if(s.i<t[a].length){let c=t[a][s.i];if(s.i++,n[c]===1)continue;r[a].push(c),n[c]===0&&(n[c]=1,i.push({u:c,i:0}))}else n[a]=2,o.push(a),i.pop()}}function Qs(e,t,n){let r=n.length;if(e.length<2||r<3)return;let o=Array.from({length:r},()=>[]),i=Array.from({length:r},()=>[]);for(let d of t)d.from!==d.to&&n[d.to]>n[d.from]&&(o[d.to].push(d.from),i[d.from].push(d.to));let s=new Array(r).fill(0),a=d=>{for(let f=0;f<d.length;f++)s[d[f]]=f};for(let d of e)a(d);let c=e.map(d=>[...d]),l=Qr(t,n,s);if(l!==0){for(let d=0;d<8;d++){let f=d%2===0?e.slice(1):e.slice(0,-1).reverse(),u=d%2===0?o:i;for(let A of f)Ks(A,u,s),a(A);let h=Qr(t,n,s);if(h<l&&(l=h,c=e.map(A=>[...A])),l===0)break}for(let d=0;d<e.length;d++)e[d].splice(0,e[d].length,...c[d])}}function Ks(e,t,n){let r=e.map(o=>({key:t[o].length===0?n[o]:t[o].reduce((i,s)=>i+n[s],0)/t[o].length,v:o}));r.sort((o,i)=>o.key-i.key);for(let o=0;o<r.length;o++)e[o]=r[o].v}function Qr(e,t,n){let r=e.filter(i=>i.from!==i.to&&t[i.to]===t[i.from]+1).map(i=>[t[i.from],n[i.from],n[i.to]]),o=0;for(let i=0;i<r.length;i++){let s=r[i];for(let a=i+1;a<r.length;a++){let c=r[a];s[0]===c[0]&&(s[1]<c[1]&&s[2]>c[2]||s[1]>c[1]&&s[2]<c[2])&&o++}}return o}function Or(e,t,n,r,o){let i=t.length,s=Array.from({length:i},()=>[]),a=Array.from({length:i},()=>[]);for(let d of r)d.from!==d.to&&o[d.to]>o[d.from]&&(s[d.to].push(d.from),a[d.from].push(d.to));let c=new Array(i).fill(0);for(let d of e){let f=0;for(let u of d){let h=t[u]/2;f+=h,c[u]=f,f+=h+n}}for(let d=0;d<10;d++){let f=d%2===0?e:[...e].reverse(),u=d%2===0?s:a;for(let h of f)Os(h,u,c,t,n)}let l=Number.POSITIVE_INFINITY;for(let d=0;d<i;d++)l=Math.min(l,c[d]-t[d]/2);return Number.isFinite(l)||(l=0),Array.from({length:i},(d,f)=>Math.max(0,Math.round(c[f]-l)))}function Os(e,t,n,r,o){let i=e.length;if(i===0)return;let s=e.map(d=>t[d].length===0?n[d]:t[d].reduce((f,u)=>f+n[u],0)/t[d].length),a=d=>r[e[d]]/2,c=new Array(i);for(let d=0;d<i;d++)c[d]=d===0?s[d]:Math.max(s[d],c[d-1]+a(d-1)+o+a(d));let l=new Array(i);for(let d=i-1;d>=0;d--)l[d]=d===i-1?s[d]:Math.min(s[d],l[d+1]-a(d+1)-o-a(d));for(let d=0;d<i;d++)n[e[d]]=(c[d]+l[d])/2;for(let d=1;d<i;d++){let f=n[e[d-1]]+a(d-1)+o+a(d);n[e[d]]<f&&(n[e[d]]=f)}}function Wt(e,t=!1){let n=[...e].sort((i,s)=>(t?i.end-i.start-(s.end-s.start):0)||i.start-s.start||i.end-s.end||i.from-s.from||i.to-s.to||i.edge-s.edge),r=[],o=[];for(let i of n){let s=r.findIndex(a=>a.every(c=>c.end+2<=i.start||i.end+2<=c.start||(c.from===i.from||c.to===i.to)&&!c.labeled&&!i.labeled));s===-1&&(r.push([]),s=r.length-1),r[s].push(i),o.push([i.edge,s])}return{assigned:o,count:r.length}}var pt=(e,t)=>t.from!==t.to&&e[t.from]===e[t.to]+1;function Xr(e,t,n,r,o,i){let s=[];return e.edges.forEach((a,c)=>{let l=o?n[a.from]!==n[a.to]:Math.abs(n[a.from]-n[a.to])>1,d=Math.min(t[a.from],t[a.to]),f=i?Math.abs(t[a.from]-t[a.to])===1:t[a.to]===t[a.from]+1;a.from!==a.to&&f&&d===r&&l&&s.push({start:Math.min(n[a.from],n[a.to]),end:Math.max(n[a.from],n[a.to]),from:a.from,to:a.to,edge:c})}),s}function Pr(e,t,n,r){let o=[];return e.edges.forEach((i,s)=>{if(i.from===i.to||t[i.to]===t[i.from]+1||r&&pt(t,i))return;let a=n[i.from],c=n[i.to],l=r?Math.min(a.cy,c.cy):Math.min(a.cx,c.cx),d=r?Math.max(a.cy,c.cy):Math.max(a.cx,c.cx);o.push({start:l,end:d,from:i.from,to:i.to,edge:s,labeled:Xe(i)!==null})}),o}function Xs(e,t,n,r,o,i){let s=Or(n,r.layW,Kr,o.edges,e),a=k=>V(s[k],se(r.boxW[k])),c=k=>a(k)+r.boxW[k]-1,l=k=>k.from!==k.to&&e[k.to]-e[k.from]>1,d=new Array(o.edges.length).fill(-1),f=new Array(o.edges.length).fill(!1),u=new Array(o.nodes.length).fill(-1),h=new Array(o.edges.length).fill(!1),A=k=>{let R=[k.label,k.cardTo].filter(N=>N!=null);return R.length===0?-1:Math.max(...R.map(N=>Math.min(H(N),Ie)))},x=o.nodes.map(()=>[]),w=o.nodes.map(()=>[]);o.edges.forEach((k,R)=>{k.from!==k.to&&(l(k)?x[k.to].push(R):e[k.to]===e[k.from]+1&&w[k.to].push(R))}),o.nodes.forEach((k,R)=>{let N=x[R];if(N.length===0)return;let K=w[R],P=s[R],F=a(R),J=c(R),Q=K.length>0,ce=Q&&K.some(le=>Math.abs(s[o.edges[le].from]-P)<=1),Fe=Q&&ce?P:F,tt=Q&&ce?N.length:(Q?1:0)+N.length,Oe=le=>Fe+Math.round((J-Fe)*(le+1)/(tt+1)),Se=[];Q&&Se.push({slot:ce?P:Oe(0),w:Math.max(...K.map(le=>A(o.edges[le]))),skip:null}),N.forEach((le,Re)=>{Se.push({slot:Oe(Q&&ce?Re:Re+(Q?1:0)),w:A(o.edges[le]),skip:le})});let Pt=[],$t=[],dt=F,Lt=!0;for(let[le,Re]of Se.entries()){let Ge=Math.max(Re.slot,dt);if(Ge>J-1){Lt=!1;break}let hs=Se[le+1]?.slot??Number.MAX_SAFE_INTEGER,Rt=Re.w;Rt>=0&&Ge+Rt+2>hs&&Ge-dt>=Rt?($t.push(!0),dt=Ge+2):($t.push(!1),dt=Rt>=0?Ge+Rt+2:Ge+2),Pt.push(Ge)}if(Lt){Se.forEach((le,Re)=>{if(le.skip===null){if(u[R]=Pt[Re],$t[Re])for(let Ge of K)h[Ge]=!0}else d[le.skip]=Pt[Re],h[le.skip]=$t[Re]});return}let ft=Q?Math.max(P,...K.map(le=>P+1+A(o.edges[le]))):-1;for(let le of N){let Re=ft===-1?P+2:ft+2,Ge=Math.min(Re,J-1);Ge>Math.max(P,ft)?d[le]=Ge:(d[le]=Math.max(F+1,P-2),h[le]=!0)}}),o.edges.forEach((k,R)=>{if(!l(k))return;let N=d[R];f[R]=o.nodes.every((K,P)=>e[P]<=e[k.from]||e[P]>=e[k.to]||N<a(P)||N>c(P))});let g=new Array(o.edges.length).fill(0),y=new Array(t+1).fill(0);for(let k=0;k<t;k++){let R=Xr(o,e,s,k,!1,!0);if(o.edges.forEach((Q,ce)=>{if(!l(Q)||e[Q.from]!==k)return;let Fe=f[ce]?d[ce]:1<<29;R.push({start:Math.min(s[Q.from],Fe),end:Math.max(s[Q.from],Fe),from:Q.from,to:Q.to,edge:ce})}),R.length===0)continue;let N=R.filter(Q=>pt(e,o.edges[Q.edge])),K=R.filter(Q=>!pt(e,o.edges[Q.edge])),P=o.edges.some(Q=>pt(e,Q)&&e[Q.to]===k)?1:0,F=Wt(N);for(let[Q,ce]of F.assigned)g[Q]=P+ce;let J=Wt(K);for(let[Q,ce]of J.assigned)g[Q]=P+F.count+ce;y[k]=P+F.count+J.count}let b=new Array(t+1).fill(!1);o.edges.forEach((k,R)=>{l(k)&&!f[R]&&(b[e[k.to]]=!0)});for(let k=0;k<t;k++)b[k+1]&&(y[k]+=1);let m=n.map(k=>k.length===0?3:Math.max(...k.map(R=>r.boxH[R]+r.extraH[R]))),M=o.edges.some(k=>k.cardFrom!==void 0||k.cardTo!==void 0)?Math.max(Tr,3):Tr,v=new Array(t+1).fill(0);for(let k=1;k<=t;k++)v[k]=v[k-1]+m[k-1]+Math.max(M,y[k-1]+1);let I=v[t]+m[t],p=Array.from({length:t+1},(k,R)=>v[R]+m[R]),S=v,B=new Array(t+1).fill(-1);for(let k=0;k<t;k++)b[k+1]&&(B[k+1]=v[k+1]-2);let D=1;n.forEach((k,R)=>{for(let N of k){let K=r.boxW[N],P=r.boxH[N],F=s[N],J=V(F,se(K)),Q=v[R]+se(m[R]-P-r.extraH[N]);i[N]={x:J,y:Q,w:K,h:P,cx:F,cy:Q+se(P),rank:R},D=Math.max(D,J+K),r.extraH[N]>0&&r.selfLabelW[N]>0&&(D=Math.max(D,J+K+2+r.selfLabelW[N]))}});let $=D;for(let k of o.edges)if(k.from!==k.to)if(e[k.to]===e[k.from]+1){let R=[k.label,k.cardTo].filter(N=>N!=null);for(let N of R){let K=Math.min(H(N),Ie);$=Math.max($,i[k.to].cx+2+K)}k.cardFrom!==void 0&&($=Math.max($,i[k.from].cx+2+H(k.cardFrom)))}else if(pt(e,k)){let R=Xe(k);R!==null&&($=Math.max($,i[k.to].cx+2+Math.min(H(R),Ie)))}else{let R=Xe(k);R!==null&&($=Math.max($,D+Math.min(H(R),Ie)+1))}let L=new Array(o.edges.length).fill(0),W=Pr(o,e,i,!0).filter(k=>!f[k.edge]),T=$,j=0;if(W.length>0){let{assigned:k,count:R}=Wt(W,!0);for(let[N,K]of k)L[N]=K;T=$+1+R,j=$+1}return{canvasW:T,canvasH:I,bandEnd:p,rankStart:S,edgeBus:g,laneBase:j,edgeLane:L,skipApproach:B,edgeEntryX:d,edgeStraight:f,fwdEntryX:u,edgeLabelLeft:h}}function Ps(e,t,n,r,o,i){let s=n.map(I=>I.length===0?0:Math.max(...I.map(p=>r.boxW[p]))),a=Or(n,r.layH,1,o.edges,e),c=I=>I.from!==I.to&&e[I.to]-e[I.from]>1,l=new Set;for(let I of o.edges){if(I.from===I.to||e[I.to]>=e[I.from])continue;let p=I.to;l.add(V(a[p],se(r.boxH[p]+r.extraH[p]))+r.boxH[p])}let d=new Array(o.edges.length).fill(!1);o.edges.forEach((I,p)=>{if(!c(I))return;let S=a[I.to];d[p]=!l.has(S)&&o.nodes.every((B,D)=>e[D]<=e[I.from]||e[D]>=e[I.to]||Math.abs(a[D]-S)>se(r.boxH[D]+r.extraH[D]))});let f=new Array(t+1).fill(0);o.edges.forEach((I,p)=>{if(I.from===I.to||e[I.to]!==e[I.from]+1&&!d[p])return;let S=I.label===null?0:Math.min(H(I.label),Ie),B=[I.cardFrom,I.cardTo].filter(D=>D!==void 0).reduce((D,$)=>D+H($)+1,0);f[e[I.from]]=Math.max(f[e[I.from]],S+B)});let u=new Array(o.edges.length).fill(0),h=new Array(t+1).fill(0);for(let I=0;I<t;I++){let p=Xr(o,e,a,I,!0,!1);if(o.edges.forEach((D,$)=>{!c(D)||!d[$]||e[D.from]!==I||p.push({start:Math.min(a[D.from],a[D.to]),end:Math.max(a[D.from],a[D.to]),from:D.from,to:D.to,edge:$})}),p.length===0)continue;let{assigned:S,count:B}=Wt(p);for(let[D,$]of S)u[D]=$;h[I]=B}let A=new Array(t+1).fill(0);for(let I=1;I<=t;I++){let p=Math.max(Kr+1,f[I-1]+3,h[I-1]+1);A[I]=A[I-1]+s[I-1]+p}let x=n[t].filter(I=>r.extraH[I]>0&&r.selfLabelW[I]>0).map(I=>2+r.selfLabelW[I]),w=A[t]+s[t]+(x.length===0?0:Math.max(...x)),g=Array.from({length:t+1},(I,p)=>A[p]+s[p]),y=A,b=1;n.forEach((I,p)=>{let S=A[p];for(let B of I){let D=r.boxW[B],$=r.boxH[B],L=a[B],W=V(L,se($+r.extraH[B]));i[B]={x:S,y:W,w:D,h:$,cx:S+se(D),cy:W+se($),rank:p},b=Math.max(b,W+$+r.extraH[B])}});let m=new Array(o.edges.length).fill(0),C=Pr(o,e,i,!1).filter(I=>!d[I.edge]),M=b,v=0;if(C.length>0){let{assigned:I,count:p}=Wt(C,!0);for(let[S,B]of I)m[S]=B;M=b+1+p,v=b+1}return{canvasW:w,canvasH:M,bandEnd:g,rankStart:y,edgeBus:u,laneBase:v,edgeLane:m,skipApproach:new Array(t+1).fill(-1),edgeEntryX:new Array(o.edges.length).fill(-1),edgeStraight:d,fwdEntryX:new Array(o.nodes.length).fill(-1),edgeLabelLeft:new Array(o.edges.length).fill(!1)}}function Dn(e,t){let n=e.nodes.length;if(n===0)return null;let r=new Map;e.edges.forEach((m,C)=>{if(m.from===m.to)return;let M=`${m.from}>${m.to}`,v=r.get(M);if(v===void 0){r.set(M,C);return}if(m.label!==null){let I=e.edges[v].label;e.edges[v].label=I===null?m.label:`${I} / ${m.label}`,m.label=null}});let o=Hs(e),i=Math.max(...o,0),s=Array.from({length:i+1},()=>[]);for(let m=0;m<o.length;m++)s[o[m]].push(m);Qs(s,e.edges,o);let a=e.dir==="down"||e.dir==="up",c=new Array(e.nodes.length).fill(!1);for(let m of e.edges)a&&pt(o,m)||m.from!==m.to&&o[m.to]!==o[m.from]+1&&(c[m.from]=!0,c[m.to]=!0);for(let m of s)m.sort((C,M)=>Number(c[C])-Number(c[M]));let l=e.nodes.map(m=>Yr(m.label,st,Wr)),d=m=>Math.max(1,m.length===0?1:Math.max(...m.map(H))),f=t.map((m,C)=>m.kind==="frame"?Math.max(m.sub.w+2,H(ue(e.nodes[C].label,st))+4):m.kind==="compartments"?d(m.sections.flat())+2*Ne+2:d(l[C])+2*Ne+2),u=t.map((m,C)=>{if(m.kind==="frame")return m.sub.h+2;if(m.kind==="compartments"){let M=m.sections.filter(v=>v.length>0).length;return m.sections.reduce((v,I)=>v+I.length,0)+V(M,1)+2}return l[C].length+2}),h=new Array(n).fill(0),A=new Array(n).fill(0);for(let m of e.edges){if(m.from!==m.to)continue;h[m.from]=2;let C=Xe(m);C!==null&&(A[m.from]=Math.max(A[m.from],Math.min(H(C),Ie)))}for(let m=0;m<n;m++)h[m]>0&&(f[m]=Math.max(f[m],7));let x={boxW:f,boxH:u,layW:f.map((m,C)=>m+(A[C]>0?2*(A[C]+3):0)),layH:u.map((m,C)=>m+h[C]),extraH:h,selfLabelW:A},w=Array.from({length:n},()=>({x:0,y:0,w:0,h:0,cx:0,cy:0,rank:0})),g=a?Xs(o,i,s,x,e,w):Ps(o,i,s,x,e,w);if(g.canvasW*g.canvasH>Bn)return null;let y=new Me(g.canvasW,g.canvasH);for(let m=0;m<n;m++){let C=t[m];y.curTag=e.nodes[m].classes?.join(" "),y.curHref=e.nodes[m].href;let M=e.dir==="up";C.kind==="frame"?js(y,w[m],e.nodes[m].label,C.sub,M):C.kind==="compartments"?Js(y,w[m],C.sections,M):bt(y,w[m],l[m],e.nodes[m].shape,M)}y.curTag=void 0,y.curHref=void 0;let b=[];return e.edges.forEach((m,C)=>{if(y.curStyle=m.line==="dotted"?kn:m.line==="thick"?vn:Sn,m.from===m.to){Us(y,w[m.from],m);return}let M=w[m.from],v=w[m.to],I=v.rank===M.rank+1,p=M.rank===v.rank+1,S=g.bandEnd[(p?v:M).rank]+g.edgeBus[C],B=g.laneBase+g.edgeLane[C];a?I?_s(y,M,v,m,S,g.fwdEntryX[m.to],g.edgeLabelLeft[C]):p?Zs(y,M,v,m,S):v.rank>M.rank?Vs(y,M,v,m,{laneX:B,entryX:g.edgeEntryX[C],busY:S,approachY:g.skipApproach[v.rank],straight:g.edgeStraight[C],labelLeft:g.edgeLabelLeft[C]}):zs(y,M,v,m,B):I?qs(y,M,v,m,S):v.rank>M.rank&&g.edgeStraight[C]?ea(y,M,v,m,S):ta(y,M,v,m,B,b)}),na(y,b),y.finalizeMask(),y}function $n(e,t){return t.dir==="up"?e.flipVertical():t.dir==="left"&&e.flipHorizontal(),e}function Jt(e){let t=e.nodes.map(()=>({kind:"plain"})),n=Dn(e,t);return n&&$n(n,e)}function jt(e){let t=e.nodes.map(r=>({kind:"compartments",sections:r.sections??[[r.label]]})),n=Dn(e,t);return n&&$n(n,e)}function _t(e){let t=new Map;e.groups.forEach((f,u)=>{let h=e.index.get(f.id);h!==void 0&&t.set(h,u)});let n=f=>{let u=[],h=f;for(;h!==null;)u.push(h),h=e.groups[h].parent;return u.reverse()},r=f=>{let u=t.get(f);return u===void 0?{item:{group:!1,i:f},chain:n(e.nodeGroup[f])}:{item:{group:!0,i:u},chain:n(e.groups[u].parent)}},o=new Map,i=new Array(e.groups.length).fill(!1);e.edges.forEach((f,u)=>{let h=r(f.from),A=r(f.to),x=0;for(;x<h.chain.length&&x<A.chain.length&&h.chain[x]===A.chain[x];)x++;let w=x===0?null:h.chain[x-1],g=h.chain.length>x?{group:!0,i:h.chain[x]}:h.item,y=A.chain.length>x?{group:!0,i:A.chain[x]}:A.item;for(let m of[g,y])m.group&&(i[m.i]=!0);let b=o.get(w);b?b.push([g,y,u]):o.set(w,[[g,y,u]])});let s=new Map;e.nodeGroup.forEach((f,u)=>{if(t.has(u))return;let h=s.get(f);h?h.push(u):s.set(f,[u])});let a=e.groups.map(()=>[]);e.groups.forEach((f,u)=>{f.parent!==null&&a[f.parent].push(u)});let c=new Array(e.groups.length).fill(!1),l=f=>{let u=i[f]||(s.get(f)??[]).length>0;for(let h of a[f])l(h)&&(u=!0);return c[f]=u,u};e.groups.forEach((f,u)=>{f.parent===null&&l(u)});let d=Jr(e,null,o,s,c);return d&&$n(d,e)}function Jr(e,t,n,r,o){let i=(r.get(t)??[]).map(h=>({group:!1,i:h})),s=e.groups.map((h,A)=>A).filter(h=>e.groups[h].parent===t&&o[h]);if(i.push(...s.map(h=>({group:!0,i:h}))),i.length===0)return new Me(1,1);let a=new Map,c=new Map,l=[],d=[];for(let h of i)if((h.group?c:a).set(h.i,l.length),!h.group)l.push({label:e.nodes[h.i].label,shape:e.nodes[h.i].shape,classes:e.nodes[h.i].classes,href:e.nodes[h.i].href}),d.push({kind:"plain"});else{let A=Jr(e,h.i,n,r,o);if(A===null)return null;l.push({label:e.groups[h.i].label,shape:"rect"}),d.push({kind:"frame",sub:A})}let f=[];for(let[h,A,x]of n.get(t)??[]){let w=(h.group?c:a).get(h.i),g=(A.group?c:a).get(A.i);if(w===void 0||g===void 0)continue;let y=e.edges[x];f.push({from:w,to:g,label:y.label,headTo:y.headTo,headFrom:y.headFrom,line:y.line})}let u=new We(e.dir);return u.nodes=l,u.edges=f,Dn(u,d)}function bt(e,t,n,r,o=!1){let{x:i,y:s,w:a,h:c}=t,l=i+a-1,d=s+c-1,[f,u,h,A]=r==="diamond"?["\u2554","\u2557","\u255A","\u255D"]:r==="round"?["\u256D","\u256E","\u2570","\u256F"]:["\u250C","\u2510","\u2514","\u2518"];if(e.set(i,s,f,"border"),e.set(l,s,u,"border"),e.set(i,d,h,"border"),e.set(l,d,A,"border"),r==="diamond"){for(let g=i+1;g<l;g++)e.set(g,s,"\u2550","border"),e.set(g,d,"\u2550","border");for(let g=s+1;g<d;g++)e.set(i,g,"\u2551","border"),e.set(l,g,"\u2551","border")}else{for(let g=i+1;g<l;g++)e.addBits(g,s,Ee|ie,"border"),e.addBits(g,d,Ee|ie,"border");for(let g=s+1;g<d;g++)e.addBits(i,g,z|_,"border"),e.addBits(l,g,z|_,"border")}for(let g=s;g<=d;g++)for(let y=i;y<=l;y++){let b=e.idx(y,g);e.occupied[b]=1,e.curTag!==void 0&&(e.tag[b]=e.curTag),e.curHref!==void 0&&(e.href[b]=e.curHref)}let x=Math.max(1,V(a,2*Ne+2));(o?[...n].reverse():n).forEach((g,y)=>{let b=ue(g,x),m=i+1+Ne+se(V(x,H(b)));ae(e,b,m,s+1+y,"text")})}function Js(e,t,n,r=!1){bt(e,t,[],"rect");let o=Math.max(1,V(t.w,2*Ne+2)),i=[];n.forEach((s,a)=>{if(s.length!==0){i.length>0&&i.push({sep:!0});for(let c of s)i.push({text:ue(c,o),center:a===0})}}),r&&i.reverse(),i.forEach((s,a)=>{let c=t.y+1+a;if(s.sep){e.set(t.x,c,"\u251C","border");for(let l=t.x+1;l<t.x+t.w-1;l++)e.set(l,c,"\u2500","border");e.set(t.x+t.w-1,c,"\u2524","border")}else{let l=s.center?t.x+1+Ne+se(V(o,H(s.text))):t.x+1+Ne;nt(e,s.text,l,c,"text")}})}function js(e,t,n,r,o=!1){if(bt(e,t,[],"rect"),n!==""){let i=ue(n,V(t.w,4));nt(e,` ${i} `,t.x+1,o?t.y+t.h-1:t.y,"text")}e.blit(r,t.x+1+se(t.w-2-r.w),t.y+1+se(t.h-2-r.h))}function ke(e,t){switch(e){case"circle":return"o";case"cross":return"\xD7";case"diamondFill":return"\u25C6";case"diamondOpen":return"\u25C7";case"triangle":return{"\u25BC":"\u25BD","\u25B2":"\u25B3","\u25C4":"\u25C1","\u25B6":"\u25B7"}[t]??t;default:return t}}function _s(e,t,n,r,o,i=-1,s=!1){let a=i===-1?n.cx:i,c=Math.abs(t.cx-a)<=1?a:t.cx,l=t.y+t.h-1,d=n.y-1;if(e.junction(c,l,_),e.segV(c,l,o),c===a?e.segV(c,o,d):(e.segH(o,c,a),e.segV(a,o,d)),r.headTo==="none"?e.addBits(a,d,z):e.set(a,d,ke(r.headTo,"\u25BC"),"edge"),r.headFrom!=="none"&&e.set(c,l,ke(r.headFrom,"\u25B2"),"edge"),r.cardFrom===void 0&&r.cardTo===void 0){if(r.label!==null){let u=s?V(a,Math.min(H(r.label),Ie)):a+1;$e(e,r.label,d,u)}return}let f=l+1;if(r.cardFrom!==void 0&&$e(e,r.cardFrom,f,c+1),r.cardTo!==void 0&&$e(e,r.cardTo,d,a+1),r.label!==null){let u=d-1;if(u>f){let h=u>o?a:c;$e(e,r.label,u,h+1)}else $e(e,r.label,d,a+1+(r.cardTo===void 0?0:H(r.cardTo)+1))}}function Zs(e,t,n,r,o){let i=Math.min(n.x+n.w-2,n.cx+2),s=Math.min(t.x+t.w-2,t.cx+2),a=Math.abs(s-i)<=1?i:s,c=t.y,l=n.y+n.h;e.junction(a,c,z),a===i?e.segV(a,l,c):(e.segV(a,o,c),e.segH(o,a,i),e.segV(i,l,o)),r.headTo==="none"?e.addBits(i,l,_):e.set(i,l,ke(r.headTo,"\u25B2"),"edge"),r.headFrom!=="none"&&e.set(a,c,ke(r.headFrom,"\u25BC"),"edge");let d=Xe(r);d!==null&&$e(e,d,l,i+1)}function Us(e,t,n){let r=t.y+t.h-1,o=t.cx+1,i=t.x+t.w-2;if(i<=o||r+2>=e.h)return;let[s,a,c,l]=n.line==="dotted"?["\u254E","\u254C","\u2570","\u256F"]:n.line==="thick"?["\u2503","\u2501","\u2517","\u251B"]:["\u2502","\u2500","\u2570","\u256F"];e.junction(o,r,_),e.set(o,r+1,s,"edge"),e.set(o,r+2,c,"edge");for(let f=o+1;f<i;f++)e.set(f,r+2,a,"edge");e.set(i,r+2,l,"edge"),e.set(i,r+1,ke(n.headTo,"\u25B2"),"edge");let d=Xe(n);d!==null&&$e(e,d,r+1,t.x+t.w+1)}function Vs(e,t,n,r,o){let{laneX:i,entryX:s,busY:a,approachY:c,straight:l,labelLeft:d}=o,f=t.cx,u=t.y+t.h-1;e.junction(f,u,_),e.segV(f,u,a),l?(e.segH(a,f,s),e.segV(s,a,n.y-1)):(e.segH(a,f,i),e.segV(i,a,c),e.segH(c,s,i),e.segV(s,c,n.y-1)),r.headTo==="none"?e.addBits(s,n.y-1,_):e.set(s,n.y-1,ke(r.headTo,"\u25BC"),"edge"),r.headFrom!=="none"&&e.set(f,u,ke(r.headFrom,"\u25B2"),"edge");let h=Xe(r);if(h!==null){let A=d?V(s,Math.min(H(h),Ie)):s+1;$e(e,h,n.y-1,A)}}function zs(e,t,n,r,o){let i=t.x+t.w-1,s=t.cy,a=Xe(r);e.junction(i,s,ie),e.segH(s,i,o),r.headFrom!=="none"&&e.set(i,s,ke(r.headFrom,"\u25C4"),"edge");let c=n.x+n.w-1,l=n.cy;e.segV(o,s,l),e.segH(l,c+1,o),r.headTo==="none"?e.addBits(c+1,l,ie):e.set(c+1,l,ke(r.headTo,"\u25C4"),"edge"),a!==null&&$e(e,a,V(l,1),V(o,H(a)+1))}function qs(e,t,n,r,o){let i=t.x+t.w-1,s=t.cy,a=n.cy,c=n.x-1;e.junction(i,s,ie),e.segH(s,i,o),s===a?e.segH(s,o,c):(e.segV(o,s,a),e.segH(a,o,c)),r.headTo==="none"?e.addBits(c,a,ie):e.set(c,a,ke(r.headTo,"\u25B6"),"edge"),r.headFrom!=="none"&&e.set(i,s,ke(r.headFrom,"\u25C4"),"edge"),r.label!==null&&$e(e,r.label,V(a,1),o+1),r.cardFrom!==void 0&&$e(e,r.cardFrom,V(s,1),i+1),r.cardTo!==void 0&&$e(e,r.cardTo,V(a,1),V(c,H(r.cardTo)))}function ea(e,t,n,r,o){let i=t.cy,s=n.cy,a=t.x+t.w-1,c=n.x-1;e.junction(a,i,ie),e.segH(i,a,o),i!==s&&e.segV(o,i,s),e.segH(s,o,c),r.headTo==="none"?e.addBits(c,s,ie):e.set(c,s,ke(r.headTo,"\u25B6"),"edge"),r.headFrom!=="none"&&e.set(a,i,ke(r.headFrom,"\u25C4"),"edge");let l=Xe(r);l!==null&&$e(e,l,V(s,1),o+1)}function ta(e,t,n,r,o,i){let s=t.cx,a=t.y+t.h-1,c=n.cx,l=n.y+n.h-1;e.junction(s,a,_),e.segV(s,a,o),e.segH(o,s,c),e.segV(c,o,l+1),r.headTo==="none"?e.addBits(c,l+1,_):e.set(c,l+1,ke(r.headTo,"\u25B2"),"edge"),r.headFrom!=="none"&&e.set(s,a,ke(r.headFrom,"\u25B2"),"edge");let d=Xe(r);d!==null&&i.push({text:` ${ue(d,Ie)} `,y:o,lo:Math.min(s,c),hi:Math.max(s,c)})}function na(e,t){for(let{text:n,y:r,lo:o,hi:i}of t){let s=H(n),a=i-1-s;if(a<o+1||r>=e.h)continue;let c=f=>{for(let u=f;u<f+s;u++){let h=e.idx(u,r);if(e.occupied[h]===1||(e.mask[h]&(z|_))!==0||e.ch[h]!==" ")return!1}return!0},l=Math.min(Math.max(se(o+i)-se(s),o+1),a),d=l;for(let f=0;;f++){let u=l-f,h=l+f;if(u<o+1&&h>a)break;if(u>=o+1&&c(u)){d=u;break}if(h<=a&&c(h)){d=h;break}}nt(e,n,d,r,"edgeLabel")}}function $e(e,t,n,r){if(n>=e.h)return;let o=ue(t,Ie),i=r;for(let[s,a]of ze(o)){if(a===0)continue;if(i+a>e.w)break;let c=!1;for(let l=0;l<a;l++){let d=e.idx(i+l,n);(e.ch[d]!==" "||e.mask[d]!==0||e.occupied[d])&&(c=!0)}if(c)break;e.set(i,n,s,"edgeLabel");for(let l=1;l<a;l++)e.set(i+l,n,Gt,"edgeLabel");i+=a}}function jr(e,t){let n=e.trim();return n!==""&&t.push(n),""}function ra(e,t){let n=[...e],r="",o=!1;for(let i=0;i<n.length;i++){let s=n[i];if(o)s==='"'&&(o=!1),r+=s;else if(s==='"')o=!0,r+=s;else{if(s==="%"&&n[i+1]==="%")break;s===";"?r=jr(r,t):r+=s}}jr(r,t)}function Zt(e){let t=0;for(;t<e.length&&e[t].trim()==="";)t++;if(e[t]?.trim()!=="---")return 0;for(t++;t<e.length&&e[t].trim()!=="---";)t++;return t+1}function Ae(e){let t=ut(e),n=[];for(let r of t.slice(Zt(t)))ra(r,n);return n}function _r(e){let t=ut(e),n=Zt(t);for(let r of t.slice(0,n)){let o=ve(r,":");if(o===null||o[0].trimEnd()!=="title")continue;let i=o[1].trim(),a=(i.length>1&&(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))?i.slice(1,-1):i).trim();return a===""?null:a}return null}function Ut(e){let t=new Uint8Array(e.length),n=!1;for(let r=0;r<e.length;r++)e[r]==='"'?(t[r]=1,n=!n):n&&(t[r]=1);return t}function Ln(e,t){let n=[],r="",o=!1,i=0;for(let s of e)s==='"'?o=!o:!o&&s==="("?i++:!o&&s===")"&&i>0&&i--,!o&&i===0&&t(s)?(r!==""&&n.push(r),r=""):r+=s;return r!==""&&n.push(r),n}function yt(e){let t=[...e];for(let n=0;n<t.length;n++){if(t[n]!==":")continue;let r=n;for(;r<t.length&&t[r]===":";)r++;if(r-n>=3){n=r-1;continue}return[t.slice(0,n).join(""),t.slice(n+1).join("")]}return null}function Pe(e){let t=e.split(":::");return t.length===1||t[0]===""?{id:e,classes:[]}:{id:t[0],classes:t.slice(1).filter(n=>n!=="")}}function ct(e){let t=e.trim(),n=t.search(/\s\S*$/);if(n===-1)return null;let r=o=>o.split(",").map(i=>i.trim()).filter(i=>i!=="");return[r(t.slice(0,n)),r(t.slice(n))]}function Vt(e){let[t,n]=xe(e);if(t===void 0||n==="call"||n==="callback")return null;let r=e.match(/"([^"]+)"/);return r===null?null:[t,r[1]]}var ge=e=>e.split(/\s+/).filter(t=>t!=="")[0]??"",xe=e=>e.split(/\s+/).filter(t=>t!=="");function ve(e,t){let n=e.indexOf(t);return n===-1?null:[e.slice(0,n),e.slice(n+t.length)]}var me=e=>e===""?null:e;function pe(e){let t=e[0];if(t===void 0)return null;let n=ge(t);return n===""?null:Be(n)}function wt(e){let t=e.trim(),n=t.search(/\s/);if(n===-1)return null;let r=t.slice(0,n).split(",").map(i=>i.trim()).filter(i=>i!==""),o={};for(let i of Ln(t.slice(n).trim(),s=>s===",")){let s=ve(i,":");if(s===null)continue;let a=s[0].trim(),c=s[1].trim();a!==""&&c!==""&&(o[a]=c)}return r.length===0?null:{names:r,props:o}}var Rn={kind:"class",headers:["classdiagram","classdiagram-v2"],render(e){let t=sa(e);if(t===null)return null;let n=jt(t);return n===null?null:{canvas:n,warnings:t.warnings,classDefs:t.classDefs}}},oa=[["<|--","triangle","none","solid"],["--|>","none","triangle","solid"],["<|..","triangle","none","dotted"],["..|>","none","triangle","dotted"],["*--","diamondFill","none","solid"],["--*","none","diamondFill","solid"],["o--","diamondOpen","none","solid"],["--o","none","diamondOpen","solid"],["<--","arrow","none","solid"],["-->","none","arrow","solid"],["<..","arrow","none","dotted"],["..>","none","arrow","dotted"],["--","none","none","solid"],["..","none","none","dotted"]],ia=4;function sa(e){let t=Ae(e),n=pe(t);if(n===null||!Rn.headers.includes(n))return null;let r=new We,o=c=>{let{id:l,classes:d}=Pe(c),f=r.nodeIndex(l,null,"rect");if(f!==null){r.nodes[f].sections??=[[ht(l)],[],[]];for(let u of d)r.addClass(f,u)}return f},i=null,s=[],a=[];for(let c of t.slice(1)){if(i!==null){c==="}"?i=null:i!=="skip"&&Zr(r.nodes[i],c);continue}let l=Be(ge(c));if(l==="direction"){r.dir=mt(xe(c)[1]??"");continue}if(l==="classdef"){let d=wt(c.slice(ge(c).length));if(d)for(let f of d.names)r.classDefs[f]=d.props;continue}if(!["note","callback","style","namespace","}"].includes(l)){if(l==="link"||l==="click"){let d=Vt(c.slice(ge(c).length));d&&a.push(d);continue}if(l==="cssclass"){let d=ct(c.slice(ge(c).length).replace(/"/g,""));d?s.push(d):r.drop(c);continue}if(l==="class"){let d=c.slice(5).trim(),f=d.endsWith("{"),u=f?d.slice(0,-1).trim():d,h=null,A=/^(\S+?)\[(.+)\](:::\S+)?$/.exec(u);if(A&&(u=A[1]+(A[3]??""),h=me(oe(A[2]))),!f&&/\s/.test(u)){let x=ct(u);x?s.push(x):r.drop(c)}else if(u===""||/\s/.test(u))r.drop(c),f&&(i="skip");else{let x=o(u);if(x!==null&&h!==null){let w=r.nodes[x];w.label=h;let g=w.sections?.[0];g&&(g[g.length-1]=h)}f&&(i=x??"skip")}}else if(c.startsWith("<<")){let d=ve(c.slice(2),">>"),f=d?d[1].trim():"";if(d===null||f===""||/\s/.test(f))r.drop(c);else{let u=o(f);u!==null&&Ur(r.nodes[u],d[0].trim())}}else{let d=aa(c);if(d!==null){let f=o(d.from),u=f===null?null:o(d.to);f!==null&&u!==null&&r.pushEdge({from:f,to:u,label:d.label,cardFrom:d.cardFrom,cardTo:d.cardTo,headTo:d.headTo,headFrom:d.headFrom,line:d.line})}else{let f=yt(c),u=f?f[0].trim():"",h=f?f[1].trim():"";if(f===null||u===""||/\s/.test(u)||h==="")r.drop(c);else{let A=o(u);A!==null&&Zr(r.nodes[A],h)}}}if(r.truncated!==null){r.warnings.push(`diagram truncated: ${r.truncated}`);break}}}return r.applyClasses(s),r.applyHrefs(a),r.nodes.length===0?null:r}function Ur(e,t){e.sections[0]=[`\xAB${t}\xBB`,ht(e.label)]}function Zr(e,t){let n=e.sections;if(t.startsWith("<<")){let i=ve(t.slice(2),">>");i&&Ur(e,i[0].trim());return}let r=fe(ht(t.trim())),o=r.includes("(")?n[2]:n[1];o.length<xt?o.push(r):o.length===xt&&o.push("\u2026")}function aa(e){let t=[...e],n=Ut(t),r=null;e:for(let h=0;h<t.length;h++){if(n[h])continue;let A=t.slice(h,h+ia).join("");for(let[x,w,g,y]of oa){if(!A.startsWith(x)||x.startsWith("o")&&h>0&&at(t[h-1]))continue;let b=t[h+[...x].length];if(!(x.endsWith("o")&&b!==void 0&&at(b))){r={pos:h,op:x,headFrom:w,headTo:g,line:y};break e}}}if(!r)return null;let o=t.slice(0,r.pos).join("").trim(),i=t.slice(r.pos+[...r.op].length).join("").trim(),[s,a]=ca(o),[c,l]=la(i),d=yt(c),f=(d?d[0]:c).trim(),u=d?me(fe(d[1].trim())):null;return s===""||f===""||/\s/.test(s)||/\s/.test(f)?null:{from:s,to:f,headFrom:r.headFrom,headTo:r.headTo,line:r.line,label:u,cardFrom:a===""?void 0:a,cardTo:l===""?void 0:l}}function ca(e){let t=e.trimEnd();if(t.endsWith('"')){let n=t.slice(0,-1),r=n.lastIndexOf('"');if(r!==-1)return[n.slice(0,r).trimEnd(),n.slice(r+1)]}return[t,""]}function la(e){let t=e.trimStart();if(t.startsWith('"')){let n=t.slice(1),r=n.indexOf('"');if(r!==-1)return[n.slice(r+1).trimStart(),n.slice(0,r)]}return[t,""]}var Nn={kind:"er",headers:["erdiagram"],render(e){let t=da(e);if(t===null)return null;let n=jt(t);return n===null?null:{canvas:n,warnings:t.warnings,classDefs:t.classDefs}}};function da(e){let t=Ae(e),n=pe(t);if(n===null||!Nn.headers.includes(n))return null;let r=new We,o=null;for(let i of t.slice(1)){if(o!==null){i==="}"?o=null:o!=="skip"&&ha(r.nodes[o],i);continue}let s=fa(i);if(s){let a=Wn(s.rel),c=a.length===3?zr(a[1]):null,l=c===null?null:Gn(r,a[0]),d=l===null?null:Gn(r,a[2]);if(c===null||l===null||d===null)r.drop(i);else{let f=s.label===null?"":oe(s.label);r.pushEdge({from:l,to:d,label:me(f),cardFrom:c.cardL,cardTo:c.cardR,headTo:"none",headFrom:"none",line:c.line})}}else{let a=i.endsWith("{"),c=a?i.slice(0,-1).trim():i;if(c===""||Wn(c).length!==1)r.drop(i),a&&(o="skip");else{let l=Gn(r,c);a&&(o=l??"skip")}}if(r.truncated!==null){r.warnings.push(`diagram truncated: ${r.truncated}`);break}}return r.nodes.length===0?null:r}function Gn(e,t){let n=t.startsWith('"')?-1:t.indexOf("["),r;if(n!==-1){let i=t.slice(0,n);t.endsWith("]")||e.warnings.push(`entity "${i}": alias is missing its closing \`]\``);let s=oe(t.slice(n+1).replace(/\]+$/,""));if(i===""||s==="")return null;r=e.nodeLabel(i,s)}else if(t.startsWith('"')){let i=oe(t);if(i==="")return null;r=e.nodeIndex(t,i,"rect")}else r=e.nodeIndex(t,null,"rect");if(r===null)return null;let o=e.nodes[r];return o.sections??=[[],[]],o.sections[0]=[ht(o.label)],r}function Wn(e){let t=[],n="",r=!1;for(let o of e)o==='"'?(r=!r,n+=o):!r&&/\s/.test(o)?n!==""&&(t.push(n),n=""):n+=o;return n!==""&&t.push(n),t}function fa(e){let t=ve(e,":"),n=t?t[0]:e,r=t?t[1].trim():null;return Wn(n).some(o=>zr(o)!==null)?{rel:n,label:r}:null}var ua=e=>{for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0};function zr(e){if(e.length!==6||!ua(e))return null;let t=e.slice(2,4),n=t==="--"?"solid":t===".."?"dotted":null;if(n===null)return null;let r=Vr(e.slice(0,2)),o=Vr(e.slice(4,6));return r===null||o===null?null:{cardL:r,cardR:o,line:n}}function Vr(e){switch(e){case"|o":case"o|":return"0..1";case"||":return"1";case"}o":case"o{":return"*";case"}|":case"|{":return"1..*";default:return null}}function ha(e,t){let n=e.sections[1],r=[];for(let i of xe(t)){if(i.startsWith('"'))break;r.push(i)}if(r.length===0)return;let o=fe(r.join(" "));n.length<xt?n.push(o):n.length===xt&&n.push("\u2026")}var Fn={kind:"flowchart",headers:["graph","flowchart"],render(e){let t=Aa(e);if(t===null)return null;let n=t.groups.length===0?Jt(t):_t(t);return n===null?null:{canvas:n,warnings:t.warnings,classDefs:t.classDefs}}};function Aa(e){let t=Ae(e),n=pe(t);if(n===null||!Fn.headers.includes(n))return null;let r=new We(mt(xe(t[0])[1]??"TB")),o=[],i=[],s=[];for(let a of t.slice(1)){switch(Be(ge(a))){case"subgraph":{if(r.groups.length>=At||o.length>=gt){r.truncated??=`subgraph cap (${At} groups, depth ${gt}) reached`;break}let[c,l]=ga(a.slice(8).trim());r.groups.push({id:c,label:l,parent:o.at(-1)??null}),o.push(r.groups.length-1),r.curGroup=o.at(-1)??null;continue}case"end":o.pop(),r.curGroup=o.at(-1)??null;continue;case"classdef":{let c=wt(a.slice(ge(a).length));if(c)for(let l of c.names)r.classDefs[l]=c.props;continue}case"class":{let c=ct(a.slice(ge(a).length));c&&i.push(c);continue}case"click":{let c=Vt(a.slice(ge(a).length));c&&s.push(c);continue}case"style":case"linkstyle":case"direction":continue;default:break}if(r.truncated===null&&xa(a,r),r.truncated!==null)break}return r.applyClasses(i),r.applyHrefs(s),r.truncated!==null&&r.warnings.push(`diagram truncated: ${r.truncated}`),r.nodes.length===0?null:r}function ga(e){if(e.startsWith('"')){let n=e.indexOf('"',1);if(n!==-1){let r=e.slice(1,n);return[r,fe(r)]}}let t=e.indexOf("[");if(t!==-1){let n=e.slice(0,t).trim(),r=oe(e.slice(t+1).replace(/\]+$/,"").trim());if(n!==""&&r!=="")return[n,r]}return[e,e]}function xa(e,t){let n=[...e],r=0,o=qr(n,r,t);if(!o){t.truncated===null&&t.warnings.push(`dropped, does not start with a node: "${e}"`);return}let i=o.group;for(r=o.next;r=Ct(n,r),!(r>=n.length);){let s=ya(n,r);if(!s){t.truncated===null&&t.warnings.push(`dropped, expected a link: "${n.slice(r).join("")}"`);break}r=Ct(n,s.next);let a=qr(n,r,t);if(!a){t.truncated===null&&t.warnings.push(`dropped, link has no target: "${e}"`);break}r=a.next;for(let c of i)for(let l of a.group){let d=s.left==="arrow"&&s.right!=="arrow";if(!t.pushEdge({from:d?l:c,to:d?c:l,label:s.label,headTo:d?"arrow":s.right,headFrom:d?s.right:s.left,line:s.line}))return}i=a.group}}function qr(e,t,n){let r=eo(e,t,n);if(!r)return null;let o=[r.index],i=r.next;for(;;){let s=Ct(e,i);if(e[s]!=="&")break;let a=eo(e,s+1,n);if(!a)return null;o.push(a.index),i=a.next}return{group:o,next:i}}function Ct(e,t){for(;t<e.length&&(e[t]===" "||e[t]===" ");)t++;return t}function eo(e,t,n){let r=Ct(e,t),o=r;for(;r<e.length&&(at(e[r])||e[r]==="-"&&r+1<e.length&&at(e[r+1]));)r++;if(r===o)return null;let i=e.slice(o,r).join(""),s=e[r]==="@"&&e[r+1]==="{"?ba(e,r+2):ma(e,r);s.unclosed!==void 0&&n.warnings.push(`node "${i}": label is missing its closing \`${s.unclosed}\``);let a=n.nodeIndex(i,s.label,s.shape);if(a===null)return null;let c=s.after;if(e[c]===":"&&e[c+1]===":"&&e[c+2]===":"){let l=c+3;for(;l<e.length&&(at(e[l])||e[l]==="-");)l++;for(;l>c+3&&e[l-1]==="-";)l--;l>c+3&&(n.addClass(a,e.slice(c+3,l).join("")),c=l)}return{index:a,next:c}}function ma(e,t){let n=e[t],r=e[t+1];return n==="["?r==="["?qe(e,t+2,"]]","rect"):r==="("?qe(e,t+2,")]","round"):qe(e,t+1,"]","rect"):n==="("?r==="("?qe(e,t+2,"))","round"):r==="["?qe(e,t+2,"])","round"):qe(e,t+1,")","round"):n==="{"?r==="{"?qe(e,t+2,"}}","diamond"):qe(e,t+1,"}","diamond"):n===">"?qe(e,t+1,"]","rect"):{shape:"rect",label:null,after:t}}function qe(e,t,n,r){let o=t;for(;e[o]===" "||e[o]===" ";)o++;let i=e[o]==='"',s=t,a="",c=!1;for(;s<e.length;){let l=e[s];if(i&&l==='"'){c=!c,a+=l,s++;continue}if(!c&&e.slice(s,s+n.length).join("")===n)return{shape:r,label:oe(a),after:s+n.length};a+=l,s++}return{shape:r,label:oe(a),after:e.length,unclosed:n}}var pa={rounded:"round",stadium:"round",pill:"round",terminal:"round",cyl:"round",cylinder:"round",database:"round",db:"round",circle:"round",circ:"round","sm-circ":"round","small-circle":"round","dbl-circ":"round","double-circle":"round","fr-circ":"round","framed-circle":"round",start:"round",stop:"round",event:"round",delay:"round",cloud:"round",bang:"round",diam:"diamond",diamond:"diamond",decision:"diamond",question:"diamond",hex:"diamond",hexagon:"diamond",prepare:"diamond"};function ba(e,t){let n=t,r=0,o=!1;for(;n<e.length;n++){let l=e[n];if(o)l==='"'&&(o=!1);else if(l==='"')o=!0;else if(l==="{")r++;else if(l==="}"){if(r===0)break;r--}}let i=e.slice(t,n).join(""),s=e[n]==="}",a="rect",c=null;for(let l of Ln(i,d=>d===",")){let d=ve(l,":");if(d===null)continue;let f=Be(d[0].trim());f==="shape"?a=pa[Be(d[1].trim())]??"rect":f==="label"&&(c=me(oe(d[1])))}return s?{shape:a,label:c,after:n+1}:{shape:a,label:c,after:e.length,unclosed:"}"}}var zt=e=>e==="-"||e==="."||e==="="||e==="<"||e===">";function ya(e,t){let n=Ct(e,t),r="none";(e[n]==="o"||e[n]==="x")&&(e[n+1]==="-"||e[n+1]==="."||e[n+1]==="=")&&(r=e[n]==="o"?"circle":"cross",n++);let o=n;for(;n<e.length&&zt(e[n]);)n++;if(n===o)return null;let i=e.slice(o,n).join("");r==="none"&&i.startsWith("<")&&(r="arrow");let s=to(i),a=i.includes(">")?"arrow":"none";if(a==="none"){let c=no(e,n);c&&(a=c.head,n=c.next)}if(e[n]==="|"){n++;let c=n,l=!1;for(;n<e.length&&(l||e[n]!=="|");)e[n]==='"'&&(l=!l),n++;let d=oe(e.slice(c,n).join(""));return e[n]==="|"&&n++,{left:r,right:a,line:s,label:me(d),next:n}}if(a==="none"){let c=Ct(e,n),l=c;for(;l<e.length;)if(e[l]==='"'){for(l++;l<e.length&&e[l]!=='"';)l++;l<e.length&&l++}else{if(zt(e[l])&&zt(e[l+1]))break;l++}if(l<e.length&&l>c&&e[l]!=="<"){let d=e.slice(c,l).join(""),f=l;for(;l<e.length&&zt(e[l]);)l++;let u=e.slice(f,l).join("");if(u.includes(">"))a="arrow";else{let h=no(e,l);h&&(a=h.head,l=h.next)}return s==="solid"&&(s=to(u)),{left:r,right:a,line:s,label:me(oe(d)),next:l}}}return{left:r,right:a,line:s,label:null,next:n}}function to(e){return e.includes("=")?"thick":e.includes(".")?"dotted":"solid"}function no(e,t){let n=e[t]==="o"?"circle":e[t]==="x"?"cross":null;if(n===null)return null;let r=e[t+1];return r===void 0||r===" "||r===" "||r==="|"||r==="&"||r===";"?{head:n,next:t+1}:null}var Tn={kind:"gitgraph",headers:["gitgraph","gitgraph:"],render(e){let t=wa(e);if(t===null)return null;let{branches:n,commits:r,forkAt:o,warnings:i}=t,s=n.length,a=new Map;r.forEach((w,g)=>{a.set(w.lane,g)});let c=[],l=n.map((w,g)=>r.some(y=>y.lane===g||y.mergeFrom===g)||g===0);for(let w=r.length-1;w>=0;w--){let g=r[w];c.push({kind:"commit",at:w}),g.mergeFrom!==null&&c.push({kind:"open",parent:g.lane,lane:g.mergeFrom});for(let y=n.length-1;y>0;y--)o[y]===w-1&&l[y]&&c.push({kind:"close",parent:r[w-1].lane,lane:y})}let d=w=>w*2,f=s*2,u=c.map(w=>{if(w.kind!=="commit")return null;let g=r[w.at],y=g.id===""?[]:[[g.id,"text"]];return a.get(g.lane)===w.at&&y.push([`(${n[g.lane]})`,"edgeLabel"]),g.tag!==null&&y.push([`[${g.tag}]`,"edgeLabel"]),g.mergeFrom!==null&&y.push([`\u21D0 ${n[g.mergeFrom]}`,"edgeLabel"]),y}),h=f+Math.max(1,...u.map(w=>w===null?0:w.reduce((g,[y])=>g+H(y)+1,0)-1)),A=new Me(h,c.length),x=new Set;return c.forEach((w,g)=>{if(w.kind==="commit"){let C=r[w.at];x.add(C.lane);for(let v of x)v!==C.lane&&A.addBits(d(v),g,z|_);A.set(d(C.lane),g,"\u25CF","edge");let M=f;for(let[v,I]of u[g]??[])ae(A,v,M,g,I),M+=H(v)+1;return}let{parent:y,lane:b}=w,m=w.kind==="open"&&x.has(b);w.kind==="open"&&x.add(b);for(let C of x)C!==y&&C!==b&&A.addBits(d(C),g,z|_);w.kind==="open"?A.addBits(d(y),g,z|_):A.addBits(d(y),g,_|(x.has(y)?z:0)),x.add(y),A.segH(g,d(y),d(b)),A.addBits(d(b),g,(w.kind==="open"?_:z)|(m?z:0)),w.kind==="close"&&x.delete(b)}),A.finalizeMask(),{canvas:A,warnings:i,classDefs:{}}}};function wa(e){let t=Ae(e),n=pe(t);if(n===null||!Tn.headers.includes(n))return null;let r=["main"],o=[null],i=[],s=[],a=[null],c=0,l=0,d=!1;for(let f of t.slice(1)){if(i.length>=He){d=!0;break}let u=xe(f)[0]?.toLowerCase()??"",h=f.slice(xe(f)[0]?.length??0).trim();if(u==="commit"){let A=Hn(h);a[c]=i.length,i.push({lane:c,id:A.id??`c${l++}`,tag:A.tag,mergeFrom:null})}else if(u==="branch"){let{name:A}=Yn(h),x=a[c]??o[c];if(A===void 0||r.includes(A)||x===null){s.push(`dropped, unreadable statement: "${f}"`);continue}r.push(A),o.push(x),a.push(null),c=r.length-1}else if(u==="checkout"||u==="switch"){let A=r.indexOf(Yn(h).name??"");if(A===-1){s.push(`dropped, unreadable statement: "${f}"`);continue}c=A}else if(u==="merge"){let{name:A,after:x}=Yn(h),w=r.indexOf(A??"");if(w===-1||w===c){s.push(`dropped, unreadable statement: "${f}"`);continue}let g=Hn(x);a[c]=i.length,i.push({lane:c,id:g.id??"",tag:g.tag,mergeFrom:w})}else if(u==="cherry-pick"){let A=Hn(h);a[c]=i.length,i.push({lane:c,id:A.id===null?`c${l++}`:`\u27F2 ${A.id}`,tag:A.tag,mergeFrom:null})}else s.push(`dropped, unreadable statement: "${f}"`)}return d&&s.push(`diagram truncated: commit cap (${He}) reached`),i.length===0?null:{branches:r,commits:i,forkAt:o,warnings:s}}function Yn(e){if(e.startsWith('"')){let n=e.indexOf('"',1);if(n!==-1)return{name:e.slice(1,n),after:e.slice(n+1)}}let t=xe(e)[0];return{name:t,after:t===void 0?e:e.slice(t.length)}}function Hn(e){let t={id:null,tag:null};for(let n of e.matchAll(/(id|tag)\s*:\s*"([^"]*)"/gi))t[n[1].toLowerCase()]=ue(oe(n[2]),Ie);return t}var ro={kind:"mindmap",headers:["mindmap"],render(e){let t=Ca(e);if(t===null)return null;let{roots:n,warnings:r}=t,o=[],i=(c,l,d)=>{o.push([l,c.text]),c.children.forEach((f,u)=>{let h=u===c.children.length-1;i(f,d+(h?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "),d+(h?" ":"\u2502 "))})};for(let c of n)i(c,"","");let s=Math.max(...o.map(([c,l])=>H(c)+H(l))),a=new Me(s,o.length);return o.forEach(([c,l],d)=>{ae(a,c,0,d,"edge"),ae(a,l,H(c),d,"text")}),{canvas:a,warnings:r,classDefs:{}}}};function Ca(e){let t=ut(e).slice(Zt(ut(e))),n=t.findIndex(c=>c.trim()!=="");if(n===-1||t[n].trim().toLowerCase()!=="mindmap")return null;let r=[],o=[],i=[],s=0,a=!1;for(let c of t.slice(n+1)){let l=c.split("%%")[0];if(l.trim()==="")continue;let d=l.length-l.trimStart().length,f=l.trim();if(f.startsWith("::icon")||f.startsWith(":::"))continue;let u=Ea(f);if(u===""){o.push(`dropped, unreadable statement: "${f}"`);continue}if(s>=Ye){a=!0;break}s++;let h={text:ue(u,st),children:[]};for(;i.length>0&&i[i.length-1].indent>=d;)i.pop();i.length===0?r.push(h):i[i.length-1].node.children.push(h),i.push({indent:d,node:h})}return a&&o.push(`diagram truncated: node cap (${Ye}) reached`),r.length===0?null:{roots:r,warnings:o}}var Ia=[["((","))"],["))","(("],["(-","-)"],["{{","}}"],["[","]"],["(",")"]];function Ea(e){for(let[t,n]of Ia){let r=e.indexOf(t);if(r!==-1&&e.endsWith(n)&&e.length>r+t.length+n.length-1)return oe(e.slice(r+t.length,e.length-n.length))}return oe(e)}var Qn=20,Ma=["","\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589"],oo={kind:"pie",headers:["pie"],render(e){let t=ka(e);if(t===null)return null;let{title:n,slices:r,showData:o,warnings:i}=t,s=Math.max(...r.map(A=>H(A.label))),a=r.reduce((A,x)=>A+x.value,0),c=r.map(A=>{let x=a===0?0:A.value/a,w=`${Math.round(x*100)}%`.padStart(4),g=o?` (${A.value})`:"";return{...A,share:x,suffix:w+g}}),l=s+2,d=l+Qn+1,f=d+Math.max(...c.map(A=>H(A.suffix))),u=n===null?0:1,h=new Me(f,u+c.length);return n!==null&&ae(h,n,Math.max(0,Math.floor((f-H(n))/2)),0,"title"),c.forEach((A,x)=>{let w=u+x;ae(h,A.label,0,w,"text");let g=Math.round(A.share*Qn*8),y="\u2588".repeat(Math.floor(g/8))+Ma[g%8];y===""&&A.value>0&&(y="\u258F"),ae(h,y,l,w,"edge"),ae(h,"\u2591".repeat(Qn-H(y)),l+H(y),w,"border"),ae(h,A.suffix,d,w,"edgeLabel")}),{canvas:h,warnings:i,classDefs:{}}}};function ka(e){let t=Ae(e);if(pe(t)!=="pie")return null;let n=xe(t[0]),r=n.some(l=>l.toLowerCase()==="showdata"),o=n.findIndex(l=>l.toLowerCase()==="title"),i=o===-1?null:me(n.slice(o+1).join(" ")),s=[],a=[],c=!1;for(let l of t.slice(1)){if(xe(l)[0]?.toLowerCase()==="title"){i=me(l.slice(l.toLowerCase().indexOf("title")+5).trim());continue}let f=va(l);if(f===null){a.push(`dropped, unreadable statement: "${l}"`);continue}if(s.length>=Ye){c=!0;break}s.push(f)}return c&&a.push(`diagram truncated: slice cap (${Ye}) reached`),s.length===0?null:{title:i,slices:s,showData:r,warnings:a}}function va(e){let t=[...e],n=Ut(t),r=t.findIndex((s,a)=>s===":"&&!n[a]);if(r===-1)return null;let o=ue(oe(t.slice(0,r).join("")),24),i=Number(t.slice(r+1).join("").trim());return o===""||!Number.isFinite(i)||i<0?null:{label:o,value:i}}var Sa=5;function io(e,t,n){if(t.kind==="over"){let o=se(e[t.from]+e[t.to]),i=Math.max(e[t.to]-e[t.from]+5,n+2*Ne+2);return{x:V(o,se(i)),w:i}}let r=n+2*Ne+2;return t.kind==="left"?{x:V(e[t.at],2+r-1),w:r}:{x:e[t.at]+2,w:r}}var so=e=>e===null?0:H(e);function co(e){let t=e.labels.length,n=e.labels.map(g=>ue(g,st)),r=n.map(g=>Math.max(1,H(g))+2*Ne+2),o=3,i=Array.from({length:V(t,1)},(g,y)=>Math.max(Sa,Math.ceil(r[y]/2)+Math.ceil(r[y+1]/2)+1)),s=[];for(let g of e.items)if(g.kind==="message"){let y=so(g.text);g.from!==g.to?s.push([Math.min(g.from,g.to),Math.max(g.from,g.to),Math.max(y+2,4)]):g.from+1<t&&s.push([g.from,g.from+1,5+y+2])}else if(g.kind==="note"){let y=H(g.text),b=g.anchor;if(b.kind==="over"&&b.from<b.to)s.push([b.from,b.to,V(y,1)]);else if(b.kind==="over"){let m=Math.ceil((y+4)/2)+2;b.from>0&&s.push([b.from-1,b.from,m]),b.from+1<t&&s.push([b.from,b.from+1,m])}else b.kind==="left"&&b.at>0?s.push([b.at-1,b.at,y+7]):b.kind==="right"&&b.at+1<t&&s.push([b.at,b.at+1,y+7])}s.sort((g,y)=>g[1]-g[0]-(y[1]-y[0]));for(let[g,y,b]of s){let m=0;for(let C=g;C<y;C++)m+=i[C];m<b&&(i[y-1]+=b-m)}let a=new Array(t);a[0]=se(r[0]);for(let g=1;g<t;g++)a[g]=a[g-1]+i[g-1];let c=0;for(let g of e.items)if(g.kind==="note"&&g.anchor.kind==="left"&&g.anchor.at===0){let y=H(g.text)+2*Ne+2;c=Math.max(c,V(y+1,a[0]))}if(c>0)for(let g=0;g<t;g++)a[g]+=c;let l=a[t-1]+Math.ceil(r[t-1]/2)+1;for(let g of e.items)if(g.kind==="message"&&g.from===g.to)l=Math.max(l,a[g.from]+5+so(g.text)+1);else if(g.kind==="note"){let y=io(a,g.anchor,H(g.text));l=Math.max(l,y.x+y.w+1)}else g.kind==="divider"&&(l=Math.max(l,H(g.text)+4));let d=[],f=o+1;for(let g of e.items)d.push(f),f+=Ba(g);let u=f,h=u+o;if(l*h>Bn)return null;let A=new Me(l,h);for(let g=0;g<t;g++)for(let y of[0,u])bt(A,ao(V(a[g],se(r[g])),y,r[g],o),[n[g]],"rect");e.items.forEach((g,y)=>{if(g.kind!=="note")return;let b=io(a,g.anchor,H(g.text));bt(A,ao(b.x,d[y],b.w,3),[g.text],"rect")});for(let g of a)A.junction(g,o-1,_),A.segV(g,o,u-1),A.junction(g,u,z);e.items.forEach((g,y)=>{let b=d[y];g.kind==="message"?Da(A,g,a,b):g.kind==="divider"&&$a(A,g.text,b,l)});let x=g=>{let y=e.items[g],b=y.kind==="message"&&y.from!==y.to&&y.text!==null;return d[g]+(b?1:0)},w=g=>{let y=e.items[g];return y.kind==="message"&&y.from===y.to?d[g]+2:x(g)};for(let g of e.activations){let y=g.to===null?u-1:w(g.to);for(let b=x(g.from);b<=y;b++){let m=A.idx(a[g.at],b);A.mask[m]!==0&&(A.ch[m]="\u2551")}}return A.finalizeMask(),A}function Ba(e){return e.kind==="note"?4:e.kind==="divider"?2:e.from===e.to?4:e.text!==null?3:2}var ao=(e,t,n,r)=>({x:e,y:t,w:n,h:r,cx:e+se(n),cy:t+1,rank:0});function Da(e,t,n,r){let o=t.dashed?"\u254C":"\u2500";if(t.from===t.to){let u=n[t.from];e.junction(u,r,ie),e.set(u+1,r,o,"edge"),e.set(u+2,r,o,"edge"),e.set(u+3,r,"\u256E","edge"),e.set(u+3,r+1,"\u2502","edge"),e.set(u+1,r+2,t.head==="cross"?"\xD7":"\u25C4","edge"),e.set(u+2,r+2,o,"edge"),e.set(u+3,r+2,"\u256F","edge"),t.text!==null&&nt(e,t.text,u+5,r+1,"text");return}let i=n[t.from],s=n[t.to],a=s>i,c=t.text!==null?r+1:r,l=Math.min(i,s),d=Math.max(i,s);e.junction(i,c,a?ie:Ee);for(let u=l+1;u<d;u++)e.set(u,c,o,"edge");let f=t.head==="cross"?"\xD7":a?"\u25B6":"\u25C4";if(e.set(a?s-1:s+1,c,f,"edge"),t.text!==null){let u=d-l-1,h=ue(t.text,Math.max(1,u));nt(e,h,l+1+se(V(u,H(h))),r,"text")}}function $a(e,t,n,r){for(let o=0;o<r;o++)e.set(o,n,"\u2500","edge");nt(e,` ${ue(t,V(r,4))} `,2,n,"edgeLabel")}var On={kind:"sequence",headers:["sequencediagram"],render(e){let t=Ga(e);if(t===null)return null;let n=co(t);return n===null?null:{canvas:n,warnings:t.warnings,classDefs:{}}}},La=[["-->>",!0,"arrow"],["->>",!1,"arrow"],["--x",!0,"cross"],["-x",!1,"cross"],["--)",!0,"arrow"],["-)",!1,"arrow"],["-->",!0,"arrow"],["->",!1,"arrow"]],Ra=4,Kn=class{labels=[];index=new Map;items=[];activations=[];truncated=null;warnings=[];participant(t,n){let r=this.index.get(t);return r!==void 0?(n!==null&&(this.labels[r]=n),r):this.labels.length>=Ye?(this.truncated??=`participant cap (${Ye}) reached`,null):(this.index.set(t,this.labels.length),this.labels.push(n??t),this.labels.length-1)}pushItem(t){this.items.length>=He?this.truncated??=`item cap (${He}) reached`:this.items.push(t)}drop(t){this.truncated===null&&this.warnings.push(`dropped, unreadable statement: "${t}"`)}activate(t,n){this.activations.push({at:t,from:n,to:null})}deactivate(t,n){for(let r=this.activations.length-1;r>=0;r--){let o=this.activations[r];if(o.at===t&&o.to===null){o.to=n;return}}}};function Ga(e){let t=Ae(e),n=pe(t);if(n===null||!On.headers.includes(n))return null;let r=new Kn,o=!1,i=0,s=[];for(let a of t.slice(1)){let c=ge(a),l=Be(c);if(l==="participant"||l==="actor"){let d=a.slice(c.length).trim();if(d==="")r.drop(a);else{let f=ve(d," as ");r.participant(f?f[0].trim():d,f?oe(f[1]):null)}}else if(l==="autonumber")o=!0;else if(l==="activate"||l==="deactivate"){let d=r.index.get(a.slice(c.length).trim());d!==void 0&&r.items.length>0&&(l==="activate"?r.activate(d,r.items.length-1):r.deactivate(d,r.items.length-1))}else if(!["create","destroy","title","acctitle","accdescr","links","link","properties"].includes(l))if(l==="note"){let d=Wa(a.slice(c.length).trim(),r);d?r.pushItem({kind:"note",anchor:d.anchor,text:d.text}):r.drop(a)}else if(["loop","alt","opt","par","critical","break","else","and","option"].includes(l)){let d=["else","and","option"].includes(l);d||s.push(!0),(!d||s.at(-1)===!0)&&r.pushItem({kind:"divider",text:fe(a)})}else if(l==="rect"||l==="box")s.push(!1);else if(l==="end")s.pop()===!0&&r.pushItem({kind:"divider",text:"end"});else{let d=Na(a,r);if(!d)r.drop(a);else{let f=d.text;o&&(i++,f=f===null?`${i}.`:`${i}. ${f}`);let u=r.items.length;r.pushItem({kind:"message",from:d.from,to:d.to,text:f,dashed:d.dashed,head:d.head}),r.items.length===u+1&&(d.marks.includes("+")&&r.activate(d.to,u),d.marks.includes("-")&&r.deactivate(d.from,u))}}if(r.truncated!==null){r.warnings.push(`diagram truncated: ${r.truncated}`);break}}return r.labels.length===0?null:r}function Wa(e,t){let n=Be(e),r,o;if(n.startsWith("over "))r="over",o=e.slice(5);else if(n.startsWith("left of "))r="left",o=e.slice(8);else if(n.startsWith("right of "))r="right",o=e.slice(9);else return null;let i=ve(o,":");if(!i)return null;let s=fe(i[1].trim()),a=i[0].split(",").map(d=>d.trim()).filter(d=>d!=="");if(a.length===0)return null;let c=t.participant(a[0],null);if(c===null)return null;if(r!=="over")return{text:s,anchor:{kind:r,at:c}};let l=c;if(a[1]!==void 0){let d=t.participant(a[1],null);if(d===null)return null;l=d}return{text:s,anchor:{kind:"over",from:Math.min(c,l),to:Math.max(c,l)}}}function Na(e,t){let n=[...e],r=null;e:for(let h=0;h<n.length;h++){let A=n.slice(h,h+Ra).join("");for(let[x,w,g]of La)if(A.startsWith(x)){let y=n[h+x.length];if((x.endsWith("x")||x.endsWith(")"))&&(y==="-"||y===">"))continue;r={pos:h,op:x,dashed:w,head:g};break e}}if(!r)return null;let o=n.slice(0,r.pos).join("").trim();if(o==="")return null;let i=n.slice(r.pos+[...r.op].length).join("").trimStart(),s=i.match(/^[+-]+/)?.[0]??"",a=i.slice(s.length),c=ve(a,":"),l=(c?c[0]:a).trim(),d=c?me(fe(c[1].trim())):null;if(l==="")return null;let f=t.participant(o,null);if(f===null)return null;let u=t.participant(l,null);return u===null?null:{from:f,to:u,text:d,dashed:r.dashed,head:r.head,marks:s}}var Xn={kind:"state",headers:["statediagram","statediagram-v2"],render(e){let t=Fa(e);if(t===null)return null;let n=t.groups.length===0?Jt(t):_t(t);return n===null?null:{canvas:n,warnings:t.warnings,classDefs:t.classDefs}}};function Fa(e){let t=Ae(e),n=pe(t);if(n===null||!Xn.headers.includes(n))return null;let r=new We,o=!1,i=[],s=[],a=(l,d)=>r.groups.length>=At||s.length>=gt?(r.truncated??=`subgraph cap (${At} groups, depth ${gt}) reached`,null):(r.groups.push({id:l,label:d,parent:r.curGroup}),r.groups.length-1),c=()=>{let l=s.at(-1);return l===void 0?null:l.region??l.base};for(let l of t.slice(1)){if(o){Be(l)==="end note"&&(o=!1);continue}let d=Be(ge(l));if(d==="direction")r.dir=mt(xe(l)[1]??"");else if(d==="note")l.includes(":")||(o=!0);else if(d==="state"){let f=l.slice(ge(l).length).trim(),u=f.endsWith("{"),h=u?f.slice(0,-1).trim():f;if(!u)Ha(h,r)===null&&r.drop(l);else{let A=Ya(h);A===null&&r.drop(l);let x=a(A?.id??`anon ${r.groups.length}`,A?.label??"");x!==null&&(s.push({base:x,region:null}),r.curGroup=x)}}else if(d==="}")s.pop(),r.curGroup=c();else if(d==="--"){let f=s.at(-1);if(f!==void 0){if(f.region===null){let h=a(`region ${r.groups.length}`,"");h!==null&&(r.nodeGroup.forEach((A,x)=>{A===f.base&&(r.nodeGroup[x]=h)}),r.groups.forEach((A,x)=>{x!==h&&A.parent===f.base&&(A.parent=h)}))}r.curGroup=f.base;let u=a(`region ${r.groups.length}`,"");f.region=u,r.curGroup=u??f.base}}else if(d==="classdef"){let f=wt(l.slice(ge(l).length));if(f)for(let u of f.names)r.classDefs[u]=f.props}else if(d==="class"){let f=ct(l.slice(ge(l).length));f&&i.push(f)}else["hide","scale"].includes(d)||(l.includes("-->")?Ta(l,r)===null&&r.drop(l):Qa(l,r)===null&&r.drop(l));if(r.truncated!==null){r.warnings.push(`diagram truncated: ${r.truncated}`);break}}return r.applyClasses(i),r.nodes.length===0?null:r}function Ya(e){if(e.startsWith('"')){let n=e.indexOf('"',1);if(n===-1)return null;let r=fe(e.slice(1,n)),o=e.slice(n+1).trim(),i=Pe(o.startsWith("as")?o.slice(2).trim():r).id;return i===""?null:{id:i,label:r}}let t=Pe(e.split("<<")[0].trim()).id;return t===""||/\s/.test(t)?null:{id:t,label:t}}function Ha(e,t){if(e==="")return!0;if(e.startsWith('"')){let l=e.indexOf('"',1);if(l===-1)return null;let d=e.slice(1,l),f=e.slice(l+1).trim(),{id:u,classes:h}=Pe(f.startsWith("as")?f.slice(2).trim():d),A=t.nodeLabel(u,fe(d));if(A===null)return null;for(let x of h)t.addClass(A,x);return!0}let n="round",r=e,o=!1,i=e.indexOf("<<");i!==-1&&(e.slice(i+2).replace(/>>$/,"").trim()==="choice"&&(n="diamond"),r=e.slice(0,i).trim(),o=!0);let{id:s,classes:a}=Pe(r);if(s===""||/\s/.test(s))return null;let c=t.nodeIndex(s,o?s:null,n);if(c===null)return null;for(let l of a)t.addClass(c,l);return!0}function Ta(e,t){let n=e,r=null;for(;;){let o=ve(n,"-->");if(!o)break;let[i,s]=o,a=Pe(i.trimEnd().replace(/-+$/,"").trim()),c;if(r!==null){if(a.id!=="")return null;c=r}else{if(a.id==="")return null;let g=lo(t,a.id,!0);if(g===null)return null;for(let y of a.classes)t.addClass(g,y);c=g}let l=s.indexOf("-->"),d=yt(s),f=d!==null&&(l===-1||d[0].length<l),u=f?d[0]:l===-1?s:s.slice(0,l),h=f?me(fe(d[1].trim())):null,A=f||l===-1?"":s.slice(l),x=Pe(u.trimStart().replace(/^>+/,"").trimEnd().replace(/-+$/,"").trim());if(x.id==="")return null;let w=lo(t,x.id,!1);if(w===null)return null;for(let g of x.classes)t.addClass(w,g);if(!t.pushEdge({from:c,to:w,label:h,headTo:"arrow",headFrom:"none",line:"solid"}))return!0;r=w,n=A}return!0}function lo(e,t,n){if(t==="[*]"){let r=e.curGroup===null?"":` g${e.curGroup}`;return e.nodeIndex(`[*]${n?"start":"end"}${r}`,"\u25CF","round")}return e.nodeIndex(t,null,"round")}function Qa(e,t){let n=yt(e),{id:r,classes:o}=Pe((n?n[0]:e).trim()),i;if(n){let s=n[1].trim();if(r===""||/\s/.test(r)||s==="")return null;let a=t.index.get(r),c=a===void 0?null:t.nodes[a].label,l=fe(s);i=t.nodeLabel(r,c!==null&&c!==r?`${c} ${l}`:l)}else{if(r===""||/\s/.test(r))return null;i=t.nodeIndex(r,null,"round")}if(i===null)return null;for(let s of o)t.addClass(i,s);return!0}var uo={kind:"timeline",headers:["timeline"],render(e){let t=Ka(e);if(t===null)return null;let{title:n,rows:r,warnings:o}=t,i=Math.max(...r.map(l=>l.section?0:H(l.period))),s=n===null?0:1,a=Math.max(n===null?0:H(n)+6,...r.map(l=>l.section?H(l.event):i+3+H(l.event))),c=new Me(a,s+r.length);if(n!==null){let l=` ${n} `,d=Math.max(0,Math.floor((a-H(l)-4)/2));ae(c,"\u2500\u2500",d,0,"edge"),ae(c,l,d+2,0,"title"),ae(c,"\u2500\u2500",d+2+H(l),0,"edge")}return r.forEach((l,d)=>{let f=s+d;if(l.section){ae(c,l.event,0,f,"title");return}ae(c,l.period,0,f,"text"),l.event!==""&&(ae(c,"\u2500",i+1,f,"edge"),ae(c,l.event,i+3,f,"edgeLabel"))}),{canvas:c,warnings:o,classDefs:{}}}};function Ka(e){let t=Ae(e);if(pe(t)!=="timeline")return null;let n=null,r=[],o=[],i=!1,s=!1;for(let a of t.slice(1)){if(r.length>=He){i=!0;break}let c=xe(a)[0]?.toLowerCase();if(c==="title"){n=me(a.slice(a.toLowerCase().indexOf("title")+5).trim());continue}if(c==="section"){let f=a.slice(a.toLowerCase().indexOf("section")+7).trim();r.push({period:"",event:fo(f),section:!0}),s=!1;continue}let l=a.split(":").map(f=>fo(f)),d=l.shift()??"";if(d===""&&l.length>0&&s){for(let f of l)r.push({period:"",event:f});continue}if(d!==""&&l.length===0){r.push({period:d,event:""}),s=!0;continue}if(d===""||l.some(f=>f==="")){o.push(`dropped, unreadable statement: "${a}"`);continue}l.forEach((f,u)=>{r.push({period:u===0?d:"",event:f})}),s=!0}return i&&o.push(`diagram truncated: event cap (${He}) reached`),r.length===0?null:{title:n,rows:r,warnings:o}}var fo=e=>ue(fe(e.trim()),Ie);var Oa=[Fn,Xn,Rn,Nn,On,oo,ro,uo,Tn];function ho(e){let t=pe(Ae(e));return t===null?null:Oa.find(n=>n.headers.includes(t))??null}function Ao(e){if(e=Fr(e),e.trim()==="")return null;let t=ho(e)?.render(e)??null;if(t===null)return null;let n=t.canvas.toLines(),r=_r(e);if(r!==null){let o=H(r);n.width=Math.max(n.width,o);let i=" ".repeat(Math.floor((n.width-o)/2));n.plain.unshift(i+r,""),n.styled.unshift(i===""?[{text:r,role:"title"}]:[{text:i,role:"none"},{text:r,role:"title"}],[])}return{...n,classDefs:t.classDefs,warnings:t.warnings}}var qt={bg:"#FFFFFF",fg:"#27272A"},Te={text:100,textSec:60,textMuted:40,textFaint:25,line:50,arrow:85,nodeFill:3,nodeStroke:20,groupHeader:5,innerStroke:12,keyBadge:10};function Je(e,t){let n=[`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@400;500;600;700&display=swap');`,...t?["@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');"]:[]],r=`
3 /* Derived from --bg and --fg (overridable via --line, --accent, etc.) */
4 --_text: var(--fg);
5 --_text-sec: var(--muted, color-mix(in srgb, var(--fg) ${Te.textSec}%, var(--bg)));
6 --_text-muted: var(--muted, color-mix(in srgb, var(--fg) ${Te.textMuted}%, var(--bg)));
7 --_text-faint: color-mix(in srgb, var(--fg) ${Te.textFaint}%, var(--bg));
8 --_line: var(--line, color-mix(in srgb, var(--fg) ${Te.line}%, var(--bg)));
9 --_arrow: var(--accent, color-mix(in srgb, var(--fg) ${Te.arrow}%, var(--bg)));
10 --_node-fill: var(--surface, color-mix(in srgb, var(--fg) ${Te.nodeFill}%, var(--bg)));
11 --_node-stroke: var(--border, color-mix(in srgb, var(--fg) ${Te.nodeStroke}%, var(--bg)));
12 --_group-fill: var(--bg);
13 --_group-hdr: color-mix(in srgb, var(--fg) ${Te.groupHeader}%, var(--bg));
14 --_inner-stroke: color-mix(in srgb, var(--fg) ${Te.innerStroke}%, var(--bg));
15 --_key-badge: color-mix(in srgb, var(--fg) ${Te.keyBadge}%, var(--bg));`;return["<style>",` ${n.join(`
16 `)}`,` text { font-family: '${e}', system-ui, sans-serif; }`,...t?[" .mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace; }"]:[],` svg {${r}`," }","</style>"].join(`
17`)}function je(e,t,n,r){let o=[`--bg:${n.bg}`,`--fg:${n.fg}`,n.line?`--line:${n.line}`:"",n.accent?`--accent:${n.accent}`:"",n.muted?`--muted:${n.muted}`:"",n.surface?`--surface:${n.surface}`:"",n.border?`--border:${n.border}`:""].filter(Boolean).join(";");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e} ${t}" width="${e}" height="${t}" style="${o}${r?"":";background:var(--bg)"}">`}var Xa=new Set(["i","l","t","f","j","I","1","!","|",".",",",":",";","'"]),Pa=new Set(["W","M","w","m","@","%"]),Ja=new Set(["W","M"]),ja=new Set(["(",")","[","]","{","}","/","\\","-",'"',"`"]);function _a(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function Za(e){return e>=4352&&e<=4447||e>=11904&&e<=12031||e>=12032&&e<=12255||e>=12288&&e<=12351||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=12544&&e<=12591||e>=12592&&e<=12687||e>=12688&&e<=12799||e>=12800&&e<=13311||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072}var Ua=/\p{Emoji_Presentation}|\p{Extended_Pictographic}/u;function Va(e){return Ua.test(e)}function za(e){let t=e.codePointAt(0);return t===void 0||_a(t)?0:Za(t)||Va(e)?2:e===" "?.3:Ja.has(e)?1.5:Pa.has(e)?1.2:Xa.has(e)?.4:ja.has(e)?.5:e==="r"?.8:t>=65&&t<=90?1.2:(t>=48&&t<=57,1)}function Pn(e,t,n){let r=n>=600?.6:n>=500?.57:.54,o=0;for(let s of e)o+=za(s);let i=t*.15;return o*t*r+i}var Jn=1.3;function Le(e,t,n){let r=e.split(`
18`),o=t*Jn,i=0;for(let s of r){let a=s.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi,""),c=Pn(a,t,n);c>i&&(i=c)}return{width:i,height:r.length*o,lines:r,lineHeight:o}}function q(e){return(e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e).replace(/<br\s*\/?>/gi,`
19`).replace(/\\n/g,`
20`).replace(/<\/?(?:sub|sup|small|mark)\s*>/gi,"").replace(/\*\*(.+?)\*\*/g,"<b>$1</b>").replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g,"<i>$1</i>").replace(/~~(.+?)~~/g,"<s>$1</s>")}function rt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var go=/<(\/)?(?:(b|strong)|(i|em)|(u)|(s|del))\s*>/gi;function qa(e){let t=[],n=!1,r=!1,o=!1,i=!1,s=0;go.lastIndex=0;let a;for(;(a=go.exec(e))!==null;){a.index>s&&t.push({text:e.slice(s,a.index),bold:n,italic:r,underline:o,strikethrough:i}),s=a.index+a[0].length;let c=!!a[1];a[2]?n=!c:a[3]?r=!c:a[4]?o=!c:a[5]&&(i=!c)}return s<e.length&&t.push({text:e.slice(s),bold:n,italic:r,underline:o,strikethrough:i}),t}var ec=/<\/?(?:b|strong|i|em|u|s|del)\s*>/i;function xo(e){if(!ec.test(e))return rt(e);let t=qa(e);return t.length===0?"":t.every(r=>!r.bold&&!r.italic&&!r.underline&&!r.strikethrough)?t.map(r=>rt(r.text)).join(""):t.map(r=>{let o=rt(r.text);if(!r.bold&&!r.italic&&!r.underline&&!r.strikethrough)return o;let i=[];r.bold&&i.push('font-weight="bold"'),r.italic&&i.push('font-style="italic"');let s=[];return r.underline&&s.push("underline"),r.strikethrough&&s.push("line-through"),s.length&&i.push(`text-decoration="${s.join(" ")}"`),`<tspan ${i.join(" ")}>${o}</tspan>`}).join("")}function de(e,t,n,r,o,i=.35){let s=e.split(`
21`);if(s.length===1){let d=r*i;return`<text x="${t}" y="${n}" ${o} dy="${d}">${xo(e)}</text>`}let a=r*Jn,c=-((s.length-1)/2)*a+r*i,l=s.map((d,f)=>`<tspan x="${t}" dy="${f===0?c:a}">${xo(d)}</tspan>`).join("");return`<text x="${t}" y="${n}" ${o}>${l}</text>`}function mo(e,t,n,r,o,i,s,a,c){let l=r+s*2,d=o+s*2,f=`<rect x="${t-l/2}" y="${n-d/2}" width="${l}" height="${d}" ${c} />`,u=de(e,t,n,i,a);return`${f}
22${u}`}function tn(e){let t=e.split(`
23`).map(r=>r.trim()).filter(r=>r.length>0&&!r.startsWith("%%"));if(t.length===0)throw new Error("Empty mermaid diagram");let n=t[0];return/^stateDiagram(-v2)?\s*$/i.test(n)?nc(t):tc(t)}function tc(e){let t=e[0].match(/^(?:graph|flowchart)\s+(TD|TB|LR|BT|RL)\s*$/i);if(!t)throw new Error(`Invalid mermaid header: "${e[0]}". Expected "graph TD", "flowchart LR", "stateDiagram-v2", etc.`);let r={direction:t[1].toUpperCase(),nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map},o=[];for(let i=1;i<e.length;i++){let s=e[i],a=s.match(/^classDef\s+(\w+)\s+(.+)$/);if(a){let h=a[1],A=a[2],x=en(A);r.classDefs.set(h,x);continue}let c=s.match(/^class\s+([\w,-]+)\s+(\w+)$/);if(c){let h=c[1].split(",").map(x=>x.trim()),A=c[2];for(let x of h)r.classAssignments.set(x,A);continue}let l=s.match(/^style\s+([\w,-]+)\s+(.+)$/);if(l){let h=l[1].split(",").map(x=>x.trim()),A=en(l[2]);for(let x of h)r.nodeStyles.set(x,{...r.nodeStyles.get(x),...A});continue}let d=s.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);if(d){let h=d[1].trim(),A=en(d[2]);if(h==="default")r.linkStyles.set("default",{...r.linkStyles.get("default"),...A});else{let x=h.split(",").map(w=>parseInt(w.trim(),10));for(let w of x)isNaN(w)||r.linkStyles.set(w,{...r.linkStyles.get(w),...A})}continue}let f=s.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(f&&o.length>0){o[o.length-1].direction=f[1].toUpperCase();continue}let u=s.match(/^subgraph\s+(.+)$/);if(u){let h=u[1].trim(),A=h.match(/^([\w-]+)\s*\[(.+)\]$/),x,w;A?(x=A[1],w=q(A[2])):(w=q(h),x=h.replace(/\s+/g,"_").replace(/[^\w]/g,""));let g={id:x,label:w,nodeIds:[],children:[]};o.push(g);continue}if(s==="end"){let h=o.pop();h&&(o.length>0?o[o.length-1].children.push(h):r.subgraphs.push(h));continue}cc(s,r,o)}return r}function nc(e){let t={direction:"TD",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map},n=[],r=new Set,o=0,i=0;for(let s=1;s<e.length;s++){let a=e[s],c=a.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(c){n.length>0?n[n.length-1].direction=c[1].toUpperCase():t.direction=c[1].toUpperCase();continue}let l=a.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);if(l){let A=l[1].trim(),x=en(l[2]);if(A==="default")t.linkStyles.set("default",{...t.linkStyles.get("default"),...x});else{let w=A.split(",").map(g=>parseInt(g.trim(),10));for(let g of w)isNaN(g)||t.linkStyles.set(g,{...t.linkStyles.get(g),...x})}continue}let d=a.match(/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}]+)\s*\{$/u);if(d){let A=d[1]??d[2],x=d[2],w={id:x,label:A,nodeIds:[],children:[]};n.push(w),r.add(x),t.nodes.delete(x);continue}if(a==="}"){let A=n.pop();A&&(n.length>0?n[n.length-1].children.push(A):t.subgraphs.push(A));continue}let f=a.match(/^state\s+"([^"]+)"\s+as\s+([\w\p{L}]+)\s*$/u);if(f){let A=q(f[1]),x=f[2];Nt(t,n,{id:x,label:A,shape:"rounded"});continue}let u=a.match(/^(\[\*\]|[\w\p{L}-]+)\s*(-->)\s*(\[\*\]|[\w\p{L}-]+)(?:\s*:\s*(.+))?$/u);if(u){let A=u[1],x=u[3],w=u[4]?.trim(),g=w?q(w):void 0;A==="[*]"?(o++,A=`_start${o>1?o:""}`,Nt(t,n,{id:A,label:"",shape:"state-start"})):r.has(A)||po(t,n,A),x==="[*]"?(i++,x=`_end${i>1?i:""}`,Nt(t,n,{id:x,label:"",shape:"state-end"})):r.has(x)||po(t,n,x),t.edges.push({source:A,target:x,label:g,style:"solid",hasArrowStart:!1,hasArrowEnd:!0});continue}let h=a.match(/^([\w\p{L}-]+)\s*:\s*(.+)$/u);if(h){let A=h[1],x=q(h[2].trim());Nt(t,n,{id:A,label:x,shape:"rounded"});continue}}return t}function Nt(e,t,n){if(!e.nodes.has(n.id)&&e.nodes.set(n.id,n),t.length>0){let o=t[t.length-1];o.nodeIds.includes(n.id)||o.nodeIds.push(n.id)}}function po(e,t,n){if(!e.nodes.has(n))Nt(e,t,{id:n,label:n,shape:"rounded"});else if(t.length>0){let r=t[t.length-1];r.nodeIds.includes(n)||r.nodeIds.push(n)}}function en(e){let t=e.replace(/;\s*$/,""),n={};for(let r of t.split(",")){let o=r.indexOf(":");if(o>0){let i=r.slice(0,o).trim(),s=r.slice(o+1).trim();i&&s&&(n[i]=s)}}return n}var rc=/^(<)?(-->|-.->|==>|---|-\.-|===)(?:\|([^|]*)\|)?/,oc=/^(<)?(--|-\.|==)\s+(.+?)\s+(-->|---|\.\->|-\.\-|==>|===)/,ic=[{regex:/^([\w-]+)\(\(\((.+?)\)\)\)/,shape:"doublecircle"},{regex:/^([\w-]+)\(\[(.+?)\]\)/,shape:"stadium"},{regex:/^([\w-]+)\(\((.+?)\)\)/,shape:"circle"},{regex:/^([\w-]+)\[\[(.+?)\]\]/,shape:"subroutine"},{regex:/^([\w-]+)\[\((.+?)\)\]/,shape:"cylinder"},{regex:/^([\w-]+)\[\/(.+?)\\\]/,shape:"trapezoid"},{regex:/^([\w-]+)\[\\(.+?)\/\]/,shape:"trapezoid-alt"},{regex:/^([\w-]+)>(.+?)\]/,shape:"asymmetric"},{regex:/^([\w-]+)\{\{(.+?)\}\}/,shape:"hexagon"},{regex:/^([\w-]+)\[(.+?)\]/,shape:"rectangle"},{regex:/^([\w-]+)\((.+?)\)/,shape:"rounded"},{regex:/^([\w-]+)\{(.+?)\}/,shape:"diamond"}],sc=/^([\w-]+)/,ac=/^:::([\w][\w-]*)/;function cc(e,t,n){let r=e.trim(),o=bo(r,t,n);if(!o||o.ids.length===0)return;r=o.remaining.trim();let i=o.ids;for(;r.length>0;){let s,a,c,l,d=r.match(rc);if(d){s=!!d[1];let u=d[2],h=d[3]?.trim();l=h?q(h):void 0,r=r.slice(d[0].length).trim(),a=dc(u),c=u.endsWith(">")}else{let u=r.match(oc);if(!u)break;s=!!u[1];let h=u[3].trim();l=h?q(h):void 0;let A=u[2],x=u[4];r=r.slice(u[0].length).trim(),a=fc(A,x),c=x.endsWith(">")}let f=bo(r,t,n);if(!f||f.ids.length===0)break;r=f.remaining.trim();for(let u of i)for(let h of f.ids)t.edges.push({source:u,target:h,label:l,style:a,hasArrowStart:s,hasArrowEnd:c});i=f.ids}}function bo(e,t,n){let r=yo(e,t,n);if(!r)return null;let o=[r.id],i=r.remaining.trim();for(;i.startsWith("&");){i=i.slice(1).trim();let s=yo(i,t,n);if(!s)break;o.push(s.id),i=s.remaining.trim()}return{ids:o,remaining:i}}function yo(e,t,n){let r=null,o=e;for(let{regex:s,shape:a}of ic){let c=e.match(s);if(c){r=c[1];let l=q(c[2]);wo(t,n,{id:r,label:l,shape:a}),o=e.slice(c[0].length);break}}if(r===null){let s=e.match(sc);s&&(r=s[1],t.nodes.has(r)||wo(t,n,{id:r,label:r,shape:"rectangle"}),o=e.slice(s[0].length))}if(r===null)return null;let i=o.match(ac);return i&&(t.classAssignments.set(r,i[1]),o=o.slice(i[0].length)),{id:r,remaining:o}}function wo(e,t,n){!e.nodes.has(n.id)&&e.nodes.set(n.id,n),lc(t,n.id)}function lc(e,t){if(e.length>0){let n=e[e.length-1];n.nodeIds.includes(t)||n.nodeIds.push(t)}}function dc(e){return e==="-.->"||e==="-.-"?"dotted":e==="==>"||e==="==="?"thick":"solid"}function fc(e,t){return e==="-."||t===".->"||t==="-.-"?"dotted":e==="=="||t==="==>"||t==="==="?"thick":"solid"}var uc="\x1B[",CA=`${uc}0m`;function Zn(e){let t={actors:[],messages:[],blocks:[],notes:[]},n=new Set,r=[];for(let o=1;o<e.length;o++){let i=e[o],s=i.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(s){let u=s[1],h=s[2],A=s[3]?.trim()??h,x=q(A);n.has(h)||(n.add(h),t.actors.push({id:h,label:x,type:u}));continue}let a=i.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);if(a){let u=a[1].toLowerCase(),h=a[2].trim(),A=q(a[3].trim()),x=h.split(",").map(g=>g.trim());for(let g of x)Yt(t,n,g);let w="over";u==="left of"?w="left":u==="right of"&&(w="right"),t.notes.push({actorIds:x,text:A,position:w,afterIndex:t.messages.length-1});continue}let c=i.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);if(c){let u=c[1],h=c[2]?.trim()??"",A=q(h);r.push({type:u,label:A,startIndex:t.messages.length,dividers:[]});continue}let l=i.match(/^(else|and)\s*(.*)$/);if(l&&r.length>0){let u=l[2]?.trim()??"",h=q(u);r[r.length-1].dividers.push({index:t.messages.length,label:h});continue}if(i==="end"&&r.length>0){let u=r.pop();t.blocks.push({type:u.type,label:u.label,startIndex:u.startIndex,endIndex:Math.max(t.messages.length-1,u.startIndex),dividers:u.dividers});continue}let d=i.match(/^(\S+?)\s*(--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(\S+?)\s*:\s*(.+)$/);if(d){let u=d[1],h=d[2],A=d[3],x=d[4],w=q(d[5].trim());Yt(t,n,u),Yt(t,n,x);let g=h.startsWith("--")?"dashed":"solid",y=h.includes(">>")||h.includes("x")?"filled":"open",b={from:u,to:x,label:w,lineStyle:g,arrowHead:y};A==="+"&&(b.activate=!0),A==="-"&&(b.deactivate=!0),t.messages.push(b);continue}let f=i.match(/^(\S+?)\s*(->>|-->>|-\)|--\)|-x|--x|->|-->)\s*([+-]?)(\S+?)\s*:\s*(.+)$/);if(f){let u=f[1],h=f[2],A=f[3],x=f[4],w=q(f[5].trim());Yt(t,n,u),Yt(t,n,x);let g=h.startsWith("--")?"dashed":"solid",y=h.includes(">>")||h.includes("x")?"filled":"open",b={from:u,to:x,label:w,lineStyle:g,arrowHead:y};A==="+"&&(b.activate=!0),A==="-"&&(b.deactivate=!0),t.messages.push(b);continue}}return t}function Yt(e,t,n){t.has(n)||(t.add(n),e.actors.push({id:n,label:n,type:"participant"}))}function Vn(e){let t={classes:[],relationships:[],namespaces:[]},n=new Map,r=null,o=null,i=0;for(let s=1;s<e.length;s++){let a=e[s];if(o&&i>0){if(a==="}"){i--,i===0&&(o=null);continue}let A=a.match(/^<<(\w+)>>$/);if(A){o.annotation=A[1];continue}let x=Do(a);x&&(x.isMethod?o.methods.push(x.member):o.attributes.push(x.member));continue}let c=a.match(/^namespace\s+(\S+)\s*\{$/);if(c){r={name:c[1],classIds:[]};continue}if(a==="}"&&r){t.namespaces.push(r),r=null;continue}let l=a.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);if(l){let A=l[1],x=l[2],w=Mt(n,A);x&&(w.label=`${A}<${x}>`),o=w,i=1,r&&r.classIds.push(A);continue}let d=a.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);if(d){let A=d[1],x=d[2],w=Mt(n,A);x&&(w.label=`${A}<${x}>`),r&&r.classIds.push(A);continue}let f=a.match(/^class\s+(\S+?)\s*\{\s*<<(\w+)>>\s*\}$/);if(f){let A=Mt(n,f[1]);A.annotation=f[2];continue}let u=a.match(/^(\S+?)\s*:\s*(.+)$/);if(u){let A=u[2];if(!A.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)){let x=Mt(n,u[1]),w=Do(A);w&&(w.isMethod?x.methods.push(w.member):x.attributes.push(w.member));continue}}let h=bc(a);if(h){Mt(n,h.from),Mt(n,h.to),t.relationships.push(h);continue}}return t.classes=[...n.values()],t}function Mt(e,t){let n=e.get(t);return n||(n={id:t,label:t,attributes:[],methods:[]},e.set(t,n)),n}function Do(e){let t=e.trim().replace(/;$/,"");if(!t)return null;let n="",r=t;/^[+\-#~]/.test(r)&&(n=r[0],r=r.slice(1).trim());let o=r.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);if(o){let d=o[1].trim(),f=o[2]?.trim()||void 0,u=o[3]?.trim(),h=d.endsWith("$")||r.includes("$"),A=d.endsWith("*")||r.includes("*");return{member:{visibility:n,name:d.replace(/[$*]$/,""),type:u||void 0,isStatic:h,isAbstract:A,isMethod:!0,params:f},isMethod:!0}}let i=r.split(/\s+/),s,a;i.length>=2?(a=i[0],s=i.slice(1).join(" ")):s=i[0]??r;let c=s.endsWith("$"),l=s.endsWith("*");return{member:{visibility:n,name:s.replace(/[$*]$/,""),type:a||void 0,isStatic:c,isAbstract:l,isMethod:!1},isMethod:!1}}function bc(e){let t=e.match(/^(\S+?)\s+(?:"([^"]*?)"\s+)?(<\|--|<\|\.\.|\*--|o--|-->|--\*|--o|--\|>|\.\.>|\.\.\|>|<--|<\.\.?|--)\s+(?:"([^"]*?)"\s+)?(\S+?)(?:\s*:\s*(.+))?$/);if(!t)return null;let n=t[1],r=t[2],o=r?q(r):void 0,i=t[3].trim(),s=t[4],a=s?q(s):void 0,c=t[5],l=t[6]?.trim(),d=l?q(l):void 0,f=yc(i);return f?{from:n,to:c,type:f.type,markerAt:f.markerAt,label:d,fromCardinality:o,toCardinality:a}:null}function yc(e){switch(e.trim()){case"<|--":return{type:"inheritance",markerAt:"from"};case"--|>":return{type:"inheritance",markerAt:"to"};case"<|..":return{type:"realization",markerAt:"from"};case"..|>":return{type:"realization",markerAt:"to"};case"*--":return{type:"composition",markerAt:"from"};case"--*":return{type:"composition",markerAt:"to"};case"o--":return{type:"aggregation",markerAt:"from"};case"--o":return{type:"aggregation",markerAt:"to"};case"-->":return{type:"association",markerAt:"to"};case"<--":return{type:"association",markerAt:"from"};case"..>":return{type:"dependency",markerAt:"to"};case"<..":return{type:"dependency",markerAt:"from"};case"--":return{type:"association",markerAt:"to"};default:return null}}function qn(e){let t={entities:[],relationships:[]},n=new Map,r=null;for(let o=1;o<e.length;o++){let i=e[o];if(r){if(i==="}"){r=null;continue}let c=Cc(i);c&&r.attributes.push(c);continue}let s=i.match(/^(\S+)\s*\{$/);if(s){let c=s[1];r=zn(n,c);continue}let a=Ic(i);if(a){zn(n,a.entity1),zn(n,a.entity2),t.relationships.push(a);continue}}return t.entities=[...n.values()],t}function zn(e,t){let n=e.get(t);return n||(n={id:t,label:t,attributes:[]},e.set(t,n)),n}function Cc(e){let t=e.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);if(!t)return null;let n=t[1],r=t[2],o=t[3]?.trim()??"",i=[],s,a=o.match(/"([^"]*)"/);a&&(s=q(a[1]));let c=o.replace(/"[^"]*"/,"").trim();for(let l of c.split(/\s+/)){let d=l.toUpperCase();(d==="PK"||d==="FK"||d==="UK")&&i.push(d)}return{type:n,name:r,keys:i,comment:s}}function Ic(e){let t=e.match(/^(\S+)\s+([|o}{]+(?:--|\.\.)[|o}{]+)\s+(\S+)\s*:\s*(.+)$/);if(!t)return null;let n=t[1],r=t[2],o=t[3],i=t[4].trim().replace(/^["']|["']$/g,""),s=q(i),a=r.match(/^([|o}{]+)(--|\.\.?)([|o}{]+)$/);if(!a)return null;let c=a[1],l=a[2],d=a[3],f=$o(c),u=$o(d),h=l==="--";return!f||!u?null:{entity1:n,entity2:o,cardinality1:f,cardinality2:u,label:s,identifying:h}}function $o(e){let t=e.split("").sort().join("");return t==="||"?"one":t==="o|"?"zero-one":t==="|}"||t==="{|"?"many":t==="{o"||t==="o{"?"zero-many":null}function er(e){let t={},n={},r=[],o,i=!1;for(let s of e){if(/^xychart(-beta)?\b/i.test(s)){/\bhorizontal\b/i.test(s)&&(i=!0);continue}let a=s.match(/^title\s+"([^"]+)"/);if(a){o=a[1];continue}let c=s.match(/^x-axis\s+(?:"([^"]*)"\s*)?\[([^\]]+)\]/);if(c){c[1]&&(t.title=c[1]),t.categories=c[2].split(",").map(A=>A.trim());continue}let l=s.match(/^x-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(l){l[1]&&(t.title=l[1]),t.range={min:parseFloat(l[2]),max:parseFloat(l[3])};continue}let d=s.match(/^y-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(d){d[1]&&(n.title=d[1]),n.range={min:parseFloat(d[2]),max:parseFloat(d[3])};continue}let f=s.match(/^y-axis\s+"([^"]+)"\s*$/);if(f){n.title=f[1];continue}let u=s.match(/^bar\s+\[([^\]]+)\]/);if(u){r.push({type:"bar",data:Lo(u[1])});continue}let h=s.match(/^line\s+\[([^\]]+)\]/);if(h){r.push({type:"line",data:Lo(h[1])});continue}}if(!n.range&&r.length>0){let s=r.flatMap(d=>d.data),a=Math.min(...s),c=Math.max(...s),l=c-a||1;a=a-l*.1,c=c+l*.1,a>0&&a<l*.5&&(a=0),n.range={min:a,max:c}}return n.range||(n.range={min:0,max:100}),{title:o,horizontal:i,xAxis:t,yAxis:n,series:r}}function Lo(e){return e.split(",").map(t=>parseFloat(t.trim()))}var Ht="#3b82f6";function Go(e){let t=e.replace("#",""),n=parseInt(t.substring(0,2),16)/255,r=parseInt(t.substring(2,4),16)/255,o=parseInt(t.substring(4,6),16)/255,i=Math.max(n,r,o),s=Math.min(n,r,o),a=(i+s)/2;if(i===s)return[0,0,a*100];let c=i-s,l=a>.5?c/(2-i-s):c/(i+s),d;return i===n?d=((r-o)/c+(r<o?6:0))/6:i===r?d=((o-n)/c+2)/6:d=((n-r)/c+4)/6,[d*360,l*100,a*100]}function Ec(e,t,n){let r=t/100,o=n/100,i=(1-Math.abs(2*o-1))*r,s=i*(1-Math.abs(e/60%2-1)),a=o-i/2,c,l,d;e<60?(c=i,l=s,d=0):e<120?(c=s,l=i,d=0):e<180?(c=0,l=i,d=s):e<240?(c=0,l=s,d=i):e<300?(c=s,l=0,d=i):(c=i,l=0,d=s);let f=u=>Math.round((u+a)*255).toString(16).padStart(2,"0");return`#${f(c)}${f(l)}${f(d)}`}function Ro(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function Mc(e){return Go(e)[2]<50}function tr(e,t,n){if(e===0)return t;let r=Ro(t)?t:Ht,o=n&&Ro(n)?n:void 0,[i,s]=Go(r),a=Math.max(55,Math.min(85,s)),c=Math.ceil(e/2),l=e%2===1,d=o&&Mc(o)?!l:l,f=d?Math.max(25,48-c*13):Math.min(78,55+c*11),u=(d?-8:12)*c,h=((i+u)%360+360)%360;return Ec(h,a,f)}var nr,kc=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),rr=(nr=String.fromCodePoint)!==null&&nr!==void 0?nr:(e=>{let t="";return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t});function or(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=kc.get(e))!==null&&t!==void 0?t:e}function ir(e){let t=typeof atob=="function"?atob(e):typeof Buffer.from=="function"?Buffer.from(e,"base64").toString("binary"):new Buffer(e,"base64").toString("binary"),n=t.length&-2,r=new Uint16Array(n/2);for(let o=0,i=0;o<n;o+=2){let s=t.charCodeAt(o),a=t.charCodeAt(o+1);r[i++]=s|a<<8}return r}var sr=ir("AAJhZ2xxBwARABMAFQBtAg0AAAAAAA8AcAAmYG8AcwAnYHQAPmB0ADxg9SFvdCJg");var Ce;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.FLAG13=8192]="FLAG13",e[e.BRANCH_LENGTH=8064]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Ce||(Ce={}));var ee;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(ee||(ee={}));var Wo=32;function ar(e){return e>=ee.ZERO&&e<=ee.NINE}function Sc(e){return e>=ee.UPPER_A&&e<=ee.UPPER_F||e>=ee.LOWER_A&&e<=ee.LOWER_F}function Bc(e){return e>=ee.UPPER_A&&e<=ee.UPPER_Z||e>=ee.LOWER_A&&e<=ee.LOWER_Z||ar(e)}function Dc(e){return e===ee.EQUALS||Bc(e)}var be;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(be||(be={}));var _e;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(_e||(_e={}));var ln=class{constructor(t,n,r){this.decodeTree=t,this.emitCodePoint=n,this.errors=r,this.state=be.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=_e.Strict,this.runConsumed=0}startEntity(t){this.decodeMode=t,this.state=be.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1,this.runConsumed=0}write(t,n){switch(this.state){case be.EntityStart:return t.charCodeAt(n)===ee.NUM?(this.state=be.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=be.NamedEntity,this.stateNamedEntity(t,n));case be.NumericStart:return this.stateNumericStart(t,n);case be.NumericDecimal:return this.stateNumericDecimal(t,n);case be.NumericHex:return this.stateNumericHex(t,n);case be.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|Wo)===ee.LOWER_X?(this.state=be.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=be.NumericDecimal,this.stateNumericDecimal(t,n))}stateNumericHex(t,n){for(;n<t.length;){let r=t.charCodeAt(n);if(ar(r)||Sc(r)){let o=r<=ee.NINE?r-ee.ZERO:(r|Wo)-ee.LOWER_A+10;this.result=this.result*16+o,this.consumed++,n++}else return this.emitNumericEntity(r,3)}return-1}stateNumericDecimal(t,n){for(;n<t.length;){let r=t.charCodeAt(n);if(ar(r))this.result=this.result*10+(r-ee.ZERO),this.consumed++,n++;else return this.emitNumericEntity(r,2)}return-1}emitNumericEntity(t,n){var r;if(this.consumed<=n)return(r=this.errors)===null||r===void 0||r.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===ee.SEMI)this.consumed+=1;else if(this.decodeMode===_e.Strict)return 0;return this.emitCodePoint(or(this.result),this.consumed),this.errors&&(t!==ee.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,n){let{decodeTree:r}=this,o=r[this.treeIndex],i=(o&Ce.VALUE_LENGTH)>>14;for(;n<t.length;){if(i===0&&(o&Ce.FLAG13)!==0){let a=(o&Ce.BRANCH_LENGTH)>>7;if(this.runConsumed===0){let c=o&Ce.JUMP_TABLE;if(t.charCodeAt(n)!==c)return this.result===0?0:this.emitNotTerminatedNamedEntity();n++,this.excess++,this.runConsumed++}for(;this.runConsumed<a;){if(n>=t.length)return-1;let c=this.runConsumed-1,l=r[this.treeIndex+1+(c>>1)],d=c%2===0?l&255:l>>8&255;if(t.charCodeAt(n)!==d)return this.runConsumed=0,this.result===0?0:this.emitNotTerminatedNamedEntity();n++,this.excess++,this.runConsumed++}this.runConsumed=0,this.treeIndex+=1+(a>>1),o=r[this.treeIndex],i=(o&Ce.VALUE_LENGTH)>>14}if(n>=t.length)break;let s=t.charCodeAt(n);if(s===ee.SEMI&&i!==0&&(o&Ce.FLAG13)!==0)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);if(this.treeIndex=Lc(r,o,this.treeIndex+Math.max(1,i),s),this.treeIndex<0)return this.result===0||this.decodeMode===_e.Attribute&&(i===0||Dc(s))?0:this.emitNotTerminatedNamedEntity();if(o=r[this.treeIndex],i=(o&Ce.VALUE_LENGTH)>>14,i!==0){if(s===ee.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==_e.Strict&&(o&Ce.FLAG13)===0&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}n++,this.excess++}return-1}emitNotTerminatedNamedEntity(){var t;let{result:n,decodeTree:r}=this,o=(r[n]&Ce.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,o,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,r){let{decodeTree:o}=this;return this.emitCodePoint(n===1?o[t]&~(Ce.VALUE_LENGTH|Ce.FLAG13):o[t+1],r),n===3&&this.emitCodePoint(o[t+2],r),r}end(){var t;switch(this.state){case be.NamedEntity:return this.result!==0&&(this.decodeMode!==_e.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case be.NumericDecimal:return this.emitNumericEntity(0,2);case be.NumericHex:return this.emitNumericEntity(0,3);case be.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case be.EntityStart:return 0}}};function $c(e){let t="",n=new ln(e,r=>t+=rr(r));return function(o,i){let s=0,a=0;for(;(a=o.indexOf("&",a))>=0;){t+=o.slice(s,a),n.startEntity(i);let l=n.write(o,a+1);if(l<0){s=a+n.end();break}s=a+l,a=l===0?s+1:s}let c=t+o.slice(s);return t="",c}}function Lc(e,t,n,r){let o=(t&Ce.BRANCH_LENGTH)>>7,i=t&Ce.JUMP_TABLE;if(o===0)return i!==0&&r===i?n:-1;if(i){let l=r-i;return l<0||l>=o?-1:e[n+l]-1}let s=o+1>>1,a=0,c=o-1;for(;a<=c;){let l=a+c>>>1,d=l>>1,u=e[n+d]>>(l&1)*8&255;if(u<r)a=l+1;else if(u>r)c=l-1;else return e[n+s+l]}return-1}var Rc=$c(sr);function Tt(e){return Rc(e,_e.Strict)}var Gc=String.prototype.codePointAt==null?(e,t)=>(e.charCodeAt(t)&64512)===55296?(e.charCodeAt(t)-55296)*1024+e.charCodeAt(t+1)-56320+65536:e.charCodeAt(t):(e,t)=>e.codePointAt(t);var No;(function(e){e[e.XML=0]="XML",e[e.HTML=1]="HTML"})(No||(No={}));var Fo;(function(e){e[e.UTF8=0]="UTF8",e[e.ASCII=1]="ASCII",e[e.Extensive=2]="Extensive",e[e.Attribute=3]="Attribute",e[e.Text=4]="Text"})(Fo||(Fo={}));function te(e,t,n){return Pn(e,t,n)}function dn(e,t){return e.length*t*.6}var Tc="'JetBrains Mono'",hm=`${Tc}, 'SF Mono', 'Fira Code', ui-monospace, monospace`,Y={nodeLabel:13,edgeLabel:11,groupHeader:12},O={nodeLabel:500,edgeLabel:400,groupHeader:600};var kt={horizontal:20,vertical:10,diamondExtra:24},Z={outerBox:1,innerBox:.75,connector:1},he="0.35em",Ze={width:8,height:5};var oi=Object.defineProperty,Qc=(e,t,n)=>t in e?oi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kc=(e,t)=>{for(var n in t)oi(e,n,{get:t[n],enumerable:!0})},Oc=(e,t,n)=>Qc(e,typeof t!="symbol"?t+"":t,n),mr={};Kc(mr,{Graph:()=>Ve,alg:()=>br});var Xc=Object.defineProperty,ii=(e,t)=>{for(var n in t)Xc(e,n,{get:t[n],enumerable:!0})},pr=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let o of r)n.add(o);return Array.from(n.values())}}isLeaf(e){var t;let n;return this.isDirected()?n=this.successors(e):n=this.neighbors(e),((t=n?.length)!=null?t:0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,s,a,c=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(a=t,c=!0)):(o=e,i=t,s=r,arguments.length>2&&(a=n,c=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let l=Qt(this._isDirected,o,i,s);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[l]=c?a:this._defaultEdgeLabelFn(o,i,s);let d=Pc(this._isDirected,o,i,s);return o=d.v,i=d.w,Object.freeze(d),this._edgeObjs[l]=d,Ho(this._preds[i],o),Ho(this._sucs[o],i),this._in[i][l]=d,this._out[o][l]=d,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?dr(this._isDirected,e):Qt(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"||r===null?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?dr(this._isDirected,e):Qt(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?dr(this._isDirected,e):Qt(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,s=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],To(this._preds[s],i),To(this._sucs[i],s),delete this._in[s][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function Ho(e,t){e[t]?e[t]++:e[t]=1}function To(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Qt(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(r===void 0?"\0":r)}function Pc(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let a=o;o=i,i=a}let s={v:o,w:i};return r&&(s.name=r),s}function dr(e,t){return Qt(e,t.v,t.w,t.name)}var Jc={};ii(Jc,{read:()=>Uc,write:()=>jc});function jc(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:_c(e),edges:Zc(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function _c(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function Zc(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Uc(e){let t=new pr(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var br={};ii(br,{CycleException:()=>un,bellmanFord:()=>si,components:()=>qc,dijkstra:()=>fn,dijkstraAll:()=>nl,findCycles:()=>rl,floydWarshall:()=>il,isAcyclic:()=>al,postorder:()=>ll,preorder:()=>dl,prim:()=>fl,shortestPaths:()=>ul,tarjan:()=>ci,topsort:()=>li});var Vc=()=>1;function si(e,t,n,r){return zc(e,String(t),n||Vc,r||function(o){var i;return(i=e.outEdges(o))!=null?i:[]})}function zc(e,t,n,r){let o={},i,s=0,a=e.nodes(),c=function(f){let u=o[f.v],h=o[f.w];if(!u||!h)return;let A=n(f);u.distance+A<h.distance&&(o[f.w]={distance:u.distance+A,predecessor:f.v},i=!0)},l=function(){a.forEach(function(f){r(f).forEach(function(u){let h=u.v===f?u.v:u.w,A=h===u.v?u.w:u.v;c({v:h,w:A})})})};a.forEach(function(f){let u=f===t?0:Number.POSITIVE_INFINITY;o[f]={distance:u,predecessor:""}});let d=a.length;for(let f=1;f<d&&(i=!1,s++,l(),!!i);f++);if(s===d-1&&(i=!1,l(),i))throw new Error("The graph contains a negative weight cycle");return o}function qc(e){let t={},n=[],r;function o(i){var s,a;i in t||(t[i]=!0,r.push(i),(s=e.successors(i))==null||s.forEach(o),(a=e.predecessors(i))==null||a.forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var ai=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw new Error("Queue underflow");this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},el=()=>1;function fn(e,t,n,r){let o=function(i){var s;return(s=e.outEdges(i))!=null?s:[]};return tl(e,String(t),n||el,r||o)}function tl(e,t,n,r){let o={},i=new ai,s,a,c=function(l){let d=l.v!==s?l.v:l.w,f=o[d];if(!f)return;let u=n(l),h=a.distance+u;if(u<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+l+" Weight: "+u);h<f.distance&&(f.distance=h,f.predecessor=s,i.decrease(d,h))};for(e.nodes().forEach(function(l){let d=l===t?0:Number.POSITIVE_INFINITY;o[l]={distance:d,predecessor:""},i.add(l,d)});i.size()>0;){s=i.removeMin();let l=o[s];if(!l||l.distance===Number.POSITIVE_INFINITY)break;a=l,r(s).forEach(c)}return o}function nl(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=fn(e,o,t,n),r},{})}function ci(e){let t=0,n=[],r={},o=[];function i(s){var a;let c=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),(a=e.successors(s))==null||a.forEach(function(l){if(l in r){let d=r[l];d!=null&&d.onStack&&(c.lowlink=Math.min(c.lowlink,d.index))}else{i(l);let d=r[l];d&&(c.lowlink=Math.min(c.lowlink,d.lowlink))}}),c.lowlink===c.index){let l=[],d;do{d=n.pop();let f=r[d];f&&(f.onStack=!1),l.push(d)}while(s!==d);o.push(l)}}return e.nodes().forEach(function(s){s in r||i(s)}),o}function rl(e){return ci(e).filter(function(t){var n;let r=t[0];return r?t.length>1||t.length===1&&((n=e.outEdges(r,r))!=null?n:[]).length>0:!1})}var ol=()=>1;function il(e,t,n){return sl(e,t||ol,n||function(r){var o;return(o=e.outEdges(r))!=null?o:[]})}function sl(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){let s={};r[i]=s,s[i]={distance:0,predecessor:""},o.forEach(function(a){i!==a&&(s[a]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(a){let c=a.v===i?a.w:a.v,l=t(a);s[c]={distance:l,predecessor:i}})}),o.forEach(function(i){let s=r[i];s&&o.forEach(function(a){let c=r[a];c&&o.forEach(function(l){let d=c[i],f=s[l],u=c[l];if(d&&f&&u){let h=d.distance+f.distance;h<u.distance&&(u.distance=h,u.predecessor=f.predecessor)}})})}),r}var un=class extends Error{constructor(e){super(e),this.name="CycleException"}};function li(e){let t={},n={},r=[];function o(i){var s;if(i in n)throw new un;i in t||(n[i]=!0,t[i]=!0,(s=e.predecessors(i))==null||s.forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new un;return r}function al(e){try{li(e)}catch(t){if(t instanceof un)return!1;throw t}return!0}function cl(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=(a=>{var c;return(c=e.isDirected()?e.successors(a):e.neighbors(a))!=null?c:[]}),s={};return t.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);o=di(e,a,n==="post",s,i,r,o)}),o}function di(e,t,n,r,o,i,s){return t in r||(r[t]=!0,n||(s=i(s,t)),o(t).forEach(function(a){s=di(e,a,n,r,o,i,s)}),n&&(s=i(s,t))),s}function fi(e,t,n){return cl(e,t,n,function(r,o){return r.push(o),r},[])}function ll(e,t){return fi(e,t,"post")}function dl(e,t){return fi(e,t,"pre")}function fl(e,t){var n;let r=new pr,o={},i=new ai,s;function a(d){let f=d.v===s?d.w:d.v,u=i.priority(f);if(u!==void 0){let h=t(d);h<u&&(o[f]=s,i.decrease(f,h))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(d){i.add(d,Number.POSITIVE_INFINITY),r.setNode(d)});let c=e.nodes()[0];c!==void 0&&i.decrease(c,0);let l=!1;for(;i.size()>0;){if(s=i.removeMin(),s in o)r.setEdge(s,o[s]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}(n=e.nodeEdges(s))==null||n.forEach(a)}return r}function ul(e,t,n,r){return hl(e,t,n,r??(o=>{var i;return(i=e.outEdges(o))!=null?i:[]}))}function hl(e,t,n,r){if(n===void 0)return fn(e,t,n,r);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let a=i[s];if(a===void 0)continue;let c=r(a);for(let l=0;l<c.length;l++){let d=c[l];if(!d)continue;let f=d.v===a?d.v:d.w,u=f===d.v?d.w:d.v;n({v:f,w:u})<0&&(o=!0)}if(o)return si(e,t,n,r)}return fn(e,t,n,r)}var Ve=pr;function St(e,t,n,r){let o=r;for(;e.hasNode(o);)o=yr(r);return n.dummy=t,e.setNode(o,n),o}function Al(e){let t=new Ve().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function ui(e){let t=new Ve({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Qo(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,s=e.width/2,a=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let c,l;return Math.abs(i)*s>Math.abs(o)*a?(i<0&&(a=-a),c=a*o/i,l=a):(o<0&&(s=-s),c=s,l=s*i/o),{x:n+c,y:r+l}}function An(e){let t=Kt(Ai(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function gl(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=Ue(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function xl(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=Ue(Math.min,t),r=[];e.nodes().forEach(s=>{let a=e.node(s).rank-n;r[a]||(r[a]=[]),r[a].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((s,a)=>{s===void 0&&a%i!==0?--o:s!==void 0&&o&&s.forEach(c=>e.node(c).rank+=o)})}function Ko(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),St(e,"border",o,t)}function ml(e,t=hi){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var hi=65535;function Ue(e,t){if(t.length>hi){let n=ml(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function Ai(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return Ue(Math.max,t)}function pl(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function bl(e,t){return t()}var yl=0;function yr(e){let t=++yl;return e+(""+t)}function Kt(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function hn(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function gn(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function wl(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var xn="\0";function gi(e,t,n){var r,o,i,s,a,c;if(!(e&&t&&n&&t.dummy==="edge"&&n.dummy==="edge"&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let l=!0;t.edgeObj.w===n.edgeObj.w&&(l=!1);let d=l?(o=(r=e[t.edgeObj.v])==null?void 0:r.rank)!=null?o:NaN+1:(s=(i=e[t.edgeObj.w])==null?void 0:i.rank)!=null?s:NaN-1,f=Object.entries(e).find(x=>{var w,g;return((w=x[1].edgeObj)==null?void 0:w.v)===t.edgeObj.v&&((g=x[1].edgeObj)==null?void 0:g.w)===t.edgeObj.w&&x[1].rank===d}),u=Object.entries(e).find(x=>{var w,g;return((w=x[1].edgeObj)==null?void 0:w.v)===n.edgeObj.v&&((g=x[1].edgeObj)==null?void 0:g.w)===n.edgeObj.w&&x[1].rank===d});if(!f||!u)return 0;let h=(a=f[1].order)!=null?a:NaN,A=(c=u[1].order)!=null?c:NaN;return isNaN(h-A)?0:h-A}var Cl=class{constructor(){Oc(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Oo(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Oo(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,Il)),n=n._prev;return"["+e.join(", ")+"]"}};function Oo(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Il(e,t){if(e!=="_next"&&e!=="_prev")return t}var El=Cl,Ml=()=>1;function kl(e,t){if(e.nodeCount()<=1)return[];let n=Sl(e,t||Ml);return vl(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function vl(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)fr(e,t,n,a);for(;a=i.dequeue();)fr(e,t,n,a);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(a=(r=t[c])==null?void 0:r.dequeue(),a){o=o.concat(fr(e,t,n,a,!0)||[]);break}}}return o}function fr(e,t,n,r,o){let i=[],s=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=e.node(a.v);o&&i.push({v:a.v,w:a.w}),l.out-=c,xr(t,n,l)}),(e.outEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=a.w,d=e.node(l);d.in-=c,xr(t,n,d)}),e.removeNode(r.v),s}function Sl(e,t){let n=new Ve,r=0,o=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let c=n.edge(a.v,a.w)||0,l=t(a),d=c+l;n.setEdge(a.v,a.w,d);let f=n.node(a.v),u=n.node(a.w);o=Math.max(o,f.out+=l),r=Math.max(r,u.in+=l)});let i=Bl(o+r+3).map(()=>new El),s=r+1;return n.nodes().forEach(a=>{xr(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function xr(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function Bl(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function Dl(e,t){(e.graph().acyclicer==="greedy"?kl(e,n(e)):$l(e,t??null)).forEach(r=>{let o=e.edge(r);e.removeEdge(r),o.forwardName=r.name,o.reversed=!0,e.setEdge(r.w,r.v,o,yr("rev"))});function n(r){return o=>r.edge(o).weight}}function $l(e,t){let n=[],r={},o={};function i(c){Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,e.outEdges(c).forEach(l=>{Object.hasOwn(r,l.w)?n.push(l):i(l.w)}),delete r[c])}function s(c){var l;Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,(l=e.outEdges(c))==null||l.forEach(d=>{var f,u;Object.hasOwn(r,d.w)||((f=t.node(c))==null?void 0:f.rank)>((u=t.node(d.w))==null?void 0:u.rank)&&Rl(e,d.w,d)?n.push(d):s(d.w)}),delete r[c])}let a=i;return t&&typeof t.node=="function"&&(a=s),e.sources().forEach(a),e.nodes().forEach(a),n}function Ll(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function Rl(e,t,n){let r=new Set;function o(i){var s;if(e.sources().includes(i))return!0;r.add(i);for(let a of(s=e.inEdges(i))!=null?s:[])if(!(a.v===n.v&&a.w===n.w)&&!r.has(a.v)&&o(a.v))return!0;return!1}return o(t)}function Gl(e){e.graph().dummyChains=[],e.edges().forEach(t=>Wl(e,t))}function Wl(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,s=t.name,a=e.edge(t),c=a.labelRank;if(i===r+1)return;e.removeEdge(t);let l,d,f;for(f=0,++r;r<i;++f,++r)a.points=[],d={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},l=St(e,"edge",d,"_d"),r===c&&(d.width=a.width,d.height=a.height,d.dummy="edge-label",d.labelpos=a.labelpos),e.setEdge(n,l,{weight:a.weight},s),f===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,o,{weight:a.weight},s)}function Nl(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function wr(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),s=i?i.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],a=Ue(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),o.rank=a}e.sources().forEach(n)}function vt(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var xi=Fl;function Fl(e){let t=new Ve({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,s;for(;Yl(t,e)<o&&(i=Hl(t,e),!!i);)s=t.hasNode(i.v)?vt(e,i):-vt(e,i),Tl(t,e,s);return t}function Yl(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let s=i.v,a=r===s?i.w:s;!e.hasNode(a)&&!vt(t,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function Hl(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=vt(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function Tl(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Ql,postorder:Kl}=br,Ol=lt;lt.initLowLimValues=Ir;lt.initCutValues=Cr;lt.calcCutValue=mi;lt.leaveEdge=bi;lt.enterEdge=yi;lt.exchangeEdges=wi;function lt(e){e=Al(e),wr(e);let t=xi(e);Ir(t),Cr(t,e);let n,r;for(;n=bi(t);)r=yi(t,e,n),wi(t,e,n,r)}function Cr(e,t){let n=Kl(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>Xl(e,t,r))}function Xl(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=mi(e,t,n)}function mi(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),s=0;i||(o=!1,i=t.edge(r,n)),s=i.weight;let a=t.nodeEdges(n);return a&&a.forEach(c=>{let l=c.v===n,d=l?c.w:c.v;if(d!==r){let f=l===o,u=t.edge(c).weight;if(s+=f?u:-u,Jl(e,n,d)){let h=e.edge(n,d).cutvalue;s+=f?-h:h}}}),s}function Ir(e,t){arguments.length<2&&(t=e.nodes()[0]),pi(e,{},1,t)}function pi(e,t,n,r,o){let i=n,s=e.node(r);t[r]=!0;let a=e.neighbors(r);return a&&a.forEach(c=>{Object.hasOwn(t,c)||(n=pi(e,t,n,c,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function bi(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function yi(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),s=e.node(o),a=i,c=!1;return i.lim>s.lim&&(a=s,c=!0),t.edges().filter(l=>c===Xo(e,e.node(l.v),a)&&c!==Xo(e,e.node(l.w),a)).reduce((l,d)=>vt(t,d)<vt(t,l)?d:l)}function wi(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Ir(e),Cr(e,t),Pl(e,t)}function Pl(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=Ql(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),a=!1;s||(s=t.edge(i,o),a=!0),t.node(o).rank=t.node(i).rank+(a?s.minlen:-s.minlen)})}function Jl(e,t,n){return e.hasEdge(t,n)}function Xo(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var jl=_l;function _l(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Po(e);break;case"tight-tree":Ul(e);break;case"longest-path":Zl(e);break;case"none":break;default:Po(e)}}var Zl=wr;function Ul(e){wr(e),xi(e)}function Po(e){Ol(e)}var Vl=zl;function zl(e){let t=ed(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(r=>{let o=e.node(r),i=o.edgeObj,s=ql(e,t,i.v,i.w),a=s.path,c=s.lca,l=0,d=a[l],f=!0;for(;r!==i.w;){if(o=e.node(r),f){for(;(d=a[l])!==c&&e.node(d).maxRank<o.rank;)l++;d===c&&(f=!1)}if(!f){for(;l<a.length-1&&e.node(a[l+1]).minRank<=o.rank;)l++;d=a[l]}d!==void 0&&e.setParent(r,d),r=e.successors(r)[0]}})}function ql(e,t,n,r){let o=[],i=[],s=Math.min(t[n].low,t[r].low),a=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),o.push(c);while(c&&(t[c].low>s||a>t[c].lim));let l=c,d=r;for(;(d=e.parent(d))!==l;)i.push(d);return{path:o.concat(i.reverse()),lca:l}}function ed(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(xn).forEach(r),t}function td(e){let t=St(e,"root",{},"_root"),n=nd(e),r=Object.values(n),o=Ue(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let s=rd(e)+1;e.children(xn).forEach(a=>{Ci(e,t,i,s,o,n,a)}),e.graph().nodeRankFactor=i}function Ci(e,t,n,r,o,i,s){var a;let c=e.children(s);if(!c.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let l=Ko(e,"_bt"),d=Ko(e,"_bb"),f=e.node(s);e.setParent(l,s),f.borderTop=l,e.setParent(d,s),f.borderBottom=d,c.forEach(u=>{var h;Ci(e,t,n,r,o,i,u);let A=e.node(u),x=A.borderTop?A.borderTop:u,w=A.borderBottom?A.borderBottom:u,g=A.borderTop?r:2*r,y=x!==w?1:o-((h=i[s])!=null?h:0)+1;e.setEdge(l,x,{weight:g,minlen:y,nestingEdge:!0}),e.setEdge(w,d,{weight:g,minlen:y,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,l,{weight:0,minlen:o+((a=i[s])!=null?a:0)})}function nd(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(s=>n(s,o+1)),t[r]=o}return e.children(xn).forEach(r=>n(r,1)),t}function rd(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function od(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var id=sd;function sd(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),o&&Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Jo(e,"borderLeft","_bl",n,o,i),Jo(e,"borderRight","_br",n,o,i)}}e.children(xn).forEach(t)}function Jo(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},a=o[t][i-1],c=St(e,"border",s,n);o[t][i]=c,e.setParent(c,r),a&&e.setEdge(a,c,{weight:1})}function ad(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&Ii(e)}function cd(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&ld(e),(n==="lr"||n==="rl")&&(dd(e),Ii(e))}function Ii(e){e.nodes().forEach(t=>jo(e.node(t))),e.edges().forEach(t=>jo(e.edge(t)))}function jo(e){let t=e.width;e.width=e.height,e.height=t}function ld(e){e.nodes().forEach(t=>ur(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ur),Object.hasOwn(r,"y")&&ur(r)})}function ur(e){e.y=-e.y}function dd(e){e.nodes().forEach(t=>hr(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(hr),Object.hasOwn(r,"x")&&hr(r)})}function hr(e){let t=e.x;e.x=e.y,e.y=t}function fd(e,t=null){let n={},r=e.nodes().filter(l=>!e.children(l).length),o=r.map(l=>e.node(l).rank),i=Ue(Math.max,o),s=Kt(i+1).map(()=>[]);function a(l){if(n[l])return;n[l]=!0;let d=e.node(l);s[d.rank].push(l);let f=e.successors(l);f&&[...f].sort((u,h)=>c(u,h)).forEach(a)}r.sort((l,d)=>e.node(l).rank-e.node(d).rank).forEach(a);function c(l,d){let f=e.node(l),u=e.node(d);return gi(t,f,u)}return s}function ud(e,t){let n=0;for(let r=1;r<t.length;++r)n+=hd(e,t[r-1],t[r]);return n}function hd(e,t,n){let r=wl(n,n.map((l,d)=>d)),o=t.flatMap(l=>{let d=e.outEdges(l);return d?d.map(f=>({pos:r[f.w],weight:e.edge(f).weight})).sort((f,u)=>f.pos-u.pos):[]}),i=1;for(;i<n.length;)i<<=1;let s=2*i-1;i-=1;let a=new Array(s).fill(0),c=0;return o.forEach(l=>{let d=l.pos+i;a[d]+=l.weight;let f=0;for(;d>0;)d%2&&(f+=a[d+1]),d=d-1>>1,a[d]+=l.weight;c+=l.weight*f}),c}function Ad(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,s)=>{let a=e.edge(s),c=e.node(s.v);return{sum:i.sum+a.weight*c.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function gd(e,t){let n={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),n[o.v]=s}),t.edges().forEach(o=>{let i=n[o.v],s=n[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let r=Object.values(n).filter(o=>!o.indegree);return xd(r)}function xd(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&md(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>hn(o,["vs","i","barycenter","weight"]))}function md(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function pd(e,t,n,r,o){let i={},s=null,a=null,c=o;typeof t=="boolean"?(c=t,i={}):t&&(i=t,s=n??null,a=r??null);let l=pl(e,g=>Object.hasOwn(g,"barycenter")),d=l.lhs,f=l.rhs.sort((g,y)=>y.i-g.i),u=[],h=0,A=0,x=0;d.sort(bd(a,s,!!c));for(let[g,y]of Object.entries(i)){let b=d.findIndex(m=>m.vs[0]===g);d.splice(b+1,0,y)}x=_o(u,f,x),d.forEach(g=>{x+=g.vs.length,u.push(g.vs),h+=g.barycenter*g.weight,A+=g.weight,x=_o(u,f,x)});let w={vs:u.flat(1)};return A&&(w.barycenter=h/A,w.weight=A),w}function _o(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function bd(e,t,n){return(r,o)=>{if(r.barycenter<o.barycenter)return-1;if(r.barycenter>o.barycenter)return 1;if(e&&(typeof r.vs[0]=="string"||typeof o.vs[0]=="string")){let i=e.node(r.vs[0]),s=e.node(o.vs[0]),a=gi(t,i,s);if(a!==0)return a}return n?o.i-r.i:r.i-o.i}}function Ei(e,t,n,r,o){var i,s,a,c,l,d,f,u,h,A,x;let w=null,g=o;typeof r=="boolean"?(g=r,w=null):r!==void 0&&(w=r);let y=e.children(t),b=e.node(t),m=b?b.borderLeft:void 0,C=b?b.borderRight:void 0,M={};m&&(y=y.filter(D=>D!==m&&D!==C));let v=Ad(e,y);v.forEach(D=>{if(e.children(D.v).length){let{result:$}=Ei(e,D.v,n,w,g);M[D.v]=$,Object.hasOwn($,"barycenter")&&wd(D,$)}});let I=gd(v,n);yd(I,M);let p={},S=!1;for(let D=0;D<I.length;D++)for(let $=D+1;$<I.length;$++)if(!(!I[D]||!I[$]||!((i=I[D])!=null&&i.barycenter)||!((s=I[$])!=null&&s.barycenter))&&((a=I[D])==null?void 0:a.barycenter)===I[$].barycenter){let L=(l=(c=I[D])==null?void 0:c.vs[0])!=null?l:"",W=(f=(d=I[$])==null?void 0:d.vs[0])!=null?f:"",T=e.node(L),j=e.node(W);if(T.dummy==="edge"&&j.dummy==="edge"&&((u=T.edgeObj)==null?void 0:u.v)===((h=j.edgeObj)==null?void 0:h.v)&&((A=T.edgeObj)==null?void 0:A.w)===((x=j.edgeObj)==null?void 0:x.w))if(T.edgeLabel.reversed){p[W]=I[D],I.splice(D,1),D--;break}else p[L]=I[$],I.splice($,1),$--;else S=!0}let B=pd(I,p,w,e,g);if(m&&C){B.vs=[m,B.vs,C].flat(1);let D=e.predecessors(m);if(D&&D.length){let $=e.node(D[0]),L=e.predecessors(C),W=e.node(L[0]);Object.hasOwn(B,"barycenter")||(B.barycenter=0,B.weight=0),B.barycenter=(B.barycenter*B.weight+$.order+W.order)/(B.weight+2),B.weight+=2}}return Object.defineProperty(B,"result",{value:B,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(B,"usedBias",{value:S,enumerable:!1,configurable:!0,writable:!0}),B}function yd(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function wd(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function Cd(e,t,n,r){r||(r=e.nodes());let o=Id(e),i=new Ve({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let a=e.node(s),c=e.parent(s);if(a.rank===t||a.minRank<=t&&t<=a.maxRank){i.setNode(s),i.setParent(s,c||o);let l=e[n](s);l&&l.forEach(d=>{let f=d.v===s?d.w:d.v,u=i.edge(f,s),h=u!==void 0?u.weight:0;i.setEdge(f,s,{weight:e.edge(d).weight+h})}),Object.hasOwn(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]})}}),i}function Id(e){let t;for(;e.hasNode(t=yr("_root")););return t}function Ed(e,t,n){let r={},o;n.forEach(i=>{let s=e.parent(i),a,c;for(;s;){if(a=e.parent(s),a?(c=r[a],r[a]=s):(c=o,o=s),c&&c!==s){t.setEdge(c,s);return}s=a}})}function Mi(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,Mi);return}let r=Ai(e),o=Zo(e,Kt(1,r+1),"inEdges"),i=Zo(e,Kt(r-1,-1,-1),"outEdges"),s=fd(e,n);if(Uo(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,c,l=t.constraints||[];for(let d=0,f=0;f<4;++d,++f){Md(d%2?o:i,d%4>=2,l,n),s=An(e);let u=ud(e,s);u<a?(f=0,c=Object.assign({},s),a=u):u===a&&(c=structuredClone(s))}Uo(e,c)}function Zo(e,t,n){let r=new Map,o=(i,s)=>{r.has(i)||r.set(i,[]),r.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&o(a,i)}return t.map(function(i){return Cd(e,i,n,r.get(i)||[])})}function Md(e,t,n,r){let o=!0,i=new Ve;e.forEach(function(s){n.forEach(d=>i.setEdge(d.left,d.right));let a=s.graph().root,{result:c,usedBias:l}=Ei(s,a,i,r,o);t&&l&&(o=!o),c.vs.forEach((d,f)=>s.node(d).order=f),Ed(s,i,c.vs)})}function Uo(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function kd(e,t){let n={};function r(o,i){let s=0,a=0,c=o.length,l=i[i.length-1];return i.forEach((d,f)=>{let u=Sd(e,d),h=u?e.node(u).order:c;(u||d===l)&&(i.slice(a,f+1).forEach(A=>{let x=e.predecessors(A);x&&x.forEach(w=>{let g=e.node(w),y=g.order;(y<s||h<y)&&!(g.dummy&&e.node(A).dummy)&&ki(n,w,A)})}),a=f+1,s=h)}),i}return t.length&&t.reduce(r),n}function vd(e,t){let n={};function r(i,s,a,c,l){Kt(s,a).forEach(d=>{let f=i[d];if(f!==void 0&&e.node(f).dummy){let u=e.predecessors(f);u&&u.forEach(h=>{if(h===void 0)return;let A=e.node(h);A.dummy&&(A.order<c||A.order>l)&&ki(n,h,f)})}})}function o(i,s){let a=-1,c=-1,l=0;return s.forEach((d,f)=>{if(e.node(d).dummy==="border"){let u=e.predecessors(d);if(u&&u.length){let h=u[0];if(h===void 0)return;c=e.node(h).order,r(s,l,f,a,c),l=f,a=c}}r(s,l,s.length,c,i.length)}),s}return t.length&&t.reduce(o),n}function Sd(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function ki(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Bd(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function Dd(e,t,n,r,o){let i={},s={},a={};return t.forEach(c=>{c.forEach((l,d)=>{i[l]=l,s[l]=l,a[l]=d})}),t.forEach(c=>{let l=-1,d=-1,f=!1,u=c,h=c.findIndex(A=>o?.includes(A)||Vo(A,e,o));h>0&&(u=[c[h],...c.slice(0,h),...c.slice(h+1)],f=!0),u.forEach(A=>{var x;let w=r(A);if(w&&w.length){o!=null&&o.includes(A)&&(w=w.filter(b=>Vo(b,e,o)));let g=w.sort((b,m)=>{let C=a[b],M=a[m];return(C!==void 0?C:0)-(M!==void 0?M:0)}),y=(g.length-1)/2;for(let b=Math.floor(y),m=Math.ceil(y);b<=m;++b){let C=g[b];if(C===void 0)continue;let M=a[C];if(M!==void 0&&s[A]===A&&l<M&&a[C]!==d&&!Bd(n,A,C)){let v=i[C];v!==void 0&&(s[C]=A,s[A]=i[A]=v,l=M,f&&(l=-1,d=(x=a[C])!=null?x:-1,f=!1))}}}})}),{root:i,align:s}}function $d(e,t,n,r,o=!1){let i={},s=Ld(e,t,n,o),a=o?"borderLeft":"borderRight";function c(h,A){let x=s.nodes().slice(),w={},g=x.pop();for(;g;){if(w[g])h(g);else{w[g]=!0,x.push(g);for(let y of A(g))x.push(y)}g=x.pop()}}function l(h){let A=s.inEdges(h);A?i[h]=A.reduce((x,w)=>{var g;let y=(g=i[w.v])!=null?g:0,b=s.edge(w);return Math.max(x,y+(b!==void 0?b:0))},0):i[h]=0}function d(h){let A=s.outEdges(h),x=Number.POSITIVE_INFINITY;A&&(x=A.reduce((g,y)=>{let b=i[y.w],m=s.edge(y);return Math.min(g,(b!==void 0?b:0)-(m!==void 0?m:0))},Number.POSITIVE_INFINITY));let w=e.node(h);x!==Number.POSITIVE_INFINITY&&w.borderType!==a&&(i[h]=Math.max(i[h]!==void 0?i[h]:0,x))}function f(h){return s.predecessors(h)||[]}function u(h){return s.successors(h)||[]}return c(l,f),c(d,u),Object.keys(r).forEach(h=>{var A;let x=n[h];x!==void 0&&(i[h]=(A=i[x])!=null?A:0)}),i}function Ld(e,t,n,r){let o=new Ve,i=e.graph(),s=Fd(i.nodesep,i.edgesep,r);return t.forEach(a=>{let c;a.forEach(l=>{let d=n[l];if(d!==void 0){if(o.setNode(d),c!==void 0){let f=n[c];if(f!==void 0){let u=o.edge(f,d);o.setEdge(f,d,Math.max(s(e,l,c),u||0))}}c=l}})}),o}function Rd(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,c])=>{let l=Yd(e,a)/2;o=Math.max(c+l,o),i=Math.min(c-l,i)});let s=o-i;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function Gd(e,t){let n=Object.values(t),r=Ue(Math.min,n),o=Ue(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let a=i+s,c=e[a];if(!c||c===t)return;let l=Object.values(c),d=r-Ue(Math.min,l);s!=="l"&&(d=o-Ue(Math.max,l)),d&&(e[a]=gn(c,f=>f+d))})})}function Wd(e,t=void 0){let n=e.ul;return n?gn(n,(r,o)=>{var i,s;if(t){let c=t.toLowerCase(),l=e[c];if(l&&l[o]!==void 0)return l[o]}let a=Object.values(e).map(c=>{let l=c[o];return l!==void 0?l:0}).sort((c,l)=>c-l);return(((i=a[1])!=null?i:0)+((s=a[2])!=null?s:0))/2}):{}}function Nd(e,t){let n=An(e),r=Object.assign(kd(e,n),vd(e,n)),o={},i;["u","d"].forEach(a=>{i=a==="u"?n:Object.values(n).reverse(),["l","r"].forEach(c=>{c==="r"&&(i=i.map(f=>Object.values(f).reverse()));let l=Dd(e,i,r,f=>(a==="u"?e.predecessors(f):e.successors(f))||[],t),d=$d(e,i,l.root,l.align,c==="r");c==="r"&&(d=gn(d,f=>-f)),o[a+c]=d})});let s=Rd(e,o);return Gd(o,s),Wd(o,e.graph().align)}function Fd(e,t,n){return(r,o,i)=>{let s=r.node(o),a=r.node(i),c=0,l;if(c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":l=-s.width/2;break;case"r":l=s.width/2;break}if(l&&(c+=n?l:-l),l=void 0,c+=(s.dummy?t:e)/2,c+=(a.dummy?t:e)/2,c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":l=a.width/2;break;case"r":l=-a.width/2;break}return l&&(c+=n?l:-l),c}}function Yd(e,t){return e.node(t).width}function Vo(e,t,n){var r;if(!n)return!1;let o=(r=t.node(e))==null?void 0:r.edgeObj;if(!o||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(o?.v),s=n.indexOf(o?.w);return i!==-1&&s!==-1&&i===(s+1)%n.length||i===(s-1)%n.length}function Hd(e,t){e=ui(e),Td(e),Object.entries(Nd(e,t)).forEach(([n,r])=>e.node(n).x=r)}function Td(e){let t=An(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(s=>{let a=s.reduce((c,l)=>{var d;let f=(d=e.node(l).height)!=null?d:0;return c>f?c:f},0);s.forEach(c=>{let l=e.node(c);o==="top"?l.y=i+l.height/2:o==="bottom"?l.y=i+a-l.height/2:l.y=i+a/2}),i+=a+r})}var zo=new WeakMap;function vi(e,t={}){return Si(e,bl,t),e}function qo(e,t,n){let r=t;for(;r!==void 0;){let o=e.parent(r);if(o===n)return r;r=o}}function Si(e,t,n){var r;let o=e.nodes().filter(y=>e.children(y).length),i={};o.forEach(y=>{let b=e.node(y);if(b&&b.rankdir){let m=new Ve({multigraph:!0,compound:!0});m.setGraph({rankdir:b.rankdir});let C=e.children(y);C.forEach(L=>{let W={...e.node(L)};m.setNode(L,W);let T=e.parent(L);T&&T!==y&&C.includes(T)&&m.setParent(L,T)});let M=new Set;e.edges().forEach(L=>{let W=qo(e,L.v,y),T=qo(e,L.w,y);if(W&&T&&W!==T){let j=`${W}\0${T}`;M.has(j)||(M.add(j),m.setEdge(W,T,{...e.edge(L)}))}}),Si(m,t,n);let v=ri(m);ei(v,t,n,null),ti(m,v);let I=1/0,p=1/0,S=-1/0,B=-1/0;m.nodes().forEach(L=>{if(L===y)return;let W=m.node(L);W&&typeof W.x=="number"&&typeof W.y=="number"&&typeof W.width=="number"&&typeof W.height=="number"&&(I=Math.min(I,W.x-W.width/2),S=Math.max(S,W.x+W.width/2),p=Math.min(p,W.y-W.height/2),B=Math.max(B,W.y+W.height/2))}),(!isFinite(I)||!isFinite(p)||!isFinite(S)||!isFinite(B))&&(I=p=0,S=B=0);let D=S-I,$=B-p;i[y]={minX:I,minY:p,maxX:S,maxY:B,width:D,height:$,offsetX:I,offsetY:p},b._dagreClusterSubgraph=m}});let s=[],a=y=>{let b=[],m=(e.children(y)||[]).filter(C=>C!==y);for(;m.length>0;){let C=m.shift();b.push(C),(e.children(C)||[]).filter(M=>M!==C).forEach(M=>m.push(M))}return b},c=new Map;o.forEach(y=>{let b=e.node(y);b&&b.rankdir&&i[y]&&c.set(y,(e.children(y)||[]).filter(m=>m!==y))});let l=new Set([...c.values()].flat()),d=new Map;c.forEach((y,b)=>{l.has(b)||d.set(b,a(b))});let f=new Set([...d.values()].flat()),u=y=>{for(let[b,m]of d)if(m.includes(y))return b;return y},h=[];e.edges().forEach(y=>{(f.has(y.v)||f.has(y.w))&&h.push({edge:y,label:e.edge(y)})});let A=new Map;f.forEach(y=>{let b=e.parent(y);A.set(y,typeof b=="string"?b:void 0)}),d.forEach((y,b)=>{let m=e.node(b),C=[];y.forEach(I=>{let p=e.node(I);p&&(C.push({id:I,node:p,parent:A.get(I)}),e.removeNode(I))});let M=h.filter(({edge:I})=>y.includes(I.v)||y.includes(I.w)),v=i[b];m&&(s.push({clusterId:b,subgraph:m._dagreClusterSubgraph,bounds:v,children:y,removedNodes:C,removedEdges:M}),m.width=v.width,m.height=v.height)});let x=new Set;h.forEach(({edge:y,label:b})=>{let m=u(y.v),C=u(y.w);if(m!==C&&e.hasNode(m)&&e.hasNode(C)){let M=`${m}\0${C}`;x.has(M)||(x.add(M),e.setEdge(m,C,{...b,width:0,height:0}))}});let w=ri(e),g=ei(w,t,n,(r=zo.get(e))!=null?r:null);zo.set(e,g),ti(e,w),x.forEach(y=>{let b=y.indexOf("\0"),m=y.slice(0,b),C=y.slice(b+1);e.hasEdge(m,C)&&e.removeEdge(m,C)}),s.forEach(({clusterId:y,subgraph:b,bounds:m,removedNodes:C,removedEdges:M})=>{var v,I;let p=e.node(y),S=(v=p?.x)!=null?v:0,B=(I=p?.y)!=null?I:0,D=(m.minX+m.maxX)/2,$=(m.minY+m.maxY)/2;C.forEach(({id:L,node:W,parent:T})=>{e.setNode(L,W),T!==void 0&&e.setParent(L,T)}),M.forEach(({edge:L,label:W})=>{e.setEdge(L,W)}),b.nodes().forEach(L=>{if(L===y)return;let W=b.node(L),T=e.node(L);T&&W&&typeof W.x=="number"&&typeof W.y=="number"&&(T.x=S+(W.x-D),T.y=B+(W.y-$))}),delete p._dagreClusterSubgraph}),o.forEach(y=>{var b,m;let C=e.node(y),M=i[y];if(C&&C.rankdir&&C._dagreClusterSubgraph&&M){let v=C._dagreClusterSubgraph,I=(b=C.x)!=null?b:0,p=(m=C.y)!=null?m:0,S=(M.minX+M.maxX)/2,B=(M.minY+M.maxY)/2;v.nodes().forEach(D=>{if(D===y)return;let $=v.node(D),L=e.node(D);if(L&&$&&typeof $.x=="number"&&typeof $.y=="number"){let W=$.x-S,T=$.y-B;L.x=I+W,L.y=p+T}}),delete C._dagreClusterSubgraph}})}function ei(e,t,n,r=null){var o,i;let s=n?.useDynamic!==!1,a=s&&(o=r?.graph)!=null?o:null,c=s&&(i=r?.rawNodes)!=null?i:null;t(" makeSpaceForEdgeLabels",()=>_d(e)),t(" removeSelfEdges",()=>rf(e)),t(" acyclic",()=>Dl(e,a)),t(" nestingGraph.run",()=>td(e)),t(" rank",()=>jl(ui(e))),t(" injectEdgeLabelProxies",()=>Zd(e)),t(" removeEmptyRanks",()=>xl(e)),t(" nestingGraph.cleanup",()=>od(e)),t(" normalizeRanks",()=>gl(e)),t(" assignRankMinMax",()=>Ud(e)),t(" removeEdgeLabelProxies",()=>Vd(e)),t(" normalize.run",()=>Gl(e)),t(" parentDummyChains",()=>Vl(e)),t(" addBorderSegments",()=>id(e)),t(" order",()=>Mi(e,n,c)),t(" insertSelfEdges",()=>of(e)),t(" adjustCoordinateSystem",()=>ad(e)),t(" position",()=>Hd(e,n.corePath)),t(" positionSelfEdges",()=>sf(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>nf(e)),t(" normalize.undo",()=>Nl(e)),t(" fixupEdgeLabelCoords",()=>ef(e)),t(" undoCoordinateSystem",()=>cd(e)),t(" translateGraph",()=>zd(e)),t(" assignNodeIntersects",()=>qd(e)),t(" reversePoints",()=>tf(e)),t(" acyclic.undo",()=>Ll(e)),{graph:e,rawNodes:l}}function ti(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Qd=["nodesep","edgesep","ranksep","marginx","marginy"],Kd={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},Od=["acyclicer","ranker","rankdir","align","rankalign"],Xd=["width","height","rank"],ni={width:0,height:0},Pd=["minlen","weight","width","height","labeloffset"],Jd={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},jd=["labelpos"];function ri(e){let t=new Ve({multigraph:!0,compound:!0}),n=gr(e.graph());return t.setGraph(Object.assign({},Kd,Ar(n,Qd),hn(n,Od))),e.nodes().forEach(r=>{let o=gr(e.node(r)),i=Ar(o,Xd);Object.keys(ni).forEach(a=>{i[a]===void 0&&(i[a]=ni[a])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=gr(e.edge(r));t.setEdge(r,Object.assign({},Jd,Ar(o,Pd),hn(o,jd)))}),t}function _d(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{var r;let o=e.edge(n);o.minlen*=2,((r=o.labelpos)!=null?r:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?o.width+=o.labeloffset:o.height+=o.labeloffset)})}function Zd(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};St(e,"edge-proxy",o,"_ep")}})}function Ud(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Vd(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function zd(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,a=i.marginy||0;function c(l){let d=l.x,f=l.y,u=l.width,h=l.height;t=Math.min(t,d-u/2),n=Math.max(n,d+u/2),r=Math.min(r,f-h/2),o=Math.max(o,f+h/2)}e.nodes().forEach(l=>c(e.node(l))),e.edges().forEach(l=>{let d=e.edge(l);Object.hasOwn(d,"x")&&c(d)}),t-=s,r-=a,e.nodes().forEach(l=>{let d=e.node(l);d.x-=t,d.y-=r}),e.edges().forEach(l=>{let d=e.edge(l);d.points.forEach(f=>{f.x-=t,f.y-=r}),Object.hasOwn(d,"x")&&(d.x-=t),Object.hasOwn(d,"y")&&(d.y-=r)}),i.width=n-t+s,i.height=o-r+a}function qd(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=o,s=r),n.points.unshift(Qo(r,i)),n.points.push(Qo(o,s))})}function ef(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function tf(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function nf(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function rf(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function of(e){An(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);typeof i.rank!="number"&&(i.rank=0),i.order=o+n,(i.selfEdges||[]).forEach(s=>{St(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++n,e:s.e,edgeLabel:s.label},"_se"),(!Array.isArray(s.label.points)||s.label.points.length!==7)&&(s.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function sf(e){e.nodes().forEach(t=>{let n=e.node(t),r=o=>typeof o=="number"&&isFinite(o);if(n.dummy==="selfedge"){let o=n,i=e.node(o.e.v),s=r(i?.x)?i.x:0,a=r(i?.y)?i.y:0,c=r(i?.width)?i.width:0,l=r(i?.height)?i.height:0,d=r(n.x)?n.x:s,f=r(n.y)?n.y:a,u=c/2,h=l/2;o.edgeLabel.points=[{x:d+u,y:f-h},{x:d+u,y:f-h},{x:d,y:f},{x:d-u,y:f+h},{x:d-u,y:f+h},{x:d,y:f},{x:d,y:f}],o.edgeLabel.x=d,o.edgeLabel.y=f,e.setEdge(o.e,o.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(o=>{if(!Array.isArray(o.label.points)||o.label.points.length!==7){let i=r(n.x)?n.x:0,s=r(n.y)?n.y:0,a=r(n.width)?n.width:0,c=r(n.height)?n.height:0,l=a/2,d=c/2;o.label.points=[{x:i+l,y:s-d},{x:i+l,y:s-d},{x:i,y:s},{x:i-l,y:s+d},{x:i-l,y:s+d},{x:i,y:s},{x:i,y:s}]}})})}function Ar(e,t){return gn(hn(e,t),Number)}function gr(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}var af={DOWN:"TB",UP:"BT",RIGHT:"LR",LEFT:"RL"},cf=28,Bi=e=>{let t=e.layoutOptions?.["elk.padding"]??"",n=r=>Number(new RegExp(r+"=(\\d+)").exec(t)?.[1]??0);return{top:n("top"),left:n("left"),bottom:n("bottom"),right:n("right")}},Li=(e,t)=>e.x>t.x&&e.x<t.x+t.width&&e.y>t.y&&e.y<t.y+t.height;function lf(e,t,n){let r=0,o=1;for(let i=0;i<30;i++){let s=(r+o)/2;Li({x:e.x+(t.x-e.x)*s,y:e.y+(t.y-e.y)*s},n)?o=s:r=s}return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o}}function Di(e,t){let n=e.findIndex(r=>Li(r,t));return n>0?[...e.slice(0,n),lf(e[n-1],e[n],t)]:e}function df(e,t){let n=[e[0]];for(let r of e.slice(1)){let o=n[n.length-1];Math.abs(o.x-r.x)>1&&Math.abs(o.y-r.y)>1&&(t?n.push({x:o.x,y:(o.y+r.y)/2},{x:r.x,y:(o.y+r.y)/2}):n.push({x:(o.x+r.x)/2,y:o.y},{x:(o.x+r.x)/2,y:r.y})),n.push(r)}return n}function $i(e,t,n){let r=(s,a,c)=>Math.min(Math.max(c,s+Math.min(12,a/2)),s+a-Math.min(12,a/2)),[o,i]=[e.x+e.width/2,e.y+e.height/2];return n?{x:r(e.x,e.width,t.x),y:t.y>i?e.y+e.height:e.y}:{x:t.x>o?e.x+e.width:e.x,y:r(e.y,e.height,t.y)}}function Bt(e){let t=af[e.layoutOptions?.["elk.direction"]]??"TB",n=t==="TB"||t==="BT",r=Bi(e),o=new mr.Graph({compound:!0,multigraph:!0});o.setGraph({rankdir:t,nodesep:Number(e.layoutOptions?.["elk.spacing.nodeNode"]??28),ranksep:Number(e.layoutOptions?.["elk.layered.spacing.nodeNodeBetweenLayers"]??48),edgesep:12,marginx:r.left,marginy:r.top});let i=new Map,s=[],a=b=>{for(let m of b.children??[])i.set(m.id,m),o.setNode(m.id,m.children?.length?{}:{width:m.width,height:m.height}),b!==e&&o.setParent(m.id,b.id),a(m);for(let m of b.edges??[])s.push([m,b])};a(e);let c=new Map;for(let[b]of s)if(b.id.endsWith("_internal")){let[m,C]=[b.sources[0],b.targets[0]];/_(in|out)_\d+$/.test(m)?c.set(m,C):c.set(C,m)}let l=b=>{let m=o.children(b);return m.length?l(m[0]):b},d=b=>l(c.get(b)??b),f=s.filter(([b])=>!b.id.endsWith("_internal"));for(let[b]of f){let m=b.labels?.[0],C=m?.layoutOptions?.["elk.edgeLabels.inline"]==="true"?"c":"r";o.setEdge(d(b.sources[0]),d(b.targets[0]),{width:m?.width??0,height:m?.height??0,labelpos:C},b.id)}vi(o);let u=new Map(o.nodes().map(b=>{let m=o.node(b);return[b,{x:m.x-m.width/2,y:m.y-m.height/2,width:m.width,height:m.height,group:o.children(b).length>0}]})),h=new Map(f.map(([b])=>{let m=o.edge(d(b.sources[0]),d(b.targets[0]),b.id);return[b,{points:m.points.map(C=>({...C})),label:{x:m.x,y:m.y}}]})),A=(b,m,C)=>{let M=b==="x"?"width":"height";for(let v of u.values())v[b]>=m||!v.group&&v[b]+v[M]/2>=m?v[b]+=C:v.group&&v[b]+v[M]>m&&(v[M]+=C);for(let{points:v,label:I}of h.values())for(let p of[...v,I])p[b]>=m&&(p[b]+=C)},x=b=>{let m=o.children(b);if(m.forEach(x),!m.length)return;let C=Bi(i.get(b)),M=u.get(b),v=()=>{let D=m.map($=>u.get($));return{x:Math.min(...D.map($=>$.x)),y:Math.min(...D.map($=>$.y)),right:Math.max(...D.map($=>$.x+$.width)),bottom:Math.max(...D.map($=>$.y+$.height))}},I=Math.max(C.top,cf+8)-(v().y-M.y);I>0&&A("y",M.y+.5,I);let p=C.left-(v().x-M.x);p>0&&A("x",M.x+.5,p);let S=v().bottom+C.bottom-(M.y+M.height);S>0&&A("y",M.y+M.height-.5,S);let B=v().right+C.right-(M.x+M.width);B>0&&A("x",M.x+M.width-.5,B)};for(let b of o.children())x(b);let w=new Map([[e,{x:0,y:0}]]),g=(b,m)=>{for(let C of b.children??[]){let M=u.get(C.id);Object.assign(C,{x:M.x-m.x,y:M.y-m.y,width:M.width,height:M.height}),w.set(C,M),g(C,M)}};g(e,{x:0,y:0});for(let[b,m]of f){let C=d(b.sources[0]),M=d(b.targets[0]),{points:v,label:I}=h.get(b),p=v.slice(1,-1),[S,B]=[u.get(C),u.get(M)],D=k=>({x:k.x+k.width/2,y:k.y+k.height/2}),$=C===M?v:df([$i(S,p[0]??D(B),n),...p,$i(B,p.at(-1)??D(S),n)],n),L=!c.has(b.sources[0])&&b.sources[0]!==C&&u.get(b.sources[0]),W=!c.has(b.targets[0])&&b.targets[0]!==M&&u.get(b.targets[0]);W&&($=Di($,W)),L&&($=Di($.reverse(),L).reverse());let T=w.get(m);b.sections=[{startPoint:{x:$[0].x-T.x,y:$[0].y-T.y},endPoint:{x:$.at(-1).x-T.x,y:$.at(-1).y-T.y},bendPoints:$.slice(1,-1).map(k=>({x:k.x-T.x,y:k.y-T.y}))}];let j=b.labels?.[0];j&&Object.assign(j,{x:I.x-j.width/2-T.x,y:I.y-j.height/2-T.y})}let y=[...u.values()];return e.width=Math.max(...y.map(b=>b.x+b.width))+r.right,e.height=Math.max(...y.map(b=>b.y+b.height))+r.bottom,e}function Er(e,t,n){if(e.length<2||t.shape==="rectangle"||t.shape==="rounded"||t.shape==="stadium")return e;let r=[...e];if(t.shape==="diamond")if(n)r[0]=Ri(e[0],e[1],t);else{let o=e.length-1;r[o]=Ri(e[o],e[o-1],t)}return r}function Ri(e,t,n){let r=n.x+n.width/2,o=n.y+n.height/2,i=n.width/2,s=n.height/2,a={x:r,y:n.y},c={x:n.x+n.width,y:o},l={x:r,y:n.y+n.height},d={x:n.x,y:o},f=e.x-t.x,u=e.y-t.y;if(Math.abs(f)<Math.abs(u)){let A=e.x;return u>0?A<=r?pn(A,d,a)??a:pn(A,a,c)??a:A<=r?pn(A,l,d)??l:pn(A,c,l)??l}else{let A=e.y;return f>0?A<=o?mn(A,a,d)??d:mn(A,d,l)??d:A<=o?mn(A,a,c)??c:mn(A,c,l)??c}}function mn(e,t,n){let r=n.y-t.y;if(Math.abs(r)<.001)return null;let o=(e-t.y)/r;return o<0||o>1?null:{x:t.x+o*(n.x-t.x),y:e}}function pn(e,t,n){let r=n.x-t.x;if(Math.abs(r)<.001)return null;let o=(e-t.x)/r;if(o<0||o>1)return null;let i=t.y+o*(n.y-t.y);return{x:e,y:i}}var Ot={font:"Inter",padding:40,nodeSpacing:28,layerSpacing:48,mergeEdges:!0,thoroughness:3};function Wi(e){switch(e){case"LR":return"RIGHT";case"RL":return"LEFT";case"BT":return"UP";case"TD":case"TB":default:return"DOWN"}}function Ni(e,t,n){let r=Le(t,Y.nodeLabel,O.nodeLabel),o=r.width+kt.horizontal*2,i=r.height+kt.vertical*2;if(n==="diamond"){let s=Math.max(o,i)+kt.diamondExtra;o=s,i=s}if(n==="circle"||n==="doublecircle"){let s=Math.ceil(Math.sqrt(o*o+i*i))+8;o=n==="doublecircle"?s+12:s,i=o}return n==="hexagon"&&(o+=kt.horizontal),(n==="trapezoid"||n==="trapezoid-alt")&&(o+=kt.horizontal),n==="asymmetric"&&(o+=12),n==="cylinder"&&(i+=14),n==="state-start"||n==="state-end"?{width:28,height:28}:(o=Math.max(o,60),i=Math.max(i,36),{width:o,height:i})}function ff(e,t){let n=new Set,r=new Set;for(let d of e.subgraphs)r.add(d.id),Yi(d,n,r);let o=uf(e.subgraphs),i=new Map;i.set(null,[]);let s=[];for(let d=0;d<e.edges.length;d++){let f=e.edges[d],u=o.get(f.source),h=o.get(f.target);u&&u===h?(i.has(u)||i.set(u,[]),i.get(u).push({index:d,edge:f})):!u&&!h?i.get(null).push({index:d,edge:f}):s.push({index:d,edge:f,sourceSubgraph:u,targetSubgraph:h})}let a=e.subgraphs.some(d=>d.direction!==void 0),c={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":Wi(e.direction),"elk.spacing.nodeNode":String(t.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing),"elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"12","elk.padding":`[top=${t.padding},left=${t.padding},bottom=${t.padding},right=${t.padding}]`,"elk.edgeRouting":"ORTHOGONAL","elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","elk.contentAlignment":"H_CENTER V_CENTER","elk.layered.thoroughness":String(Ot.thoroughness),"elk.layered.highDegreeNodes.treatment":"true","elk.layered.highDegreeNodes.threshold":"8","elk.layered.compaction.postCompaction.strategy":"LEFT_RIGHT_CONSTRAINT_LOCKING","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.wrapping.strategy":"OFF","elk.hierarchyHandling":a?"SEPARATE":"INCLUDE_CHILDREN"},children:[],edges:[]},l=new Map;if(a)for(let{index:d,edge:f,sourceSubgraph:u,targetSubgraph:h}of s){if(u){let A=`${u}_out_${d}`;l.has(u)||l.set(u,[]),l.get(u).push({portId:A,edgeIndex:d,direction:"outgoing",internalNodeId:f.source})}if(h){let A=`${h}_in_${d}`;l.has(h)||l.set(h,[]),l.get(h).push({portId:A,edgeIndex:d,direction:"incoming",internalNodeId:f.target})}}for(let[d,f]of e.nodes)if(!n.has(d)&&!r.has(d)){let u=Ni(d,f.label,f.shape);c.children.push({id:d,width:u.width,height:u.height,labels:[{text:f.label}]})}for(let d of e.subgraphs)c.children.push(Fi(d,e,t,i,l));for(let{index:d,edge:f}of i.get(null)){let u={id:`e${d}`,sources:[f.source],targets:[f.target]};if(f.label){let h=Le(f.label,Y.edgeLabel,O.edgeLabel);u.labels=[{text:f.label,width:h.width+8,height:h.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}c.edges.push(u)}for(let{index:d,edge:f,sourceSubgraph:u,targetSubgraph:h}of s){let A={id:`e${d}`,sources:a&&u?[`${u}_out_${d}`]:[f.source],targets:a&&h?[`${h}_in_${d}`]:[f.target]};if(f.label){let x=Le(f.label,Y.edgeLabel,O.edgeLabel);A.labels=[{text:f.label,width:x.width+8,height:x.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}c.edges.push(A)}return c}function Fi(e,t,n,r,o){let i={"elk.algorithm":"layered","elk.padding":"[top=44,left=16,bottom=16,right=16]","elk.edgeRouting":"ORTHOGONAL","elk.contentAlignment":"H_CENTER V_CENTER","elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"12","elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","elk.layered.spacing.nodeNodeBetweenLayers":String(n.layerSpacing),"elk.spacing.nodeNode":String(n.nodeSpacing)};e.direction&&(i["elk.direction"]=Wi(e.direction));let s={id:e.id,layoutOptions:i,labels:e.label?[{text:e.label}]:void 0,children:[],edges:[]},a=o.get(e.id)??[];a.length>0&&(s.ports=a.map(l=>({id:l.portId})));for(let l of e.nodeIds){let d=t.nodes.get(l);if(d){let f=Ni(l,d.label,d.shape);s.children.push({id:l,width:f.width,height:f.height,labels:[{text:d.label}]})}}for(let l of e.children)s.children.push(Fi(l,t,n,r,o));let c=r.get(e.id)??[];for(let{index:l,edge:d}of c){let f={id:`e${l}`,sources:[d.source],targets:[d.target]};if(d.label){let u=Le(d.label,Y.edgeLabel,O.edgeLabel);f.labels=[{text:d.label,width:u.width+8,height:u.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}s.edges.push(f)}for(let l of a){let d=`e${l.edgeIndex}_internal`,f=l.direction==="incoming"?{id:d,sources:[l.portId],targets:[l.internalNodeId]}:{id:d,sources:[l.internalNodeId],targets:[l.portId]};s.edges.push(f)}return s}function Yi(e,t,n){for(let r of e.nodeIds)t.add(r);for(let r of e.children)n.add(r.id),Yi(r,t,n)}function uf(e){let t=new Map;function n(r){for(let o of r.nodeIds)t.set(o,r.id);for(let o of r.children)n(o)}for(let r of e)n(r);return t}function Hi(e){let t=[];for(let n of e)t.push({x:n.x,y:n.y,right:n.x+n.width,bottom:n.y+n.height}),t.push(...Hi(n.children));return t}function hf(e,t,n=!1){let r=[],o=[],i=[],s=new Set;for(let A of t.subgraphs)Ki(A,s);Mr(e,t,s,r,i,0,0);let a=Hi(i),c=a.length>0?{leftX:Math.min(...a.map(A=>A.x))-20,rightX:Math.max(...a.map(A=>A.right))+20}:void 0;Af(e,t,o,0,0,c),pf(r,o,t.direction),n&&bf(o,r,i,t.direction);let l=new Map(r.map(A=>[A.id,A]));for(let A of o){let x=l.get(A.source),w=l.get(A.target);x&&(A.points=Er(A.points,x,!0)),w&&(A.points=Er(A.points,w,!1))}let d=e.width??800,f=e.height??600,u=Ze.width,h=Ot.padding;for(let A of o){for(let x of A.points)d=Math.max(d,x.x+u+h),f=Math.max(f,x.y+u+h);A.labelPosition&&(d=Math.max(d,A.labelPosition.x+60+h),f=Math.max(f,A.labelPosition.y+20+h))}return{width:d,height:f,nodes:r,edges:o,groups:i}}function Mr(e,t,n,r,o,i,s){if(e.children)for(let a of e.children){let c=(a.x??0)+i,l=(a.y??0)+s,d=a.width??0,f=a.height??0;if(n.has(a.id)){let u=[];Mr(a,t,n,r,u,c,l);let h=Qi(t.subgraphs,a.id);o.push({id:a.id,label:h?.label??"",x:c,y:l,width:d,height:f,children:u})}else{let u=t.nodes.get(a.id);if(u){let h=xf(a.id,t);r.push({id:a.id,label:u.label,shape:u.shape,x:c,y:l,width:d,height:f,inlineStyle:h})}a.children&&a.children.length>0&&Mr(a,t,n,r,o,c,l)}}}function Gi(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];let t=0;for(let r=1;r<e.length;r++){let o=e[r].x-e[r-1].x,i=e[r].y-e[r-1].y;t+=Math.sqrt(o*o+i*i)}let n=t/2;for(let r=1;r<e.length;r++){let o=e[r].x-e[r-1].x,i=e[r].y-e[r-1].y,s=Math.sqrt(o*o+i*i);if(n<=s){let a=n/s;return{x:e[r-1].x+a*o,y:e[r-1].y+a*i}}n-=s}return e[e.length-1]}function Af(e,t,n,r,o,i){let s=new Map;Ti(e,s,0,0);let a=0;for(let[c,l]of s){let d=t.edges[c];if(!d)continue;let f=[];l.outgoing&&l.outgoing.points.length>0&&f.push(...l.outgoing.points),l.external&&l.external.points.length>0&&(f.length>0?f.push(...l.external.points.slice(1)):f.push(...l.external.points)),l.incoming&&l.incoming.points.length>0&&(f.length>0?f.push(...l.incoming.points.slice(1)):f.push(...l.incoming.points));let u;d.label&&f.length>=2&&(u=l.external?.labelPosition??Gi(f));let h=gf(f,i,a);h!==f&&a++,d.label&&h!==f&&h.length>=2&&(u=Gi(h)),n.push({source:d.source,target:d.target,label:d.label,style:d.style,hasArrowStart:d.hasArrowStart,hasArrowEnd:d.hasArrowEnd,points:h,labelPosition:u,inlineStyle:mf(c,t)})}}function gf(e,t,n=0){if(e.length<2)return e;let r=!1;for(let s=1;s<e.length;s++){let a=Math.abs(e[s].x-e[s-1].x),c=Math.abs(e[s].y-e[s-1].y);if(a>1&&c>1){r=!0;break}}if(!r)return e;let o=12,i=[e[0]];for(let s=1;s<e.length;s++){let a=i[i.length-1],c=e[s],l=Math.abs(c.x-a.x),d=Math.abs(c.y-a.y);if(l>1&&d>1)if(t){let f=n%2===0,u=Math.floor(n/2)*o,h=f?t.rightX+u:t.leftX-u;i.push({x:h,y:a.y}),i.push({x:h,y:c.y})}else{let f=(a.y+c.y)/2;i.push({x:a.x,y:f}),i.push({x:c.x,y:f})}i.push(c)}return i}function Ti(e,t,n,r){if(e.edges)for(let o of e.edges){let i=o.id.endsWith("_internal"),s=parseInt(o.id.substring(1),10);if(isNaN(s))continue;let a=[];if(o.sections&&o.sections.length>0){let d=o.sections[0];if(a.push({x:d.startPoint.x+n,y:d.startPoint.y+r}),d.bendPoints)for(let f of d.bendPoints)a.push({x:f.x+n,y:f.y+r});a.push({x:d.endPoint.x+n,y:d.endPoint.y+r})}let c;if(o.labels&&o.labels.length>0){let d=o.labels[0];d.x!=null&&d.y!=null&&(c={x:d.x+(d.width??0)/2+n,y:d.y+(d.height??0)/2+r})}t.has(s)||t.set(s,{});let l=t.get(s);if(i){let d=o.sources?.[0]??"",f=o.targets?.[0]??"",u=d.includes("_in_")||d.includes("_out_"),h=f.includes("_in_")||f.includes("_out_");u?l.incoming={edgeIndex:s,isInternal:i,points:a,labelPosition:c}:h&&(l.outgoing={edgeIndex:s,isInternal:i,points:a,labelPosition:c})}else l.external={edgeIndex:s,isInternal:i,points:a,labelPosition:c}}if(e.children)for(let o of e.children)Ti(o,t,n+(o.x??0),r+(o.y??0))}function Qi(e,t){for(let n of e){if(n.id===t)return n;let r=Qi(n.children,t);if(r)return r}}function Ki(e,t){t.add(e.id);for(let n of e.children)Ki(n,t)}function xf(e,t){let n,r=t.classAssignments.get(e);if(r){let i=t.classDefs.get(r);i&&(n={...i})}let o=t.nodeStyles.get(e);return o&&(n=n?{...n,...o}:{...o}),n}function mf(e,t){let n,r=t.linkStyles.get("default");r&&(n={...r});let o=t.linkStyles.get(e);return o&&(n=n?{...n,...o}:{...o}),n}function pf(e,t,n){if(e.length===0)return;let r=n==="LR"||n==="RL",o=new Set;for(let f of t)o.add(`${f.source}:${f.target}`),o.add(`${f.target}:${f.source}`);let i=Ot.layerSpacing*.6,s=[...e].sort((f,u)=>r?f.x-u.x:f.y-u.y),a=[],c=[s[0]];for(let f=1;f<s.length;f++){let u=r?s[f].x:s[f].y,h=r?s[f-1].x:s[f-1].y,A=u-h,x=c.some(w=>o.has(`${w.id}:${s[f].id}`));A<=i&&!x?c.push(s[f]):(a.push(c),c=[s[f]])}a.push(c);let l=new Map;for(let f of a){if(f.length<=1)continue;let u=f.map(w=>r?w.x:w.y),h=Math.min(...u),A=Math.max(...u);if(A-h<=1)continue;let x=(h+A)/2;for(let w of f){let g=r?w.x:w.y,y=x-g;Math.abs(y)>.5&&(r?w.x=x:w.y=x,l.set(w.id,y))}}if(l.size===0)return;let d=new Map(e.map(f=>[f.id,f]));for(let f of t){if(f.points.length<2)continue;let u=l.get(f.source),h=l.get(f.target);if(u!=null){let A=f.points[0];r?(A.x+=u,f.points.length>1&&f.points[1].x===A.x-u&&(f.points[1].x+=u)):(A.y+=u,f.points.length>1&&f.points[1].y===A.y-u&&(f.points[1].y+=u))}if(h!=null){let A=f.points[f.points.length-1];if(r){if(A.x+=h,f.points.length>1){let x=f.points[f.points.length-2];x.x===A.x-h&&(x.x+=h)}}else if(A.y+=h,f.points.length>1){let x=f.points[f.points.length-2];x.y===A.y-h&&(x.y+=h)}}}}function kr(e,t,n){let r=[];for(let o of n)e>=o.x&&e<=o.x+o.width&&t>=o.y&&t<=o.y+o.height&&(r.push(o),r.push(...kr(e,t,o.children)));return r}function bn(e,t,n,r,o){let s=o==="LR",a=o==="RL",c=o==="BT",l=s||a,d=new Set(kr(t,n,r).map(x=>x.id)),A=kr(l?e:t,l?n:e,r).find(x=>!d.has(x.id));return A?s?A.x-12:a?A.x+A.width+12:c?A.y+A.height+12:A.y-12:e}function bf(e,t,n,r){let o=new Map(t.map(u=>[u.id,u])),i=new Set,s=r==="LR",a=r==="RL",c=r==="BT",l=s||a,d=new Map;for(let u of e)u.source!==u.target&&(d.has(u.source)||d.set(u.source,[]),d.get(u.source).push(u));for(let[u,h]of d){if(h.length<2)continue;let A=h[0].style;if(h.some(m=>m.label||m.style!==A))continue;let x=o.get(u);if(!x)continue;let w=h.filter(m=>{let C=o.get(m.target);return C?s?C.x>x.x+x.width:a?C.x+C.width<x.x:c?C.y+C.height<x.y:C.y>x.y+x.height:!1});if(w.length<2)continue;let g=w.map(m=>({edge:m,node:o.get(m.target)})),y=x.x+x.width/2,b=x.y+x.height/2;if(l){let m=s?x.x+x.width:x.x,C=b,M=s?Math.min(...g.map(I=>I.node.x)):Math.max(...g.map(I=>I.node.x+I.node.width)),v=m+(M-m)/2;v=bn(v,y,b,n,r);for(let{edge:I,node:p}of g){let S=s?p.x:p.x+p.width,B=p.y+p.height/2;I.points=[{x:m,y:C},{x:v,y:C},{x:v,y:B},{x:S,y:B}],i.add(I)}}else{let m=y,C=c?x.y:x.y+x.height,M=c?Math.max(...g.map(I=>I.node.y+I.node.height)):Math.min(...g.map(I=>I.node.y)),v=C+(M-C)/2;v=bn(v,y,b,n,r);for(let{edge:I,node:p}of g){let S=p.x+p.width/2,B=c?p.y+p.height:p.y;I.points=[{x:m,y:C},{x:m,y:v},{x:S,y:v},{x:S,y:B}],i.add(I)}}}let f=new Map;for(let u of e)i.has(u)||u.source===u.target||(f.has(u.target)||f.set(u.target,[]),f.get(u.target).push(u));for(let[u,h]of f){if(h.length<2)continue;let A=h[0].style;if(h.some(m=>m.label||m.style!==A))continue;let x=o.get(u);if(!x)continue;let w=h.filter(m=>{let C=o.get(m.source);return C?s?C.x+C.width<x.x:a?C.x>x.x+x.width:c?C.y>x.y+x.height:C.y+C.height<x.y:!1});if(w.length<2)continue;let g=w.map(m=>({edge:m,node:o.get(m.source)})),y=x.x+x.width/2,b=x.y+x.height/2;if(l){let m=s?x.x:x.x+x.width,C=b,M=s?Math.max(...g.map(I=>I.node.x+I.node.width)):Math.min(...g.map(I=>I.node.x)),v=M+(m-M)/2;v=bn(v,y,b,n,r);for(let{edge:I,node:p}of g){let S=s?p.x+p.width:p.x,B=p.y+p.height/2;I.points=[{x:S,y:B},{x:v,y:B},{x:v,y:C},{x:m,y:C}]}}else{let m=y,C=c?x.y+x.height:x.y,M=c?Math.min(...g.map(I=>I.node.y)):Math.max(...g.map(I=>I.node.y+I.node.height)),v=M+(C-M)/2;v=bn(v,y,b,n,r);for(let{edge:I,node:p}of g){let S=p.x+p.width/2,B=c?p.y:p.y+p.height;I.points=[{x:S,y:B},{x:S,y:v},{x:m,y:v},{x:m,y:C}]}}}}function vr(e,t={}){let n={...Ot,...t},r=ff(e,n),o=Bt(r);return hf(o,e,Ot.mergeEdges)}function Xi(e,t,n="Inter",r=!1){let o=[];o.push(je(e.width,e.height,t,r)),o.push(Je(n,!1)),o.push("<defs>"),o.push(yf());let i=new Set;for(let s of e.edges)s.inlineStyle?.stroke&&i.add(s.inlineStyle.stroke);for(let s of i)o.push(wf(s));o.push("</defs>");for(let s of e.groups)o.push(Ji(s,n));for(let s of e.edges)o.push(Cf(s));for(let s of e.edges)s.label&&o.push(Ef(s,n));for(let s of e.nodes)o.push(kf(s,n));return o.push("</svg>"),o.join(`
24`)}function yf(){let e=Ze.width,t=Ze.height,n='fill="var(--_arrow)" stroke="var(--_arrow)" stroke-width="0.75" stroke-linejoin="round"',r=e-1;return` <marker id="arrowhead" markerWidth="${e}" markerHeight="${t}" refX="${r}" refY="${t/2}" orient="auto">
25 <polygon points="0 0, ${e} ${t/2}, 0 ${t}" ${n} />
26 </marker>
27 <marker id="arrowhead-start" markerWidth="${e}" markerHeight="${t}" refX="1" refY="${t/2}" orient="auto-start-reverse">
28 <polygon points="${e} 0, 0 ${t/2}, ${e} ${t}" ${n} />
29 </marker>`}function wf(e){let t=Ze.width,n=Ze.height,r=ye(e),o=`fill="${r}" stroke="${r}" stroke-width="0.75" stroke-linejoin="round"`,i=t-1,s=Pi(e);return` <marker id="arrowhead-${s}" markerWidth="${t}" markerHeight="${n}" refX="${i}" refY="${n/2}" orient="auto">
30 <polygon points="0 0, ${t} ${n/2}, 0 ${n}" ${o} />
31 </marker>
32 <marker id="arrowhead-start-${s}" markerWidth="${t}" markerHeight="${n}" refX="1" refY="${n/2}" orient="auto-start-reverse">
33 <polygon points="${t} 0, 0 ${n/2}, ${t} ${n}" ${o} />
34 </marker>`}function Pi(e){return e.replace(/[^a-zA-Z0-9]/g,t=>t.charCodeAt(0).toString(16))}function Ji(e,t){let n=Y.groupHeader+16,r=[];r.push(`<g class="subgraph" data-id="${ye(e.id)}" data-label="${ye(e.label)}">`),r.push(` <rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="0" ry="0" fill="var(--_group-fill)" stroke="var(--_node-stroke)" stroke-width="${Z.outerBox}" />`),r.push(` <rect x="${e.x}" y="${e.y}" width="${e.width}" height="${n}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${Z.outerBox}" />`),r.push(" "+de(e.label,e.x+12,e.y+n/2,Y.groupHeader,`font-size="${Y.groupHeader}" font-weight="${O.groupHeader}" fill="var(--_text-sec)"`));for(let o of e.children)r.push(Ji(o,t));return r.push("</g>"),r.join(`
35`)}function Cf(e){if(e.points.length<2)return"";let t=If(e.points),n=e.style==="dotted"?' stroke-dasharray="4 4"':"",r=e.style==="thick"?Z.connector*2:Z.connector,o=ye(e.inlineStyle?.stroke??"var(--_line)"),i=ye(e.inlineStyle?.["stroke-width"]??String(r)),s=e.inlineStyle?.stroke?`-${Pi(e.inlineStyle.stroke)}`:"",a="";e.hasArrowEnd&&(a+=` marker-end="url(#arrowhead${s})"`),e.hasArrowStart&&(a+=` marker-start="url(#arrowhead-start${s})"`);let c=['class="edge"',`data-from="${ye(e.source)}"`,`data-to="${ye(e.target)}"`,`data-style="${e.style}"`,`data-arrow-start="${e.hasArrowStart}"`,`data-arrow-end="${e.hasArrowEnd}"`];return e.label&&c.push(`data-label="${ye(e.label)}"`),`<polyline ${c.join(" ")} points="${t}" fill="none" stroke="${o}" stroke-width="${i}"${n}${a} />`}function If(e){return e.map(t=>`${t.x},${t.y}`).join(" ")}function Ef(e,t){let n=e.labelPosition??Mf(e.points),r=e.label,o=8,i=Le(r,Y.edgeLabel,O.edgeLabel),s=mo(r,n.x,n.y,i.width,i.height,Y.edgeLabel,o,`text-anchor="middle" font-size="${Y.edgeLabel}" font-weight="${O.edgeLabel}" fill="var(--_text-sec)"`,'rx="2" ry="2" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="1"');return`<g class="edge-label" data-from="${ye(e.source)}" data-to="${ye(e.target)}" data-label="${ye(r)}">
36 ${s.replace(/\n/g,`
37 `)}
38</g>`}function Mf(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];let t=0;for(let r=1;r<e.length;r++)t+=Oi(e[r-1],e[r]);let n=t/2;for(let r=1;r<e.length;r++){let o=Oi(e[r-1],e[r]);if(n<=o){let i=n/o;return{x:e[r-1].x+i*(e[r].x-e[r-1].x),y:e[r-1].y+i*(e[r].y-e[r-1].y)}}n-=o}return e[e.length-1]}function Oi(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}function kf(e,t){let n=vf(e),r=Kf(e,t),o=[];return o.push(`<g class="node" data-id="${ye(e.id)}" data-label="${ye(e.label)}" data-shape="${e.shape}">`),o.push(` ${n.replace(/\n/g,`
39 `)}`),r&&o.push(` ${r.replace(/\n/g,`
40 `)}`),o.push("</g>"),o.join(`
41`)}function vf(e){let{x:t,y:n,width:r,height:o,shape:i,inlineStyle:s}=e,a=ye(s?.fill??"var(--_node-fill)"),c=ye(s?.stroke??"var(--_node-stroke)"),l=ye(s?.["stroke-width"]??String(Z.innerBox));switch(i){case"diamond":return Lf(t,n,r,o,a,c,l);case"rounded":return Bf(t,n,r,o,a,c,l);case"stadium":return Df(t,n,r,o,a,c,l);case"circle":return $f(t,n,r,o,a,c,l);case"subroutine":return Rf(t,n,r,o,a,c,l);case"doublecircle":return Gf(t,n,r,o,a,c,l);case"hexagon":return Wf(t,n,r,o,a,c,l);case"cylinder":return Nf(t,n,r,o,a,c,l);case"asymmetric":return Ff(t,n,r,o,a,c,l);case"trapezoid":return Yf(t,n,r,o,a,c,l);case"trapezoid-alt":return Hf(t,n,r,o,a,c,l);case"state-start":return Tf(t,n,r,o);case"state-end":return Qf(t,n,r,o);case"rectangle":default:return Sf(t,n,r,o,a,c,l)}}function Sf(e,t,n,r,o,i,s){return`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="0" ry="0" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Bf(e,t,n,r,o,i,s){return`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="6" ry="6" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Df(e,t,n,r,o,i,s){let a=r/2;return`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="${a}" ry="${a}" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function $f(e,t,n,r,o,i,s){let a=e+n/2,c=t+r/2,l=Math.min(n,r)/2;return`<circle cx="${a}" cy="${c}" r="${l}" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Lf(e,t,n,r,o,i,s){let a=e+n/2,c=t+r/2,l=n/2,d=r/2;return`<polygon points="${[`${a},${c-d}`,`${a+l},${c}`,`${a},${c+d}`,`${a-l},${c}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Rf(e,t,n,r,o,i,s){return`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="0" ry="0" fill="${o}" stroke="${i}" stroke-width="${s}" />
42<line x1="${e+8}" y1="${t}" x2="${e+8}" y2="${t+r}" stroke="${i}" stroke-width="${s}" />
43<line x1="${e+n-8}" y1="${t}" x2="${e+n-8}" y2="${t+r}" stroke="${i}" stroke-width="${s}" />`}function Gf(e,t,n,r,o,i,s){let a=e+n/2,c=t+r/2,l=Math.min(n,r)/2,d=l-5;return`<circle cx="${a}" cy="${c}" r="${l}" fill="${o}" stroke="${i}" stroke-width="${s}" />
44<circle cx="${a}" cy="${c}" r="${d}" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Wf(e,t,n,r,o,i,s){let a=r/4;return`<polygon points="${[`${e+a},${t}`,`${e+n-a},${t}`,`${e+n},${t+r/2}`,`${e+n-a},${t+r}`,`${e+a},${t+r}`,`${e},${t+r/2}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Nf(e,t,n,r,o,i,s){let c=e+n/2,l=t+7,d=r-14;return`<rect x="${e}" y="${l}" width="${n}" height="${d}" fill="${o}" stroke="none" />
45<line x1="${e}" y1="${l}" x2="${e}" y2="${l+d}" stroke="${i}" stroke-width="${s}" />
46<line x1="${e+n}" y1="${l}" x2="${e+n}" y2="${l+d}" stroke="${i}" stroke-width="${s}" />
47<ellipse cx="${c}" cy="${t+r-7}" rx="${n/2}" ry="7" fill="${o}" stroke="${i}" stroke-width="${s}" />
48<ellipse cx="${c}" cy="${l}" rx="${n/2}" ry="7" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Ff(e,t,n,r,o,i,s){return`<polygon points="${[`${e+12},${t}`,`${e+n},${t}`,`${e+n},${t+r}`,`${e+12},${t+r}`,`${e},${t+r/2}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Yf(e,t,n,r,o,i,s){let a=n*.15;return`<polygon points="${[`${e+a},${t}`,`${e+n-a},${t}`,`${e+n},${t+r}`,`${e},${t+r}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Hf(e,t,n,r,o,i,s){let a=n*.15;return`<polygon points="${[`${e},${t}`,`${e+n},${t}`,`${e+n-a},${t+r}`,`${e+a},${t+r}`].join(" ")}" fill="${o}" stroke="${i}" stroke-width="${s}" />`}function Tf(e,t,n,r){let o=e+n/2,i=t+r/2,s=Math.min(n,r)/2-2;return`<circle cx="${o}" cy="${i}" r="${s}" fill="var(--_text)" stroke="none" />`}function Qf(e,t,n,r){let o=e+n/2,i=t+r/2,s=Math.min(n,r)/2-2,a=s-4;return`<circle cx="${o}" cy="${i}" r="${s}" fill="none" stroke="var(--_text)" stroke-width="${Z.innerBox*2}" />
49<circle cx="${o}" cy="${i}" r="${a}" fill="var(--_text)" stroke="none" />`}function Kf(e,t){if((e.shape==="state-start"||e.shape==="state-end")&&!e.label)return"";let n=e.x+e.width/2,r=e.y+e.height/2,o=ye(e.inlineStyle?.color??"var(--_text)");return de(e.label,n,r,Y.nodeLabel,`text-anchor="middle" font-size="${Y.nodeLabel}" font-weight="${O.nodeLabel}" fill="${o}"`)}function ye(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var X={padding:30,actorGap:140,actorHeight:40,actorPadX:16,headerGap:20,messageRowHeight:40,selfMessageHeight:30,activationWidth:10,blockPadX:10,blockPadTop:40,blockPadBottom:8,blockHeaderExtra:28,dividerExtra:24,noteWidth:60,notePadX:12,notePadY:6,noteGap:10};function ji(e,t={}){if(e.actors.length===0)return{width:0,height:0,actors:[],lifelines:[],messages:[],activations:[],blocks:[],notes:[]};let n=e.actors.map(p=>{let S=te(p.label,Y.nodeLabel,O.nodeLabel);return Math.max(S+X.actorPadX*2,80)}),r=[],o=X.padding+n[0]/2;for(let p=0;p<e.actors.length;p++){if(p>0){let S=Math.max(X.actorGap,(n[p-1]+n[p])/2+40);o+=S}r.push(o)}let i=new Map;for(let p=0;p<e.actors.length;p++)i.set(e.actors[p].id,p);let s=X.padding,a=e.actors.map((p,S)=>({id:p.id,label:p.label,type:p.type,x:r[S],y:s,width:n[S],height:X.actorHeight})),c=s+X.actorHeight+X.headerGap,l=[],d=new Map;for(let p of e.blocks){let S=d.get(p.startIndex)??0;d.set(p.startIndex,Math.max(S,X.blockHeaderExtra));for(let B of p.dividers){let D=d.get(B.index)??0;d.set(B.index,Math.max(D,X.dividerExtra))}}let f=new Map;for(let p of e.notes){let S=f.get(p.afterIndex)??[];S.push(p),f.set(p.afterIndex,S)}let u=[],h=new Map,A=[],x=4;for(let p=0;p<e.messages.length;p++){let S=e.messages[p],B=i.get(S.from)??0,D=i.get(S.to)??0,$=S.from===S.to,L=d.get(p)??0;L>0&&(c+=L);let W=r[B],T=r[D];if(l.push({from:S.from,to:S.to,label:S.label,lineStyle:S.lineStyle,arrowHead:S.arrowHead,x1:W,x2:T,y:c,isSelf:$}),S.activate){h.has(S.to)||h.set(S.to,[]);let k=h.get(S.to),R=k.length;k.push({startY:c,depth:R})}if(S.deactivate){let k=h.get(S.from);if(k&&k.length>0){let{startY:R,depth:N}=k.pop(),K=i.get(S.from)??0,P=N*x;A.push({actorId:S.from,x:r[K]-X.activationWidth/2+P,topY:R,bottomY:c,width:X.activationWidth})}}c+=$?X.selfMessageHeight+X.messageRowHeight:X.messageRowHeight;let j=f.get(p);if(j&&j.length>0){let k=$?X.selfMessageHeight:0,R=l[p].y+k+8;for(let N of j){let K=Math.max(X.noteWidth,te(N.text,Y.edgeLabel,O.edgeLabel)+X.notePadX*2),P=Y.edgeLabel+X.notePadY*2,F=i.get(N.actorIds[0]??"")??0,J;if(N.position==="left")J=r[F]-n[F]/2-K-X.noteGap;else if(N.position==="right")J=r[F]+n[F]/2+X.noteGap;else if(N.actorIds.length>1){let Q=i.get(N.actorIds[N.actorIds.length-1]??"")??F;J=(r[F]+r[Q])/2-K/2}else J=r[F]-K/2;u.push({text:N.text,x:J,y:R,width:K,height:P,position:N.position,actors:N.actorIds}),R+=P+4}c=Math.max(c,R+X.messageRowHeight/2)}}for(let[p,S]of h)for(let{startY:B,depth:D}of S){let $=i.get(p)??0,L=D*x;A.push({actorId:p,x:r[$]-X.activationWidth/2+L,topY:B,bottomY:c-X.messageRowHeight/2,width:X.activationWidth})}let w=e.blocks.map(p=>{let S=l[p.startIndex],B=l[p.endIndex],D=(S?.y??c)-X.blockPadTop,$=(B?.y??c)+X.blockPadBottom+12,L=new Set;for(let N=p.startIndex;N<=p.endIndex;N++){let K=e.messages[N];K&&(L.add(i.get(K.from)??0),L.add(i.get(K.to)??0))}if(L.size===0)for(let N=0;N<e.actors.length;N++)L.add(N);let W=Math.min(...L),T=Math.max(...L),j=r[W]-n[W]/2-X.blockPadX,k=r[T]+n[T]/2+X.blockPadX,R=p.dividers.map(N=>{let K=l[N.index],P=K?.y??c,F=28;if(N.label&&K?.label){let J=`[${N.label}]`,Q=te(J,Y.edgeLabel,O.edgeLabel),ce=j+8,Fe=ce+Q,tt=te(K.label,Y.edgeLabel,O.edgeLabel),Oe=K.isSelf?K.x1+36:(K.x1+K.x2)/2-tt/2,Se=Oe+tt;Fe>Oe&&ce<Se&&(F=36)}return{y:P-F,label:N.label}});return{type:p.type,label:p.label,x:j,y:D,width:k-j,height:$-D,dividers:R}}),g=u,y=c+X.padding,b=X.padding,m=0;for(let p of a)b=Math.min(b,p.x-p.width/2),m=Math.max(m,p.x+p.width/2);for(let p of w)b=Math.min(b,p.x),m=Math.max(m,p.x+p.width);for(let p of g)b=Math.min(b,p.x),m=Math.max(m,p.x+p.width);for(let p of l)if(p.isSelf&&p.label){let D=p.x1+30+8,$=te(p.label,Y.edgeLabel,O.edgeLabel);m=Math.max(m,D+$+8)}let C=b<X.padding?X.padding-b:0;if(C>0){for(let p of a)p.x+=C;for(let p of l)p.x1+=C,p.x2+=C;for(let p of A)p.x+=C;for(let p of w)p.x+=C;for(let p of g)p.x+=C;for(let p=0;p<r.length;p++)r[p]+=C}let M=e.actors.map((p,S)=>({actorId:p.id,x:r[S],topY:s+X.actorHeight,bottomY:y-X.padding})),v=m+C+X.padding,I=y;return{width:Math.max(v,200),height:Math.max(I,100),actors:a,lifelines:M,messages:l,activations:A,blocks:w,notes:g}}function _i(e,t,n="Inter",r=!1){let o=[];o.push(je(e.width,e.height,t,r)),o.push(Je(n,!1)),o.push("<defs>"),o.push(Of()),o.push("</defs>");for(let i of e.blocks)o.push(_f(i));for(let i of e.lifelines)o.push(Pf(i));for(let i of e.activations)o.push(Jf(i));for(let i of e.messages)o.push(jf(i));for(let i of e.notes)o.push(Zf(i));for(let i of e.actors)o.push(Xf(i));return o.push("</svg>"),o.join(`
50`)}function Of(){let e=Ze.width,t=Ze.height;return` <marker id="seq-arrow" markerWidth="${e}" markerHeight="${t}" refX="${e}" refY="${t/2}" orient="auto-start-reverse">
51 <polygon points="0 0, ${e} ${t/2}, 0 ${t}" fill="var(--_arrow)" />
52 </marker>
53 <marker id="seq-arrow-open" markerWidth="${e}" markerHeight="${t}" refX="${e}" refY="${t/2}" orient="auto-start-reverse">
54 <polyline points="0 0, ${e} ${t/2}, 0 ${t}" fill="none" stroke="var(--_arrow)" stroke-width="1" />
55 </marker>`}function Xf(e){let{id:t,x:n,y:r,width:o,height:i,label:s,type:a}=e,c=[];if(c.push(`<g class="actor" data-id="${Qe(t)}" data-label="${Qe(s)}" data-type="${a}">`),a==="actor"){let l=i/24*.9,d=n-12*l,f=r+(i-24*l)/2,u=Z.outerBox/l,h="var(--_line)";c.push(` <g transform="translate(${d},${f}) scale(${l})">
56 <path d="M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" fill="none" stroke="${h}" stroke-width="${u}" />
57 <path d="M15 10C15 11.6569 13.6569 13 12 13C10.3431 13 9 11.6569 9 10C9 8.34315 10.3431 7 12 7C13.6569 7 15 8.34315 15 10Z" fill="none" stroke="${h}" stroke-width="${u}" />
58 <path d="M5.62842 18.3563C7.08963 17.0398 9.39997 16 12 16C14.6 16 16.9104 17.0398 18.3716 18.3563" fill="none" stroke="${h}" stroke-width="${u}" />
59 </g>`),c.push(" "+de(s,n,r+i+14,Y.nodeLabel,`font-size="${Y.nodeLabel}" text-anchor="middle" font-weight="${O.nodeLabel}" fill="var(--_text)"`))}else{let l=n-o/2;c.push(` <rect x="${l}" y="${r}" width="${o}" height="${i}" rx="4" ry="4" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${Z.outerBox}" />`),c.push(" "+de(s,n,r+i/2,Y.nodeLabel,`font-size="${Y.nodeLabel}" text-anchor="middle" font-weight="${O.nodeLabel}" fill="var(--_text)"`))}return c.push("</g>"),c.join(`
60`)}function Pf(e){return`<line class="lifeline" data-actor="${Qe(e.actorId)}" x1="${e.x}" y1="${e.topY}" x2="${e.x}" y2="${e.bottomY}" stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`}function Jf(e){return`<rect class="activation" data-actor="${Qe(e.actorId)}" x="${e.x}" y="${e.topY}" width="${e.width}" height="${e.bottomY-e.topY}" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${Z.innerBox}" />`}function jf(e){let t=[],n=e.lineStyle==="dashed"?' stroke-dasharray="6 4"':"",r=e.arrowHead==="filled"?"seq-arrow":"seq-arrow-open";if(t.push(`<g class="message" data-from="${Qe(e.from)}" data-to="${Qe(e.to)}" data-label="${Qe(e.label)}" data-line-style="${e.lineStyle}" data-arrow-head="${e.arrowHead}" data-self="${e.isSelf}">`),e.isSelf)t.push(` <polyline points="${e.x1},${e.y} ${e.x1+30},${e.y} ${e.x1+30},${e.y+20} ${e.x2},${e.y+20}" fill="none" stroke="var(--_line)" stroke-width="${Z.connector}"${n} marker-end="url(#${r})" />`),t.push(" "+de(e.label,e.x1+30+8,e.y+20/2,Y.edgeLabel,`font-size="${Y.edgeLabel}" text-anchor="start" font-weight="${O.edgeLabel}" fill="var(--_text-muted)"`));else{t.push(` <line x1="${e.x1}" y1="${e.y}" x2="${e.x2}" y2="${e.y}" stroke="var(--_line)" stroke-width="${Z.connector}"${n} marker-end="url(#${r})" />`);let o=(e.x1+e.x2)/2;t.push(" "+de(e.label,o,e.y-10,Y.edgeLabel,`font-size="${Y.edgeLabel}" text-anchor="middle" font-weight="${O.edgeLabel}" fill="var(--_text-muted)"`))}return t.push("</g>"),t.join(`
61`)}function _f(e){let t=[],n=e.label?` data-label="${Qe(e.label)}"`:"";t.push(`<g class="block" data-type="${Qe(e.type)}"${n}>`),t.push(` <rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="0" ry="0" fill="none" stroke="var(--_node-stroke)" stroke-width="${Z.outerBox}" />`);let r=`${e.type}${e.label?` [${e.label}]`:""}`,o=r.split(`
62`)[0],i=te(o,Y.edgeLabel,O.groupHeader)+16,s=18;t.push(` <rect x="${e.x}" y="${e.y}" width="${i}" height="${s}" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${Z.outerBox}" />`),t.push(" "+de(r,e.x+6,e.y+s/2,Y.edgeLabel,`font-size="${Y.edgeLabel}" font-weight="${O.groupHeader}" fill="var(--_text-sec)"`));for(let a of e.dividers)t.push(` <line x1="${e.x}" y1="${a.y}" x2="${e.x+e.width}" y2="${a.y}" stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`),a.label&&t.push(" "+de(`[${a.label}]`,e.x+8,a.y+14,Y.edgeLabel,`font-size="${Y.edgeLabel}" text-anchor="start" font-weight="${O.edgeLabel}" fill="var(--_text-muted)"`));return t.push("</g>"),t.join(`
63`)}function Zf(e){let{x:n,y:r,width:o,height:i}=e,s=e.actors&&e.actors.length>0?` data-actors="${e.actors.map(Qe).join(",")}"`:"",a=e.position?` data-position="${Qe(e.position)}"`:"",c=[`${n},${r}`,`${n+o-6},${r}`,`${n+o},${r+6}`,`${n+o},${r+i}`,`${n},${r+i}`].join(" ");return`<g class="note"${a}${s}>
64 <polygon points="${c}" fill="var(--bg)" stroke="var(--_node-stroke)" stroke-width="${Z.innerBox}" />
65 <polygon points="${n+o-6},${r} ${n+o},${r+6} ${n+o-6},${r+6}" fill="var(--_inner-stroke)" stroke="var(--_node-stroke)" stroke-width="${Z.innerBox}" />
66 ${de(e.text,n+o/2,r+i/2,Y.edgeLabel,`font-size="${Y.edgeLabel}" text-anchor="middle" font-weight="${O.edgeLabel}" fill="var(--_text-muted)"`)}
67</g>`}function Qe(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var ne={padding:40,boxPadX:8,headerBaseHeight:32,annotationHeight:16,memberRowHeight:20,sectionPadY:8,emptySectionHeight:8,minWidth:120,memberFontSize:11,memberFontWeight:400,nodeSpacing:40,layerSpacing:60};function Uf(e,t){let n=new Map;for(let o of e.classes){let i=o.annotation?ne.headerBaseHeight+ne.annotationHeight:ne.headerBaseHeight,s=o.attributes.length>0?o.attributes.length*ne.memberRowHeight+ne.sectionPadY:ne.emptySectionHeight,a=o.methods.length>0?o.methods.length*ne.memberRowHeight+ne.sectionPadY:ne.emptySectionHeight,c=te(o.label,Y.nodeLabel,O.nodeLabel),l=Zi(o.attributes),d=Zi(o.methods),f=Math.max(ne.minWidth,c+ne.boxPadX*2,l+ne.boxPadX*2,d+ne.boxPadX*2),u=i+s+a;n.set(o.id,{width:f,height:u,headerHeight:i,attrHeight:s,methodHeight:a})}let r={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.spacing.nodeNode":String(ne.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(ne.layerSpacing),"elk.padding":`[top=${ne.padding},left=${ne.padding},bottom=${ne.padding},right=${ne.padding}]`,"elk.edgeRouting":"ORTHOGONAL","elk.edgeLabels.placement":"CENTER"},children:[],edges:[]};for(let o of e.classes){let i=n.get(o.id);r.children.push({id:o.id,width:i.width,height:i.height})}for(let o=0;o<e.relationships.length;o++){let i=e.relationships[o],s={id:`e${o}`,sources:[i.from],targets:[i.to]};if(i.label){let a=Le(i.label,Y.edgeLabel,O.edgeLabel);s.labels=[{text:i.label,width:a.width+8,height:a.height+6}]}r.edges.push(s)}return{elkGraph:r,classSizes:n}}function Vf(e,t,n){let r=new Map;for(let s of t.classes)r.set(s.id,s);let o=[];for(let s of e.children??[]){let a=r.get(s.id);if(a){let c=n.get(a.id);o.push({id:a.id,label:a.label,annotation:a.annotation,attributes:a.attributes,methods:a.methods,x:s.x??0,y:s.y??0,width:s.width??c.width,height:s.height??c.height,headerHeight:c.headerHeight,attrHeight:c.attrHeight,methodHeight:c.methodHeight})}}let i=[];for(let s=0;s<(e.edges?.length??0);s++){let a=e.edges[s],c=t.relationships[s],l=[];if(a.sections&&a.sections.length>0){let f=a.sections[0];if(l.push({x:f.startPoint.x,y:f.startPoint.y}),f.bendPoints)for(let u of f.bendPoints)l.push({x:u.x,y:u.y});l.push({x:f.endPoint.x,y:f.endPoint.y})}let d;if(a.labels&&a.labels.length>0){let f=a.labels[0];f.x!=null&&f.y!=null&&(d={x:f.x+(f.width??0)/2,y:f.y+(f.height??0)/2})}i.push({from:c.from,to:c.to,type:c.type,markerAt:c.markerAt,label:c.label,fromCardinality:c.fromCardinality,toCardinality:c.toCardinality,points:l,labelPosition:d})}return{width:e.width??600,height:e.height??400,classes:o,relationships:i}}function Ui(e,t={}){if(e.classes.length===0)return{width:0,height:0,classes:[],relationships:[]};let{elkGraph:n,classSizes:r}=Uf(e,t),o=Bt(n);return Vf(o,e,r)}function Zi(e){if(e.length===0)return 0;let t=0;for(let n of e){let r=zf(n),o=dn(r,ne.memberFontSize);o>t&&(t=o)}return t}function zf(e){let t=e.visibility?`${e.visibility} `:"",n=e.isMethod?`${e.name}(${e.params||""})`:e.name,r=e.type?`: ${e.type}`:"";return`${t}${n}${r}`}var wn={memberSize:11,memberWeight:400,annotationSize:10,annotationWeight:500};function qi(e,t,n="Inter",r=!1){let o=[];o.push(je(e.width,e.height,t,r)),o.push(Je(n,!0)),o.push("<defs>"),o.push(qf()),o.push("</defs>");for(let i of e.relationships)o.push(tu(i));for(let i of e.classes)o.push(eu(i));for(let i of e.relationships)o.push(ou(i));return o.push("</svg>"),o.join(`
68`)}function qf(){return` <marker id="cls-inherit" markerWidth="12" markerHeight="10" refX="12" refY="5" orient="auto-start-reverse">
69 <polygon points="0 0, 12 5, 0 10" fill="var(--bg)" stroke="var(--_arrow)" stroke-width="1.5" />
70 </marker>
71 <marker id="cls-composition" markerWidth="12" markerHeight="10" refX="0" refY="5" orient="auto-start-reverse">
72 <polygon points="6 0, 12 5, 6 10, 0 5" fill="var(--_arrow)" stroke="var(--_arrow)" stroke-width="1" />
73 </marker>
74 <marker id="cls-aggregation" markerWidth="12" markerHeight="10" refX="0" refY="5" orient="auto-start-reverse">
75 <polygon points="6 0, 12 5, 6 10, 0 5" fill="var(--bg)" stroke="var(--_arrow)" stroke-width="1.5" />
76 </marker>
77 <marker id="cls-arrow" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto-start-reverse">
78 <polyline points="0 0, 8 3, 0 6" fill="none" stroke="var(--_arrow)" stroke-width="1.5" />
79 </marker>`}function eu(e){let{x:t,y:n,width:r,height:o,headerHeight:i,attrHeight:s,methodHeight:a}=e,c=[],l=e.annotation?` data-annotation="${it(e.annotation)}"`:"";c.push(`<g class="class-node" data-id="${it(e.id)}" data-label="${it(e.label)}"${l}>`),c.push(` <rect x="${t}" y="${n}" width="${r}" height="${o}" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${Z.outerBox}" />`),c.push(` <rect x="${t}" y="${n}" width="${r}" height="${i}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${Z.outerBox}" />`);let d=n+i/2;if(e.annotation){let A=n+12;c.push(` <text x="${t+r/2}" y="${A}" text-anchor="middle" dy="${he}" font-size="${wn.annotationSize}" font-weight="${wn.annotationWeight}" font-style="italic" fill="var(--_text-muted)"><<${yn(e.annotation)}>></text>`),d=n+i/2+6}c.push(" "+de(e.label,t+r/2,d,Y.nodeLabel,`text-anchor="middle" font-size="${Y.nodeLabel}" font-weight="700" fill="var(--_text)"`));let f=n+i;c.push(` <line x1="${t}" y1="${f}" x2="${t+r}" y2="${f}" stroke="var(--_node-stroke)" stroke-width="${Z.innerBox}" />`);let u=20;for(let A=0;A<e.attributes.length;A++){let x=e.attributes[A],w=f+4+A*u+u/2;c.push(" "+Vi(x,t+ne.boxPadX,w))}let h=f+s;c.push(` <line x1="${t}" y1="${h}" x2="${t+r}" y2="${h}" stroke="var(--_node-stroke)" stroke-width="${Z.innerBox}" />`);for(let A=0;A<e.methods.length;A++){let x=e.methods[A],w=h+4+A*u+u/2;c.push(" "+Vi(x,t+ne.boxPadX,w))}return c.push("</g>"),c.join(`
80`)}function Vi(e,t,n){let r=e.isAbstract?' font-style="italic"':"",o=e.isStatic?' text-decoration="underline"':"",i=[];e.visibility&&i.push(`<tspan fill="var(--_text-faint)">${yn(e.visibility)} </tspan>`);let s=e.isMethod?`${e.name}(${e.params||""})`:e.name;return i.push(`<tspan fill="var(--_text-sec)">${yn(s)}</tspan>`),e.type&&(i.push('<tspan fill="var(--_text-faint)">: </tspan>'),i.push(`<tspan fill="var(--_text-muted)">${yn(e.type)}</tspan>`)),`<text x="${t}" y="${n}" class="mono" dy="${he}" font-size="${wn.memberSize}" font-weight="${wn.memberWeight}"${r}${o}>${i.join("")}</text>`}function tu(e){if(e.points.length<2)return"";let t=e.points.map(s=>`${s.x},${s.y}`).join(" "),r=e.type==="dependency"||e.type==="realization"?' stroke-dasharray="6 4"':"",o=nu(e.type,e.markerAt),i=['class="class-relationship"',`data-from="${it(e.from)}"`,`data-to="${it(e.to)}"`,`data-type="${e.type}"`,`data-marker-at="${e.markerAt}"`];return e.label&&i.push(`data-label="${it(e.label)}"`),e.fromCardinality&&i.push(`data-from-cardinality="${it(e.fromCardinality)}"`),e.toCardinality&&i.push(`data-to-cardinality="${it(e.toCardinality)}"`),`<polyline ${i.join(" ")} points="${t}" fill="none" stroke="var(--_line)" stroke-width="${Z.connector}"${r}${o} />`}function nu(e,t){let n=ru(e);return n?t==="from"?` marker-start="url(#${n})"`:` marker-end="url(#${n})"`:""}function ru(e){switch(e){case"inheritance":case"realization":return"cls-inherit";case"composition":return"cls-composition";case"aggregation":return"cls-aggregation";case"association":case"dependency":return"cls-arrow";default:return null}}function ou(e){if(!e.label&&!e.fromCardinality&&!e.toCardinality||e.points.length<2)return"";let t=[];if(e.label){let n=e.labelPosition??iu(e.points);t.push(de(e.label,n.x,n.y-8,Y.edgeLabel,`font-size="${Y.edgeLabel}" text-anchor="middle" font-weight="${O.edgeLabel}" fill="var(--_text-muted)"`))}if(e.fromCardinality){let n=e.points[0],r=e.points[1],o=zi(n,r);t.push(de(e.fromCardinality,n.x+o.x,n.y+o.y,Y.edgeLabel,`font-size="${Y.edgeLabel}" text-anchor="middle" font-weight="${O.edgeLabel}" fill="var(--_text-muted)"`))}if(e.toCardinality){let n=e.points[e.points.length-1],r=e.points[e.points.length-2],o=zi(n,r);t.push(de(e.toCardinality,n.x+o.x,n.y+o.y,Y.edgeLabel,`font-size="${Y.edgeLabel}" text-anchor="middle" font-weight="${O.edgeLabel}" fill="var(--_text-muted)"`))}return t.join(`
81`)}function iu(e){if(e.length===0)return{x:0,y:0};let t=Math.floor(e.length/2);return e[t]}function zi(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.abs(n)>Math.abs(r)?{x:n>0?14:-14,y:-10}:{x:-14,y:r>0?14:-14}}var yn=rt;function it(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var De={padding:40,boxPadX:14,headerHeight:34,rowHeight:22,minWidth:140,attrFontSize:11,attrFontWeight:400,nodeSpacing:70,layerSpacing:90};function su(e,t){let n=new Map;for(let o of e.entities){let i=te(o.label,Y.nodeLabel,O.nodeLabel),s=0;for(let l of o.attributes){let d=`${l.type} ${l.name}${l.keys.length>0?" "+l.keys.join(","):""}`,f=dn(d,De.attrFontSize);f>s&&(s=f)}let a=Math.max(De.minWidth,i+De.boxPadX*2,s+De.boxPadX*2),c=De.headerHeight+Math.max(o.attributes.length,1)*De.rowHeight;n.set(o.id,{width:a,height:c})}let r={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.spacing.nodeNode":String(De.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(De.layerSpacing),"elk.padding":`[top=${De.padding},left=${De.padding},bottom=${De.padding},right=${De.padding}]`,"elk.edgeRouting":"ORTHOGONAL","elk.edgeLabels.placement":"CENTER"},children:[],edges:[]};for(let o of e.entities){let i=n.get(o.id);r.children.push({id:o.id,width:i.width,height:i.height})}for(let o=0;o<e.relationships.length;o++){let i=e.relationships[o],s=Le(i.label,Y.edgeLabel,O.edgeLabel),a={id:`e${o}`,sources:[i.entity1],targets:[i.entity2]};i.label&&(a.labels=[{text:i.label,width:s.width+8,height:s.height+6}]),r.edges.push(a)}return{elkGraph:r,entitySizes:n}}function au(e,t,n){let r=new Map;for(let s of t.entities)r.set(s.id,s);let o=[];for(let s of e.children??[]){let a=r.get(s.id);a&&o.push({id:a.id,label:a.label,attributes:a.attributes,x:s.x??0,y:s.y??0,width:s.width??n.get(a.id).width,height:s.height??n.get(a.id).height,headerHeight:De.headerHeight,rowHeight:De.rowHeight})}let i=[];for(let s=0;s<(e.edges?.length??0);s++){let a=e.edges[s],c=t.relationships[s],l=[];if(a.sections&&a.sections.length>0){let d=a.sections[0];if(l.push({x:d.startPoint.x,y:d.startPoint.y}),d.bendPoints)for(let f of d.bendPoints)l.push({x:f.x,y:f.y});l.push({x:d.endPoint.x,y:d.endPoint.y})}i.push({entity1:c.entity1,entity2:c.entity2,cardinality1:c.cardinality1,cardinality2:c.cardinality2,label:c.label,identifying:c.identifying,points:l})}return{width:e.width??600,height:e.height??400,entities:o,relationships:i}}function es(e,t={}){if(e.entities.length===0)return{width:0,height:0,entities:[],relationships:[]};let{elkGraph:n,entitySizes:r}=su(e,t),o=Bt(n);return au(o,e,r)}var et={attrSize:11,attrWeight:400,keySize:9,keyWeight:600};function ns(e,t,n="Inter",r=!1){let o=[];o.push(je(e.width,e.height,t,r)),o.push(Je(n,!0)),o.push("<defs>"),o.push("</defs>");for(let i of e.relationships)o.push(du(i));for(let i of e.entities)o.push(cu(i));for(let i of e.relationships)o.push(uu(i));for(let i of e.relationships)o.push(fu(i));return o.push("</svg>"),o.join(`
82`)}function cu(e){let{id:t,x:n,y:r,width:o,height:i,headerHeight:s,rowHeight:a,label:c,attributes:l}=e,d=[];d.push(`<g class="entity" data-id="${Xt(t)}" data-label="${Xt(c)}">`),d.push(` <rect x="${n}" y="${r}" width="${o}" height="${i}" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${Z.outerBox}" />`),d.push(` <rect x="${n}" y="${r}" width="${o}" height="${s}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${Z.outerBox}" />`),d.push(" "+de(c,n+o/2,r+s/2,Y.nodeLabel,`text-anchor="middle" font-size="${Y.nodeLabel}" font-weight="700" fill="var(--_text)"`));let f=r+s;d.push(` <line x1="${n}" y1="${f}" x2="${n+o}" y2="${f}" stroke="var(--_node-stroke)" stroke-width="${Z.innerBox}" />`);for(let u=0;u<l.length;u++){let h=l[u],A=f+u*a+a/2;d.push(" "+lu(h,n,A,o).replace(/\n/g,`
83 `))}return l.length===0&&d.push(` <text x="${n+o/2}" y="${f+a/2}" text-anchor="middle" dy="${he}" font-size="${et.attrSize}" fill="var(--_text-faint)" font-style="italic">(no attributes)</text>`),d.push("</g>"),d.join(`
84`)}function lu(e,t,n,r){let o=[],i=e.comment&&e.comment.length>0;if(i){let l=e.comment.replace(/<br\s*\/?>/gi,`
85`);o.push(`<g><title>${Sr(l)}</title>`)}let s=0;if(e.keys.length>0){let l=e.keys.join(",");s=te(l,et.keySize,et.keyWeight)+8,o.push(`<rect x="${t+6}" y="${n-7}" width="${s}" height="14" rx="2" ry="2" fill="var(--_key-badge)" />`),o.push(`<text x="${t+6+s/2}" y="${n}" text-anchor="middle" dy="${he}" font-size="${et.keySize}" font-weight="${et.keyWeight}" fill="var(--_text-sec)">${e.keys.join(",")}</text>`)}let a=t+8+(s>0?s+6:0);o.push(`<text x="${a}" y="${n}" class="mono" dy="${he}" font-size="${et.attrSize}" font-weight="${et.attrWeight}"><tspan fill="var(--_text-muted)">${Sr(e.type)}</tspan></text>`);let c=t+r-8;return o.push(`<text x="${c}" y="${n}" class="mono" text-anchor="end" dy="${he}" font-size="${et.attrSize}" font-weight="${et.attrWeight}"><tspan fill="var(--_text-sec)">${Sr(e.name)}</tspan></text>`),i&&o.push("</g>"),o.join(`
86`)}function du(e){if(e.points.length<2)return"";let t=e.points.map(i=>`${i.x},${i.y}`).join(" "),n=e.identifying?"":' stroke-dasharray="6 4"',r=e.label?` data-label="${Xt(e.label)}"`:"";return`<polyline ${['class="er-relationship"',`data-entity1="${Xt(e.entity1)}"`,`data-entity2="${Xt(e.entity2)}"`,`data-cardinality1="${e.cardinality1}"`,`data-cardinality2="${e.cardinality2}"`,`data-identifying="${e.identifying}"`].join(" ")}${r} points="${t}" fill="none" stroke="var(--_line)" stroke-width="${Z.connector}"${n} />`}function fu(e){if(!e.label||e.points.length<2)return"";let t=hu(e.points),n=Le(e.label,Y.edgeLabel,O.edgeLabel),r=n.width+8,o=n.height+6;return`<rect x="${t.x-r/2}" y="${t.y-o/2}" width="${r}" height="${o}" rx="2" ry="2" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
87${de(e.label,t.x,t.y,Y.edgeLabel,`text-anchor="middle" font-size="${Y.edgeLabel}" font-weight="${O.edgeLabel}" fill="var(--_text-muted)"`)}`}function uu(e){if(e.points.length<2)return"";let t=[],n=e.points[0],r=e.points[1];t.push(ts(n,r,e.cardinality1));let o=e.points[e.points.length-1],i=e.points[e.points.length-2];return t.push(ts(o,i,e.cardinality2)),t.join(`
88`)}function ts(e,t,n){let r=[],o=Z.connector+.25,i=e.x-t.x,s=e.y-t.y,a=Math.sqrt(i*i+s*s);if(a===0)return"";let c=i/a,l=s/a,d=-l,f=c,u=e.x-c*4,h=e.y-l*4,A=e.x-c*16,x=e.y-l*16,w=n==="one"||n==="zero-one",g=n==="many"||n==="zero-many",y=n==="zero-one"||n==="zero-many";if(w){r.push(`<line x1="${u+d*6}" y1="${h+f*6}" x2="${u-d*6}" y2="${h-f*6}" stroke="var(--_line)" stroke-width="${o}" />`);let m=u-c*4,C=h-l*4;r.push(`<line x1="${m+d*6}" y1="${C+f*6}" x2="${m-d*6}" y2="${C-f*6}" stroke="var(--_line)" stroke-width="${o}" />`)}if(g){let m=u,C=h;r.push(`<line x1="${m+d*7}" y1="${C+f*7}" x2="${A}" y2="${x}" stroke="var(--_line)" stroke-width="${o}" />`),r.push(`<line x1="${m}" y1="${C}" x2="${A}" y2="${x}" stroke="var(--_line)" stroke-width="${o}" />`),r.push(`<line x1="${m-d*7}" y1="${C-f*7}" x2="${A}" y2="${x}" stroke="var(--_line)" stroke-width="${o}" />`)}if(y){let b=g?20:12,m=e.x-c*b,C=e.y-l*b;r.push(`<circle cx="${m}" cy="${C}" r="4" fill="var(--bg)" stroke="var(--_line)" stroke-width="${o}" />`)}return r.join(`
89`)}function hu(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];let t=0;for(let o=1;o<e.length;o++){let i=e[o].x-e[o-1].x,s=e[o].y-e[o-1].y;t+=Math.sqrt(i*i+s*s)}if(t===0)return e[0];let n=t/2,r=0;for(let o=1;o<e.length;o++){let i=e[o].x-e[o-1].x,s=e[o].y-e[o-1].y,a=Math.sqrt(i*i+s*s);if(r+a>=n){let c=a>0?(n-r)/a:0;return{x:e[o-1].x+i*c,y:e[o-1].y+s*c}}r+=a}return e[e.length-1]}var Sr=rt;function Xt(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var G={plotWidth:600,plotHeight:340,padding:22,titleFontSize:18,titleFontWeight:600,titleHeight:42,axisLabelFontSize:14,axisLabelFontWeight:400,axisTitleFontSize:15,axisTitleFontWeight:500,xLabelHeight:38,yLabelWidth:58,yLabelGap:18,axisTitlePad:30,tickLength:4,barPadRatio:.2,barGroupGap:0,maxBarWidth:40,legendFontSize:14,legendFontWeight:400,legendHeight:28,legendSwatchW:14,legendSwatchH:14,legendGap:6,legendItemGap:16};function rs(e,t={}){return e.horizontal?gu(e):Au(e)}function Au(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,o=e.series.length>1,i=e.yAxis.range,s=os(i.min,i.max),a=Math.max(...s.map(R=>te(Cn(R),G.axisLabelFontSize,G.axisLabelFontWeight)),G.yLabelWidth),c=G.padding+(t?G.titleHeight:0)+(o?G.legendHeight:0),l=G.padding+G.xLabelHeight+(n?G.axisTitlePad:0),d=G.padding+a+G.yLabelGap+(r?G.axisTitlePad:0),f=G.padding,u=G.plotWidth,h=G.plotHeight,A=d+u+f,x=c+h+l,w={x:d,y:c,width:u,height:h},g=Br(e),y=R=>d+(R+.5)*(u/g),b=u/g,m=R=>{let N=(R-i.min)/(i.max-i.min||1);return c+h-N*h},C=xu(e,y,c+h,b),M=s.map(R=>({label:Cn(R),x:d,y:m(R),tx:d-G.tickLength,ty:m(R),labelX:d-G.yLabelGap,labelY:m(R),textAnchor:"end"})),v=s.map(R=>({x1:d,y1:m(R),x2:d+u,y2:m(R)})),I=Dr(e,g),p=e.series.map((R,N)=>N),S=mu(e,y,m,b,i.min,I,p),B=pu(e,y,m,I,p),D=G.padding+(t?G.titleHeight:0)+G.legendHeight/2,$=o?is(e,A/2,D,p):[],L={x1:d,y1:c+h,x2:d+u,y2:c+h},W={x1:d,y1:c,x2:d,y2:c+h},T={ticks:C,line:L,...n?{title:{text:e.xAxis.title,x:d+u/2,y:x-G.padding}}:{}},j={ticks:M,line:W,...r?{title:{text:e.yAxis.title,x:G.padding+4,y:c+h/2,rotate:-90}}:{}},k=t?{text:e.title,x:A/2,y:G.padding+G.titleFontSize}:void 0;return{width:A,height:x,title:k,xAxis:T,yAxis:j,plotArea:w,bars:S,lines:B,gridLines:v,legend:$}}function gu(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,o=e.series.length>1,i=e.yAxis.range,s=os(i.min,i.max),a=Br(e),c=Dr(e,a),l=Math.max(...c.map(F=>te(F,G.axisLabelFontSize,G.axisLabelFontWeight)),40),d=G.padding+(t?G.titleHeight:0)+(o?G.legendHeight:0),f=G.padding+G.xLabelHeight+(r?G.axisTitlePad:0),u=G.padding+l+G.yLabelGap+(n?G.axisTitlePad:0),h=G.padding,A=G.plotWidth,x=G.plotHeight,w=u+A+h,g=d+x+f,y={x:u,y:d,width:A,height:x},b=F=>{let J=(F-i.min)/(i.max-i.min||1);return u+J*A},m=x/a,C=F=>d+(F+.5)*m,M=s.map(F=>({label:Cn(F),x:b(F),y:d+x,tx:b(F),ty:d+x+G.tickLength,labelX:b(F),labelY:d+x+18,textAnchor:"middle"})),v=c.map((F,J)=>({label:F,x:u,y:C(J),tx:u-G.tickLength,ty:C(J),labelX:u-G.yLabelGap,labelY:C(J),textAnchor:"end"})),I=s.map(F=>({x1:b(F),y1:d,x2:b(F),y2:d+x})),p=e.series.map((F,J)=>J),B=e.series.filter(F=>F.type==="bar").length,D=[];if(B>0){let F=m*(1-G.barPadRatio),J=B>1?(F-(B-1)*G.barGroupGap)/B:F,Q=Math.min(J,G.maxBarWidth),ce=B>1?Q*B+G.barGroupGap*(B-1):Q,Fe=0,tt=0;for(let Oe of e.series){if(Oe.type!=="bar"){tt++;continue}for(let Se=0;Se<Oe.data.length;Se++){let dt=C(Se)-ce/2+Fe*(Q+G.barGroupGap),Lt=b(Math.max(Oe.data[Se],i.min)),ft=b(Math.max(0,i.min));D.push({x:Math.min(ft,Lt),y:dt,width:Math.abs(Lt-ft),height:Q,value:Oe.data[Se],label:c[Se],seriesIndex:Fe,colorIndex:p[tt]})}Fe++,tt++}}let $=[],L=0,W=0;for(let F of e.series){if(F.type!=="line"){W++;continue}let J=F.data.map((Q,ce)=>({x:b(Q),y:C(ce),value:Q,label:c[ce]}));$.push({points:J,seriesIndex:L,colorIndex:p[W]}),L++,W++}let T={x1:u,y1:d+x,x2:u+A,y2:d+x},j={x1:u,y1:d,x2:u,y2:d+x},k={ticks:M,line:T,...r?{title:{text:e.yAxis.title,x:u+A/2,y:g-G.padding}}:{}},R={ticks:v,line:j,...n?{title:{text:e.xAxis.title,x:G.padding+4,y:d+x/2,rotate:-90}}:{}},N=t?{text:e.title,x:w/2,y:G.padding+G.titleFontSize}:void 0,K=G.padding+(t?G.titleHeight:0)+G.legendHeight/2,P=o?is(e,w/2,K,p):[];return{width:w,height:g,horizontal:!0,title:N,xAxis:k,yAxis:R,plotArea:y,bars:D,lines:$,gridLines:I,legend:P}}function Br(e){if(e.xAxis.categories)return e.xAxis.categories.length;for(let t of e.series)if(t.data.length>0)return t.data.length;return 1}function Dr(e,t){if(e.xAxis.categories)return e.xAxis.categories;if(e.xAxis.range){let{min:n,max:r}=e.xAxis.range,o=t>1?(r-n)/(t-1):0;return Array.from({length:t},(i,s)=>Cn(n+o*s))}return Array.from({length:t},(n,r)=>String(r+1))}function xu(e,t,n,r){let o=Br(e);return Dr(e,o).map((s,a)=>({label:s,x:t(a),y:n,tx:t(a),ty:n+G.tickLength,labelX:t(a),labelY:n+18,textAnchor:"middle"}))}function mu(e,t,n,r,o,i,s){let c=e.series.filter(w=>w.type==="bar").length;if(c===0)return[];let l=r*(1-G.barPadRatio),d=c>1?(l-(c-1)*G.barGroupGap)/c:l,f=Math.min(d,G.maxBarWidth),u=c>1?f*c+G.barGroupGap*(c-1):f,h=[],A=0,x=0;for(let w of e.series){if(w.type!=="bar"){x++;continue}for(let g=0;g<w.data.length;g++){let m=t(g)-u/2+A*(f+G.barGroupGap),C=n(w.data[g]),M=n(Math.max(0,o));h.push({x:m,y:Math.min(C,M),width:f,height:Math.abs(M-C),value:w.data[g],label:i[g],seriesIndex:A,colorIndex:s[x]})}A++,x++}return h}function pu(e,t,n,r,o){let i=[],s=0,a=0;for(let c of e.series){if(c.type!=="line"){a++;continue}let l=c.data.map((d,f)=>({x:t(f),y:n(d),value:d,label:r[f]}));i.push({points:l,seriesIndex:s,colorIndex:o[a]}),s++,a++}return i}function os(e,t){let n=t-e;if(n<=0)return[e];let r=n/6,o=Math.pow(10,Math.floor(Math.log10(r))),i=r/o,s;i<=1.5?s=o:i<=3?s=2*o:i<=7?s=5*o:s=10*o;let a=Math.ceil(e/s)*s,c=[];for(let l=a;l<=t+s*.001;l+=s)c.push(Math.round(l*1e10)/1e10);return c}function Cn(e){return Number.isInteger(e)?String(e):e.toFixed(Math.abs(e)<10?1:0)}function is(e,t,n,r){let o=[],i=0,s=0;for(let d=0;d<e.series.length;d++){let f=e.series[d],u=f.type==="bar"?`Bar ${i+1}`:`Line ${s+1}`;o.push({label:u,x:0,y:n,type:f.type,seriesIndex:f.type==="bar"?i:s,colorIndex:r[d]}),f.type==="bar"?i++:s++}let a=o.map(d=>{let f=te(d.label,G.legendFontSize,G.legendFontWeight);return G.legendSwatchW+G.legendGap+f}),c=a.reduce((d,f)=>d+f,0)+(o.length-1)*G.legendItemGap,l=t-c/2;for(let d=0;d<o.length;d++)o[d].x=l,l+=a[d]+G.legendItemGap;return o}var re={titleSize:18,titleWeight:600,axisTitleSize:15,axisTitleWeight:500,labelSize:14,labelWeight:400,legendSize:14,legendWeight:400,dotRadius:5,lineWidth:2.5,barRadius:8},U={fontSize:15,fontWeight:500,height:32,padX:14,offsetY:12,rx:8,minY:4,pointerSize:6};function as(e,t,n="Inter",r=!1,o=!1){let i=[],s=Math.max(0,...e.bars.map(p=>p.colorIndex),...e.lines.map(p=>p.colorIndex)),a=je(e.width,e.height,t,r).replace("<svg ",`<svg data-xychart-colors="${s}" `);i.push(a),i.push(Je(n,!1));let c=Math.max(...e.lines.map(p=>p.points.length),0),l=c>0&&c<=12,{style:d,defs:f}=bu(e,o,l,t.accent,t.bg);i.push(d),f&&i.push(f);let{plotArea:u}=e,h=e.xAxis.ticks.map(p=>p.x),A=e.horizontal?e.yAxis.ticks.map(p=>p.y):e.gridLines.map(p=>p.y1),x=h.length>1?Math.abs(h[1]-h[0]):u.width/6,w=A.length>1?Math.abs(A[1]-A[0]):u.height/6,g=x/Math.max(1,Math.round(x/20)),y=w/Math.max(1,Math.round(w/20)),b=h[0]??u.x,m=A[0]??u.y,C=b-Math.ceil((b-u.x)/g)*g,M=m-Math.ceil((m-u.y)/y)*y;for(let p=M;p<=u.y+u.height+.5;p+=y)for(let S=C;S<=u.x+u.width+.5;S+=g)i.push(`<circle cx="${E(S)}" cy="${E(p)}" r="1.5" class="xychart-grid"/>`);let v=[];for(let p of e.bars){let S=` data-value="${p.value}"${p.label?` data-label="${we(p.label)}"`:""}`,B=e.horizontal?wu(p.x,p.y,p.width,p.height,re.barRadius):yu(p.x,p.y,p.width,p.height,re.barRadius);if(i.push(`<path d="${B}" class="xychart-bar xychart-color-${p.colorIndex}"${S}/>`),o){let D=$r(p.value),$=p.label?`${p.label}: ${D}`:D,L=ss(p.x+p.width/2,p.y,D);v.push(`<g class="xychart-bar-group"><rect x="${E(p.x)}" y="${E(p.y)}" width="${E(p.width)}" height="${E(p.height)}" fill="transparent"/><title>${we($)}</title>`+L+"</g>")}}for(let p of e.lines){if(p.points.length===0)continue;let S=Cu(p.points);i.push(`<path d="${S}" class="xychart-line-shadow xychart-color-${p.colorIndex}" transform="translate(0,2)"/>`),i.push(`<path d="${S}" class="xychart-line xychart-color-${p.colorIndex}"/>`)}let I=[];if(o||l){let p=new Map;for(let B of e.legend)B.type==="line"&&p.set(B.seriesIndex,B.label);let S=new Map;for(let B of e.lines)for(let D of B.points){let $=E(D.x);S.has($)||S.set($,[]),S.get($).push({x:D.x,y:D.y,value:D.value,label:D.label,seriesIndex:B.seriesIndex,colorIndex:B.colorIndex})}for(let B of S.values()){let D=B[0].x,$=B[0].label||"";if(o&&B.length>1){let L=Math.min(...B.map(F=>F.y)),W=Math.max(...B.map(F=>F.y)),T=re.dotRadius*3,j=`<rect x="${E(D-T)}" y="${E(L-T)}" width="${E(T*2)}" height="${E(W-L+T*2)}" fill="transparent" class="xychart-hit"/>`,k=B.map(F=>({text:$r(F.value),legendLabel:p.get(F.seriesIndex)||`Line ${F.seriesIndex+1}`})),R=Iu(D,L-re.dotRadius,$,k),N=k.map(F=>F.text),K=$?`${$}: ${N.join(" \xB7 ")}`:N.join(" \xB7 "),P=`<g class="xychart-dot-group">${j}`;for(let F of B){let J=` data-value="${F.value}"${F.label?` data-label="${we(F.label)}"`:""}`;P+=`<circle cx="${E(F.x)}" cy="${E(F.y)}" r="${re.dotRadius}" class="xychart-dot xychart-color-${F.colorIndex}"${J}/>`}P+=`<title>${we(K)}</title>${R}</g>`,I.push(P)}else if(o){let L=B[0],W=` data-value="${L.value}"${L.label?` data-label="${we(L.label)}"`:""}`,T=$r(L.value),j=L.label?`${L.label}: ${T}`:T,k=ss(D,L.y-re.dotRadius,T),R=l?`<circle cx="${E(D)}" cy="${E(L.y)}" r="${re.dotRadius*3}" fill="transparent" class="xychart-hit"/>`:"";I.push(`<g class="xychart-dot-group">${R}<circle cx="${E(L.x)}" cy="${E(L.y)}" r="${re.dotRadius}" class="xychart-dot xychart-color-${L.colorIndex}"${W}/><title>${we(j)}</title>${k}</g>`)}else for(let L of B){let W=` data-value="${L.value}"${L.label?` data-label="${we(L.label)}"`:""}`;i.push(`<circle cx="${E(L.x)}" cy="${E(L.y)}" r="${re.dotRadius}" class="xychart-dot xychart-color-${L.colorIndex}"${W}/>`)}}}for(let p of e.xAxis.ticks)i.push(`<text x="${p.labelX}" y="${p.labelY}" text-anchor="${p.textAnchor}" font-size="${re.labelSize}" font-weight="${re.labelWeight}" dy="${he}" class="xychart-label">${we(p.label)}</text>`);for(let p of e.yAxis.ticks)i.push(`<text x="${p.labelX}" y="${p.labelY}" text-anchor="${p.textAnchor}" font-size="${re.labelSize}" font-weight="${re.labelWeight}" dy="${he}" class="xychart-label">${we(p.label)}</text>`);if(e.xAxis.title){let p=e.xAxis.title,S=p.rotate?` transform="rotate(${p.rotate},${p.x},${p.y})"`:"";i.push(`<text x="${p.x}" y="${p.y}" text-anchor="middle"${S} font-size="${re.axisTitleSize}" font-weight="${re.axisTitleWeight}" dy="${he}" class="xychart-axis-title">${we(p.text)}</text>`)}if(e.yAxis.title){let p=e.yAxis.title,S=p.rotate?` transform="rotate(${p.rotate},${p.x},${p.y})"`:"";i.push(`<text x="${p.x}" y="${p.y}" text-anchor="middle"${S} font-size="${re.axisTitleSize}" font-weight="${re.axisTitleWeight}" dy="${he}" class="xychart-axis-title">${we(p.text)}</text>`)}e.title&&i.push(`<text x="${e.title.x}" y="${e.title.y}" text-anchor="middle" font-size="${re.titleSize}" font-weight="${re.titleWeight}" dy="${he}" class="xychart-title">${we(e.title.text)}</text>`);for(let p of e.legend){if(p.type==="bar")i.push(`<rect x="${p.x}" y="${p.y-14/2}" width="14" height="14" rx="3" class="xychart-bar xychart-color-${p.colorIndex}"/>`);else{let $=p.y;i.push(`<line x1="${p.x}" y1="${$}" x2="${p.x+14}" y2="${$}" stroke-width="${re.lineWidth}" stroke-linecap="round" class="xychart-legend-line xychart-color-${p.colorIndex}"/>`)}i.push(`<text x="${p.x+14+6}" y="${p.y}" text-anchor="start" font-size="${re.legendSize}" font-weight="${re.legendWeight}" dy="${he}" class="xychart-label">${we(p.label)}</text>`)}for(let p of v)i.push(p);for(let p of I)i.push(p);return i.push("</svg>"),i.join(`
90`)}function bu(e,t,n,r,o){let i=r??Ht,s=new Set;for(let u of e.bars)s.add(u.colorIndex);for(let u of e.lines)s.add(u.colorIndex);let a=[];for(let u of[...s].sort((h,A)=>h-A)){let h=u===0?`var(--accent, ${Ht})`:tr(u,i,o);a.push(` --xychart-color-${u}: ${h};`),a.push(` --xychart-bar-fill-${u}: color-mix(in srgb, var(--bg) 75%, var(--xychart-color-${u}) 25%);`)}let c=[];for(let u of[...s].sort((h,A)=>h-A)){let h=`var(--xychart-color-${u})`;c.push(` .xychart-bar.xychart-color-${u} { stroke: ${h}; fill: var(--xychart-bar-fill-${u}); }`),c.push(` path.xychart-color-${u}, line.xychart-color-${u} { stroke: ${h}; }`),c.push(` circle.xychart-color-${u} { fill: ${h}; }`)}let l=t?`
91 .xychart-tip { opacity: 0; pointer-events: none; }
92 .xychart-tip-bg { fill: var(--_text); filter: drop-shadow(0 1px 3px color-mix(in srgb, var(--fg) 20%, transparent)); }
93 .xychart-tip-text { fill: var(--bg); font-size: ${U.fontSize}px; font-weight: ${U.fontWeight}; }
94 .xychart-tip-ptr { fill: var(--_text); }
95 .xychart-bar-group:hover .xychart-tip,
96 .xychart-dot-group:hover .xychart-tip { opacity: 1; }`:"",d=a.length>0?`
97 svg {
98${a.join(`
99`)}
100 }`:"";return{style:`<style>
101 .xychart-grid { fill: var(--_inner-stroke); stroke: none; opacity: 0.65; }
102 .xychart-bar { stroke-width: 1.5; }
103 .xychart-line { fill: none; stroke-width: ${re.lineWidth}; stroke-linecap: round; stroke-linejoin: round; }
104 .xychart-line-shadow { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.12; }
105 .xychart-dot { stroke: var(--bg); stroke-width: 2; }
106 .xychart-label { fill: var(--_text-muted); }
107 .xychart-axis-title { fill: var(--_text-sec); }
108 .xychart-title { fill: var(--_text); }${d}
109${c.join(`
110`)}${l}
111</style>`,defs:""}}function yu(e,t,n,r,o){let i=Math.min(o,n/2,r/2);return i<=0?`M${E(e)},${E(t)} h${E(n)} v${E(r)} h${E(-n)} Z`:[`M${E(e)},${E(t+i)}`,`Q${E(e)},${E(t)} ${E(e+i)},${E(t)}`,`L${E(e+n-i)},${E(t)}`,`Q${E(e+n)},${E(t)} ${E(e+n)},${E(t+i)}`,`L${E(e+n)},${E(t+r-i)}`,`Q${E(e+n)},${E(t+r)} ${E(e+n-i)},${E(t+r)}`,`L${E(e+i)},${E(t+r)}`,`Q${E(e)},${E(t+r)} ${E(e)},${E(t+r-i)}`,"Z"].join(" ")}function wu(e,t,n,r,o){let i=Math.min(o,n/2,r/2);return i<=0?`M${E(e)},${E(t)} h${E(n)} v${E(r)} h${E(-n)} Z`:[`M${E(e+i)},${E(t)}`,`L${E(e+n-i)},${E(t)}`,`Q${E(e+n)},${E(t)} ${E(e+n)},${E(t+i)}`,`L${E(e+n)},${E(t+r-i)}`,`Q${E(e+n)},${E(t+r)} ${E(e+n-i)},${E(t+r)}`,`L${E(e+i)},${E(t+r)}`,`Q${E(e)},${E(t+r)} ${E(e)},${E(t+r-i)}`,`L${E(e)},${E(t+i)}`,`Q${E(e)},${E(t)} ${E(e+i)},${E(t)}`,"Z"].join(" ")}function Cu(e){if(e.length===0)return"";if(e.length===1)return`M${E(e[0].x)},${E(e[0].y)}`;if(e.length===2)return`M${E(e[0].x)},${E(e[0].y)} L${E(e[1].x)},${E(e[1].y)}`;let t=e.length,n=[],r=[];for(let a=0;a<t-1;a++)n.push(e[a+1].x-e[a].x),r.push(n[a]===0?0:(e[a+1].y-e[a].y)/n[a]);let o=new Array(t).fill(0);if(t>2){let a=new Array(t).fill(0),c=new Array(t).fill(0);for(let l=1;l<t-1;l++){let d=2*(n[l-1]+n[l]),f=3*(r[l]-r[l-1]);if(l===1)a[l]=n[l]/d,c[l]=f/d;else{let u=d-n[l-1]*a[l-1];a[l]=n[l]/u,c[l]=(f-n[l-1]*c[l-1])/u}}for(let l=t-2;l>=1;l--)o[l]=c[l]-a[l]*o[l+1]}let i=new Array(t).fill(0);for(let a=0;a<t-1;a++)i[a]=r[a]-n[a]*(2*o[a]+o[a+1])/3;i[t-1]=r[t-2]+n[t-2]*o[t-2]/3;let s=`M${E(e[0].x)},${E(e[0].y)}`;for(let a=0;a<t-1;a++){let c=n[a]/3,l=e[a].x+c,d=e[a].y+i[a]*c,f=e[a+1].x-c,u=e[a+1].y-i[a+1]*c;s+=` C${E(l)},${E(d)} ${E(f)},${E(u)} ${E(e[a+1].x)},${E(e[a+1].y)}`}return s}function Iu(e,t,n,r){let a=te(n,U.fontSize,600),c=Math.max(...r.map(C=>{let M=te(C.legendLabel,U.fontSize,U.fontWeight),v=te(C.text,U.fontSize,U.fontWeight);return M+10+v})),l=Math.max(a,c)+U.padX*2,d=26+r.length*20+6,f=Math.max(U.minY,t-U.offsetY-d-U.pointerSize),u=e-l/2,h=e,A=f+d,x=U.pointerSize,w=`<polygon points="${E(h-x)},${E(A)} ${E(h+x)},${E(A)} ${E(h)},${E(A+x)}" class="xychart-tip xychart-tip-ptr"/>`,g=`<rect x="${E(u)}" y="${E(f)}" width="${E(l)}" height="${d}" rx="${U.rx}" class="xychart-tip xychart-tip-bg"/>`;g+=w;let y=f+6+20/2;g+=`<text x="${E(e)}" y="${E(y)}" text-anchor="middle" font-weight="600" font-size="${U.fontSize}" dy="${he}" class="xychart-tip xychart-tip-text">${we(n)}</text>`;let b=u+U.padX,m=u+l-U.padX;for(let C of r)y+=20,g+=`<text x="${E(b)}" y="${E(y)}" text-anchor="start" font-size="${U.fontSize}" font-weight="${U.fontWeight}" dy="${he}" class="xychart-tip xychart-tip-text">${we(C.legendLabel)}</text>`,g+=`<text x="${E(m)}" y="${E(y)}" text-anchor="end" font-size="${U.fontSize}" font-weight="${U.fontWeight}" dy="${he}" class="xychart-tip xychart-tip-text">${we(C.text)}</text>`;return g}function ss(e,t,n){let o=te(n,U.fontSize,U.fontWeight)+U.padX*2,i=U.height,s=Math.max(U.minY,t-U.offsetY-i-U.pointerSize),a=e-o/2,c=e,l=s+i/2,d=e,f=s+i,u=U.pointerSize,h=`<polygon points="${E(d-u)},${E(f)} ${E(d+u)},${E(f)} ${E(d)},${E(f+u)}" class="xychart-tip xychart-tip-ptr"/>`;return`<rect x="${E(a)}" y="${E(s)}" width="${E(o)}" height="${i}" rx="${U.rx}" class="xychart-tip xychart-tip-bg"/>`+h+`<text x="${E(c)}" y="${E(l)}" text-anchor="middle" dy="${he}" class="xychart-tip xychart-tip-text">${we(n)}</text>`}function $r(e){return Number.isInteger(e)?e.toLocaleString("en-US"):e.toFixed(Math.abs(e)<10?1:0)}function E(e){return String(Math.round(e*10)/10)}function we(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Eu(e){let t=e.trim().split(/[\n;]/)[0]?.trim().toLowerCase()??"";return/^xychart(-beta)?\b/.test(t)?"xychart":/^sequencediagram\s*$/.test(t)?"sequence":/^classdiagram\s*$/.test(t)?"class":/^erdiagram\s*$/.test(t)?"er":"flowchart"}function Mu(e){return{bg:e.bg??qt.bg,fg:e.fg??qt.fg,line:e.line,accent:e.accent,muted:e.muted,surface:e.surface,border:e.border}}function cs(e,t={}){e=Tt(e);let n=Mu(t),r=t.font??"Inter",o=t.transparent??!1,i=Eu(e),s=e.split(`
112`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("%%"));switch(i){case"sequence":{let a=Zn(s),c=ji(a,t);return _i(c,n,r,o)}case"class":{let a=Vn(s),c=Ui(a,t);return qi(c,n,r,o)}case"er":{let a=qn(s),c=es(a,t);return ns(c,n,r,o)}case"xychart":{let a=er(s),c=rs(a,t);return as(c,n,r,o,t.interactive??!1)}case"flowchart":default:{let a=tn(e),c=vr(a,t);return Xi(c,n,r,o)}}}var ku=/```mermaid[^\n]*\n([\s\S]*?)\n[ \t]*```/g,Lr=new Map;function ds(e){let t=[],n=0;for(let r of e.matchAll(ku))r.index>n&&t.push({kind:"markdown",text:e.slice(n,r.index)}),t.push({kind:"diagram",source:r[1],fence:r[0]}),n=r.index+r[0].length;return n<e.length&&t.push({kind:"markdown",text:e.slice(n)}),t}function fs(e,t){if(!Lr.has(e)){let n;try{n=t()}catch{n=null}Lr.set(e,n)}return Lr.get(e)}var vu=e=>fs("art:"+e,()=>Ao(e)),us={},Ke=(e,t)=>[...t].forEach(n=>us[n]=e);Ke("-","\u2500\u2501\u2550\u2574\u2576\u2578\u257A");Ke("|","\u2502\u2503\u2551\u2575\u2577\u2579\u257B");Ke(".","\u254C\u2504\u2508\u254D\u2505\u2509\u2591\u2026");Ke(":","\u254E\u2506\u250A\u254F\u2507\u250B");Ke(">","\u25B6\u25BA\u25B7\u2192\u21D2");Ke("<","\u25C0\u25C4\u25C1\u2190\u21D0");Ke("^","\u25B2\u25B3\u2191");Ke("v","\u25BC\u25BD\u2193");Ke("*","\u25CF\u25C6");Ke("o","\u25C7\u25CB\u25EF");Ke("#","\u2588\u2589\u258A\u258B\u258C\u258D\u258E\u258F");var Su=e=>e.replace(/[\u2026\u2190-\u21FF\u2500-\u25FF]/g,t=>us[t]??(t>="\u2500"&&t<="\u257F"?"+":t)),Bu="svg{--bg:#FFFFFF;--fg:#27272A}@media (prefers-color-scheme: dark){svg{--bg:#1F1F23;--fg:#E4E4E7}}text{font-family:system-ui,-apple-system,'Segoe UI','Noto Sans KR',sans-serif}",Du=131072,$u=4096,Lu=e=>e.replace(/^<svg([^>]*?) style="[^"]*"/,'<svg$1 style="background:var(--bg)"').replace(/ data-[\w-]+="[^"]*"/g,"").replace(/="([^"]*)"/g,(t,n)=>`="${n.replace(/(\.\d\d)\d+/g,"$1")}"`).replace(/<style>([\s\S]*?)<\/style>/,(t,n)=>`<style>${n.replace(/\/\*[\s\S]*?\*\/|@import url\([^)]*\);|text \{ font-family:[^}]*\}/g,"").replace(/\s+/g," ").replace(/ ?([{};]) ?/g,"$1").trim()}${Bu}</style>`).replace(/>\s+</g,"><"),Ru=e=>fs("svg:"+e,()=>{let t=Lu(cs(e,{transparent:!1})),n=Number(/^<svg[^>]* width="([\d.]+)"/.exec(t)?.[1]);return t.length<=Du&&n>0?{source:t,width:Math.min(n,$u)}:null});function Gu(e,t,n){let r=!1,o=ds(e).map(i=>{if(i.kind==="markdown")return i.text;let s=vu(i.source);return s===null||s.width>t?i.fence:(r=!0,"```\n"+(n?s.plain.map(Su):s.plain).join(`
113`)+"\n```")}).join("");return r?o:null}function Wu(e){let t=[],n="",r=()=>{n.trim()&&t.push({markdown:n.replace(/^\n+|\s+$/g,"")}),n=""};for(let o of ds(e)){let i=o.kind==="diagram"?Ru(o.source):null;if(i===null){n+=o.kind==="markdown"?o.text:o.fence;continue}r(),t.push({svg:i,alt:o.source})}return r(),t.some(o=>o.svg)?t:null}var Dt=new Map;function ls(e,t){let n=Dt.get(e);return n===void 0?(n=t(),Dt.size>=64&&Dt.delete(Dt.keys().next().value)):Dt.delete(e),Dt.set(e,n),n}function O1(e,t){let n=t?.useAscii===!0;e("ui.render",{component:"AssistantMessage"},(r,o,i)=>{let{text:s}=o.props;if(!s.includes("```mermaid"))return i(o);if(o.surface==="terminal"){let u=(o.viewport?.columns??80)-4,h=ls(`t${u}${n?"a":""}
114${s}`,()=>Gu(s,u,n));return i(h===null?o:{...o,props:{...o.props,text:h}})}let a=ls(`d
115`+s,()=>Wu(s));if(a===null)return i(o);let{Box:c,Markdown:l,Svg:d}=r.ui.resolve(o),f=a.map(u=>u.svg?d({...u.svg,alt:u.alt}):l({text:u.markdown}));return c({flexDirection:"column",gap:1,children:f})})}export{O1 as register};
116/*! Bundled license information:
117
118@dagrejs/dagre/dist/dagre.esm.js:
119 (*! For license information please see dagre.esm.js.LEGAL.txt *)
120*/
121