@ahrowe/ui 0.27.0 → 0.29.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/dist/esm/common/accordion/accordion.mjs +1 -1
- package/dist/esm/common/accordion/accordion.mjs.map +1 -1
- package/dist/esm/common/accordion/accordion.module.mjs +1 -1
- package/dist/esm/common/accordion/accordion.module.mjs.map +1 -1
- package/dist/esm/common/accordion/accordion.plain.module.mjs +1 -1
- package/dist/esm/common/accordion/accordion.plain.module.mjs.map +1 -1
- package/dist/esm/common/accordion/accordion.primary.module.mjs +1 -1
- package/dist/esm/common/accordion/accordion.primary.module.mjs.map +1 -1
- package/dist/esm/common/actionButtons/actionButtons.mjs.map +1 -1
- package/dist/esm/common/actionButtons/actionButtons.module.mjs +1 -1
- package/dist/esm/common/actionButtons/actionButtons.module.mjs.map +1 -1
- package/dist/esm/common/actionIcon/actionIcon.mjs.map +1 -1
- package/dist/esm/common/actionIcon/actionIcon.module.mjs +1 -1
- package/dist/esm/common/actionIcon/actionIcon.module.mjs.map +1 -1
- package/dist/esm/common/alert/alert.mjs.map +1 -1
- package/dist/esm/common/alert/alert.module.mjs +1 -1
- package/dist/esm/common/animatedIcon/animatedIcon.mjs.map +1 -1
- package/dist/esm/common/animatedIcon/animatedIcon.module.mjs +1 -1
- package/dist/esm/common/animatedIcon/animatedIcon.module.mjs.map +1 -1
- package/dist/esm/common/animatedLogo/animatedLogo.mjs.map +1 -1
- package/dist/esm/common/animatedLogo/animatedLogo.module.mjs +1 -1
- package/dist/esm/common/animatedText/animatedText.mjs +1 -1
- package/dist/esm/common/animatedText/animatedText.mjs.map +1 -1
- package/dist/esm/common/animatedText/animatedText.module.mjs +1 -1
- package/dist/esm/common/animatedText/animatedText.module.mjs.map +1 -1
- package/dist/esm/common/avatar/avatar.mjs.map +1 -1
- package/dist/esm/common/avatar/avatar.module.mjs +1 -1
- package/dist/esm/common/avatar/avatar.module.mjs.map +1 -1
- package/dist/esm/common/avatar/avatarGroup.mjs.map +1 -1
- package/dist/esm/common/badge/badge.mjs.map +1 -1
- package/dist/esm/common/badge/badge.module.mjs +1 -1
- package/dist/esm/common/badge/badge.module.mjs.map +1 -1
- package/dist/esm/common/breadcrumb/breadcrumb.mjs.map +1 -1
- package/dist/esm/common/breadcrumb/breadcrumb.module.mjs +1 -1
- package/dist/esm/common/button/button.mjs.map +1 -1
- package/dist/esm/common/button/button.module.mjs +1 -1
- package/dist/esm/common/button/button.module.mjs.map +1 -1
- package/dist/esm/common/buttonGroup/buttonGroup.mjs.map +1 -1
- package/dist/esm/common/buttonGroup/buttonGroup.module.mjs +1 -1
- package/dist/esm/common/buttonGroup/buttonGroup.module.mjs.map +1 -1
- package/dist/esm/common/card/Card.mjs.map +1 -1
- package/dist/esm/common/card/CardActions.mjs.map +1 -1
- package/dist/esm/common/card/CardHeader.mjs.map +1 -1
- package/dist/esm/common/card/card.module.mjs +1 -1
- package/dist/esm/common/card/card.module.mjs.map +1 -1
- package/dist/esm/common/carousel/carousel.mjs +1 -1
- package/dist/esm/common/carousel/carousel.mjs.map +1 -1
- package/dist/esm/common/carousel/carousel.module.mjs +1 -1
- package/dist/esm/common/carousel/carousel.module.mjs.map +1 -1
- package/dist/esm/common/checkbox/checkbox.mjs.map +1 -1
- package/dist/esm/common/checkbox/checkbox.module.mjs +1 -1
- package/dist/esm/common/checkbox/checkbox.module.mjs.map +1 -1
- package/dist/esm/common/chip/chip.mjs.map +1 -1
- package/dist/esm/common/chip/chip.module.mjs +1 -1
- package/dist/esm/common/chip/chip.module.mjs.map +1 -1
- package/dist/esm/common/colorPicker/colorPicker.mjs +1 -1
- package/dist/esm/common/colorPicker/colorPicker.mjs.map +1 -1
- package/dist/esm/common/colorPicker/colorPicker.module.mjs +1 -1
- package/dist/esm/common/colorPicker/colorPicker.module.mjs.map +1 -1
- package/dist/esm/common/configProvider/configProvider.mjs.map +1 -1
- package/dist/esm/common/configProvider/useComponentDefaults.mjs.map +1 -1
- package/dist/esm/common/confirmModal/confirmModal.mjs +1 -1
- package/dist/esm/common/confirmModal/confirmModal.mjs.map +1 -1
- package/dist/esm/common/datePicker/components/datePickerMonth/datePickerMonth.mjs.map +1 -1
- package/dist/esm/common/datePicker/components/datePickerMonth/datePickerMonth.module.mjs +1 -1
- package/dist/esm/common/datePicker/components/datePickerMonth/datePickerMonth.module.mjs.map +1 -1
- package/dist/esm/common/datePicker/dateFunctions.mjs.map +1 -1
- package/dist/esm/common/datePicker/datePicker.mjs +1 -1
- package/dist/esm/common/datePicker/datePicker.mjs.map +1 -1
- package/dist/esm/common/datePicker/datePicker.module.mjs +1 -1
- package/dist/esm/common/divider/divider.mjs.map +1 -1
- package/dist/esm/common/divider/divider.module.mjs +1 -1
- package/dist/esm/common/drawer/drawer.mjs.map +1 -1
- package/dist/esm/common/drawer/drawer.module.mjs +1 -1
- package/dist/esm/common/drawer/drawer.module.mjs.map +1 -1
- package/dist/esm/common/dropZone/dropZone.mjs +1 -1
- package/dist/esm/common/dropZone/dropZone.mjs.map +1 -1
- package/dist/esm/common/dropZone/dropZone.module.mjs +1 -1
- package/dist/esm/common/dropZone/dropZone.module.mjs.map +1 -1
- package/dist/esm/common/dropdown/dropdown.mjs +1 -1
- package/dist/esm/common/dropdown/dropdown.mjs.map +1 -1
- package/dist/esm/common/dropdown/dropdown.module.mjs +1 -1
- package/dist/esm/common/dropdown/dropdown.module.mjs.map +1 -1
- package/dist/esm/common/emptyState/emptyState.mjs.map +1 -1
- package/dist/esm/common/emptyState/emptyState.module.mjs +1 -1
- package/dist/esm/common/errorBoundary/errorBoundary.mjs.map +1 -1
- package/dist/esm/common/errorBoundary/errorBoundary.module.mjs +1 -1
- package/dist/esm/common/errorBoundary/errorBoundary.module.mjs.map +1 -1
- package/dist/esm/common/fab/components/fabBase/fabBase.mjs.map +1 -1
- package/dist/esm/common/fab/components/fabBase/fabBase.module.mjs +1 -1
- package/dist/esm/common/fab/fab.mjs.map +1 -1
- package/dist/esm/common/fab/fab.module.mjs +1 -1
- package/dist/esm/common/fab/fab.module.mjs.map +1 -1
- package/dist/esm/common/flip/flip.mjs +1 -1
- package/dist/esm/common/flip/flip.mjs.map +1 -1
- package/dist/esm/common/flip/flip.module.mjs +1 -1
- package/dist/esm/common/floatingMenu/floatingMenu.mjs +1 -1
- package/dist/esm/common/floatingMenu/floatingMenu.mjs.map +1 -1
- package/dist/esm/common/floatingMenu/floatingMenu.module.mjs +1 -1
- package/dist/esm/common/floatingMenu/floatingMenu.module.mjs.map +1 -1
- package/dist/esm/common/floatingMenu/floatingMenu.types.mjs.map +1 -1
- package/dist/esm/common/floatingMenu/useFloatingPosition.mjs +1 -1
- package/dist/esm/common/floatingMenu/useFloatingPosition.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.faces.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.geometry.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.graph.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.graph.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.hit.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.json.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.json.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.mesh.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.path.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.plan.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.plan.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.rooms.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.rooms.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.snap.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.triangulate.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.triangulate.mjs.map +1 -1
- package/dist/esm/common/floorPlan/legacySvg.mjs.map +1 -1
- package/dist/esm/common/hooks/useAnchorTracking.mjs +2 -0
- package/dist/esm/common/hooks/useAnchorTracking.mjs.map +1 -0
- package/dist/esm/common/hooks/useCoarsePointer.mjs +1 -1
- package/dist/esm/common/hooks/useFocusBoundary.mjs.map +1 -1
- package/dist/esm/common/hooks/useMediaQuery.mjs +1 -1
- package/dist/esm/common/hooks/useMediaQuery.mjs.map +1 -1
- package/dist/esm/common/hooks/useOverlay.mjs.map +1 -1
- package/dist/esm/common/hooks/useSheet.mjs +1 -1
- package/dist/esm/common/hooks/useSheet.mjs.map +1 -1
- package/dist/esm/common/hooks/useSwipeDismiss.mjs +1 -1
- package/dist/esm/common/hooks/useSwipeDismiss.mjs.map +1 -1
- package/dist/esm/common/iconPicker/iconPicker.mjs +1 -1
- package/dist/esm/common/iconPicker/iconPicker.mjs.map +1 -1
- package/dist/esm/common/iconPicker/iconPicker.module.mjs +1 -1
- package/dist/esm/common/idleManager/idleManager.mjs +1 -1
- package/dist/esm/common/idleManager/idleManager.mjs.map +1 -1
- package/dist/esm/common/infiniteBlock/infiniteBlock.mjs.map +1 -1
- package/dist/esm/common/infiniteBlock/infiniteBlock.module.mjs +1 -1
- package/dist/esm/common/input/input.mjs +1 -1
- package/dist/esm/common/input/input.mjs.map +1 -1
- package/dist/esm/common/input/input.module.mjs +1 -1
- package/dist/esm/common/input/input.module.mjs.map +1 -1
- package/dist/esm/common/input/input.types.mjs.map +1 -1
- package/dist/esm/common/inputDropdown/inputDropdown.mjs +1 -1
- package/dist/esm/common/inputDropdown/inputDropdown.mjs.map +1 -1
- package/dist/esm/common/inputDropdown/inputDropdown.module.mjs +1 -1
- package/dist/esm/common/inputDropdown/inputDropdown.module.mjs.map +1 -1
- package/dist/esm/common/interactableDiv/interactableDiv.mjs.map +1 -1
- package/dist/esm/common/interactableDiv/interactableDiv.module.mjs +1 -1
- package/dist/esm/common/kanbanBoard/KanbanBoard.mjs +1 -1
- package/dist/esm/common/kanbanBoard/KanbanBoard.mjs.map +1 -1
- package/dist/esm/common/kanbanBoard/KanbanColumn.mjs +1 -1
- package/dist/esm/common/kanbanBoard/KanbanColumn.mjs.map +1 -1
- package/dist/esm/common/kanbanBoard/KanbanItem.mjs.map +1 -1
- package/dist/esm/common/kanbanBoard/kanbanBoard.module.mjs +1 -1
- package/dist/esm/common/kanbanBoard/kanbanBoard.module.mjs.map +1 -1
- package/dist/esm/common/kanbanBoard/kanbanBoard.utils.mjs +1 -1
- package/dist/esm/common/kanbanBoard/kanbanBoard.utils.mjs.map +1 -1
- package/dist/esm/common/klipyPicker/components/gifPreview/gifPreview.mjs.map +1 -1
- package/dist/esm/common/klipyPicker/components/gifPreview/gifPreview.module.mjs +1 -1
- package/dist/esm/common/klipyPicker/components/gifPreview/gifPreview.module.mjs.map +1 -1
- package/dist/esm/common/klipyPicker/components/gifView/gifView.mjs +1 -1
- package/dist/esm/common/klipyPicker/components/gifView/gifView.mjs.map +1 -1
- package/dist/esm/common/klipyPicker/components/gifView/gifView.module.mjs +1 -1
- package/dist/esm/common/klipyPicker/components/gifView/gifView.module.mjs.map +1 -1
- package/dist/esm/common/klipyPicker/klipyPicker.mjs.map +1 -1
- package/dist/esm/common/klipyPicker/klipyPicker.module.mjs +1 -1
- package/dist/esm/common/loading/iconLoading/iconLoading.mjs.map +1 -1
- package/dist/esm/common/loading/iconLoading/iconLoading.module.mjs +1 -1
- package/dist/esm/common/loading/iconLoading/iconLoading.module.mjs.map +1 -1
- package/dist/esm/common/loading/spinnerLoading/spinnerLoading.mjs.map +1 -1
- package/dist/esm/common/loading/spinnerLoading/spinnerLoading.module.mjs +1 -1
- package/dist/esm/common/modal/modal.mjs.map +1 -1
- package/dist/esm/common/modal/modal.module.mjs +1 -1
- package/dist/esm/common/modal/modal.module.mjs.map +1 -1
- package/dist/esm/common/multiSelect/multiSelect.mjs +2 -0
- package/dist/esm/common/multiSelect/multiSelect.mjs.map +1 -0
- package/dist/esm/common/multiSelect/multiSelect.module.mjs +2 -0
- package/dist/esm/common/multiSelect/multiSelect.module.mjs.map +1 -0
- package/dist/esm/common/numberInput/numberInput.mjs +1 -1
- package/dist/esm/common/numberInput/numberInput.mjs.map +1 -1
- package/dist/esm/common/numberInput/numberInput.module.mjs +1 -1
- package/dist/esm/common/numberInput/numberInput.module.mjs.map +1 -1
- package/dist/esm/common/numberInput/useStepRepeat.mjs +1 -1
- package/dist/esm/common/numberInput/useStepRepeat.mjs.map +1 -1
- package/dist/esm/common/optionPicker/optionPicker.mjs +1 -1
- package/dist/esm/common/optionPicker/optionPicker.mjs.map +1 -1
- package/dist/esm/common/optionPicker/optionPicker.module.mjs +1 -1
- package/dist/esm/common/optionPicker/optionPicker.module.mjs.map +1 -1
- package/dist/esm/common/otpInput/otpInput.mjs.map +1 -1
- package/dist/esm/common/otpInput/otpInput.module.mjs +1 -1
- package/dist/esm/common/otpInput/otpInput.module.mjs.map +1 -1
- package/dist/esm/common/overscroll/overscroll.mjs +1 -1
- package/dist/esm/common/overscroll/overscroll.mjs.map +1 -1
- package/dist/esm/common/overscroll/overscroll.module.mjs +1 -1
- package/dist/esm/common/pagination/pagination.mjs +2 -0
- package/dist/esm/common/pagination/pagination.mjs.map +1 -0
- package/dist/esm/common/pagination/pagination.module.mjs +2 -0
- package/dist/esm/common/pagination/pagination.module.mjs.map +1 -0
- package/dist/esm/common/planCanvas/planCanvas.mjs +1 -1
- package/dist/esm/common/planCanvas/planCanvas.mjs.map +1 -1
- package/dist/esm/common/planCanvas/planCanvas.module.mjs +1 -1
- package/dist/esm/common/planCanvas/planCanvas.module.mjs.map +1 -1
- package/dist/esm/common/popover/popover.mjs +1 -1
- package/dist/esm/common/popover/popover.mjs.map +1 -1
- package/dist/esm/common/popover/popover.module.mjs +1 -1
- package/dist/esm/common/popover/popover.module.mjs.map +1 -1
- package/dist/esm/common/popover/usePopoverPosition.mjs +1 -1
- package/dist/esm/common/popover/usePopoverPosition.mjs.map +1 -1
- package/dist/esm/common/progressBar/progressBar.mjs +1 -1
- package/dist/esm/common/progressBar/progressBar.mjs.map +1 -1
- package/dist/esm/common/progressBar/progressBar.module.mjs +1 -1
- package/dist/esm/common/progressBar/progressBar.module.mjs.map +1 -1
- package/dist/esm/common/radioGroup/radioGroup.mjs +1 -1
- package/dist/esm/common/radioGroup/radioGroup.mjs.map +1 -1
- package/dist/esm/common/radioGroup/radioGroup.module.mjs +1 -1
- package/dist/esm/common/radioGroup/radioGroup.module.mjs.map +1 -1
- package/dist/esm/common/rating/rating.mjs +1 -1
- package/dist/esm/common/rating/rating.mjs.map +1 -1
- package/dist/esm/common/rating/rating.module.mjs +1 -1
- package/dist/esm/common/revealLens/revealLens.mjs.map +1 -1
- package/dist/esm/common/revealLens/revealLens.module.mjs +1 -1
- package/dist/esm/common/revealLens/revealLens.module.mjs.map +1 -1
- package/dist/esm/common/ripple/ripple.mjs.map +1 -1
- package/dist/esm/common/ripple/ripple.module.mjs +1 -1
- package/dist/esm/common/ripple/ripple.module.mjs.map +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.mjs +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.mjs.map +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.module.mjs +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.module.mjs.map +1 -1
- package/dist/esm/common/roomDrawer/usePlanHistory.mjs.map +1 -1
- package/dist/esm/common/roomViewer/roomViewer.mjs +1 -1
- package/dist/esm/common/roomViewer/roomViewer.mjs.map +1 -1
- package/dist/esm/common/roomViewer/roomViewer.module.mjs +1 -1
- package/dist/esm/common/scrollbarProvider/scrollbarProvider.mjs.map +1 -1
- package/dist/esm/common/scrollbarProvider/scrollbarProvider.module.mjs +1 -1
- package/dist/esm/common/scrollbarProvider/scrollbarProvider.module.mjs.map +1 -1
- package/dist/esm/common/searchInput/searchInput.mjs.map +1 -1
- package/dist/esm/common/searchInput/searchInput.module.mjs +1 -1
- package/dist/esm/common/sectionHeader/sectionHeader.mjs.map +1 -1
- package/dist/esm/common/sectionHeader/sectionHeader.module.mjs +1 -1
- package/dist/esm/common/sectionHeader/sectionHeader.module.mjs.map +1 -1
- package/dist/esm/common/skeleton/skeleton.mjs.map +1 -1
- package/dist/esm/common/skeleton/skeleton.module.mjs +1 -1
- package/dist/esm/common/slider/slider.mjs +1 -1
- package/dist/esm/common/slider/slider.mjs.map +1 -1
- package/dist/esm/common/slider/slider.module.mjs +1 -1
- package/dist/esm/common/slider/slider.module.mjs.map +1 -1
- package/dist/esm/common/splitButton/splitButton.mjs.map +1 -1
- package/dist/esm/common/splitButton/splitButton.module.mjs +1 -1
- package/dist/esm/common/stepper/stepper.mjs.map +1 -1
- package/dist/esm/common/stepper/stepper.module.mjs +1 -1
- package/dist/esm/common/stepper/stepper.module.mjs.map +1 -1
- package/dist/esm/common/sticky/sticky.mjs.map +1 -1
- package/dist/esm/common/sticky/sticky.module.mjs +1 -1
- package/dist/esm/common/sticky/stickyStack.mjs.map +1 -1
- package/dist/esm/common/styles/sheet.module.mjs +1 -1
- package/dist/esm/common/styles/sheet.module.mjs.map +1 -1
- package/dist/esm/common/switch/switch.mjs.map +1 -1
- package/dist/esm/common/switch/switch.module.mjs +1 -1
- package/dist/esm/common/tabHeader/tabHeader.mjs.map +1 -1
- package/dist/esm/common/tabHeader/tabHeader.module.mjs +1 -1
- package/dist/esm/common/tabHeader/tabHeader.module.mjs.map +1 -1
- package/dist/esm/common/themeProvider/defaultTheme.mjs.map +1 -1
- package/dist/esm/common/themeProvider/theme.module.mjs +1 -1
- package/dist/esm/common/themeProvider/themeProvider.mjs +1 -1
- package/dist/esm/common/themeProvider/themeProvider.mjs.map +1 -1
- package/dist/esm/common/themeProvider/useTheme.mjs.map +1 -1
- package/dist/esm/common/tilt/tilt.mjs.map +1 -1
- package/dist/esm/common/tilt/tilt.module.mjs +1 -1
- package/dist/esm/common/tiltGroup/tiltGroup.mjs.map +1 -1
- package/dist/esm/common/timeInput/components/clockDial/clockDial.mjs +1 -1
- package/dist/esm/common/timeInput/components/clockDial/clockDial.mjs.map +1 -1
- package/dist/esm/common/timeInput/components/clockDial/clockDial.module.mjs +1 -1
- package/dist/esm/common/timeInput/components/clockDial/clockDial.module.mjs.map +1 -1
- package/dist/esm/common/timeInput/timeFunctions.mjs +1 -1
- package/dist/esm/common/timeInput/timeFunctions.mjs.map +1 -1
- package/dist/esm/common/timeInput/timeInput.mjs +1 -1
- package/dist/esm/common/timeInput/timeInput.mjs.map +1 -1
- package/dist/esm/common/timeInput/timeInput.module.mjs +1 -1
- package/dist/esm/common/timeInput/timeInput.module.mjs.map +1 -1
- package/dist/esm/common/timeline/timeline.mjs.map +1 -1
- package/dist/esm/common/timeline/timeline.module.mjs +1 -1
- package/dist/esm/common/timeline/timeline.module.mjs.map +1 -1
- package/dist/esm/common/timer/timer.chime.mjs.map +1 -1
- package/dist/esm/common/timer/timer.mjs +1 -1
- package/dist/esm/common/timer/timer.mjs.map +1 -1
- package/dist/esm/common/timer/timer.module.mjs +1 -1
- package/dist/esm/common/timer/timer.module.mjs.map +1 -1
- package/dist/esm/common/toast/toast.mjs.map +1 -1
- package/dist/esm/common/toast/toast.module.mjs +1 -1
- package/dist/esm/common/toast/toast.module.mjs.map +1 -1
- package/dist/esm/common/toast/toastProvider.mjs.map +1 -1
- package/dist/esm/common/tooltip/tooltip.mjs.map +1 -1
- package/dist/esm/common/tooltip/tooltip.module.mjs +1 -1
- package/dist/esm/common/tooltip/tooltip.module.mjs.map +1 -1
- package/dist/esm/common/tree/flattenTree.mjs +2 -0
- package/dist/esm/common/tree/flattenTree.mjs.map +1 -0
- package/dist/esm/common/tree/tree.mjs +2 -0
- package/dist/esm/common/tree/tree.mjs.map +1 -0
- package/dist/esm/common/tree/tree.module.mjs +2 -0
- package/dist/esm/common/tree/tree.module.mjs.map +1 -0
- package/dist/esm/common/utils/renderIcon.mjs +1 -1
- package/dist/esm/common/utils/renderIcon.mjs.map +1 -1
- package/dist/esm/common/virtualList/useColumns.mjs +1 -1
- package/dist/esm/common/virtualList/useColumns.mjs.map +1 -1
- package/dist/esm/common/virtualList/useRowDrag.mjs +1 -1
- package/dist/esm/common/virtualList/useRowDrag.mjs.map +1 -1
- package/dist/esm/common/virtualList/useSelection.mjs.map +1 -1
- package/dist/esm/common/virtualList/useVirtualWindow.mjs +1 -1
- package/dist/esm/common/virtualList/useVirtualWindow.mjs.map +1 -1
- package/dist/esm/common/virtualList/virtualList.mjs +1 -1
- package/dist/esm/common/virtualList/virtualList.mjs.map +1 -1
- package/dist/esm/common/virtualList/virtualList.module.mjs +1 -1
- package/dist/esm/common/virtualList/virtualList.module.mjs.map +1 -1
- package/dist/esm/common/virtualList/virtualList.utils.mjs.map +1 -1
- package/dist/esm/common/virtualList/virtualRow.mjs +1 -1
- package/dist/esm/common/virtualList/virtualRow.mjs.map +1 -1
- package/dist/esm/common/wizard/wizard.mjs +1 -1
- package/dist/esm/common/wizard/wizard.mjs.map +1 -1
- package/dist/esm/common/wizard/wizard.module.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/services/formValidation/FormValidatorGroupWithForm.mjs.map +1 -1
- package/dist/esm/services/formValidation/index.mjs +1 -1
- package/dist/esm/services/formValidation/useFormValidatorGroup.mjs.map +1 -1
- package/dist/esm/services/formValidation/validatableComponent.mjs.map +1 -1
- package/dist/esm/services/klipy.mjs.map +1 -1
- package/dist/esm/services/localization.mjs.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/{package/common → common}/actionButtons/actionButtons.d.ts +1 -1
- package/dist/types/{package/common → common}/animatedIcon/animatedIcon.d.ts +1 -1
- package/dist/types/common/card/Card.d.ts +4 -0
- package/dist/types/{package/common → common}/card/CardActions.d.ts +2 -1
- package/dist/types/common/card/CardContent.d.ts +4 -0
- package/dist/types/{package/common → common}/card/CardHeader.d.ts +2 -1
- package/dist/types/common/card/CardMedia.d.ts +4 -0
- package/dist/types/common/carousel/carousel.d.ts +4 -0
- package/dist/types/common/chip/chip.d.ts +4 -0
- package/dist/types/{package/common → common}/configProvider/configProvider.d.ts +1 -1
- package/dist/types/{package/common → common}/configProvider/configProvider.types.d.ts +6 -0
- package/dist/types/{package/common → common}/datePicker/components/datePickerMonth/datePickerMonth.d.ts +1 -1
- package/dist/types/{package/common → common}/datePicker/datePicker.d.ts +1 -1
- package/dist/types/{package/common → common}/drawer/drawer.d.ts +1 -1
- package/dist/types/{package/common → common}/dropZone/dropZone.d.ts +2 -1
- package/dist/types/common/dropdown/dropdown.d.ts +4 -0
- package/dist/types/{package/common → common}/fab/components/fabBase/fabBase.d.ts +1 -1
- package/dist/types/{package/common → common}/fab/fab.d.ts +1 -1
- package/dist/types/{package/common → common}/floatingMenu/floatingMenu.d.ts +1 -1
- package/dist/types/{package/common → common}/floatingMenu/useFloatingPosition.d.ts +5 -7
- package/dist/types/common/hooks/useAnchorTracking.d.ts +40 -0
- package/dist/types/{package/common → common}/hooks/useOverlay.d.ts +1 -1
- package/dist/types/{package/common → common}/iconPicker/iconPicker.d.ts +2 -1
- package/dist/types/{package/common → common}/idleManager/idleManager.d.ts +1 -1
- package/dist/types/{package/common → common}/infiniteBlock/infiniteBlock.d.ts +2 -1
- package/dist/types/common/input/input.d.ts +4 -0
- package/dist/types/{package/common → common}/inputDropdown/inputDropdown.d.ts +2 -1
- package/dist/types/{package/common → common}/inputDropdown/inputDropdown.types.d.ts +6 -0
- package/dist/types/{package/common → common}/kanbanBoard/KanbanBoard.d.ts +1 -1
- package/dist/types/{package/common → common}/kanbanBoard/KanbanColumn.d.ts +1 -1
- package/dist/types/{package/common → common}/kanbanBoard/KanbanItem.d.ts +1 -1
- package/dist/types/{package/common → common}/loading/iconLoading/iconLoading.d.ts +2 -1
- package/dist/types/common/modal/modal.d.ts +3 -0
- package/dist/types/common/multiSelect/index.d.ts +2 -0
- package/dist/types/common/multiSelect/multiSelect.d.ts +4 -0
- package/dist/types/common/multiSelect/multiSelect.types.d.ts +62 -0
- package/dist/types/{package/common → common}/overscroll/overscroll.d.ts +1 -1
- package/dist/types/common/pagination/index.d.ts +2 -0
- package/dist/types/common/pagination/pagination.d.ts +4 -0
- package/dist/types/common/pagination/pagination.types.d.ts +30 -0
- package/dist/types/common/popover/popover.d.ts +3 -0
- package/dist/types/{package/common → common}/popover/usePopoverPosition.d.ts +4 -2
- package/dist/types/{package/common → common}/scrollbarProvider/scrollbarProvider.d.ts +1 -1
- package/dist/types/{package/common → common}/sheetBackdrop/sheetBackdrop.d.ts +1 -1
- package/dist/types/common/slider/slider.d.ts +3 -0
- package/dist/types/{package/common → common}/slider/slider.types.d.ts +35 -10
- package/dist/types/{package/common → common}/splitButton/splitButton.d.ts +1 -1
- package/dist/types/{package/common → common}/stepper/stepper.d.ts +2 -1
- package/dist/types/{package/common → common}/sticky/sticky.d.ts +2 -1
- package/dist/types/{package/common → common}/tabHeader/tabHeader.d.ts +2 -1
- package/dist/types/common/textarea/textarea.d.ts +3 -0
- package/dist/types/{package/common → common}/themeProvider/themeProvider.d.ts +1 -1
- package/dist/types/{package/common → common}/timeInput/components/clockDial/clockDial.d.ts +2 -1
- package/dist/types/{package/common → common}/timeInput/timeInput.d.ts +2 -1
- package/dist/types/{package/common → common}/timeline/timeline.d.ts +2 -1
- package/dist/types/{package/common → common}/toast/index.d.ts +1 -1
- package/dist/types/{package/common → common}/toast/toast.d.ts +2 -1
- package/dist/types/{package/common → common}/toast/toastProvider.d.ts +2 -2
- package/dist/types/{package/common → common}/tooltip/tooltip.d.ts +2 -1
- package/dist/types/common/tree/flattenTree.d.ts +3 -0
- package/dist/types/common/tree/index.d.ts +3 -0
- package/dist/types/common/tree/tree.d.ts +4 -0
- package/dist/types/common/tree/tree.types.d.ts +62 -0
- package/dist/types/{package/common → common}/virtualList/virtualList.types.d.ts +8 -0
- package/dist/types/{package/common → common}/virtualList/virtualRow.d.ts +2 -2
- package/dist/types/{package/common → common}/wizard/wizard.d.ts +2 -1
- package/dist/types/{package/index.d.ts → index.d.ts} +6 -0
- package/dist/types/{package/services → services}/formValidation/index.d.ts +1 -1
- package/docs/CLAUDE.md +3 -0
- package/docs/InputDropdown.md +3 -0
- package/docs/MultiSelect.md +100 -0
- package/docs/Pagination.md +72 -0
- package/docs/Slider.md +34 -4
- package/docs/Tree.md +95 -0
- package/docs/VirtualList.md +1 -0
- package/package.json +74 -70
- package/dist/types/package/common/card/Card.d.ts +0 -3
- package/dist/types/package/common/card/CardContent.d.ts +0 -3
- package/dist/types/package/common/card/CardMedia.d.ts +0 -3
- package/dist/types/package/common/carousel/carousel.d.ts +0 -3
- package/dist/types/package/common/chip/chip.d.ts +0 -3
- package/dist/types/package/common/dropdown/dropdown.d.ts +0 -3
- package/dist/types/package/common/input/input.d.ts +0 -3
- package/dist/types/package/common/modal/modal.d.ts +0 -3
- package/dist/types/package/common/popover/popover.d.ts +0 -3
- package/dist/types/package/common/slider/slider.d.ts +0 -3
- package/dist/types/package/common/textarea/textarea.d.ts +0 -2
- /package/dist/types/{package/common → common}/accordion/accordion.d.ts +0 -0
- /package/dist/types/{package/common → common}/accordion/accordion.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/accordion/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/actionButtons/actionButtons.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/actionButtons/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/actionIcon/actionIcon.d.ts +0 -0
- /package/dist/types/{package/common → common}/actionIcon/actionIcon.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/actionIcon/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/alert/alert.d.ts +0 -0
- /package/dist/types/{package/common → common}/alert/alert.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/alert/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/animatedIcon/animatedIcon.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/animatedIcon/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/animatedLogo/animatedLogo.d.ts +0 -0
- /package/dist/types/{package/common → common}/animatedLogo/animatedLogo.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/animatedLogo/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/animatedText/animatedText.d.ts +0 -0
- /package/dist/types/{package/common → common}/animatedText/animatedText.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/animatedText/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/avatar/avatar.d.ts +0 -0
- /package/dist/types/{package/common → common}/avatar/avatar.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/avatar/avatarGroup.d.ts +0 -0
- /package/dist/types/{package/common → common}/avatar/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/badge/badge.d.ts +0 -0
- /package/dist/types/{package/common → common}/badge/badge.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/badge/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/bodyEnd/bodyEnd.d.ts +0 -0
- /package/dist/types/{package/common → common}/bodyEnd/bodyEnd.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/bodyEnd/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/breadcrumb/breadcrumb.d.ts +0 -0
- /package/dist/types/{package/common → common}/breadcrumb/breadcrumb.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/breadcrumb/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/button/button.d.ts +0 -0
- /package/dist/types/{package/common → common}/button/button.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/button/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/buttonGroup/buttonGroup.d.ts +0 -0
- /package/dist/types/{package/common → common}/buttonGroup/buttonGroup.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/buttonGroup/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/card/card.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/card/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/carousel/carousel.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/carousel/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/checkbox/checkbox.d.ts +0 -0
- /package/dist/types/{package/common → common}/checkbox/checkbox.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/checkbox/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/chip/chip.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/chip/chipContainer.d.ts +0 -0
- /package/dist/types/{package/common → common}/chip/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/colorPicker/colorPicker.d.ts +0 -0
- /package/dist/types/{package/common → common}/colorPicker/colorPicker.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/colorPicker/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/configProvider/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/configProvider/useComponentDefaults.d.ts +0 -0
- /package/dist/types/{package/common → common}/configProvider/usePresentationDefault.d.ts +0 -0
- /package/dist/types/{package/common → common}/confirmModal/confirmModal.d.ts +0 -0
- /package/dist/types/{package/common → common}/confirmModal/confirmModal.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/confirmModal/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/datePicker/components/datePickerMonth/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/datePicker/dateFunctions.d.ts +0 -0
- /package/dist/types/{package/common → common}/datePicker/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/divider/divider.d.ts +0 -0
- /package/dist/types/{package/common → common}/divider/divider.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/divider/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/drawer/drawer.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/drawer/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/dropZone/dropZone.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/dropZone/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/dropdown/dropdown.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/dropdown/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/emptyState/emptyState.d.ts +0 -0
- /package/dist/types/{package/common → common}/emptyState/emptyState.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/emptyState/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/errorBoundary/errorBoundary.d.ts +0 -0
- /package/dist/types/{package/common → common}/errorBoundary/errorBoundary.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/errorBoundary/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/fab/components/fabBase/fabBase.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/fab/components/fabBase/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/fab/fab.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/fab/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/flip/flip.d.ts +0 -0
- /package/dist/types/{package/common → common}/flip/flip.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/flip/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/floatingMenu/floatingMenu.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/floatingMenu/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.faces.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.fixtures.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.geometry.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.graph.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.hit.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.json.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.mesh.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.path.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.plan.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.rooms.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.snap.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.triangulate.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/floorPlan.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/floorPlan/legacySvg.d.ts +0 -0
- /package/dist/types/{package/common → common}/hooks/useCoarsePointer.d.ts +0 -0
- /package/dist/types/{package/common → common}/hooks/useFocusBoundary.d.ts +0 -0
- /package/dist/types/{package/common → common}/hooks/useMediaQuery.d.ts +0 -0
- /package/dist/types/{package/common → common}/hooks/useSheet.d.ts +0 -0
- /package/dist/types/{package/common → common}/hooks/useSwipeDismiss.d.ts +0 -0
- /package/dist/types/{package/common → common}/hooks/useVisualViewportSize.d.ts +0 -0
- /package/dist/types/{package/common → common}/iconPicker/iconPicker.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/iconPicker/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/idleManager/idleManager.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/idleManager/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/infiniteBlock/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/infiniteBlock/infiniteBlock.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/input/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/input/input.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/inputDropdown/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/interactableDiv/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/interactableDiv/interactableDiv.d.ts +0 -0
- /package/dist/types/{package/common → common}/kanbanBoard/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/kanbanBoard/kanbanBoard.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/kanbanBoard/kanbanBoard.utils.d.ts +0 -0
- /package/dist/types/{package/common → common}/klipyPicker/components/gifPreview/gifPreview.d.ts +0 -0
- /package/dist/types/{package/common → common}/klipyPicker/components/gifPreview/gifPreview.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/klipyPicker/components/gifPreview/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/klipyPicker/components/gifView/gifView.d.ts +0 -0
- /package/dist/types/{package/common → common}/klipyPicker/components/gifView/gifView.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/klipyPicker/components/gifView/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/klipyPicker/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/klipyPicker/klipyPicker.d.ts +0 -0
- /package/dist/types/{package/common → common}/klipyPicker/klipyPicker.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/loading/iconLoading/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/loading/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/loading/spinnerLoading/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/loading/spinnerLoading/spinnerLoading.d.ts +0 -0
- /package/dist/types/{package/common → common}/modal/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/modal/modal.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/numberInput/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/numberInput/numberInput.d.ts +0 -0
- /package/dist/types/{package/common → common}/numberInput/numberInput.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/numberInput/useStepRepeat.d.ts +0 -0
- /package/dist/types/{package/common → common}/optionPicker/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/optionPicker/optionPicker.d.ts +0 -0
- /package/dist/types/{package/common → common}/optionPicker/optionPicker.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/otpInput/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/otpInput/otpInput.d.ts +0 -0
- /package/dist/types/{package/common → common}/otpInput/otpInput.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/overscroll/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/overscroll/overscroll.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/planCanvas/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/planCanvas/planCanvas.d.ts +0 -0
- /package/dist/types/{package/common → common}/planCanvas/planCanvas.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/popover/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/popover/popover.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/progressBar/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/progressBar/progressBar.d.ts +0 -0
- /package/dist/types/{package/common → common}/progressBar/progressBar.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/radioGroup/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/radioGroup/radioGroup.d.ts +0 -0
- /package/dist/types/{package/common → common}/radioGroup/radioGroup.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/rating/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/rating/rating.d.ts +0 -0
- /package/dist/types/{package/common → common}/rating/rating.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/revealLens/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/revealLens/revealLens.d.ts +0 -0
- /package/dist/types/{package/common → common}/revealLens/revealLens.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/ripple/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/ripple/ripple.d.ts +0 -0
- /package/dist/types/{package/common → common}/ripple/ripple.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/roomDrawer/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/roomDrawer/roomDrawer.d.ts +0 -0
- /package/dist/types/{package/common → common}/roomDrawer/roomDrawer.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/roomDrawer/usePlanHistory.d.ts +0 -0
- /package/dist/types/{package/common → common}/roomViewer/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/roomViewer/roomViewer.d.ts +0 -0
- /package/dist/types/{package/common → common}/roomViewer/roomViewer.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/scrollbarProvider/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/searchInput/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/searchInput/searchInput.d.ts +0 -0
- /package/dist/types/{package/common → common}/searchInput/searchInput.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/sectionHeader/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/sectionHeader/sectionHeader.d.ts +0 -0
- /package/dist/types/{package/common → common}/sectionHeader/sectionHeader.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/sheetBackdrop/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/sheetBackdrop/sheetBackdrop.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/skeleton/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/skeleton/skeleton.d.ts +0 -0
- /package/dist/types/{package/common → common}/skeleton/skeleton.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/slider/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/splitButton/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/splitButton/splitButton.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/stepper/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/stepper/stepper.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/sticky/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/sticky/sticky.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/sticky/stickyStack.d.ts +0 -0
- /package/dist/types/{package/common → common}/switch/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/switch/switch.d.ts +0 -0
- /package/dist/types/{package/common → common}/switch/switch.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/tabHeader/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/tabHeader/tabHeader.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/textarea/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/textarea/textarea.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/themeProvider/defaultTheme.d.ts +0 -0
- /package/dist/types/{package/common → common}/themeProvider/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/themeProvider/theme.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/themeProvider/useTheme.d.ts +0 -0
- /package/dist/types/{package/common → common}/tilt/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/tilt/tilt.d.ts +0 -0
- /package/dist/types/{package/common → common}/tilt/tilt.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/tilt/tiltMath.d.ts +0 -0
- /package/dist/types/{package/common → common}/tiltGroup/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/tiltGroup/tiltGroup.d.ts +0 -0
- /package/dist/types/{package/common → common}/tiltGroup/tiltGroup.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/timeInput/components/clockDial/clockDial.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/timeInput/components/clockDial/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/timeInput/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/timeInput/timeFunctions.d.ts +0 -0
- /package/dist/types/{package/common → common}/timeInput/timeInput.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/timeline/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/timeline/timeline.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/timer/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/timer/timer.chime.d.ts +0 -0
- /package/dist/types/{package/common → common}/timer/timer.d.ts +0 -0
- /package/dist/types/{package/common → common}/timer/timer.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/toast/toast.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/toast/toastService.d.ts +0 -0
- /package/dist/types/{package/common → common}/tooltip/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/tooltip/tooltip.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/types/actions.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/types/baseProps.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/types/icon.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/types/slots.types.d.ts +0 -0
- /package/dist/types/{package/common → common}/utils/renderIcon.d.ts +0 -0
- /package/dist/types/{package/common → common}/utils/scrollAncestors.d.ts +0 -0
- /package/dist/types/{package/common → common}/utils/visualViewport.d.ts +0 -0
- /package/dist/types/{package/common → common}/virtualList/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/virtualList/useColumns.d.ts +0 -0
- /package/dist/types/{package/common → common}/virtualList/useRowDrag.d.ts +0 -0
- /package/dist/types/{package/common → common}/virtualList/useSelection.d.ts +0 -0
- /package/dist/types/{package/common → common}/virtualList/useVirtualWindow.d.ts +0 -0
- /package/dist/types/{package/common → common}/virtualList/virtualList.d.ts +0 -0
- /package/dist/types/{package/common → common}/virtualList/virtualList.utils.d.ts +0 -0
- /package/dist/types/{package/common → common}/wizard/index.d.ts +0 -0
- /package/dist/types/{package/common → common}/wizard/wizard.types.d.ts +0 -0
- /package/dist/types/{package/hooks → hooks}/useWindowSize.d.ts +0 -0
- /package/dist/types/{package/services → services}/formValidation/FormValidatorGroupWithForm.d.ts +0 -0
- /package/dist/types/{package/services → services}/formValidation/useFormValidatorGroup.d.ts +0 -0
- /package/dist/types/{package/services → services}/formValidation/validatableComponent.d.ts +0 -0
- /package/dist/types/{package/services → services}/klipy.d.ts +0 -0
- /package/dist/types/{package/services → services}/localization.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.graph.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.graph.ts"],"sourcesContent":["/**\n * Graph maintenance: the operations that keep the wall graph a valid planar embedding\n * while the user draws.\n *\n * The invariant every function here protects: no two walls may cross without a node at\n * the intersection, and no node may lie on a wall's interior without that wall being\n * split there. Break either and the face walk silently merges two rooms into one\n * figure-eight face, with no error anywhere.\n *\n * Every operation is pure and returns a new floor, for direct use as React state.\n */\n\nimport {\n EPS_ANGLE,\n EPS_COINCIDENT,\n MIN_OPENING_WIDTH,\n MIN_WALL_LENGTH,\n cross,\n dist,\n pointToSegment,\n projectOnSegment,\n segmentIntersection,\n} from './floorPlan.geometry';\nimport { PlanIssueKind, WallType } from './floorPlan.types';\nimport type {\n PlanEdit,\n PlanFloor,\n PlanIssue,\n PlanNode,\n PlanOpening,\n PlanPoint,\n PlanWall,\n} from './floorPlan.types';\n\n// ─── Ids ───────────────────────────────────────────────────────────────────────\n\nlet idSeq = 0;\n\n/**\n * Ids are deliberately non-numeric strings, so `Record` iteration keeps insertion\n * order (JavaScript reorders integer-like keys), which is what makes derivation\n * reproducible.\n */\nexport function newId(prefix: string): string {\n idSeq += 1;\n const rand =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'\n ? crypto.randomUUID().slice(0, 8)\n : Math.random().toString(36).slice(2, 10);\n return `${prefix}_${rand}${idSeq.toString(36)}`;\n}\n\n/** Test-only: makes generated ids reproducible within a single test. */\nexport function __resetIdSeq(): void {\n idSeq = 0;\n}\n\n// ─── Internals ─────────────────────────────────────────────────────────────────\n\nfunction cloneFloor(floor: PlanFloor): PlanFloor {\n return {\n ...floor,\n nodes: { ...floor.nodes },\n walls: { ...floor.walls },\n openings: { ...floor.openings },\n rooms: { ...floor.rooms },\n };\n}\n\nfunction issue(kind: PlanIssueKind, message: string, extra: Partial<PlanIssue> = {}): PlanIssue {\n return { kind, message, ...extra };\n}\n\nfunction wallLength(floor: PlanFloor, wall: PlanWall): number {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) return 0;\n return dist(a, b);\n}\n\nfunction wallsAtNode(floor: PlanFloor, nodeId: string): PlanWall[] {\n return Object.values(floor.walls).filter((w) => w.a === nodeId || w.b === nodeId);\n}\n\nfunction findWallBetween(floor: PlanFloor, a: string, b: string): PlanWall | null {\n for (const w of Object.values(floor.walls)) {\n if ((w.a === a && w.b === b) || (w.a === b && w.b === a)) return w;\n }\n return null;\n}\n\n// ─── Node spatial hash ─────────────────────────────────────────────────────────\n\n/**\n * Bucket size for the node hash, in millimetres. Any lookup checks the 3x3\n * neighbourhood, so this only has to exceed the largest snap tolerance in world units.\n */\nconst HASH_CELL = 250;\n\nfunction hashKey(x: number, y: number): string {\n return `${Math.round(x / HASH_CELL)}|${Math.round(y / HASH_CELL)}`;\n}\n\nfunction buildNodeHash(floor: PlanFloor): Map<string, PlanNode[]> {\n const map = new Map<string, PlanNode[]>();\n for (const node of Object.values(floor.nodes)) {\n const key = hashKey(node.x, node.y);\n const list = map.get(key);\n if (list) list.push(node);\n else map.set(key, [node]);\n }\n return map;\n}\n\n/** Nearest existing node within `tol`, using the spatial hash. */\nexport function findNodeNear(floor: PlanFloor, p: PlanPoint, tol: number): PlanNode | null {\n const hash = buildNodeHash(floor);\n const cx = Math.round(p.x / HASH_CELL);\n const cy = Math.round(p.y / HASH_CELL);\n let best: PlanNode | null = null;\n let bestDist = tol;\n const span = Math.max(1, Math.ceil(tol / HASH_CELL));\n for (let dx = -span; dx <= span; dx++) {\n for (let dy = -span; dy <= span; dy++) {\n for (const node of hash.get(`${cx + dx}|${cy + dy}`) ?? []) {\n const d = dist(p, node);\n if (d <= bestDist) {\n best = node;\n bestDist = d;\n }\n }\n }\n }\n return best;\n}\n\n/** Nearest wall whose centreline passes within `tol` of `p`. */\nexport function findWallNear(\n floor: PlanFloor,\n p: PlanPoint,\n tol: number,\n exclude?: ReadonlySet<string>,\n): { wall: PlanWall; t: number; point: PlanPoint; dist: number } | null {\n let best: { wall: PlanWall; t: number; point: PlanPoint; dist: number } | null = null;\n for (const wall of Object.values(floor.walls)) {\n if (exclude?.has(wall.id)) continue;\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const r = pointToSegment(p, a, b);\n if (r.dist <= tol && (!best || r.dist < best.dist)) {\n best = { wall, t: r.t, point: r.point, dist: r.dist };\n }\n }\n return best;\n}\n\n// ─── splitWall ─────────────────────────────────────────────────────────────────\n\nexport interface SplitWallResult {\n nodeId: string;\n wallIds: [string, string] | null;\n droppedOpeningIds: string[];\n}\n\n/**\n * Splits a wall at a point or parameter, returning the node at the cut.\n *\n * Refuses to cut within `MIN_WALL_LENGTH` of either end, returning that endpoint's\n * existing node instead. That single rule is what keeps zero-length walls out of the\n * graph entirely, which in turn is what stops the angular sort from being fed a\n * direction-less dart.\n */\nexport function splitWall(\n floor: PlanFloor,\n wallId: string,\n at: PlanPoint | number,\n): PlanEdit<SplitWallResult> {\n const wall = floor.walls[wallId];\n if (!wall) {\n return { floor, result: { nodeId: '', wallIds: null, droppedOpeningIds: [] }, issues: [] };\n }\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) {\n return { floor, result: { nodeId: '', wallIds: null, droppedOpeningIds: [] }, issues: [] };\n }\n\n const len = dist(a, b);\n const point = typeof at === 'number' ? { x: a.x + (b.x - a.x) * at, y: a.y + (b.y - a.y) * at } : at;\n // Project exactly, so the two children stay perfectly collinear and dissolveNode can\n // undo the split cleanly later.\n const exact = projectOnSegment(point, a, b);\n const fromA = dist(a, exact);\n\n if (fromA < MIN_WALL_LENGTH) {\n return { floor, result: { nodeId: wall.a, wallIds: null, droppedOpeningIds: [] }, issues: [] };\n }\n if (len - fromA < MIN_WALL_LENGTH) {\n return { floor, result: { nodeId: wall.b, wallIds: null, droppedOpeningIds: [] }, issues: [] };\n }\n\n const next = cloneFloor(floor);\n const nodeId = newId('n');\n next.nodes[nodeId] = { id: nodeId, x: exact.x, y: exact.y };\n\n const firstId = newId('w');\n const secondId = newId('w');\n const base = { thickness: wall.thickness, type: wall.type, height: wall.height, baseHeight: wall.baseHeight };\n next.walls[firstId] = { ...base, id: firstId, a: wall.a, b: nodeId };\n next.walls[secondId] = { ...base, id: secondId, a: nodeId, b: wall.b };\n delete next.walls[wallId];\n\n // Reassign openings by the side their CENTRE falls on. An opening straddling the cut\n // is a genuine conflict: move it wholly into that child and clamp it, or drop it and\n // say so. Silently deleting a window is not acceptable.\n const droppedOpeningIds: string[] = [];\n const issues: PlanIssue[] = [];\n for (const opening of Object.values(floor.openings)) {\n if (opening.wallId !== wallId) continue;\n const intoFirst = opening.offset <= fromA;\n const childId = intoFirst ? firstId : secondId;\n const childLen = intoFirst ? fromA : len - fromA;\n const offset = intoFirst ? opening.offset : opening.offset - fromA;\n\n const maxWidth = Math.min(opening.width, childLen - 2, offset * 2, (childLen - offset) * 2);\n if (maxWidth < MIN_OPENING_WIDTH) {\n delete next.openings[opening.id];\n droppedOpeningIds.push(opening.id);\n issues.push(\n issue(\n PlanIssueKind.OpeningDropped,\n 'An opening was removed: the wall it sat on became too short for it.',\n { openingIds: [opening.id], wallIds: [wallId] },\n ),\n );\n continue;\n }\n next.openings[opening.id] = { ...opening, wallId: childId, offset, width: maxWidth };\n }\n\n return { floor: next, result: { nodeId, wallIds: [firstId, secondId], droppedOpeningIds }, issues };\n}\n\n// ─── resolveNodeAt ─────────────────────────────────────────────────────────────\n\nexport interface ResolveNodeResult {\n nodeId: string;\n createdNode: boolean;\n splitWallId: string | null;\n}\n\n/**\n * Returns the node to use at `p`: an existing one within `tol`, a new one created by\n * splitting a wall that passes under `p`, or a brand new free-standing node.\n */\nexport function resolveNodeAt(\n floor: PlanFloor,\n p: PlanPoint,\n tol: number,\n): PlanEdit<ResolveNodeResult> {\n const existing = findNodeNear(floor, p, tol);\n if (existing) {\n return { floor, result: { nodeId: existing.id, createdNode: false, splitWallId: null }, issues: [] };\n }\n\n const onWall = findWallNear(floor, p, tol);\n if (onWall) {\n const split = splitWall(floor, onWall.wall.id, onWall.point);\n if (split.result.nodeId) {\n return {\n floor: split.floor,\n result: {\n nodeId: split.result.nodeId,\n createdNode: split.result.wallIds !== null,\n splitWallId: split.result.wallIds ? onWall.wall.id : null,\n },\n issues: split.issues,\n };\n }\n }\n\n const next = cloneFloor(floor);\n const nodeId = newId('n');\n next.nodes[nodeId] = { id: nodeId, x: p.x, y: p.y };\n return { floor: next, result: { nodeId, createdNode: true, splitWallId: null }, issues: [] };\n}\n\n// ─── addWall ───────────────────────────────────────────────────────────────────\n\nexport type WallAttrs = Pick<PlanWall, 'thickness' | 'type'> &\n Partial<Pick<PlanWall, 'height' | 'baseHeight'>>;\n\nexport const DEFAULT_WALL_ATTRS: WallAttrs = { thickness: 200, type: WallType.Interior };\n\ninterface Cut {\n t: number;\n nodeId: string | null;\n /** Set while the node does not exist yet because its wall has not been split. */\n pending?: { wallId: string; s: number };\n}\n\n/**\n * Adds a wall from `a` to `b`, splitting anything it crosses so the graph stays planar.\n *\n * Collect-then-apply, in two phases: the naive version splits walls while iterating\n * over walls, which both invalidates the iteration and reparameterises the very\n * segments it is about to test.\n */\nexport function addWall(\n floor: PlanFloor,\n a: PlanPoint,\n b: PlanPoint,\n attrs: WallAttrs = DEFAULT_WALL_ATTRS,\n tol: number = EPS_COINCIDENT,\n): PlanEdit<{ wallIds: string[]; nodeIds: string[] }> {\n const issues: PlanIssue[] = [];\n if (dist(a, b) < MIN_WALL_LENGTH) {\n return { floor, result: { wallIds: [], nodeIds: [] }, issues };\n }\n\n // 1. Endpoints. Each may reuse a node, split a wall, or create a node.\n const startEdit = resolveNodeAt(floor, a, tol);\n let work = startEdit.floor;\n issues.push(...startEdit.issues);\n const endEdit = resolveNodeAt(work, b, tol);\n work = endEdit.floor;\n issues.push(...endEdit.issues);\n\n const na = startEdit.result.nodeId;\n const nb = endEdit.result.nodeId;\n if (na === nb) return { floor, result: { wallIds: [], nodeIds: [] }, issues };\n\n const A = work.nodes[na];\n const B = work.nodes[nb];\n const len = dist(A, B);\n if (len < MIN_WALL_LENGTH) return { floor, result: { wallIds: [], nodeIds: [] }, issues };\n\n // 2. COLLECT. Nothing is mutated in this phase.\n const cuts: Cut[] = [\n { t: 0, nodeId: na },\n { t: 1, nodeId: nb },\n ];\n const splits = new Map<string, number[]>();\n const overlaps: Array<[number, number]> = [];\n\n const paramAlong = (p: PlanPoint): number => pointToSegment(p, A, B).t;\n\n for (const wall of Object.values(work.walls)) {\n const wa = work.nodes[wall.a];\n const wb = work.nodes[wall.b];\n if (!wa || !wb) continue;\n\n const hit = segmentIntersection(A, B, wa, wb, tol);\n\n if (hit.kind === 'collinearOverlap') {\n const t0 = paramAlong(wa);\n const t1 = paramAlong(wb);\n overlaps.push([Math.min(t0, t1), Math.max(t0, t1)]);\n // Endpoints of the overlapping wall that fall strictly inside AB still need cuts,\n // or the new wall would run straight past them.\n for (const [node, t] of [\n [wa, t0],\n [wb, t1],\n ] as const) {\n if (t * len > MIN_WALL_LENGTH && (1 - t) * len > MIN_WALL_LENGTH) {\n cuts.push({ t, nodeId: node.id });\n }\n }\n continue;\n }\n\n if (hit.kind === 'proper' && hit.t !== undefined && hit.s !== undefined) {\n const list = splits.get(wall.id);\n if (list) list.push(hit.s);\n else splits.set(wall.id, [hit.s]);\n cuts.push({ t: hit.t, nodeId: null, pending: { wallId: wall.id, s: hit.s } });\n continue;\n }\n\n if (hit.kind === 'touch' && hit.t !== undefined && hit.s !== undefined) {\n // A T junction where one of the wall's own endpoints sits on AB: reuse it.\n const atWallStart = hit.s <= 0.5;\n const endpoint = atWallStart ? wa : wb;\n const tOnAb = paramAlong(endpoint);\n if (\n pointToSegment(endpoint, A, B).dist <= tol &&\n tOnAb * len > MIN_WALL_LENGTH &&\n (1 - tOnAb) * len > MIN_WALL_LENGTH\n ) {\n cuts.push({ t: tOnAb, nodeId: endpoint.id });\n }\n }\n }\n\n // 3. Nodes lying on AB that no crossing test found. NOT redundant with step 2: a node\n // whose incident walls all run away from AB is invisible to every crossing test, yet\n // failing to cut AB there leaves a node on a wall interior, which silently merges the\n // two rooms either side of it.\n for (const node of Object.values(work.nodes)) {\n if (node.id === na || node.id === nb) continue;\n const r = pointToSegment(node, A, B);\n if (r.dist > tol) continue;\n if (r.t * len <= MIN_WALL_LENGTH || (1 - r.t) * len <= MIN_WALL_LENGTH) continue;\n cuts.push({ t: r.t, nodeId: node.id });\n }\n\n // 4. APPLY splits, per wall, in DESCENDING parameter order so that earlier\n // parameters stay valid as later ones are consumed.\n for (const [wallId, params] of splits) {\n const sorted = [...params].sort((x, y) => y - x);\n let currentWallId = wallId;\n const remaining = new Set(sorted);\n for (const s of sorted) {\n const target = work.walls[currentWallId];\n if (!target) break;\n const wa = work.nodes[target.a];\n const wb = work.nodes[target.b];\n if (!wa || !wb) break;\n // Re-project onto the wall as it stands now, rather than reusing the original\n // parameter, which the previous split may have reparameterised.\n const original = floor.walls[wallId];\n const oa = work.nodes[original?.a ?? target.a] ?? wa;\n const ob = work.nodes[original?.b ?? target.b] ?? wb;\n const worldPoint = { x: oa.x + (ob.x - oa.x) * s, y: oa.y + (ob.y - oa.y) * s };\n const edit = splitWall(work, currentWallId, worldPoint);\n work = edit.floor;\n issues.push(...edit.issues);\n remaining.delete(s);\n for (const cut of cuts) {\n if (cut.pending && cut.pending.wallId === wallId && cut.pending.s === s) {\n cut.nodeId = edit.result.nodeId;\n cut.pending = undefined;\n }\n }\n // Continue splitting whichever child still holds the remaining parameters.\n if (edit.result.wallIds) {\n const [first, second] = edit.result.wallIds;\n const nextS = Math.max(...[...remaining], -1);\n currentWallId = nextS >= 0 && nextS > s ? second : first;\n }\n }\n }\n\n // 5. Chain the cuts into walls.\n const resolved = cuts.filter((c): c is Cut & { nodeId: string } => Boolean(c.nodeId));\n resolved.sort((x, y) => x.t - y.t);\n\n const chain: Array<Cut & { nodeId: string }> = [];\n for (const cut of resolved) {\n const last = chain[chain.length - 1];\n if (!last) {\n chain.push(cut);\n continue;\n }\n if (last.nodeId === cut.nodeId) continue;\n if ((cut.t - last.t) * len < MIN_WALL_LENGTH) {\n // Too close to be a separate wall. Prefer whichever end is an endpoint of AB.\n if (cut.t >= 1 - 1e-9) chain[chain.length - 1] = cut;\n continue;\n }\n chain.push(cut);\n }\n\n const createdWallIds: string[] = [];\n for (let i = 0; i + 1 < chain.length; i++) {\n const from = chain[i];\n const to = chain[i + 1];\n const midT = (from.t + to.t) / 2;\n if (overlaps.some(([lo, hi]) => midT > lo + 1e-9 && midT < hi - 1e-9)) {\n // Already walled. Do not create a duplicate, and do not rewrite the existing\n // wall's attributes from a stroke that was aimed elsewhere.\n continue;\n }\n if (findWallBetween(work, from.nodeId, to.nodeId)) continue;\n const wa = work.nodes[from.nodeId];\n const wb = work.nodes[to.nodeId];\n if (!wa || !wb || dist(wa, wb) < MIN_WALL_LENGTH) continue;\n\n const id = newId('w');\n work = { ...work, walls: { ...work.walls, [id]: { ...attrs, id, a: from.nodeId, b: to.nodeId } } };\n createdWallIds.push(id);\n }\n\n if (createdWallIds.length === 0 && overlaps.length > 0) {\n issues.push(\n issue(PlanIssueKind.DuplicateWall, 'A wall already covers that span, so nothing was added.'),\n );\n }\n\n return {\n floor: work,\n result: { wallIds: createdWallIds, nodeIds: chain.map((c) => c.nodeId) },\n issues,\n };\n}\n\n/** Draws the four walls of an axis-aligned rectangle, welding onto anything already there. */\nexport function addRect(\n floor: PlanFloor,\n corner: PlanPoint,\n opposite: PlanPoint,\n attrs: WallAttrs = DEFAULT_WALL_ATTRS,\n tol: number = EPS_COINCIDENT,\n): PlanEdit<{ wallIds: string[] }> {\n const x0 = Math.min(corner.x, opposite.x);\n const x1 = Math.max(corner.x, opposite.x);\n const y0 = Math.min(corner.y, opposite.y);\n const y1 = Math.max(corner.y, opposite.y);\n if (x1 - x0 < MIN_WALL_LENGTH || y1 - y0 < MIN_WALL_LENGTH) {\n return { floor, result: { wallIds: [] }, issues: [] };\n }\n\n const corners: PlanPoint[] = [\n { x: x0, y: y0 },\n { x: x1, y: y0 },\n { x: x1, y: y1 },\n { x: x0, y: y1 },\n ];\n\n let work = floor;\n const wallIds: string[] = [];\n const issues: PlanIssue[] = [];\n for (let i = 0; i < 4; i++) {\n const edit = addWall(work, corners[i], corners[(i + 1) % 4], attrs, tol);\n work = edit.floor;\n wallIds.push(...edit.result.wallIds);\n issues.push(...edit.issues);\n }\n return { floor: work, result: { wallIds }, issues };\n}\n\n// ─── mergeNodes ────────────────────────────────────────────────────────────────\n\n/**\n * Merges `removeId` into `keepId`, as when a node is dragged onto another.\n *\n * Order matters, and step 3 is mandatory rather than cosmetic: a duplicate wall between\n * the same pair of nodes is exactly the identical-angle degeneracy that corrupts the\n * face walk's angular sort.\n */\nexport function mergeNodes(\n floor: PlanFloor,\n keepId: string,\n removeId: string,\n): PlanEdit<{ removedWallIds: string[] }> {\n if (keepId === removeId || !floor.nodes[keepId] || !floor.nodes[removeId]) {\n return { floor, result: { removedWallIds: [] }, issues: [] };\n }\n\n const next = cloneFloor(floor);\n const removedWallIds: string[] = [];\n const issues: PlanIssue[] = [];\n\n // 1. Rewire.\n for (const wall of Object.values(next.walls)) {\n if (wall.a === removeId) next.walls[wall.id] = { ...next.walls[wall.id], a: keepId };\n if (wall.b === removeId) next.walls[wall.id] = { ...next.walls[wall.id], b: keepId };\n }\n\n // 2. Drop self-loops, and their openings with them.\n for (const wall of Object.values(next.walls)) {\n if (wall.a !== wall.b) continue;\n delete next.walls[wall.id];\n removedWallIds.push(wall.id);\n for (const opening of Object.values(next.openings)) {\n if (opening.wallId === wall.id) delete next.openings[opening.id];\n }\n }\n\n // 3. Deduplicate walls that now share the same unordered node pair.\n const seen = new Map<string, PlanWall>();\n for (const wall of Object.values(next.walls)) {\n const key = wall.a < wall.b ? `${wall.a}|${wall.b}` : `${wall.b}|${wall.a}`;\n const prior = seen.get(key);\n if (!prior) {\n seen.set(key, wall);\n continue;\n }\n // Keep the thicker wall, and carry both walls' openings onto it.\n const keep = wall.thickness >= prior.thickness ? wall : prior;\n const drop = keep === wall ? prior : wall;\n for (const opening of Object.values(next.openings)) {\n if (opening.wallId === drop.id) {\n next.openings[opening.id] = { ...opening, wallId: keep.id };\n }\n }\n delete next.walls[drop.id];\n removedWallIds.push(drop.id);\n seen.set(key, keep);\n issues.push(\n issue(PlanIssueKind.DuplicateWall, 'Two walls became the same wall and were merged.', {\n wallIds: [keep.id, drop.id],\n }),\n );\n }\n\n // 4. Drop the now-unreferenced node.\n delete next.nodes[removeId];\n\n return { floor: next, result: { removedWallIds }, issues };\n}\n\n// ─── dissolveNode ──────────────────────────────────────────────────────────────\n\nexport interface DissolveNodeOptions {\n /**\n * Rejoin the two walls even when the corner is bent or the walls differ in\n * construction, taking the thicker wall's attributes and rescaling openings onto the\n * shorter merged wall.\n *\n * This is \"delete this corner\" as a user means it. The default, unforced behaviour is\n * the stricter one used by cleanup and by `removeWall`, where dissolving must not\n * change the drawing's geometry at all.\n */\n force?: boolean;\n}\n\n/**\n * Merges the two walls meeting at a degree-2 node back into one, the natural inverse of\n * `splitWall`.\n *\n * Returns `null` unless the node is genuinely a seam: degree exactly 2, both walls\n * identical in construction, and the turn within `EPS_ANGLE` of straight. Pass\n * `{ force: true }` to rejoin a bent corner as well. Never call it mid-drag: it destroys\n * node ids the user may be holding.\n */\nexport function dissolveNode(\n floor: PlanFloor,\n nodeId: string,\n options: DissolveNodeOptions = {},\n): PlanEdit<{ wallId: string } | null> {\n const { force = false } = options;\n const node = floor.nodes[nodeId];\n if (!node) return { floor, result: null, issues: [] };\n\n const incident = wallsAtNode(floor, nodeId);\n if (incident.length !== 2) return { floor, result: null, issues: [] };\n\n const [w1, w2] = incident;\n const sameConstruction =\n w1.thickness === w2.thickness &&\n w1.type === w2.type &&\n w1.height === w2.height &&\n w1.baseHeight === w2.baseHeight;\n if (!sameConstruction && !force) return { floor, result: null, issues: [] };\n\n const far1 = w1.a === nodeId ? w1.b : w1.a;\n const far2 = w2.a === nodeId ? w2.b : w2.a;\n if (far1 === far2) return { floor, result: null, issues: [] };\n\n const p1 = floor.nodes[far1];\n const p2 = floor.nodes[far2];\n if (!p1 || !p2) return { floor, result: null, issues: [] };\n\n const span = dist(p1, p2);\n if (span < MIN_WALL_LENGTH) return { floor, result: null, issues: [] };\n\n if (!force) {\n // Straightness by perpendicular offset rather than raw angle, so the tolerance stays\n // meaningful at any wall length.\n const offset = Math.abs(cross(p1, p2, node)) / span;\n if (offset > Math.max(EPS_COINCIDENT, span * EPS_ANGLE)) {\n return { floor, result: null, issues: [] };\n }\n }\n\n // Forced over a bent corner, the survivor is the thicker of the two, since that is the\n // one whose construction the rest of the plan is more likely to depend on.\n const keep = !sameConstruction && w1.thickness < w2.thickness ? w2 : w1;\n\n const next = cloneFloor(floor);\n const id = newId('w');\n next.walls[id] = {\n id,\n a: far1,\n b: far2,\n thickness: keep.thickness,\n type: keep.type,\n height: keep.height,\n baseHeight: keep.baseHeight,\n };\n\n // Re-express every opening's offset against the merged wall's direction (far1 -> far2).\n const len1 = dist(p1, node);\n const len2 = dist(node, p2);\n // Cutting a bent corner shortens the run, so positions are scaled along it rather than\n // carried over, which would push an opening off the end of its own wall.\n const scale = len1 + len2 > 0 ? span / (len1 + len2) : 1;\n const issues: PlanIssue[] = [];\n\n for (const opening of Object.values(floor.openings)) {\n if (opening.wallId !== w1.id && opening.wallId !== w2.id) continue;\n const onFirst = opening.wallId === w1.id;\n const wall = onFirst ? w1 : w2;\n const startsAtNode = wall.a === nodeId;\n const lenOfWall = wallLength(floor, wall);\n // Distance from the seam, then from the merged wall's own start.\n const fromSeam = startsAtNode ? opening.offset : lenOfWall - opening.offset;\n const alongOriginal = onFirst ? len1 - fromSeam : len1 + fromSeam;\n const offsetOnMerged = alongOriginal * scale;\n\n const width = Math.min(opening.width * scale, span - 2);\n if (width < MIN_OPENING_WIDTH) {\n issues.push(\n issue(\n PlanIssueKind.OpeningDropped,\n 'An opening was removed: the wall it sat on became too short for it.',\n { openingIds: [opening.id], wallIds: [wall.id] },\n ),\n );\n delete next.openings[opening.id];\n continue;\n }\n\n next.openings[opening.id] = {\n ...opening,\n wallId: id,\n width,\n offset: Math.min(Math.max(offsetOnMerged, width / 2), span - width / 2),\n };\n }\n\n delete next.walls[w1.id];\n delete next.walls[w2.id];\n delete next.nodes[nodeId];\n\n return { floor: next, result: { wallId: id }, issues };\n}\n\n// ─── detachWall ────────────────────────────────────────────────────────────────\n\nexport interface DetachWallResult {\n /** The wall's end nodes after the detach, in `[a, b]` order. */\n nodeIds: [string, string];\n /** Connecting walls minted where an end was shared with a neighbour. */\n connectorIds: string[];\n /** Ends that became a straight seam once the wall left, and were dissolved away. */\n dissolvedNodeIds: string[];\n}\n\n/**\n * Pulls a wall off the nodes it shares with its neighbours and moves it by `delta`,\n * leaving a connecting wall behind at each end that was shared.\n *\n * This is the extrude half of dragging a wall. A plain drag moves the shared end nodes,\n * so everything meeting the wall follows it; here the neighbours keep their ends and\n * only the new connectors grow, which is what you want when a partition joins the wall\n * halfway along and should stay put.\n *\n * A free end is only moved: there is nothing there to detach from, and a connector would\n * be zero length. For the same reason `delta` must be at least `MIN_WALL_LENGTH` long —\n * below that the caller should `moveNode` both ends instead.\n *\n * The connector continues whatever was already at the corner (its thickness, type and\n * heights) when exactly one wall was, so pulling a wall off a plain corner redraws\n * exactly as a plain drag would: the seam that leaves behind is straight and is\n * dissolved before returning. At a junction there is no single wall to continue, so the\n * connector takes the dragged wall's own construction.\n */\nexport function detachWall(\n floor: PlanFloor,\n wallId: string,\n delta: PlanPoint,\n): PlanEdit<DetachWallResult | null> {\n const wall = floor.walls[wallId];\n if (!wall || wall.a === wall.b) return { floor, result: null, issues: [] };\n if (Math.hypot(delta.x, delta.y) < MIN_WALL_LENGTH) return { floor, result: null, issues: [] };\n\n const ends: [string, string] = [wall.a, wall.b];\n const nodeIds: [string, string] = [wall.a, wall.b];\n const sources: (PlanWall | null)[] = [null, null];\n const connectorIds: string[] = [];\n const issues: PlanIssue[] = [];\n let out = floor;\n\n // 1. Give the wall its own ends. `resolveNodeAt` rather than a bare node, because the\n // new end often lands in the middle of another wall — the usual case is pushing the\n // shared wall of two rooms sideways, where each end slides along the wall above and\n // below it — and only a split keeps a node off a wall's interior.\n ends.forEach((nodeId, index) => {\n const origin = floor.nodes[nodeId];\n if (!origin) return;\n const to = { x: origin.x + delta.x, y: origin.y + delta.y };\n const others = wallsAtNode(floor, nodeId).filter((w) => w.id !== wallId);\n\n if (others.length === 0) {\n // A free end has nothing to detach from, and a connector there would be a wall\n // between a node and itself.\n const next = cloneFloor(out);\n next.nodes[nodeId] = { ...next.nodes[nodeId], x: to.x, y: to.y };\n out = next;\n return;\n }\n\n const edit = resolveNodeAt(out, to, EPS_COINCIDENT);\n out = edit.floor;\n nodeIds[index] = edit.result.nodeId;\n // The connector continues whatever was already at this corner, so pulling a wall off\n // a plain corner redraws exactly as a plain drag would. At a junction there is no\n // single wall to continue, so it takes the dragged wall's own construction.\n sources[index] = others.length === 1 ? others[0] : wall;\n });\n\n // 2. Move the wall onto them. Its openings ride along untouched: a detach is a pure\n // translation, so the wall keeps its id, its direction and its length.\n const moved = cloneFloor(out);\n moved.walls[wallId] = { ...moved.walls[wallId], a: nodeIds[0], b: nodeIds[1] };\n out = moved;\n\n // 3. Bridge each end back to where it came from, unless a wall already runs there.\n ends.forEach((nodeId, index) => {\n const source = sources[index];\n const from = out.nodes[nodeId];\n const to = out.nodes[nodeIds[index]];\n if (!source || !from || !to) return;\n const edit = addWall(out, from, to, {\n thickness: source.thickness,\n type: source.type,\n height: source.height,\n baseHeight: source.baseHeight,\n });\n out = edit.floor;\n connectorIds.push(...edit.result.wallIds);\n issues.push(...edit.issues);\n });\n\n // 4. An end that was a plain corner is now a straight seam. Dissolving it is what\n // makes detaching a wall with nothing attached to it a no-op on the drawing.\n const dissolvedNodeIds: string[] = [];\n ends.forEach((nodeId, index) => {\n if (nodeIds[index] === nodeId) return;\n const edit = dissolveNode(out, nodeId);\n if (!edit.result) return;\n out = edit.floor;\n dissolvedNodeIds.push(nodeId);\n issues.push(...edit.issues);\n });\n\n return { floor: out, result: { nodeIds, connectorIds, dissolvedNodeIds }, issues };\n}\n\n// ─── weldShortWalls ────────────────────────────────────────────────────────────\n\n/**\n * Collapses every wall shorter than `minLength` by merging its two ends together.\n *\n * Squashing a wall to nothing is the one thing a drag can do that the model forbids, and\n * it is easy to do by accident: pushing a wall back onto the line it was detached from,\n * or dragging a corner past the one next to it. Deleting the short wall is the wrong\n * repair — it leaves two nodes sitting on the same point with the plan split between\n * them, which reads as two corners stacked on top of each other and derives as two\n * rooms. Merging is lossless, since the two ends are within `minLength` of each other by\n * definition.\n *\n * The end with more walls on it survives, so the corner that was already there keeps its\n * position and the one that arrived is the one that gives way.\n */\nexport function weldShortWalls(\n floor: PlanFloor,\n minLength: number = MIN_WALL_LENGTH,\n): PlanEdit<{ weldedWallIds: string[] }> {\n let out = floor;\n const weldedWallIds: string[] = [];\n const issues: PlanIssue[] = [];\n\n // Re-scan rather than iterate: one weld moves nodes, so it can shorten another wall to\n // nothing in turn. Bounded by the wall count, since every pass removes at least one.\n for (let guard = Object.keys(floor.walls).length; guard > 0; guard--) {\n const short = Object.values(out.walls).find((w) => {\n if (w.a === w.b) return false;\n const a = out.nodes[w.a];\n const b = out.nodes[w.b];\n return a && b && dist(a, b) < minLength;\n });\n if (!short) break;\n\n const keep =\n wallsAtNode(out, short.b).length > wallsAtNode(out, short.a).length ? short.b : short.a;\n const edit = mergeNodes(out, keep, keep === short.a ? short.b : short.a);\n if (edit.floor === out) break;\n out = edit.floor;\n weldedWallIds.push(short.id);\n issues.push(...edit.issues);\n }\n\n return { floor: out, result: { weldedWallIds }, issues };\n}\n\n// ─── removeWall / moveNode ─────────────────────────────────────────────────────\n\nexport function removeWall(\n floor: PlanFloor,\n wallId: string,\n opts: { pruneOrphanNodes?: boolean; dissolveCollinear?: boolean } = {},\n): PlanEdit<{ removedNodeIds: string[]; dissolvedWallIds: string[] }> {\n const { pruneOrphanNodes = true, dissolveCollinear = true } = opts;\n const wall = floor.walls[wallId];\n if (!wall) return { floor, result: { removedNodeIds: [], dissolvedWallIds: [] }, issues: [] };\n\n let next = cloneFloor(floor);\n delete next.walls[wallId];\n for (const opening of Object.values(next.openings)) {\n if (opening.wallId === wallId) delete next.openings[opening.id];\n }\n\n const removedNodeIds: string[] = [];\n const dissolvedWallIds: string[] = [];\n const issues: PlanIssue[] = [];\n\n for (const endpoint of [wall.a, wall.b]) {\n const degree = wallsAtNode(next, endpoint).length;\n if (degree === 0 && pruneOrphanNodes) {\n delete next.nodes[endpoint];\n removedNodeIds.push(endpoint);\n } else if (degree === 2 && dissolveCollinear) {\n // The natural inverse of the split that created this seam.\n const edit = dissolveNode(next, endpoint);\n if (edit.result) {\n next = edit.floor;\n dissolvedWallIds.push(edit.result.wallId);\n removedNodeIds.push(endpoint);\n issues.push(...edit.issues);\n }\n }\n }\n\n return { floor: next, result: { removedNodeIds, dissolvedWallIds }, issues };\n}\n\nexport function moveNode(floor: PlanFloor, nodeId: string, to: PlanPoint): PlanEdit {\n const node = floor.nodes[nodeId];\n if (!node) return { floor, result: undefined, issues: [] };\n const next = cloneFloor(floor);\n next.nodes[nodeId] = { ...node, x: to.x, y: to.y };\n return { floor: next, result: undefined, issues: [] };\n}\n\n/**\n * Translates every node, and every room anchor with it.\n *\n * Room matching does not depend on this (it is primarily wall-id based), but a plan\n * that is dragged and then saved without a derive should still have sane anchors.\n */\nexport function transformPlan(floor: PlanFloor, dx: number, dy: number): PlanFloor {\n const next = cloneFloor(floor);\n for (const node of Object.values(floor.nodes)) {\n next.nodes[node.id] = { ...node, x: node.x + dx, y: node.y + dy };\n }\n for (const room of Object.values(floor.rooms)) {\n next.rooms[room.id] = { ...room, anchor: { x: room.anchor.x + dx, y: room.anchor.y + dy } };\n }\n return next;\n}\n\n/**\n * Multiplies every coordinate and dimension by `factor`.\n *\n * The one place a scale factor belongs: converting a unitless legacy plan into the\n * module's millimetre invariant, once, at the import boundary. The caller picks the\n * factor, because nothing in the old data says what it should be.\n */\nexport function scalePlan(floor: PlanFloor, factor: number): PlanFloor {\n const next = cloneFloor(floor);\n for (const node of Object.values(floor.nodes)) {\n next.nodes[node.id] = { ...node, x: node.x * factor, y: node.y * factor };\n }\n for (const wall of Object.values(floor.walls)) {\n next.walls[wall.id] = {\n ...wall,\n thickness: wall.thickness * factor,\n height: wall.height === undefined ? undefined : wall.height * factor,\n baseHeight: wall.baseHeight === undefined ? undefined : wall.baseHeight * factor,\n };\n }\n for (const opening of Object.values(floor.openings)) {\n next.openings[opening.id] = {\n ...opening,\n offset: opening.offset * factor,\n width: opening.width * factor,\n sill: opening.sill * factor,\n head: opening.head * factor,\n };\n }\n for (const room of Object.values(floor.rooms)) {\n next.rooms[room.id] = {\n ...room,\n anchor: { x: room.anchor.x * factor, y: room.anchor.y * factor },\n area: room.area * factor * factor,\n };\n }\n return next;\n}\n\n// ─── Openings ──────────────────────────────────────────────────────────────────\n\nexport function addOpening(\n floor: PlanFloor,\n opening: Omit<PlanOpening, 'id'>,\n): PlanEdit<{ openingId: string | null }> {\n const wall = floor.walls[opening.wallId];\n if (!wall) return { floor, result: { openingId: null }, issues: [] };\n\n const len = wallLength(floor, wall);\n const width = Math.min(opening.width, len - 2);\n if (width < MIN_OPENING_WIDTH) {\n return {\n floor,\n result: { openingId: null },\n issues: [\n issue(PlanIssueKind.OpeningDropped, 'That wall is too short for an opening.', {\n wallIds: [wall.id],\n }),\n ],\n };\n }\n\n const offset = Math.min(Math.max(opening.offset, width / 2), len - width / 2);\n const next = cloneFloor(floor);\n const id = newId('o');\n next.openings[id] = { ...opening, id, offset, width };\n return { floor: next, result: { openingId: id }, issues: [] };\n}\n\nexport function updateOpening(\n floor: PlanFloor,\n openingId: string,\n patch: Partial<Omit<PlanOpening, 'id' | 'wallId'>>,\n): PlanEdit {\n const opening = floor.openings[openingId];\n if (!opening) return { floor, result: undefined, issues: [] };\n const wall = floor.walls[opening.wallId];\n if (!wall) return { floor, result: undefined, issues: [] };\n\n const len = wallLength(floor, wall);\n const merged = { ...opening, ...patch };\n const width = Math.min(Math.max(merged.width, MIN_OPENING_WIDTH), Math.max(len - 2, MIN_OPENING_WIDTH));\n const offset = Math.min(Math.max(merged.offset, width / 2), Math.max(len - width / 2, width / 2));\n\n const next = cloneFloor(floor);\n next.openings[openingId] = { ...merged, width, offset };\n return { floor: next, result: undefined, issues: [] };\n}\n\nexport function removeOpening(floor: PlanFloor, openingId: string): PlanEdit {\n if (!floor.openings[openingId]) return { floor, result: undefined, issues: [] };\n const next = cloneFloor(floor);\n delete next.openings[openingId];\n return { floor: next, result: undefined, issues: [] };\n}\n\n// ─── Validation and cleanup ────────────────────────────────────────────────────\n\n/**\n * Reports every way the graph currently violates the planar invariant.\n *\n * O(W²), so run it in tests and in development, not on every keystroke.\n */\nexport function validatePlan(floor: PlanFloor): PlanIssue[] {\n const issues: PlanIssue[] = [];\n const walls = Object.values(floor.walls);\n\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (wall.a === wall.b) {\n issues.push(issue(PlanIssueKind.SelfLoopWall, 'A wall starts and ends at the same node.', { wallIds: [wall.id] }));\n continue;\n }\n if (!a || !b) {\n issues.push(issue(PlanIssueKind.ZeroLengthWall, 'A wall references a missing node.', { wallIds: [wall.id] }));\n continue;\n }\n if (dist(a, b) < MIN_WALL_LENGTH) {\n issues.push(issue(PlanIssueKind.ZeroLengthWall, 'A wall is shorter than the minimum length.', { wallIds: [wall.id] }));\n }\n }\n\n const pairSeen = new Map<string, string>();\n for (const wall of walls) {\n const key = wall.a < wall.b ? `${wall.a}|${wall.b}` : `${wall.b}|${wall.a}`;\n const prior = pairSeen.get(key);\n if (prior) {\n issues.push(\n issue(PlanIssueKind.DuplicateWall, 'Two walls connect the same pair of nodes.', {\n wallIds: [prior, wall.id],\n }),\n );\n } else {\n pairSeen.set(key, wall.id);\n }\n }\n\n const nodes = Object.values(floor.nodes);\n for (let i = 0; i < nodes.length; i++) {\n for (let j = i + 1; j < nodes.length; j++) {\n if (dist(nodes[i], nodes[j]) < EPS_COINCIDENT) {\n issues.push(\n issue(PlanIssueKind.CoincidentNodes, 'Two nodes occupy the same position.', {\n nodeIds: [nodes[i].id, nodes[j].id],\n }),\n );\n }\n }\n }\n\n for (let i = 0; i < walls.length; i++) {\n for (let j = i + 1; j < walls.length; j++) {\n const w1 = walls[i];\n const w2 = walls[j];\n const a = floor.nodes[w1.a];\n const b = floor.nodes[w1.b];\n const c = floor.nodes[w2.a];\n const d = floor.nodes[w2.b];\n if (!a || !b || !c || !d) continue;\n const hit = segmentIntersection(a, b, c, d);\n if (hit.kind === 'proper') {\n issues.push(\n issue(PlanIssueKind.UnsplitCrossing, 'Two walls cross with no node at the intersection.', {\n wallIds: [w1.id, w2.id],\n }),\n );\n } else if (hit.kind === 'collinearOverlap') {\n issues.push(\n issue(PlanIssueKind.OverlappingWalls, 'Two walls overlap along the same line.', {\n wallIds: [w1.id, w2.id],\n }),\n );\n }\n }\n }\n\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n for (const node of nodes) {\n if (node.id === wall.a || node.id === wall.b) continue;\n const r = pointToSegment(node, a, b);\n if (r.dist < EPS_COINCIDENT && r.t > 0 && r.t < 1) {\n issues.push(\n issue(PlanIssueKind.UnsplitNodeOnWall, 'A node sits on a wall that was never split there.', {\n wallIds: [wall.id],\n nodeIds: [node.id],\n }),\n );\n }\n }\n }\n\n for (const opening of Object.values(floor.openings)) {\n if (!floor.walls[opening.wallId]) {\n issues.push(\n issue(PlanIssueKind.DanglingOpening, 'An opening references a wall that no longer exists.', {\n openingIds: [opening.id],\n }),\n );\n }\n }\n\n const referenced = new Set<string>();\n for (const wall of walls) {\n referenced.add(wall.a);\n referenced.add(wall.b);\n }\n for (const node of nodes) {\n if (!referenced.has(node.id)) {\n issues.push(issue(PlanIssueKind.OrphanNode, 'A node has no walls.', { nodeIds: [node.id] }));\n }\n }\n\n return issues;\n}\n\n/**\n * Removes what validation can safely remove: degenerate walls, orphan nodes, dangling\n * openings, and duplicate walls. Idempotent.\n *\n * Deliberately does not touch unsplit crossings: fixing one changes the room structure,\n * which is the user's call, not a cleanup pass's.\n */\nexport function cleanupPlan(floor: PlanFloor): PlanEdit<PlanIssue[]> {\n const fixed: PlanIssue[] = [];\n\n // Welding comes first, and is why the sweep below only ever sees walls that are\n // degenerate for some other reason: a wall squashed to nothing has two perfectly good\n // ends, and deleting it would leave them stacked on the same point.\n const welded = weldShortWalls(floor);\n const next = cloneFloor(welded.floor);\n for (const wallId of welded.result.weldedWallIds) {\n fixed.push(\n issue(PlanIssueKind.ZeroLengthWall, 'Welded the two ends of a wall with no length.', {\n wallIds: [wallId],\n }),\n );\n }\n\n for (const wall of Object.values(next.walls)) {\n const a = next.nodes[wall.a];\n const b = next.nodes[wall.b];\n if (wall.a === wall.b || !a || !b || dist(a, b) < MIN_WALL_LENGTH) {\n delete next.walls[wall.id];\n fixed.push(issue(PlanIssueKind.ZeroLengthWall, 'Removed a degenerate wall.', { wallIds: [wall.id] }));\n }\n }\n\n const pairSeen = new Map<string, PlanWall>();\n for (const wall of Object.values(next.walls)) {\n const key = wall.a < wall.b ? `${wall.a}|${wall.b}` : `${wall.b}|${wall.a}`;\n const prior = pairSeen.get(key);\n if (!prior) {\n pairSeen.set(key, wall);\n continue;\n }\n const keep = wall.thickness >= prior.thickness ? wall : prior;\n const drop = keep === wall ? prior : wall;\n for (const opening of Object.values(next.openings)) {\n if (opening.wallId === drop.id) next.openings[opening.id] = { ...opening, wallId: keep.id };\n }\n delete next.walls[drop.id];\n pairSeen.set(key, keep);\n fixed.push(issue(PlanIssueKind.DuplicateWall, 'Removed a duplicate wall.', { wallIds: [drop.id] }));\n }\n\n for (const opening of Object.values(next.openings)) {\n if (!next.walls[opening.wallId]) {\n delete next.openings[opening.id];\n fixed.push(\n issue(PlanIssueKind.DanglingOpening, 'Removed an opening with no wall.', {\n openingIds: [opening.id],\n }),\n );\n }\n }\n\n // One pass to count degrees, rather than scanning every wall per node: the naive form\n // is O(nodes x walls), which is the dominant cost on a large plan.\n const referenced = new Set<string>();\n for (const wall of Object.values(next.walls)) {\n referenced.add(wall.a);\n referenced.add(wall.b);\n }\n for (const node of Object.values(next.nodes)) {\n if (!referenced.has(node.id)) {\n delete next.nodes[node.id];\n fixed.push(issue(PlanIssueKind.OrphanNode, 'Removed a node with no walls.', { nodeIds: [node.id] }));\n }\n }\n\n return { floor: next, result: fixed, issues: fixed };\n}\n\nexport { wallLength, wallsAtNode, findWallBetween };\n"],"mappings":"kMAoCA,IAAI,EAAQ,EAOZ,SAAgB,EAAM,EAAwB,CAM5C,MALA,IAAS,EAKF,GAAG,EAAO,GAHf,OAAO,OAAW,KAAe,OAAO,OAAO,YAAe,WAC1D,OAAO,WAAW,EAAE,MAAM,EAAG,CAAC,EAC9B,KAAK,OAAO,EAAE,SAAS,EA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KAAQ,OAAO,OAAO,EAAK,KAAK,EACzC,EAAW,IAAI,EAAK,CAAC,EACrB,EAAW,IAAI,EAAK,CAAC,EAEvB,IAAK,IAAM,KAAQ,OAAO,OAAO,EAAK,KAAK,EACpC,EAAW,IAAI,EAAK,EAAE,IACzB,OAAO,EAAK,MAAM,EAAK,IACvB,EAAM,KAAK,EAAM,EAAc,WAAY,gCAAiC,CAAE,QAAS,CAAC,EAAK,EAAE,CAAE,CAAC,CAAC,GAIvG,MAAO,CAAE,MAAO,EAAM,OAAQ,EAAO,OAAQ,CAAM,CACrD"}
|
|
1
|
+
{"version":3,"file":"floorPlan.graph.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.graph.ts"],"sourcesContent":["/**\n * Graph maintenance: the operations that keep the wall graph a valid planar embedding\n * while the user draws.\n *\n * The invariant every function here protects: no two walls may cross without a node at\n * the intersection, and no node may lie on a wall's interior without that wall being\n * split there. Break either and the face walk silently merges two rooms into one\n * figure-eight face, with no error anywhere.\n *\n * Every operation is pure and returns a new floor, for direct use as React state.\n */\n\nimport {\n EPS_ANGLE,\n EPS_COINCIDENT,\n MIN_OPENING_WIDTH,\n MIN_WALL_LENGTH,\n cross,\n dist,\n pointToSegment,\n projectOnSegment,\n segmentIntersection,\n} from './floorPlan.geometry';\nimport { PlanIssueKind, WallType } from './floorPlan.types';\nimport type { PlanEdit, PlanFloor, PlanIssue, PlanNode, PlanOpening, PlanPoint, PlanWall } from './floorPlan.types';\n\n// ─── Ids ───────────────────────────────────────────────────────────────────────\n\nlet idSeq = 0;\n\n/**\n * Ids are deliberately non-numeric strings, so `Record` iteration keeps insertion\n * order (JavaScript reorders integer-like keys), which is what makes derivation\n * reproducible.\n */\nexport function newId(prefix: string): string {\n idSeq += 1;\n const rand =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'\n ? crypto.randomUUID().slice(0, 8)\n : Math.random().toString(36).slice(2, 10);\n return `${prefix}_${rand}${idSeq.toString(36)}`;\n}\n\n/** Test-only: makes generated ids reproducible within a single test. */\nexport function __resetIdSeq(): void {\n idSeq = 0;\n}\n\n// ─── Internals ─────────────────────────────────────────────────────────────────\n\nfunction cloneFloor(floor: PlanFloor): PlanFloor {\n return {\n ...floor,\n nodes: { ...floor.nodes },\n walls: { ...floor.walls },\n openings: { ...floor.openings },\n rooms: { ...floor.rooms },\n };\n}\n\nfunction issue(kind: PlanIssueKind, message: string, extra: Partial<PlanIssue> = {}): PlanIssue {\n return { kind, message, ...extra };\n}\n\nfunction wallLength(floor: PlanFloor, wall: PlanWall): number {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) return 0;\n return dist(a, b);\n}\n\nfunction wallsAtNode(floor: PlanFloor, nodeId: string): PlanWall[] {\n return Object.values(floor.walls).filter((w) => w.a === nodeId || w.b === nodeId);\n}\n\nfunction findWallBetween(floor: PlanFloor, a: string, b: string): PlanWall | null {\n for (const w of Object.values(floor.walls)) {\n if ((w.a === a && w.b === b) || (w.a === b && w.b === a)) return w;\n }\n return null;\n}\n\n// ─── Node spatial hash ─────────────────────────────────────────────────────────\n\n/**\n * Bucket size for the node hash, in millimetres. Any lookup checks the 3x3\n * neighbourhood, so this only has to exceed the largest snap tolerance in world units.\n */\nconst HASH_CELL = 250;\n\nfunction hashKey(x: number, y: number): string {\n return `${Math.round(x / HASH_CELL)}|${Math.round(y / HASH_CELL)}`;\n}\n\nfunction buildNodeHash(floor: PlanFloor): Map<string, PlanNode[]> {\n const map = new Map<string, PlanNode[]>();\n for (const node of Object.values(floor.nodes)) {\n const key = hashKey(node.x, node.y);\n const list = map.get(key);\n if (list) list.push(node);\n else map.set(key, [node]);\n }\n return map;\n}\n\n/** Nearest existing node within `tol`, using the spatial hash. */\nexport function findNodeNear(floor: PlanFloor, p: PlanPoint, tol: number): PlanNode | null {\n const hash = buildNodeHash(floor);\n const cx = Math.round(p.x / HASH_CELL);\n const cy = Math.round(p.y / HASH_CELL);\n let best: PlanNode | null = null;\n let bestDist = tol;\n const span = Math.max(1, Math.ceil(tol / HASH_CELL));\n for (let dx = -span; dx <= span; dx++) {\n for (let dy = -span; dy <= span; dy++) {\n for (const node of hash.get(`${cx + dx}|${cy + dy}`) ?? []) {\n const d = dist(p, node);\n if (d <= bestDist) {\n best = node;\n bestDist = d;\n }\n }\n }\n }\n return best;\n}\n\n/** Nearest wall whose centreline passes within `tol` of `p`. */\nexport function findWallNear(\n floor: PlanFloor,\n p: PlanPoint,\n tol: number,\n exclude?: ReadonlySet<string>,\n): { wall: PlanWall; t: number; point: PlanPoint; dist: number } | null {\n let best: { wall: PlanWall; t: number; point: PlanPoint; dist: number } | null = null;\n for (const wall of Object.values(floor.walls)) {\n if (exclude?.has(wall.id)) continue;\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const r = pointToSegment(p, a, b);\n if (r.dist <= tol && (!best || r.dist < best.dist)) {\n best = { wall, t: r.t, point: r.point, dist: r.dist };\n }\n }\n return best;\n}\n\n// ─── splitWall ─────────────────────────────────────────────────────────────────\n\nexport interface SplitWallResult {\n nodeId: string;\n wallIds: [string, string] | null;\n droppedOpeningIds: string[];\n}\n\n/**\n * Splits a wall at a point or parameter, returning the node at the cut.\n *\n * Refuses to cut within `MIN_WALL_LENGTH` of either end, returning that endpoint's\n * existing node instead. That single rule is what keeps zero-length walls out of the\n * graph entirely, which in turn is what stops the angular sort from being fed a\n * direction-less dart.\n */\nexport function splitWall(floor: PlanFloor, wallId: string, at: PlanPoint | number): PlanEdit<SplitWallResult> {\n const wall = floor.walls[wallId];\n if (!wall) {\n return { floor, result: { nodeId: '', wallIds: null, droppedOpeningIds: [] }, issues: [] };\n }\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) {\n return { floor, result: { nodeId: '', wallIds: null, droppedOpeningIds: [] }, issues: [] };\n }\n\n const len = dist(a, b);\n const point = typeof at === 'number' ? { x: a.x + (b.x - a.x) * at, y: a.y + (b.y - a.y) * at } : at;\n // Project exactly, so the two children stay perfectly collinear and dissolveNode can\n // undo the split cleanly later.\n const exact = projectOnSegment(point, a, b);\n const fromA = dist(a, exact);\n\n if (fromA < MIN_WALL_LENGTH) {\n return { floor, result: { nodeId: wall.a, wallIds: null, droppedOpeningIds: [] }, issues: [] };\n }\n if (len - fromA < MIN_WALL_LENGTH) {\n return { floor, result: { nodeId: wall.b, wallIds: null, droppedOpeningIds: [] }, issues: [] };\n }\n\n const next = cloneFloor(floor);\n const nodeId = newId('n');\n next.nodes[nodeId] = { id: nodeId, x: exact.x, y: exact.y };\n\n const firstId = newId('w');\n const secondId = newId('w');\n const base = { thickness: wall.thickness, type: wall.type, height: wall.height, baseHeight: wall.baseHeight };\n next.walls[firstId] = { ...base, id: firstId, a: wall.a, b: nodeId };\n next.walls[secondId] = { ...base, id: secondId, a: nodeId, b: wall.b };\n delete next.walls[wallId];\n\n // Reassign openings by the side their CENTRE falls on. An opening straddling the cut\n // is a genuine conflict: move it wholly into that child and clamp it, or drop it and\n // say so. Silently deleting a window is not acceptable.\n const droppedOpeningIds: string[] = [];\n const issues: PlanIssue[] = [];\n for (const opening of Object.values(floor.openings)) {\n if (opening.wallId !== wallId) continue;\n const intoFirst = opening.offset <= fromA;\n const childId = intoFirst ? firstId : secondId;\n const childLen = intoFirst ? fromA : len - fromA;\n const offset = intoFirst ? opening.offset : opening.offset - fromA;\n\n const maxWidth = Math.min(opening.width, childLen - 2, offset * 2, (childLen - offset) * 2);\n if (maxWidth < MIN_OPENING_WIDTH) {\n delete next.openings[opening.id];\n droppedOpeningIds.push(opening.id);\n issues.push(\n issue(PlanIssueKind.OpeningDropped, 'An opening was removed: the wall it sat on became too short for it.', {\n openingIds: [opening.id],\n wallIds: [wallId],\n }),\n );\n continue;\n }\n next.openings[opening.id] = { ...opening, wallId: childId, offset, width: maxWidth };\n }\n\n return { floor: next, result: { nodeId, wallIds: [firstId, secondId], droppedOpeningIds }, issues };\n}\n\n// ─── resolveNodeAt ─────────────────────────────────────────────────────────────\n\nexport interface ResolveNodeResult {\n nodeId: string;\n createdNode: boolean;\n splitWallId: string | null;\n}\n\n/**\n * Returns the node to use at `p`: an existing one within `tol`, a new one created by\n * splitting a wall that passes under `p`, or a brand new free-standing node.\n */\nexport function resolveNodeAt(floor: PlanFloor, p: PlanPoint, tol: number): PlanEdit<ResolveNodeResult> {\n const existing = findNodeNear(floor, p, tol);\n if (existing) {\n return { floor, result: { nodeId: existing.id, createdNode: false, splitWallId: null }, issues: [] };\n }\n\n const onWall = findWallNear(floor, p, tol);\n if (onWall) {\n const split = splitWall(floor, onWall.wall.id, onWall.point);\n if (split.result.nodeId) {\n return {\n floor: split.floor,\n result: {\n nodeId: split.result.nodeId,\n createdNode: split.result.wallIds !== null,\n splitWallId: split.result.wallIds ? onWall.wall.id : null,\n },\n issues: split.issues,\n };\n }\n }\n\n const next = cloneFloor(floor);\n const nodeId = newId('n');\n next.nodes[nodeId] = { id: nodeId, x: p.x, y: p.y };\n return { floor: next, result: { nodeId, createdNode: true, splitWallId: null }, issues: [] };\n}\n\n// ─── addWall ───────────────────────────────────────────────────────────────────\n\nexport type WallAttrs = Pick<PlanWall, 'thickness' | 'type'> & Partial<Pick<PlanWall, 'height' | 'baseHeight'>>;\n\nexport const DEFAULT_WALL_ATTRS: WallAttrs = { thickness: 200, type: WallType.Interior };\n\ninterface Cut {\n t: number;\n nodeId: string | null;\n /** Set while the node does not exist yet because its wall has not been split. */\n pending?: { wallId: string; s: number };\n}\n\n/**\n * Adds a wall from `a` to `b`, splitting anything it crosses so the graph stays planar.\n *\n * Collect-then-apply, in two phases: the naive version splits walls while iterating\n * over walls, which both invalidates the iteration and reparameterises the very\n * segments it is about to test.\n */\nexport function addWall(\n floor: PlanFloor,\n a: PlanPoint,\n b: PlanPoint,\n attrs: WallAttrs = DEFAULT_WALL_ATTRS,\n tol: number = EPS_COINCIDENT,\n): PlanEdit<{ wallIds: string[]; nodeIds: string[] }> {\n const issues: PlanIssue[] = [];\n if (dist(a, b) < MIN_WALL_LENGTH) {\n return { floor, result: { wallIds: [], nodeIds: [] }, issues };\n }\n\n // 1. Endpoints. Each may reuse a node, split a wall, or create a node.\n const startEdit = resolveNodeAt(floor, a, tol);\n let work = startEdit.floor;\n issues.push(...startEdit.issues);\n const endEdit = resolveNodeAt(work, b, tol);\n work = endEdit.floor;\n issues.push(...endEdit.issues);\n\n const na = startEdit.result.nodeId;\n const nb = endEdit.result.nodeId;\n if (na === nb) return { floor, result: { wallIds: [], nodeIds: [] }, issues };\n\n const A = work.nodes[na];\n const B = work.nodes[nb];\n const len = dist(A, B);\n if (len < MIN_WALL_LENGTH) return { floor, result: { wallIds: [], nodeIds: [] }, issues };\n\n // 2. COLLECT. Nothing is mutated in this phase.\n const cuts: Cut[] = [\n { t: 0, nodeId: na },\n { t: 1, nodeId: nb },\n ];\n const splits = new Map<string, number[]>();\n const overlaps: Array<[number, number]> = [];\n\n const paramAlong = (p: PlanPoint): number => pointToSegment(p, A, B).t;\n\n for (const wall of Object.values(work.walls)) {\n const wa = work.nodes[wall.a];\n const wb = work.nodes[wall.b];\n if (!wa || !wb) continue;\n\n const hit = segmentIntersection(A, B, wa, wb, tol);\n\n if (hit.kind === 'collinearOverlap') {\n const t0 = paramAlong(wa);\n const t1 = paramAlong(wb);\n overlaps.push([Math.min(t0, t1), Math.max(t0, t1)]);\n // Endpoints of the overlapping wall that fall strictly inside AB still need cuts,\n // or the new wall would run straight past them.\n for (const [node, t] of [\n [wa, t0],\n [wb, t1],\n ] as const) {\n if (t * len > MIN_WALL_LENGTH && (1 - t) * len > MIN_WALL_LENGTH) {\n cuts.push({ t, nodeId: node.id });\n }\n }\n continue;\n }\n\n if (hit.kind === 'proper' && hit.t !== undefined && hit.s !== undefined) {\n const list = splits.get(wall.id);\n if (list) list.push(hit.s);\n else splits.set(wall.id, [hit.s]);\n cuts.push({ t: hit.t, nodeId: null, pending: { wallId: wall.id, s: hit.s } });\n continue;\n }\n\n if (hit.kind === 'touch' && hit.t !== undefined && hit.s !== undefined) {\n // A T junction where one of the wall's own endpoints sits on AB: reuse it.\n const atWallStart = hit.s <= 0.5;\n const endpoint = atWallStart ? wa : wb;\n const tOnAb = paramAlong(endpoint);\n if (\n pointToSegment(endpoint, A, B).dist <= tol &&\n tOnAb * len > MIN_WALL_LENGTH &&\n (1 - tOnAb) * len > MIN_WALL_LENGTH\n ) {\n cuts.push({ t: tOnAb, nodeId: endpoint.id });\n }\n }\n }\n\n // 3. Nodes lying on AB that no crossing test found. NOT redundant with step 2: a node\n // whose incident walls all run away from AB is invisible to every crossing test, yet\n // failing to cut AB there leaves a node on a wall interior, which silently merges the\n // two rooms either side of it.\n for (const node of Object.values(work.nodes)) {\n if (node.id === na || node.id === nb) continue;\n const r = pointToSegment(node, A, B);\n if (r.dist > tol) continue;\n if (r.t * len <= MIN_WALL_LENGTH || (1 - r.t) * len <= MIN_WALL_LENGTH) continue;\n cuts.push({ t: r.t, nodeId: node.id });\n }\n\n // 4. APPLY splits, per wall, in DESCENDING parameter order so that earlier\n // parameters stay valid as later ones are consumed.\n for (const [wallId, params] of splits) {\n const sorted = [...params].sort((x, y) => y - x);\n let currentWallId = wallId;\n const remaining = new Set(sorted);\n for (const s of sorted) {\n const target = work.walls[currentWallId];\n if (!target) break;\n const wa = work.nodes[target.a];\n const wb = work.nodes[target.b];\n if (!wa || !wb) break;\n // Re-project onto the wall as it stands now, rather than reusing the original\n // parameter, which the previous split may have reparameterised.\n const original = floor.walls[wallId];\n const oa = work.nodes[original?.a ?? target.a] ?? wa;\n const ob = work.nodes[original?.b ?? target.b] ?? wb;\n const worldPoint = { x: oa.x + (ob.x - oa.x) * s, y: oa.y + (ob.y - oa.y) * s };\n const edit = splitWall(work, currentWallId, worldPoint);\n work = edit.floor;\n issues.push(...edit.issues);\n remaining.delete(s);\n for (const cut of cuts) {\n if (cut.pending && cut.pending.wallId === wallId && cut.pending.s === s) {\n cut.nodeId = edit.result.nodeId;\n cut.pending = undefined;\n }\n }\n // Continue splitting whichever child still holds the remaining parameters.\n if (edit.result.wallIds) {\n const [first, second] = edit.result.wallIds;\n const nextS = Math.max(...[...remaining], -1);\n currentWallId = nextS >= 0 && nextS > s ? second : first;\n }\n }\n }\n\n // 5. Chain the cuts into walls.\n const resolved = cuts.filter((c): c is Cut & { nodeId: string } => Boolean(c.nodeId));\n resolved.sort((x, y) => x.t - y.t);\n\n const chain: Array<Cut & { nodeId: string }> = [];\n for (const cut of resolved) {\n const last = chain[chain.length - 1];\n if (!last) {\n chain.push(cut);\n continue;\n }\n if (last.nodeId === cut.nodeId) continue;\n if ((cut.t - last.t) * len < MIN_WALL_LENGTH) {\n // Too close to be a separate wall. Prefer whichever end is an endpoint of AB.\n if (cut.t >= 1 - 1e-9) chain[chain.length - 1] = cut;\n continue;\n }\n chain.push(cut);\n }\n\n const createdWallIds: string[] = [];\n for (let i = 0; i + 1 < chain.length; i++) {\n const from = chain[i];\n const to = chain[i + 1];\n const midT = (from.t + to.t) / 2;\n if (overlaps.some(([lo, hi]) => midT > lo + 1e-9 && midT < hi - 1e-9)) {\n // Already walled. Do not create a duplicate, and do not rewrite the existing\n // wall's attributes from a stroke that was aimed elsewhere.\n continue;\n }\n if (findWallBetween(work, from.nodeId, to.nodeId)) continue;\n const wa = work.nodes[from.nodeId];\n const wb = work.nodes[to.nodeId];\n if (!wa || !wb || dist(wa, wb) < MIN_WALL_LENGTH) continue;\n\n const id = newId('w');\n work = { ...work, walls: { ...work.walls, [id]: { ...attrs, id, a: from.nodeId, b: to.nodeId } } };\n createdWallIds.push(id);\n }\n\n if (createdWallIds.length === 0 && overlaps.length > 0) {\n issues.push(issue(PlanIssueKind.DuplicateWall, 'A wall already covers that span, so nothing was added.'));\n }\n\n return {\n floor: work,\n result: { wallIds: createdWallIds, nodeIds: chain.map((c) => c.nodeId) },\n issues,\n };\n}\n\n/** Draws the four walls of an axis-aligned rectangle, welding onto anything already there. */\nexport function addRect(\n floor: PlanFloor,\n corner: PlanPoint,\n opposite: PlanPoint,\n attrs: WallAttrs = DEFAULT_WALL_ATTRS,\n tol: number = EPS_COINCIDENT,\n): PlanEdit<{ wallIds: string[] }> {\n const x0 = Math.min(corner.x, opposite.x);\n const x1 = Math.max(corner.x, opposite.x);\n const y0 = Math.min(corner.y, opposite.y);\n const y1 = Math.max(corner.y, opposite.y);\n if (x1 - x0 < MIN_WALL_LENGTH || y1 - y0 < MIN_WALL_LENGTH) {\n return { floor, result: { wallIds: [] }, issues: [] };\n }\n\n const corners: PlanPoint[] = [\n { x: x0, y: y0 },\n { x: x1, y: y0 },\n { x: x1, y: y1 },\n { x: x0, y: y1 },\n ];\n\n let work = floor;\n const wallIds: string[] = [];\n const issues: PlanIssue[] = [];\n for (let i = 0; i < 4; i++) {\n const edit = addWall(work, corners[i], corners[(i + 1) % 4], attrs, tol);\n work = edit.floor;\n wallIds.push(...edit.result.wallIds);\n issues.push(...edit.issues);\n }\n return { floor: work, result: { wallIds }, issues };\n}\n\n// ─── mergeNodes ────────────────────────────────────────────────────────────────\n\n/**\n * Merges `removeId` into `keepId`, as when a node is dragged onto another.\n *\n * Order matters, and step 3 is mandatory rather than cosmetic: a duplicate wall between\n * the same pair of nodes is exactly the identical-angle degeneracy that corrupts the\n * face walk's angular sort.\n */\nexport function mergeNodes(floor: PlanFloor, keepId: string, removeId: string): PlanEdit<{ removedWallIds: string[] }> {\n if (keepId === removeId || !floor.nodes[keepId] || !floor.nodes[removeId]) {\n return { floor, result: { removedWallIds: [] }, issues: [] };\n }\n\n const next = cloneFloor(floor);\n const removedWallIds: string[] = [];\n const issues: PlanIssue[] = [];\n\n // 1. Rewire.\n for (const wall of Object.values(next.walls)) {\n if (wall.a === removeId) next.walls[wall.id] = { ...next.walls[wall.id], a: keepId };\n if (wall.b === removeId) next.walls[wall.id] = { ...next.walls[wall.id], b: keepId };\n }\n\n // 2. Drop self-loops, and their openings with them.\n for (const wall of Object.values(next.walls)) {\n if (wall.a !== wall.b) continue;\n delete next.walls[wall.id];\n removedWallIds.push(wall.id);\n for (const opening of Object.values(next.openings)) {\n if (opening.wallId === wall.id) delete next.openings[opening.id];\n }\n }\n\n // 3. Deduplicate walls that now share the same unordered node pair.\n const seen = new Map<string, PlanWall>();\n for (const wall of Object.values(next.walls)) {\n const key = wall.a < wall.b ? `${wall.a}|${wall.b}` : `${wall.b}|${wall.a}`;\n const prior = seen.get(key);\n if (!prior) {\n seen.set(key, wall);\n continue;\n }\n // Keep the thicker wall, and carry both walls' openings onto it.\n const keep = wall.thickness >= prior.thickness ? wall : prior;\n const drop = keep === wall ? prior : wall;\n for (const opening of Object.values(next.openings)) {\n if (opening.wallId === drop.id) {\n next.openings[opening.id] = { ...opening, wallId: keep.id };\n }\n }\n delete next.walls[drop.id];\n removedWallIds.push(drop.id);\n seen.set(key, keep);\n issues.push(\n issue(PlanIssueKind.DuplicateWall, 'Two walls became the same wall and were merged.', {\n wallIds: [keep.id, drop.id],\n }),\n );\n }\n\n // 4. Drop the now-unreferenced node.\n delete next.nodes[removeId];\n\n return { floor: next, result: { removedWallIds }, issues };\n}\n\n// ─── dissolveNode ──────────────────────────────────────────────────────────────\n\nexport interface DissolveNodeOptions {\n /**\n * Rejoin the two walls even when the corner is bent or the walls differ in\n * construction, taking the thicker wall's attributes and rescaling openings onto the\n * shorter merged wall.\n *\n * This is \"delete this corner\" as a user means it. The default, unforced behaviour is\n * the stricter one used by cleanup and by `removeWall`, where dissolving must not\n * change the drawing's geometry at all.\n */\n force?: boolean;\n}\n\n/**\n * Merges the two walls meeting at a degree-2 node back into one, the natural inverse of\n * `splitWall`.\n *\n * Returns `null` unless the node is genuinely a seam: degree exactly 2, both walls\n * identical in construction, and the turn within `EPS_ANGLE` of straight. Pass\n * `{ force: true }` to rejoin a bent corner as well. Never call it mid-drag: it destroys\n * node ids the user may be holding.\n */\nexport function dissolveNode(\n floor: PlanFloor,\n nodeId: string,\n options: DissolveNodeOptions = {},\n): PlanEdit<{ wallId: string } | null> {\n const { force = false } = options;\n const node = floor.nodes[nodeId];\n if (!node) return { floor, result: null, issues: [] };\n\n const incident = wallsAtNode(floor, nodeId);\n if (incident.length !== 2) return { floor, result: null, issues: [] };\n\n const [w1, w2] = incident;\n const sameConstruction =\n w1.thickness === w2.thickness && w1.type === w2.type && w1.height === w2.height && w1.baseHeight === w2.baseHeight;\n if (!sameConstruction && !force) return { floor, result: null, issues: [] };\n\n const far1 = w1.a === nodeId ? w1.b : w1.a;\n const far2 = w2.a === nodeId ? w2.b : w2.a;\n if (far1 === far2) return { floor, result: null, issues: [] };\n\n const p1 = floor.nodes[far1];\n const p2 = floor.nodes[far2];\n if (!p1 || !p2) return { floor, result: null, issues: [] };\n\n const span = dist(p1, p2);\n if (span < MIN_WALL_LENGTH) return { floor, result: null, issues: [] };\n\n if (!force) {\n // Straightness by perpendicular offset rather than raw angle, so the tolerance stays\n // meaningful at any wall length.\n const offset = Math.abs(cross(p1, p2, node)) / span;\n if (offset > Math.max(EPS_COINCIDENT, span * EPS_ANGLE)) {\n return { floor, result: null, issues: [] };\n }\n }\n\n // Forced over a bent corner, the survivor is the thicker of the two, since that is the\n // one whose construction the rest of the plan is more likely to depend on.\n const keep = !sameConstruction && w1.thickness < w2.thickness ? w2 : w1;\n\n const next = cloneFloor(floor);\n const id = newId('w');\n next.walls[id] = {\n id,\n a: far1,\n b: far2,\n thickness: keep.thickness,\n type: keep.type,\n height: keep.height,\n baseHeight: keep.baseHeight,\n };\n\n // Re-express every opening's offset against the merged wall's direction (far1 -> far2).\n const len1 = dist(p1, node);\n const len2 = dist(node, p2);\n // Cutting a bent corner shortens the run, so positions are scaled along it rather than\n // carried over, which would push an opening off the end of its own wall.\n const scale = len1 + len2 > 0 ? span / (len1 + len2) : 1;\n const issues: PlanIssue[] = [];\n\n for (const opening of Object.values(floor.openings)) {\n if (opening.wallId !== w1.id && opening.wallId !== w2.id) continue;\n const onFirst = opening.wallId === w1.id;\n const wall = onFirst ? w1 : w2;\n const startsAtNode = wall.a === nodeId;\n const lenOfWall = wallLength(floor, wall);\n // Distance from the seam, then from the merged wall's own start.\n const fromSeam = startsAtNode ? opening.offset : lenOfWall - opening.offset;\n const alongOriginal = onFirst ? len1 - fromSeam : len1 + fromSeam;\n const offsetOnMerged = alongOriginal * scale;\n\n const width = Math.min(opening.width * scale, span - 2);\n if (width < MIN_OPENING_WIDTH) {\n issues.push(\n issue(PlanIssueKind.OpeningDropped, 'An opening was removed: the wall it sat on became too short for it.', {\n openingIds: [opening.id],\n wallIds: [wall.id],\n }),\n );\n delete next.openings[opening.id];\n continue;\n }\n\n next.openings[opening.id] = {\n ...opening,\n wallId: id,\n width,\n offset: Math.min(Math.max(offsetOnMerged, width / 2), span - width / 2),\n };\n }\n\n delete next.walls[w1.id];\n delete next.walls[w2.id];\n delete next.nodes[nodeId];\n\n return { floor: next, result: { wallId: id }, issues };\n}\n\n// ─── detachWall ────────────────────────────────────────────────────────────────\n\nexport interface DetachWallResult {\n /** The wall's end nodes after the detach, in `[a, b]` order. */\n nodeIds: [string, string];\n /** Connecting walls minted where an end was shared with a neighbour. */\n connectorIds: string[];\n /** Ends that became a straight seam once the wall left, and were dissolved away. */\n dissolvedNodeIds: string[];\n}\n\n/**\n * Pulls a wall off the nodes it shares with its neighbours and moves it by `delta`,\n * leaving a connecting wall behind at each end that was shared.\n *\n * This is the extrude half of dragging a wall. A plain drag moves the shared end nodes,\n * so everything meeting the wall follows it; here the neighbours keep their ends and\n * only the new connectors grow, which is what you want when a partition joins the wall\n * halfway along and should stay put.\n *\n * A free end is only moved: there is nothing there to detach from, and a connector would\n * be zero length. For the same reason `delta` must be at least `MIN_WALL_LENGTH` long —\n * below that the caller should `moveNode` both ends instead.\n *\n * The connector continues whatever was already at the corner (its thickness, type and\n * heights) when exactly one wall was, so pulling a wall off a plain corner redraws\n * exactly as a plain drag would: the seam that leaves behind is straight and is\n * dissolved before returning. At a junction there is no single wall to continue, so the\n * connector takes the dragged wall's own construction.\n */\nexport function detachWall(floor: PlanFloor, wallId: string, delta: PlanPoint): PlanEdit<DetachWallResult | null> {\n const wall = floor.walls[wallId];\n if (!wall || wall.a === wall.b) return { floor, result: null, issues: [] };\n if (Math.hypot(delta.x, delta.y) < MIN_WALL_LENGTH) return { floor, result: null, issues: [] };\n\n const ends: [string, string] = [wall.a, wall.b];\n const nodeIds: [string, string] = [wall.a, wall.b];\n const sources: (PlanWall | null)[] = [null, null];\n const connectorIds: string[] = [];\n const issues: PlanIssue[] = [];\n let out = floor;\n\n // 1. Give the wall its own ends. `resolveNodeAt` rather than a bare node, because the\n // new end often lands in the middle of another wall — the usual case is pushing the\n // shared wall of two rooms sideways, where each end slides along the wall above and\n // below it — and only a split keeps a node off a wall's interior.\n ends.forEach((nodeId, index) => {\n const origin = floor.nodes[nodeId];\n if (!origin) return;\n const to = { x: origin.x + delta.x, y: origin.y + delta.y };\n const others = wallsAtNode(floor, nodeId).filter((w) => w.id !== wallId);\n\n if (others.length === 0) {\n // A free end has nothing to detach from, and a connector there would be a wall\n // between a node and itself.\n const next = cloneFloor(out);\n next.nodes[nodeId] = { ...next.nodes[nodeId], x: to.x, y: to.y };\n out = next;\n return;\n }\n\n const edit = resolveNodeAt(out, to, EPS_COINCIDENT);\n out = edit.floor;\n nodeIds[index] = edit.result.nodeId;\n // The connector continues whatever was already at this corner, so pulling a wall off\n // a plain corner redraws exactly as a plain drag would. At a junction there is no\n // single wall to continue, so it takes the dragged wall's own construction.\n sources[index] = others.length === 1 ? others[0] : wall;\n });\n\n // 2. Move the wall onto them. Its openings ride along untouched: a detach is a pure\n // translation, so the wall keeps its id, its direction and its length.\n const moved = cloneFloor(out);\n moved.walls[wallId] = { ...moved.walls[wallId], a: nodeIds[0], b: nodeIds[1] };\n out = moved;\n\n // 3. Bridge each end back to where it came from, unless a wall already runs there.\n ends.forEach((nodeId, index) => {\n const source = sources[index];\n const from = out.nodes[nodeId];\n const to = out.nodes[nodeIds[index]];\n if (!source || !from || !to) return;\n const edit = addWall(out, from, to, {\n thickness: source.thickness,\n type: source.type,\n height: source.height,\n baseHeight: source.baseHeight,\n });\n out = edit.floor;\n connectorIds.push(...edit.result.wallIds);\n issues.push(...edit.issues);\n });\n\n // 4. An end that was a plain corner is now a straight seam. Dissolving it is what\n // makes detaching a wall with nothing attached to it a no-op on the drawing.\n const dissolvedNodeIds: string[] = [];\n ends.forEach((nodeId, index) => {\n if (nodeIds[index] === nodeId) return;\n const edit = dissolveNode(out, nodeId);\n if (!edit.result) return;\n out = edit.floor;\n dissolvedNodeIds.push(nodeId);\n issues.push(...edit.issues);\n });\n\n return { floor: out, result: { nodeIds, connectorIds, dissolvedNodeIds }, issues };\n}\n\n// ─── weldShortWalls ────────────────────────────────────────────────────────────\n\n/**\n * Collapses every wall shorter than `minLength` by merging its two ends together.\n *\n * Squashing a wall to nothing is the one thing a drag can do that the model forbids, and\n * it is easy to do by accident: pushing a wall back onto the line it was detached from,\n * or dragging a corner past the one next to it. Deleting the short wall is the wrong\n * repair — it leaves two nodes sitting on the same point with the plan split between\n * them, which reads as two corners stacked on top of each other and derives as two\n * rooms. Merging is lossless, since the two ends are within `minLength` of each other by\n * definition.\n *\n * The end with more walls on it survives, so the corner that was already there keeps its\n * position and the one that arrived is the one that gives way.\n */\nexport function weldShortWalls(\n floor: PlanFloor,\n minLength: number = MIN_WALL_LENGTH,\n): PlanEdit<{ weldedWallIds: string[] }> {\n let out = floor;\n const weldedWallIds: string[] = [];\n const issues: PlanIssue[] = [];\n\n // Re-scan rather than iterate: one weld moves nodes, so it can shorten another wall to\n // nothing in turn. Bounded by the wall count, since every pass removes at least one.\n for (let guard = Object.keys(floor.walls).length; guard > 0; guard--) {\n const short = Object.values(out.walls).find((w) => {\n if (w.a === w.b) return false;\n const a = out.nodes[w.a];\n const b = out.nodes[w.b];\n return a && b && dist(a, b) < minLength;\n });\n if (!short) break;\n\n const keep = wallsAtNode(out, short.b).length > wallsAtNode(out, short.a).length ? short.b : short.a;\n const edit = mergeNodes(out, keep, keep === short.a ? short.b : short.a);\n if (edit.floor === out) break;\n out = edit.floor;\n weldedWallIds.push(short.id);\n issues.push(...edit.issues);\n }\n\n return { floor: out, result: { weldedWallIds }, issues };\n}\n\n// ─── removeWall / moveNode ─────────────────────────────────────────────────────\n\nexport function removeWall(\n floor: PlanFloor,\n wallId: string,\n opts: { pruneOrphanNodes?: boolean; dissolveCollinear?: boolean } = {},\n): PlanEdit<{ removedNodeIds: string[]; dissolvedWallIds: string[] }> {\n const { pruneOrphanNodes = true, dissolveCollinear = true } = opts;\n const wall = floor.walls[wallId];\n if (!wall) return { floor, result: { removedNodeIds: [], dissolvedWallIds: [] }, issues: [] };\n\n let next = cloneFloor(floor);\n delete next.walls[wallId];\n for (const opening of Object.values(next.openings)) {\n if (opening.wallId === wallId) delete next.openings[opening.id];\n }\n\n const removedNodeIds: string[] = [];\n const dissolvedWallIds: string[] = [];\n const issues: PlanIssue[] = [];\n\n for (const endpoint of [wall.a, wall.b]) {\n const degree = wallsAtNode(next, endpoint).length;\n if (degree === 0 && pruneOrphanNodes) {\n delete next.nodes[endpoint];\n removedNodeIds.push(endpoint);\n } else if (degree === 2 && dissolveCollinear) {\n // The natural inverse of the split that created this seam.\n const edit = dissolveNode(next, endpoint);\n if (edit.result) {\n next = edit.floor;\n dissolvedWallIds.push(edit.result.wallId);\n removedNodeIds.push(endpoint);\n issues.push(...edit.issues);\n }\n }\n }\n\n return { floor: next, result: { removedNodeIds, dissolvedWallIds }, issues };\n}\n\nexport function moveNode(floor: PlanFloor, nodeId: string, to: PlanPoint): PlanEdit {\n const node = floor.nodes[nodeId];\n if (!node) return { floor, result: undefined, issues: [] };\n const next = cloneFloor(floor);\n next.nodes[nodeId] = { ...node, x: to.x, y: to.y };\n return { floor: next, result: undefined, issues: [] };\n}\n\n/**\n * Translates every node, and every room anchor with it.\n *\n * Room matching does not depend on this (it is primarily wall-id based), but a plan\n * that is dragged and then saved without a derive should still have sane anchors.\n */\nexport function transformPlan(floor: PlanFloor, dx: number, dy: number): PlanFloor {\n const next = cloneFloor(floor);\n for (const node of Object.values(floor.nodes)) {\n next.nodes[node.id] = { ...node, x: node.x + dx, y: node.y + dy };\n }\n for (const room of Object.values(floor.rooms)) {\n next.rooms[room.id] = { ...room, anchor: { x: room.anchor.x + dx, y: room.anchor.y + dy } };\n }\n return next;\n}\n\n/**\n * Multiplies every coordinate and dimension by `factor`.\n *\n * The one place a scale factor belongs: converting a unitless legacy plan into the\n * module's millimetre invariant, once, at the import boundary. The caller picks the\n * factor, because nothing in the old data says what it should be.\n */\nexport function scalePlan(floor: PlanFloor, factor: number): PlanFloor {\n const next = cloneFloor(floor);\n for (const node of Object.values(floor.nodes)) {\n next.nodes[node.id] = { ...node, x: node.x * factor, y: node.y * factor };\n }\n for (const wall of Object.values(floor.walls)) {\n next.walls[wall.id] = {\n ...wall,\n thickness: wall.thickness * factor,\n height: wall.height === undefined ? undefined : wall.height * factor,\n baseHeight: wall.baseHeight === undefined ? undefined : wall.baseHeight * factor,\n };\n }\n for (const opening of Object.values(floor.openings)) {\n next.openings[opening.id] = {\n ...opening,\n offset: opening.offset * factor,\n width: opening.width * factor,\n sill: opening.sill * factor,\n head: opening.head * factor,\n };\n }\n for (const room of Object.values(floor.rooms)) {\n next.rooms[room.id] = {\n ...room,\n anchor: { x: room.anchor.x * factor, y: room.anchor.y * factor },\n area: room.area * factor * factor,\n };\n }\n return next;\n}\n\n// ─── Openings ──────────────────────────────────────────────────────────────────\n\nexport function addOpening(floor: PlanFloor, opening: Omit<PlanOpening, 'id'>): PlanEdit<{ openingId: string | null }> {\n const wall = floor.walls[opening.wallId];\n if (!wall) return { floor, result: { openingId: null }, issues: [] };\n\n const len = wallLength(floor, wall);\n const width = Math.min(opening.width, len - 2);\n if (width < MIN_OPENING_WIDTH) {\n return {\n floor,\n result: { openingId: null },\n issues: [\n issue(PlanIssueKind.OpeningDropped, 'That wall is too short for an opening.', {\n wallIds: [wall.id],\n }),\n ],\n };\n }\n\n const offset = Math.min(Math.max(opening.offset, width / 2), len - width / 2);\n const next = cloneFloor(floor);\n const id = newId('o');\n next.openings[id] = { ...opening, id, offset, width };\n return { floor: next, result: { openingId: id }, issues: [] };\n}\n\nexport function updateOpening(\n floor: PlanFloor,\n openingId: string,\n patch: Partial<Omit<PlanOpening, 'id' | 'wallId'>>,\n): PlanEdit {\n const opening = floor.openings[openingId];\n if (!opening) return { floor, result: undefined, issues: [] };\n const wall = floor.walls[opening.wallId];\n if (!wall) return { floor, result: undefined, issues: [] };\n\n const len = wallLength(floor, wall);\n const merged = { ...opening, ...patch };\n const width = Math.min(Math.max(merged.width, MIN_OPENING_WIDTH), Math.max(len - 2, MIN_OPENING_WIDTH));\n const offset = Math.min(Math.max(merged.offset, width / 2), Math.max(len - width / 2, width / 2));\n\n const next = cloneFloor(floor);\n next.openings[openingId] = { ...merged, width, offset };\n return { floor: next, result: undefined, issues: [] };\n}\n\nexport function removeOpening(floor: PlanFloor, openingId: string): PlanEdit {\n if (!floor.openings[openingId]) return { floor, result: undefined, issues: [] };\n const next = cloneFloor(floor);\n delete next.openings[openingId];\n return { floor: next, result: undefined, issues: [] };\n}\n\n// ─── Validation and cleanup ────────────────────────────────────────────────────\n\n/**\n * Reports every way the graph currently violates the planar invariant.\n *\n * O(W²), so run it in tests and in development, not on every keystroke.\n */\nexport function validatePlan(floor: PlanFloor): PlanIssue[] {\n const issues: PlanIssue[] = [];\n const walls = Object.values(floor.walls);\n\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (wall.a === wall.b) {\n issues.push(\n issue(PlanIssueKind.SelfLoopWall, 'A wall starts and ends at the same node.', { wallIds: [wall.id] }),\n );\n continue;\n }\n if (!a || !b) {\n issues.push(issue(PlanIssueKind.ZeroLengthWall, 'A wall references a missing node.', { wallIds: [wall.id] }));\n continue;\n }\n if (dist(a, b) < MIN_WALL_LENGTH) {\n issues.push(\n issue(PlanIssueKind.ZeroLengthWall, 'A wall is shorter than the minimum length.', { wallIds: [wall.id] }),\n );\n }\n }\n\n const pairSeen = new Map<string, string>();\n for (const wall of walls) {\n const key = wall.a < wall.b ? `${wall.a}|${wall.b}` : `${wall.b}|${wall.a}`;\n const prior = pairSeen.get(key);\n if (prior) {\n issues.push(\n issue(PlanIssueKind.DuplicateWall, 'Two walls connect the same pair of nodes.', {\n wallIds: [prior, wall.id],\n }),\n );\n } else {\n pairSeen.set(key, wall.id);\n }\n }\n\n const nodes = Object.values(floor.nodes);\n for (let i = 0; i < nodes.length; i++) {\n for (let j = i + 1; j < nodes.length; j++) {\n if (dist(nodes[i], nodes[j]) < EPS_COINCIDENT) {\n issues.push(\n issue(PlanIssueKind.CoincidentNodes, 'Two nodes occupy the same position.', {\n nodeIds: [nodes[i].id, nodes[j].id],\n }),\n );\n }\n }\n }\n\n for (let i = 0; i < walls.length; i++) {\n for (let j = i + 1; j < walls.length; j++) {\n const w1 = walls[i];\n const w2 = walls[j];\n const a = floor.nodes[w1.a];\n const b = floor.nodes[w1.b];\n const c = floor.nodes[w2.a];\n const d = floor.nodes[w2.b];\n if (!a || !b || !c || !d) continue;\n const hit = segmentIntersection(a, b, c, d);\n if (hit.kind === 'proper') {\n issues.push(\n issue(PlanIssueKind.UnsplitCrossing, 'Two walls cross with no node at the intersection.', {\n wallIds: [w1.id, w2.id],\n }),\n );\n } else if (hit.kind === 'collinearOverlap') {\n issues.push(\n issue(PlanIssueKind.OverlappingWalls, 'Two walls overlap along the same line.', {\n wallIds: [w1.id, w2.id],\n }),\n );\n }\n }\n }\n\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n for (const node of nodes) {\n if (node.id === wall.a || node.id === wall.b) continue;\n const r = pointToSegment(node, a, b);\n if (r.dist < EPS_COINCIDENT && r.t > 0 && r.t < 1) {\n issues.push(\n issue(PlanIssueKind.UnsplitNodeOnWall, 'A node sits on a wall that was never split there.', {\n wallIds: [wall.id],\n nodeIds: [node.id],\n }),\n );\n }\n }\n }\n\n for (const opening of Object.values(floor.openings)) {\n if (!floor.walls[opening.wallId]) {\n issues.push(\n issue(PlanIssueKind.DanglingOpening, 'An opening references a wall that no longer exists.', {\n openingIds: [opening.id],\n }),\n );\n }\n }\n\n const referenced = new Set<string>();\n for (const wall of walls) {\n referenced.add(wall.a);\n referenced.add(wall.b);\n }\n for (const node of nodes) {\n if (!referenced.has(node.id)) {\n issues.push(issue(PlanIssueKind.OrphanNode, 'A node has no walls.', { nodeIds: [node.id] }));\n }\n }\n\n return issues;\n}\n\n/**\n * Removes what validation can safely remove: degenerate walls, orphan nodes, dangling\n * openings, and duplicate walls. Idempotent.\n *\n * Deliberately does not touch unsplit crossings: fixing one changes the room structure,\n * which is the user's call, not a cleanup pass's.\n */\nexport function cleanupPlan(floor: PlanFloor): PlanEdit<PlanIssue[]> {\n const fixed: PlanIssue[] = [];\n\n // Welding comes first, and is why the sweep below only ever sees walls that are\n // degenerate for some other reason: a wall squashed to nothing has two perfectly good\n // ends, and deleting it would leave them stacked on the same point.\n const welded = weldShortWalls(floor);\n const next = cloneFloor(welded.floor);\n for (const wallId of welded.result.weldedWallIds) {\n fixed.push(\n issue(PlanIssueKind.ZeroLengthWall, 'Welded the two ends of a wall with no length.', {\n wallIds: [wallId],\n }),\n );\n }\n\n for (const wall of Object.values(next.walls)) {\n const a = next.nodes[wall.a];\n const b = next.nodes[wall.b];\n if (wall.a === wall.b || !a || !b || dist(a, b) < MIN_WALL_LENGTH) {\n delete next.walls[wall.id];\n fixed.push(issue(PlanIssueKind.ZeroLengthWall, 'Removed a degenerate wall.', { wallIds: [wall.id] }));\n }\n }\n\n const pairSeen = new Map<string, PlanWall>();\n for (const wall of Object.values(next.walls)) {\n const key = wall.a < wall.b ? `${wall.a}|${wall.b}` : `${wall.b}|${wall.a}`;\n const prior = pairSeen.get(key);\n if (!prior) {\n pairSeen.set(key, wall);\n continue;\n }\n const keep = wall.thickness >= prior.thickness ? wall : prior;\n const drop = keep === wall ? prior : wall;\n for (const opening of Object.values(next.openings)) {\n if (opening.wallId === drop.id) next.openings[opening.id] = { ...opening, wallId: keep.id };\n }\n delete next.walls[drop.id];\n pairSeen.set(key, keep);\n fixed.push(issue(PlanIssueKind.DuplicateWall, 'Removed a duplicate wall.', { wallIds: [drop.id] }));\n }\n\n for (const opening of Object.values(next.openings)) {\n if (!next.walls[opening.wallId]) {\n delete next.openings[opening.id];\n fixed.push(\n issue(PlanIssueKind.DanglingOpening, 'Removed an opening with no wall.', {\n openingIds: [opening.id],\n }),\n );\n }\n }\n\n // One pass to count degrees, rather than scanning every wall per node: the naive form\n // is O(nodes x walls), which is the dominant cost on a large plan.\n const referenced = new Set<string>();\n for (const wall of Object.values(next.walls)) {\n referenced.add(wall.a);\n referenced.add(wall.b);\n }\n for (const node of Object.values(next.nodes)) {\n if (!referenced.has(node.id)) {\n delete next.nodes[node.id];\n fixed.push(issue(PlanIssueKind.OrphanNode, 'Removed a node with no walls.', { nodeIds: [node.id] }));\n }\n }\n\n return { floor: next, result: fixed, issues: fixed };\n}\n\nexport { wallLength, wallsAtNode, findWallBetween };\n"],"mappings":"kMA4BA,IAAI,EAAQ,EAOZ,SAAgB,EAAM,EAAwB,CAM5C,MALA,IAAS,EAKF,GAAG,EAAO,GAHf,OAAO,OAAW,KAAe,OAAO,OAAO,YAAe,WAC1D,OAAO,WAAW,CAAC,CAAC,MAAM,EAAG,CAAC,EAC9B,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAG,EAAE,IACjB,EAAM,SAAS,EAAE,GAC9C,CASA,SAAS,EAAW,EAA6B,CAC/C,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAM,KAAM,EACxB,MAAO,CAAE,GAAG,EAAM,KAAM,EACxB,SAAU,CAAE,GAAG,EAAM,QAAS,EAC9B,MAAO,CAAE,GAAG,EAAM,KAAM,CAC1B,CACF,CAEA,SAAS,EAAM,EAAqB,EAAiB,EAA4B,CAAC,EAAc,CAC9F,MAAO,CAAE,OAAM,UAAS,GAAG,CAAM,CACnC,CAEA,SA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AiC,CAAE,QAAS,CAAC,EAAK,EAAE,CAAE,CAAC,CAAC,GAIvG,MAAO,CAAE,MAAO,EAAM,OAAQ,EAAO,OAAQ,CAAM,CACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.hit.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.hit.ts"],"sourcesContent":["/**\n * Hit testing against a derived plan.\n *\n * Tolerances arrive in WORLD units and are expected to have been converted from screen\n * pixels by the caller (`HIT_PX / view.zoom`), so a handle stays the same size on screen\n * at any zoom level.\n */\n\nimport { dist, pointToSegment } from './floorPlan.geometry';\nimport { openingGeometry } from './floorPlan.path';\nimport { roomAtPoint } from './floorPlan.rooms';\nimport type { DerivedRoom, PlanFloor, PlanPoint, PlanSelection } from './floorPlan.types';\n\nexport interface HitTolerances {\n node: number;\n opening: number;\n wall: number;\n}\n\n/** Screen-pixel hit radii, divided by `view.zoom` to get world tolerances. */\nexport const HIT_PX: HitTolerances = { node: 10, opening: 9, wall: 8 };\n/** Wider targets for touch, where there is no pixel-accurate pointer. */\nexport const HIT_PX_COARSE: HitTolerances = { node: 18, opening: 16, wall: 14 };\n\nexport function worldTolerances(px: HitTolerances, zoom: number): HitTolerances {\n const safeZoom = zoom > 0 ? zoom : 1;\n return { node: px.node / safeZoom, opening: px.opening / safeZoom, wall: px.wall / safeZoom };\n}\n\nexport interface HitTestOptions {\n /** Restricts what can be hit. Defaults to everything. */\n accept?: Array<PlanSelection['type']>;\n excludeIds?: ReadonlySet<string>;\n}\n\n/**\n * Finds what is under `point`, in priority order: node handle, opening, wall, then room\n * fill.\n *\n * The order is what makes editing feel right. A node sits on top of the walls that meet\n * there, and an opening sits on top of the wall it cuts, so the smaller, more specific\n * target always wins over the larger one underneath it.\n */\nexport function hitTest(\n floor: PlanFloor,\n rooms: DerivedRoom[],\n point: PlanPoint,\n tolerances: HitTolerances,\n options: HitTestOptions = {},\n): PlanSelection | null {\n const accepts = (type: PlanSelection['type']) => !options.accept || options.accept.includes(type);\n const excluded = (id: string) => options.excludeIds?.has(id) ?? false;\n\n if (accepts('node')) {\n let best: { id: string; d: number } | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (excluded(node.id)) continue;\n const d = dist(point, node);\n if (d <= tolerances.node && (!best || d < best.d)) best = { id: node.id, d };\n }\n if (best) return { type: 'node', id: best.id };\n }\n\n if (accepts('opening')) {\n let best: { id: string; d: number } | null = null;\n for (const opening of Object.values(floor.openings)) {\n if (excluded(opening.id)) continue;\n const geo = openingGeometry(floor, opening);\n if (!geo) continue;\n const d = pointToSegment(point, geo.p1, geo.p2).dist;\n if (d <= tolerances.opening && (!best || d < best.d)) best = { id: opening.id, d };\n }\n if (best) return { type: 'opening', id: best.id };\n }\n\n if (accepts('wall')) {\n let best: { id: string; d: number } | null = null;\n for (const wall of Object.values(floor.walls)) {\n if (excluded(wall.id)) continue;\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n // Half the wall's own thickness, so a thick wall is grabbable across its body\n // rather than only along its centreline.\n const reach = Math.max(tolerances.wall, wall.thickness / 2);\n const d = pointToSegment(point, a, b).dist;\n if (d <= reach && (!best || d < best.d)) best = { id: wall.id, d };\n }\n if (best) return { type: 'wall', id: best.id };\n }\n\n if (accepts('room')) {\n const room = roomAtPoint(rooms, point);\n if (room?.roomId && !excluded(room.roomId)) return { type: 'room', id: room.roomId };\n }\n\n return null;\n}\n\nexport function selectionsEqual(a: PlanSelection | null, b: PlanSelection | null): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n return a.type === b.type && a.id === b.id;\n}\n"],"mappings":"+KAoBA,IAAa,EAAwB,CAAE,KAAM,GAAI,QAAS,EAAG,KAAM,CAAE,EAExD,EAA+B,CAAE,KAAM,GAAI,QAAS,GAAI,KAAM,EAAG,EAE9E,SAAgB,EAAgB,EAAmB,EAA6B,CAC9E,IAAM,EAAW,EAAO,EAAI,EAAO,EACnC,MAAO,CAAE,KAAM,EAAG,KAAO,EAAU,QAAS,EAAG,QAAU,EAAU,KAAM,EAAG,KAAO,CAAS,CAC9F,CAgBA,SAAgB,EACd,EACA,EACA,EACA,EACA,EAA0B,CAAC,EACL,CACtB,IAAM,EAAW,GAAgC,CAAC,EAAQ,QAAU,EAAQ,OAAO,SAAS,CAAI,EAC1F,EAAY,GAAe,EAAQ,YAAY,IAAI,CAAE,GAAK,GAEhE,GAAI,EAAQ,MAAM,EAAG,CACnB,IAAI,EAAyC,KAC7C,IAAK,IAAM,KAAQ,OAAO,OAAO,EAAM,KAAK,EAAG,CAC7C,GAAI,EAAS,EAAK,EAAE,EAAG,SACvB,IAAM,EAAI,EAAK,EAAO,CAAI,EACtB,GAAK,EAAW,OAAS,CAAC,GAAQ,EAAI,EAAK,KAAI,EAAO,CAAE,GAAI,EAAK,GAAI,GAAE,EAC7E,CACA,GAAI,EAAM,MAAO,CAAE,KAAM,OAAQ,GAAI,EAAK,EAAG,CAC/C,CAEA,GAAI,EAAQ,SAAS,EAAG,CACtB,IAAI,EAAyC,KAC7C,IAAK,IAAM,KAAW,OAAO,OAAO,EAAM,QAAQ,EAAG,CACnD,GAAI,EAAS,EAAQ,EAAE,EAAG,SAC1B,IAAM,EAAM,EAAgB,EAAO,CAAO,EAC1C,GAAI,CAAC,EAAK,SACV,IAAM,EAAI,EAAe,EAAO,EAAI,GAAI,EAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"floorPlan.hit.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.hit.ts"],"sourcesContent":["/**\n * Hit testing against a derived plan.\n *\n * Tolerances arrive in WORLD units and are expected to have been converted from screen\n * pixels by the caller (`HIT_PX / view.zoom`), so a handle stays the same size on screen\n * at any zoom level.\n */\n\nimport { dist, pointToSegment } from './floorPlan.geometry';\nimport { openingGeometry } from './floorPlan.path';\nimport { roomAtPoint } from './floorPlan.rooms';\nimport type { DerivedRoom, PlanFloor, PlanPoint, PlanSelection } from './floorPlan.types';\n\nexport interface HitTolerances {\n node: number;\n opening: number;\n wall: number;\n}\n\n/** Screen-pixel hit radii, divided by `view.zoom` to get world tolerances. */\nexport const HIT_PX: HitTolerances = { node: 10, opening: 9, wall: 8 };\n/** Wider targets for touch, where there is no pixel-accurate pointer. */\nexport const HIT_PX_COARSE: HitTolerances = { node: 18, opening: 16, wall: 14 };\n\nexport function worldTolerances(px: HitTolerances, zoom: number): HitTolerances {\n const safeZoom = zoom > 0 ? zoom : 1;\n return { node: px.node / safeZoom, opening: px.opening / safeZoom, wall: px.wall / safeZoom };\n}\n\nexport interface HitTestOptions {\n /** Restricts what can be hit. Defaults to everything. */\n accept?: Array<PlanSelection['type']>;\n excludeIds?: ReadonlySet<string>;\n}\n\n/**\n * Finds what is under `point`, in priority order: node handle, opening, wall, then room\n * fill.\n *\n * The order is what makes editing feel right. A node sits on top of the walls that meet\n * there, and an opening sits on top of the wall it cuts, so the smaller, more specific\n * target always wins over the larger one underneath it.\n */\nexport function hitTest(\n floor: PlanFloor,\n rooms: DerivedRoom[],\n point: PlanPoint,\n tolerances: HitTolerances,\n options: HitTestOptions = {},\n): PlanSelection | null {\n const accepts = (type: PlanSelection['type']) => !options.accept || options.accept.includes(type);\n const excluded = (id: string) => options.excludeIds?.has(id) ?? false;\n\n if (accepts('node')) {\n let best: { id: string; d: number } | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (excluded(node.id)) continue;\n const d = dist(point, node);\n if (d <= tolerances.node && (!best || d < best.d)) best = { id: node.id, d };\n }\n if (best) return { type: 'node', id: best.id };\n }\n\n if (accepts('opening')) {\n let best: { id: string; d: number } | null = null;\n for (const opening of Object.values(floor.openings)) {\n if (excluded(opening.id)) continue;\n const geo = openingGeometry(floor, opening);\n if (!geo) continue;\n const d = pointToSegment(point, geo.p1, geo.p2).dist;\n if (d <= tolerances.opening && (!best || d < best.d)) best = { id: opening.id, d };\n }\n if (best) return { type: 'opening', id: best.id };\n }\n\n if (accepts('wall')) {\n let best: { id: string; d: number } | null = null;\n for (const wall of Object.values(floor.walls)) {\n if (excluded(wall.id)) continue;\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n // Half the wall's own thickness, so a thick wall is grabbable across its body\n // rather than only along its centreline.\n const reach = Math.max(tolerances.wall, wall.thickness / 2);\n const d = pointToSegment(point, a, b).dist;\n if (d <= reach && (!best || d < best.d)) best = { id: wall.id, d };\n }\n if (best) return { type: 'wall', id: best.id };\n }\n\n if (accepts('room')) {\n const room = roomAtPoint(rooms, point);\n if (room?.roomId && !excluded(room.roomId)) return { type: 'room', id: room.roomId };\n }\n\n return null;\n}\n\nexport function selectionsEqual(a: PlanSelection | null, b: PlanSelection | null): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n return a.type === b.type && a.id === b.id;\n}\n"],"mappings":"+KAoBA,IAAa,EAAwB,CAAE,KAAM,GAAI,QAAS,EAAG,KAAM,CAAE,EAExD,EAA+B,CAAE,KAAM,GAAI,QAAS,GAAI,KAAM,EAAG,EAE9E,SAAgB,EAAgB,EAAmB,EAA6B,CAC9E,IAAM,EAAW,EAAO,EAAI,EAAO,EACnC,MAAO,CAAE,KAAM,EAAG,KAAO,EAAU,QAAS,EAAG,QAAU,EAAU,KAAM,EAAG,KAAO,CAAS,CAC9F,CAgBA,SAAgB,EACd,EACA,EACA,EACA,EACA,EAA0B,CAAC,EACL,CACtB,IAAM,EAAW,GAAgC,CAAC,EAAQ,QAAU,EAAQ,OAAO,SAAS,CAAI,EAC1F,EAAY,GAAe,EAAQ,YAAY,IAAI,CAAE,GAAK,GAEhE,GAAI,EAAQ,MAAM,EAAG,CACnB,IAAI,EAAyC,KAC7C,IAAK,IAAM,KAAQ,OAAO,OAAO,EAAM,KAAK,EAAG,CAC7C,GAAI,EAAS,EAAK,EAAE,EAAG,SACvB,IAAM,EAAI,EAAK,EAAO,CAAI,EACtB,GAAK,EAAW,OAAS,CAAC,GAAQ,EAAI,EAAK,KAAI,EAAO,CAAE,GAAI,EAAK,GAAI,GAAE,E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gB,EAAyB,EAAkC,CAGzF,OAFI,IAAM,EAAU,GAChB,CAAC,GAAK,CAAC,EAAU,GACd,EAAE,OAAS,EAAE,MAAQ,EAAE,KAAO,EAAE,EACzC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DoorSwing as e,OpeningKind as t,PlanUnitSystem as n,WallType as r}from"./floorPlan.types.mjs";import{cleanupPlan as i,newId as a}from"./floorPlan.graph.mjs";import{emptyFloor as o}from"./floorPlan.plan.mjs";var s=1;function c(e,t={}){return JSON.stringify(e,null,t.pretty===!1?void 0:2)}function l(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function u(e,t){let n=typeof e==`string`?Number(e):e;return typeof n==`number`&&Number.isFinite(n)?n:t}function d(e,t){return typeof e==`string`?e:t}function f(e,t){return typeof e==`boolean`?e:t}function p(e,t,n){return typeof e==`string`&&t.includes(e)?e:n}function m(e,t){return l(e)?{x:u(e.x,t.x),y:u(e.y,t.y)}:t}function h(e){return Array.isArray(e)?e:l(e)?Object.values(e):[]}function g(e){let t={};for(let n of e)t[n.id]=n;return t}function _(n,a,s){let c=`floor ${a+1}`,_=l(n)?n:{};l(n)||s.push(`${c} was not an object, so it was read as empty`);let v=o();v.id=d(_.id,v.id),v.label=d(_.label,v.label),v.elevation=u(_.elevation,0),v.height=u(_.height,v.height);let y=[];for(let e of h(_.nodes))
|
|
1
|
+
import{DoorSwing as e,OpeningKind as t,PlanUnitSystem as n,WallType as r}from"./floorPlan.types.mjs";import{cleanupPlan as i,newId as a}from"./floorPlan.graph.mjs";import{emptyFloor as o}from"./floorPlan.plan.mjs";var s=1;function c(e,t={}){return JSON.stringify(e,null,t.pretty===!1?void 0:2)}function l(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function u(e,t){let n=typeof e==`string`?Number(e):e;return typeof n==`number`&&Number.isFinite(n)?n:t}function d(e,t){return typeof e==`string`?e:t}function f(e,t){return typeof e==`boolean`?e:t}function p(e,t,n){return typeof e==`string`&&t.includes(e)?e:n}function m(e,t){return l(e)?{x:u(e.x,t.x),y:u(e.y,t.y)}:t}function h(e){return Array.isArray(e)?e:l(e)?Object.values(e):[]}function g(e){let t={};for(let n of e)t[n.id]=n;return t}function _(n,a,s){let c=`floor ${a+1}`,_=l(n)?n:{};l(n)||s.push(`${c} was not an object, so it was read as empty`);let v=o();v.id=d(_.id,v.id),v.label=d(_.label,v.label),v.elevation=u(_.elevation,0),v.height=u(_.height,v.height);let y=[];for(let e of h(_.nodes))l(e)&&typeof e.id==`string`&&y.push({id:e.id,x:u(e.x,0),y:u(e.y,0)});v.nodes=g(y);let b=[],x=0;for(let e of h(_.walls)){if(!l(e)||typeof e.id!=`string`)continue;let t=d(e.a,``),n=d(e.b,``);if(!v.nodes[t]||!v.nodes[n]||t===n){x+=1;continue}b.push({id:e.id,a:t,b:n,thickness:Math.max(1,u(e.thickness,100)),height:e.height===void 0?void 0:u(e.height,0),baseHeight:e.baseHeight===void 0?void 0:u(e.baseHeight,0),type:p(e.type,Object.values(r),r.Interior)})}v.walls=g(b),x>0&&s.push(`${c}: dropped ${x} wall(s) whose corners were missing`);let S=[],C=0;for(let n of h(_.openings)){if(!l(n)||typeof n.id!=`string`)continue;let r=d(n.wallId,``);if(!v.walls[r]){C+=1;continue}S.push({id:n.id,wallId:r,kind:p(n.kind,Object.values(t),t.Door),offset:u(n.offset,0),width:Math.max(1,u(n.width,800)),sill:u(n.sill,0),head:u(n.head,2100),swing:n.swing===void 0?void 0:p(n.swing,Object.values(e),e.StartLeft)})}v.openings=g(S),C>0&&s.push(`${c}: dropped ${C} opening(s) with no wall to sit in`);let w=[];for(let e of h(_.rooms))l(e)&&typeof e.id==`string`&&w.push({id:e.id,name:d(e.name,``),colour:typeof e.colour==`string`?e.colour:void 0,usage:typeof e.usage==`string`?e.usage:void 0,anchor:m(e.anchor,{x:0,y:0}),anchorPinned:f(e.anchorPinned,!1),seq:u(e.seq,w.length),wallIds:Array.isArray(e.wallIds)?e.wallIds.filter(e=>typeof e==`string`&&!!v.walls[e]):[],area:u(e.area,0)});v.rooms=g(w);let T=i(v);return T.result.length>0&&s.push(`${c}: repaired ${T.result.length} inconsistency(ies) in the geometry`),T.floor}function v(e){let t=[],r;try{r=JSON.parse(e)}catch(e){return{plan:null,issues:[`Not valid JSON: ${e.message}`]}}if(!l(r))return{plan:null,issues:[`Not a floor plan: expected an object`]};if(r.version!==void 0&&r.version!==1)return{plan:null,issues:[`Plan format version ${String(r.version)} is not supported (this build reads version 1)`]};r.version===void 0&&t.push(`No format version, read as version 1`);let i=Array.isArray(r.floors)?r.floors:[];if(i.length===0){if(r.floors!==void 0)t.push(`No floors in the file, started an empty one`);else return{plan:null,issues:["Not a floor plan: no `floors`"]}}let o=(i.length>0?i:[void 0]).map((e,n)=>_(e,n,t));return{plan:{id:d(r.id,a(`plan`)),name:typeof r.name==`string`?r.name:void 0,version:1,unitSystem:p(r.unitSystem,Object.values(n),n.Metric),floors:o,revision:u(r.revision,0)+1},issues:t}}export{s as PLAN_FORMAT_VERSION,v as planFromJson,c as planToJson};
|
|
2
2
|
//# sourceMappingURL=floorPlan.json.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.json.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.json.ts"],"sourcesContent":["/**\n * Reading and writing a plan as JSON, which is the interchange format.\n *\n * Writing is trivial. Reading is not: the text comes off a disk, so it is untrusted, and\n * the component that receives the result renders it immediately. `planFromJson` therefore\n * rebuilds the plan field by field rather than casting the parsed object, so nothing that\n * was not checked can reach the renderer, and returns everything it had to fix so a\n * caller can tell the difference between a clean file and a salvaged one.\n *\n * It repairs rather than rejects wherever a repair is unambiguous: a wall whose node is\n * missing is dropped, a thickness of `\"200\"` is read as 200, an unknown wall type becomes\n * `Interior`. A file is only refused when there is nothing to salvage, because a plan a\n * user spent an hour on should not be lost to one bad field.\n */\n\nimport { cleanupPlan, newId } from './floorPlan.graph';\nimport { emptyFloor } from './floorPlan.plan';\nimport { DoorSwing, OpeningKind, PlanUnitSystem, WallType } from './floorPlan.types';\nimport type {\n FloorPlan,\n PlanFloor,\n PlanNode,\n PlanOpening,\n PlanPoint,\n PlanRoom,\n PlanWall,\n} from './floorPlan.types';\n\n/** The only `version` a file may carry. Bump only for a breaking shape change. */\nexport const PLAN_FORMAT_VERSION = 1;\n\nexport interface PlanParseResult {\n /** `null` only when the file could not be read as a plan at all. */\n plan: FloorPlan | null;\n /**\n * Everything that had to be repaired or dropped, in plain language. Empty means the\n * file was clean. A non-empty list with a plan means it was salvaged.\n */\n issues: string[];\n}\n\n/** A plan as JSON text, ready to write to a file. Indented unless told otherwise. */\nexport function planToJson(plan: FloorPlan, options: { pretty?: boolean } = {}): string {\n return JSON.stringify(plan, null, options.pretty === false ? undefined : 2);\n}\n\n// ─── Field readers ─────────────────────────────────────────────────────────────\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** A finite number, also accepting the numeric strings a hand-edited file tends to grow. */\nfunction num(value: unknown, fallback: number): number {\n const n = typeof value === 'string' ? Number(value) : value;\n return typeof n === 'number' && Number.isFinite(n) ? n : fallback;\n}\n\nfunction str(value: unknown, fallback: string): string {\n return typeof value === 'string' ? value : fallback;\n}\n\nfunction bool(value: unknown, fallback: boolean): boolean {\n return typeof value === 'boolean' ? value : fallback;\n}\n\nfunction oneOf<T extends string>(value: unknown, allowed: readonly T[], fallback: T): T {\n return typeof value === 'string' && (allowed as readonly string[]).includes(value)\n ? (value as T)\n : fallback;\n}\n\nfunction point(value: unknown, fallback: PlanPoint): PlanPoint {\n if (!isRecord(value)) return fallback;\n return { x: num(value.x, fallback.x), y: num(value.y, fallback.y) };\n}\n\n/**\n * The entries of a `Record<string, T>`, tolerating the array a different exporter might\n * have written. Entries without a usable `id` are dropped by the caller.\n */\nfunction entries(value: unknown): unknown[] {\n if (Array.isArray(value)) return value;\n if (isRecord(value)) return Object.values(value);\n return [];\n}\n\nfunction byId<T extends { id: string }>(items: T[]): Record<string, T> {\n const out: Record<string, T> = {};\n for (const item of items) out[item.id] = item;\n return out;\n}\n\n// ─── Floor ─────────────────────────────────────────────────────────────────────\n\nfunction readFloor(raw: unknown, index: number, issues: string[]): PlanFloor {\n const where = `floor ${index + 1}`;\n const source = isRecord(raw) ? raw : {};\n if (!isRecord(raw)) issues.push(`${where} was not an object, so it was read as empty`);\n\n const floor = emptyFloor();\n floor.id = str(source.id, floor.id);\n floor.label = str(source.label, floor.label);\n floor.elevation = num(source.elevation, 0);\n floor.height = num(source.height, floor.height);\n\n const nodes: PlanNode[] = [];\n for (const raw of entries(source.nodes)) {\n if (!isRecord(raw) || typeof raw.id !== 'string') continue;\n nodes.push({ id: raw.id, x: num(raw.x, 0), y: num(raw.y, 0) });\n }\n floor.nodes = byId(nodes);\n\n const walls: PlanWall[] = [];\n let orphanWalls = 0;\n for (const raw of entries(source.walls)) {\n if (!isRecord(raw) || typeof raw.id !== 'string') continue;\n const a = str(raw.a, '');\n const b = str(raw.b, '');\n // A wall with no node to stand on would break face extraction, which assumes every\n // wall resolves. There is no way to guess where it was meant to go.\n if (!floor.nodes[a] || !floor.nodes[b] || a === b) {\n orphanWalls += 1;\n continue;\n }\n walls.push({\n id: raw.id,\n a,\n b,\n thickness: Math.max(1, num(raw.thickness, 100)),\n height: raw.height === undefined ? undefined : num(raw.height, 0),\n baseHeight: raw.baseHeight === undefined ? undefined : num(raw.baseHeight, 0),\n type: oneOf(raw.type, Object.values(WallType), WallType.Interior),\n });\n }\n floor.walls = byId(walls);\n if (orphanWalls > 0) {\n issues.push(`${where}: dropped ${orphanWalls} wall(s) whose corners were missing`);\n }\n\n const openings: PlanOpening[] = [];\n let orphanOpenings = 0;\n for (const raw of entries(source.openings)) {\n if (!isRecord(raw) || typeof raw.id !== 'string') continue;\n const wallId = str(raw.wallId, '');\n if (!floor.walls[wallId]) {\n orphanOpenings += 1;\n continue;\n }\n openings.push({\n id: raw.id,\n wallId,\n kind: oneOf(raw.kind, Object.values(OpeningKind), OpeningKind.Door),\n offset: num(raw.offset, 0),\n width: Math.max(1, num(raw.width, 800)),\n sill: num(raw.sill, 0),\n head: num(raw.head, 2100),\n swing:\n raw.swing === undefined\n ? undefined\n : oneOf(raw.swing, Object.values(DoorSwing), DoorSwing.StartLeft),\n });\n }\n floor.openings = byId(openings);\n if (orphanOpenings > 0) {\n issues.push(`${where}: dropped ${orphanOpenings} opening(s) with no wall to sit in`);\n }\n\n const rooms: PlanRoom[] = [];\n for (const raw of entries(source.rooms)) {\n if (!isRecord(raw) || typeof raw.id !== 'string') continue;\n // A room is only a name attached to a face, and the face is recomputed on load, so a\n // room whose walls have gone is kept rather than dropped: re-adding the wall brings\n // its name back, and dropping it is the one way this model loses data for good.\n rooms.push({\n id: raw.id,\n name: str(raw.name, ''),\n colour: typeof raw.colour === 'string' ? raw.colour : undefined,\n usage: typeof raw.usage === 'string' ? raw.usage : undefined,\n anchor: point(raw.anchor, { x: 0, y: 0 }),\n anchorPinned: bool(raw.anchorPinned, false),\n seq: num(raw.seq, rooms.length),\n wallIds: Array.isArray(raw.wallIds)\n ? raw.wallIds.filter((id): id is string => typeof id === 'string' && !!floor.walls[id])\n : [],\n area: num(raw.area, 0),\n });\n }\n floor.rooms = byId(rooms);\n\n const cleaned = cleanupPlan(floor);\n if (cleaned.result.length > 0) {\n issues.push(`${where}: repaired ${cleaned.result.length} inconsistency(ies) in the geometry`);\n }\n return cleaned.floor;\n}\n\n// ─── Document ──────────────────────────────────────────────────────────────────\n\n/**\n * Reads JSON text as a plan, repairing what it can and reporting what it could not.\n *\n * `plan` is `null` only when the text is not JSON, is not an object, or carries a\n * `version` this build does not know. Everything else comes back as a usable plan.\n */\nexport function planFromJson(text: string): PlanParseResult {\n const issues: string[] = [];\n\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (error) {\n return { plan: null, issues: [`Not valid JSON: ${(error as Error).message}`] };\n }\n\n if (!isRecord(raw)) return { plan: null, issues: ['Not a floor plan: expected an object'] };\n\n if (raw.version !== undefined && raw.version !== PLAN_FORMAT_VERSION) {\n // Refusing beats guessing: a future version may mean something different by the same\n // field names, and silently misreading it loses the file's real contents.\n return {\n plan: null,\n issues: [\n `Plan format version ${String(raw.version)} is not supported ` +\n `(this build reads version ${PLAN_FORMAT_VERSION})`,\n ],\n };\n }\n if (raw.version === undefined) issues.push('No format version, read as version 1');\n\n const rawFloors = Array.isArray(raw.floors) ? raw.floors : [];\n if (rawFloors.length === 0) {\n if (raw.floors !== undefined) issues.push('No floors in the file, started an empty one');\n else return { plan: null, issues: ['Not a floor plan: no `floors`'] };\n }\n\n const floors = (rawFloors.length > 0 ? rawFloors : [undefined]).map((floor, i) =>\n readFloor(floor, i, issues),\n );\n\n return {\n plan: {\n id: str(raw.id, newId('plan')),\n name: typeof raw.name === 'string' ? raw.name : undefined,\n version: PLAN_FORMAT_VERSION,\n unitSystem: oneOf(raw.unitSystem, Object.values(PlanUnitSystem), PlanUnitSystem.Metric),\n floors,\n // Bumped, not carried over: the plan in hand is not the one the file described if\n // anything was repaired, and `derivePlan` memoises on this.\n revision: num(raw.revision, 0) + 1,\n },\n issues,\n };\n}\n"],"mappings":"sNA6BA,IAAa,EAAsB,EAanC,SAAgB,EAAW,EAAiB,EAAgC,CAAC,EAAW,CACtF,OAAO,KAAK,UAAU,EAAM,KAAM,EAAQ,SAAW,GAAQ,IAAA,GAAY,CAAC,CAC5E,CAIA,SAAS,EAAS,EAAkD,CAClE,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAGA,SAAS,EAAI,EAAgB,EAA0B,CACrD,IAAM,EAAI,OAAO,GAAU,SAAW,OAAO,CAAK,EAAI,EACtD,OAAO,OAAO,GAAM,UAAY,OAAO,SAAS,CAAC,EAAI,EAAI,CAC3D,CAEA,SAAS,EAAI,EAAgB,EAA0B,CACrD,OAAO,OAAO,GAAU,SAAW,EAAQ,CAC7C,CAEA,SAAS,EAAK,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AAoB,EAAgB,SAAS,CAAE,CAC/E,CAEA,GAAI,CAAC,EAAS,CAAG,EAAG,MAAO,CAAE,KAAM,KAAM,OAAQ,CAAC,sCAAsC,CAAE,EAE1F,GAAI,EAAI,UAAY,IAAA,IAAa,EAAI,UAAA,EAGnC,MAAO,CACL,KAAM,KACN,OAAQ,CACN,uBAAuB,OAAO,EAAI,OAAO,EAAE,+CAE7C,CACF,EAEE,EAAI,UAAY,IAAA,IAAW,EAAO,KAAK,sCAAsC,EAEjF,IAAM,EAAY,MAAM,QAAQ,EAAI,MAAM,EAAI,EAAI,OAAS,CAAC,EAC5D,GAAI,EAAU,SAAW,EACvB,GAAI,EAAI,SAAW,IAAA,GAAW,EAAO,KAAK,6CAA6C,OAClF,MAAO,CAAE,KAAM,KAAM,OAAQ,CAAC,+BAA+B,CAAE,EAGtE,IAAM,GAAU,EAAU,OAAS,EAAI,EAAY,CAAC,IAAA,EAAS,GAAG,KAAK,EAAO,IAC1E,EAAU,EAAO,EAAG,CAAM,CAC5B,EAEA,MAAO,CACL,KAAM,CACJ,GAAI,EAAI,EAAI,GAAI,EAAM,MAAM,CAAC,EAC7B,KAAM,OAAO,EAAI,MAAS,SAAW,EAAI,KAAO,IAAA,GAChD,QAAA,EACA,WAAY,EAAM,EAAI,WAAY,OAAO,OAAO,CAAc,EAAG,EAAe,MAAM,EACtF,SAGA,SAAU,EAAI,EAAI,SAAU,CAAC,EAAI,CACnC,EACA,QACF,CACF"}
|
|
1
|
+
{"version":3,"file":"floorPlan.json.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.json.ts"],"sourcesContent":["/**\n * Reading and writing a plan as JSON, which is the interchange format.\n *\n * Writing is trivial. Reading is not: the text comes off a disk, so it is untrusted, and\n * the component that receives the result renders it immediately. `planFromJson` therefore\n * rebuilds the plan field by field rather than casting the parsed object, so nothing that\n * was not checked can reach the renderer, and returns everything it had to fix so a\n * caller can tell the difference between a clean file and a salvaged one.\n *\n * It repairs rather than rejects wherever a repair is unambiguous: a wall whose node is\n * missing is dropped, a thickness of `\"200\"` is read as 200, an unknown wall type becomes\n * `Interior`. A file is only refused when there is nothing to salvage, because a plan a\n * user spent an hour on should not be lost to one bad field.\n */\n\nimport { cleanupPlan, newId } from './floorPlan.graph';\nimport { emptyFloor } from './floorPlan.plan';\nimport { DoorSwing, OpeningKind, PlanUnitSystem, WallType } from './floorPlan.types';\nimport type { FloorPlan, PlanFloor, PlanNode, PlanOpening, PlanPoint, PlanRoom, PlanWall } from './floorPlan.types';\n\n/** The only `version` a file may carry. Bump only for a breaking shape change. */\nexport const PLAN_FORMAT_VERSION = 1;\n\nexport interface PlanParseResult {\n /** `null` only when the file could not be read as a plan at all. */\n plan: FloorPlan | null;\n /**\n * Everything that had to be repaired or dropped, in plain language. Empty means the\n * file was clean. A non-empty list with a plan means it was salvaged.\n */\n issues: string[];\n}\n\n/** A plan as JSON text, ready to write to a file. Indented unless told otherwise. */\nexport function planToJson(plan: FloorPlan, options: { pretty?: boolean } = {}): string {\n return JSON.stringify(plan, null, options.pretty === false ? undefined : 2);\n}\n\n// ─── Field readers ─────────────────────────────────────────────────────────────\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** A finite number, also accepting the numeric strings a hand-edited file tends to grow. */\nfunction num(value: unknown, fallback: number): number {\n const n = typeof value === 'string' ? Number(value) : value;\n return typeof n === 'number' && Number.isFinite(n) ? n : fallback;\n}\n\nfunction str(value: unknown, fallback: string): string {\n return typeof value === 'string' ? value : fallback;\n}\n\nfunction bool(value: unknown, fallback: boolean): boolean {\n return typeof value === 'boolean' ? value : fallback;\n}\n\nfunction oneOf<T extends string>(value: unknown, allowed: readonly T[], fallback: T): T {\n return typeof value === 'string' && (allowed as readonly string[]).includes(value) ? (value as T) : fallback;\n}\n\nfunction point(value: unknown, fallback: PlanPoint): PlanPoint {\n if (!isRecord(value)) return fallback;\n return { x: num(value.x, fallback.x), y: num(value.y, fallback.y) };\n}\n\n/**\n * The entries of a `Record<string, T>`, tolerating the array a different exporter might\n * have written. Entries without a usable `id` are dropped by the caller.\n */\nfunction entries(value: unknown): unknown[] {\n if (Array.isArray(value)) return value;\n if (isRecord(value)) return Object.values(value);\n return [];\n}\n\nfunction byId<T extends { id: string }>(items: T[]): Record<string, T> {\n const out: Record<string, T> = {};\n for (const item of items) out[item.id] = item;\n return out;\n}\n\n// ─── Floor ─────────────────────────────────────────────────────────────────────\n\nfunction readFloor(raw: unknown, index: number, issues: string[]): PlanFloor {\n const where = `floor ${index + 1}`;\n const source = isRecord(raw) ? raw : {};\n if (!isRecord(raw)) issues.push(`${where} was not an object, so it was read as empty`);\n\n const floor = emptyFloor();\n floor.id = str(source.id, floor.id);\n floor.label = str(source.label, floor.label);\n floor.elevation = num(source.elevation, 0);\n floor.height = num(source.height, floor.height);\n\n const nodes: PlanNode[] = [];\n for (const raw of entries(source.nodes)) {\n if (!isRecord(raw) || typeof raw.id !== 'string') continue;\n nodes.push({ id: raw.id, x: num(raw.x, 0), y: num(raw.y, 0) });\n }\n floor.nodes = byId(nodes);\n\n const walls: PlanWall[] = [];\n let orphanWalls = 0;\n for (const raw of entries(source.walls)) {\n if (!isRecord(raw) || typeof raw.id !== 'string') continue;\n const a = str(raw.a, '');\n const b = str(raw.b, '');\n // A wall with no node to stand on would break face extraction, which assumes every\n // wall resolves. There is no way to guess where it was meant to go.\n if (!floor.nodes[a] || !floor.nodes[b] || a === b) {\n orphanWalls += 1;\n continue;\n }\n walls.push({\n id: raw.id,\n a,\n b,\n thickness: Math.max(1, num(raw.thickness, 100)),\n height: raw.height === undefined ? undefined : num(raw.height, 0),\n baseHeight: raw.baseHeight === undefined ? undefined : num(raw.baseHeight, 0),\n type: oneOf(raw.type, Object.values(WallType), WallType.Interior),\n });\n }\n floor.walls = byId(walls);\n if (orphanWalls > 0) {\n issues.push(`${where}: dropped ${orphanWalls} wall(s) whose corners were missing`);\n }\n\n const openings: PlanOpening[] = [];\n let orphanOpenings = 0;\n for (const raw of entries(source.openings)) {\n if (!isRecord(raw) || typeof raw.id !== 'string') continue;\n const wallId = str(raw.wallId, '');\n if (!floor.walls[wallId]) {\n orphanOpenings += 1;\n continue;\n }\n openings.push({\n id: raw.id,\n wallId,\n kind: oneOf(raw.kind, Object.values(OpeningKind), OpeningKind.Door),\n offset: num(raw.offset, 0),\n width: Math.max(1, num(raw.width, 800)),\n sill: num(raw.sill, 0),\n head: num(raw.head, 2100),\n swing: raw.swing === undefined ? undefined : oneOf(raw.swing, Object.values(DoorSwing), DoorSwing.StartLeft),\n });\n }\n floor.openings = byId(openings);\n if (orphanOpenings > 0) {\n issues.push(`${where}: dropped ${orphanOpenings} opening(s) with no wall to sit in`);\n }\n\n const rooms: PlanRoom[] = [];\n for (const raw of entries(source.rooms)) {\n if (!isRecord(raw) || typeof raw.id !== 'string') continue;\n // A room is only a name attached to a face, and the face is recomputed on load, so a\n // room whose walls have gone is kept rather than dropped: re-adding the wall brings\n // its name back, and dropping it is the one way this model loses data for good.\n rooms.push({\n id: raw.id,\n name: str(raw.name, ''),\n colour: typeof raw.colour === 'string' ? raw.colour : undefined,\n usage: typeof raw.usage === 'string' ? raw.usage : undefined,\n anchor: point(raw.anchor, { x: 0, y: 0 }),\n anchorPinned: bool(raw.anchorPinned, false),\n seq: num(raw.seq, rooms.length),\n wallIds: Array.isArray(raw.wallIds)\n ? raw.wallIds.filter((id): id is string => typeof id === 'string' && !!floor.walls[id])\n : [],\n area: num(raw.area, 0),\n });\n }\n floor.rooms = byId(rooms);\n\n const cleaned = cleanupPlan(floor);\n if (cleaned.result.length > 0) {\n issues.push(`${where}: repaired ${cleaned.result.length} inconsistency(ies) in the geometry`);\n }\n return cleaned.floor;\n}\n\n// ─── Document ──────────────────────────────────────────────────────────────────\n\n/**\n * Reads JSON text as a plan, repairing what it can and reporting what it could not.\n *\n * `plan` is `null` only when the text is not JSON, is not an object, or carries a\n * `version` this build does not know. Everything else comes back as a usable plan.\n */\nexport function planFromJson(text: string): PlanParseResult {\n const issues: string[] = [];\n\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (error) {\n return { plan: null, issues: [`Not valid JSON: ${(error as Error).message}`] };\n }\n\n if (!isRecord(raw)) return { plan: null, issues: ['Not a floor plan: expected an object'] };\n\n if (raw.version !== undefined && raw.version !== PLAN_FORMAT_VERSION) {\n // Refusing beats guessing: a future version may mean something different by the same\n // field names, and silently misreading it loses the file's real contents.\n return {\n plan: null,\n issues: [\n `Plan format version ${String(raw.version)} is not supported ` +\n `(this build reads version ${PLAN_FORMAT_VERSION})`,\n ],\n };\n }\n if (raw.version === undefined) issues.push('No format version, read as version 1');\n\n const rawFloors = Array.isArray(raw.floors) ? raw.floors : [];\n if (rawFloors.length === 0) {\n if (raw.floors !== undefined) issues.push('No floors in the file, started an empty one');\n else return { plan: null, issues: ['Not a floor plan: no `floors`'] };\n }\n\n const floors = (rawFloors.length > 0 ? rawFloors : [undefined]).map((floor, i) => readFloor(floor, i, issues));\n\n return {\n plan: {\n id: str(raw.id, newId('plan')),\n name: typeof raw.name === 'string' ? raw.name : undefined,\n version: PLAN_FORMAT_VERSION,\n unitSystem: oneOf(raw.unitSystem, Object.values(PlanUnitSystem), PlanUnitSystem.Metric),\n floors,\n // Bumped, not carried over: the plan in hand is not the one the file described if\n // anything was repaired, and `derivePlan` memoises on this.\n revision: num(raw.revision, 0) + 1,\n },\n issues,\n };\n}\n"],"mappings":"sNAqBA,IAAa,EAAsB,EAanC,SAAgB,EAAW,EAAiB,EAAgC,CAAC,EAAW,CACtF,OAAO,KAAK,UAAU,EAAM,KAAM,EAAQ,SAAW,GAAQ,IAAA,GAAY,CAAC,CAC5E,CAIA,SAAS,EAAS,EAAkD,CAClE,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAGA,SAAS,EAAI,EAAgB,EAA0B,CACrD,IAAM,EAAI,OAAO,GAAU,SAAW,OAAO,CAAK,EAAI,EACtD,O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,EAAa,EAA+B,CAC1D,IAAM,EAAmB,CAAC,EAEtB,EACJ,GAAI,CACF,EAAM,KAAK,MAAM,CAAI,CACvB,OAAS,EAAO,CACd,MAAO,CAAE,KAAM,KAAM,OAAQ,CAAC,mBAAoB,EAAgB,SAAS,CAAE,CAC/E,CAEA,GAAI,CAAC,EAAS,CAAG,EAAG,MAAO,CAAE,KAAM,KAAM,OAAQ,CAAC,sCAAsC,CAAE,EAE1F,GAAI,EAAI,UAAY,IAAA,IAAa,EAAI,UAAA,EAGnC,MAAO,CACL,KAAM,KACN,OAAQ,CACN,uBAAuB,OAAO,EAAI,OAAO,EAAE,+CAE7C,CACF,EAEE,EAAI,UAAY,IAAA,IAAW,EAAO,KAAK,sCAAsC,EAEjF,IAAM,EAAY,MAAM,QAAQ,EAAI,MAAM,EAAI,EAAI,OAAS,CAAC,EAC5D,GAAI,EAAU,SAAW,EAAG,CAC1B,GAAI,EAAI,SAAW,IAAA,GAAW,EAAO,KAAK,6CAA6C,OAClF,MAAO,CAAE,KAAM,KAAM,OAAQ,CAAC,+BAA+B,CAAE,CACtE,CAEA,IAAM,GAAU,EAAU,OAAS,EAAI,EAAY,CAAC,IAAA,EAAS,EAAA,CAAG,KAAK,EAAO,IAAM,EAAU,EAAO,EAAG,CAAM,CAAC,EAE7G,MAAO,CACL,KAAM,CACJ,GAAI,EAAI,EAAI,GAAI,EAAM,MAAM,CAAC,EAC7B,KAAM,OAAO,EAAI,MAAS,SAAW,EAAI,KAAO,IAAA,GAChD,QAAA,EACA,WAAY,EAAM,EAAI,WAAY,OAAO,OAAO,CAAc,EAAG,EAAe,MAAM,EACtF,SAGA,SAAU,EAAI,EAAI,SAAU,CAAC,EAAI,CACnC,EACA,QACF,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.mesh.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.mesh.ts"],"sourcesContent":["/**\n * Turns a floor into triangles: wall solids with their openings cut out, and a floor\n * slab under them.\n *\n * Plain arrays, no renderer and no dependency. `positions`/`normals`/`indices` is the\n * shape every engine takes, so the result feeds three.js, Babylon, a glTF writer or a\n * software rasteriser without this package having an opinion about which.\n *\n * AXES: plan x becomes world x, plan y becomes world z, and world y is up. A plan is\n * drawn in SVG's y-down space, so that mapping is a handedness flip, which is why\n * winding is fixed per face here rather than inherited from the 2D rings.\n *\n * Openings are cut by SPLITTING the wall, not by subtracting solids. Every opening is an\n * axis-aligned rectangle in its wall's own plane, so the wall falls into at most three\n * prisms — under the sill, over the head, and the full-height stretches between openings.\n * That is exact, and it needs no CSG.\n */\n\nimport { dist } from './floorPlan.geometry';\nimport { derivePlan } from './floorPlan.rooms';\nimport { wallCentrelineSpans } from './floorPlan.path';\nimport { triangulate } from './floorPlan.triangulate';\nimport type { PlanFloor, PlanOpening, PlanPoint, PlanWall } from './floorPlan.types';\n\nconst EPS = 1e-6;\n\n/**\n * Millimetres the walls drop past the slab, so the two solids never share a face.\n *\n * A wall overlaps the slab it stands over, because the slab reaches the wall centrelines\n * and the wall straddles them. Land their undersides on the same plane and the two\n * downward faces fight for the same pixels, which speckles the whole underside of the\n * building. One millimetre on a slab of a couple of hundred puts the wall's face clear\n * below and the slab's inside the wall, so each height has exactly one surface at it.\n */\nconst Z_BIAS = 1;\n\nexport type PlanMeshPart = 'wall' | 'floor';\n\nexport interface PlanMeshGroup {\n part: PlanMeshPart;\n /** Offset into `indices`, and how many of them. Draw ranges, or assign materials. */\n start: number;\n count: number;\n}\n\nexport interface PlanMesh {\n /** World-space xyz triples, in millimetres. */\n positions: Float32Array;\n /** Unit face normals, one per vertex. */\n normals: Float32Array;\n indices: Uint32Array;\n groups: PlanMeshGroup[];\n}\n\nexport interface BuildPlanMeshOptions {\n /** Storey height for walls that do not carry their own. Defaults to the floor's. */\n wallHeight?: number;\n /** Lay a slab under each room. Default true. */\n includeFloorSlab?: boolean;\n /** Millimetres. The slab hangs below the floor level. Default 200. */\n slabThickness?: number;\n /**\n * Lift everything by the floor's own elevation, so several storeys stack into one\n * scene. Default true.\n */\n applyElevation?: boolean;\n}\n\n/** Accumulates triangles as flat arrays, with a face normal per triangle. */\nclass MeshBuilder {\n readonly positions: number[] = [];\n readonly normals: number[] = [];\n readonly indices: number[] = [];\n\n /**\n * One triangle, with its vertices duplicated rather than shared.\n *\n * Walls are flat-shaded: sharing a vertex between two faces would average their\n * normals and round off a corner that is physically square.\n */\n triangle(a: number[], b: number[], c: number[]): void {\n const ux = b[0] - a[0];\n const uy = b[1] - a[1];\n const uz = b[2] - a[2];\n const vx = c[0] - a[0];\n const vy = c[1] - a[1];\n const vz = c[2] - a[2];\n let nx = uy * vz - uz * vy;\n let ny = uz * vx - ux * vz;\n let nz = ux * vy - uy * vx;\n const len = Math.hypot(nx, ny, nz);\n if (len < EPS) return; // degenerate: contributes nothing and has no normal\n nx /= len;\n ny /= len;\n nz /= len;\n\n const base = this.positions.length / 3;\n for (const p of [a, b, c]) this.positions.push(p[0], p[1], p[2]);\n for (let i = 0; i < 3; i++) this.normals.push(nx, ny, nz);\n this.indices.push(base, base + 1, base + 2);\n }\n\n /** A planar quad as two triangles, wound so its normal follows a -> b -> c. */\n quad(a: number[], b: number[], c: number[], d: number[]): void {\n this.triangle(a, b, c);\n this.triangle(a, c, d);\n }\n}\n\n/**\n * A wall as a box: its footprint corners in plan, and the heights it spans.\n *\n * The footprint is the centreline offset by half the thickness each way. Walls that meet\n * at a corner overlap slightly inside the joint rather than mitring into each other; for\n * an opaque solid that is invisible from any angle, and it keeps each wall a closed box\n * instead of a shape that depends on its neighbours.\n */\n/** The walls meeting at each node, for mitring a corner. */\nfunction wallsByNode(floor: PlanFloor): Map<string, PlanWall[]> {\n const at = new Map<string, PlanWall[]>();\n for (const wall of Object.values(floor.walls)) {\n for (const id of [wall.a, wall.b]) {\n const list = at.get(id);\n if (list) list.push(wall);\n else at.set(id, [wall]);\n }\n }\n return at;\n}\n\n/** How far a mitre may run before the corner is left square, as multiples of half a wall. */\nconst MITRE_LIMIT = 4;\n\n/**\n * How far the footprint's two edges reach past a node, as a vector to be scaled by half\n * the thickness and added on the wall's left, subtracted on its right.\n *\n * Two walls meeting at a corner both STOP at the shared node, so between them they leave\n * a square of half a thickness uncovered on the outside of the turn — the same notch the\n * 2D renderer fills with a mitre join, cut here through the full height of the wall.\n * Extending both walls to where their edges actually cross closes it.\n *\n * `null` leaves the end square: at a junction there is no single corner to mitre to, at a\n * change of thickness the two edges are offset by different amounts, and past the mitre\n * limit an acute corner would run away into a spike.\n */\nfunction mitreVector(\n floor: PlanFloor,\n wall: PlanWall,\n nodeId: string,\n at: Map<string, PlanWall[]>,\n): PlanPoint | null {\n const here = at.get(nodeId);\n if (!here || here.length !== 2) return null;\n const other = here[0].id === wall.id ? here[1] : here[0];\n if (other.thickness !== wall.thickness) return null;\n\n const node = floor.nodes[nodeId];\n const far = floor.nodes[wall.a === nodeId ? wall.b : wall.a];\n const onward = floor.nodes[other.a === nodeId ? other.b : other.a];\n if (!node || !far || !onward) return null;\n\n // Into the corner along this wall, then out along its neighbour.\n const u = unit(far, node);\n const v = unit(node, onward);\n if (!u || !v) return null;\n\n const along = u.x * v.x + u.y * v.y;\n if (along < -1 + EPS) return null; // doubles back on itself: no corner to speak of\n const nu = { x: -u.y, y: u.x };\n const nv = { x: -v.y, y: v.x };\n const scale = 1 + along;\n const mitre = { x: (nu.x + nv.x) / scale, y: (nu.y + nv.y) / scale };\n if (Math.hypot(mitre.x, mitre.y) > MITRE_LIMIT) return null;\n\n // Returned on the wall's own left, which is `u`'s left at this end.\n return wall.b === nodeId ? mitre : { x: -mitre.x, y: -mitre.y };\n}\n\nfunction unit(from: PlanPoint, to: PlanPoint): PlanPoint | null {\n const len = dist(from, to);\n if (len < EPS) return null;\n return { x: (to.x - from.x) / len, y: (to.y - from.y) / len };\n}\n\n/**\n * The stretch of a wall between two offsets along it, as a footprint quad.\n *\n * Ends that are the wall's true ends are mitred into their neighbour; ends created by an\n * opening are left square, because a jamb is a square face.\n */\nfunction footprintBetween(\n floor: PlanFloor,\n wall: PlanWall,\n from: number,\n to: number,\n at: Map<string, PlanWall[]>,\n): [PlanPoint, PlanPoint, PlanPoint, PlanPoint] | null {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) return null;\n const len = dist(a, b);\n if (len < EPS || to - from < EPS) return null;\n\n const d = unit(a, b)!;\n const half = wall.thickness / 2;\n const n = { x: -d.y * half, y: d.x * half };\n\n const start = { x: a.x + d.x * from, y: a.y + d.y * from };\n const end = { x: a.x + d.x * to, y: a.y + d.y * to };\n\n const mitreA = from < EPS ? mitreVector(floor, wall, wall.a, at) : null;\n const mitreB = to > len - EPS ? mitreVector(floor, wall, wall.b, at) : null;\n\n const offset = (p: PlanPoint, m: PlanPoint | null, sign: 1 | -1) =>\n m\n ? { x: p.x + m.x * half * sign, y: p.y + m.y * half * sign }\n : { x: p.x + n.x * sign, y: p.y + n.y * sign };\n\n return [\n offset(start, mitreA, 1),\n offset(end, mitreB, 1),\n offset(end, mitreB, -1),\n offset(start, mitreA, -1),\n ];\n}\n\n/** A closed box over a footprint, between two heights. */\nfunction box(\n mesh: MeshBuilder,\n foot: readonly PlanPoint[],\n bottom: number,\n top: number,\n): void {\n if (top - bottom < EPS) return;\n const lo = foot.map((p) => [p.x, bottom, p.y]);\n const hi = foot.map((p) => [p.x, top, p.y]);\n\n /*\n * Which way round the footprint runs decides which way the faces look. Plan y becomes\n * world z with y up, which is a handedness flip, so a footprint that reads\n * counter-clockwise in plan comes out clockwise seen from above and its faces would\n * point inwards. Hence the inversion rather than taking the plan winding at its word.\n */\n let twice = 0;\n for (let i = 0; i < foot.length; i++) {\n const p = foot[i];\n const q = foot[(i + 1) % foot.length];\n twice += p.x * q.y - q.x * p.y;\n }\n const ccw = twice < 0;\n\n for (let i = 0; i < foot.length; i++) {\n const j = (i + 1) % foot.length;\n if (ccw) mesh.quad(lo[i], lo[j], hi[j], hi[i]);\n else mesh.quad(lo[j], lo[i], hi[i], hi[j]);\n }\n\n // Caps. A footprint is always convex here — it is a rectangle — so a fan is enough.\n for (let i = 1; i + 1 < foot.length; i++) {\n if (ccw) {\n mesh.triangle(hi[0], hi[i], hi[i + 1]);\n mesh.triangle(lo[0], lo[i + 1], lo[i]);\n } else {\n mesh.triangle(hi[0], hi[i + 1], hi[i]);\n mesh.triangle(lo[0], lo[i], lo[i + 1]);\n }\n }\n}\n\n/** The openings on one wall, clamped to it and sorted along it. */\nfunction openingsOn(floor: PlanFloor, wall: PlanWall, length: number): PlanOpening[] {\n return Object.values(floor.openings)\n .filter((o) => o.wallId === wall.id)\n .filter((o) => o.offset + o.width / 2 > EPS && o.offset - o.width / 2 < length - EPS)\n .sort((a, b) => a.offset - b.offset);\n}\n\n/**\n * Triangles for one floor: every wall, with its openings cut out, and a slab per room.\n *\n * Call it per storey and concatenate to build a whole building; each floor already knows\n * its own elevation.\n */\nexport function buildPlanMesh(floor: PlanFloor, options: BuildPlanMeshOptions = {}): PlanMesh {\n const {\n wallHeight,\n includeFloorSlab = true,\n slabThickness = 200,\n applyElevation = true,\n } = options;\n\n const mesh = new MeshBuilder();\n const groups: PlanMeshGroup[] = [];\n const base = applyElevation ? floor.elevation : 0;\n\n /*\n * `elevation` is the FINISHED FLOOR LEVEL, so a storey's slab hangs below it. Walls\n * start at the slab's underside rather than at the level itself, which is to say they\n * clothe the floor plate the way a facade does instead of stopping short of it.\n *\n * That keeps a wall exactly `floor.height` tall, and makes each storey's walls meet the\n * ones below face to face: this storey starts at `elevation - slab`, and the storey\n * below ends there too. No band of exposed slab between them, and nothing overlapping\n * along the facade.\n */\n const slabDrop = includeFloorSlab ? slabThickness + Z_BIAS : 0;\n\n // ── Walls ──────────────────────────────────────────────────────────────────────\n const atNode = wallsByNode(floor);\n const wallStart = mesh.indices.length;\n for (const wall of Object.values(floor.walls)) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const length = dist(a, b);\n if (length < EPS) continue;\n\n const bottom = base + (wall.baseHeight ?? 0) - slabDrop;\n const top = bottom + (wall.height ?? wallHeight ?? floor.height);\n if (top - bottom < EPS) continue;\n\n const openings = openingsOn(floor, wall, length);\n if (openings.length === 0) {\n const foot = footprintBetween(floor, wall, 0, length, atNode);\n if (foot) box(mesh, foot, bottom, top);\n continue;\n }\n\n // Full-height stretches between the openings, from `wallCentrelineSpans` so the\n // solid is cut exactly where the drawing is.\n for (const [from, to] of wallCentrelineSpans(floor, wall)) {\n const foot = footprintBetween(floor, wall, from, to, atNode);\n if (foot) box(mesh, foot, bottom, top);\n }\n\n // Then the lintel over each opening and the upstand under it.\n for (const opening of openings) {\n const from = Math.max(0, opening.offset - opening.width / 2);\n const to = Math.min(length, opening.offset + opening.width / 2);\n const foot = footprintBetween(floor, wall, from, to, atNode);\n if (!foot) continue;\n const sill = bottom + Math.max(0, opening.sill);\n const head = bottom + Math.max(0, opening.head);\n if (sill > bottom + EPS) box(mesh, foot, bottom, Math.min(sill, top));\n if (head < top - EPS) box(mesh, foot, Math.max(head, bottom), top);\n }\n }\n if (mesh.indices.length > wallStart) {\n groups.push({ part: 'wall', start: wallStart, count: mesh.indices.length - wallStart });\n }\n\n // ── Floor slabs ────────────────────────────────────────────────────────────────\n if (includeFloorSlab) {\n const slabStart = mesh.indices.length;\n for (const room of derivePlan(floor).rooms) {\n const { vertices, indices } = triangulate(room.outer, room.holes);\n if (indices.length === 0) continue;\n const top = base;\n const bottom = base - slabThickness;\n\n for (let i = 0; i < indices.length; i += 3) {\n const t = [vertices[indices[i]], vertices[indices[i + 1]], vertices[indices[i + 2]]];\n const up = t.map((q) => [q.x, top, q.y]);\n const down = t.map((q) => [q.x, bottom, q.y]);\n // `triangulate` returns counter-clockwise triangles in plan space; the y-down to\n // y-up flip reverses that, so the top face is wound the other way here.\n mesh.triangle(up[0], up[2], up[1]);\n mesh.triangle(down[0], down[1], down[2]);\n }\n\n // The slab's edge, so it is a solid rather than two sheets.\n for (const ring of [room.outer, ...room.holes]) {\n for (let i = 0; i < ring.length; i++) {\n const q = ring[i];\n const r = ring[(i + 1) % ring.length];\n // Wound so the face looks away from the solid. Holes come back wound opposite\n // to the outer ring, so walking each ring as it is gives both the right way out.\n mesh.quad(\n [q.x, bottom, q.y],\n [q.x, top, q.y],\n [r.x, top, r.y],\n [r.x, bottom, r.y],\n );\n }\n }\n }\n if (mesh.indices.length > slabStart) {\n groups.push({ part: 'floor', start: slabStart, count: mesh.indices.length - slabStart });\n }\n }\n\n return {\n positions: new Float32Array(mesh.positions),\n normals: new Float32Array(mesh.normals),\n indices: new Uint32Array(mesh.indices),\n groups,\n };\n}\n"],"mappings":"wNAwBA,IAAM,EAAM,KAWN,EAAS,EAmCT,EAAN,KAAkB,8BACe,CAAC,eACH,CAAC,eACD,CAAC,EAQ9B,SAAS,EAAa,EAAa,EAAmB,CACpD,IAAM,EAAK,EAAE,GAAK,EAAE,GACd,EAAK,EAAE,GAAK,EAAE,GACd,EAAK,EAAE,GAAK,EAAE,GACd,EAAK,EAAE,GAAK,EAAE,GACd,EAAK,EAAE,GAAK,EAAE,GACd,EAAK,EAAE,GAAK,EAAE,GAChB,EAAK,EAAK,EAAK,EAAK,EACpB,EAAK,EAAK,EAAK,EAAK,EACpB,EAAK,EAAK,EAAK,EAAK,EAClB,EAAM,KAAK,MAAM,EAAI,EAAI,CAAE,EACjC,GAAI,EAAM,EAAK,OACf,GAAM,EACN,GAAM,EACN,GAAM,EAEN,IAAM,EAAO,KAAK,UAAU,OAAS,EACrC,IAAK,IAAM,IAAK,CAAC,EAAG,EAAG,CAAC,EAAG,KAAK,UAAU,KAAK,EAAE,GAAI,EAAE,GAAI,EAAE,EAAE,EAC/D,IAAK,IAAI,EAAI,EAAG,EAAI,EAAG,IAAK,KAAK,QAAQ,KAAK,EAAI,EAAI,CAAE,EACxD,KAAK,QAAQ,KAAK,EAAM,EAAO,EAAG,EAAO,CAAC,CAC5C,CAGA,KAAK,EAAa,EAAa,EAAa,EAAmB,CAC7D,KAAK,S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,EAAK,KAAK,EAC3C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,IAAK,CACpC,IAAM,EAAI,EAAK,GACT,EAAI,GAAM,EAAI,GAAK,EAAK,QAG9B,EAAK,KACH,CAAC,EAAE,EAAG,EAAQ,EAAE,CAAC,EACjB,CAAC,EAAE,EAAG,EAAK,EAAE,CAAC,EACd,CAAC,EAAE,EAAG,EAAK,EAAE,CAAC,EACd,CAAC,EAAE,EAAG,EAAQ,EAAE,CAAC,CACnB,CACF,CAEJ,CACI,EAAK,QAAQ,OAAS,GACxB,EAAO,KAAK,CAAE,KAAM,QAAS,MAAO,EAAW,MAAO,EAAK,QAAQ,OAAS,CAAU,CAAC,CAE3F,CAEA,MAAO,CACL,UAAW,IAAI,aAAa,EAAK,SAAS,EAC1C,QAAS,IAAI,aAAa,EAAK,OAAO,EACtC,QAAS,IAAI,YAAY,EAAK,OAAO,EACrC,QACF,CACF"}
|
|
1
|
+
{"version":3,"file":"floorPlan.mesh.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.mesh.ts"],"sourcesContent":["/**\n * Turns a floor into triangles: wall solids with their openings cut out, and a floor\n * slab under them.\n *\n * Plain arrays, no renderer and no dependency. `positions`/`normals`/`indices` is the\n * shape every engine takes, so the result feeds three.js, Babylon, a glTF writer or a\n * software rasteriser without this package having an opinion about which.\n *\n * AXES: plan x becomes world x, plan y becomes world z, and world y is up. A plan is\n * drawn in SVG's y-down space, so that mapping is a handedness flip, which is why\n * winding is fixed per face here rather than inherited from the 2D rings.\n *\n * Openings are cut by SPLITTING the wall, not by subtracting solids. Every opening is an\n * axis-aligned rectangle in its wall's own plane, so the wall falls into at most three\n * prisms — under the sill, over the head, and the full-height stretches between openings.\n * That is exact, and it needs no CSG.\n */\n\nimport { dist } from './floorPlan.geometry';\nimport { derivePlan } from './floorPlan.rooms';\nimport { wallCentrelineSpans } from './floorPlan.path';\nimport { triangulate } from './floorPlan.triangulate';\nimport type { PlanFloor, PlanOpening, PlanPoint, PlanWall } from './floorPlan.types';\n\nconst EPS = 1e-6;\n\n/**\n * Millimetres the walls drop past the slab, so the two solids never share a face.\n *\n * A wall overlaps the slab it stands over, because the slab reaches the wall centrelines\n * and the wall straddles them. Land their undersides on the same plane and the two\n * downward faces fight for the same pixels, which speckles the whole underside of the\n * building. One millimetre on a slab of a couple of hundred puts the wall's face clear\n * below and the slab's inside the wall, so each height has exactly one surface at it.\n */\nconst Z_BIAS = 1;\n\nexport type PlanMeshPart = 'wall' | 'floor';\n\nexport interface PlanMeshGroup {\n part: PlanMeshPart;\n /** Offset into `indices`, and how many of them. Draw ranges, or assign materials. */\n start: number;\n count: number;\n}\n\nexport interface PlanMesh {\n /** World-space xyz triples, in millimetres. */\n positions: Float32Array;\n /** Unit face normals, one per vertex. */\n normals: Float32Array;\n indices: Uint32Array;\n groups: PlanMeshGroup[];\n}\n\nexport interface BuildPlanMeshOptions {\n /** Storey height for walls that do not carry their own. Defaults to the floor's. */\n wallHeight?: number;\n /** Lay a slab under each room. Default true. */\n includeFloorSlab?: boolean;\n /** Millimetres. The slab hangs below the floor level. Default 200. */\n slabThickness?: number;\n /**\n * Lift everything by the floor's own elevation, so several storeys stack into one\n * scene. Default true.\n */\n applyElevation?: boolean;\n}\n\n/** Accumulates triangles as flat arrays, with a face normal per triangle. */\nclass MeshBuilder {\n readonly positions: number[] = [];\n readonly normals: number[] = [];\n readonly indices: number[] = [];\n\n /**\n * One triangle, with its vertices duplicated rather than shared.\n *\n * Walls are flat-shaded: sharing a vertex between two faces would average their\n * normals and round off a corner that is physically square.\n */\n triangle(a: number[], b: number[], c: number[]): void {\n const ux = b[0] - a[0];\n const uy = b[1] - a[1];\n const uz = b[2] - a[2];\n const vx = c[0] - a[0];\n const vy = c[1] - a[1];\n const vz = c[2] - a[2];\n let nx = uy * vz - uz * vy;\n let ny = uz * vx - ux * vz;\n let nz = ux * vy - uy * vx;\n const len = Math.hypot(nx, ny, nz);\n if (len < EPS) return; // degenerate: contributes nothing and has no normal\n nx /= len;\n ny /= len;\n nz /= len;\n\n const base = this.positions.length / 3;\n for (const p of [a, b, c]) this.positions.push(p[0], p[1], p[2]);\n for (let i = 0; i < 3; i++) this.normals.push(nx, ny, nz);\n this.indices.push(base, base + 1, base + 2);\n }\n\n /** A planar quad as two triangles, wound so its normal follows a -> b -> c. */\n quad(a: number[], b: number[], c: number[], d: number[]): void {\n this.triangle(a, b, c);\n this.triangle(a, c, d);\n }\n}\n\n/**\n * A wall as a box: its footprint corners in plan, and the heights it spans.\n *\n * The footprint is the centreline offset by half the thickness each way. Walls that meet\n * at a corner overlap slightly inside the joint rather than mitring into each other; for\n * an opaque solid that is invisible from any angle, and it keeps each wall a closed box\n * instead of a shape that depends on its neighbours.\n */\n/** The walls meeting at each node, for mitring a corner. */\nfunction wallsByNode(floor: PlanFloor): Map<string, PlanWall[]> {\n const at = new Map<string, PlanWall[]>();\n for (const wall of Object.values(floor.walls)) {\n for (const id of [wall.a, wall.b]) {\n const list = at.get(id);\n if (list) list.push(wall);\n else at.set(id, [wall]);\n }\n }\n return at;\n}\n\n/** How far a mitre may run before the corner is left square, as multiples of half a wall. */\nconst MITRE_LIMIT = 4;\n\n/**\n * How far the footprint's two edges reach past a node, as a vector to be scaled by half\n * the thickness and added on the wall's left, subtracted on its right.\n *\n * Two walls meeting at a corner both STOP at the shared node, so between them they leave\n * a square of half a thickness uncovered on the outside of the turn — the same notch the\n * 2D renderer fills with a mitre join, cut here through the full height of the wall.\n * Extending both walls to where their edges actually cross closes it.\n *\n * `null` leaves the end square: at a junction there is no single corner to mitre to, at a\n * change of thickness the two edges are offset by different amounts, and past the mitre\n * limit an acute corner would run away into a spike.\n */\nfunction mitreVector(floor: PlanFloor, wall: PlanWall, nodeId: string, at: Map<string, PlanWall[]>): PlanPoint | null {\n const here = at.get(nodeId);\n if (!here || here.length !== 2) return null;\n const other = here[0].id === wall.id ? here[1] : here[0];\n if (other.thickness !== wall.thickness) return null;\n\n const node = floor.nodes[nodeId];\n const far = floor.nodes[wall.a === nodeId ? wall.b : wall.a];\n const onward = floor.nodes[other.a === nodeId ? other.b : other.a];\n if (!node || !far || !onward) return null;\n\n // Into the corner along this wall, then out along its neighbour.\n const u = unit(far, node);\n const v = unit(node, onward);\n if (!u || !v) return null;\n\n const along = u.x * v.x + u.y * v.y;\n if (along < -1 + EPS) return null; // doubles back on itself: no corner to speak of\n const nu = { x: -u.y, y: u.x };\n const nv = { x: -v.y, y: v.x };\n const scale = 1 + along;\n const mitre = { x: (nu.x + nv.x) / scale, y: (nu.y + nv.y) / scale };\n if (Math.hypot(mitre.x, mitre.y) > MITRE_LIMIT) return null;\n\n // Returned on the wall's own left, which is `u`'s left at this end.\n return wall.b === nodeId ? mitre : { x: -mitre.x, y: -mitre.y };\n}\n\nfunction unit(from: PlanPoint, to: PlanPoint): PlanPoint | null {\n const len = dist(from, to);\n if (len < EPS) return null;\n return { x: (to.x - from.x) / len, y: (to.y - from.y) / len };\n}\n\n/**\n * The stretch of a wall between two offsets along it, as a footprint quad.\n *\n * Ends that are the wall's true ends are mitred into their neighbour; ends created by an\n * opening are left square, because a jamb is a square face.\n */\nfunction footprintBetween(\n floor: PlanFloor,\n wall: PlanWall,\n from: number,\n to: number,\n at: Map<string, PlanWall[]>,\n): [PlanPoint, PlanPoint, PlanPoint, PlanPoint] | null {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) return null;\n const len = dist(a, b);\n if (len < EPS || to - from < EPS) return null;\n\n const d = unit(a, b)!;\n const half = wall.thickness / 2;\n const n = { x: -d.y * half, y: d.x * half };\n\n const start = { x: a.x + d.x * from, y: a.y + d.y * from };\n const end = { x: a.x + d.x * to, y: a.y + d.y * to };\n\n const mitreA = from < EPS ? mitreVector(floor, wall, wall.a, at) : null;\n const mitreB = to > len - EPS ? mitreVector(floor, wall, wall.b, at) : null;\n\n const offset = (p: PlanPoint, m: PlanPoint | null, sign: 1 | -1) =>\n m ? { x: p.x + m.x * half * sign, y: p.y + m.y * half * sign } : { x: p.x + n.x * sign, y: p.y + n.y * sign };\n\n return [offset(start, mitreA, 1), offset(end, mitreB, 1), offset(end, mitreB, -1), offset(start, mitreA, -1)];\n}\n\n/** A closed box over a footprint, between two heights. */\nfunction box(mesh: MeshBuilder, foot: readonly PlanPoint[], bottom: number, top: number): void {\n if (top - bottom < EPS) return;\n const lo = foot.map((p) => [p.x, bottom, p.y]);\n const hi = foot.map((p) => [p.x, top, p.y]);\n\n /*\n * Which way round the footprint runs decides which way the faces look. Plan y becomes\n * world z with y up, which is a handedness flip, so a footprint that reads\n * counter-clockwise in plan comes out clockwise seen from above and its faces would\n * point inwards. Hence the inversion rather than taking the plan winding at its word.\n */\n let twice = 0;\n for (let i = 0; i < foot.length; i++) {\n const p = foot[i];\n const q = foot[(i + 1) % foot.length];\n twice += p.x * q.y - q.x * p.y;\n }\n const ccw = twice < 0;\n\n for (let i = 0; i < foot.length; i++) {\n const j = (i + 1) % foot.length;\n if (ccw) mesh.quad(lo[i], lo[j], hi[j], hi[i]);\n else mesh.quad(lo[j], lo[i], hi[i], hi[j]);\n }\n\n // Caps. A footprint is always convex here — it is a rectangle — so a fan is enough.\n for (let i = 1; i + 1 < foot.length; i++) {\n if (ccw) {\n mesh.triangle(hi[0], hi[i], hi[i + 1]);\n mesh.triangle(lo[0], lo[i + 1], lo[i]);\n } else {\n mesh.triangle(hi[0], hi[i + 1], hi[i]);\n mesh.triangle(lo[0], lo[i], lo[i + 1]);\n }\n }\n}\n\n/** The openings on one wall, clamped to it and sorted along it. */\nfunction openingsOn(floor: PlanFloor, wall: PlanWall, length: number): PlanOpening[] {\n return Object.values(floor.openings)\n .filter((o) => o.wallId === wall.id)\n .filter((o) => o.offset + o.width / 2 > EPS && o.offset - o.width / 2 < length - EPS)\n .sort((a, b) => a.offset - b.offset);\n}\n\n/**\n * Triangles for one floor: every wall, with its openings cut out, and a slab per room.\n *\n * Call it per storey and concatenate to build a whole building; each floor already knows\n * its own elevation.\n */\nexport function buildPlanMesh(floor: PlanFloor, options: BuildPlanMeshOptions = {}): PlanMesh {\n const { wallHeight, includeFloorSlab = true, slabThickness = 200, applyElevation = true } = options;\n\n const mesh = new MeshBuilder();\n const groups: PlanMeshGroup[] = [];\n const base = applyElevation ? floor.elevation : 0;\n\n /*\n * `elevation` is the FINISHED FLOOR LEVEL, so a storey's slab hangs below it. Walls\n * start at the slab's underside rather than at the level itself, which is to say they\n * clothe the floor plate the way a facade does instead of stopping short of it.\n *\n * That keeps a wall exactly `floor.height` tall, and makes each storey's walls meet the\n * ones below face to face: this storey starts at `elevation - slab`, and the storey\n * below ends there too. No band of exposed slab between them, and nothing overlapping\n * along the facade.\n */\n const slabDrop = includeFloorSlab ? slabThickness + Z_BIAS : 0;\n\n // ── Walls ──────────────────────────────────────────────────────────────────────\n const atNode = wallsByNode(floor);\n const wallStart = mesh.indices.length;\n for (const wall of Object.values(floor.walls)) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const length = dist(a, b);\n if (length < EPS) continue;\n\n const bottom = base + (wall.baseHeight ?? 0) - slabDrop;\n const top = bottom + (wall.height ?? wallHeight ?? floor.height);\n if (top - bottom < EPS) continue;\n\n const openings = openingsOn(floor, wall, length);\n if (openings.length === 0) {\n const foot = footprintBetween(floor, wall, 0, length, atNode);\n if (foot) box(mesh, foot, bottom, top);\n continue;\n }\n\n // Full-height stretches between the openings, from `wallCentrelineSpans` so the\n // solid is cut exactly where the drawing is.\n for (const [from, to] of wallCentrelineSpans(floor, wall)) {\n const foot = footprintBetween(floor, wall, from, to, atNode);\n if (foot) box(mesh, foot, bottom, top);\n }\n\n // Then the lintel over each opening and the upstand under it.\n for (const opening of openings) {\n const from = Math.max(0, opening.offset - opening.width / 2);\n const to = Math.min(length, opening.offset + opening.width / 2);\n const foot = footprintBetween(floor, wall, from, to, atNode);\n if (!foot) continue;\n const sill = bottom + Math.max(0, opening.sill);\n const head = bottom + Math.max(0, opening.head);\n if (sill > bottom + EPS) box(mesh, foot, bottom, Math.min(sill, top));\n if (head < top - EPS) box(mesh, foot, Math.max(head, bottom), top);\n }\n }\n if (mesh.indices.length > wallStart) {\n groups.push({ part: 'wall', start: wallStart, count: mesh.indices.length - wallStart });\n }\n\n // ── Floor slabs ────────────────────────────────────────────────────────────────\n if (includeFloorSlab) {\n const slabStart = mesh.indices.length;\n for (const room of derivePlan(floor).rooms) {\n const { vertices, indices } = triangulate(room.outer, room.holes);\n if (indices.length === 0) continue;\n const top = base;\n const bottom = base - slabThickness;\n\n for (let i = 0; i < indices.length; i += 3) {\n const t = [vertices[indices[i]], vertices[indices[i + 1]], vertices[indices[i + 2]]];\n const up = t.map((q) => [q.x, top, q.y]);\n const down = t.map((q) => [q.x, bottom, q.y]);\n // `triangulate` returns counter-clockwise triangles in plan space; the y-down to\n // y-up flip reverses that, so the top face is wound the other way here.\n mesh.triangle(up[0], up[2], up[1]);\n mesh.triangle(down[0], down[1], down[2]);\n }\n\n // The slab's edge, so it is a solid rather than two sheets.\n for (const ring of [room.outer, ...room.holes]) {\n for (let i = 0; i < ring.length; i++) {\n const q = ring[i];\n const r = ring[(i + 1) % ring.length];\n // Wound so the face looks away from the solid. Holes come back wound opposite\n // to the outer ring, so walking each ring as it is gives both the right way out.\n mesh.quad([q.x, bottom, q.y], [q.x, top, q.y], [r.x, top, r.y], [r.x, bottom, r.y]);\n }\n }\n }\n if (mesh.indices.length > slabStart) {\n groups.push({ part: 'floor', start: slabStart, count: mesh.indices.length - slabStart });\n }\n }\n\n return {\n positions: new Float32Array(mesh.positions),\n normals: new Float32Array(mesh.normals),\n indices: new Uint32Array(mesh.indices),\n groups,\n };\n}\n"],"mappings":"wNAwBA,IAAM,EAAM,KAWN,EAAS,EAmCT,EAAN,KAAkB,eACe,KAAA,UAAA,CAAC,EACH,KAAA,QAAA,CAAC,EACD,KAAA,QAAA,CAAC,EAQ9B,SAAS,EAAa,EAAa,EAAmB,CACpD,IAAM,EAAK,EAAE,GAAK,EAA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