@zuilib/text-editor 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -3
- package/README.md +61 -35
- package/dist/chunk-3KAABUZQ.js +2 -0
- package/dist/chunk-5J4TV6XA.js +2 -0
- package/dist/chunk-6JQG6QDN.js +16 -0
- package/dist/chunk-6LHJXZZ2.js +2 -0
- package/dist/chunk-N6OUUWQO.js +5 -0
- package/dist/comments.js +1 -1
- package/dist/drawing.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lexical.js +1 -1
- package/dist/markdown.js +1 -1
- package/dist/mentions.js +1 -1
- package/dist/styles.css +215 -6
- package/dist/tailwind.css +7 -0
- package/package.json +19 -33
- package/dist/chunk-3TZVOXWX.js +0 -16
- package/dist/chunk-C7VEINKX.js +0 -2
- package/dist/chunk-R5PL4Q7X.js +0 -5
- package/dist/chunk-SDICQI2B.js +0 -2
- package/dist/chunk-XP3MZRCW.js +0 -2
package/dist/markdown.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use client";import"./chunk-TGVEPLDM.js";import{a as t,d as E,j as q,k as r}from"./chunk-
|
|
2
|
+
"use client";import"./chunk-TGVEPLDM.js";import{a as t,d as E,j as q,k as r}from"./chunk-N6OUUWQO.js";import{a as e,b as i,d as m,e as p,f as d,g as n,q as o,v,w as y}from"./chunk-N5JWZ2VW.js";import"./chunk-6LHJXZZ2.js";import{c as A,d as D,i as K,j as N,o as O,p as T,q as W,r as _,s as b,t as g,u as h,v as j}from"./chunk-AGTPMKLK.js";import{b as M,c as k,d as s,e as w,f as x,o as R,p as l,q as u,t as P,u as S}from"./chunk-LDVPFZCN.js";import{a,b as c,c as f}from"./chunk-YFFSTMIR.js";var F=r(o);export{v as BLOCK_WIDTHS,e as BUILTIN_CODE_LANGUAGES,g as BlockButtons,E as CODE_TOKEN_TYPES,q as CharacterCount,k as DEFAULT_LABELS,x as DEFAULT_TABLE_SETTINGS,c as EDIT_LINK_COMMAND,b as FormatButtons,j as HistoryButtons,h as InsertButtons,F as MarkdownEditor,i as PLAIN_LANGUAGE,a as SAFE_LINK_PROTOCOLS,R as TABLE_WIDTH_MARKER,P as TOOLBAR_ITEM_ATTRIBUTE,T as Toolbar,_ as ToolbarButton,W as ToolbarDivider,N as canDeleteColumn,D as canDeleteRow,u as formatTableSettingsMarker,n as getCodeLanguages,p as hasCodeLanguage,K as insertableColumnIndices,A as insertableRowIndices,y as isBlockWidth,f as isSafeUrl,l as parseTableSettingsMarker,m as registerCodeLanguage,d as resolveCodeLanguage,s as resolveLabels,t as tokenizeCode,M as useEditorContext,w as useLabels,O as useMarkdownEditor,S as useToolbarKeyboard};
|
package/dist/mentions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use client";import{a as i,b as M,c as r,d as s}from"./chunk-
|
|
2
|
+
"use client";import{a as i,b as M,c as r,d as s}from"./chunk-3KAABUZQ.js";import{a as e,b as n,c as o,d as t}from"./chunk-5VRVC56Y.js";import"./chunk-6LHJXZZ2.js";import"./chunk-XRJNLGI4.js";export{n as $createMentionNode,o as $isMentionNode,i as DEFAULT_MENTIONS_LABELS,M as INSERT_MENTION_COMMAND,t as MENTION,e as MentionNode,s as MentionsPlugin,r as findMentionMatch};
|
package/dist/styles.css
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefix for the generated plain-CSS entry. The build appends the editor and
|
|
3
|
+
* plugin CSS so dist/styles.css stays directly inspectable and usable by
|
|
4
|
+
* processors that do not inline relative imports.
|
|
5
|
+
*/
|
|
6
|
+
@import "@zuilib/tokens/tokens.css";
|
|
7
|
+
/*
|
|
8
|
+
* The root is an inline-size container: the toolbar, the outline and the
|
|
9
|
+
* document respond to the editor's own width (see the small-container
|
|
10
|
+
* rules at the end), so an editor in a sidebar lays out like one on a
|
|
11
|
+
* phone. Containment also makes the root a stacking context, so the
|
|
12
|
+
* sticky toolbar's z-index stays inside the editor.
|
|
13
|
+
*/
|
|
1
14
|
.zui-text-editor {
|
|
2
15
|
position: relative;
|
|
3
16
|
width: 100%;
|
|
4
17
|
height: 100%;
|
|
5
18
|
overflow-y: auto;
|
|
19
|
+
container-type: inline-size;
|
|
6
20
|
}
|
|
7
21
|
|
|
8
22
|
.zui-text-editor-body {
|
|
@@ -41,6 +55,8 @@
|
|
|
41
55
|
min-height: 100%;
|
|
42
56
|
padding: 1.5rem var(--zui-text-editor-gutter, 2rem);
|
|
43
57
|
outline: none;
|
|
58
|
+
/* A URL or token longer than the line wraps instead of widening the pane */
|
|
59
|
+
overflow-wrap: break-word;
|
|
44
60
|
}
|
|
45
61
|
|
|
46
62
|
/* Keyboard focus: an inset ring so it is visible without changing layout */
|
|
@@ -305,6 +321,7 @@
|
|
|
305
321
|
display: flex;
|
|
306
322
|
align-items: center;
|
|
307
323
|
gap: 0.125rem;
|
|
324
|
+
min-width: 0;
|
|
308
325
|
padding: 0.375rem 0.75rem;
|
|
309
326
|
border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
|
|
310
327
|
background: inherit;
|
|
@@ -313,6 +330,7 @@
|
|
|
313
330
|
|
|
314
331
|
.zui-text-editor-toolbar-button {
|
|
315
332
|
display: inline-flex;
|
|
333
|
+
flex-shrink: 0;
|
|
316
334
|
align-items: center;
|
|
317
335
|
justify-content: center;
|
|
318
336
|
width: 1.75rem;
|
|
@@ -342,6 +360,7 @@
|
|
|
342
360
|
}
|
|
343
361
|
|
|
344
362
|
.zui-text-editor-toolbar-divider {
|
|
363
|
+
flex-shrink: 0;
|
|
345
364
|
width: 1px;
|
|
346
365
|
height: 1.125rem;
|
|
347
366
|
margin: 0 0.375rem;
|
|
@@ -563,6 +582,24 @@
|
|
|
563
582
|
opacity: 1;
|
|
564
583
|
}
|
|
565
584
|
|
|
585
|
+
/*
|
|
586
|
+
* Touch: a tap on the rail pins the handle where the finger was (there is
|
|
587
|
+
* no hover to follow); a second tap on the handle acts. A finger sliding
|
|
588
|
+
* along the rail moves the handle, so the rail claims that axis.
|
|
589
|
+
*/
|
|
590
|
+
.zui-table-rail.is-row {
|
|
591
|
+
touch-action: pan-x;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
.zui-table-rail.is-column {
|
|
595
|
+
touch-action: pan-y;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.zui-table-rail.is-pinned .zui-table-rail-handle,
|
|
599
|
+
.zui-table-rail.is-pinned .zui-table-rail-preview {
|
|
600
|
+
opacity: 1;
|
|
601
|
+
}
|
|
602
|
+
|
|
566
603
|
@media (prefers-reduced-motion: reduce) {
|
|
567
604
|
.zui-table-rail-marker,
|
|
568
605
|
.zui-table-rail-handle,
|
|
@@ -625,6 +662,10 @@
|
|
|
625
662
|
box-shadow: 0 0 0 3px color-mix(in srgb, var(--zui-drawing-accent) 12%, transparent);
|
|
626
663
|
}
|
|
627
664
|
|
|
665
|
+
.zui-drawing-canvas.is-editable:focus-within .zui-drawing-surface {
|
|
666
|
+
touch-action: none;
|
|
667
|
+
}
|
|
668
|
+
|
|
628
669
|
.zui-drawing-canvas.is-content-width {
|
|
629
670
|
width: fit-content;
|
|
630
671
|
max-width: 100%;
|
|
@@ -638,7 +679,12 @@
|
|
|
638
679
|
display: block;
|
|
639
680
|
width: 100%;
|
|
640
681
|
max-width: 100%;
|
|
641
|
-
|
|
682
|
+
/*
|
|
683
|
+
* A finger on an idle canvas scrolls the page; once the canvas is
|
|
684
|
+
* active (tapped, so focused) touches draw and drag. Mouse input is
|
|
685
|
+
* unaffected either way.
|
|
686
|
+
*/
|
|
687
|
+
touch-action: pan-y pinch-zoom;
|
|
642
688
|
font-family: var(--zui-drawing-font);
|
|
643
689
|
background-color: var(--zui-drawing-surface);
|
|
644
690
|
background-image: radial-gradient(circle, var(--zui-drawing-grid) 1px, transparent 1px);
|
|
@@ -715,8 +761,11 @@
|
|
|
715
761
|
|
|
716
762
|
.zui-drawing-toolbar-group {
|
|
717
763
|
display: flex;
|
|
764
|
+
/* Narrow canvases: the tools flow onto a second line rather than being clipped */
|
|
765
|
+
flex-wrap: wrap;
|
|
718
766
|
align-items: center;
|
|
719
767
|
gap: 0.125rem;
|
|
768
|
+
min-width: 0;
|
|
720
769
|
}
|
|
721
770
|
|
|
722
771
|
.zui-drawing-toolbar-group-end {
|
|
@@ -984,8 +1033,11 @@
|
|
|
984
1033
|
position: absolute;
|
|
985
1034
|
z-index: 6;
|
|
986
1035
|
display: flex;
|
|
1036
|
+
flex-wrap: wrap;
|
|
987
1037
|
align-items: center;
|
|
988
1038
|
gap: 0.25rem;
|
|
1039
|
+
/* Never wider than the pane (`cqw` is .zui-text-editor-main's width) */
|
|
1040
|
+
max-width: calc(100cqw - 0.5rem);
|
|
989
1041
|
padding: 0.25rem;
|
|
990
1042
|
border: 1px solid var(--border, color-mix(in srgb, currentColor 12%, transparent));
|
|
991
1043
|
border-radius: var(--radius-md, 0.5rem);
|
|
@@ -995,7 +1047,9 @@
|
|
|
995
1047
|
}
|
|
996
1048
|
|
|
997
1049
|
.zui-text-editor-link-input {
|
|
998
|
-
|
|
1050
|
+
flex: 1 1 auto;
|
|
1051
|
+
width: 14rem;
|
|
1052
|
+
min-width: 0;
|
|
999
1053
|
padding: 0.25rem 0.5rem;
|
|
1000
1054
|
border: 1px solid var(--border, color-mix(in srgb, currentColor 15%, transparent));
|
|
1001
1055
|
border-radius: var(--radius-sm, 0.375rem);
|
|
@@ -1142,6 +1196,157 @@
|
|
|
1142
1196
|
letter-spacing: 0.01em;
|
|
1143
1197
|
}
|
|
1144
1198
|
|
|
1199
|
+
/*
|
|
1200
|
+
* Small containers. `.zui-text-editor` and `.zui-text-editor-main` are
|
|
1201
|
+
* inline-size containers, so these rules follow the editor's own width,
|
|
1202
|
+
* not the viewport. Nothing here applies to a pane wider than 40rem.
|
|
1203
|
+
*/
|
|
1204
|
+
@container (max-width: 40rem) {
|
|
1205
|
+
/* Toolbar: order matters, so it scrolls sideways (snapping) rather than wrapping */
|
|
1206
|
+
.zui-text-editor-toolbar {
|
|
1207
|
+
overflow-x: auto;
|
|
1208
|
+
overflow-y: hidden;
|
|
1209
|
+
scrollbar-width: none;
|
|
1210
|
+
scroll-snap-type: x proximity;
|
|
1211
|
+
scroll-padding-inline: 0.75rem;
|
|
1212
|
+
overscroll-behavior-x: contain;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
.zui-text-editor-toolbar::-webkit-scrollbar {
|
|
1216
|
+
display: none;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
.zui-text-editor-toolbar > * {
|
|
1220
|
+
scroll-snap-align: start;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
/* Outline: a collapsible strip above the document instead of a side column */
|
|
1224
|
+
.zui-text-editor-body {
|
|
1225
|
+
flex-direction: column;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
.zui-text-editor-outline {
|
|
1229
|
+
order: -1;
|
|
1230
|
+
position: static;
|
|
1231
|
+
align-self: stretch;
|
|
1232
|
+
width: auto;
|
|
1233
|
+
max-height: 30dvh;
|
|
1234
|
+
padding: 0.5rem 0.75rem;
|
|
1235
|
+
border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
.zui-text-editor-outline-item,
|
|
1239
|
+
.zui-text-editor-outline-empty {
|
|
1240
|
+
font-size: 0.875rem;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/*
|
|
1244
|
+
* Tables: the table becomes its own horizontal scroll container (its
|
|
1245
|
+
* rows form an anonymous table inside) and every column keeps a
|
|
1246
|
+
* readable minimum, so a wide table scrolls within the pane instead of
|
|
1247
|
+
* squeezing or widening the page. `!important` beats the inline
|
|
1248
|
+
* `width: auto` of a content-width table.
|
|
1249
|
+
*/
|
|
1250
|
+
.zui-table {
|
|
1251
|
+
display: block;
|
|
1252
|
+
width: fit-content !important;
|
|
1253
|
+
overflow: auto hidden;
|
|
1254
|
+
scrollbar-width: thin;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
.zui-table-cell {
|
|
1258
|
+
min-width: 6rem;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/* Display sizes step down with the pane */
|
|
1262
|
+
.zui-text-editor-content .zui-heading-1 {
|
|
1263
|
+
font-size: 2rem;
|
|
1264
|
+
line-height: 1.15;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
.zui-text-editor-content .zui-heading-2 {
|
|
1268
|
+
font-size: 1.625rem;
|
|
1269
|
+
line-height: 1.2;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
.zui-text-editor-content .zui-heading-3 {
|
|
1273
|
+
font-size: 1.375rem;
|
|
1274
|
+
line-height: 1.25;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/*
|
|
1279
|
+
* Coarse pointers (touch). Targets grow to 44px — visibly for buttons,
|
|
1280
|
+
* as an invisible hit area (::before) for the small controls whose
|
|
1281
|
+
* geometry the layout depends on — and hover-revealed controls are shown
|
|
1282
|
+
* by default. Fine-pointer geometry is unchanged.
|
|
1283
|
+
*/
|
|
1284
|
+
@media (pointer: coarse) {
|
|
1285
|
+
.zui-text-editor-toolbar-button,
|
|
1286
|
+
.zui-drawing-tool,
|
|
1287
|
+
.zui-text-editor-outline-toggle {
|
|
1288
|
+
min-width: 2.75rem;
|
|
1289
|
+
min-height: 2.75rem;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.zui-drawing-popover-item,
|
|
1293
|
+
.zui-text-editor-mention-option,
|
|
1294
|
+
.zui-text-editor-link-input {
|
|
1295
|
+
min-height: 2.75rem;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
.zui-text-editor-mention-option {
|
|
1299
|
+
align-items: center;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
.zui-text-editor-outline-item {
|
|
1303
|
+
padding-block: 0.8125rem;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
.zui-text-editor-fold {
|
|
1307
|
+
opacity: 0.45;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
.zui-table-rail-handle,
|
|
1311
|
+
.zui-table-rail-handle.is-resting {
|
|
1312
|
+
opacity: 1;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
.zui-drawing-swatch {
|
|
1316
|
+
position: relative;
|
|
1317
|
+
width: 1.5rem;
|
|
1318
|
+
height: 1.5rem;
|
|
1319
|
+
margin: 0 0.25rem;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
.zui-table-rail-handle::before,
|
|
1323
|
+
.zui-text-editor-fold::before,
|
|
1324
|
+
.zui-drawing-swatch::before,
|
|
1325
|
+
.zui-drawing-resize::before {
|
|
1326
|
+
content: '';
|
|
1327
|
+
position: absolute;
|
|
1328
|
+
inset: -0.75rem;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
.zui-text-editor-fold::before {
|
|
1332
|
+
inset: -0.8125rem;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
.zui-drawing-swatch::before {
|
|
1336
|
+
inset: -0.625rem;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
/* Phones: editable text renders at 16px or more, so iOS does not zoom on focus */
|
|
1341
|
+
@media (max-width: 40rem) {
|
|
1342
|
+
.zui-text-editor-content,
|
|
1343
|
+
.zui-text-editor-textarea,
|
|
1344
|
+
.zui-text-editor-link-input,
|
|
1345
|
+
.zui-drawing-popover-item {
|
|
1346
|
+
font-size: max(16px, 1em);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1145
1350
|
/*
|
|
1146
1351
|
* First-party plugins (mentions, comments, images). Appended to styles.css
|
|
1147
1352
|
* at build time; every color comes from the host theme tokens.
|
|
@@ -1161,8 +1366,11 @@
|
|
|
1161
1366
|
.zui-text-editor-mentions {
|
|
1162
1367
|
position: absolute;
|
|
1163
1368
|
z-index: 6;
|
|
1164
|
-
min-width: 12rem;
|
|
1165
|
-
|
|
1369
|
+
min-width: min(12rem, calc(100cqw - 0.5rem));
|
|
1370
|
+
/* Inside the pane (`cqw` is .zui-text-editor-main's width) and above a soft keyboard */
|
|
1371
|
+
max-width: min(20rem, calc(100cqw - 0.5rem));
|
|
1372
|
+
max-height: min(18rem, 50dvh);
|
|
1373
|
+
overflow-y: auto;
|
|
1166
1374
|
padding: 0.25rem;
|
|
1167
1375
|
border: 1px solid var(--border, color-mix(in srgb, currentColor 12%, transparent));
|
|
1168
1376
|
border-radius: var(--radius-md, 0.5rem);
|
|
@@ -1236,8 +1444,8 @@
|
|
|
1236
1444
|
display: flex;
|
|
1237
1445
|
flex-direction: column;
|
|
1238
1446
|
gap: 0.375rem;
|
|
1239
|
-
min-width: 14rem;
|
|
1240
|
-
max-width: 22rem;
|
|
1447
|
+
min-width: min(14rem, calc(100cqw - 0.5rem));
|
|
1448
|
+
max-width: min(22rem, calc(100cqw - 0.5rem));
|
|
1241
1449
|
padding: 0.5rem;
|
|
1242
1450
|
border: 1px solid var(--border, color-mix(in srgb, currentColor 12%, transparent));
|
|
1243
1451
|
border-radius: var(--radius-md, 0.5rem);
|
|
@@ -1312,6 +1520,7 @@
|
|
|
1312
1520
|
inset-block-start: calc(100% + 0.25rem);
|
|
1313
1521
|
z-index: 6;
|
|
1314
1522
|
display: flex;
|
|
1523
|
+
max-width: calc(100cqw - 1rem);
|
|
1315
1524
|
padding: 0.25rem;
|
|
1316
1525
|
border: 1px solid var(--border, color-mix(in srgb, currentColor 12%, transparent));
|
|
1317
1526
|
border-radius: var(--radius-md, 0.5rem);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuilib/text-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "ZUI — Markdown editor with tables, drawings, code blocks, comments and mentions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -48,57 +48,43 @@
|
|
|
48
48
|
"import": "./dist/paste.js"
|
|
49
49
|
},
|
|
50
50
|
"./styles.css": "./dist/styles.css",
|
|
51
|
+
"./tailwind.css": "./dist/tailwind.css",
|
|
51
52
|
"./package.json": "./package.json"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
|
-
"@lexical/clipboard": "^0.35.0",
|
|
55
|
-
"@lexical/code": "^0.35.0",
|
|
56
|
-
"@lexical/html": "^0.35.0",
|
|
57
|
-
"@lexical/link": "^0.35.0",
|
|
58
|
-
"@lexical/list": "^0.35.0",
|
|
59
|
-
"@lexical/mark": "^0.35.0",
|
|
60
|
-
"@lexical/markdown": "^0.35.0",
|
|
61
|
-
"@lexical/react": "^0.35.0",
|
|
62
|
-
"@lexical/rich-text": "^0.35.0",
|
|
63
|
-
"@lexical/selection": "^0.35.0",
|
|
64
|
-
"@lexical/table": "^0.35.0",
|
|
65
|
-
"@lexical/utils": "^0.35.0",
|
|
66
|
-
"@zuilib/tokens": "^0.2.0",
|
|
67
|
-
"lexical": "^0.35.0",
|
|
68
55
|
"react": "^18.0.0 || ^19.0.0",
|
|
69
56
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
70
57
|
"tailwindcss": "^4"
|
|
71
58
|
},
|
|
72
59
|
"peerDependenciesMeta": {
|
|
73
|
-
"@zuilib/tokens": {
|
|
74
|
-
"optional": true
|
|
75
|
-
},
|
|
76
60
|
"tailwindcss": {
|
|
77
61
|
"optional": true
|
|
78
62
|
}
|
|
79
63
|
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@lexical/clipboard": "0.35.0",
|
|
66
|
+
"@lexical/code": "0.35.0",
|
|
67
|
+
"@lexical/html": "0.35.0",
|
|
68
|
+
"@lexical/link": "0.35.0",
|
|
69
|
+
"@lexical/list": "0.35.0",
|
|
70
|
+
"@lexical/mark": "0.35.0",
|
|
71
|
+
"@lexical/markdown": "0.35.0",
|
|
72
|
+
"@lexical/react": "0.35.0",
|
|
73
|
+
"@lexical/rich-text": "0.35.0",
|
|
74
|
+
"@lexical/selection": "0.35.0",
|
|
75
|
+
"@lexical/table": "0.35.0",
|
|
76
|
+
"@lexical/utils": "0.35.0",
|
|
77
|
+
"lexical": "0.35.0",
|
|
78
|
+
"@zuilib/tokens": "^0.2.1"
|
|
79
|
+
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@lexical/clipboard": "^0.35.0",
|
|
82
|
-
"@lexical/code": "^0.35.0",
|
|
83
81
|
"@lexical/headless": "0.35.0",
|
|
84
|
-
"@lexical/html": "^0.35.0",
|
|
85
|
-
"@lexical/link": "^0.35.0",
|
|
86
|
-
"@lexical/list": "^0.35.0",
|
|
87
|
-
"@lexical/mark": "^0.35.0",
|
|
88
|
-
"@lexical/markdown": "^0.35.0",
|
|
89
|
-
"@lexical/react": "^0.35.0",
|
|
90
|
-
"@lexical/rich-text": "^0.35.0",
|
|
91
|
-
"@lexical/selection": "^0.35.0",
|
|
92
|
-
"@lexical/table": "^0.35.0",
|
|
93
|
-
"@lexical/utils": "^0.35.0",
|
|
94
82
|
"@types/react": "^18.0.0 || ^19.0.0",
|
|
95
83
|
"@types/react-dom": "^18.0.0 || ^19.0.0",
|
|
96
84
|
"axe-core": "^4.13.0",
|
|
97
85
|
"jsdom": "^30.0.1",
|
|
98
|
-
"lexical": "^0.35.0",
|
|
99
86
|
"react": "^18.0.0 || ^19.0.0",
|
|
100
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
101
|
-
"@zuilib/tokens": "^0.2.0"
|
|
87
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
102
88
|
},
|
|
103
89
|
"keywords": [
|
|
104
90
|
"lexical",
|
package/dist/chunk-3TZVOXWX.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{k as $e,o as Bn,p as $n,t as zn,u as Hn,w as ae}from"./chunk-N5JWZ2VW.js";import{a as An,e as K,r as Le,s as Ln,t as ze,u as Wn}from"./chunk-LDVPFZCN.js";var de=["rect","ellipse","diamond","note","cylinder","cloud","queue","actor"],ue=["arrow","line"],pi=[...de,...ue,"text"];function A(t){return de.includes(t)}function T(t){return ue.includes(t)}var Un=320,fi=80,He=5e3,Fn=1e5,hi=2e3,xi=/^(#[0-9a-f]{3,8}|(rgba?|hsla?|oklch|oklab)\([\w.,%\s/+-]*\)|[a-z]+)$/i;function Gn(t){return typeof t=="string"&&t.length<=64&&xi.test(t)}var I=15,z=11,et=1.35,nt={version:3,canvasHeight:Un,shapes:[]},Dt=["#1e1e1e","#e03131","#2f9e44","#1971c2","#f08c00","#7048e8"],Xn=["transparent","#ffc9c9","#b2f2bb","#a5d8ff","#ffec99","#d0bfff"],Kn=0;function Ge(){return Kn+=1,`s${Date.now().toString(36)}${Kn.toString(36)}`}var Ke={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5]};function Y(t){return JSON.stringify(t)}function ye(t){try{return Ye(JSON.parse(t))}catch{return nt}}var Yn=!1;function gi(t){Yn||(Yn=!0,console.warn(t))}function mi(t){if(!$t(t))return t;let{w:e,h:n,...o}=t;return{...o,width:e,height:n}}function Ye(t,e=gi){if(!$t(t)||t.version!==2&&t.version!==3||!Array.isArray(t.shapes))return nt;let n=t.version===2?t.shapes.map(mi):t.shapes;n.length>He&&(e(`Drawing has ${n.length} shapes; keeping the first ${He}`),n=n.slice(0,He));let o=n.flatMap(s=>{let l=wi(s);return l?[l]:[]}),i=new Set(o.map(s=>s.id)),r=We(t.canvasHeight,NaN),a=We(t.canvasWidth,NaN);return{version:3,canvasHeight:Number.isFinite(r)&&r>=fi?r:Un,...Number.isFinite(a)&&a>=120?{canvasWidth:a}:{},...ae(t.width)?{width:t.width}:{},...se(t.title)?{title:se(t.title)}:{},...se(t.description)?{description:se(t.description)}:{},shapes:o.map(s=>{if(!T(s.type))return s;let l=qn(s.startBinding,i,o),c=qn(s.endBinding,i,o);return l===s.startBinding&&c===s.endBinding?s:{...s,startBinding:l,endBinding:c}})}}function qn(t,e,n){if(!t||!e.has(t.id))return;let o=n.find(i=>i.id===t.id);return o&&A(o.type)?t:void 0}function $t(t){return typeof t=="object"&&t!==null}function We(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function le(t){return typeof t=="string"&&t!==""?t:void 0}function se(t){let e=le(t)?.trim();return e?e.slice(0,hi):void 0}function ce(t){return Math.min(Fn,Math.max(-Fn,t))}function Vn(t){if(!$t(t)||typeof t.id!="string"||!t.id)return;let e={id:t.id},n=t.fixedPoint;return Array.isArray(n)&&n.length===2&&typeof n[0]=="number"&&typeof n[1]=="number"&&(e.fixedPoint=[Fe(n[0]),Fe(n[1])]),t.mode==="inside"&&(e.mode="inside"),e}function Fe(t){return Math.min(1,Math.max(0,t))}function wi(t){if(!$t(t))return null;let e=t.type;if(typeof t.id!="string"||!t.id||typeof e!="string"||!pi.includes(e)||typeof t.x!="number"||typeof t.y!="number"||typeof t.width!="number"||typeof t.height!="number"||![t.x,t.y,t.width,t.height].every(Number.isFinite))return null;let n={id:t.id,type:e,x:ce(t.x),y:ce(t.y),width:ce(t.width),height:ce(t.height),stroke:Gn(t.stroke)?t.stroke:Dt[0],fill:Gn(t.fill)?t.fill:"transparent",strokeWidth:Math.min(100,Math.max(0,We(t.strokeWidth,2)))},o=le(t.text);if(o!==void 0&&(n.text=o),A(n.type)){let i=le(t.label),r=le(t.footer);i!==void 0&&(n.label=i),r!==void 0&&(n.footer=r),n.width<0&&(n.x+=n.width,n.width=-n.width),n.height<0&&(n.y+=n.height,n.height=-n.height)}if(T(n.type)){let i=Vn(t.startBinding),r=Vn(t.endBinding);if(i&&(n.startBinding=i),r&&(n.endBinding=r),n.type==="arrow"&&t.bidirectional===!0&&(n.bidirectional=!0),t.routing==="elbow"&&(n.routing="elbow"),typeof t.elbow=="number"&&Number.isFinite(t.elbow)&&(n.elbow=Fe(t.elbow)),Array.isArray(t.waypoints)){let a=t.waypoints.flatMap(s=>$t(s)&&typeof s.x=="number"&&typeof s.y=="number"&&Number.isFinite(s.x)&&Number.isFinite(s.y)?[{x:s.x,y:s.y}]:[]);a.length&&(n.waypoints=a)}}return n}var pe={up:{x:0,y:-1},right:{x:1,y:0},down:{x:0,y:1},left:{x:-1,y:0}};function Zn(t){return t==="up"?"down":t==="down"?"up":t==="left"?"right":"left"}function jn(t){return t==="left"||t==="right"}function qe(t,e){let n=e.x-t.x,o=e.y-t.y;return Math.abs(n)>=Math.abs(o)?n>=0?"right":"left":o>=0?"down":"up"}function k(t){return{x:Math.min(t.x,t.x+t.width),y:Math.min(t.y,t.y+t.height),w:Math.abs(t.width),h:Math.abs(t.height)}}function Jn(t){if(T(t.type)||t.width>=0&&t.height>=0)return t;let e=k(t);return{...t,x:e.x,y:e.y,width:e.w,height:e.h}}function Qn(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function to(t){return Qn(k(t))}function fe(t,e){return{x:t.x-e,y:t.y-e,w:t.w+e*2,h:t.h+e*2}}function Ve(t,e,n=0){return e.x>=t.x-n&&e.x<=t.x+t.w+n&&e.y>=t.y-n&&e.y<=t.y+t.h+n}function Ue(t,e){return e.x>t.x&&e.x<t.x+t.w&&e.y>t.y&&e.y<t.y+t.h}function eo(t,e){return t.x>=e.x&&t.y>=e.y&&t.x+t.w<=e.x+e.w&&t.y+t.h<=e.y+e.h}function Lt(t){if(!t.length)return{x:0,y:0,w:0,h:0};let e=1/0,n=1/0,o=-1/0,i=-1/0;for(let r of t)e=Math.min(e,r.x),n=Math.min(n,r.y),o=Math.max(o,r.x+r.w),i=Math.max(i,r.y+r.h);return{x:e,y:n,w:o-e,h:i-n}}function kt(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function ut(t,e=40){let n=Qn(t);return Array.from({length:e},(o,i)=>{let r=i*2*Math.PI/e;return{x:n.x+t.w/2*Math.cos(r),y:n.y+t.h/2*Math.sin(r)}})}function Xe(t){return[{x:t.x,y:t.y},{x:t.x+t.w,y:t.y},{x:t.x+t.w,y:t.y+t.h},{x:t.x,y:t.y+t.h}]}function he(t,e){let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){let r=e[o],a=e[i];r.y>t.y!=a.y>t.y&&t.x<(a.x-r.x)*(t.y-r.y)/(a.y-r.y)+r.x&&(n=!n)}return n}function xe(t,e){let n=1/0;for(let o=0;o<e.length;o++)n=Math.min(n,bi(t,e[o],e[(o+1)%e.length]));return n}function bi(t,e,n){let o=n.x-e.x,i=n.y-e.y,r=o*o+i*i,a=r===0?0:Math.max(0,Math.min(1,((t.x-e.x)*o+(t.y-e.y)*i)/r));return Math.hypot(t.x-(e.x+o*a),t.y-(e.y+i*a))}function Ze(t,e,n,o=1e-6){let i=null;for(let r=0;r<n.length;r++){let a=n[r],s=n[(r+1)%n.length],l=s.x-a.x,c=s.y-a.y,u=e.x*c-e.y*l;if(Math.abs(u)<1e-9)continue;let x=a.x-t.x,y=a.y-t.y,m=(x*c-y*l)/u,g=(x*e.y-y*e.x)/u;m>=o&&g>=-1e-9&&g<=1+1e-9&&(i===null||m<i)&&(i=m)}return i}function ot(t,e,n){let o=n*.6,i=Math.max(1,Math.floor(e/o)),r=[];for(let a of t.split(`
|
|
3
|
-
`)){if(a.length<=i){r.push(a);continue}let s="";for(let l of a.split(" ")){for(;l.length>i;)s&&(r.push(s),s=""),r.push(l.slice(0,i)),l=l.slice(i);s?s.length+1+l.length<=i?s+=` ${l}`:(r.push(s),s=l):s=l}r.push(s)}return r}function U(t,e=I){let n=t.split(`
|
|
4
|
-
`),o=n.reduce((i,r)=>Math.max(i,r.length),0);return{w:Math.max(20,o*e*.6),h:n.length*e*et}}var xt=8;function zt(t,e,n=e){return{x:t.x+e,y:t.y+n,w:Math.max(t.w-e*2,20),h:Math.max(t.h-n*2,10)}}function Si(t){let e=(1-Math.SQRT1_2)/2;return zt(t,t.w*e,t.h*e)}var Et=t=>Math.min(18,t.w/4,t.h/4),Tt=t=>Math.min(t.h*.14,18),Rt=t=>Math.min(t.w*.12,18),Ht=.62;function ge(t,e,n,o,i,r,a=12){return Array.from({length:a+1},(s,l)=>{let c=i+(r-i)*l/a;return{x:t+n*Math.cos(c),y:e+o*Math.sin(c)}})}var gt={rect:{type:"rect",label:"Rectangle",defaultSize:{w:160,h:90},textSlots:["label","text","footer"],outline:t=>Xe(k(t)),textArea:t=>zt(k(t),xt)},ellipse:{type:"ellipse",label:"Ellipse",defaultSize:{w:160,h:90},textSlots:["label","text","footer"],outline:t=>ut(k(t)),textArea:t=>zt(Si(k(t)),2)},diamond:{type:"diamond",label:"Diamond",defaultSize:{w:170,h:100},textSlots:["label","text","footer"],outline:t=>{let e=k(t);return[{x:e.x+e.w/2,y:e.y},{x:e.x+e.w,y:e.y+e.h/2},{x:e.x+e.w/2,y:e.y+e.h},{x:e.x,y:e.y+e.h/2}]},textArea:t=>{let e=k(t);return zt(e,e.w/4,e.h/4)}},note:{type:"note",label:"Note",defaultSize:{w:160,h:110},textSlots:["label","text","footer"],defaultFill:"#ffec99",outline:t=>{let e=k(t),n=Et(e);return[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h-n},{x:e.x+e.w-n,y:e.y+e.h},{x:e.x,y:e.y+e.h}]},textArea:t=>{let e=k(t),n=Et(e);return{x:e.x+xt,y:e.y+xt,w:Math.max(e.w-xt*2,20),h:Math.max(e.h-xt*2-n/2,10)}}},cylinder:{type:"cylinder",label:"Database",defaultSize:{w:140,h:110},textSlots:["label","text","footer"],outline:t=>{let e=k(t),n=Tt(e),o=e.x+e.w/2;return[...ge(o,e.y+n,e.w/2,n,Math.PI,2*Math.PI),...ge(o,e.y+e.h-n,e.w/2,n,0,Math.PI)]},textArea:t=>{let e=k(t),n=Tt(e);return{x:e.x+xt,y:e.y+n*2+4,w:Math.max(e.w-xt*2,20),h:Math.max(e.h-n*3-8,10)}}},cloud:{type:"cloud",label:"Cloud",defaultSize:{w:180,h:110},textSlots:["label","text","footer"],outline:t=>ut(k(t)),textArea:t=>{let e=k(t);return zt(e,e.w*.17,e.h*.2)}},queue:{type:"queue",label:"Queue",defaultSize:{w:180,h:80},textSlots:["label","text","footer"],outline:t=>{let e=k(t),n=Rt(e),o=e.y+e.h/2;return[...ge(e.x+e.w-n,o,n,e.h/2,-Math.PI/2,Math.PI/2),...ge(e.x+n,o,n,e.h/2,Math.PI/2,3*Math.PI/2)]},textArea:t=>{let e=k(t),n=Rt(e);return{x:e.x+n+4,y:e.y+6,w:Math.max(e.w-n*3-8,20),h:Math.max(e.h-12,10)}}},actor:{type:"actor",label:"Actor",defaultSize:{w:90,h:120},textSlots:["text"],outline:t=>Xe(k(t)),textArea:t=>{let e=k(t),n=e.y+e.h*Ht;return{x:e.x-20,y:n,w:e.w+40,h:Math.max(e.y+e.h-n,10)}}}};function me(t){return gt[t.type]??null}var ao=6,Mi=10,Pi=.55;function Gt(t){let e=me(t);if(e)return e.outline(t);let n=k(t);return[{x:n.x,y:n.y},{x:n.x+n.w,y:n.y},{x:n.x+n.w,y:n.y+n.h},{x:n.x,y:n.y+n.h}]}function Di(t,e,n=0){let o=Gt(t);return he(e,o)?!0:n>0&&xe(e,o)<=n}function Wt(t,e,n,o=Mi){let i=null,r=1/0;for(let a=t.length-1;a>=0;a--){let s=t[a];if(s.id===n||!A(s.type)||!Di(s,e,o))continue;let l=k(s),c=l.w*l.h;c<r&&(i=s,r=c)}return i}function mt(t,e){let n=k(t),[o,i]=e?.fixedPoint??[.5,.5];return{x:n.x+n.w*o,y:n.y+n.h*i}}function ki(t,e){let n=k(t);if(n.w<1||n.h<1)return;let o=Math.min(1,Math.max(0,(e.x-n.x)/n.w)),i=Math.min(1,Math.max(0,(e.y-n.y)/n.h)),r=(1-Pi)/2;if(o>r&&o<1-r&&i>r&&i<1-r)return;let a=[[o*n.w,"fx",0],[(1-o)*n.w,"fx",1],[i*n.h,"fy",0],[(1-i)*n.h,"fy",1]];a.sort((u,x)=>u[0]-x[0]);let[,s,l]=a[0],c=s==="fx"?[l,i]:[o,l];return[no(c[0]),no(c[1])]}function no(t){return Math.round(t*1e3)/1e3}function Ei(t){let e=t?.fixedPoint;if(!e)return null;let[n,o]=e;return o<=0?n<=0||n>=1?null:"up":o>=1?n<=0||n>=1?null:"down":n<=0?"left":n>=1?"right":null}function Ft(t,e,n){let o=Ei(e);if(o)return o;let i=k(t),r=to(t),a=(n.x-r.x)/Math.max(i.w,1),s=(n.y-r.y)/Math.max(i.h,1);return Math.abs(a)>=Math.abs(s)?a>=0?"right":"left":s>=0?"down":"up"}function oo(t,e,n,o=ao){let i=mt(t,e);if(e?.mode==="inside")return i;let r=n.x-i.x,a=n.y-i.y,s=Math.hypot(r,a);if(s<1)return i;let l=r/s,c=a/s,u=Gt(t),m=!(xe(i,u)<.5)&&he(i,u)?Ze(i,{x:l,y:c},u)??0:0;return{x:i.x+l*(m+o),y:i.y+c*(m+o)}}function io(t,e,n,o=ao){let i=mt(t,e);if(e?.mode==="inside")return i;let r=pe[n],a=Gt(t),c=!(xe(i,a)<.5)&&he(i,a)?Ze(i,r,a)??0:0;return{x:i.x+r.x*(c+o),y:i.y+r.y*(c+o)}}function be(t){let e=new Map(t.map(n=>[n.id,n]));return t.map(n=>{if(!T(n.type)||!n.startBinding&&!n.endBinding)return n;let o=ro(e,n.startBinding),i=ro(e,n.endBinding);if(!o&&!i)return{...n,startBinding:void 0,endBinding:void 0};let r={x:n.x,y:n.y},a={x:n.x+n.width,y:n.y+n.height},s=n.waypoints,l=s?.length?s[0]:i?mt(i,n.endBinding):a,c=s?.length?s[s.length-1]:o?mt(o,n.startBinding):r,u=n.routing==="elbow"&&!s?.length,x=o?u?io(o,n.startBinding,Ft(o,n.startBinding,l)):oo(o,n.startBinding,l):r,y=i?u?io(i,n.endBinding,Ft(i,n.endBinding,c)):oo(i,n.endBinding,c):a,m={...n,x:x.x,y:x.y,width:y.x-x.x,height:y.y-x.y,startBinding:o?n.startBinding:void 0,endBinding:i?n.endBinding:void 0};return Ti(n,m)?n:m})}function ro(t,e){if(!e)return;let n=t.get(e.id);return n&&A(n.type)?n:void 0}function Ti(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height&&t.startBinding===e.startBinding&&t.endBinding===e.endBinding}function so(t,e){let n={x:t.x,y:t.y},o={x:t.x+t.width,y:t.y+t.height},i=Wt(e,n,t.id),r=Wt(e,o,t.id);return i&&r&&i.id===r.id?t:{...t,startBinding:i?we(i,n):void 0,endBinding:r?we(r,o):void 0}}function we(t,e){let n=ki(t,e);return n?{id:t.id,fixedPoint:n}:{id:t.id}}var Se=" ",Ri=Dt[0],je="transparent";function co(t,e={}){let n=t.shapes.filter(c=>A(c.type)),o=new Set(n.map(c=>c.id)),i=t.shapes.filter(c=>T(c.type)&&c.startBinding!==void 0&&o.has(c.startBinding.id)&&c.endBinding!==void 0&&o.has(c.endBinding.id)),r=t.shapes.filter(c=>c.type==="text"),a=Ci(n),s=c=>a.get(c)??c;return`${[`flowchart ${e.direction??Ni(i)}`,...n.map(c=>Se+Ii(c,s(c.id))),...i.map(c=>Se+_i(c,s)),...n.flatMap(c=>{let u=Ai(c,s(c.id));return u?[Se+u]:[]}),...r.map(c=>`${Se}%% note: ${(c.text??"").replace(/\s*\n\s*/g," ")}`)].join(`
|
|
5
|
-
`)}
|
|
6
|
-
`}function Ni(t){return t.length===0||t.filter(n=>Math.abs(n.width)>=Math.abs(n.height)).length*2>=t.length?"LR":"TD"}function Ci(t){let e=new Map,n=new Set;for(let o of t){let i=Oi(o.id),r=i;for(let a=2;n.has(r);a+=1)r=`${i}_${a}`;n.add(r),e.set(o.id,r)}return e}function Oi(t){let e=t.replace(/[^A-Za-z0-9_]/g,"_");return e===""||/^[0-9]/.test(e)?`n_${e}`:e}var vi={rect:["[","]"],ellipse:["([","])"],diamond:["{","}"],note:["[","]"],cylinder:["[(",")]"],cloud:["((","))"],queue:["[[","]]"],actor:["((","))"]};function Ii(t,e){let[n,o]=vi[t.type],i=[t.label,t.text,t.footer].filter(a=>a!==void 0&&a!==""),r=i.length?i.map(lo).join("<br/>"):t.id;return`${e}${n}"${r}"${o}`}function _i(t,e){let n=e(t.startBinding?.id??""),o=e(t.endBinding?.id??""),i=t.type==="line"?"---":t.bidirectional?"<-->":"-->",r=t.text?`|${lo(t.text).replace(/\|/g,"#124;")}|`:"";return`${n} ${i}${r} ${o}`}function Ai(t,e){let n=[];return t.fill!==je&&n.push(`fill:${t.fill}`),t.stroke!==Ri&&n.push(`stroke:${t.stroke}`),n.length===0?null:(t.fill===je&&n.unshift(`fill:${je}`),`style ${e} ${n.join(",")}`)}function lo(t){return t.replace(/"/g,"#quot;").replace(/</g,"#lt;").replace(/>/g,"#gt;").replace(/\r?\n/g,"<br/>")}var X={plain:{stroke:"transparent",fill:"#f1f3f5"},black:{stroke:"#1e1e1e",fill:"#1e1e1e"},gray:{stroke:"#1e1e1e",fill:"transparent"},red:{stroke:"#e03131",fill:"#ffc9c9"},green:{stroke:"#2f9e44",fill:"#b2f2bb"},blue:{stroke:"#1971c2",fill:"#a5d8ff"},orange:{stroke:"#f08c00",fill:"#ffec99"},purple:{stroke:"#7048e8",fill:"#d0bfff"}},xo=Object.keys(X),Bi=260,$i=6,Li=90,uo=40,Me=32,zi=32,Hi=120,Qe="#1e1e1e",tn=2;function Wi(t){return Kt(t)&&Array.isArray(t.boxes)}function go(t){try{let e=JSON.parse(t);return Wi(e)?Fi(Qi(e)):nt}catch{return nt}}function Fi(t){let e=Ji(t.boxes),n=new Map(e.map(d=>[d.id,d.type??"rect"])),o=new Map(e.map(d=>[d.id,Gi(d,n.get(d.id))])),i=new Set(n.keys()),r=(t.connectors??[]).filter(d=>i.has(at(d.from))&&i.has(at(d.to))&&at(d.from)!==at(d.to)),a=Yi(e,o,r,t.direction??"right"),s=e.map(d=>Ui(d,n.get(d.id),o.get(d.id),a.get(d.id))),l=new Map(s.map(d=>[d.id,ji(d)])),c=new Set(i),u=d=>{let f=c.size+1;for(;c.has(`${d}${f}`);)f+=1;let P=`${d}${f}`;return c.add(P),P},x=r.map(d=>Xi(d,l,u("c"))),y=(t.texts??[]).map(d=>Zi(d,u("t"))),m=be([...s,...x,...y]),g=m.reduce((d,f)=>{let P=k(f);return Math.max(d,P.y+P.h)},0);return Ye({version:3,...t.canvasWidth!==void 0?{canvasWidth:t.canvasWidth}:{},canvasHeight:t.canvasHeight??Math.max(Hi,Math.ceil(g+zi)),...t.width!==void 0?{width:t.width}:{},shapes:m})}function Gi(t,e){let n=gt[e],o={id:"",type:e,x:0,y:0,width:n.defaultSize.w,height:n.defaultSize.h,stroke:"",fill:"",strokeWidth:0},i=n.textArea(o),r=i.w/n.defaultSize.w,a=i.h/n.defaultSize.h,s=t.w!==void 0?Math.max(20,t.w*r):Bi,l=n.textSlots.flatMap(x=>{let y=Ki(t,x,s);return y?[y]:[]}),c=l.reduce((x,y)=>Math.max(x,y.w),0),u=l.reduce((x,y)=>x+y.h,0)+Math.max(0,l.length-1)*$i;return{w:t.w??Math.max(n.defaultSize.w,Math.ceil(c/r)),h:t.h??Math.max(n.defaultSize.h,Math.ceil(u/a))}}function Ki(t,e,n){let o=t[e];if(!o)return null;let i=e==="text"?I:z;return U(ot(o,n,i).join(`
|
|
7
|
-
`),i)}function Yi(t,e,n,o){let i=new Map,r=t.filter(f=>f.x===void 0||f.y===void 0),a=new Set(r.map(f=>f.id)),s=n.map(f=>({from:at(f.from),to:at(f.to)})).filter(f=>f.from!==f.to&&a.has(f.from)&&a.has(f.to)),l=Vi(r.map(f=>f.id),qi(r.map(f=>f.id),s)),c=[];for(let f of r){let P=l.get(f.id)??0;(c[P]??(c[P]=[])).push(f.id)}let u=o==="right"?"w":"h",x=o==="right"?"h":"w",y=c.map(f=>f.reduce((P,b)=>Math.max(P,e.get(b)[u]),0)),m=c.map(f=>f.reduce((P,b)=>P+e.get(b)[x],0)+Math.max(0,f.length-1)*uo),g=m.reduce((f,P)=>Math.max(f,P),0),d=Me;c.forEach((f,P)=>{let b=Me+(g-m[P])/2;for(let F of f){let _=e.get(F),ct=Math.round(d+(y[P]-_[u])/2),_t=Math.round(b);i.set(F,o==="right"?{x:ct,y:_t}:{x:_t,y:ct}),b+=_[x]+uo}d+=y[P]+Li});for(let f of t){let P=i.get(f.id)??{x:Me,y:Me};i.set(f.id,{x:f.x??P.x,y:f.y??P.y})}return i}function qi(t,e){let n=new Map;for(let a of e)(n.get(a.from)??n.set(a.from,[]).get(a.from)).push(a);let o=new Map,i=[],r=a=>{o.set(a,"visiting");for(let s of n.get(a)??[]){let l=o.get(s.to);l!=="visiting"&&(i.push(s),l===void 0&&r(s.to))}o.set(a,"done")};for(let a of t)o.has(a)||r(a);return i}function Vi(t,e){let n=new Map;for(let r of e)(n.get(r.to)??n.set(r.to,[]).get(r.to)).push(r.from);let o=new Map,i=r=>{let a=o.get(r);if(a!==void 0)return a;let s=(n.get(r)??[]).reduce((l,c)=>Math.max(l,i(c)+1),0);return o.set(r,s),s};for(let r of t)i(r);return o}function Ui(t,e,n,o){let i=t.color?X[t.color]:void 0,r=t.fill??i?.fill??gt[e].defaultFill??"transparent";return{id:t.id,type:e,x:o.x,y:o.y,width:n.w,height:n.h,stroke:t.stroke??i?.stroke??Qe,fill:r,strokeWidth:tn,...t.text?{text:t.text}:{},...t.label?{label:t.label}:{},...t.footer?{footer:t.footer}:{}}}function Xi(t,e,n){let o=t.type??"arrow",i=e.get(at(t.from)),r=e.get(at(t.to));return{id:t.id??n,type:o,x:i.x,y:i.y,width:r.x-i.x,height:r.y-i.y,stroke:t.stroke??(t.color?X[t.color].stroke:Qe),fill:"transparent",strokeWidth:tn,startBinding:yo(t.from),endBinding:yo(t.to),...t.text?{text:t.text}:{},...o==="arrow"&&t.bidirectional?{bidirectional:!0}:{},...t.routing==="elbow"?{routing:"elbow"}:{}}}function Zi(t,e){let n=U(t.text);return{id:t.id??e,type:"text",x:t.x,y:t.y,width:n.w,height:n.h,stroke:t.stroke??(t.color?X[t.color].stroke:Qe),fill:"transparent",strokeWidth:tn,text:t.text}}function at(t){return typeof t=="string"?t:t.id}function yo(t){return typeof t=="string"||!t.side?{id:at(t)}:{id:t.id,fixedPoint:Ke[t.side]}}function ji(t){let e=k(t);return{x:e.x+e.w/2,y:e.y+e.h/2}}function Ji(t){let e=new Set;return t.filter(n=>e.has(n.id)?!1:(e.add(n.id),!0))}function Qi(t){let e=t,n=e.boxes.flatMap(s=>{let l=tr(s);return l?[l]:[]}),o=Array.isArray(e.connectors)?e.connectors.flatMap(s=>{let l=er(s);return l?[l]:[]}):[],i=Array.isArray(e.texts)?e.texts.flatMap(s=>{let l=nr(s);return l?[l]:[]}):[],r=wt(e.canvasWidth),a=wt(e.canvasHeight);return{direction:e.direction==="down"?"down":"right",...r!==void 0?{canvasWidth:r}:{},...a!==void 0?{canvasHeight:a}:{},...ae(e.width)?{width:e.width}:{},boxes:n,connectors:o,texts:i}}function tr(t){return!Kt(t)||!H(t.id)||t.type!==void 0&&!(typeof t.type=="string"&&A(t.type))?null:nn({id:t.id,type:t.type,label:H(t.label)?t.label:void 0,text:H(t.text)?t.text:void 0,footer:H(t.footer)?t.footer:void 0,x:wt(t.x),y:wt(t.y),w:fo(t.w),h:fo(t.h),color:en(t.color),stroke:H(t.stroke)?t.stroke:void 0,fill:H(t.fill)?t.fill:void 0})}function er(t){if(!Kt(t))return null;let e=po(t.from),n=po(t.to);return!e||!n||t.type!==void 0&&!(typeof t.type=="string"&&T(t.type))?null:nn({id:H(t.id)?t.id:void 0,type:t.type,from:e,to:n,text:H(t.text)?t.text:void 0,bidirectional:t.bidirectional===!0?!0:void 0,routing:t.routing==="elbow"?"elbow":void 0,color:en(t.color),stroke:H(t.stroke)?t.stroke:void 0})}function po(t){if(H(t))return t;if(!Kt(t)||!H(t.id))return null;let e=t.side;return typeof e=="string"&&e in Ke?{id:t.id,side:e}:{id:t.id}}function nr(t){if(!Kt(t)||!H(t.text))return null;let e=wt(t.x),n=wt(t.y);return e===void 0||n===void 0?null:nn({id:H(t.id)?t.id:void 0,x:e,y:n,text:t.text,color:en(t.color),stroke:H(t.stroke)?t.stroke:void 0})}function Kt(t){return typeof t=="object"&&t!==null}function H(t){return typeof t=="string"&&t!==""}function wt(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0}function fo(t){let e=wt(t);return e!==void 0&&e>0?e:void 0}function en(t){return typeof t=="string"&&xo.includes(t)?t:void 0}function nn(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}var Je={enum:xo,description:"Named color preset: outline plus, for boxes, a matching fill. `plain` has no outline and a light fill, `black` is a dark card with light text, `gray` is a dark outline on transparent (the default); the rest pair a colored outline with its pastel fill."},ho={oneOf:[{type:"string",description:"Id of a box. The connector attaches to its outline, aimed at the other end"},{type:"object",required:["id"],additionalProperties:!1,properties:{id:{type:"string",description:"Id of a box"},side:{enum:["top","right","bottom","left"],description:"Pin the endpoint to the middle of this side of the box instead of auto-aiming"}}}],description:"Box a connector end attaches to: a bare box id, or {id, side} to pick the attach edge"},fa={$schema:"http://json-schema.org/draft-07/schema#",title:"DrawingSkeleton",description:"Compact intent description of a diagram. Boxes are sized from their text and laid out automatically along the connector flow; connectors are drawn between box outlines. Only say what is on the canvas \u2014 geometry is derived",type:"object",required:["boxes"],additionalProperties:!1,properties:{direction:{enum:["right","down"],description:'Auto-layout flow direction. Boxes connected a\u2192b are placed in successive ranks along this axis ("right" = columns left to right, "down" = rows top to bottom). Default "right"'},canvasWidth:{type:"number",minimum:120,description:"Logical canvas width in px. Omit for a fluid canvas in CSS pixels"},canvasHeight:{type:"number",minimum:80,description:"Canvas height in px. Omit to fit the content"},width:{enum:["full","text","content"],description:'Block width: "text" aligns the drawing with the text column (same as "full" unless the app sets a text measure); "content" fits the drawing to its shapes and left-aligns it with the text; omit to span the editor'},boxes:{type:"array",items:{$ref:"#/definitions/box"},description:"Card-like shapes carrying up to three text slots. Order is the render order and the stacking order within a layout rank"},connectors:{type:"array",items:{$ref:"#/definitions/connector"},description:"Arrows and lines between boxes. Connectors whose from/to id does not match a box are dropped"},texts:{type:"array",items:{$ref:"#/definitions/text"},description:"Free-floating annotations not attached to any box. Prefer box slots (label/text/footer) when the text belongs to a box"}},definitions:{box:{type:"object",required:["id"],additionalProperties:!1,properties:{id:{type:"string",description:"Unique within the drawing; connectors reference it"},type:{enum:de,description:'Shape: rect (default), ellipse, diamond (decision), note (sticky note, yellow by default), cylinder (database), cloud (external system), queue (message queue), actor (stick figure; only the "text" slot renders, below the figure)'},label:{type:"string",description:"Small bold heading at the top of the box"},text:{type:"string",description:'Main content, centered. Wraps automatically; "\\n" forces a line break'},footer:{type:"string",description:"Small dim line at the bottom of the box"},x:{type:"number",description:"Top-left x in px. Omit (with y) to let the layout place the box"},y:{type:"number",description:"Top-left y in px. Omit (with x) to let the layout place the box"},w:{type:"number",exclusiveMinimum:0,description:"Width in px. Omit to size from the text (never smaller than the type default)"},h:{type:"number",exclusiveMinimum:0,description:"Height in px. Omit to size from the text (never smaller than the type default)"},color:Je,stroke:{type:"string",description:"CSS color of the outline and text; overrides the preset"},fill:{type:"string",description:'CSS color of the interior ("transparent" for none); overrides the preset'}}},connector:{type:"object",required:["from","to"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional; generated when omitted"},type:{enum:ue,description:'arrow (default; arrowhead at "to") or line (no arrowheads)'},from:ho,to:ho,text:{type:"string",description:"Label rendered at the middle of the connector"},bidirectional:{type:"boolean",description:"Arrow only: arrowheads on both ends"},routing:{enum:["straight","elbow"],description:"straight (default) draws a direct line; elbow draws a right-angled path routed around the boxes"},color:Je,stroke:{type:"string",description:"CSS color of the line and label; overrides the preset"}}},text:{type:"object",required:["x","y","text"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional; generated when omitted"},x:{type:"number",description:"Top-left x of the first line, in px"},y:{type:"number",description:"Top-left y of the first line, in px"},text:{type:"string",description:'Content; "\\n" forces a line break'},color:Je,stroke:{type:"string",description:"CSS color of the text; overrides the preset"}}}}};import{$applyNodeReplacement as zr,DecoratorNode as Hr}from"lexical";import{useCallback as v,useEffect as Mn,useMemo as Vo,useRef as W,useState as Q,useContext as Tr}from"react";import{$getNodeByKey as Rr}from"lexical";import{useLexicalComposerContext as Nr}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Cr}from"@lexical/react/useLexicalEditable";var mo=28,bo=14,or=60,ir=1;function So(t,e){let n=new Map(e.map(b=>[b.id,b])),o=t.startBinding?n.get(t.startBinding.id):void 0,i=t.endBinding?n.get(t.endBinding.id):void 0,r={x:t.x,y:t.y},a={x:t.x+t.width,y:t.y+t.height},s=i?mt(i,t.endBinding):a,l=o?mt(o,t.startBinding):r,c=o?Ft(o,t.startBinding,s):qe(r,a),u=i?Ft(i,t.endBinding,l):qe(a,r),x=o?wo(r,c,mo):r,y=i?wo(a,u,mo):a,m=Lt([Pe(x),Pe(y)]),g=fe(m,or),d=e.filter(b=>A(b.type)).map(b=>fe(k(b),bo)).filter(b=>rr(b,g)).filter(b=>!Ve(b,x)&&!Ve(b,y)),f=ar(x,y,c,u,d)??(jn(c)?[x,{x:y.x,y:x.y},y]:[x,{x:x.x,y:y.y},y]),P=lr([r,x,...f,y,a]);return t.elbow!==void 0&&P.length===4&&(P=dr(P,t.elbow,d)),P}function wo(t,e,n){let o=pe[e];return{x:t.x+o.x*n,y:t.y+o.y*n}}function Pe(t){return{x:t.x,y:t.y,w:0,h:0}}function rr(t,e){return t.x<=e.x+e.w&&t.x+t.w>=e.x&&t.y<=e.y+e.h&&t.y+t.h>=e.y}function ar(t,e,n,o,i){let r=new Set([t.x,e.x,(t.x+e.x)/2]),a=new Set([t.y,e.y,(t.y+e.y)/2]);for(let d of i)r.add(d.x),r.add(d.x+d.w),a.add(d.y),a.add(d.y+d.h);let s=fe(Lt([Pe(t),Pe(e),...i]),bo);r.add(s.x),r.add(s.x+s.w),a.add(s.y),a.add(s.y+s.h);let l=[...r].sort((d,f)=>d-f),c=[...a].sort((d,f)=>d-f),u=c.map((d,f)=>l.map((P,b)=>({x:P,y:d,col:b,row:f,g:1/0,f:1/0,closed:!1,visited:!1,parent:null,dir:null}))),x=u[c.indexOf(t.y)][l.indexOf(t.x)],y=u[c.indexOf(e.y)][l.indexOf(e.x)];if(x===y)return[t];let m=Math.max(1e4,kt(t,e)**2),g=new on;for(x.g=0,x.f=kt(x,y),x.visited=!0,g.push(x);g.size;){let d=g.pop();if(d.closed)continue;if(d===y)return cr(d);d.closed=!0;let f=d.dir??n;for(let[P,b]of sr(u,d)){if(b.closed||P===Zn(f)||b===y&&P===o)continue;let F={x:(d.x+b.x)/2,y:(d.y+b.y)/2};if(i.some(ct=>Ue(ct,F)))continue;let _=d.g+kt(d,b)+(P!==f?m:0);(!b.visited||_<b.g)&&(b.visited=!0,b.parent=d,b.dir=P,b.g=_,b.f=_+kt(b,y),g.push(b))}}return null}function sr(t,e){let n=[];return e.row>0&&n.push(["up",t[e.row-1][e.col]]),e.col<t[0].length-1&&n.push(["right",t[e.row][e.col+1]]),e.row<t.length-1&&n.push(["down",t[e.row+1][e.col]]),e.col>0&&n.push(["left",t[e.row][e.col-1]]),n}function cr(t){let e=[];for(let n=t;n;n=n.parent)e.push({x:n.x,y:n.y});return e.reverse()}var on=class{constructor(){this.items=[]}get size(){return this.items.length}push(e){let n=this.items;n.push(e);let o=n.length-1;for(;o>0;){let i=o-1>>1;if(n[i].f<=n[o].f)break;[n[i],n[o]]=[n[o],n[i]],o=i}}pop(){let e=this.items,n=e[0],o=e.pop();if(e.length){e[0]=o;let i=0;for(;;){let r=i*2+1,a=r+1,s=i;if(r<e.length&&e[r].f<e[s].f&&(s=r),a<e.length&&e[a].f<e[s].f&&(s=a),s===i)break;[e[s],e[i]]=[e[i],e[s]],i=s}}return n}};function lr(t){let e=[];for(let o of t){let i=e[e.length-1];i&&kt(i,o)<ir||e.push(o)}let n=[];for(let o=0;o<e.length;o++){let i=n[n.length-1],r=e[o+1],a=e[o];if(i&&r){let s=Math.abs(i.x-a.x)<.01&&Math.abs(a.x-r.x)<.01,l=Math.abs(i.y-a.y)<.01&&Math.abs(a.y-r.y)<.01;if(s||l)continue}n.push(a)}return n}function dr(t,e,n){let[o,i,r,a]=t,s=Math.abs(i.y-r.y)<.01&&Math.abs(i.x-r.x)>.01,l=Math.abs(i.x-r.x)<.01&&Math.abs(i.y-r.y)>.01,c=Math.min(.95,Math.max(.05,e)),u;if(l){let x=o.x+(a.x-o.x)*c;u=[o,{x,y:i.y},{x,y:r.y},a]}else if(s){let x=o.y+(a.y-o.y)*c;u=[o,{x:i.x,y:x},{x:r.x,y:x},a]}else return t;for(let x=0;x<u.length-1;x++){let y={x:(u[x].x+u[x+1].x)/2,y:(u[x].y+u[x+1].y)/2};if(n.some(m=>Ue(m,y)))return t}return u}function rn(t,e=[]){let n={x:t.x,y:t.y},o={x:t.x+t.width,y:t.y+t.height};return t.waypoints?.length?[n,...t.waypoints,o]:t.routing==="elbow"?So(t,e):[n,o]}function an(t,e=6){if(t.length<2)return"";if(t.length===2)return`M ${O(t[0].x)} ${O(t[0].y)} L ${O(t[1].x)} ${O(t[1].y)}`;let n=`M ${O(t[0].x)} ${O(t[0].y)}`;for(let i=1;i<t.length-1;i++){let r=t[i-1],a=t[i],s=t[i+1],l=Math.hypot(a.x-r.x,a.y-r.y),c=Math.hypot(s.x-a.x,s.y-a.y),u=Math.min(e,l/2,c/2);if(u<.5){n+=` L ${O(a.x)} ${O(a.y)}`;continue}let x={x:a.x-(a.x-r.x)/l*u,y:a.y-(a.y-r.y)/l*u},y={x:a.x+(s.x-a.x)/c*u,y:a.y+(s.y-a.y)/c*u};n+=` L ${O(x.x)} ${O(x.y)} Q ${O(a.x)} ${O(a.y)} ${O(y.x)} ${O(y.y)}`}let o=t[t.length-1];return`${n} L ${O(o.x)} ${O(o.y)}`}function O(t){return Number.isInteger(t)?String(t):t.toFixed(2)}function Yt(t,e,n){let o=n?1:-1;for(let i=e+o;i>=0&&i<t.length;i+=o){let r=t[e].x-t[i].x,a=t[e].y-t[i].y;if(Math.abs(r)>.01||Math.abs(a)>.01)return Math.atan2(a,r)}return 0}function De(t,e,n){let o=Math.PI/7;return[{x:t.x-n*Math.cos(e-o),y:t.y-n*Math.sin(e-o)},t,{x:t.x-n*Math.cos(e+o),y:t.y-n*Math.sin(e+o)}]}function Mo(t,e,n){let[o,i,r]=De(t,e,n);return`M ${O(o.x)} ${O(o.y)} L ${O(i.x)} ${O(i.y)} L ${O(r.x)} ${O(r.y)}`}function sn(t){let e=0;for(let n=1;n<t.length;n++)e+=Math.hypot(t[n].x-t[n-1].x,t[n].y-t[n-1].y);return e}function Po(t,e){if(t.type!=="arrow"||e.length<2)return[];let n=sn(e);if(n<1)return[];let o=Math.min(14,4+n/4),i=e.length-1,r=[Mo(e[i],Yt(e,i,!1),o)];return t.bidirectional&&r.push(Mo(e[0],Yt(e,0,!0),o)),r}function ke(t){if(t.length===0)return{x:0,y:0};if(t.length===1)return t[0];let e=t[Math.floor((t.length-1)/2)],n=t[Math.ceil((t.length+1)/2)-1];return{x:(e.x+n.x)/2,y:(e.y+n.y)/2}}import{jsx as R,jsxs as qt}from"react/jsx-runtime";var Vt={select:R("path",{d:"M4.5 2.5l12 6.5-5.4 1.4L8.5 16.5z",fill:"currentColor",stroke:"none"}),rect:R("rect",{x:"3",y:"4.5",width:"14",height:"11",rx:"2"}),ellipse:R("ellipse",{cx:"10",cy:"10",rx:"7",ry:"5.5"}),diamond:R("path",{d:"M10 3l7 7-7 7-7-7z"}),note:R("path",{d:"M4 3.5h12v9l-3.5 3.5H4z M12.5 16v-3.5H16"}),cylinder:qt("g",{children:[R("ellipse",{cx:"10",cy:"5.5",rx:"6",ry:"2.5"}),R("path",{d:"M4 5.5v9c0 1.4 2.7 2.5 6 2.5s6-1.1 6-2.5v-9"})]}),cloud:R("path",{d:"M6 15.5a3 3 0 0 1-.5-5.95A4.5 4.5 0 0 1 14 8.3a3.6 3.6 0 0 1 .5 7.2z"}),queue:qt("g",{children:[R("path",{d:"M5.5 5.5h9M5.5 14.5h9M5.5 5.5a2.2 4.5 0 0 0 0 9"}),R("ellipse",{cx:"14.5",cy:"10",rx:"2.2",ry:"4.5"})]}),actor:qt("g",{children:[R("circle",{cx:"10",cy:"5",r:"2.2"}),R("path",{d:"M10 7.2v5M6.5 9.2h7M10 12.2l-3 4.6M10 12.2l3 4.6"})]}),arrow:R("path",{d:"M4 16L16 4M9 4h7v7"}),line:R("path",{d:"M4 16L16 4"}),text:R("path",{d:"M4 5V3.5h12V5M10 3.5V16.5M7 16.5h6"})},Z={more:qt("g",{children:[R("rect",{x:"3",y:"3",width:"5.5",height:"5.5",rx:"1.2"}),R("circle",{cx:"14.25",cy:"5.75",r:"2.75"}),R("path",{d:"M5.75 11.5l2.75 5h-5.5z"}),R("path",{d:"M11.5 12h5.5v5h-5.5z"})]}),straight:R("path",{d:"M4 16L16 4"}),elbow:R("path",{d:"M4 16v-6h12V4"}),oneWay:R("path",{d:"M3 10h13M12 5.5L16.5 10L12 14.5"}),twoWay:R("path",{d:"M3.5 10h13M8 5.5L3.5 10L8 14.5M12 5.5L16.5 10L12 14.5"}),trash:R("path",{d:"M4 6h12M8 6V4h4v2M6 6l1 10h6l1-10M8.5 9v4M11.5 9v4"}),mermaid:qt("g",{children:[R("rect",{x:"3",y:"3.5",width:"5",height:"4",rx:"1"}),R("rect",{x:"12",y:"3.5",width:"5",height:"4",rx:"1"}),R("rect",{x:"7.5",y:"12.5",width:"5",height:"4",rx:"1"}),R("path",{d:"M5.5 7.5v2.5h9V7.5M10 10v2.5"})]}),check:R("path",{d:"M4 10.5l4 4 8-9"}),grip:R("path",{d:"M7 7h.01M7 10h.01M7 13h.01M10 7h.01M10 10h.01M10 13h.01M13 7h.01M13 10h.01M13 13h.01",strokeWidth:"2.2"})};function yt({children:t,size:e=16}){return R("svg",{viewBox:"0 0 20 20",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t})}var Ee=8,Ut=3;function cn(t,e){return{x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function Do(t,e,n){return t.filter(o=>{if(T(o.type)){let i=n.get(o.id)??[];return i.length>0&&i.every(r=>r.x>=e.x&&r.x<=e.x+e.w&&r.y>=e.y&&r.y<=e.y+e.h)}return eo(k(o),e)}).map(o=>o.id)}function ln(t,e,n){switch(e.mode){case"marquee":return t;case"draw":return t.map(o=>o.id===e.id?{...o,w:n.x-o.x,h:n.y-o.y}:o);case"move":{let o=n.x-e.origin.x,i=n.y-e.origin.y;return t.map(r=>{let a=e.origs.get(r.id);return a?{...r,x:a.x+o,y:a.y+i,waypoints:a.waypoints?.map(s=>({x:s.x+o,y:s.y+i}))}:r})}case"resize":{let o=e.orig,i=o.x+o.width,r=o.y+o.height,a=e.corner==="nw"||e.corner==="sw"?n.x:o.x,s=e.corner==="nw"||e.corner==="ne"?n.y:o.y,l=e.corner==="ne"||e.corner==="se"?n.x:i,c=e.corner==="sw"||e.corner==="se"?n.y:r;return t.map(u=>u.id===e.id?{...u,x:a,y:s,width:l-a,height:c-s}:u)}case"endpoint":{let o=e.orig;return t.map(i=>i.id!==e.id?i:e.end==="start"?{...i,x:n.x,y:n.y,width:o.x+o.width-n.x,height:o.y+o.height-n.y}:{...i,width:n.x-o.x,height:n.y-o.y})}case"elbow":{let o=e.vertical?e.d.x-e.a.x:e.d.y-e.a.y;if(Math.abs(o)<1)return t;let i=e.vertical?(n.x-e.a.x)/o:(n.y-e.a.y)/o,r=Math.round(Math.min(.95,Math.max(.05,i))*1e3)/1e3;return t.map(a=>a.id===e.id?{...a,elbow:r}:a)}case"waypoint":return t.map(o=>{if(o.id!==e.id||!o.waypoints)return o;let i=o.waypoints;if(e.index<0||e.index>=i.length)return o;let r=e.index===0?{x:o.x,y:o.y}:i[e.index-1],a=e.index===i.length-1?{x:o.x+o.width,y:o.y+o.height}:i[e.index+1],s=n.x,l=n.y;Math.abs(s-r.x)<Ee?s=r.x:Math.abs(s-a.x)<Ee&&(s=a.x),Math.abs(l-r.y)<Ee?l=r.y:Math.abs(l-a.y)<Ee&&(l=a.y);let c=[...i];return c[e.index]={x:s,y:l},{...o,waypoints:c}})}}function dn(t,e,n){let o=e.has(n)?e:new Set([n]);return new Map(t.filter(i=>o.has(i.id)).map(i=>[i.id,i]))}import{jsx as j,jsxs as un}from"react/jsx-runtime";var ur=Object.keys(X);function yr({name:t,active:e,onClick:n}){let o=X[t],i=K().drawing.color(t);return j("button",{type:"button",title:i,"aria-label":i,"aria-pressed":e,className:`zui-drawing-swatch ${e?"is-active":""}`,style:{backgroundColor:o.fill,borderColor:o.stroke},onClick:n})}function Xt({label:t,active:e,onClick:n,children:o,className:i}){return j("button",{type:"button",title:t,"aria-label":t,"aria-pressed":e,className:`zui-drawing-tool ${e?"is-active":""} ${i??""}`,onClick:n,children:j(yt,{children:o})})}function ko({selection:t,stroke:e,fill:n,onColor:o,onRouting:i,onDirection:r,onDelete:a}){let s=t.filter(g=>T(g.type)),l=t.filter(g=>g.type==="arrow"),c=s.length>0&&s.every(g=>g.routing==="elbow"),u=s.length>0&&s.every(g=>g.routing!=="elbow"),x=l.length>0&&l.every(g=>g.bidirectional),y=l.length>0&&l.every(g=>!g.bidirectional),m=K().drawing;return un("div",{className:"zui-drawing-props",onPointerDown:g=>g.stopPropagation(),children:[j("div",{className:"zui-drawing-props-group",role:"radiogroup","aria-label":m.colors,children:ur.map(g=>j(yr,{name:g,active:X[g].stroke===e&&X[g].fill===n,onClick:()=>o(g)},g))}),s.length>0&&un("div",{className:"zui-drawing-props-group","aria-label":m.connectorRouting,children:[j(Xt,{label:m.straight,active:u,onClick:()=>i(!1),children:Z.straight}),j(Xt,{label:m.elbow,active:c,onClick:()=>i(!0),children:Z.elbow})]}),l.length>0&&un("div",{className:"zui-drawing-props-group","aria-label":m.arrowDirection,children:[j(Xt,{label:m.oneWay,active:y,onClick:()=>r(!1),children:Z.oneWay}),j(Xt,{label:m.twoWay,active:x,onClick:()=>r(!0),children:Z.twoWay})]}),t.length>0&&j("div",{className:"zui-drawing-props-group",children:j(Xt,{label:t.length>1?m.deleteShapes(t.length):m.deleteShape,className:"zui-drawing-tool-danger",onClick:a,children:Z.trash})})]})}import{jsx as B,jsxs as yn}from"react/jsx-runtime";var Zt=7;function Te({x:t,y:e,cursor:n,square:o,onPointerDown:i,title:r}){let a={className:"zui-drawing-handle",strokeWidth:1.5,style:{cursor:n},onPointerDown:i};return o?B("rect",{...a,x:t-Zt/2,y:e-Zt/2,width:Zt,height:Zt,rx:2,children:r&&B("title",{children:r})}):B("circle",{...a,cx:t,cy:e,r:Zt/2+.5,children:r&&B("title",{children:r})})}function Eo({shape:t,points:e,onHandlePointerDown:n,onWaypointAdd:o,onWaypointRemove:i}){let r=K().drawing;if(T(t.type)){let u=t.waypoints??[],x=t.routing==="elbow"&&!u.length&&e.length===4,y=x?{x:(e[1].x+e[2].x)/2,y:(e[1].y+e[2].y)/2}:null,m=x&&Math.abs(e[1].x-e[2].x)<.01,g=e.slice(0,-1).flatMap((d,f)=>{let P=e[f+1];return Math.hypot(P.x-d.x,P.y-d.y)<28?[]:x&&f===1?[]:[{index:f,x:(d.x+P.x)/2,y:(d.y+P.y)/2}]});return yn("g",{className:"zui-drawing-selection",children:[g.map(({index:d,x:f,y:P})=>B("circle",{className:"zui-drawing-handle zui-drawing-ghost",cx:f,cy:P,r:4.5,strokeWidth:1.5,strokeDasharray:"2 2",style:{cursor:"copy"},onPointerDown:b=>o(b,t.id,d,{x:f,y:P}),children:B("title",{children:"Drag to add a bend"})},`ghost-${d}`)),u.map((d,f)=>B("g",{onDoubleClick:P=>{P.stopPropagation(),i(t.id,f)},children:B(Te,{x:d.x,y:d.y,square:!0,cursor:"move",title:r.waypoint,onPointerDown:P=>n(P,{mode:"waypoint",id:t.id,index:f})})},`wp-${f}`)),y&&B(Te,{x:y.x,y:y.y,square:!0,cursor:m?"ew-resize":"ns-resize",title:r.elbowHandle,onPointerDown:d=>n(d,{mode:"elbow",id:t.id,a:e[0],d:e[3],vertical:m})}),["start","end"].map(d=>{let f=d==="start"?e[0]:e[e.length-1];return B(Te,{x:f.x,y:f.y,cursor:"crosshair",onPointerDown:P=>n(P,{mode:"endpoint",id:t.id,end:d,orig:t})},d)})]})}let a=k(t),s=5,l=[{corner:"nw",x:a.x-s,y:a.y-s},{corner:"ne",x:a.x+a.w+s,y:a.y-s},{corner:"sw",x:a.x-s,y:a.y+a.h+s},{corner:"se",x:a.x+a.w+s,y:a.y+a.h+s}],c=t.type!=="text";return yn("g",{className:"zui-drawing-selection",children:[B(To,{rect:a,pad:s}),c&&l.map(({corner:u,x,y})=>B(Te,{x,y,square:!0,cursor:u==="nw"||u==="se"?"nwse-resize":"nesw-resize",onPointerDown:m=>n(m,{mode:"resize",id:t.id,corner:u,orig:t})},u))]})}function To({rect:t,pad:e}){return B("rect",{x:t.x-e,y:t.y-e,width:t.w+e*2,height:t.h+e*2,rx:6,fill:"none",stroke:"currentColor",strokeWidth:1,strokeDasharray:"5 4",pointerEvents:"none"})}function Ro({shapes:t,paths:e}){if(!t.length)return null;let n=t.map(o=>{if(!T(o.type))return k(o);let i=e.get(o.id)??[],r=i.map(c=>c.x),a=i.map(c=>c.y),s=Math.min(...r),l=Math.min(...a);return{x:s,y:l,w:Math.max(...r)-s,h:Math.max(...a)-l}});return yn("g",{className:"zui-drawing-selection",pointerEvents:"none",children:[n.map((o,i)=>B("rect",{x:o.x-3,y:o.y-3,width:o.w+6,height:o.h+6,rx:4,fill:"none",stroke:"currentColor",strokeWidth:1,opacity:.45},t[i].id)),B(To,{rect:Lt(n),pad:8})]})}function No({rect:t}){return B("rect",{className:"zui-drawing-selection",x:t.x,y:t.y,width:t.w,height:t.h,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeWidth:1,pointerEvents:"none"})}import{jsx as q,jsxs as Re}from"react/jsx-runtime";var D=t=>Number.isInteger(t)?String(t):t.toFixed(2);function Co({shape:t,stroke:e}){let n=k(t),o=t.fill;switch(t.type){case"rect":return q("rect",{...e,x:n.x,y:n.y,width:n.w,height:n.h,rx:Math.min(8,n.w/4,n.h/4),fill:o});case"ellipse":return q("ellipse",{...e,cx:n.x+n.w/2,cy:n.y+n.h/2,rx:n.w/2,ry:n.h/2,fill:o});case"diamond":return q("polygon",{...e,points:`${D(n.x+n.w/2)},${D(n.y)} ${D(n.x+n.w)},${D(n.y+n.h/2)} ${D(n.x+n.w/2)},${D(n.y+n.h)} ${D(n.x)},${D(n.y+n.h/2)}`,fill:o});case"note":{let i=Et(n),r=n.x+n.w,a=n.y+n.h;return Re("g",{children:[q("path",{...e,d:`M ${D(n.x)} ${D(n.y)} H ${D(r)} V ${D(a-i)} L ${D(r-i)} ${D(a)} H ${D(n.x)} Z`,fill:o}),q("path",{...e,d:`M ${D(r-i)} ${D(a)} V ${D(a-i)} H ${D(r)}`,fill:"rgba(0,0,0,0.08)"})]})}case"cylinder":{let i=Tt(n),r=n.w/2,a=n.x+r;return Re("g",{children:[q("path",{...e,d:`M ${D(n.x)} ${D(n.y+i)} V ${D(n.y+n.h-i)} A ${D(r)} ${D(i)} 0 0 0 ${D(n.x+n.w)} ${D(n.y+n.h-i)} V ${D(n.y+i)}`,fill:o}),q("ellipse",{...e,cx:a,cy:n.y+i,rx:r,ry:i,fill:o})]})}case"cloud":{let i=(r,a)=>`${D(n.x+r*n.w)} ${D(n.y+a*n.h)}`;return q("path",{...e,d:`M ${i(.22,.86)} C ${i(.04,.88)} ${i(0,.58)} ${i(.16,.5)} C ${i(.08,.26)} ${i(.3,.12)} ${i(.42,.28)} C ${i(.5,.02)} ${i(.76,.04)} ${i(.78,.3)} C ${i(.98,.26)} ${i(1.04,.56)} ${i(.88,.64)} C ${i(1,.8)} ${i(.9,.9)} ${i(.76,.86)} Z`,fill:o})}case"queue":{let i=Rt(n),r=n.h/2;return Re("g",{children:[q("path",{...e,d:`M ${D(n.x+i)} ${D(n.y)} H ${D(n.x+n.w-i)} V ${D(n.y+n.h)} H ${D(n.x+i)} A ${D(i)} ${D(r)} 0 0 1 ${D(n.x+i)} ${D(n.y)} Z`,fill:o}),q("ellipse",{...e,cx:n.x+n.w-i,cy:n.y+r,rx:i,ry:r,fill:o})]})}case"actor":{let i=n.h*Ht,r=n.x+n.w/2,a=Math.max(4,Math.min(i*.16,n.w*.2)),s=n.y+a*2,l=n.y+i*.62,c=s+i*.12,u=Math.min(n.w*.32,i*.3);return Re("g",{children:[q("circle",{...e,cx:r,cy:n.y+a,r:a,fill:o}),q("path",{...e,fill:"none",d:`M ${D(r)} ${D(s)} V ${D(l)} M ${D(r-u)} ${D(c)} H ${D(r+u)} M ${D(r)} ${D(l)} L ${D(r-u)} ${D(n.y+i)} M ${D(r)} ${D(l)} L ${D(r+u)} ${D(n.y+i)}`})]})}default:return null}}function pn(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function vo(t){let e=t>>>0;return()=>{e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function Io(t){return Math.min(4,Math.max(1,t*.03))}function _o(t){let e=vo(t^2654435769),n=e()*Math.PI*2,o=2+e();return{x:Math.cos(n)*o,y:Math.sin(n)*o}}function pr(t,e,n){let o=vo(t),i=(g,d)=>g+Math.floor(o()*d),r=n?i(2,2):1.5+o(),a=n?i(5,3):3+o()*2,s=n?i(2,2):1+o(),l=o()*Math.PI*2,c=o()*Math.PI*2,u=o()*Math.PI*2,x=e*(.55+o()*.15),y=e*.3,m=Math.PI*2;return{offset:g=>x*Math.sin(m*r*g+l)+y*Math.sin(m*a*g+c),pressure:g=>1+.3*Math.sin(m*s*g+u)}}function fr(t,e){let n=e?[...t,t[0]]:[...t],o=[],i=0;for(let l=1;l<n.length;l++){let c=Math.hypot(n[l].x-n[l-1].x,n[l].y-n[l-1].y);o.push(c),i+=c}if(i===0)return{points:[n[0]],ts:[0]};let r=[],a=[],s=0;for(let l=1;l<n.length;l++){let c=n[l-1],u=n[l],x=o[l-1],y=Math.max(1,Math.round(x/5));for(let m=0;m<y;m++){let g=m/y;r.push({x:c.x+(u.x-c.x)*g,y:c.y+(u.y-c.y)*g}),a.push((s+x*g)/i)}s+=x}return e||(r.push(n[n.length-1]),a.push(1)),{points:r,ts:a}}function hr(t,e,n){let o=t.length,i=t[n?(e-1+o)%o:Math.max(0,e-1)],r=t[n?(e+1)%o:Math.min(o-1,e+1)],a=r.x-i.x,s=r.y-i.y,l=Math.hypot(a,s)||1;return{x:-s/l,y:a/l}}var Oo=t=>Number.isInteger(t)?String(t):t.toFixed(2),Nt=t=>t.map((e,n)=>`${n===0?"M":"L"} ${Oo(e.x)} ${Oo(e.y)}`).join(" ");function Ct(t,e){if(t.length<2)return{ring:"",center:""};let{closed:n,seed:o,width:i,amplitude:r}=e,a=pr(o,r,n),{points:s,ts:l}=fr(t,n);if(s.length<2)return{ring:"",center:""};let c=[],u=[],x=[];for(let y=0;y<s.length;y++){let m=l[y],g=hr(s,y,n),d=a.offset(m),f={x:s[y].x+g.x*d,y:s[y].y+g.y*d},P=n?1:.55+.45*Math.min(1,m/.1,(1-m)/.1),b=i*a.pressure(m)*P/2;c.push(f),u.push({x:f.x+g.x*b,y:f.y+g.y*b}),x.push({x:f.x-g.x*b,y:f.y-g.y*b})}return n?{ring:`${Nt(u)} Z ${Nt([...x].reverse())} Z`,center:`${Nt(c)} Z`}:{ring:`${Nt(u)} ${Nt([...x].reverse()).replace(/^M/,"L")} Z`,center:Nt(c)}}function Ao(t,e,n=4){let o=Math.min(e,t.w/2,t.h/2);if(o<=0)return[{x:t.x,y:t.y},{x:t.x+t.w,y:t.y},{x:t.x+t.w,y:t.y+t.h},{x:t.x,y:t.y+t.h}];let i=[[t.x+t.w-o,t.y+o,-Math.PI/2],[t.x+t.w-o,t.y+t.h-o,0],[t.x+o,t.y+t.h-o,Math.PI/2],[t.x+o,t.y+o,Math.PI]],r=[];for(let[a,s,l]of i)for(let c=0;c<=n;c++){let u=l+Math.PI/2*(c/n);r.push({x:a+o*Math.cos(u),y:s+o*Math.sin(u)})}return r}function Bo(t,e=6,n=4){if(t.length<3)return[...t];let o=[t[0]];for(let i=1;i<t.length-1;i++){let r=t[i-1],a=t[i],s=t[i+1],l=Math.hypot(a.x-r.x,a.y-r.y),c=Math.hypot(s.x-a.x,s.y-a.y),u=Math.min(e,l/2,c/2);if(u<.5){o.push(a);continue}let x={x:a.x-(a.x-r.x)/l*u,y:a.y-(a.y-r.y)/l*u},y={x:a.x+(s.x-a.x)/c*u,y:a.y+(s.y-a.y)/c*u};for(let m=0;m<=n;m++){let g=m/n,d=1-g;o.push({x:d*d*x.x+2*d*g*a.x+g*g*y.x,y:d*d*x.y+2*d*g*a.y+g*g*y.y})}}return o.push(t[t.length-1]),o}function $o(t,e,n,o,i=10){let r=[];for(let a=1;a<=i;a++){let s=a/i,l=1-s;r.push({x:l*l*l*t.x+3*l*l*s*e.x+3*l*s*s*n.x+s*s*s*o.x,y:l*l*l*t.y+3*l*l*s*e.y+3*l*s*s*n.y+s*s*s*o.y})}return r}function fn(t,e,n,o,i,r,a=12){return Array.from({length:a+1},(s,l)=>{let c=i+(r-i)*l/a;return{x:t+n*Math.cos(c),y:e+o*Math.sin(c)}})}import{jsx as pt,jsxs as Ot}from"react/jsx-runtime";var Ne=t=>Number.isInteger(t)?String(t):t.toFixed(2);function Lo(t){let e=1/0,n=1/0,o=-1/0,i=-1/0;for(let r of t)r.x<e&&(e=r.x),r.x>o&&(o=r.x),r.y<n&&(n=r.y),r.y>i&&(i=r.y);return{w:o-e,h:i-n}}function zo({shape:t}){let e=k(t),n=pn(t.id),o=t.strokeWidth,i=_o(n),r=`translate(${Ne(i.x)} ${Ne(i.y)})`,a=c=>Io(Math.min(Lo(c).w,Lo(c).h)),s=(c,u,x=t.fill)=>{let y=Ct(c,{closed:!0,seed:n+u,width:o,amplitude:a(c)});return Ot("g",{children:[pt("path",{d:y.center,fill:x,stroke:"none",transform:r}),pt("path",{d:y.ring,fill:t.stroke,fillRule:"evenodd",stroke:"none"})]})},l=(c,u,x=o)=>pt("path",{d:Ct(c,{closed:!1,seed:n+u,width:x,amplitude:a(c)}).ring,fill:t.stroke,stroke:"none"});switch(t.type){case"rect":return s(Ao(e,Math.min(8,e.w/4,e.h/4)),0);case"ellipse":return s(ut(e,64),0);case"diamond":return s([{x:e.x+e.w/2,y:e.y},{x:e.x+e.w,y:e.y+e.h/2},{x:e.x+e.w/2,y:e.y+e.h},{x:e.x,y:e.y+e.h/2}],0);case"note":{let c=Et(e),u=e.x+e.w,x=e.y+e.h,y=[{x:e.x,y:e.y},{x:u,y:e.y},{x:u,y:x-c},{x:u-c,y:x},{x:e.x,y:x}],m=[{x:u-c,y:x},{x:u-c,y:x-c},{x:u,y:x-c}];return Ot("g",{children:[s(y,0),pt("path",{d:`M ${m.map(g=>`${Ne(g.x)} ${Ne(g.y)}`).join(" L ")} Z`,fill:"rgba(0,0,0,0.08)",stroke:"none"}),l(m,1)]})}case"cylinder":{let c=Tt(e),u=e.w/2,x=e.x+u,y=[{x:e.x,y:e.y+c},{x:e.x,y:e.y+e.h-c},...fn(x,e.y+e.h-c,u,c,Math.PI,0,16),{x:e.x+e.w,y:e.y+c}],m=Ct(y,{closed:!1,seed:n+0,width:o,amplitude:a(y)});return Ot("g",{children:[pt("path",{d:`${m.center} Z`,fill:t.fill,stroke:"none",transform:r}),pt("path",{d:m.ring,fill:t.stroke,stroke:"none"}),s(ut({x:e.x,y:e.y,w:e.w,h:c*2},48),1)]})}case"cloud":{let c=(g,d)=>({x:e.x+g*e.w,y:e.y+d*e.h}),u=c(.22,.86),x=[[c(.04,.88),c(0,.58),c(.16,.5)],[c(.08,.26),c(.3,.12),c(.42,.28)],[c(.5,.02),c(.76,.04),c(.78,.3)],[c(.98,.26),c(1.04,.56),c(.88,.64)],[c(1,.8),c(.9,.9),c(.76,.86)]],y=[u],m=u;for(let[g,d,f]of x)y.push(...$o(m,g,d,f,8)),m=f;return s(y,0)}case"queue":{let c=Rt(e),u=e.h/2,x=[{x:e.x+c,y:e.y},{x:e.x+e.w-c,y:e.y},{x:e.x+e.w-c,y:e.y+e.h},{x:e.x+c,y:e.y+e.h},...fn(e.x+c,e.y+u,c,u,Math.PI/2,3*Math.PI/2,16).slice(1,-1)];return Ot("g",{children:[s(x,0),s(ut({x:e.x+e.w-c*2,y:e.y,w:c*2,h:e.h},48),1)]})}case"actor":{let c=e.h*Ht,u=e.x+e.w/2,x=Math.max(4,Math.min(c*.16,e.w*.2)),y=e.y+x*2,m=e.y+c*.62,g=y+c*.12,d=Math.min(e.w*.32,c*.3);return Ot("g",{children:[s(ut({x:u-x,y:e.y,w:x*2,h:x*2},32),0),l([{x:u,y},{x:u,y:m}],1),l([{x:u-d,y:g},{x:u+d,y:g}],2),l([{x:u-d,y:e.y+c},{x:u,y:m},{x:u+d,y:e.y+c}],3)]})}default:return null}}function Ho({shape:t,points:e}){if(e.length<2)return null;let n=pn(t.id),o=sn(e),i=Math.min(3,Math.max(.8,o*.015)),r=t.strokeWidth,a=Ct(Bo(e),{closed:!1,seed:n,width:r,amplitude:i}),s=[];if(t.type==="arrow"&&o>=1){let l=Math.min(14,4+o/4),c=e.length-1;s.push(De(e[c],Yt(e,c,!1),l)),t.bidirectional&&s.push(De(e[0],Yt(e,0,!0),l))}return Ot("g",{fill:t.stroke,stroke:"none",children:[pt("path",{d:a.ring}),s.map((l,c)=>pt("path",{d:Ct(l,{closed:!1,seed:n+1+c,width:r*1.15,amplitude:.8}).ring},c))]})}import{Fragment as wr,jsx as $,jsxs as jt}from"react/jsx-runtime";import{createElement as xn}from"react";var st=12,gn=160;function Oe(t){let e=me(t);return{area:e?e.textArea(t):k(t),slots:e?e.textSlots:["label","text","footer"]}}function mn(t,e){let{area:n,slots:o}=Oe(t),i=(e-n.y)/Math.max(n.h,1);return i<.3&&o.includes("label")?"label":i>.7&&o.includes("footer")?"footer":o.includes("text")?"text":o[0]}var Ce={userSelect:"none"};function xr(t){let e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(!e)return 1;let n=e[1].length===3?e[1].replace(/./g,a=>a+a):e[1],[o,i,r]=[0,2,4].map(a=>parseInt(n.slice(a,a+2),16)/255);return .2126*o+.7152*i+.0722*r}function wn(t){return t.stroke==="transparent"||t.stroke==="none"?"#1e1e1e":xr(t.fill)<.35?"#ffffff":t.stroke}var hn={userSelect:"none",pointerEvents:"none"};function gr({shape:t,hideField:e,showHints:n}){let{area:o,slots:i}=Oe(t),r=o.x+o.w/2,a=Math.max(o.w,20),s=n&&o.h>=56&&o.w>=44,l=ot(t.text??"",a,I),c=ot(t.label??"",a,z),u=ot(t.footer??"",a,z),x=I*et,y=z*et,m=o.y+o.h/2-(l.length-1)*x/2+I*.35,g={fill:wn(t),textAnchor:"middle"};return jt("g",{children:[i.includes("label")&&e!=="label"&&(t.label?c.map((d,f)=>xn("text",{...g,key:f,x:r,y:o.y+z+f*y,fontSize:z,fontWeight:600,letterSpacing:.3,opacity:.85,style:Ce},d)):s&&$("text",{...g,x:r,y:o.y+z,fontSize:z,opacity:.3,style:hn,children:"Label"})),i.includes("text")&&e!=="text"&&(t.text?l.map((d,f)=>xn("text",{...g,key:f,x:r,y:m+f*x,fontSize:I,style:Ce},d)):s&&$("text",{...g,x:r,y:m,fontSize:I,opacity:.3,style:hn,children:"Text"})),i.includes("footer")&&e!=="footer"&&(t.footer?u.map((d,f)=>xn("text",{...g,key:f,x:r,y:o.y+o.h-3-(u.length-1-f)*y,fontSize:z,opacity:.65,style:Ce},d)):s&&$("text",{...g,x:r,y:o.y+o.h-3,fontSize:z,opacity:.3,style:hn,children:"Footer"}))]})}function mr({shape:t,points:e}){let n=t.text??"",o=ot(n,gn,st),i=U(o.join(`
|
|
8
|
-
`),st),{x:r,y:a}=ke(e),s=st*et,l=a-(o.length-1)*s/2+st*.35;return jt("g",{children:[$("rect",{x:r-i.w/2-5,y:a-i.h/2-3,width:i.w+10,height:i.h+6,rx:5,className:"zui-drawing-label-plate",opacity:.94}),o.map((c,u)=>$("text",{x:r,y:l+u*s,fill:t.stroke,fontSize:st,textAnchor:"middle",style:Ce,children:c},u))]})}function Wo({shape:t,points:e,hideField:n,showHints:o,ink:i=!1}){let r={stroke:t.stroke,strokeWidth:t.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round"};if(A(t.type))return jt("g",{children:[i?$(zo,{shape:t}):$(Co,{shape:t,stroke:r}),$(gr,{shape:t,hideField:n,showHints:o})]});if(T(t.type)){let a=e??[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y+t.height}];return jt("g",{children:[i?$(Ho,{shape:t,points:a}):jt(wr,{children:[$("path",{...r,d:an(a),fill:"none"}),Po(t,a).map((s,l)=>$("path",{...r,d:s,fill:"none"},l))]}),t.text&&n!=="text"&&$(mr,{shape:t,points:a})]})}return $("text",{x:t.x,y:t.y+I,fill:t.stroke,fontSize:I,style:{userSelect:"none",whiteSpace:"pre"},children:(t.text??"").split(`
|
|
9
|
-
`).map((a,s)=>$("tspan",{x:t.x,dy:s===0?0:I*et,children:a},s))})}function Fo({shape:t,points:e}){if(T(t.type)&&e)return $("path",{d:an(e),fill:"none",stroke:"transparent",strokeWidth:16});let n=k(t);return $("rect",{x:n.x-2,y:n.y-2,width:Math.max(n.w,8)+4,height:Math.max(n.h,8)+4,fill:"transparent",stroke:"none"})}import{useEffect as br,useRef as Go,useState as Sr}from"react";import{jsx as Mr}from"react/jsx-runtime";function Ko({shape:t,field:e,points:n,onCommit:o}){let i=t[e]??"",[r,a]=Sr(i),s=Go(null),l=Go(r);l.current=r,br(()=>{let y=s.current;if(!y)return;y.focus(),y.select();let m=d=>{if(d.stopPropagation(),(d.key==="Home"||d.key==="End")&&!d.shiftKey&&!d.metaKey&&!d.ctrlKey){d.preventDefault();let f=y.value,P=d.key==="Home"?y.selectionStart:y.selectionEnd,b=d.key==="Home"?f.lastIndexOf(`
|
|
10
|
-
`,P-1)+1:(f.indexOf(`
|
|
11
|
-
`,P)+1||f.length+1)-1;y.setSelectionRange(b,b);return}d.key==="Enter"&&!d.shiftKey?(d.preventDefault(),o(t.id,e,l.current)):d.key==="Escape"&&(d.preventDefault(),o(t.id,e,i))},g=d=>d.stopPropagation();return y.addEventListener("keydown",m),y.addEventListener("keyup",g),y.addEventListener("keypress",g),()=>{y.removeEventListener("keydown",m),y.removeEventListener("keyup",g),y.removeEventListener("keypress",g)}},[]);let c={color:wn(t),fontFamily:"var(--zui-drawing-font)",lineHeight:et};if(t.type==="text"){let y=U(r||" ");Object.assign(c,{left:t.x,top:t.y,fontSize:I,width:Math.max(80,y.w+20),height:y.h+2,whiteSpace:"pre-wrap"})}else if(T(t.type)){let y=ot(r,gn,st),m=U(y.join(`
|
|
12
|
-
`)||" ",st),g=Math.max(70,m.w+16),d=m.h+4,f=ke(n??[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y+t.height}]);Object.assign(c,{left:f.x-g/2,top:f.y-d/2,width:g,height:d,fontSize:st,textAlign:"center",whiteSpace:"pre-wrap"})}else{let{area:y}=Oe(t),m=e==="text"?I:z,g=Math.max(y.w,40),f=ot(r,g,m).length*m*et+2,P=e==="label"?y.y-1:e==="footer"?y.y+y.h-f+1:y.y+y.h/2-f/2;Object.assign(c,{left:y.x,top:P,width:g,height:f,fontSize:m,fontWeight:e==="label"?600:void 0,letterSpacing:e==="label"?.3:void 0,opacity:e==="text"?1:e==="label"?.85:.65,textAlign:"center",whiteSpace:"pre-wrap"})}let u=K().drawing,x=e==="label"?u.labelPlaceholder:e==="footer"?u.footerPlaceholder:u.textPlaceholder;return Mr("textarea",{ref:s,className:"zui-drawing-text-input",style:c,value:r,placeholder:x,spellCheck:!1,onChange:y=>a(y.target.value),onBlur:()=>o(t.id,e,r),onPointerDown:y=>y.stopPropagation()})}import{useEffect as Pr,useRef as Dr,useState as bn}from"react";import{Fragment as Er,jsx as J,jsxs as vt}from"react/jsx-runtime";var kr=[{tool:"select",label:"select"},{tool:"rect",label:"rect"},{tool:"ellipse",label:"ellipse"},{tool:"diamond",label:"diamond"},{tool:"arrow",label:"arrow"},{tool:"line",label:"line"},{tool:"text",label:"text"}],Yo=["note","cylinder","cloud","queue","actor"];function Sn({label:t,active:e,onClick:n,children:o,className:i,pressed:r}){return J("button",{type:"button",title:t,"aria-label":t,"aria-pressed":r??e,className:`zui-drawing-tool ${e?"is-active":""} ${i??""}`,onClick:n,[ze]:"",children:J(yt,{children:o})})}function qo({tool:t,onToolChange:e,width:n,onWidthChange:o,onCopyMermaid:i,properties:r}){let[a,s]=bn(!1),[l,c]=bn("note"),[u,x]=bn(!1),y=Dr(null),m=Wn(),g=K(),d=g.drawing;Pr(()=>{if(!a)return;let b=_=>{y.current?.contains(_.target)||s(!1)},F=_=>{_.key==="Escape"&&s(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",F),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",F)}},[a]);let f=Yo.includes(t),P=f?Vt[t]:Vt[l];return vt(Er,{children:[vt("div",{className:"zui-drawing-toolbar-group",role:"toolbar","aria-label":d.tools,...m,children:[kr.map(({tool:b,label:F})=>J(Sn,{label:d[F],active:t===b,onClick:()=>e(b),children:Vt[b]},b)),vt("div",{className:"zui-drawing-more",ref:y,children:[vt("button",{type:"button",title:d.moreShapes,"aria-label":d.moreShapes,"aria-haspopup":"menu","aria-expanded":a,className:`zui-drawing-tool zui-drawing-tool-more ${f?"is-active":""}`,onClick:()=>s(b=>!b),[ze]:"",children:[J(yt,{children:P}),J("span",{className:"zui-drawing-caret","aria-hidden":"true"})]}),a&&J("div",{className:"zui-drawing-popover",role:"menu",children:Yo.map(b=>vt("button",{type:"button",role:"menuitemradio","aria-checked":t===b,className:`zui-drawing-popover-item ${t===b?"is-active":""}`,onClick:()=>{c(b),e(b),s(!1)},children:[J(yt,{size:18,children:Vt[b]}),J("span",{children:d[b]})]},b))})]})]}),r,vt("div",{className:"zui-drawing-toolbar-group zui-drawing-toolbar-group-end",children:[J(Sn,{label:u?d.copiedMermaid:d.copyMermaid,className:u?"is-success":"",onClick:()=>{i().then(b=>{b&&(x(!0),setTimeout(()=>x(!1),1600))})},children:u?Z.check:Z.mermaid}),J("span",{className:"zui-drawing-toolbar-divider"}),zn.map(({preset:b,label:F,icon:_,width:ct})=>J(Sn,{label:g.layout[F],active:Hn(n)===b,onClick:()=>o(ct),children:_},b))]})]})}import{jsx as L,jsxs as ve}from"react/jsx-runtime";var Or=120,vr=1200,Ir={full:"",text:"is-text-width",content:"is-content-width"},_r=240,Ar=40,bt=new Set;function Br(t,e){let n=0;for(let o of t)if(T(o.type))for(let i of e.get(o.id)??[])n=Math.max(n,i.x);else{let i=k(o);n=Math.max(n,i.x+i.w)}return Math.max(_r,Math.ceil(n+Ar))}function $r(t){let e=new Map;for(let n of t)T(n.type)&&e.set(n.id,rn(n,t));return e}function Pn({nodeKey:t,data:e}){let[n]=Nr(),o=Cr(),[i,r]=Q(e.shapes),[a,s]=Q(e.canvasHeight),[l,c]=Q(e.width??"full"),u=Tr(An)?.drawingStyle==="ink",x=K().drawing,[y,m]=Q("select"),[g,d]=Q(bt),[f,P]=Q(null),[b,F]=Q(Dt[0]),[_,ct]=Q(Xn[0]),[_t,En]=Q(null),[Ie,Tn]=Q(null),[Rn,Nn]=Q(1),Qt=W(null),te=W(null),tt=W(null),ee=W(null),_e=W(null),St=W(null),ne=W(Y(e)),G=W(i);G.current=i;let Ae=W(a);Ae.current=a;let Cn=W(l);Cn.current=l;let At=W(g);At.current=g;let lt=Vo(()=>$r(i),[i]),oe=e.canvasWidth,V=oe??(l==="content"?Br(i,lt):null);Mn(()=>{let p=Y(e);p!==ne.current&&(ne.current=p,r(e.shapes),s(e.canvasHeight),c(e.width??"full"),d(bt),P(null))},[e]),Mn(()=>{let p=te.current;if(!V||!p||typeof ResizeObserver>"u"){Nn(1);return}let h=()=>{let w=p.getBoundingClientRect();Nn(w.width>0?w.width/V:1)};h();let S=new ResizeObserver(h);return S.observe(p),()=>S.disconnect()},[V]);let Bt=v((p,h)=>{let S=h?.width??Cn.current,w=h?.width===void 0&&e.width!==void 0,M={version:3,...oe?{canvasWidth:oe}:{},canvasHeight:h?.height??Ae.current,...S!=="full"||w?{width:S}:{},...e.title?{title:e.title}:{},...e.description?{description:e.description}:{},shapes:p},E=Y(M);E!==ne.current&&(ne.current=E,n.update(()=>{let N=Rr(t);Dn(N)&&N.setData(M)}))},[n,t,oe,e.width,e.title,e.description]),C=v((p,h)=>{r(S=>{let w=be(p(S));return h?.commit&&Bt(w),w})},[Bt]),it=v(p=>{let h=te.current;if(!h)return{x:0,y:0};let S=h.getScreenCTM();if(!S){let M=h.getBoundingClientRect();return{x:p.clientX-M.left,y:p.clientY-M.top}}let w=S.inverse();return{x:w.a*p.clientX+w.c*p.clientY+w.e,y:w.b*p.clientX+w.d*p.clientY+w.f}},[]),ht=Vo(()=>i.filter(p=>g.has(p.id)),[i,g]),Mt=ht.length===1?ht[0]:null,rt=v((p,h)=>{P({id:p,field:h}),d(new Set([p]))},[]),ie=p=>{te.current?.setPointerCapture(p.pointerId)},jo=v(p=>{if(!o||f||p.button!==0)return;let h=it(p);if(ie(p),y==="select"){p.shiftKey||d(bt),tt.current={mode:"marquee",origin:h,current:h,additive:p.shiftKey};return}if(y==="text"){let E=Ge(),N=U("");C(dt=>[...dt,{id:E,type:"text",x:h.x,y:h.y-I/2,width:N.w,height:N.h,stroke:b,fill:"transparent",strokeWidth:2,text:""}]),m("select"),d(new Set([E])),ee.current=E;return}let S=Ge(),w=A(y)?gt[y]:null,M=w?_==="transparent"&&w.defaultFill?w.defaultFill:_:"transparent";tt.current={mode:"draw",id:S,origin:h},d(bt),C(E=>[...E,{id:S,type:y,x:h.x,y:h.y,width:0,height:0,stroke:b,fill:M,strokeWidth:2}])},[o,f,it,y,b,_,C,rt]),Jo=v((p,h)=>{if(!o||y!=="select"||f||p.button!==0)return;p.stopPropagation();let S=it(p);ie(p);let w=At.current;if(p.shiftKey){if(w.has(h.id)){let dt=new Set(w);dt.delete(h.id),d(dt);return}let N=new Set(w).add(h.id);d(N),tt.current={mode:"move",clickedId:h.id,origin:S,origs:dn(G.current,N,h.id),wasSelected:!1};return}let M=w.size===1&&w.has(h.id),E=w.has(h.id)?w:new Set([h.id]);w.has(h.id)||d(E),tt.current={mode:"move",clickedId:h.id,origin:S,origs:dn(G.current,E,h.id),wasSelected:M}},[o,y,f,it]),Qo=v((p,h)=>{if(!(!o||p.button!==0)&&(p.stopPropagation(),ie(p),tt.current=h,h.mode==="endpoint")){let S=h.end==="start"?"startBinding":"endBinding";C(w=>w.map(M=>M.id===h.id?{...M,[S]:void 0}:M))}},[o,C]),On=v(()=>{St.current=null;let p=_e.current,h=tt.current;if(!(!p||!h)){if(h.mode==="marquee"){h.current=p,Tn({origin:h.origin,current:p});return}if(C(S=>ln(S,h,p)),h.mode==="endpoint"||h.mode==="draw"&&T(G.current.find(S=>S.id===h.id)?.type??"")){let S=Wt(G.current,p,h.id);En(w=>w===(S?.id??null)?w:S?.id??null)}}},[C]),ti=v(p=>{tt.current&&(_e.current=it(p),St.current===null&&(St.current=requestAnimationFrame(On)))},[it,On]),vn=v(p=>{let h=tt.current;if(tt.current=null,St.current!==null&&(cancelAnimationFrame(St.current),St.current=null),_e.current=null,En(null),ee.current){let w=ee.current;ee.current=null,rt(w,"text");return}if(!h)return;let S=it(p);if(h.mode==="marquee"){Tn(null);let w=cn(h.origin,S);if(w.w<Ut&&w.h<Ut)return;let M=Do(G.current,w,lt);d(E=>h.additive?new Set([...E,...M]):new Set(M));return}if(h.mode==="move"&&h.wasSelected){let w=Math.abs(S.x-h.origin.x)>Ut||Math.abs(S.y-h.origin.y)>Ut,M=G.current.find(E=>E.id===h.clickedId);if(!w&&M){C(E=>ln(E,h,h.origin)),M.type==="text"||T(M.type)?rt(M.id,"text"):rt(M.id,mn(M,h.origin.y));return}}if(h.mode==="draw"){let w=G.current.find(M=>M.id===h.id);if(w&&Math.abs(w.width)<4&&Math.abs(w.height)<4){if(w&&A(w.type)){let M=gt[w.type].defaultSize;C(E=>E.map(N=>N.id===h.id?{...N,x:N.x-M.w/2,y:N.y-M.h/2,w:M.w,h:M.h}:N),{commit:!0}),m("select"),d(new Set([h.id]))}else C(M=>M.filter(E=>E.id!==h.id));return}w&&T(w.type)&&C(M=>M.map(E=>E.id===h.id?so(E,M):E)),m("select"),d(new Set([h.id]))}h.mode==="endpoint"&&C(w=>w.map(M=>{if(M.id!==h.id)return M;let E=h.end==="start"?{x:M.x,y:M.y}:{x:M.x+M.width,y:M.y+M.height},N=Wt(w,E,M.id),dt=h.end==="start"?M.endBinding:M.startBinding;if(N&&N.id===dt?.id)return M;let yi=h.end==="start"?"startBinding":"endBinding";return{...M,[yi]:N?we(N,E):void 0}})),C(w=>w.map(Jn),{commit:!0})},[it,lt,C,rt]),Be=v(()=>{let p=At.current;p.size&&(P(null),d(bt),C(h=>h.filter(S=>!p.has(S.id)&&!(S.startBinding&&p.has(S.startBinding.id))&&!(S.endBinding&&p.has(S.endBinding.id))),{commit:!0}))},[C]),In=W(f);In.current=f,Mn(()=>{let p=Qt.current;if(!p||!o)return;let h=S=>{if(In.current)return;let w=At.current;if((S.key==="Delete"||S.key==="Backspace")&&w.size)S.preventDefault(),S.stopPropagation(),Be();else if(S.key==="Enter"&&w.size===1){let[M]=w,E=G.current.find(N=>N.id===M);E&&(S.preventDefault(),S.stopPropagation(),rt(E.id,"text"))}else S.key==="a"&&(S.metaKey||S.ctrlKey)&&!S.shiftKey&&!S.altKey?(S.preventDefault(),S.stopPropagation(),d(new Set(G.current.map(M=>M.id)))):S.key==="Escape"&&(S.stopPropagation(),d(bt),m("select"))};return p.addEventListener("keydown",h),()=>p.removeEventListener("keydown",h)},[o,Be,rt]);let Pt=v(p=>{let h=At.current;h.size&&C(S=>S.map(w=>h.has(w.id)?p(w):w),{commit:!0})},[C]),ei=v(p=>{let h=X[p];F(h.stroke),ct(h.fill),Pt(S=>A(S.type)?{...S,stroke:h.stroke,fill:h.fill}:{...S,stroke:h.stroke==="transparent"?Dt[0]:h.stroke})},[Pt]),ni=v(p=>Pt(h=>T(h.type)?{...h,routing:p?"elbow":void 0,elbow:void 0,waypoints:void 0}:h),[Pt]),oi=v(p=>Pt(h=>h.type==="arrow"?{...h,bidirectional:p||void 0}:h),[Pt]),ii=v(p=>{c(p),Bt(G.current,{width:p})},[Bt]),ri=v((p,h,S,w)=>{!o||p.button!==0||(p.stopPropagation(),ie(p),C(M=>M.map(E=>{if(E.id!==h||!T(E.type))return E;let N=rn(E,M).slice(1,-1),dt=[...N.slice(0,S),w,...N.slice(S)];return{...E,waypoints:dt,routing:void 0,elbow:void 0}})),tt.current={mode:"waypoint",id:h,index:S})},[o,C]),ai=v((p,h)=>{C(S=>S.map(w=>{if(w.id!==p||!w.waypoints)return w;let M=w.waypoints.filter((E,N)=>N!==h);return{...w,waypoints:M.length?M:void 0}}),{commit:!0})},[C]),si=v((p,h,S)=>{P(null),Qt.current?.focus({preventScroll:!0}),C(w=>w.flatMap(M=>M.id!==p?[M]:M.type==="text"?S.trim()===""?[]:[{...M,text:S,...U(S)}]:[{...M,[h]:S.trim()===""?void 0:S}]),{commit:!0})},[C]),ci=v(async()=>{let p={version:3,canvasHeight:Ae.current,shapes:G.current};try{return await navigator.clipboard.writeText(co(p)),!0}catch{return!1}},[]),re=i.find(p=>p.id===f?.id)??null,_n=_t?i.find(p=>p.id===_t):null,li=Mt?.stroke??ht[0]?.stroke??b,di=Mt?.fill??ht[0]?.fill??_,ui=y==="select"?"default":y==="text"?"text":"crosshair";return ve("div",{ref:Qt,className:`zui-drawing-canvas ${Ir[l]} ${o?"is-editable":""} ${u?"is-ink":""}`,tabIndex:o?0:void 0,onFocus:()=>n.dispatchCommand(Le,t),onBlur:p=>{Qt.current?.contains(p.relatedTarget)||n.dispatchCommand(Le,null)},children:[o&&L("div",{className:"zui-drawing-toolbar",onPointerDown:p=>p.stopPropagation(),children:L(qo,{tool:y,onToolChange:p=>{m(p),p!=="select"&&d(bt)},width:l,onWidthChange:ii,onCopyMermaid:ci,properties:L("div",{className:"zui-drawing-props-host",children:L(ko,{selection:ht,stroke:li,fill:di,onColor:ei,onRouting:ni,onDirection:oi,onDelete:Be})})})}),ve("div",{className:"zui-drawing-stage",children:[ve("svg",{ref:te,className:"zui-drawing-surface",role:"img","aria-label":e.title??x.canvas,"aria-description":e.description,style:{height:V?void 0:a,width:V??void 0,maxWidth:"100%",aspectRatio:V?`${V} / ${a}`:void 0,cursor:ui},viewBox:V?`0 0 ${V} ${a}`:void 0,preserveAspectRatio:"xMinYMin meet",onPointerDown:jo,onPointerMove:ti,onPointerUp:vn,onPointerCancel:vn,onDoubleClick:p=>{if(!o)return;let S=p.target.closest("[data-shape-id]")?.getAttribute("data-shape-id"),w=S?i.find(M=>M.id===S):null;w&&(w.type==="text"||T(w.type)?rt(w.id,"text"):rt(w.id,mn(w,it(p).y)))},children:[i.map(p=>ve("g",{"data-shape-id":p.id,className:`zui-drawing-shape ${g.has(p.id)?"is-selected":""}`,style:{cursor:o&&y==="select"?"move":void 0},onPointerDown:h=>Jo(h,p),children:[L(Fo,{shape:p,points:lt.get(p.id)}),p.id===f?.id&&p.type==="text"?null:L(Wo,{shape:p,ink:u,points:lt.get(p.id),hideField:p.id===f?.id?f.field:null,showHints:o&&y==="select"&&Mt?.id===p.id&&p.id!==f?.id})]},p.id)),_n&&L("polygon",{className:"zui-drawing-selection zui-drawing-bind-target",points:Gt(_n).map(p=>`${p.x},${p.y}`).join(" "),fill:"currentColor",fillOpacity:.06,stroke:"currentColor",strokeWidth:2,strokeLinejoin:"round",pointerEvents:"none"}),Mt&&o&&!f&&L(Eo,{shape:Mt,points:lt.get(Mt.id)??[],onHandlePointerDown:Qo,onWaypointAdd:ri,onWaypointRemove:ai}),ht.length>1&&o&&L(Ro,{shapes:ht,paths:lt}),Ie&&L(No,{rect:cn(Ie.origin,Ie.current)})]}),o&&i.length===0&&L("div",{className:"zui-drawing-empty","aria-hidden":"true",children:"Pick a shape above, then click or drag on the canvas"}),re&&f&&L("div",{className:"zui-drawing-overlay",style:{transform:`scale(${Rn})`,width:V??void 0,height:V?a:void 0},children:L(Ko,{shape:re,field:f.field,points:lt.get(re.id),onCommit:si},`${re.id}:${f.field}`)}),o&&L(Lr,{height:a,scale:Rn,onChange:s,onCommit:p=>Bt(G.current,{height:p})})]})]})}function Lr({height:t,scale:e,onChange:n,onCommit:o}){let i=W(null),r=W(t);r.current=t;let a=l=>Math.round(Math.min(vr,Math.max(Or,l))),s=K().drawing.resize;return L("div",{className:"zui-drawing-resize",title:s,role:"separator","aria-orientation":"horizontal",onPointerDown:l=>{l.preventDefault(),l.stopPropagation(),l.currentTarget.setPointerCapture(l.pointerId),i.current={startY:l.clientY,orig:t}},onPointerMove:l=>{let c=i.current;c&&n(a(c.orig+(l.clientY-c.startY)/Math.max(e,.05)))},onPointerUp:()=>{i.current&&(i.current=null,o(r.current))},children:L(yt,{size:14,children:Z.grip})})}import{jsx as Gr}from"react/jsx-runtime";var Wr=64,Jt=new Map;function Fr(t){let e=Jt.get(t);if(e)return e;let n=ye(t);if(Jt.size>=Wr){let o=Jt.keys().next().value;o!==void 0&&Jt.delete(o)}return Jt.set(t,n),n}var ft=class t extends Hr{static getType(){return"drawing"}static clone(e){return new t(e.__data,e.__key)}constructor(e,n){super(n),this.__data=e}static importJSON(e){return It(e.data)}exportJSON(){return{data:this.__data,type:"drawing",version:1}}createDOM(e){let n=document.createElement("div"),o=e.theme.drawing;return n.className=typeof o=="string"?o:"zui-drawing",n}updateDOM(){return!1}exportDOM(){let e=document.createElement("pre");return e.setAttribute("data-drawing",this.__data),{element:e}}static importDOM(){return{pre:e=>e.hasAttribute("data-drawing")?{conversion:n=>({node:It(Y(ye(n.getAttribute("data-drawing")??"")))}),priority:2}:null}}getData(){return Fr(this.getLatest().__data)}setData(e){let n=this.getWritable();n.__data=Y(e)}getBlockWidth(){return this.getData().width??"full"}setBlockWidth(e){let{width:n,...o}=this.getData();this.setData(e==="full"?o:{...o,width:e})}isInline(){return!1}decorate(e,n){return Gr(Pn,{nodeKey:this.getKey(),data:this.getData()})}};function It(t=Y(nt)){return zr(new ft(t))}function Dn(t){return t instanceof ft}var Uo=/^```\s*$/,Xo={dependencies:[ft],export:t=>Dn(t)?`\`\`\`drawing
|
|
13
|
-
${t.getLatest().__data}
|
|
14
|
-
\`\`\``:null,regExpStart:/^```drawing\s*$/,regExpEnd:Uo,replace:(t,e,n,o,i,r)=>{if(!r||e!=null||i==null)return!1;let a=ye(i.join(`
|
|
15
|
-
`).trim());t.append(It(Y(a)))},type:"multiline-element"},Zo={dependencies:[ft],export:()=>null,regExpStart:/^```diagram\s*$/,regExpEnd:Uo,replace:(t,e,n,o,i,r)=>{if(!r||e!=null||i==null)return!1;let a=go(i.join(`
|
|
16
|
-
`).trim());t.append(It(Y(a)))},type:"multiline-element"};import{useEffect as Kr}from"react";import{useLexicalComposerContext as Yr}from"@lexical/react/LexicalComposerContext";import{COMMAND_PRIORITY_EDITOR as qr}from"lexical";import{$insertNodeToNearestRoot as Vr}from"@lexical/utils";function kn(){let[t]=Yr();return Kr(()=>t.registerCommand(Ln,e=>{let n=e?.width,o=n===void 0?nt:{version:3,canvasHeight:nt.canvasHeight,width:n,shapes:[]};return Vr(It(Y(o))),!0},qr),[t]),null}import{jsx as Zr}from"react/jsx-runtime";var Ur=[...Bn,ft],Xr=[$e,Xo,Zo,...$n.filter(t=>t!==$e)],sc={nodes:Ur,transformers:Xr,plugins:Zr(kn,{})};export{de as a,ue as b,pi as c,A as d,nt as e,Dt as f,Xn as g,Ke as h,Y as i,ye as j,Ye as k,gt as l,Wt as m,we as n,co as o,X as p,Wi as q,go as r,Fi as s,fa as t,ft as u,It as v,Dn as w,Xo as x,Zo as y,kn as z,Ur as A,Xr as B,sc as C};
|
package/dist/chunk-C7VEINKX.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{d as k,f as B,g as H}from"./chunk-A7MCBSAZ.js";import{a as h,b as R}from"./chunk-SDICQI2B.js";import{useCallback as U,useEffect as y,useMemo as ee,useRef as g,useState as x}from"react";import{useLexicalComposerContext as te}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as oe}from"@lexical/react/useLexicalEditable";import{$getSelection as E,$isRangeSelection as M,$isTextNode as S,COMMAND_PRIORITY_EDITOR as q,COMMAND_PRIORITY_HIGH as ne,KEY_DOWN_COMMAND as re,SELECTION_CHANGE_COMMAND as se,createCommand as ae}from"lexical";import{$createMarkNode as F,$getMarkIDs as ie,$isMarkNode as Y,$wrapSelectionInMarkNode as le,MarkNode as de}from"@lexical/mark";import{$findMatchingParent as ce,mergeRegister as G,registerNestedElementResolver as me}from"@lexical/utils";import{Fragment as j,jsx as f,jsxs as p}from"react/jsx-runtime";var ue={add:"Add comment",comments:"Comments",resolve:"Resolve",reopen:"Reopen",remove:"Delete comment",resolved:"Resolved",unknown:t=>`Comment ${t}`},Se={mark:"zui-comment",markOverlap:"zui-comment-overlap"},fe=ae("ADD_COMMENT_COMMAND");function ge(){let t=typeof crypto<"u"?crypto:void 0;return t&&typeof t.randomUUID=="function"?t.randomUUID():`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function pe(t){return(t.metaKey||t.ctrlKey)&&t.shiftKey&&!t.altKey&&t.key.toLowerCase()==="m"}function ve(t){let n=E();if(!M(n)||n.isCollapsed())return null;let l=n.getTextContent();if(l.trim()==="")return null;let[r]=n.isBackward()?[n.focus]:[n.anchor],a=H(r.getNode())+(S(r.getNode())?r.offset:0);le(n,n.isBackward(),t,o=>F(o));let c=k().filter(o=>o.hasID(t)),m=c[c.length-1]?.getLastDescendant();return S(m)&&m.select(m.getTextContentSize(),m.getTextContentSize()),{id:t,quote:l,range:{start:a,end:a+l.length},resolved:!1}}function Ce(){let t=E();if(!M(t)||!t.isCollapsed())return[];let n=t.anchor.getNode();if(S(n)){let r=ie(n,t.anchor.offset);if(r&&r.length>0)return r;let a=n.getPreviousSibling();if(t.anchor.offset===0&&Y(a))return a.getIDs()}let l=ce(n,Y);return l?l.getIDs():[]}function W(t,n){let l=new Set(n.filter(r=>r.resolved).map(r=>r.id));t.getEditorState().read(()=>{for(let r of k()){let a=t.getElementByKey(r.getKey());if(!a)continue;let c=r.getIDs();a.classList.add("zui-comment"),a.setAttribute("data-slot","comment"),a.setAttribute("data-comment-ids",c.join(",")),a.classList.toggle("is-resolved",c.length>0&&c.every(m=>l.has(m)))}})}function ye({comments:t,onAdd:n,onResolve:l,onDelete:r,createId:a=ge,labels:c,renderComment:m}){let[o]=te(),A=oe(),u=ee(()=>({...ue,...c}),[c]),[L,J]=x(null),[b,Q]=x([]),[I,w]=x(null),T=g(n);T.current=n;let $=g(l);$.current=l;let O=g(r);O.current=r;let z=g(a);z.current=a;let _=g(t);_.current=t;let P=g(null),K=g(null),C=U(()=>{let e=ve(z.current());return e&&T.current?.(e),e!==null},[]),V=U(()=>{let e=!1;return o.update(()=>{e=C()},{discrete:!0}),e},[o,C]);y(()=>me(o,de,e=>F(e.getIDs()),(e,i)=>{for(let d of e.getIDs())i.addID(d)}),[o]),y(()=>G(o.registerCommand(fe,()=>C(),q),o.registerCommand(re,e=>{if(!pe(e))return!1;if(e.preventDefault(),C())return!0;let i=P.current?.querySelector("button");return i?(i.focus(),!0):!1},ne)),[o,C]),y(()=>{let e=()=>{let{hasRange:i,ids:d,key:v}=o.getEditorState().read(()=>{let s=E(),D=M(s)&&!s.isCollapsed()&&s.getTextContent().trim()!=="",N=M(s)?s.anchor.getNode().getKey():null;return{hasRange:D,ids:Ce(),key:N}});K.current=v,J(A&&i?h(o,R(o,v),"above"):null),Q(s=>s.length===d.length&&s.every((D,N)=>D===d[N])?s:d)};return e(),G(o.registerUpdateListener(e),o.registerCommand(se,()=>(e(),!1),q))},[o,A]),y(()=>{if(b.length===0){w(null);return}w(h(o,R(o,K.current),"below"))},[o,b]),y(()=>(W(o,t),o.registerUpdateListener(()=>W(o,_.current))),[o,t]);let X=e=>{let i=t.find(d=>d.id===e);$.current?.(e,!(i?.resolved??!1))},Z=e=>{o.update(()=>{B(e)}),O.current?.(e)};return p(j,{children:[L&&f("div",{className:"zui-text-editor-comment-add",style:L,"data-slot":"comment-add",children:p("button",{type:"button",className:"zui-text-editor-toolbar-button",title:u.add,onMouseDown:e=>e.preventDefault(),onClick:()=>V(),children:[p("svg",{viewBox:"0 0 20 20",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f("path",{d:"M3 5.5A1.5 1.5 0 0 1 4.5 4h11A1.5 1.5 0 0 1 17 5.5v7a1.5 1.5 0 0 1-1.5 1.5H8l-4 3v-3h.5A1.5 1.5 0 0 1 3 12.5z"}),f("path",{d:"M10 7v5M7.5 9.5h5"})]}),f("span",{children:u.add})]})}),I&&b.length>0&&f("div",{ref:P,className:"zui-text-editor-comments",style:I,role:"group","aria-label":u.comments,"data-slot":"comments",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),o.getRootElement()?.focus({preventScroll:!0}),o.focus())},children:b.map(e=>{let i=t.find(s=>s.id===e)??{id:e,quote:"",resolved:!1},d=t.some(s=>s.id===e),v={resolve:()=>X(e),remove:()=>Z(e)};return f("div",{className:`zui-text-editor-comment${i.resolved?" is-resolved":""}`,"data-comment-id":e,children:m?m(i,v):p(j,{children:[p("div",{className:"zui-text-editor-comment-quote",children:[d?i.quote:u.unknown(e),i.resolved&&p("span",{className:"zui-text-editor-comment-state",children:[" ",u.resolved]})]}),p("div",{className:"zui-text-editor-comment-actions",children:[d&&f("button",{type:"button",className:"zui-text-editor-toolbar-button",onMouseDown:s=>s.preventDefault(),onClick:v.resolve,children:i.resolved?u.reopen:u.resolve}),f("button",{type:"button",className:"zui-text-editor-toolbar-button",onMouseDown:s=>s.preventDefault(),onClick:v.remove,children:u.remove})]})]})},e)})})]})}export{ue as a,Se as b,fe as c,ye as d};
|