@pascal-app/core 1.1.0 → 1.1.2

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.
Files changed (133) hide show
  1. package/dist/agent-operations/__fixtures__/cases.d.ts +3 -2
  2. package/dist/agent-operations/__fixtures__/cases.d.ts.map +1 -1
  3. package/dist/agent-operations/__fixtures__/place-items-cases.d.ts.map +1 -1
  4. package/dist/agent-operations/__fixtures__/place-items-cases.js +28 -0
  5. package/dist/agent-operations/__fixtures__/roof-bearing-cases.d.ts +2618 -2618
  6. package/dist/agent-operations/asset-catalog.d.ts +21 -11
  7. package/dist/agent-operations/asset-catalog.d.ts.map +1 -1
  8. package/dist/agent-operations/asset-catalog.js +28 -10
  9. package/dist/agent-operations/asset-views.d.ts +8 -3
  10. package/dist/agent-operations/asset-views.d.ts.map +1 -1
  11. package/dist/agent-operations/asset-views.js +19 -3
  12. package/dist/agent-operations/batch.d.ts +4 -2
  13. package/dist/agent-operations/batch.d.ts.map +1 -1
  14. package/dist/agent-operations/batch.js +9 -6
  15. package/dist/agent-operations/catalog-asset.d.ts +15 -0
  16. package/dist/agent-operations/catalog-asset.d.ts.map +1 -0
  17. package/dist/agent-operations/catalog-asset.js +4 -0
  18. package/dist/agent-operations/circulation-spaces.d.ts +585 -585
  19. package/dist/agent-operations/design-brief.d.ts.map +1 -1
  20. package/dist/agent-operations/design-brief.js +2 -0
  21. package/dist/agent-operations/furnish-room.d.ts.map +1 -1
  22. package/dist/agent-operations/furnish-room.js +2 -1
  23. package/dist/agent-operations/index.d.ts +5716 -7
  24. package/dist/agent-operations/index.d.ts.map +1 -1
  25. package/dist/agent-operations/index.js +17 -3
  26. package/dist/agent-operations/level-reads.d.ts.map +1 -1
  27. package/dist/agent-operations/level-reads.js +4 -1
  28. package/dist/agent-operations/place-in-room.d.ts.map +1 -1
  29. package/dist/agent-operations/place-in-room.js +2 -1
  30. package/dist/agent-operations/place-items.d.ts.map +1 -1
  31. package/dist/agent-operations/place-items.js +2 -1
  32. package/dist/agent-operations/scene-queries.d.ts +3818 -3818
  33. package/dist/agent-operations/scene-view.d.ts.map +1 -1
  34. package/dist/agent-operations/scene-view.js +38 -13
  35. package/dist/agent-operations/search-assets.d.ts.map +1 -1
  36. package/dist/agent-operations/search-assets.js +6 -0
  37. package/dist/agent-operations/types.d.ts +10 -2
  38. package/dist/agent-operations/types.d.ts.map +1 -1
  39. package/dist/agent-operations/usage-checks.js +18 -3
  40. package/dist/agent-operations/verify-scene.d.ts +7 -3
  41. package/dist/agent-operations/verify-scene.d.ts.map +1 -1
  42. package/dist/agent-operations/verify-scene.js +15 -7
  43. package/dist/agent-tools/assets.js +1 -1
  44. package/dist/building/__fixtures__/wall-opening-cases.d.ts +30 -30
  45. package/dist/building/level-duplication.d.ts +3409 -3409
  46. package/dist/building/level-duplication.d.ts.map +1 -1
  47. package/dist/building/level-duplication.js +3 -1
  48. package/dist/building/wall-openings.d.ts +75 -75
  49. package/dist/commands/structure/shared.d.ts +3407 -3407
  50. package/dist/commands/structure/zone-wall-merge.d.ts +652 -652
  51. package/dist/hooks/spatial-grid/spatial-grid-sync.d.ts +3818 -3818
  52. package/dist/index.d.ts +2 -0
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +2 -0
  55. package/dist/lib/__fixtures__/mezzanine.d.ts +2003 -2003
  56. package/dist/lib/absorb-wall-separators.d.ts +1032 -1032
  57. package/dist/lib/asset-storage.d.ts.map +1 -1
  58. package/dist/lib/asset-storage.js +3 -0
  59. package/dist/lib/floor-foundation-datum.d.ts.map +1 -1
  60. package/dist/lib/floor-foundation-datum.js +5 -1
  61. package/dist/lib/floorplan/context.d.ts +95 -0
  62. package/dist/lib/floorplan/context.d.ts.map +1 -0
  63. package/dist/lib/floorplan/context.js +155 -0
  64. package/dist/lib/floorplan/index.d.ts +6 -0
  65. package/dist/lib/floorplan/index.d.ts.map +1 -0
  66. package/dist/lib/floorplan/index.js +5 -0
  67. package/dist/lib/floorplan/marks.d.ts +71 -0
  68. package/dist/lib/floorplan/marks.d.ts.map +1 -0
  69. package/dist/lib/floorplan/marks.js +157 -0
  70. package/dist/lib/floorplan/plan-math.d.ts +18 -0
  71. package/dist/lib/floorplan/plan-math.d.ts.map +1 -0
  72. package/dist/lib/floorplan/plan-math.js +82 -0
  73. package/dist/lib/floorplan/svg-paths.d.ts +17 -0
  74. package/dist/lib/floorplan/svg-paths.d.ts.map +1 -0
  75. package/dist/lib/floorplan/svg-paths.js +92 -0
  76. package/dist/lib/floorplan/wall-affordances.d.ts +31 -0
  77. package/dist/lib/floorplan/wall-affordances.d.ts.map +1 -0
  78. package/dist/lib/floorplan/wall-affordances.js +24 -0
  79. package/dist/lib/steps.d.ts +8 -0
  80. package/dist/lib/steps.d.ts.map +1 -0
  81. package/dist/lib/steps.js +7 -0
  82. package/dist/registry/__fixtures__/roof-planes.d.ts +69 -0
  83. package/dist/registry/__fixtures__/roof-planes.d.ts.map +1 -0
  84. package/dist/registry/__fixtures__/roof-planes.js +59 -0
  85. package/dist/registry/index.d.ts +2 -1
  86. package/dist/registry/index.d.ts.map +1 -1
  87. package/dist/registry/index.js +1 -0
  88. package/dist/registry/roofs.d.ts +34 -0
  89. package/dist/registry/roofs.d.ts.map +1 -0
  90. package/dist/registry/roofs.js +61 -0
  91. package/dist/registry/types.d.ts +30 -0
  92. package/dist/registry/types.d.ts.map +1 -1
  93. package/dist/registry/validate-relations.d.ts +5 -1
  94. package/dist/registry/validate-relations.d.ts.map +1 -1
  95. package/dist/registry/validate-relations.js +6 -2
  96. package/dist/schema/asset-url.d.ts +8 -0
  97. package/dist/schema/asset-url.d.ts.map +1 -1
  98. package/dist/schema/asset-url.js +17 -0
  99. package/dist/schema/nodes/roof.d.ts +1 -1
  100. package/dist/schema/nodes/roof.d.ts.map +1 -1
  101. package/dist/schema/nodes/roof.js +13 -8
  102. package/dist/schema/types.d.ts +1 -1
  103. package/dist/services/roof-level.d.ts.map +1 -1
  104. package/dist/services/roof-level.js +12 -2
  105. package/dist/services/roof-move.d.ts +4 -2
  106. package/dist/services/roof-move.d.ts.map +1 -1
  107. package/dist/services/roof-move.js +21 -9
  108. package/dist/spatial/usage-field/findings.d.ts +10 -1
  109. package/dist/spatial/usage-field/findings.d.ts.map +1 -1
  110. package/dist/spatial/usage-field/findings.js +56 -12
  111. package/dist/spatial/usage-field/measure.d.ts +3 -1
  112. package/dist/spatial/usage-field/measure.d.ts.map +1 -1
  113. package/dist/spatial/usage-field/measure.js +7 -2
  114. package/dist/spatial/usage-field/path.d.ts.map +1 -1
  115. package/dist/spatial/usage-field/path.js +28 -18
  116. package/dist/store/actions/node-actions.d.ts +2380 -2380
  117. package/dist/store/scene-annotations.d.ts +1279 -1279
  118. package/dist/systems/document-reconcile.d.ts.map +1 -1
  119. package/dist/systems/document-reconcile.js +1 -2
  120. package/dist/systems/roof/roof-elevation.d.ts +11 -6
  121. package/dist/systems/roof/roof-elevation.d.ts.map +1 -1
  122. package/dist/systems/roof/roof-elevation.js +24 -11
  123. package/dist/systems/slab/__fixtures__/floor-step.d.ts +2381 -2381
  124. package/dist/systems/slab/__fixtures__/raised-room.d.ts +3818 -3818
  125. package/dist/systems/stair/stair-opening-preview.d.ts +900 -900
  126. package/dist/utils/ensure-scene-openings.d.ts +4815 -4815
  127. package/dist/utils/floor-plate-migration.d.ts +1032 -1032
  128. package/dist/utils/owned-floor-opening-migration.d.ts +1032 -1032
  129. package/dist/utils/reconcile-structure-on-load.d.ts +2380 -2380
  130. package/dist/utils/scene-bounds.d.ts +32 -0
  131. package/dist/utils/scene-bounds.d.ts.map +1 -0
  132. package/dist/utils/scene-bounds.js +201 -0
  133. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import { USAGE_INDICATORS, } from '../../building/code-profile.js';
2
+ import { inOneGo } from '../../lib/steps.js';
2
3
  import { bedIssues } from './beds.js';
3
4
  import { blockedOpeningIssues } from './blocked.js';
4
5
  import { clashIssues } from './clash.js';
@@ -6,7 +7,7 @@ import { doorOverStairIssues } from './door-stairs.js';
6
7
  import { entryIssues } from './entry-way.js';
7
8
  import { fixtureClearanceIssues } from './fixtures.js';
8
9
  import { m, nameOf, quote, unique } from './labels.js';
9
- import { measureUsage, } from './measure.js';
10
+ import { measureUsageSteps, } from './measure.js';
10
11
  import { usageShapes } from './shapes.js';
11
12
  import { doorSwingIssues } from './swings.js';
12
13
  /** Clear width of a path in a house: 0,90 m, the arrêté du 24 décembre 2015 art. 11 II (36 in is the IRC hall). */
@@ -202,16 +203,9 @@ function pocketIssue(nodes, room, from) {
202
203
  approximate,
203
204
  };
204
205
  }
205
- /**
206
- * The usage findings of a scene: narrow passages (measured from the chosen entrance, one for each
207
- * place that is narrow with the rooms it leads to, and the best other door as a fact), missing turning circles, floor a 0.60 m unit cannot get out of, wall
208
- * objects that stand out into circulation, pieces inside something solid, what stands in front of a
209
- * window or a door, a bed's room, a room's headroom and its ceiling. Every threshold is an indicator,
210
- * not a compliance check.
211
- */
212
- export function usageIssues(nodes, options = {}) {
213
- const shapes = usageShapes(nodes);
214
- const measure = measureUsage(nodes, shapes, options);
206
+ /** The passages, turning circles and pockets of every group of rooms, measured on one clearance field. */
207
+ function* circulationIssues(nodes, shapes, options) {
208
+ const measure = yield* measureUsageSteps(nodes, shapes, options);
215
209
  const issues = [];
216
210
  for (const group of measure.groups) {
217
211
  const from = group.source.kind === 'door' ? 'the entrance' : 'the stair arrival';
@@ -247,6 +241,56 @@ export function usageIssues(nodes, options = {}) {
247
241
  }
248
242
  }
249
243
  }
250
- issues.push(...clashIssues(nodes, shapes), ...blockedOpeningIssues(nodes, shapes), ...doorSwingIssues(nodes, shapes), ...entryIssues(nodes, shapes), ...doorOverStairIssues(nodes, shapes), ...fixtureClearanceIssues(nodes, shapes), ...bedIssues(nodes, shapes));
244
+ return issues;
245
+ }
246
+ /**
247
+ * Each measurement with the finding types it gives, in the order their findings are listed. On a
248
+ * building of a few hundred rooms the circulation measurement takes seconds and the others a
249
+ * fraction of one, so a question about some types takes the measurements that give them alone,
250
+ * and the circulation measurement is taken in steps.
251
+ */
252
+ const MEASUREMENTS = [
253
+ {
254
+ types: ['usage_pocket', 'usage_passage_narrow', 'usage_turning_narrow'],
255
+ run: circulationIssues,
256
+ },
257
+ { types: ['usage_clash'], run: clashIssues },
258
+ {
259
+ types: ['usage_opening_blocked'],
260
+ run: (nodes, shapes) => blockedOpeningIssues(nodes, shapes),
261
+ },
262
+ { types: ['usage_door_swing'], run: doorSwingIssues },
263
+ { types: ['usage_entry_narrow'], run: entryIssues },
264
+ { types: ['usage_door_over_stair'], run: doorOverStairIssues },
265
+ { types: ['usage_fixture_clearance'], run: fixtureClearanceIssues },
266
+ { types: ['usage_bed_clearance'], run: bedIssues },
267
+ ];
268
+ /** Every finding type a measurement gives. */
269
+ export const USAGE_TYPES = new Set(MEASUREMENTS.flatMap((measurement) => measurement.types));
270
+ /**
271
+ * The usage findings of a scene: narrow passages (measured from the chosen entrance, one for each
272
+ * place that is narrow with the rooms it leads to, and the best other door as a fact), missing turning circles, floor a 0.60 m unit cannot get out of, wall
273
+ * objects that stand out into circulation, pieces inside something solid, what stands in front of a
274
+ * window or a door, a bed's room, a room's headroom and its ceiling. Every threshold is an indicator,
275
+ * not a compliance check.
276
+ */
277
+ export function usageIssues(nodes, options = {}) {
278
+ return inOneGo(usageIssueSteps(nodes, options));
279
+ }
280
+ /** `usageIssues`, a step for each measurement and for each floor of the circulation one. */
281
+ export function* usageIssueSteps(nodes, options = {}) {
282
+ const { types, ...measure } = options;
283
+ const asked = types
284
+ ? MEASUREMENTS.filter((measurement) => measurement.types.some((type) => types.has(type)))
285
+ : MEASUREMENTS;
286
+ if (asked.length === 0)
287
+ return [];
288
+ const shapes = usageShapes(nodes);
289
+ const issues = [];
290
+ for (const measurement of asked) {
291
+ const found = measurement.run(nodes, shapes, measure);
292
+ issues.push(...(Array.isArray(found) ? found : yield* found));
293
+ yield;
294
+ }
251
295
  return issues;
252
296
  }
@@ -1,3 +1,4 @@
1
+ import { type Steps } from '../../lib/steps.js';
1
2
  import { type Grid } from './field.js';
2
3
  import { type FloorGroup } from './level-field.js';
3
4
  import type { Prism, Ring, UsageShapes } from './types.js';
@@ -318,7 +319,8 @@ export declare function prepareGroup(nodes: Nodes, shapes: UsageShapes, group: F
318
319
  * shapes `usageShapes` read. The floor is a cell grid of the clearance to the nearest obstacle in a
319
320
  * band a body stands in; a passage is the widest path from the entrance to the room, its pinch
320
321
  * re-solved on a finer grid to the millimetre; a pocket is floor where a 0.60 m unit fits but
321
- * cannot get out.
322
+ * cannot get out. One floor a step: a building of many floors takes seconds.
322
323
  */
324
+ export declare function measureUsageSteps(nodes: Nodes, shapes: UsageShapes, options?: MeasureOptions): Steps<UsageMeasure>;
323
325
  export declare function measureUsage(nodes: Nodes, shapes: UsageShapes, options?: MeasureOptions): UsageMeasure;
324
326
  //# sourceMappingURL=measure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../../src/spatial/usage-field/measure.ts"],"names":[],"mappings":"AAUA,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAIL,KAAK,UAAU,EAIhB,MAAM,eAAe,CAAA;AAWtB,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,sIAAsI;AACtI,eAAO,MAAM,gBAAgB,MAAM,CAAA;AAInC,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACnB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AASD,MAAM,MAAM,OAAO,GAAG;IACpB,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAA;IACb,gCAAgC;IAChC,I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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwL7E;AAED;;;;;;GAMG;AACH,wBAAiB,iBAAiB,CAChC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,cAAmB,GAC3B,KAAK,CAAC,YAAY,CAAC,CAgOrB;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,cAAmB,GAC3B,YAAY,CAEd"}
@@ -3,6 +3,7 @@ import { floorsOf } from '../../agent-operations/circulation-spaces.js';
3
3
  import { isFloorUnderlay } from '../../agent-operations/furniture-kind.js';
4
4
  import { area, difference, union } from '../../lib/polygon-boolean.js';
5
5
  import { polygonInteriorPoint } from '../../lib/polygon-label.js';
6
+ import { inOneGo } from '../../lib/steps.js';
6
7
  import { resolveStairWalkingSurfaces } from '../../systems/stair/stair-clearance.js';
7
8
  import { cellX, cellZ } from './field.js';
8
9
  import { BODY_BAND, buildField, FEET_BAND, floorGroups, inRegion, maskOf, } from './level-field.js';
@@ -248,9 +249,9 @@ export function prepareGroup(nodes, shapes, group, cell, underlay) {
248
249
  * shapes `usageShapes` read. The floor is a cell grid of the clearance to the nearest obstacle in a
249
250
  * band a body stands in; a passage is the widest path from the entrance to the room, its pinch
250
251
  * re-solved on a finer grid to the millimetre; a pocket is floor where a 0.60 m unit fits but
251
- * cannot get out.
252
+ * cannot get out. One floor a step: a building of many floors takes seconds.
252
253
  */
253
- export function measureUsage(nodes, shapes, options = {}) {
254
+ export function* measureUsageSteps(nodes, shapes, options = {}) {
254
255
  const cell = options.cell ?? 0.02;
255
256
  const floors = floorsOf(nodes).floors;
256
257
  const exterior = exteriorDoors(nodes);
@@ -453,6 +454,10 @@ export function measureUsage(nodes, shapes, options = {}) {
453
454
  };
454
455
  });
455
456
  groups.push({ levelId: group.levelId, y: group.y, source, rooms });
457
+ yield;
456
458
  }
457
459
  return { groups, entranceDoorId: entrance };
458
460
  }
461
+ export function measureUsage(nodes, shapes, options = {}) {
462
+ return inOneGo(measureUsageSteps(nodes, shapes, options));
463
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/spatial/usage-field/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAwB,KAAK,IAAI,EAAE,MAAM,SAAS,CAAA;AA2D3E;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,CAAC,EAAE,IAAI,EACP,CAAC,EAAE,YAAY,EACf,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GACxB;IAAE,CAAC,EAAE,YAAY,CAAC;IAAC,CAAC,EAAE,UAAU,CAAA;CAAE,CAiCpC;AAED,qGAAqG;AACrG,wBAAgB,MAAM,CACpB,CAAC,EAAE,UAAU,EACb,CAAC,EAAE,YAAY,EACf,CAAC,EAAE,MAAM,GACR;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAOxC;AA8BD,qHAAqH;AACrH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,YAAY,CAkCzF;AA8FD,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CAAA;AAE1E;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,CAAC,EAAE,IAAI,EACP,CAAC,EAAE,YAAY,EACf,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,E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Z,EAAE,EAAE,MAAM,GACT,MAAM,EAAE,GAAG,IAAI,CAkCjB"}
@@ -1,8 +1,9 @@
1
1
  import { cellOf, cellX, cellZ } from './field.js';
2
- /** A binary min-heap on a numeric key. */
2
+ /** A binary min-heap on a numeric key. `pop` returns the value and leaves its key in `key`. */
3
3
  class Heap {
4
4
  keys = [];
5
5
  values = [];
6
+ key = 0;
6
7
  get size() {
7
8
  return this.keys.length;
8
9
  }
@@ -14,37 +15,45 @@ class Heap {
14
15
  values.push(value);
15
16
  while (i > 0) {
16
17
  const parent = (i - 1) >> 1;
17
- if (keys[i] >= keys[parent])
18
+ const above = keys[parent];
19
+ if (key >= above)
18
20
  break;
19
- [keys[i], keys[parent]] = [keys[parent], keys[i]];
20
- [values[i], values[parent]] = [values[parent], values[i]];
21
+ keys[i] = above;
22
+ values[i] = values[parent];
21
23
  i = parent;
22
24
  }
25
+ keys[i] = key;
26
+ values[i] = value;
23
27
  }
24
28
  pop() {
25
29
  const keys = this.keys;
26
30
  const values = this.values;
27
- const top = [keys[0], values[0]];
28
- const lastKey = keys.pop();
29
- const lastValue = values.pop();
30
- if (keys.length) {
31
- keys[0] = lastKey;
32
- values[0] = lastValue;
31
+ this.key = keys[0];
32
+ const top = values[0];
33
+ const key = keys.pop();
34
+ const value = values.pop();
35
+ const size = keys.length;
36
+ if (size) {
33
37
  let i = 0;
34
38
  for (;;) {
35
39
  const l = 2 * i + 1;
36
40
  const r = l + 1;
37
41
  let m = i;
38
- if (l < keys.length && keys[l] < keys[m])
42
+ let least = key;
43
+ if (l < size && keys[l] < least) {
39
44
  m = l;
40
- if (r < keys.length && keys[r] < keys[m])
45
+ least = keys[l];
46
+ }
47
+ if (r < size && keys[r] < least)
41
48
  m = r;
42
49
  if (m === i)
43
50
  break;
44
- [keys[i], keys[m]] = [keys[m], keys[i]];
45
- [values[i], values[m]] = [values[m], values[i]];
51
+ keys[i] = keys[m];
52
+ values[i] = values[m];
46
53
  i = m;
47
54
  }
55
+ keys[i] = key;
56
+ values[i] = value;
48
57
  }
49
58
  return top;
50
59
  }
@@ -72,11 +81,11 @@ export function widestPath(g, F, inside, sources) {
72
81
  heap.push(-F[s], s);
73
82
  }
74
83
  while (heap.size) {
75
- const [negative, c] = heap.pop();
84
+ const c = heap.pop();
76
85
  if (done[c])
77
86
  continue;
78
87
  done[c] = 1;
79
- const b = -negative;
88
+ const b = -heap.key;
80
89
  const i = c % g.W;
81
90
  const j = (c / g.W) | 0;
82
91
  for (const [di, dj] of FOUR) {
@@ -150,7 +159,8 @@ export function travel(g, pass, sources) {
150
159
  heap.push(0, s);
151
160
  }
152
161
  while (heap.size) {
153
- const [d, c] = heap.pop();
162
+ const c = heap.pop();
163
+ const d = heap.key;
154
164
  if (d > D[c])
155
165
  continue;
156
166
  const i = c % g.W;
@@ -322,7 +332,7 @@ export function shortestRoute(g, pass, from, to) {
322
332
  cost[from] = 0;
323
333
  heap.push(heuristic(from), from);
324
334
  while (heap.size) {
325
- const [, c] = heap.pop();
335
+ const c = heap.pop();
326
336
  if (c === to)
327
337
  break;
328
338
  const i = c % g.W;