orcasvn-react-diagrams 0.2.9 → 0.2.11

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.
@@ -1164,13 +1164,21 @@ var createElementVisibilitySelectionState = function () { return ({
1164
1164
  style: { fill: '#e2e8f0', stroke: '#334155', strokeWidth: 2 },
1165
1165
  },
1166
1166
  {
1167
- id: 'policy-hidden',
1168
- position: { x: 700, y: 140 },
1169
- size: { width: 180, height: 120 },
1167
+ id: 'policy-hidden-parent',
1168
+ position: { x: 660, y: 110 },
1169
+ size: { width: 220, height: 170 },
1170
1170
  shapeId: 'default',
1171
1171
  visible: false,
1172
1172
  style: { fill: '#fee2e2', stroke: '#dc2626', strokeWidth: 2 },
1173
1173
  },
1174
+ {
1175
+ id: 'policy-hidden-child',
1176
+ parentId: 'policy-hidden-parent',
1177
+ position: { x: 50, y: 58 },
1178
+ size: { width: 120, height: 72 },
1179
+ shapeId: 'default',
1180
+ style: { fill: '#dcfce7', stroke: '#16a34a', strokeWidth: 2 },
1181
+ },
1174
1182
  ],
1175
1183
  ports: [
1176
1184
  {
@@ -1186,9 +1194,15 @@ var createElementVisibilitySelectionState = function () { return ({
1186
1194
  shapeId: 'port-circle',
1187
1195
  },
1188
1196
  {
1189
- id: 'policy-hidden-port',
1190
- elementId: 'policy-hidden',
1191
- position: { x: 0, y: 60 },
1197
+ id: 'policy-hidden-parent-port',
1198
+ elementId: 'policy-hidden-parent',
1199
+ position: { x: 0, y: 85 },
1200
+ shapeId: 'port-circle',
1201
+ },
1202
+ {
1203
+ id: 'policy-hidden-child-port',
1204
+ elementId: 'policy-hidden-child',
1205
+ position: { x: 120, y: 36 },
1192
1206
  shapeId: 'port-circle',
1193
1207
  },
1194
1208
  ],
@@ -1204,22 +1218,32 @@ var createElementVisibilitySelectionState = function () { return ({
1204
1218
  style: { stroke: '#2563eb', strokeWidth: 3 },
1205
1219
  },
1206
1220
  {
1207
- id: 'policy-hidden-link',
1221
+ id: 'policy-hidden-parent-link',
1208
1222
  sourcePortId: 'policy-normal-port',
1209
- targetPortId: 'policy-hidden-port',
1223
+ targetPortId: 'policy-hidden-parent-port',
1210
1224
  points: [
1211
1225
  { x: 300, y: 220 },
1212
- { x: 700, y: 200 },
1226
+ { x: 660, y: 195 },
1213
1227
  ],
1214
1228
  style: { stroke: '#dc2626', strokeWidth: 3 },
1215
1229
  },
1230
+ {
1231
+ id: 'policy-visible-child-link',
1232
+ sourcePortId: 'policy-normal-port',
1233
+ targetPortId: 'policy-hidden-child-port',
1234
+ points: [
1235
+ { x: 300, y: 220 },
1236
+ { x: 830, y: 204 },
1237
+ ],
1238
+ style: { stroke: '#16a34a', strokeWidth: 3 },
1239
+ },
1216
1240
  ],
1217
1241
  texts: [
1218
1242
  {
1219
1243
  id: 'policy-tip',
1220
- content: 'Blue node is normal. Slate node is visible but its body ignores click and marquee. Its port stays interactive. Hidden node, its port, and its attached red link stay in state but are suppressed from scene, selection, zoom-to-fit, and fit-to-content export.',
1244
+ content: 'Blue node is normal. Slate node is visible but its body ignores click and marquee. Its port stays interactive. Red parent container is hidden, but its green child stays visible and interactive. Parent-owned port/text and the red parent link stay suppressed, while the green child link remains in scene, selection, zoom-to-fit, and fit-to-content export.',
1221
1245
  position: { x: 80, y: 72 },
1222
- size: { width: 760, height: 44 },
1246
+ size: { width: 810, height: 60 },
1223
1247
  style: { fontSize: 14, fill: '#0f172a' },
1224
1248
  },
1225
1249
  {
@@ -1236,16 +1260,22 @@ var createElementVisibilitySelectionState = function () { return ({
1236
1260
  },
1237
1261
  {
1238
1262
  id: 'policy-hidden-label',
1239
- content: 'Hidden in state',
1263
+ content: 'Hidden parent body',
1240
1264
  position: { x: 16, y: 14 },
1241
- ownerId: 'policy-hidden',
1265
+ ownerId: 'policy-hidden-parent',
1266
+ },
1267
+ {
1268
+ id: 'policy-hidden-child-label',
1269
+ content: 'Visible child inside hidden parent',
1270
+ position: { x: 10, y: 12 },
1271
+ ownerId: 'policy-hidden-child',
1242
1272
  },
1243
1273
  ],
1244
1274
  }); };
1245
1275
  var elementVisibilitySelectionDemoConfig = {
1246
1276
  id: 'element-visibility-selection',
1247
1277
  title: 'Element Visibility + Selectability',
1248
- description: 'QA scene for visible-but-unselectable element bodies, hidden-in-state elements, and port/link propagation. Shift + drag marquee to confirm only eligible items are collected.',
1278
+ description: 'QA scene for visible-but-unselectable bodies, hidden parent containers, and visible descendants that survive hidden ancestors. Shift + drag marquee to confirm only eligible items are collected.',
1249
1279
  createState: createElementVisibilitySelectionState,
1250
1280
  elementShapes: baseElementShapes,
1251
1281
  portShapes: basePortShapes,
@@ -1259,9 +1289,14 @@ var elementVisibilitySelectionDemoConfig = {
1259
1289
  editor.setSelection([
1260
1290
  'policy-normal',
1261
1291
  'policy-unselectable',
1262
- 'policy-hidden',
1292
+ 'policy-hidden-parent',
1293
+ 'policy-hidden-child',
1263
1294
  'policy-unselectable-port',
1264
- 'policy-hidden-link',
1295
+ 'policy-hidden-parent-port',
1296
+ 'policy-hidden-child-port',
1297
+ 'policy-hidden-parent-link',
1298
+ 'policy-visible-child-link',
1299
+ 'policy-hidden-child-label',
1265
1300
  ]);
1266
1301
  },
1267
1302
  },
@@ -3451,55 +3486,96 @@ var labelStyleDemoConfig = {
3451
3486
  var createLinkColorPoolState = function () { return ({
3452
3487
  elements: [
3453
3488
  {
3454
- id: 'lc-off-source',
3455
- position: { x: 80, y: 170 },
3489
+ id: 'lc-load-missing-source',
3490
+ position: { x: 80, y: 160 },
3456
3491
  size: { width: 190, height: 120 },
3457
3492
  shapeId: 'default',
3458
3493
  },
3459
3494
  {
3460
- id: 'lc-off-target',
3461
- position: { x: 350, y: 170 },
3495
+ id: 'lc-load-missing-target',
3496
+ position: { x: 350, y: 160 },
3462
3497
  size: { width: 190, height: 120 },
3463
3498
  shapeId: 'default',
3464
3499
  },
3465
3500
  {
3466
- id: 'lc-default-source',
3467
- position: { x: 80, y: 360 },
3501
+ id: 'lc-load-blank-source',
3502
+ position: { x: 80, y: 350 },
3468
3503
  size: { width: 190, height: 120 },
3469
3504
  shapeId: 'panel',
3470
3505
  },
3471
3506
  {
3472
- id: 'lc-default-target',
3473
- position: { x: 350, y: 360 },
3507
+ id: 'lc-load-blank-target',
3508
+ position: { x: 350, y: 350 },
3474
3509
  size: { width: 190, height: 120 },
3475
3510
  shapeId: 'panel',
3476
3511
  },
3477
3512
  {
3478
- id: 'lc-custom-source',
3479
- position: { x: 620, y: 170 },
3513
+ id: 'lc-load-explicit-source',
3514
+ position: { x: 80, y: 540 },
3515
+ size: { width: 190, height: 120 },
3516
+ shapeId: 'default',
3517
+ },
3518
+ {
3519
+ id: 'lc-load-explicit-target',
3520
+ position: { x: 350, y: 540 },
3521
+ size: { width: 190, height: 120 },
3522
+ shapeId: 'default',
3523
+ },
3524
+ {
3525
+ id: 'lc-create-auto-source',
3526
+ position: { x: 620, y: 250 },
3480
3527
  size: { width: 190, height: 120 },
3481
3528
  shapeId: 'default',
3482
3529
  },
3483
3530
  {
3484
- id: 'lc-custom-target',
3485
- position: { x: 620, y: 360 },
3531
+ id: 'lc-create-auto-target',
3532
+ position: { x: 620, y: 420 },
3486
3533
  size: { width: 190, height: 120 },
3487
3534
  shapeId: 'default',
3488
3535
  },
3536
+ {
3537
+ id: 'lc-create-explicit-source',
3538
+ position: { x: 870, y: 250 },
3539
+ size: { width: 190, height: 120 },
3540
+ shapeId: 'panel',
3541
+ },
3542
+ {
3543
+ id: 'lc-create-explicit-target',
3544
+ position: { x: 870, y: 420 },
3545
+ size: { width: 190, height: 120 },
3546
+ shapeId: 'panel',
3547
+ },
3489
3548
  ],
3490
3549
  ports: [
3491
- { id: 'lc-off-source-port', elementId: 'lc-off-source', position: { x: 170, y: 60 }, shapeId: 'port-circle' },
3492
- { id: 'lc-off-target-port', elementId: 'lc-off-target', position: { x: 20, y: 60 }, shapeId: 'port-circle' },
3493
- { id: 'lc-default-source-port', elementId: 'lc-default-source', position: { x: 170, y: 60 }, shapeId: 'port-circle' },
3494
- { id: 'lc-default-target-port', elementId: 'lc-default-target', position: { x: 20, y: 60 }, shapeId: 'port-circle' },
3495
- { id: 'lc-custom-source-port', elementId: 'lc-custom-source', position: { x: 95, y: 110 }, shapeId: 'port-circle' },
3496
- { id: 'lc-custom-target-port', elementId: 'lc-custom-target', position: { x: 95, y: 10 }, shapeId: 'port-circle' },
3550
+ { id: 'lc-load-missing-source-port', elementId: 'lc-load-missing-source', position: { x: 170, y: 60 }, shapeId: 'port-circle' },
3551
+ { id: 'lc-load-missing-target-port', elementId: 'lc-load-missing-target', position: { x: 20, y: 60 }, shapeId: 'port-circle' },
3552
+ { id: 'lc-load-blank-source-port', elementId: 'lc-load-blank-source', position: { x: 170, y: 60 }, shapeId: 'port-circle' },
3553
+ { id: 'lc-load-blank-target-port', elementId: 'lc-load-blank-target', position: { x: 20, y: 60 }, shapeId: 'port-circle' },
3554
+ { id: 'lc-load-explicit-source-port', elementId: 'lc-load-explicit-source', position: { x: 170, y: 60 }, shapeId: 'port-circle' },
3555
+ { id: 'lc-load-explicit-target-port', elementId: 'lc-load-explicit-target', position: { x: 20, y: 60 }, shapeId: 'port-circle' },
3556
+ { id: 'lc-create-auto-source-port', elementId: 'lc-create-auto-source', position: { x: 95, y: 110 }, shapeId: 'port-circle' },
3557
+ { id: 'lc-create-auto-target-port', elementId: 'lc-create-auto-target', position: { x: 95, y: 10 }, shapeId: 'port-circle' },
3558
+ { id: 'lc-create-explicit-source-port', elementId: 'lc-create-explicit-source', position: { x: 95, y: 110 }, shapeId: 'port-circle' },
3559
+ { id: 'lc-create-explicit-target-port', elementId: 'lc-create-explicit-target', position: { x: 95, y: 10 }, shapeId: 'port-circle' },
3497
3560
  ],
3498
3561
  links: [
3499
3562
  {
3500
- id: 'lc-reference-link',
3501
- sourcePortId: 'lc-off-source-port',
3502
- targetPortId: 'lc-off-target-port',
3563
+ id: 'lc-loaded-missing-link',
3564
+ sourcePortId: 'lc-load-missing-source-port',
3565
+ targetPortId: 'lc-load-missing-target-port',
3566
+ points: [],
3567
+ },
3568
+ {
3569
+ id: 'lc-loaded-blank-link',
3570
+ sourcePortId: 'lc-load-blank-source-port',
3571
+ targetPortId: 'lc-load-blank-target-port',
3572
+ points: [],
3573
+ style: { stroke: ' ', strokeWidth: 2 },
3574
+ },
3575
+ {
3576
+ id: 'lc-loaded-explicit-link',
3577
+ sourcePortId: 'lc-load-explicit-source-port',
3578
+ targetPortId: 'lc-load-explicit-target-port',
3503
3579
  points: [],
3504
3580
  style: { stroke: '#374151', strokeWidth: 2 },
3505
3581
  },
@@ -3507,18 +3583,20 @@ var createLinkColorPoolState = function () { return ({
3507
3583
  texts: [
3508
3584
  {
3509
3585
  id: 'lc-intro',
3510
- content: 'Use Color Mode above: Off keeps baseline link color behavior. Default Pool enables random colors from the built-in 20-color pool. Custom Pool restricts random colors to #0b7285, #e8590c, #5f3dc4.',
3586
+ content: 'Change Color Mode, then use Reload Demo State to compare load-time fill. The left column loads one missing-stroke link, one blank-stroke link, and one explicit-stroke link. The right column actions add new links so you can compare creation-time color assignment with explicit-stroke preservation under the same policy.',
3511
3587
  position: { x: 80, y: 86 },
3512
3588
  },
3513
- { id: 'lc-off-label', content: 'Off scenario pair', ownerId: 'lc-off-source', position: { x: 10, y: -16 } },
3514
- { id: 'lc-default-label', content: 'Default-pool scenario pair', ownerId: 'lc-default-source', position: { x: 10, y: -16 } },
3515
- { id: 'lc-custom-label', content: 'Custom-pool scenario pair', ownerId: 'lc-custom-source', position: { x: 10, y: -16 } },
3589
+ { id: 'lc-load-missing-label', content: 'Loaded link with missing stroke', ownerId: 'lc-load-missing-source', position: { x: 10, y: -16 } },
3590
+ { id: 'lc-load-blank-label', content: 'Loaded link with blank stroke', ownerId: 'lc-load-blank-source', position: { x: 10, y: -16 } },
3591
+ { id: 'lc-load-explicit-label', content: 'Loaded link with explicit stroke', ownerId: 'lc-load-explicit-source', position: { x: 10, y: -16 } },
3592
+ { id: 'lc-create-auto-label', content: 'Add new unstyled links here', ownerId: 'lc-create-auto-source', position: { x: 10, y: -16 } },
3593
+ { id: 'lc-create-explicit-label', content: 'Add new explicit-stroke links here', ownerId: 'lc-create-explicit-source', position: { x: 10, y: -16 } },
3516
3594
  ],
3517
3595
  }); };
3518
3596
  var linkColorPoolDemoConfig = {
3519
3597
  id: 'link-color-pool',
3520
3598
  title: 'Link Color Pool',
3521
- description: 'Verify disabled/default/custom random link-color assignment on new links.',
3599
+ description: 'Verify off/default/custom load-time fill for missing link strokes and compare it with creation-time color assignment.',
3522
3600
  createState: createLinkColorPoolState,
3523
3601
  elementShapes: baseElementShapes,
3524
3602
  portShapes: basePortShapes,
@@ -3526,38 +3604,30 @@ var linkColorPoolDemoConfig = {
3526
3604
  defaultPortShapeId: 'port-circle',
3527
3605
  actions: [
3528
3606
  {
3529
- id: 'add-link-off-pair',
3530
- label: 'Add link (off pair)',
3607
+ id: 'add-link-create-auto',
3608
+ label: 'Add new unstyled link',
3531
3609
  run: function (editor) {
3532
3610
  editor.addLink({
3533
- id: "link-color-off-".concat(createId()),
3534
- sourcePortId: 'lc-off-source-port',
3535
- targetPortId: 'lc-off-target-port',
3611
+ id: "link-color-create-auto-".concat(createId()),
3612
+ sourcePortId: 'lc-create-auto-source-port',
3613
+ targetPortId: 'lc-create-auto-target-port',
3536
3614
  points: [],
3537
3615
  });
3538
3616
  },
3539
3617
  },
3540
3618
  {
3541
- id: 'add-link-default-pair',
3542
- label: 'Add link (default pair)',
3619
+ id: 'add-link-create-explicit',
3620
+ label: 'Add new explicit-stroke link',
3543
3621
  run: function (editor) {
3544
3622
  editor.addLink({
3545
- id: "link-color-default-".concat(createId()),
3546
- sourcePortId: 'lc-default-source-port',
3547
- targetPortId: 'lc-default-target-port',
3548
- points: [],
3549
- });
3550
- },
3551
- },
3552
- {
3553
- id: 'add-link-custom-pair',
3554
- label: 'Add link (custom pair)',
3555
- run: function (editor) {
3556
- editor.addLink({
3557
- id: "link-color-custom-".concat(createId()),
3558
- sourcePortId: 'lc-custom-source-port',
3559
- targetPortId: 'lc-custom-target-port',
3623
+ id: "link-color-create-explicit-".concat(createId()),
3624
+ sourcePortId: 'lc-create-explicit-source-port',
3625
+ targetPortId: 'lc-create-explicit-target-port',
3560
3626
  points: [],
3627
+ style: {
3628
+ stroke: '#111827',
3629
+ strokeWidth: 2,
3630
+ },
3561
3631
  });
3562
3632
  },
3563
3633
  },
@@ -5183,18 +5253,7 @@ var DiagramModel = /** @class */ (function () {
5183
5253
  var element = this.elements.get(id);
5184
5254
  if (!element)
5185
5255
  return false;
5186
- if (element.visible === false)
5187
- return false;
5188
- var currentParentId = element.parentId;
5189
- while (currentParentId) {
5190
- var parent_1 = this.elements.get(currentParentId);
5191
- if (!parent_1)
5192
- break;
5193
- if (parent_1.visible === false)
5194
- return false;
5195
- currentParentId = parent_1.parentId;
5196
- }
5197
- return true;
5256
+ return element.visible !== false;
5198
5257
  };
5199
5258
  DiagramModel.prototype.isElementSelectable = function (id) {
5200
5259
  var element = this.elements.get(id);
@@ -5465,18 +5524,18 @@ var DiagramModel = /** @class */ (function () {
5465
5524
  }
5466
5525
  var current = element;
5467
5526
  while (current === null || current === void 0 ? void 0 : current.parentId) {
5468
- var parent_2 = this.elements.get(current.parentId);
5469
- if (!parent_2)
5527
+ var parent_1 = this.elements.get(current.parentId);
5528
+ if (!parent_1)
5470
5529
  break;
5471
- var parentX = parent_2.position.x;
5472
- var parentY = parent_2.position.y;
5473
- if (parent_2.anchorCenter) {
5474
- parentX -= parent_2.size.width / 2;
5475
- parentY -= parent_2.size.height / 2;
5530
+ var parentX = parent_1.position.x;
5531
+ var parentY = parent_1.position.y;
5532
+ if (parent_1.anchorCenter) {
5533
+ parentX -= parent_1.size.width / 2;
5534
+ parentY -= parent_1.size.height / 2;
5476
5535
  }
5477
5536
  x += parentX;
5478
5537
  y += parentY;
5479
- current = parent_2;
5538
+ current = parent_1;
5480
5539
  }
5481
5540
  return { x: x, y: y };
5482
5541
  };
@@ -8019,6 +8078,10 @@ var DEFAULT_LINK_COLOR_POOL = [
8019
8078
  '#9c755f',
8020
8079
  '#bab0ab',
8021
8080
  ];
8081
+ var hasUsableLinkStroke = function (style) {
8082
+ var stroke = style === null || style === void 0 ? void 0 : style.stroke;
8083
+ return stroke !== undefined && stroke !== null && "".concat(stroke).trim().length > 0;
8084
+ };
8022
8085
  var normalizeLinkColorPoolPolicy = function (policy) {
8023
8086
  var _a;
8024
8087
  var enabled = Boolean(policy === null || policy === void 0 ? void 0 : policy.enabled);
@@ -8026,7 +8089,11 @@ var normalizeLinkColorPoolPolicy = function (policy) {
8026
8089
  .map(function (color) { return color.trim(); })
8027
8090
  .filter(function (color) { return color.length > 0; });
8028
8091
  var colors = normalizedColors.length > 0 ? normalizedColors : __spreadArray([], DEFAULT_LINK_COLOR_POOL, true);
8029
- return { enabled: enabled, colors: colors };
8092
+ return {
8093
+ enabled: enabled,
8094
+ colors: colors,
8095
+ assignOnLoadWhenMissingStroke: Boolean(policy === null || policy === void 0 ? void 0 : policy.assignOnLoadWhenMissingStroke),
8096
+ };
8030
8097
  };
8031
8098
  var DiagramEngine = /** @class */ (function () {
8032
8099
  function DiagramEngine(config) {
@@ -8072,8 +8139,9 @@ var DiagramEngine = /** @class */ (function () {
8072
8139
  DiagramEngine.prototype.load = function (state) {
8073
8140
  var _this = this;
8074
8141
  var patches = this.commandQueue.run(createLoadCommand(state), this.model);
8142
+ var linkColorPatches = this.assignOptionalLinkColorsOnLoad();
8075
8143
  var mutationPatches = this.mutationPipeline.run({
8076
- basePatches: patches,
8144
+ basePatches: __spreadArray(__spreadArray([], patches, true), linkColorPatches, true),
8077
8145
  layoutSteps: [function () { return _this.applyAllLayouts(); }],
8078
8146
  includeEmptyLinkRouting: true,
8079
8147
  });
@@ -9431,21 +9499,41 @@ var DiagramEngine = /** @class */ (function () {
9431
9499
  return this.linkRoutingService.routeLinksWithEmptyPoints();
9432
9500
  };
9433
9501
  DiagramEngine.prototype.applyOptionalLinkColor = function (link) {
9434
- if (!this.linkColorPoolPolicy.enabled)
9435
- return link;
9436
- var existingStyle = link.style;
9437
- var hasExplicitStroke = existingStyle !== undefined &&
9438
- Object.prototype.hasOwnProperty.call(existingStyle, 'stroke') &&
9439
- existingStyle.stroke !== undefined &&
9440
- existingStyle.stroke !== null &&
9441
- "".concat(existingStyle.stroke).trim().length > 0;
9442
- if (hasExplicitStroke)
9502
+ var style = this.resolveOptionalLinkColorStyle(link.style);
9503
+ if (style === link.style)
9443
9504
  return link;
9505
+ return __assign(__assign({}, link), { style: style });
9506
+ };
9507
+ DiagramEngine.prototype.assignOptionalLinkColorsOnLoad = function () {
9508
+ var _this = this;
9509
+ if (!this.linkColorPoolPolicy.enabled || !this.linkColorPoolPolicy.assignOnLoadWhenMissingStroke) {
9510
+ return [];
9511
+ }
9512
+ var patches = [];
9513
+ this.model.links.forEach(function (link) {
9514
+ var style = _this.resolveOptionalLinkColorStyle(link.style);
9515
+ if (style === link.style)
9516
+ return;
9517
+ link.style = style;
9518
+ patches.push(patchUpdate('link', link.id, { style: style }));
9519
+ });
9520
+ return patches;
9521
+ };
9522
+ DiagramEngine.prototype.resolveOptionalLinkColorStyle = function (style) {
9523
+ if (!this.linkColorPoolPolicy.enabled || hasUsableLinkStroke(style)) {
9524
+ return style;
9525
+ }
9526
+ var stroke = this.pickOptionalLinkColor();
9527
+ if (!stroke)
9528
+ return style;
9529
+ return __assign(__assign({}, (style !== null && style !== void 0 ? style : {})), { stroke: stroke });
9530
+ };
9531
+ DiagramEngine.prototype.pickOptionalLinkColor = function () {
9444
9532
  var colors = this.linkColorPoolPolicy.colors;
9445
9533
  if (colors.length === 0)
9446
- return link;
9534
+ return undefined;
9447
9535
  var index = Math.max(0, Math.min(colors.length - 1, Math.floor(Math.random() * colors.length)));
9448
- return __assign(__assign({}, link), { style: __assign(__assign({}, (existingStyle !== null && existingStyle !== void 0 ? existingStyle : {})), { stroke: colors[index] }) });
9536
+ return colors[index];
9449
9537
  };
9450
9538
  DiagramEngine.prototype.refreshLinksForRenderCycle = function () {
9451
9539
  if (this.linkRouteRefreshPolicy.mode !== 'redraw-two-endpoint-change')
@@ -13591,22 +13679,10 @@ var resolveViewportFitOptions = function (options) {
13591
13679
  };
13592
13680
  var clamp = function (value, min, max) { return Math.max(min, Math.min(max, value)); };
13593
13681
  var isElementVisibleInState = function (elementId, elementsById) {
13594
- var _a, _b;
13595
13682
  var element = elementsById.get(elementId);
13596
13683
  if (!element)
13597
13684
  return false;
13598
- if (element.visible === false)
13599
- return false;
13600
- var currentParentId = (_a = element.parentId) !== null && _a !== void 0 ? _a : null;
13601
- while (currentParentId) {
13602
- var parent_1 = elementsById.get(currentParentId);
13603
- if (!parent_1)
13604
- break;
13605
- if (parent_1.visible === false)
13606
- return false;
13607
- currentParentId = (_b = parent_1.parentId) !== null && _b !== void 0 ? _b : null;
13608
- }
13609
- return true;
13685
+ return element.visible !== false;
13610
13686
  };
13611
13687
  var isPortVisibleInState = function (portId, portsById, elementsById) {
13612
13688
  var port = portsById.get(portId);
@@ -13635,6 +13711,103 @@ var isTextVisibleInState = function (text, elementsById, portsById, linksById) {
13635
13711
  return isLinkVisibleInState(text.ownerId, linksById, portsById, elementsById);
13636
13712
  return true;
13637
13713
  };
13714
+ var resolveElementWorldPositionInState = function (elementId, elementsById) {
13715
+ var element = elementsById.get(elementId);
13716
+ if (!element)
13717
+ return null;
13718
+ var x = element.position.x;
13719
+ var y = element.position.y;
13720
+ if (element.anchorCenter) {
13721
+ x -= element.size.width / 2;
13722
+ y -= element.size.height / 2;
13723
+ }
13724
+ var current = element;
13725
+ while (current.parentId) {
13726
+ var parent_1 = elementsById.get(current.parentId);
13727
+ if (!parent_1)
13728
+ break;
13729
+ var parentX = parent_1.position.x;
13730
+ var parentY = parent_1.position.y;
13731
+ if (parent_1.anchorCenter) {
13732
+ parentX -= parent_1.size.width / 2;
13733
+ parentY -= parent_1.size.height / 2;
13734
+ }
13735
+ x += parentX;
13736
+ y += parentY;
13737
+ current = parent_1;
13738
+ }
13739
+ return { x: x, y: y };
13740
+ };
13741
+ var resolvePortWorldPositionInState = function (portId, portsById, elementsById) {
13742
+ var port = portsById.get(portId);
13743
+ if (!port)
13744
+ return null;
13745
+ var elementPosition = resolveElementWorldPositionInState(port.elementId, elementsById);
13746
+ if (!elementPosition)
13747
+ return __assign({}, port.position);
13748
+ return {
13749
+ x: elementPosition.x + port.position.x,
13750
+ y: elementPosition.y + port.position.y,
13751
+ };
13752
+ };
13753
+ var resolveLinkMidpointInState = function (link) {
13754
+ var points = link.points;
13755
+ if (points.length === 0)
13756
+ return { x: 0, y: 0 };
13757
+ if (points.length === 1)
13758
+ return __assign({}, points[0]);
13759
+ var total = 0;
13760
+ for (var i = 1; i < points.length; i += 1) {
13761
+ total += distance(points[i - 1], points[i]);
13762
+ }
13763
+ var halfway = total / 2;
13764
+ var traveled = 0;
13765
+ for (var i = 1; i < points.length; i += 1) {
13766
+ var segment = distance(points[i - 1], points[i]);
13767
+ if (traveled + segment >= halfway) {
13768
+ var ratio = segment === 0 ? 0 : (halfway - traveled) / segment;
13769
+ return {
13770
+ x: points[i - 1].x + (points[i].x - points[i - 1].x) * ratio,
13771
+ y: points[i - 1].y + (points[i].y - points[i - 1].y) * ratio,
13772
+ };
13773
+ }
13774
+ traveled += segment;
13775
+ }
13776
+ return __assign({}, points[points.length - 1]);
13777
+ };
13778
+ var resolveTextWorldPositionInState = function (text, elementsById, portsById, linksById) {
13779
+ if (!text.ownerId)
13780
+ return __assign({}, text.position);
13781
+ if (elementsById.has(text.ownerId)) {
13782
+ var elementPosition = resolveElementWorldPositionInState(text.ownerId, elementsById);
13783
+ if (!elementPosition)
13784
+ return __assign({}, text.position);
13785
+ return {
13786
+ x: elementPosition.x + text.position.x,
13787
+ y: elementPosition.y + text.position.y,
13788
+ };
13789
+ }
13790
+ if (portsById.has(text.ownerId)) {
13791
+ var portPosition = resolvePortWorldPositionInState(text.ownerId, portsById, elementsById);
13792
+ if (!portPosition)
13793
+ return __assign({}, text.position);
13794
+ return {
13795
+ x: portPosition.x + text.position.x,
13796
+ y: portPosition.y + text.position.y,
13797
+ };
13798
+ }
13799
+ if (linksById.has(text.ownerId)) {
13800
+ var link = linksById.get(text.ownerId);
13801
+ if (!link)
13802
+ return __assign({}, text.position);
13803
+ var midpoint = resolveLinkMidpointInState(link);
13804
+ return {
13805
+ x: midpoint.x + text.position.x,
13806
+ y: midpoint.y + text.position.y,
13807
+ };
13808
+ }
13809
+ return __assign({}, text.position);
13810
+ };
13638
13811
  var resolveStateWorldBounds = function (state) {
13639
13812
  var bounds = createBounds();
13640
13813
  var elementsById = new Map(state.elements.map(function (element) { return [element.id, element]; }));
@@ -13643,20 +13816,26 @@ var resolveStateWorldBounds = function (state) {
13643
13816
  state.elements.forEach(function (element) {
13644
13817
  if (!isElementVisibleInState(element.id, elementsById))
13645
13818
  return;
13646
- includeRect(bounds, element.position.x, element.position.y, element.size.width, element.size.height);
13819
+ var position = resolveElementWorldPositionInState(element.id, elementsById);
13820
+ if (!position)
13821
+ return;
13822
+ includeRect(bounds, position.x, position.y, element.size.width, element.size.height);
13647
13823
  });
13648
13824
  state.ports.forEach(function (port) {
13649
13825
  var _a;
13650
13826
  if (!isPortVisibleInState(port.id, portsById, elementsById))
13651
13827
  return;
13828
+ var position = resolvePortWorldPositionInState(port.id, portsById, elementsById);
13829
+ if (!position)
13830
+ return;
13652
13831
  var size = port.size;
13653
13832
  if (!size) {
13654
- expandBounds(bounds, port.position.x, port.position.y);
13833
+ expandBounds(bounds, position.x, position.y);
13655
13834
  return;
13656
13835
  }
13657
13836
  var anchorCenter = (_a = port.anchorCenter) !== null && _a !== void 0 ? _a : true;
13658
- var x = anchorCenter ? port.position.x - size.width / 2 : port.position.x;
13659
- var y = anchorCenter ? port.position.y - size.height / 2 : port.position.y;
13837
+ var x = anchorCenter ? position.x - size.width / 2 : position.x;
13838
+ var y = anchorCenter ? position.y - size.height / 2 : position.y;
13660
13839
  includeRect(bounds, x, y, size.width, size.height);
13661
13840
  });
13662
13841
  state.links.forEach(function (link) {
@@ -13671,7 +13850,8 @@ var resolveStateWorldBounds = function (state) {
13671
13850
  if (!isTextVisibleInState(text, elementsById, portsById, linksById))
13672
13851
  return;
13673
13852
  var offset = (_a = text.displayOffset) !== null && _a !== void 0 ? _a : { x: 0, y: 0 };
13674
- var position = { x: text.position.x + offset.x, y: text.position.y + offset.y };
13853
+ var worldPosition = resolveTextWorldPositionInState(text, elementsById, portsById, linksById);
13854
+ var position = { x: worldPosition.x + offset.x, y: worldPosition.y + offset.y };
13675
13855
  var clipSize = text.displayClipSize;
13676
13856
  var size = clipSize !== null && clipSize !== void 0 ? clipSize : text.size;
13677
13857
  if (size) {
@@ -13688,7 +13868,10 @@ var resolveElementWorldBounds = function (state) {
13688
13868
  state.elements.forEach(function (element) {
13689
13869
  if (!isElementVisibleInState(element.id, elementsById))
13690
13870
  return;
13691
- includeRect(bounds, element.position.x, element.position.y, element.size.width, element.size.height);
13871
+ var position = resolveElementWorldPositionInState(element.id, elementsById);
13872
+ if (!position)
13873
+ return;
13874
+ includeRect(bounds, position.x, position.y, element.size.width, element.size.height);
13692
13875
  });
13693
13876
  return hasBounds(bounds) ? bounds : null;
13694
13877
  };
@@ -16374,9 +16557,10 @@ var LinkColorPoolDemo = function () {
16374
16557
  var linkColorPoolPolicy = React.useMemo(function () {
16375
16558
  if (mode === 'off')
16376
16559
  return undefined;
16377
- if (mode === 'default')
16378
- return { enabled: true };
16379
- return { enabled: true, colors: customPool };
16560
+ if (mode === 'default') {
16561
+ return { enabled: true, assignOnLoadWhenMissingStroke: true };
16562
+ }
16563
+ return { enabled: true, assignOnLoadWhenMissingStroke: true, colors: customPool };
16380
16564
  }, [mode]);
16381
16565
  return (React.createElement(SimpleDemo, { demo: linkColorPoolDemoConfig, linkColorPoolPolicy: linkColorPoolPolicy, beforeStage: React.createElement("div", { style: {
16382
16566
  marginBottom: 12,
@@ -16388,9 +16572,10 @@ var LinkColorPoolDemo = function () {
16388
16572
  React.createElement("label", { htmlFor: "link-color-mode", style: { display: 'inline-flex', alignItems: 'center', gap: 8, fontWeight: 600 } },
16389
16573
  "Color Mode",
16390
16574
  React.createElement("select", { id: "link-color-mode", value: mode, onChange: function (event) { return setMode(event.target.value); } },
16391
- React.createElement("option", { value: "off" }, "Off (default behavior)"),
16392
- React.createElement("option", { value: "default" }, "Default 20-color pool"),
16393
- React.createElement("option", { value: "custom" }, "Custom pool (#0b7285, #e8590c, #5f3dc4)")))) }));
16575
+ React.createElement("option", { value: "off" }, "Off (no load fill)"),
16576
+ React.createElement("option", { value: "default" }, "Default pool load fill"),
16577
+ React.createElement("option", { value: "custom" }, "Custom pool load fill (#0b7285, #e8590c, #5f3dc4)"))),
16578
+ React.createElement("p", { style: { margin: '8px 0 0', fontSize: 13 } }, "Switching modes recreates the demo so the seeded loaded links can prove whether missing and blank strokes are filled, while explicit loaded strokes stay untouched.")) }));
16394
16579
  };
16395
16580
 
16396
16581
  var sidePositions = {